Skip to content

Commit 0d66ddb

Browse files
ij-intelshuahkh
authored andcommitted
selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl()
write_bm_pid_to_resctrl() uses resctrl_val to check test name which is not a good interface generic resctrl FS functions should provide. Tests define mongrp when needed. Remove the test name check in write_bm_pid_to_resctrl() to only rely on the mongrp parameter being non-NULL. Remove write_bm_pid_to_resctrl() resctrl_val parameter and resctrl_val member from the struct resctrl_val_param that are not used anymore. Similarly, remove the test name constants that are no longer used. Signed-off-by: Ilpo Järvinen <[email protected]> Tested-by: Babu Moger <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent f58e66b commit 0d66ddb

File tree

7 files changed

+17
-38
lines changed

7 files changed

+17
-38
lines changed

tools/testing/selftests/resctrl/cat_test.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ static int cat_test(const struct resctrl_test *test,
158158
struct resctrl_val_param *param,
159159
size_t span, unsigned long current_mask)
160160
{
161-
char *resctrl_val = param->resctrl_val;
162161
struct perf_event_read pe_read;
163162
struct perf_event_attr pea;
164163
cpu_set_t old_affinity;
@@ -178,8 +177,7 @@ static int cat_test(const struct resctrl_test *test,
178177
return ret;
179178

180179
/* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/
181-
ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp,
182-
resctrl_val);
180+
ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp);
183181
if (ret)
184182
goto reset_affinity;
185183

@@ -272,7 +270,6 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
272270
start_mask = create_bit_mask(start, n);
273271

274272
struct resctrl_val_param param = {
275-
.resctrl_val = CAT_STR,
276273
.ctrlgrp = "c1",
277274
.filename = RESULT_FILE_NAME,
278275
.num_of_runs = 0,

tools/testing/selftests/resctrl/cmt_test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param
144144
}
145145

146146
struct resctrl_val_param param = {
147-
.resctrl_val = CMT_STR,
148147
.ctrlgrp = "c1",
149148
.filename = RESULT_FILE_NAME,
150149
.mask = ~(long_mask << n) & long_mask,

tools/testing/selftests/resctrl/mba_test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ static void mba_test_cleanup(void)
164164
static int mba_run_test(const struct resctrl_test *test, const struct user_params *uparams)
165165
{
166166
struct resctrl_val_param param = {
167-
.resctrl_val = MBA_STR,
168167
.ctrlgrp = "c1",
169168
.filename = RESULT_FILE_NAME,
170169
.init = mba_init,

tools/testing/selftests/resctrl/mbm_test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ static void mbm_test_cleanup(void)
132132
static int mbm_run_test(const struct resctrl_test *test, const struct user_params *uparams)
133133
{
134134
struct resctrl_val_param param = {
135-
.resctrl_val = MBM_STR,
136135
.ctrlgrp = "c1",
137136
.filename = RESULT_FILE_NAME,
138137
.init = mbm_init,

tools/testing/selftests/resctrl/resctrl.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ struct resctrl_test {
8181

8282
/*
8383
* resctrl_val_param: resctrl test parameters
84-
* @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc)
8584
* @ctrlgrp: Name of the control monitor group (con_mon grp)
8685
* @mongrp: Name of the monitor group (mon grp)
8786
* @filename: Name of file to which the o/p should be written
@@ -90,7 +89,6 @@ struct resctrl_test {
9089
* @measure: Callback that performs the measurement (a single test)
9190
*/
9291
struct resctrl_val_param {
93-
char *resctrl_val;
9492
const char *ctrlgrp;
9593
const char *mongrp;
9694
char filename[64];
@@ -113,11 +111,6 @@ struct perf_event_read {
113111
} values[2];
114112
};
115113

116-
#define MBM_STR "mbm"
117-
#define MBA_STR "mba"
118-
#define CMT_STR "cmt"
119-
#define CAT_STR "cat"
120-
121114
/*
122115
* Memory location that consumes values compiler must not optimize away.
123116
* Volatile ensures writes to this location cannot be optimized away by
@@ -143,8 +136,7 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity);
143136
int taskset_restore(pid_t bm_pid, cpu_set_t *old_affinity);
144137
int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no,
145138
const char *resource);
146-
int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
147-
const char *mongrp, const char *resctrl_val);
139+
int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp);
148140
int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
149141
int group_fd, unsigned long flags);
150142
unsigned char *alloc_buffer(size_t buf_size, int memflush);

tools/testing/selftests/resctrl/resctrl_val.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ int resctrl_val(const struct resctrl_test *test,
684684
const char * const *benchmark_cmd,
685685
struct resctrl_val_param *param)
686686
{
687-
char *resctrl_val = param->resctrl_val;
688687
struct sigaction sigact;
689688
int ret = 0, pipefd[2];
690689
char pipe_message = 0;
@@ -775,8 +774,7 @@ int resctrl_val(const struct resctrl_test *test,
775774
goto out;
776775

777776
/* Write benchmark to specified control&monitoring grp in resctrl FS */
778-
ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp,
779-
resctrl_val);
777+
ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp);
780778
if (ret)
781779
goto out;
782780

tools/testing/selftests/resctrl/resctrlfs.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)
522522
* @bm_pid: PID that should be written
523523
* @ctrlgrp: Name of the control monitor group (con_mon grp)
524524
* @mongrp: Name of the monitor group (mon grp)
525-
* @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc)
526525
*
527526
* If a con_mon grp is requested, create it and write pid to it, otherwise
528527
* write pid to root con_mon grp.
@@ -532,8 +531,7 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)
532531
*
533532
* Return: 0 on success, < 0 on error.
534533
*/
535-
int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
536-
const char *mongrp, const char *resctrl_val)
534+
int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp)
537535
{
538536
char controlgroup[128], monitorgroup[512], monitorgroup_p[256];
539537
char tasks[1024];
@@ -553,22 +551,19 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
553551
if (ret)
554552
goto out;
555553

556-
/* Create mon grp and write pid into it for "mbm" and "cmt" test */
557-
if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)) ||
558-
!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) {
559-
if (mongrp) {
560-
sprintf(monitorgroup_p, "%s/mon_groups", controlgroup);
561-
sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp);
562-
ret = create_grp(mongrp, monitorgroup, monitorgroup_p);
563-
if (ret)
564-
goto out;
565-
566-
sprintf(tasks, "%s/mon_groups/%s/tasks",
567-
controlgroup, mongrp);
568-
ret = write_pid_to_tasks(tasks, bm_pid);
569-
if (ret)
570-
goto out;
571-
}
554+
/* Create monitor group and write pid into if it is used */
555+
if (mongrp) {
556+
sprintf(monitorgroup_p, "%s/mon_groups", controlgroup);
557+
sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp);
558+
ret = create_grp(mongrp, monitorgroup, monitorgroup_p);
559+
if (ret)
560+
goto out;
561+
562+
sprintf(tasks, "%s/mon_groups/%s/tasks",
563+
controlgroup, mongrp);
564+
ret = write_pid_to_tasks(tasks, bm_pid);
565+
if (ret)
566+
goto out;
572567
}
573568

574569
out:

0 commit comments

Comments
 (0)