From 5d1f479a00fe7df60e46d8e0d48b5e50f09e026b Mon Sep 17 00:00:00 2001
From: attilio <attilio@FreeBSD.org>
Date: Sat, 30 Apr 2011 22:33:11 +0000
Subject: Remove unnecessary usage of memory barriers when dealing with
 pmc_cpumask.

Discussed with:	fabient
---
 sys/dev/hwpmc/hwpmc_mod.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'sys/dev/hwpmc')

diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 4fa169c..55ed262 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -4083,7 +4083,7 @@ pmc_process_interrupt(int cpu, struct pmc *pm, struct trapframe *tf,
 
  done:
 	/* mark CPU as needing processing */
-	atomic_set_rel_int(&pmc_cpumask, (1 << cpu));
+	atomic_set_int(&pmc_cpumask, (1 << cpu));
 
 	return (error);
 }
@@ -4193,7 +4193,7 @@ pmc_process_samples(int cpu)
 			break;
 		if (ps->ps_nsamples == PMC_SAMPLE_INUSE) {
 			/* Need a rescan at a later time. */
-			atomic_set_rel_int(&pmc_cpumask, (1 << cpu));
+			atomic_set_int(&pmc_cpumask, (1 << cpu));
 			break;
 		}
 
@@ -4782,7 +4782,7 @@ pmc_cleanup(void)
 	PMCDBG(MOD,INI,0, "%s", "cleanup");
 
 	/* switch off sampling */
-	atomic_store_rel_int(&pmc_cpumask, 0);
+	atomic_store_int(&pmc_cpumask, 0);
 	pmc_intr = NULL;
 
 	sx_xlock(&pmc_sx);
-- 
cgit v1.1


From 3fcaa270bf26cf5b7b13f23688accabede67dd29 Mon Sep 17 00:00:00 2001
From: attilio <attilio@FreeBSD.org>
Date: Sat, 30 Apr 2011 22:34:44 +0000
Subject: Fix a typo/error.

---
 sys/dev/hwpmc/hwpmc_mod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'sys/dev/hwpmc')

diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 55ed262..d6225d8 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -4782,7 +4782,7 @@ pmc_cleanup(void)
 	PMCDBG(MOD,INI,0, "%s", "cleanup");
 
 	/* switch off sampling */
-	atomic_store_int(&pmc_cpumask, 0);
+	pmc_cpumask = 0;
 	pmc_intr = NULL;
 
 	sx_xlock(&pmc_sx);
-- 
cgit v1.1


From fe4de567b50f7ca317b16f69b7b3a7de693025af Mon Sep 17 00:00:00 2001
From: attilio <attilio@FreeBSD.org>
Date: Thu, 5 May 2011 14:39:14 +0000
Subject: Commit the support for removing cpumask_t and replacing it directly
 with cpuset_t objects. That is going to offer the underlying support for a
 simple bump of MAXCPU and then support for number of cpus > 32 (as it is
 today).

Right now, cpumask_t is an int, 32 bits on all our supported architecture.
cpumask_t on the other side is implemented as an array of longs, and
easilly extendible by definition.

The architectures touched by this commit are the following:
- amd64
- i386
- pc98
- arm
- ia64
- XEN

while the others are still missing.
Userland is believed to be fully converted with the changes contained
here.

Some technical notes:
- This commit may be considered an ABI nop for all the architectures
  different from amd64 and ia64 (and sparc64 in the future)
- per-cpu members, which are now converted to cpuset_t, needs to be
  accessed avoiding migration, because the size of cpuset_t should be
  considered unknown
- size of cpuset_t objects is different from kernel and userland (this is
  primirally done in order to leave some more space in userland to cope
  with KBI extensions). If you need to access kernel cpuset_t from the
  userland please refer to example in this patch on how to do that
  correctly (kgdb may be a good source, for example).
- Support for other architectures is going to be added soon
- Only MAXCPU for amd64 is bumped now

The patch has been tested by sbruno and Nicholas Esborn on opteron
4 x 12 pack CPUs. More testing on big SMP is expected to came soon.
pluknet tested the patch with his 8-ways on both amd64 and i386.

Tested by:	pluknet, sbruno, gianni, Nicholas Esborn
Reviewed by:	jeff, jhb, sbruno
---
 sys/dev/hwpmc/hwpmc_mod.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'sys/dev/hwpmc')

diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index d6225d8..4cfcea8 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -1991,7 +1991,7 @@ pmc_hook_handler(struct thread *td, int function, void *arg)
 		 * had already processed the interrupt).  We don't
 		 * lose the interrupt sample.
 		 */
-		atomic_clear_int(&pmc_cpumask, (1 << PCPU_GET(cpuid)));
+		CPU_CLR_ATOMIC(PCPU_GET(cpuid), &pmc_cpumask);
 		pmc_process_samples(PCPU_GET(cpuid));
 		break;
 
@@ -4083,7 +4083,7 @@ pmc_process_interrupt(int cpu, struct pmc *pm, struct trapframe *tf,
 
  done:
 	/* mark CPU as needing processing */
-	atomic_set_int(&pmc_cpumask, (1 << cpu));
+	CPU_SET_ATOMIC(cpu, &pmc_cpumask);
 
 	return (error);
 }
@@ -4193,7 +4193,7 @@ pmc_process_samples(int cpu)
 			break;
 		if (ps->ps_nsamples == PMC_SAMPLE_INUSE) {
 			/* Need a rescan at a later time. */
-			atomic_set_int(&pmc_cpumask, (1 << cpu));
+			CPU_SET_ATOMIC(cpu, &pmc_cpumask);
 			break;
 		}
 
@@ -4782,7 +4782,7 @@ pmc_cleanup(void)
 	PMCDBG(MOD,INI,0, "%s", "cleanup");
 
 	/* switch off sampling */
-	pmc_cpumask = 0;
+	CPU_ZERO(&pmc_cpumask);
 	pmc_intr = NULL;
 
 	sx_xlock(&pmc_sx);
-- 
cgit v1.1