Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages

From: Sergey Senozhatsky
Date: Mon Sep 18 2017 - 03:03:24 EST


On (09/14/17 16:01), Luck, Tony wrote:
>
> > let's hear from ia64 and ppc64 guys.
>
> If you write a patch, I can try it on some ia64 h/w.
>
> Please include some test cases (perhaps as a second patch that adds a few good/bad %pF and %pS
> to some code (both in base kernel, and in a module).

Hello,

I sent out an RFC patch set.


would the following test case work for you?

kernel)

echo 1 > /proc/sys/vm/drop_caches

module)

modprobe zram
echo 100M > /sys/block/zram0/disksize


---

drivers/block/zram/zram_drv.c | 15 +++++++++++++++
fs/drop_caches.c | 11 +++++++++++
2 files changed, 26 insertions(+)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 2981c27d3aae..ac92aaeaced0 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1508,6 +1508,12 @@ static int zram_add(void)
struct request_queue *queue;
int ret, device_id;

+ printk("printk#13 %pF\n", (void *)_RET_IP_);
+ printk("printk#14 %pS\n", (void *)_RET_IP_);
+
+ printk("printk#15 %pF\n", __builtin_return_address(0));
+ printk("printk#16 %pS\n", __builtin_return_address(0));
+
zram = kzalloc(sizeof(struct zram), GFP_KERNEL);
if (!zram)
return -ENOMEM;
@@ -1730,6 +1736,15 @@ static int __init zram_init(void)
{
int ret;

+ printk("printk#7 %pF\n", zram_init);
+ printk("printk#8 %pS\n", zram_init);
+
+ printk("printk#9 %pF\n", (void *)_RET_IP_);
+ printk("printk#10 %pS\n", (void *)_RET_IP_);
+
+ printk("printk#11 %pF\n", __builtin_return_address(0));
+ printk("printk#12 %pS\n", __builtin_return_address(0));
+
ret = cpuhp_setup_state_multi(CPUHP_ZCOMP_PREPARE, "block/zram:prepare",
zcomp_cpu_up_prepare, zcomp_cpu_dead);
if (ret < 0)
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d72d52b90433..3db4adcac78d 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -39,11 +39,22 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
iput(toput_inode);
}

+#include <linux/sched.h>
+
int drop_caches_sysctl_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
{
int ret;

+ printk("printk#1 %pF\n", schedule_timeout);
+ printk("printk#2 %pS\n", schedule_timeout);
+
+ printk("printk#3 %pF\n", (void *)_RET_IP_);
+ printk("printk#4 %pS\n", (void *)_RET_IP_);
+
+ printk("printk#5 %pF\n", __builtin_return_address(0));
+ printk("printk#6 %pS\n", __builtin_return_address(0));
+
ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
if (ret)
return ret;