Commit eea203fe authored by Joe Perches's avatar Joe Perches Committed by Paul E. McKenney

rcu: Use pr_alert/pr_cont for printing logs

User pr_alert/pr_cont for printing the logs from rcutorture module directly
instead of writing it to a buffer and then printing it. This allows us from not
having to allocate such buffers. Also remove a resulting empty function.

I tested this using the parse-torture.sh script as follows:

$ dmesg | grep torture > log.txt
$ bash parse-torture.sh log.txt test
$

There were no warnings which means that parsing went fine.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarPranith Kumar <bobby.prani@gmail.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 188c1e89
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
/* Definitions for online/offline exerciser. */ /* Definitions for online/offline exerciser. */
int torture_onoff_init(long ooholdoff, long oointerval); int torture_onoff_init(long ooholdoff, long oointerval);
char *torture_onoff_stats(char *page); void torture_onoff_stats(void);
bool torture_onoff_failures(void); bool torture_onoff_failures(void);
/* Low-rider random number generator. */ /* Low-rider random number generator. */
......
...@@ -242,7 +242,7 @@ struct rcu_torture_ops { ...@@ -242,7 +242,7 @@ struct rcu_torture_ops {
void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
void (*cb_barrier)(void); void (*cb_barrier)(void);
void (*fqs)(void); void (*fqs)(void);
void (*stats)(char *page); void (*stats)(void);
int irq_capable; int irq_capable;
int can_boost; int can_boost;
const char *name; const char *name;
...@@ -525,21 +525,21 @@ static void srcu_torture_barrier(void) ...@@ -525,21 +525,21 @@ static void srcu_torture_barrier(void)
srcu_barrier(&srcu_ctl); srcu_barrier(&srcu_ctl);
} }
static void srcu_torture_stats(char *page) static void srcu_torture_stats(void)
{ {
int cpu; int cpu;
int idx = srcu_ctl.completed & 0x1; int idx = srcu_ctl.completed & 0x1;
page += sprintf(page, "%s%s per-CPU(idx=%d):", pr_alert("%s%s per-CPU(idx=%d):",
torture_type, TORTURE_FLAG, idx); torture_type, TORTURE_FLAG, idx);
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
long c0, c1; long c0, c1;
c0 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx]; c0 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx];
c1 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]; c1 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx];
page += sprintf(page, " %d(%ld,%ld)", cpu, c0, c1); pr_cont(" %d(%ld,%ld)", cpu, c0, c1);
} }
sprintf(page, "\n"); pr_cont("\n");
} }
static void srcu_torture_synchronize_expedited(void) static void srcu_torture_synchronize_expedited(void)
...@@ -1031,10 +1031,15 @@ rcu_torture_reader(void *arg) ...@@ -1031,10 +1031,15 @@ rcu_torture_reader(void *arg)
} }
/* /*
* Create an RCU-torture statistics message in the specified buffer. * Print torture statistics. Caller must ensure that there is only
* one call to this function at a given time!!! This is normally
* accomplished by relying on the module system to only have one copy
* of the module loaded, and then by giving the rcu_torture_stats
* kthread full control (or the init/cleanup functions when rcu_torture_stats
* thread is not running).
*/ */
static void static void
rcu_torture_printk(char *page) rcu_torture_stats_print(void)
{ {
int cpu; int cpu;
int i; int i;
...@@ -1052,55 +1057,60 @@ rcu_torture_printk(char *page) ...@@ -1052,55 +1057,60 @@ rcu_torture_printk(char *page)
if (pipesummary[i] != 0) if (pipesummary[i] != 0)
break; break;
} }
page += sprintf(page, "%s%s ", torture_type, TORTURE_FLAG);
page += sprintf(page, pr_alert("%s%s ", torture_type, TORTURE_FLAG);
"rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ", pr_cont("rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",
rcu_torture_current, rcu_torture_current,
rcu_torture_current_version, rcu_torture_current_version,
list_empty(&rcu_torture_freelist), list_empty(&rcu_torture_freelist),
atomic_read(&n_rcu_torture_alloc), atomic_read(&n_rcu_torture_alloc),
atomic_read(&n_rcu_torture_alloc_fail), atomic_read(&n_rcu_torture_alloc_fail),
atomic_read(&n_rcu_torture_free)); atomic_read(&n_rcu_torture_free));
page += sprintf(page, "rtmbe: %d rtbke: %ld rtbre: %ld ", pr_cont("rtmbe: %d rtbke: %ld rtbre: %ld ",
atomic_read(&n_rcu_torture_mberror), atomic_read(&n_rcu_torture_mberror),
n_rcu_torture_boost_ktrerror, n_rcu_torture_boost_ktrerror,
n_rcu_torture_boost_rterror); n_rcu_torture_boost_rterror);
page += sprintf(page, "rtbf: %ld rtb: %ld nt: %ld ", pr_cont("rtbf: %ld rtb: %ld nt: %ld ",
n_rcu_torture_boost_failure, n_rcu_torture_boost_failure,
n_rcu_torture_boosts, n_rcu_torture_boosts,
n_rcu_torture_timers); n_rcu_torture_timers);
page = torture_onoff_stats(page); torture_onoff_stats();
page += sprintf(page, "barrier: %ld/%ld:%ld", pr_cont("barrier: %ld/%ld:%ld\n",
n_barrier_successes, n_barrier_successes,
n_barrier_attempts, n_barrier_attempts,
n_rcu_torture_barrier_error); n_rcu_torture_barrier_error);
page += sprintf(page, "\n%s%s ", torture_type, TORTURE_FLAG);
pr_alert("%s%s ", torture_type, TORTURE_FLAG);
if (atomic_read(&n_rcu_torture_mberror) != 0 || if (atomic_read(&n_rcu_torture_mberror) != 0 ||
n_rcu_torture_barrier_error != 0 || n_rcu_torture_barrier_error != 0 ||
n_rcu_torture_boost_ktrerror != 0 || n_rcu_torture_boost_ktrerror != 0 ||
n_rcu_torture_boost_rterror != 0 || n_rcu_torture_boost_rterror != 0 ||
n_rcu_torture_boost_failure != 0 || n_rcu_torture_boost_failure != 0 ||
i > 1) { i > 1) {
page += sprintf(page, "!!! "); pr_cont("%s", "!!! ");
atomic_inc(&n_rcu_torture_error); atomic_inc(&n_rcu_torture_error);
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
} }
page += sprintf(page, "Reader Pipe: "); pr_cont("Reader Pipe: ");
for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
page += sprintf(page, " %ld", pipesummary[i]); pr_cont(" %ld", pipesummary[i]);
page += sprintf(page, "\n%s%s ", torture_type, TORTURE_FLAG); pr_cont("\n");
page += sprintf(page, "Reader Batch: ");
pr_alert("%s%s ", torture_type, TORTURE_FLAG);
pr_cont("Reader Batch: ");
for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
page += sprintf(page, " %ld", batchsummary[i]); pr_cont(" %ld", batchsummary[i]);
page += sprintf(page, "\n%s%s ", torture_type, TORTURE_FLAG); pr_cont("\n");
page += sprintf(page, "Free-Block Circulation: ");
pr_alert("%s%s ", torture_type, TORTURE_FLAG);
pr_cont("Free-Block Circulation: ");
for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) { for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
page += sprintf(page, " %d", pr_cont(" %d", atomic_read(&rcu_torture_wcount[i]));
atomic_read(&rcu_torture_wcount[i]));
} }
page += sprintf(page, "\n"); pr_cont("\n");
if (cur_ops->stats) if (cur_ops->stats)
cur_ops->stats(page); cur_ops->stats();
if (rtcv_snap == rcu_torture_current_version && if (rtcv_snap == rcu_torture_current_version &&
rcu_torture_current != NULL) { rcu_torture_current != NULL) {
int __maybe_unused flags; int __maybe_unused flags;
...@@ -1109,8 +1119,7 @@ rcu_torture_printk(char *page) ...@@ -1109,8 +1119,7 @@ rcu_torture_printk(char *page)
rcutorture_get_gp_data(cur_ops->ttype, rcutorture_get_gp_data(cur_ops->ttype,
&flags, &gpnum, &completed); &flags, &gpnum, &completed);
page += sprintf(page, pr_alert("??? Writer stall state %d g%lu c%lu f%#x\n",
"??? Writer stall state %d g%lu c%lu f%#x\n",
rcu_torture_writer_state, rcu_torture_writer_state,
gpnum, completed, flags); gpnum, completed, flags);
show_rcu_gp_kthreads(); show_rcu_gp_kthreads();
...@@ -1119,30 +1128,6 @@ rcu_torture_printk(char *page) ...@@ -1119,30 +1128,6 @@ rcu_torture_printk(char *page)
rtcv_snap = rcu_torture_current_version; rtcv_snap = rcu_torture_current_version;
} }
/*
* Print torture statistics. Caller must ensure that there is only
* one call to this function at a given time!!! This is normally
* accomplished by relying on the module system to only have one copy
* of the module loaded, and then by giving the rcu_torture_stats
* kthread full control (or the init/cleanup functions when rcu_torture_stats
* thread is not running).
*/
static void
rcu_torture_stats_print(void)
{
int size = nr_cpu_ids * 200 + 8192;
char *buf;
buf = kmalloc(size, GFP_KERNEL);
if (!buf) {
pr_err("rcu-torture: Out of memory, need: %d", size);
return;
}
rcu_torture_printk(buf);
pr_alert("%s", buf);
kfree(buf);
}
/* /*
* Periodically prints torture statistics, if periodic statistics printing * Periodically prints torture statistics, if periodic statistics printing
* was specified via the stat_interval module parameter. * was specified via the stat_interval module parameter.
......
...@@ -211,18 +211,16 @@ EXPORT_SYMBOL_GPL(torture_onoff_cleanup); ...@@ -211,18 +211,16 @@ EXPORT_SYMBOL_GPL(torture_onoff_cleanup);
/* /*
* Print online/offline testing statistics. * Print online/offline testing statistics.
*/ */
char *torture_onoff_stats(char *page) void torture_onoff_stats(void)
{ {
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
page += sprintf(page, pr_cont("onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ",
"onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ",
n_online_successes, n_online_attempts, n_online_successes, n_online_attempts,
n_offline_successes, n_offline_attempts, n_offline_successes, n_offline_attempts,
min_online, max_online, min_online, max_online,
min_offline, max_offline, min_offline, max_offline,
sum_online, sum_offline, HZ); sum_online, sum_offline, HZ);
#endif /* #ifdef CONFIG_HOTPLUG_CPU */ #endif /* #ifdef CONFIG_HOTPLUG_CPU */
return page;
} }
EXPORT_SYMBOL_GPL(torture_onoff_stats); EXPORT_SYMBOL_GPL(torture_onoff_stats);
......
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