@@ -139,8 +139,6 @@ MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s");
139
139
#define VERBOSE_PRINTK_ERRSTRING (s ) \
140
140
do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
141
141
142
- static char printk_buf [4096 ];
143
-
144
142
static int nrealreaders ;
145
143
static struct task_struct * writer_task ;
146
144
static struct task_struct * * fakewriter_tasks ;
@@ -376,7 +374,7 @@ struct rcu_torture_ops {
376
374
void (* call )(struct rcu_head * head , void (* func )(struct rcu_head * rcu ));
377
375
void (* cb_barrier )(void );
378
376
void (* fqs )(void );
379
- int (* stats )(char * page );
377
+ void (* stats )(char * page );
380
378
int irq_capable ;
381
379
int can_boost ;
382
380
const char * name ;
@@ -578,21 +576,19 @@ static void srcu_torture_barrier(void)
578
576
srcu_barrier (& srcu_ctl );
579
577
}
580
578
581
- static int srcu_torture_stats (char * page )
579
+ static void srcu_torture_stats (char * page )
582
580
{
583
- int cnt = 0 ;
584
581
int cpu ;
585
582
int idx = srcu_ctl .completed & 0x1 ;
586
583
587
- cnt += sprintf (& page [ cnt ] , "%s%s per-CPU(idx=%d):" ,
584
+ page += sprintf (page , "%s%s per-CPU(idx=%d):" ,
588
585
torture_type , TORTURE_FLAG , idx );
589
586
for_each_possible_cpu (cpu ) {
590
- cnt += sprintf (& page [ cnt ] , " %d(%lu,%lu)" , cpu ,
587
+ page += sprintf (page , " %d(%lu,%lu)" , cpu ,
591
588
per_cpu_ptr (srcu_ctl .per_cpu_ref , cpu )-> c [!idx ],
592
589
per_cpu_ptr (srcu_ctl .per_cpu_ref , cpu )-> c [idx ]);
593
590
}
594
- cnt += sprintf (& page [cnt ], "\n" );
595
- return cnt ;
591
+ sprintf (page , "\n" );
596
592
}
597
593
598
594
static void srcu_torture_synchronize_expedited (void )
@@ -1052,10 +1048,9 @@ rcu_torture_reader(void *arg)
1052
1048
/*
1053
1049
* Create an RCU-torture statistics message in the specified buffer.
1054
1050
*/
1055
- static int
1051
+ static void
1056
1052
rcu_torture_printk (char * page )
1057
1053
{
1058
- int cnt = 0 ;
1059
1054
int cpu ;
1060
1055
int i ;
1061
1056
long pipesummary [RCU_TORTURE_PIPE_LEN + 1 ] = { 0 };
@@ -1071,62 +1066,61 @@ rcu_torture_printk(char *page)
1071
1066
if (pipesummary [i ] != 0 )
1072
1067
break ;
1073
1068
}
1074
- cnt += sprintf (& page [ cnt ] , "%s%s " , torture_type , TORTURE_FLAG );
1075
- cnt += sprintf (& page [ cnt ] ,
1069
+ page += sprintf (page , "%s%s " , torture_type , TORTURE_FLAG );
1070
+ page += sprintf (page ,
1076
1071
"rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d " ,
1077
1072
rcu_torture_current ,
1078
1073
rcu_torture_current_version ,
1079
1074
list_empty (& rcu_torture_freelist ),
1080
1075
atomic_read (& n_rcu_torture_alloc ),
1081
1076
atomic_read (& n_rcu_torture_alloc_fail ),
1082
1077
atomic_read (& n_rcu_torture_free ));
1083
- cnt += sprintf (& page [ cnt ] , "rtmbe: %d rtbke: %ld rtbre: %ld " ,
1078
+ page += sprintf (page , "rtmbe: %d rtbke: %ld rtbre: %ld " ,
1084
1079
atomic_read (& n_rcu_torture_mberror ),
1085
1080
n_rcu_torture_boost_ktrerror ,
1086
1081
n_rcu_torture_boost_rterror );
1087
- cnt += sprintf (& page [ cnt ] , "rtbf: %ld rtb: %ld nt: %ld " ,
1082
+ page += sprintf (page , "rtbf: %ld rtb: %ld nt: %ld " ,
1088
1083
n_rcu_torture_boost_failure ,
1089
1084
n_rcu_torture_boosts ,
1090
1085
n_rcu_torture_timers );
1091
- cnt += sprintf (& page [ cnt ] ,
1086
+ page += sprintf (page ,
1092
1087
"onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) " ,
1093
1088
n_online_successes , n_online_attempts ,
1094
1089
n_offline_successes , n_offline_attempts ,
1095
1090
min_online , max_online ,
1096
1091
min_offline , max_offline ,
1097
1092
sum_online , sum_offline , HZ );
1098
- cnt += sprintf (& page [ cnt ] , "barrier: %ld/%ld:%ld" ,
1093
+ page += sprintf (page , "barrier: %ld/%ld:%ld" ,
1099
1094
n_barrier_successes ,
1100
1095
n_barrier_attempts ,
1101
1096
n_rcu_torture_barrier_error );
1102
- cnt += sprintf (& page [ cnt ] , "\n%s%s " , torture_type , TORTURE_FLAG );
1097
+ page += sprintf (page , "\n%s%s " , torture_type , TORTURE_FLAG );
1103
1098
if (atomic_read (& n_rcu_torture_mberror ) != 0 ||
1104
1099
n_rcu_torture_barrier_error != 0 ||
1105
1100
n_rcu_torture_boost_ktrerror != 0 ||
1106
1101
n_rcu_torture_boost_rterror != 0 ||
1107
1102
n_rcu_torture_boost_failure != 0 ||
1108
1103
i > 1 ) {
1109
- cnt += sprintf (& page [ cnt ] , "!!! " );
1104
+ page += sprintf (page , "!!! " );
1110
1105
atomic_inc (& n_rcu_torture_error );
1111
1106
WARN_ON_ONCE (1 );
1112
1107
}
1113
- cnt += sprintf (& page [ cnt ] , "Reader Pipe: " );
1108
+ page += sprintf (page , "Reader Pipe: " );
1114
1109
for (i = 0 ; i < RCU_TORTURE_PIPE_LEN + 1 ; i ++ )
1115
- cnt += sprintf (& page [ cnt ] , " %ld" , pipesummary [i ]);
1116
- cnt += sprintf (& page [ cnt ] , "\n%s%s " , torture_type , TORTURE_FLAG );
1117
- cnt += sprintf (& page [ cnt ] , "Reader Batch: " );
1110
+ page += sprintf (page , " %ld" , pipesummary [i ]);
1111
+ page += sprintf (page , "\n%s%s " , torture_type , TORTURE_FLAG );
1112
+ page += sprintf (page , "Reader Batch: " );
1118
1113
for (i = 0 ; i < RCU_TORTURE_PIPE_LEN + 1 ; i ++ )
1119
- cnt += sprintf (& page [ cnt ] , " %ld" , batchsummary [i ]);
1120
- cnt += sprintf (& page [ cnt ] , "\n%s%s " , torture_type , TORTURE_FLAG );
1121
- cnt += sprintf (& page [ cnt ] , "Free-Block Circulation: " );
1114
+ page += sprintf (page , " %ld" , batchsummary [i ]);
1115
+ page += sprintf (page , "\n%s%s " , torture_type , TORTURE_FLAG );
1116
+ page += sprintf (page , "Free-Block Circulation: " );
1122
1117
for (i = 0 ; i < RCU_TORTURE_PIPE_LEN + 1 ; i ++ ) {
1123
- cnt += sprintf (& page [ cnt ] , " %d" ,
1118
+ page += sprintf (page , " %d" ,
1124
1119
atomic_read (& rcu_torture_wcount [i ]));
1125
1120
}
1126
- cnt += sprintf (& page [ cnt ] , "\n" );
1121
+ page += sprintf (page , "\n" );
1127
1122
if (cur_ops -> stats )
1128
- cnt += cur_ops -> stats (& page [cnt ]);
1129
- return cnt ;
1123
+ cur_ops -> stats (page );
1130
1124
}
1131
1125
1132
1126
/*
@@ -1140,10 +1134,17 @@ rcu_torture_printk(char *page)
1140
1134
static void
1141
1135
rcu_torture_stats_print (void )
1142
1136
{
1143
- int cnt ;
1137
+ int size = nr_cpu_ids * 200 + 8192 ;
1138
+ char * buf ;
1144
1139
1145
- cnt = rcu_torture_printk (printk_buf );
1146
- pr_alert ("%s" , printk_buf );
1140
+ buf = kmalloc (size , GFP_KERNEL );
1141
+ if (!buf ) {
1142
+ pr_err ("rcu-torture: Out of memory, need: %d" , size );
1143
+ return ;
1144
+ }
1145
+ rcu_torture_printk (buf );
1146
+ pr_alert ("%s" , buf );
1147
+ kfree (buf );
1147
1148
}
1148
1149
1149
1150
/*
0 commit comments