diff options
author | Joe Perches <joe@perches.com> | 2014-07-14 09:16:15 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-09-07 19:24:47 -0400 |
commit | eea203fea3484598280a07fe503e025e886297fb (patch) | |
tree | 7456a2d44438ebbb4badad2d1a3818008c85c1d4 | |
parent | 188c1e896c0c28ac98809d11b6f29523805b34ef (diff) |
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: Joe Perches <joe@perches.com>
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
-rw-r--r-- | include/linux/torture.h | 2 | ||||
-rw-r--r-- | kernel/rcu/rcutorture.c | 127 | ||||
-rw-r--r-- | kernel/torture.c | 16 |
3 files changed, 64 insertions, 81 deletions
diff --git a/include/linux/torture.h b/include/linux/torture.h index 5ca58fcbaf1b..fec46f8c08eb 100644 --- a/include/linux/torture.h +++ b/include/linux/torture.h | |||
@@ -51,7 +51,7 @@ | |||
51 | 51 | ||
52 | /* Definitions for online/offline exerciser. */ | 52 | /* Definitions for online/offline exerciser. */ |
53 | int torture_onoff_init(long ooholdoff, long oointerval); | 53 | int torture_onoff_init(long ooholdoff, long oointerval); |
54 | char *torture_onoff_stats(char *page); | 54 | void torture_onoff_stats(void); |
55 | bool torture_onoff_failures(void); | 55 | bool torture_onoff_failures(void); |
56 | 56 | ||
57 | /* Low-rider random number generator. */ | 57 | /* Low-rider random number generator. */ |
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 7e67711cbae8..ff4f0c756dee 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c | |||
@@ -242,7 +242,7 @@ struct rcu_torture_ops { | |||
242 | void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); | 242 | void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); |
243 | void (*cb_barrier)(void); | 243 | void (*cb_barrier)(void); |
244 | void (*fqs)(void); | 244 | void (*fqs)(void); |
245 | void (*stats)(char *page); | 245 | void (*stats)(void); |
246 | int irq_capable; | 246 | int irq_capable; |
247 | int can_boost; | 247 | int can_boost; |
248 | const char *name; | 248 | const char *name; |
@@ -525,21 +525,21 @@ static void srcu_torture_barrier(void) | |||
525 | srcu_barrier(&srcu_ctl); | 525 | srcu_barrier(&srcu_ctl); |
526 | } | 526 | } |
527 | 527 | ||
528 | static void srcu_torture_stats(char *page) | 528 | static void srcu_torture_stats(void) |
529 | { | 529 | { |
530 | int cpu; | 530 | int cpu; |
531 | int idx = srcu_ctl.completed & 0x1; | 531 | int idx = srcu_ctl.completed & 0x1; |
532 | 532 | ||
533 | page += sprintf(page, "%s%s per-CPU(idx=%d):", | 533 | pr_alert("%s%s per-CPU(idx=%d):", |
534 | torture_type, TORTURE_FLAG, idx); | 534 | torture_type, TORTURE_FLAG, idx); |
535 | for_each_possible_cpu(cpu) { | 535 | for_each_possible_cpu(cpu) { |
536 | long c0, c1; | 536 | long c0, c1; |
537 | 537 | ||
538 | c0 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx]; | 538 | c0 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx]; |
539 | c1 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]; | 539 | c1 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]; |
540 | page += sprintf(page, " %d(%ld,%ld)", cpu, c0, c1); | 540 | pr_cont(" %d(%ld,%ld)", cpu, c0, c1); |
541 | } | 541 | } |
542 | sprintf(page, "\n"); | 542 | pr_cont("\n"); |
543 | } | 543 | } |
544 | 544 | ||
545 | static void srcu_torture_synchronize_expedited(void) | 545 | static void srcu_torture_synchronize_expedited(void) |
@@ -1031,10 +1031,15 @@ rcu_torture_reader(void *arg) | |||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | /* | 1033 | /* |
1034 | * Create an RCU-torture statistics message in the specified buffer. | 1034 | * Print torture statistics. Caller must ensure that there is only |
1035 | * one call to this function at a given time!!! This is normally | ||
1036 | * accomplished by relying on the module system to only have one copy | ||
1037 | * of the module loaded, and then by giving the rcu_torture_stats | ||
1038 | * kthread full control (or the init/cleanup functions when rcu_torture_stats | ||
1039 | * thread is not running). | ||
1035 | */ | 1040 | */ |
1036 | static void | 1041 | static void |
1037 | rcu_torture_printk(char *page) | 1042 | rcu_torture_stats_print(void) |
1038 | { | 1043 | { |
1039 | int cpu; | 1044 | int cpu; |
1040 | int i; | 1045 | int i; |
@@ -1052,55 +1057,60 @@ rcu_torture_printk(char *page) | |||
1052 | if (pipesummary[i] != 0) | 1057 | if (pipesummary[i] != 0) |
1053 | break; | 1058 | break; |
1054 | } | 1059 | } |
1055 | page += sprintf(page, "%s%s ", torture_type, TORTURE_FLAG); | 1060 | |
1056 | page += sprintf(page, | 1061 | pr_alert("%s%s ", torture_type, TORTURE_FLAG); |
1057 | "rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ", | 1062 | pr_cont("rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ", |
1058 | rcu_torture_current, | 1063 | rcu_torture_current, |
1059 | rcu_torture_current_version, | 1064 | rcu_torture_current_version, |
1060 | list_empty(&rcu_torture_freelist), | 1065 | list_empty(&rcu_torture_freelist), |
1061 | atomic_read(&n_rcu_torture_alloc), | 1066 | atomic_read(&n_rcu_torture_alloc), |
1062 | atomic_read(&n_rcu_torture_alloc_fail), | 1067 | atomic_read(&n_rcu_torture_alloc_fail), |
1063 | atomic_read(&n_rcu_torture_free)); | 1068 | atomic_read(&n_rcu_torture_free)); |
1064 | page += sprintf(page, "rtmbe: %d rtbke: %ld rtbre: %ld ", | 1069 | pr_cont("rtmbe: %d rtbke: %ld rtbre: %ld ", |
1065 | atomic_read(&n_rcu_torture_mberror), | 1070 | atomic_read(&n_rcu_torture_mberror), |
1066 | n_rcu_torture_boost_ktrerror, | 1071 | n_rcu_torture_boost_ktrerror, |
1067 | n_rcu_torture_boost_rterror); | 1072 | n_rcu_torture_boost_rterror); |
1068 | page += sprintf(page, "rtbf: %ld rtb: %ld nt: %ld ", | 1073 | pr_cont("rtbf: %ld rtb: %ld nt: %ld ", |
1069 | n_rcu_torture_boost_failure, | 1074 | n_rcu_torture_boost_failure, |
1070 | n_rcu_torture_boosts, | 1075 | n_rcu_torture_boosts, |
1071 | n_rcu_torture_timers); | 1076 | n_rcu_torture_timers); |
1072 | page = torture_onoff_stats(page); | 1077 | torture_onoff_stats(); |
1073 | page += sprintf(page, "barrier: %ld/%ld:%ld", | 1078 | pr_cont("barrier: %ld/%ld:%ld\n", |
1074 | n_barrier_successes, | 1079 | n_barrier_successes, |
1075 | n_barrier_attempts, | 1080 | n_barrier_attempts, |
1076 | n_rcu_torture_barrier_error); | 1081 | n_rcu_torture_barrier_error); |
1077 | page += sprintf(page, "\n%s%s ", torture_type, TORTURE_FLAG); | 1082 | |
1083 | pr_alert("%s%s ", torture_type, TORTURE_FLAG); | ||
1078 | if (atomic_read(&n_rcu_torture_mberror) != 0 || | 1084 | if (atomic_read(&n_rcu_torture_mberror) != 0 || |
1079 | n_rcu_torture_barrier_error != 0 || | 1085 | n_rcu_torture_barrier_error != 0 || |
1080 | n_rcu_torture_boost_ktrerror != 0 || | 1086 | n_rcu_torture_boost_ktrerror != 0 || |
1081 | n_rcu_torture_boost_rterror != 0 || | 1087 | n_rcu_torture_boost_rterror != 0 || |
1082 | n_rcu_torture_boost_failure != 0 || | 1088 | n_rcu_torture_boost_failure != 0 || |
1083 | i > 1) { | 1089 | i > 1) { |
1084 | page += sprintf(page, "!!! "); | 1090 | pr_cont("%s", "!!! "); |
1085 | atomic_inc(&n_rcu_torture_error); | 1091 | atomic_inc(&n_rcu_torture_error); |
1086 | WARN_ON_ONCE(1); | 1092 | WARN_ON_ONCE(1); |
1087 | } | 1093 | } |
1088 | page += sprintf(page, "Reader Pipe: "); | 1094 | pr_cont("Reader Pipe: "); |
1089 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) | 1095 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) |
1090 | page += sprintf(page, " %ld", pipesummary[i]); | 1096 | pr_cont(" %ld", pipesummary[i]); |
1091 | page += sprintf(page, "\n%s%s ", torture_type, TORTURE_FLAG); | 1097 | pr_cont("\n"); |
1092 | page += sprintf(page, "Reader Batch: "); | 1098 | |
1099 | pr_alert("%s%s ", torture_type, TORTURE_FLAG); | ||
1100 | pr_cont("Reader Batch: "); | ||
1093 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) | 1101 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) |
1094 | page += sprintf(page, " %ld", batchsummary[i]); | 1102 | pr_cont(" %ld", batchsummary[i]); |
1095 | page += sprintf(page, "\n%s%s ", torture_type, TORTURE_FLAG); | 1103 | pr_cont("\n"); |
1096 | page += sprintf(page, "Free-Block Circulation: "); | 1104 | |
1105 | pr_alert("%s%s ", torture_type, TORTURE_FLAG); | ||
1106 | pr_cont("Free-Block Circulation: "); | ||
1097 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) { | 1107 | for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) { |
1098 | page += sprintf(page, " %d", | 1108 | pr_cont(" %d", atomic_read(&rcu_torture_wcount[i])); |
1099 | atomic_read(&rcu_torture_wcount[i])); | ||
1100 | } | 1109 | } |
1101 | page += sprintf(page, "\n"); | 1110 | pr_cont("\n"); |
1111 | |||
1102 | if (cur_ops->stats) | 1112 | if (cur_ops->stats) |
1103 | cur_ops->stats(page); | 1113 | cur_ops->stats(); |
1104 | if (rtcv_snap == rcu_torture_current_version && | 1114 | if (rtcv_snap == rcu_torture_current_version && |
1105 | rcu_torture_current != NULL) { | 1115 | rcu_torture_current != NULL) { |
1106 | int __maybe_unused flags; | 1116 | int __maybe_unused flags; |
@@ -1109,10 +1119,9 @@ rcu_torture_printk(char *page) | |||
1109 | 1119 | ||
1110 | rcutorture_get_gp_data(cur_ops->ttype, | 1120 | rcutorture_get_gp_data(cur_ops->ttype, |
1111 | &flags, &gpnum, &completed); | 1121 | &flags, &gpnum, &completed); |
1112 | page += sprintf(page, | 1122 | pr_alert("??? Writer stall state %d g%lu c%lu f%#x\n", |
1113 | "??? Writer stall state %d g%lu c%lu f%#x\n", | 1123 | rcu_torture_writer_state, |
1114 | rcu_torture_writer_state, | 1124 | gpnum, completed, flags); |
1115 | gpnum, completed, flags); | ||
1116 | show_rcu_gp_kthreads(); | 1125 | show_rcu_gp_kthreads(); |
1117 | rcutorture_trace_dump(); | 1126 | rcutorture_trace_dump(); |
1118 | } | 1127 | } |
@@ -1120,30 +1129,6 @@ rcu_torture_printk(char *page) | |||
1120 | } | 1129 | } |
1121 | 1130 | ||
1122 | /* | 1131 | /* |
1123 | * Print torture statistics. Caller must ensure that there is only | ||
1124 | * one call to this function at a given time!!! This is normally | ||
1125 | * accomplished by relying on the module system to only have one copy | ||
1126 | * of the module loaded, and then by giving the rcu_torture_stats | ||
1127 | * kthread full control (or the init/cleanup functions when rcu_torture_stats | ||
1128 | * thread is not running). | ||
1129 | */ | ||
1130 | static void | ||
1131 | rcu_torture_stats_print(void) | ||
1132 | { | ||
1133 | int size = nr_cpu_ids * 200 + 8192; | ||
1134 | char *buf; | ||
1135 | |||
1136 | buf = kmalloc(size, GFP_KERNEL); | ||
1137 | if (!buf) { | ||
1138 | pr_err("rcu-torture: Out of memory, need: %d", size); | ||
1139 | return; | ||
1140 | } | ||
1141 | rcu_torture_printk(buf); | ||
1142 | pr_alert("%s", buf); | ||
1143 | kfree(buf); | ||
1144 | } | ||
1145 | |||
1146 | /* | ||
1147 | * Periodically prints torture statistics, if periodic statistics printing | 1132 | * Periodically prints torture statistics, if periodic statistics printing |
1148 | * was specified via the stat_interval module parameter. | 1133 | * was specified via the stat_interval module parameter. |
1149 | */ | 1134 | */ |
diff --git a/kernel/torture.c b/kernel/torture.c index d600af21f022..ede8b25ec1ae 100644 --- a/kernel/torture.c +++ b/kernel/torture.c | |||
@@ -211,18 +211,16 @@ EXPORT_SYMBOL_GPL(torture_onoff_cleanup); | |||
211 | /* | 211 | /* |
212 | * Print online/offline testing statistics. | 212 | * Print online/offline testing statistics. |
213 | */ | 213 | */ |
214 | char *torture_onoff_stats(char *page) | 214 | void torture_onoff_stats(void) |
215 | { | 215 | { |
216 | #ifdef CONFIG_HOTPLUG_CPU | 216 | #ifdef CONFIG_HOTPLUG_CPU |
217 | page += sprintf(page, | 217 | pr_cont("onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ", |
218 | "onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ", | 218 | n_online_successes, n_online_attempts, |
219 | n_online_successes, n_online_attempts, | 219 | n_offline_successes, n_offline_attempts, |
220 | n_offline_successes, n_offline_attempts, | 220 | min_online, max_online, |
221 | min_online, max_online, | 221 | min_offline, max_offline, |
222 | min_offline, max_offline, | 222 | sum_online, sum_offline, HZ); |
223 | sum_online, sum_offline, HZ); | ||
224 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | 223 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
225 | return page; | ||
226 | } | 224 | } |
227 | EXPORT_SYMBOL_GPL(torture_onoff_stats); | 225 | EXPORT_SYMBOL_GPL(torture_onoff_stats); |
228 | 226 | ||