@@ -156,12 +156,12 @@ static int read_from_imc_dir(char *imc_dir, int count)
156
156
sprintf (imc_counter_type , "%s%s" , imc_dir , "type" );
157
157
fp = fopen (imc_counter_type , "r" );
158
158
if (!fp ) {
159
- perror ("Failed to open imc counter type file" );
159
+ ksft_perror ("Failed to open iMC counter type file" );
160
160
161
161
return -1 ;
162
162
}
163
163
if (fscanf (fp , "%u" , & imc_counters_config [count ][READ ].type ) <= 0 ) {
164
- perror ("Could not get imc type" );
164
+ ksft_perror ("Could not get iMC type" );
165
165
fclose (fp );
166
166
167
167
return -1 ;
@@ -175,12 +175,12 @@ static int read_from_imc_dir(char *imc_dir, int count)
175
175
sprintf (imc_counter_cfg , "%s%s" , imc_dir , READ_FILE_NAME );
176
176
fp = fopen (imc_counter_cfg , "r" );
177
177
if (!fp ) {
178
- perror ("Failed to open imc config file" );
178
+ ksft_perror ("Failed to open iMC config file" );
179
179
180
180
return -1 ;
181
181
}
182
182
if (fscanf (fp , "%s" , cas_count_cfg ) <= 0 ) {
183
- perror ("Could not get imc cas count read" );
183
+ ksft_perror ("Could not get iMC cas count read" );
184
184
fclose (fp );
185
185
186
186
return -1 ;
@@ -193,12 +193,12 @@ static int read_from_imc_dir(char *imc_dir, int count)
193
193
sprintf (imc_counter_cfg , "%s%s" , imc_dir , WRITE_FILE_NAME );
194
194
fp = fopen (imc_counter_cfg , "r" );
195
195
if (!fp ) {
196
- perror ("Failed to open imc config file" );
196
+ ksft_perror ("Failed to open iMC config file" );
197
197
198
198
return -1 ;
199
199
}
200
200
if (fscanf (fp , "%s" , cas_count_cfg ) <= 0 ) {
201
- perror ("Could not get imc cas count write" );
201
+ ksft_perror ("Could not get iMC cas count write" );
202
202
fclose (fp );
203
203
204
204
return -1 ;
@@ -262,12 +262,12 @@ static int num_of_imcs(void)
262
262
}
263
263
closedir (dp );
264
264
if (count == 0 ) {
265
- perror ("Unable find iMC counters! \n" );
265
+ ksft_print_msg ("Unable to find iMC counters\n" );
266
266
267
267
return -1 ;
268
268
}
269
269
} else {
270
- perror ("Unable to open PMU directory!\n " );
270
+ ksft_perror ("Unable to open PMU directory" );
271
271
272
272
return -1 ;
273
273
}
@@ -339,14 +339,14 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
339
339
340
340
if (read (r -> fd , & r -> return_value ,
341
341
sizeof (struct membw_read_format )) == -1 ) {
342
- perror ("Couldn't get read b/w through iMC" );
342
+ ksft_perror ("Couldn't get read b/w through iMC" );
343
343
344
344
return -1 ;
345
345
}
346
346
347
347
if (read (w -> fd , & w -> return_value ,
348
348
sizeof (struct membw_read_format )) == -1 ) {
349
- perror ("Couldn't get write bw through iMC" );
349
+ ksft_perror ("Couldn't get write bw through iMC" );
350
350
351
351
return -1 ;
352
352
}
@@ -416,7 +416,7 @@ static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp,
416
416
int resource_id ;
417
417
418
418
if (get_resource_id (cpu_no , & resource_id ) < 0 ) {
419
- perror ("Could not get resource_id" );
419
+ ksft_print_msg ("Could not get resource_id\n " );
420
420
return ;
421
421
}
422
422
@@ -449,12 +449,12 @@ static int get_mem_bw_resctrl(unsigned long *mbm_total)
449
449
450
450
fp = fopen (mbm_total_path , "r" );
451
451
if (!fp ) {
452
- perror ("Failed to open total bw file" );
452
+ ksft_perror ("Failed to open total bw file" );
453
453
454
454
return -1 ;
455
455
}
456
456
if (fscanf (fp , "%lu" , mbm_total ) <= 0 ) {
457
- perror ("Could not get mbm local bytes" );
457
+ ksft_perror ("Could not get mbm local bytes" );
458
458
fclose (fp );
459
459
460
460
return -1 ;
@@ -495,7 +495,7 @@ int signal_handler_register(void)
495
495
if (sigaction (SIGINT , & sigact , NULL ) ||
496
496
sigaction (SIGTERM , & sigact , NULL ) ||
497
497
sigaction (SIGHUP , & sigact , NULL )) {
498
- perror ( "# sigaction" );
498
+ ksft_perror ( " sigaction" );
499
499
ret = -1 ;
500
500
}
501
501
return ret ;
@@ -515,7 +515,7 @@ void signal_handler_unregister(void)
515
515
if (sigaction (SIGINT , & sigact , NULL ) ||
516
516
sigaction (SIGTERM , & sigact , NULL ) ||
517
517
sigaction (SIGHUP , & sigact , NULL )) {
518
- perror ( "# sigaction" );
518
+ ksft_perror ( " sigaction" );
519
519
}
520
520
}
521
521
@@ -540,14 +540,14 @@ static int print_results_bw(char *filename, int bm_pid, float bw_imc,
540
540
} else {
541
541
fp = fopen (filename , "a" );
542
542
if (!fp ) {
543
- perror ("Cannot open results file" );
543
+ ksft_perror ("Cannot open results file" );
544
544
545
545
return errno ;
546
546
}
547
547
if (fprintf (fp , "Pid: %d \t Mem_BW_iMC: %f \t Mem_BW_resc: %lu \t Difference: %lu\n" ,
548
548
bm_pid , bw_imc , bw_resc , diff ) <= 0 ) {
549
+ ksft_print_msg ("Could not log results\n" );
549
550
fclose (fp );
550
- perror ("Could not log results." );
551
551
552
552
return errno ;
553
553
}
@@ -585,7 +585,7 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp,
585
585
int resource_id ;
586
586
587
587
if (get_resource_id (cpu_no , & resource_id ) < 0 ) {
588
- perror ( "# Unable to resource_id" );
588
+ ksft_print_msg ( "Could not get resource_id\n " );
589
589
return ;
590
590
}
591
591
@@ -647,32 +647,37 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext)
647
647
* stdio (console)
648
648
*/
649
649
fp = freopen ("/dev/null" , "w" , stdout );
650
- if (!fp )
651
- PARENT_EXIT ("Unable to direct benchmark status to /dev/null" );
650
+ if (!fp ) {
651
+ ksft_perror ("Unable to direct benchmark status to /dev/null" );
652
+ PARENT_EXIT ();
653
+ }
652
654
653
655
if (strcmp (benchmark_cmd [0 ], "fill_buf" ) == 0 ) {
654
656
/* Execute default fill_buf benchmark */
655
657
span = strtoul (benchmark_cmd [1 ], NULL , 10 );
656
658
memflush = atoi (benchmark_cmd [2 ]);
657
659
operation = atoi (benchmark_cmd [3 ]);
658
- if (!strcmp (benchmark_cmd [4 ], "true" ))
660
+ if (!strcmp (benchmark_cmd [4 ], "true" )) {
659
661
once = true;
660
- else if (!strcmp (benchmark_cmd [4 ], "false" ))
662
+ } else if (!strcmp (benchmark_cmd [4 ], "false" )) {
661
663
once = false;
662
- else
663
- PARENT_EXIT ("Invalid once parameter" );
664
+ } else {
665
+ ksft_print_msg ("Invalid once parameter\n" );
666
+ PARENT_EXIT ();
667
+ }
664
668
665
669
if (run_fill_buf (span , memflush , operation , once ))
666
670
fprintf (stderr , "Error in running fill buffer\n" );
667
671
} else {
668
672
/* Execute specified benchmark */
669
673
ret = execvp (benchmark_cmd [0 ], benchmark_cmd );
670
674
if (ret )
671
- perror ( "wrong\n " );
675
+ ksft_perror ( "execvp " );
672
676
}
673
677
674
678
fclose (stdout );
675
- PARENT_EXIT ("Unable to run specified benchmark" );
679
+ ksft_print_msg ("Unable to run specified benchmark\n" );
680
+ PARENT_EXIT ();
676
681
}
677
682
678
683
/*
@@ -709,7 +714,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par
709
714
ppid = getpid ();
710
715
711
716
if (pipe (pipefd )) {
712
- perror ( "# Unable to create pipe" );
717
+ ksft_perror ( " Unable to create pipe" );
713
718
714
719
return -1 ;
715
720
}
@@ -721,7 +726,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par
721
726
fflush (stdout );
722
727
bm_pid = fork ();
723
728
if (bm_pid == -1 ) {
724
- perror ( "# Unable to fork" );
729
+ ksft_perror ( " Unable to fork" );
725
730
726
731
return -1 ;
727
732
}
@@ -738,15 +743,17 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par
738
743
sigact .sa_flags = SA_SIGINFO ;
739
744
740
745
/* Register for "SIGUSR1" signal from parent */
741
- if (sigaction (SIGUSR1 , & sigact , NULL ))
742
- PARENT_EXIT ("Can't register child for signal" );
746
+ if (sigaction (SIGUSR1 , & sigact , NULL )) {
747
+ ksft_perror ("Can't register child for signal" );
748
+ PARENT_EXIT ();
749
+ }
743
750
744
751
/* Tell parent that child is ready */
745
752
close (pipefd [0 ]);
746
753
pipe_message = 1 ;
747
754
if (write (pipefd [1 ], & pipe_message , sizeof (pipe_message )) <
748
755
sizeof (pipe_message )) {
749
- perror ( "# failed signaling parent process" );
756
+ ksft_perror ( "Failed signaling parent process" );
750
757
close (pipefd [1 ]);
751
758
return -1 ;
752
759
}
@@ -755,7 +762,8 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par
755
762
/* Suspend child until delivery of "SIGUSR1" from parent */
756
763
sigsuspend (& sigact .sa_mask );
757
764
758
- PARENT_EXIT ("Child is done" );
765
+ ksft_perror ("Child is done" );
766
+ PARENT_EXIT ();
759
767
}
760
768
761
769
ksft_print_msg ("Benchmark PID: %d\n" , bm_pid );
@@ -796,7 +804,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par
796
804
while (pipe_message != 1 ) {
797
805
if (read (pipefd [0 ], & pipe_message , sizeof (pipe_message )) <
798
806
sizeof (pipe_message )) {
799
- perror ( "# failed reading message from child process" );
807
+ ksft_perror ( "Failed reading message from child process" );
800
808
close (pipefd [0 ]);
801
809
goto out ;
802
810
}
@@ -805,7 +813,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par
805
813
806
814
/* Signal child to start benchmark */
807
815
if (sigqueue (bm_pid , SIGUSR1 , value ) == -1 ) {
808
- perror ( "# sigqueue SIGUSR1 to child" );
816
+ ksft_perror ( " sigqueue SIGUSR1 to child" );
809
817
ret = errno ;
810
818
goto out ;
811
819
}
0 commit comments