mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luming Yu <luming.yu@gmail.com>
To: arnd@arndb.de, linux-kernel@vger.kernel.org
Cc: Luming Yu <luming.yu@gmail.com>, Luming Yu <luming.yu@intel.com>
Subject: [PATCH 04/13] HW-latency: Differentiate three modes to use CPU carry out testing
Date: Sun,  4 Nov 2012 20:59:35 -0500	[thread overview]
Message-ID: <1352080784-30839-5-git-send-email-luming.yu@gmail.com> (raw)
In-Reply-To: <1352080784-30839-1-git-send-email-luming.yu@gmail.com>

0: all online cpus
1: any one of online cpus
2: all online cpus sequentially run test

Signed-off-by: Luming Yu <luming.yu@intel.com>
---
 drivers/misc/hw_latency_test.c | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/hw_latency_test.c b/drivers/misc/hw_latency_test.c
index 8a8c6ba..4303644 100644
--- a/drivers/misc/hw_latency_test.c
+++ b/drivers/misc/hw_latency_test.c
@@ -47,6 +47,7 @@ static unsigned long buf_size = 262144UL;
 static struct task_struct *kthread;
 
 struct sample {
+	unsigned int cpu;
 	u64	seqnum;
 	u64	duration;
 	struct timespec	timestamp;
@@ -70,6 +71,7 @@ static struct data {
 static ktime_t	now;
 struct sample_function {
 	const char *name;
+	u8	type; /* 0=all parallel, 1=anyone, 2=all sequential*/
 	struct list_head list;
 	int (*get_sample)(void *unused);
 };
@@ -186,14 +188,11 @@ static int get_freq_sample(void *unused)
 	u32	sample = 0;
 	int	ret = 1;
 	unsigned int cpu_tsc_freq;
-	static DEFINE_MUTEX(freq_pit_mutex);
 
 	start = ktime_get();
 	do {
 		t1 = ktime_get();
-		mutex_lock(&freq_pit_mutex);
 		cpu_tsc_freq = x86_platform.calibrate_tsc();
-		mutex_unlock(&freq_pit_mutex);
 		t2 = ktime_get();
 		total = ktime_to_us(ktime_sub(t2, start));
 		diff = abs(cpu_tsc_freq - tsc_khz);
@@ -249,23 +248,30 @@ out:
 
 struct sample_function tsc_sample = {
 	.name		= "tsc",
+	.type		= 0,
 	.get_sample 	= get_tsc_sample,
 };
 
 struct sample_function tsc_freq_sample = {
 	.name		= "freq",
+	.type		= 2,
 	.get_sample 	= get_freq_sample,
 };
 
 struct sample_function random_bytes_sample = {
 	.name		= "random_bytes",
+	.type		= 0,
 	.get_sample 	= get_random_bytes_sample,
 };
 
+static DECLARE_BITMAP(testing_cpu_map, NR_CPUS);
+
 static int kthread_fn(void *unused)
 {
 	int err = 0;
 	u64 interval = 0;
+	int cpu;
+	struct cpumask *testing_cpu_mask = to_cpumask(testing_cpu_map);
 	int (*get_sample)(void *unused);
 	
 	mutex_lock(&sample_function_mutex);
@@ -274,10 +280,31 @@ static int kthread_fn(void *unused)
 	else
 		goto out;
 
+	cpumask_or(testing_cpu_mask, testing_cpu_mask, cpu_online_mask);
 	while (!kthread_should_stop()) {
 		mutex_lock(&data.lock);
-	
-		err = stop_machine(get_sample, unused, cpu_online_mask);
+
+		switch (current_sample_func->type) {
+		case 0:
+			err = stop_machine(get_sample, unused, testing_cpu_mask);
+			break;
+		case 1:
+			err = stop_machine(get_sample, unused, NULL);
+			break;
+		case 2:
+			for_each_cpu(cpu, cpu_online_mask) {
+				cpumask_clear(testing_cpu_mask);
+				cpumask_set_cpu(cpu, testing_cpu_mask);
+				err = stop_machine(get_sample, unused, NULL);
+				if (err)
+					break;
+			}
+			break;
+		default:
+			mutex_unlock(&data.lock);
+			goto err_out;
+		}
+
 		if (err) {
 			mutex_unlock(&data.lock);
 			goto err_out;
-- 
1.7.12.1


  parent reply	other threads:[~2012-11-04 13:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05  1:59 [PATCH 00/13] A simple hardware detector for latency as well as throughtput ver 0.10 Luming Yu
2012-11-05  1:59 ` [PATCH 01/13] HW-latency: hardware latency test 0.10 Luming Yu
2012-11-04 21:07   ` Maarten Lankhorst
2012-11-05 12:14     ` Luming Yu
2012-11-04 21:23   ` John Kacur
2012-11-05 12:20     ` Luming Yu
2012-11-05  8:44   ` No recipient
2012-11-05  8:44   ` Ove Karlsen
2012-11-05  1:59 ` [PATCH 02/13] HW-latency: Fix a lockdep warnning Luming Yu
2012-11-05  1:59 ` [PATCH 03/13] HW-latency: Use get_random_bytes_arch Luming Yu
2012-11-05  1:59 ` Luming Yu [this message]
2012-11-05  1:59 ` [PATCH 05/13] HW-latency: Add CPU field in sample output Luming Yu
2012-11-05  1:59 ` [PATCH 06/13] HW-latency: cycle through all online cpus to re-test cpufreq Luming Yu
2012-11-05  1:59 ` [PATCH 07/13] HW-latency: delete too many "Fast TSC calibration using PIT" in cpufreq sampling Luming Yu
2012-11-05  1:59 ` [PATCH 08/13] HW-latency: A stupid memory scanner for raw memory latency test Luming Yu
2012-11-05  1:59 ` [PATCH 09/13] HW-latency: Fix unwanted crash caused by write to dummy debugfs interface Luming Yu
2012-11-05  1:59 ` [PATCH 10/13] HW-latency: add address range for x86-32 Luming Yu
2012-11-05  1:59 ` [PATCH 11/13] HW-latency: fix a warnning in previous patch Luming Yu
2012-11-05  1:59 ` [PATCH 12/13] HW-latency: Add sample unit in sample data Luming Yu
2012-11-05  1:59 ` [PATCH 13/13] HW-latency: some sample data format change Luming Yu
2012-11-08 16:04 ` [PATCH 00/13] A simple hardware detector for latency as well as throughtput ver 0.10 Theodore Ts'o

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=1352080784-30839-5-git-send-email-luming.yu@gmail.com \
    --to=luming.yu@gmail.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luming.yu@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome