Skip to content

Commit 8ee592a

Browse files
ij-intelshuahkh
authored andcommitted
selftests/resctrl: Don't use variable argument list for ->setup()
struct resctrl_val_param has ->setup() function that accepts variable argument list. All test cases use only 1 argument as input and it's the struct resctrl_val_param pointer. Instead of variable argument list, directly pass struct resctrl_val_param pointer as the only parameter to ->setup(). Co-developed-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Babu Moger <babu.moger@amd.com> Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 7f3c980 commit 8ee592a

File tree

7 files changed

+7
-33
lines changed

7 files changed

+7
-33
lines changed

tools/testing/selftests/resctrl/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ int cat_val(struct resctrl_val_param *param)
236236
/* Test runs until the callback setup() tells the test to stop. */
237237
while (1) {
238238
if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) {
239-
ret = param->setup(1, param);
239+
ret = param->setup(param);
240240
if (ret == END_OF_TESTS) {
241241
ret = 0;
242242
break;

tools/testing/selftests/resctrl/cat_test.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,11 @@ static unsigned long cache_size;
2727
* con_mon grp, mon_grp in resctrl FS.
2828
* Run 5 times in order to get average values.
2929
*/
30-
static int cat_setup(int num, ...)
30+
static int cat_setup(struct resctrl_val_param *p)
3131
{
32-
struct resctrl_val_param *p;
3332
char schemata[64];
34-
va_list param;
3533
int ret = 0;
3634

37-
va_start(param, num);
38-
p = va_arg(param, struct resctrl_val_param *);
39-
va_end(param);
40-
4135
/* Run NUM_OF_RUNS times */
4236
if (p->num_of_runs >= NUM_OF_RUNS)
4337
return END_OF_TESTS;

tools/testing/selftests/resctrl/cmt_test.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,8 @@ static char cbm_mask[256];
2121
static unsigned long long_mask;
2222
static unsigned long cache_size;
2323

24-
static int cmt_setup(int num, ...)
24+
static int cmt_setup(struct resctrl_val_param *p)
2525
{
26-
struct resctrl_val_param *p;
27-
va_list param;
28-
29-
va_start(param, num);
30-
p = va_arg(param, struct resctrl_val_param *);
31-
va_end(param);
32-
3326
/* Run NUM_OF_RUNS times */
3427
if (p->num_of_runs >= NUM_OF_RUNS)
3528
return END_OF_TESTS;

tools/testing/selftests/resctrl/mba_test.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,12 @@
2222
* con_mon grp, mon_grp in resctrl FS.
2323
* For each allocation, run 5 times in order to get average values.
2424
*/
25-
static int mba_setup(int num, ...)
25+
static int mba_setup(struct resctrl_val_param *p)
2626
{
2727
static int runs_per_allocation, allocation = 100;
28-
struct resctrl_val_param *p;
2928
char allocation_str[64];
30-
va_list param;
3129
int ret;
3230

33-
va_start(param, num);
34-
p = va_arg(param, struct resctrl_val_param *);
35-
va_end(param);
36-
3731
if (runs_per_allocation >= NUM_OF_RUNS)
3832
runs_per_allocation = 0;
3933

tools/testing/selftests/resctrl/mbm_test.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,10 @@ static int check_results(size_t span)
8686
return ret;
8787
}
8888

89-
static int mbm_setup(int num, ...)
89+
static int mbm_setup(struct resctrl_val_param *p)
9090
{
91-
struct resctrl_val_param *p;
92-
va_list param;
9391
int ret = 0;
9492

95-
va_start(param, num);
96-
p = va_arg(param, struct resctrl_val_param *);
97-
va_end(param);
98-
9993
/* Run NUM_OF_RUNS times */
10094
if (p->num_of_runs >= NUM_OF_RUNS)
10195
return END_OF_TESTS;

tools/testing/selftests/resctrl/resctrl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#ifndef RESCTRL_H
44
#define RESCTRL_H
55
#include <stdio.h>
6-
#include <stdarg.h>
76
#include <math.h>
87
#include <errno.h>
98
#include <sched.h>
@@ -68,7 +67,7 @@ struct resctrl_val_param {
6867
char *bw_report;
6968
unsigned long mask;
7069
int num_of_runs;
71-
int (*setup)(int num, ...);
70+
int (*setup)(struct resctrl_val_param *param);
7271
};
7372

7473
#define MBM_STR "mbm"

tools/testing/selftests/resctrl/resctrl_val.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param)
759759

760760
/* Test runs until the callback setup() tells the test to stop. */
761761
while (1) {
762-
ret = param->setup(1, param);
762+
ret = param->setup(param);
763763
if (ret == END_OF_TESTS) {
764764
ret = 0;
765765
break;

0 commit comments

Comments
 (0)