@@ -83,12 +83,6 @@ struct reader_task {
83
83
atomic_t start ;
84
84
wait_queue_head_t wq ;
85
85
u64 last_duration_ns ;
86
-
87
- // The average latency When 1..<this reader> are concurrently
88
- // running an experiment. For example, if this reader_task is
89
- // of index 5 in the reader_tasks array, then result is for
90
- // 6 cores.
91
- u64 result_avg ;
92
86
};
93
87
94
88
static struct task_struct * shutdown_task ;
@@ -289,12 +283,12 @@ ref_perf_reader(void *arg)
289
283
return 0 ;
290
284
}
291
285
292
- void reset_readers (int n )
286
+ void reset_readers (void )
293
287
{
294
288
int i ;
295
289
struct reader_task * rt ;
296
290
297
- for (i = 0 ; i < n ; i ++ ) {
291
+ for (i = 0 ; i < nreaders ; i ++ ) {
298
292
rt = & (reader_tasks [i ]);
299
293
300
294
rt -> last_duration_ns = 0 ;
@@ -314,7 +308,7 @@ u64 process_durations(int n)
314
308
sprintf (buf , "Experiment #%d (Format: <THREAD-NUM>:<Total loop time in ns>)" ,
315
309
exp_idx );
316
310
317
- for (i = 0 ; i <= n && !torture_must_stop (); i ++ ) {
311
+ for (i = 0 ; i < n && !torture_must_stop (); i ++ ) {
318
312
rt = & (reader_tasks [i ]);
319
313
sprintf (buf1 , "%d: %llu\t" , i , rt -> last_duration_ns );
320
314
@@ -342,11 +336,15 @@ static int main_func(void *arg)
342
336
int exp , r ;
343
337
char buf1 [64 ];
344
338
char buf [512 ];
339
+ u64 * result_avg ;
345
340
346
341
set_cpus_allowed_ptr (current , cpumask_of (nreaders % nr_cpu_ids ));
347
342
set_user_nice (current , MAX_NICE );
348
343
349
344
VERBOSE_PERFOUT ("main_func task started" );
345
+ result_avg = kzalloc (nruns * sizeof (* result_avg ), GFP_KERNEL );
346
+ if (!result_avg )
347
+ VERBOSE_PERFOUT_ERRSTRING ("out of memory" );
350
348
atomic_inc (& n_init );
351
349
352
350
// Wait for all threads to start.
@@ -355,22 +353,24 @@ static int main_func(void *arg)
355
353
schedule_timeout_interruptible (holdoff * HZ );
356
354
357
355
// Start exp readers up per experiment
358
- for (exp = 0 ; exp < nreaders && !torture_must_stop (); exp ++ ) {
356
+ for (exp = 0 ; exp < nruns && !torture_must_stop (); exp ++ ) {
357
+ if (!result_avg )
358
+ break ;
359
359
if (torture_must_stop ())
360
360
goto end ;
361
361
362
- reset_readers (exp );
363
- atomic_set (& nreaders_exp , exp + 1 );
362
+ reset_readers ();
363
+ atomic_set (& nreaders_exp , nreaders );
364
364
365
365
exp_idx = exp ;
366
366
367
- for (r = 0 ; r <= exp ; r ++ ) {
367
+ for (r = 0 ; r < nreaders ; r ++ ) {
368
368
atomic_set (& reader_tasks [r ].start , 1 );
369
369
wake_up (& reader_tasks [r ].wq );
370
370
}
371
371
372
372
VERBOSE_PERFOUT ("main_func: experiment started, waiting for %d readers" ,
373
- exp );
373
+ nreaders );
374
374
375
375
wait_event (main_wq ,
376
376
!atomic_read (& nreaders_exp ) || torture_must_stop ());
@@ -380,7 +380,7 @@ static int main_func(void *arg)
380
380
if (torture_must_stop ())
381
381
goto end ;
382
382
383
- reader_tasks [exp ]. result_avg = 1000 * process_durations (exp ) / (( exp + 1 ) * loops );
383
+ result_avg [exp ] = 1000 * process_durations (nreaders ) / (nreaders * loops );
384
384
}
385
385
386
386
// Print the average of all experiments
@@ -390,12 +390,15 @@ static int main_func(void *arg)
390
390
strcat (buf , "\n" );
391
391
strcat (buf , "Threads\tTime(ns)\n" );
392
392
393
- for (exp = 0 ; exp < nreaders ; exp ++ ) {
394
- sprintf (buf1 , "%d\t%llu.%03d\n" , exp + 1 , reader_tasks [exp ].result_avg / 1000 , (int )(reader_tasks [exp ].result_avg % 1000 ));
393
+ for (exp = 0 ; exp < nruns ; exp ++ ) {
394
+ if (!result_avg )
395
+ break ;
396
+ sprintf (buf1 , "%d\t%llu.%03d\n" , exp + 1 , result_avg [exp ] / 1000 , (int )(result_avg [exp ] % 1000 ));
395
397
strcat (buf , buf1 );
396
398
}
397
399
398
- PERFOUT ("%s" , buf );
400
+ if (result_avg )
401
+ PERFOUT ("%s" , buf );
399
402
400
403
// This will shutdown everything including us.
401
404
if (shutdown ) {
@@ -416,8 +419,8 @@ static void
416
419
ref_perf_print_module_parms (struct ref_perf_ops * cur_ops , const char * tag )
417
420
{
418
421
pr_alert ("%s" PERF_FLAG
419
- "--- %s: verbose=%d shutdown=%d holdoff=%d loops=%ld nreaders=%d\n" , perf_type , tag ,
420
- verbose , shutdown , holdoff , loops , nreaders );
422
+ "--- %s: verbose=%d shutdown=%d holdoff=%d loops=%ld nreaders=%d nruns=%d \n" , perf_type , tag ,
423
+ verbose , shutdown , holdoff , loops , nreaders , nruns );
421
424
}
422
425
423
426
static void
0 commit comments