selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl()
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 10 Jun 2024 15:14:57 +0000 (18:14 +0300)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 11 Jul 2024 17:23:54 +0000 (11:23 -0600)
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 <ilpo.jarvinen@linux.intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/resctrl/cat_test.c
tools/testing/selftests/resctrl/cmt_test.c
tools/testing/selftests/resctrl/mba_test.c
tools/testing/selftests/resctrl/mbm_test.c
tools/testing/selftests/resctrl/resctrl.h
tools/testing/selftests/resctrl/resctrl_val.c
tools/testing/selftests/resctrl/resctrlfs.c

index 55315ed695f47e573d96b68e17802a6d073a9284..742782438ca3b0d59c1ce786648c361c4572083a 100644 (file)
@@ -158,7 +158,6 @@ static int cat_test(const struct resctrl_test *test,
                    struct resctrl_val_param *param,
                    size_t span, unsigned long current_mask)
 {
-       char *resctrl_val = param->resctrl_val;
        struct perf_event_read pe_read;
        struct perf_event_attr pea;
        cpu_set_t old_affinity;
@@ -178,8 +177,7 @@ static int cat_test(const struct resctrl_test *test,
                return ret;
 
        /* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/
-       ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp,
-                                     resctrl_val);
+       ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp);
        if (ret)
                goto reset_affinity;
 
@@ -272,7 +270,6 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
        start_mask = create_bit_mask(start, n);
 
        struct resctrl_val_param param = {
-               .resctrl_val    = CAT_STR,
                .ctrlgrp        = "c1",
                .filename       = RESULT_FILE_NAME,
                .num_of_runs    = 0,
index 2713263a001e8992bd5c87baf3ae70bef5ec2e4f..0c045080d808541be192c65e9c0f70c3c686e765 100644 (file)
@@ -144,7 +144,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param
        }
 
        struct resctrl_val_param param = {
-               .resctrl_val    = CMT_STR,
                .ctrlgrp        = "c1",
                .filename       = RESULT_FILE_NAME,
                .mask           = ~(long_mask << n) & long_mask,
index 725227caf1c721051becb16feddb2ca49af7ad1c..ab8496a4925b461a7e5ec3ec354c7200a2da7396 100644 (file)
@@ -164,7 +164,6 @@ static void mba_test_cleanup(void)
 static int mba_run_test(const struct resctrl_test *test, const struct user_params *uparams)
 {
        struct resctrl_val_param param = {
-               .resctrl_val    = MBA_STR,
                .ctrlgrp        = "c1",
                .filename       = RESULT_FILE_NAME,
                .init           = mba_init,
index 40eca4a9eec9bda591b054fc97fa976d628764dc..6b5a3b52d861b8d7d093e564b276eda0a4abc06c 100644 (file)
@@ -132,7 +132,6 @@ static void mbm_test_cleanup(void)
 static int mbm_run_test(const struct resctrl_test *test, const struct user_params *uparams)
 {
        struct resctrl_val_param param = {
-               .resctrl_val    = MBM_STR,
                .ctrlgrp        = "c1",
                .filename       = RESULT_FILE_NAME,
                .init           = mbm_init,
index a999fbc13fd32158972718a2f9cae7e1b750c8d2..2dda560845880e3c5a19101382856a3b27c9c16e 100644 (file)
@@ -81,7 +81,6 @@ struct resctrl_test {
 
 /*
  * resctrl_val_param:  resctrl test parameters
- * @resctrl_val:       Resctrl feature (Eg: mbm, mba.. etc)
  * @ctrlgrp:           Name of the control monitor group (con_mon grp)
  * @mongrp:            Name of the monitor group (mon grp)
  * @filename:          Name of file to which the o/p should be written
@@ -90,7 +89,6 @@ struct resctrl_test {
  * @measure:           Callback that performs the measurement (a single test)
  */
 struct resctrl_val_param {
-       char            *resctrl_val;
        const char      *ctrlgrp;
        const char      *mongrp;
        char            filename[64];
@@ -113,11 +111,6 @@ struct perf_event_read {
        } values[2];
 };
 
-#define MBM_STR                        "mbm"
-#define MBA_STR                        "mba"
-#define CMT_STR                        "cmt"
-#define CAT_STR                        "cat"
-
 /*
  * Memory location that consumes values compiler must not optimize away.
  * 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);
 int taskset_restore(pid_t bm_pid, cpu_set_t *old_affinity);
 int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no,
                   const char *resource);
-int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
-                           const char *mongrp, const char *resctrl_val);
+int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp);
 int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
                    int group_fd, unsigned long flags);
 unsigned char *alloc_buffer(size_t buf_size, int memflush);
index 0a0abc860a7f129df7b9d63fc116073423c0ccf1..8c275f6b4dd777a19bb0e553d33f0a0abbeb1a71 100644 (file)
@@ -684,7 +684,6 @@ int resctrl_val(const struct resctrl_test *test,
                const char * const *benchmark_cmd,
                struct resctrl_val_param *param)
 {
-       char *resctrl_val = param->resctrl_val;
        struct sigaction sigact;
        int ret = 0, pipefd[2];
        char pipe_message = 0;
@@ -775,8 +774,7 @@ int resctrl_val(const struct resctrl_test *test,
                goto out;
 
        /* Write benchmark to specified control&monitoring grp in resctrl FS */
-       ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp,
-                                     resctrl_val);
+       ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp);
        if (ret)
                goto out;
 
index e2d1ecb55d51f60cc4b88c4109540db4a9cb76ac..250c320349a785c3b1de96fea59831471e79b2b7 100644 (file)
@@ -522,7 +522,6 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)
  * @bm_pid:            PID that should be written
  * @ctrlgrp:           Name of the control monitor group (con_mon grp)
  * @mongrp:            Name of the monitor group (mon grp)
- * @resctrl_val:       Resctrl feature (Eg: mbm, mba.. etc)
  *
  * If a con_mon grp is requested, create it and write pid to it, otherwise
  * write pid to root con_mon grp.
@@ -532,8 +531,7 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)
  *
  * Return: 0 on success, < 0 on error.
  */
-int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
-                           const char *mongrp, const char *resctrl_val)
+int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp)
 {
        char controlgroup[128], monitorgroup[512], monitorgroup_p[256];
        char tasks[1024];
@@ -553,22 +551,19 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
        if (ret)
                goto out;
 
-       /* Create mon grp and write pid into it for "mbm" and "cmt" test */
-       if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)) ||
-           !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) {
-               if (mongrp) {
-                       sprintf(monitorgroup_p, "%s/mon_groups", controlgroup);
-                       sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp);
-                       ret = create_grp(mongrp, monitorgroup, monitorgroup_p);
-                       if (ret)
-                               goto out;
-
-                       sprintf(tasks, "%s/mon_groups/%s/tasks",
-                               controlgroup, mongrp);
-                       ret = write_pid_to_tasks(tasks, bm_pid);
-                       if (ret)
-                               goto out;
-               }
+       /* Create monitor group and write pid into if it is used */
+       if (mongrp) {
+               sprintf(monitorgroup_p, "%s/mon_groups", controlgroup);
+               sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp);
+               ret = create_grp(mongrp, monitorgroup, monitorgroup_p);
+               if (ret)
+                       goto out;
+
+               sprintf(tasks, "%s/mon_groups/%s/tasks",
+                       controlgroup, mongrp);
+               ret = write_pid_to_tasks(tasks, bm_pid);
+               if (ret)
+                       goto out;
        }
 
 out: