All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
To: shuah@kernel.org, linux-kselftest@vger.kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	tony.luck@intel.com, reinette.chatre@intel.com,
	babu.moger@amd.com, james.morse@arm.com,
	ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Subject: [PATCH V1 12/13] selftests/resctrl: Dynamically select buffer size for CAT test
Date: Fri,  6 Mar 2020 19:40:53 -0800	[thread overview]
Message-ID: <18ab8b47d1d2b6373d7899bdf8df19fa94afcfaa.1583657204.git.sai.praneeth.prakhya@intel.com> (raw)
In-Reply-To: <cover.1583657204.git.sai.praneeth.prakhya@intel.com>

Presently, while running CAT test case, if user hasn't given any input for
'-n' option, the test defaults to 5 bits to determine the buffer size that
is used during test. Instead of statically running always with 5 bits,
change it such that the buffer size is always half of the cache size.

Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
---
 tools/testing/selftests/resctrl/cat_test.c      | 16 +++++++++++-----
 tools/testing/selftests/resctrl/resctrl.h       |  3 ++-
 tools/testing/selftests/resctrl/resctrl_tests.c |  7 ++++---
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index f7a67f005fe5..d1c50430ab20 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -109,7 +109,8 @@ void cat_test_cleanup(void)
 	remove(RESULT_FILE_NAME);
 }
 
-static int prepare_masks_for_two_processes(int no_of_bits, char *cache_type)
+static int prepare_masks_for_two_processes(int *no_of_bits, bool user_bits,
+					   char *cache_type)
 {
 	int ret, i;
 	unsigned long long_mask, shareable_mask;
@@ -123,12 +124,15 @@ static int prepare_masks_for_two_processes(int no_of_bits, char *cache_type)
 	long_mask = strtoul(cbm_mask, NULL, 16);
 	count_of_bits = count_bits(long_mask);
 
+	if (!user_bits)
+		*no_of_bits = count_of_bits / 2;
+
 	/*
 	 * Max limit is count_of_bits - 1 because we need exclusive masks for
 	 * the two processes. So, the last saved bit will be used by the other
 	 * process.
 	 */
-	if (no_of_bits < 1 || no_of_bits > count_of_bits - 1) {
+	if (*no_of_bits < 1 || *no_of_bits > count_of_bits - 1) {
 		printf("Invalid input value for no_of_bits 'n'\n");
 		printf("Please Enter value in range 1 to %d\n",
 		       count_of_bits - 1);
@@ -140,7 +144,7 @@ static int prepare_masks_for_two_processes(int no_of_bits, char *cache_type)
 		return ret;
 
 	/* Prepare cbm mask without any shareable bits */
-	for (i = 0; i < no_of_bits; i++) {
+	for (i = 0; i < *no_of_bits; i++) {
 		p1_mask <<= 1;
 		p1_mask |= 1;
 	}
@@ -176,7 +180,8 @@ static int start_noisy_process(pid_t pid, int sibling_cpu_no)
 	return 0;
 }
 
-int cat_perf_miss_val(int cpu_no, int no_of_bits, char *cache_type)
+int cat_perf_miss_val(int cpu_no, int no_of_bits, bool user_bits,
+		      char *cache_type)
 {
 	int ret, sibling_cpu_no;
 	unsigned long buf_size;
@@ -194,7 +199,8 @@ int cat_perf_miss_val(int cpu_no, int no_of_bits, char *cache_type)
 	if (!validate_resctrl_feature_request("cat"))
 		return -1;
 
-	ret = prepare_masks_for_two_processes(no_of_bits, cache_type);
+	ret = prepare_masks_for_two_processes(&no_of_bits, user_bits,
+					      cache_type);
 	if (ret)
 		return ret;
 
diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
index cb67ad689475..393f2f34ccac 100644
--- a/tools/testing/selftests/resctrl/resctrl.h
+++ b/tools/testing/selftests/resctrl/resctrl.h
@@ -102,7 +102,8 @@ void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
 int setup_critical_process(pid_t pid, struct resctrl_val_param *param);
 int run_critical_process(pid_t pid, struct resctrl_val_param *param);
 void cat_test_cleanup(void);
-int cat_perf_miss_val(int cpu_no, int no_of_bits, char *cache_type);
+int cat_perf_miss_val(int cpu_no, int no_of_bits, bool user_bits,
+		      char *cache_type);
 int cqm_schemata_change(int cpu_no, int span, char *cache_type,
 			char **benchmark_cmd);
 unsigned int count_bits(unsigned long n);
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
index 3c408c636b6d..4461c3dc8cce 100644
--- a/tools/testing/selftests/resctrl/resctrl_tests.c
+++ b/tools/testing/selftests/resctrl/resctrl_tests.c
@@ -57,11 +57,11 @@ void tests_cleanup(void)
 int main(int argc, char **argv)
 {
 	bool has_ben = false, mbm_test = true, mba_test = true, cqm_test = true;
-	int res, c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits = 5;
+	int res, c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits;
 	char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64];
 	char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE];
 	int ben_ind, ben_count;
-	bool cat_test = true;
+	bool cat_test = true, user_bits = false;
 
 	for (i = 0; i < argc; i++) {
 		if (strcmp(argv[i], "-b") == 0) {
@@ -105,6 +105,7 @@ int main(int argc, char **argv)
 			cpu_no = atoi(optarg);
 			break;
 		case 'n':
+			user_bits = true;
 			no_of_bits = atoi(optarg);
 			break;
 		case 'h':
@@ -192,7 +193,7 @@ int main(int argc, char **argv)
 
 	if (cat_test) {
 		printf("# Starting CAT test ...\n");
-		res = cat_perf_miss_val(cpu_no, no_of_bits, "L3");
+		res = cat_perf_miss_val(cpu_no, no_of_bits, user_bits, "L3");
 		printf("%sok CAT: test\n", res ? "not " : "");
 		cat_test_cleanup();
 		tests_run++;
-- 
2.7.4


  parent reply	other threads:[~2020-03-07  3:46 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-07  3:40 [PATCH V1 00/13] Miscellaneous fixes for resctrl selftests Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 01/13] selftests/resctrl: Fix feature detection Sai Praneeth Prakhya
2020-03-09 21:44   ` Reinette Chatre
2020-03-09 22:22     ` Prakhya, Sai Praneeth
2020-03-09 22:33       ` Reinette Chatre
2020-03-09 22:51         ` Prakhya, Sai Praneeth
2020-03-11 18:06           ` Reinette Chatre
2020-03-11 18:22             ` Sai Praneeth Prakhya
2020-03-11 18:45               ` Reinette Chatre
2020-03-11 18:54                 ` Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 02/13] selftests/resctrl: Fix typo Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 03/13] selftests/resctrl: Fix typo in help text Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 04/13] selftests/resctrl: Ensure sibling CPU is not same as original CPU Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 05/13] selftests/resctrl: Fix missing options "-n" and "-p" Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 06/13] selftests/resctrl: Fix MBA/MBM results reporting format Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 07/13] selftests/resctrl: Don't use variable argument list for setup function Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 08/13] selftests/resctrl: Fix typos Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 09/13] selftests/resctrl: Modularize fill_buf for new CAT test case Sai Praneeth Prakhya
2020-03-10 21:59   ` Reinette Chatre
2020-03-11  1:04     ` Sai Praneeth Prakhya
2020-03-11 15:44       ` Reinette Chatre
2020-03-11 17:45         ` Sai Praneeth Prakhya
2020-03-11 18:10           ` Reinette Chatre
2020-03-11 18:14             ` Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 10/13] selftests/resctrl: Change Cache Allocation Technology (CAT) test Sai Praneeth Prakhya
2020-03-10 22:14   ` Reinette Chatre
2020-03-11  1:59     ` Sai Praneeth Prakhya
2020-03-11 17:03       ` Reinette Chatre
2020-03-11 19:14         ` Sai Praneeth Prakhya
2020-03-11 20:22           ` Reinette Chatre
2020-03-11 20:55             ` Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 11/13] selftests/resctrl: Change Cache Quality Monitoring (CQM) test Sai Praneeth Prakhya
2020-03-10 22:18   ` Reinette Chatre
2020-03-11  2:46     ` Sai Praneeth Prakhya
2020-03-11 17:19       ` Reinette Chatre
2020-03-11 17:33         ` Sai Praneeth Prakhya
2020-03-11 18:03           ` Reinette Chatre
2020-03-11 18:07             ` Sai Praneeth Prakhya
2020-03-07  3:40 ` Sai Praneeth Prakhya [this message]
2020-03-10 22:19   ` [PATCH V1 12/13] selftests/resctrl: Dynamically select buffer size for CAT test Reinette Chatre
2020-03-11  2:52     ` Sai Praneeth Prakhya
2020-03-07  3:40 ` [PATCH V1 13/13] selftests/resctrl: Cleanup fill_buff after changing " Sai Praneeth Prakhya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18ab8b47d1d2b6373d7899bdf8df19fa94afcfaa.1583657204.git.sai.praneeth.prakhya@intel.com \
    --to=sai.praneeth.prakhya@intel.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=fenghua.yu@intel.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=reinette.chatre@intel.com \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.