Commit 9880eb87 authored by Li Zhijian's avatar Li Zhijian Committed by Paul E. McKenney

refscale: Prevent buffer to pr_alert() being too long

0Day/LKP observed that the refscale results fail to complete when larger
values of nrun (such as 300) are specified.  The problem is that printk()
can accept at most a 1024-byte buffer.  This commit therefore prints
the buffer whenever its length exceeds 800 bytes.

CC: Philip Li <philip.li@intel.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarLi Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent c30c8763
...@@ -604,7 +604,7 @@ static u64 process_durations(int n) ...@@ -604,7 +604,7 @@ static u64 process_durations(int n)
char *buf; char *buf;
u64 sum = 0; u64 sum = 0;
buf = kmalloc(128 + nreaders * 32, GFP_KERNEL); buf = kmalloc(800 + 64, GFP_KERNEL);
if (!buf) if (!buf)
return 0; return 0;
buf[0] = 0; buf[0] = 0;
...@@ -617,13 +617,15 @@ static u64 process_durations(int n) ...@@ -617,13 +617,15 @@ static u64 process_durations(int n)
if (i % 5 == 0) if (i % 5 == 0)
strcat(buf, "\n"); strcat(buf, "\n");
if (strlen(buf) >= 800) {
pr_alert("%s", buf);
buf[0] = 0;
}
strcat(buf, buf1); strcat(buf, buf1);
sum += rt->last_duration_ns; sum += rt->last_duration_ns;
} }
strcat(buf, "\n"); pr_alert("%s\n", buf);
SCALEOUT("%s\n", buf);
kfree(buf); kfree(buf);
return sum; return sum;
...@@ -647,7 +649,7 @@ static int main_func(void *arg) ...@@ -647,7 +649,7 @@ static int main_func(void *arg)
VERBOSE_SCALEOUT("main_func task started"); VERBOSE_SCALEOUT("main_func task started");
result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL); result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
buf = kzalloc(64 + nruns * 32, GFP_KERNEL); buf = kzalloc(800 + 64, GFP_KERNEL);
if (!result_avg || !buf) { if (!result_avg || !buf) {
VERBOSE_SCALEOUT_ERRSTRING("out of memory"); VERBOSE_SCALEOUT_ERRSTRING("out of memory");
goto oom_exit; goto oom_exit;
...@@ -695,10 +697,7 @@ static int main_func(void *arg) ...@@ -695,10 +697,7 @@ static int main_func(void *arg)
// Print the average of all experiments // Print the average of all experiments
SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n"); SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
buf[0] = 0; pr_alert("Runs\tTime(ns)\n");
strcat(buf, "\n");
strcat(buf, "Runs\tTime(ns)\n");
for (exp = 0; exp < nruns; exp++) { for (exp = 0; exp < nruns; exp++) {
u64 avg; u64 avg;
u32 rem; u32 rem;
...@@ -706,9 +705,13 @@ static int main_func(void *arg) ...@@ -706,9 +705,13 @@ static int main_func(void *arg)
avg = div_u64_rem(result_avg[exp], 1000, &rem); avg = div_u64_rem(result_avg[exp], 1000, &rem);
sprintf(buf1, "%d\t%llu.%03u\n", exp + 1, avg, rem); sprintf(buf1, "%d\t%llu.%03u\n", exp + 1, avg, rem);
strcat(buf, buf1); strcat(buf, buf1);
if (strlen(buf) >= 800) {
pr_alert("%s", buf);
buf[0] = 0;
}
} }
SCALEOUT("%s", buf); pr_alert("%s", buf);
oom_exit: oom_exit:
// This will shutdown everything including us. // This will shutdown everything including us.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment