Received: from mnm [127.0.0.1]
	by localhost with POP3 (fetchmail-5.9.0)
	for akpm@localhost (single-drop); Tue, 05 Aug 2003 23:07:05 -0700 (PDT)
Received: from fire-1.osdl.org (air1.pdx.osdl.net [172.20.0.5])
	by mail.osdl.org (8.11.6/8.11.6) with ESMTP id h7664sI07443
	for <akpm@osdl.org>; Tue, 5 Aug 2003 23:04:54 -0700
Received: from holomorphy (mail@holomorphy.com [66.224.33.161])
	by fire-1.osdl.org (8.12.8/8.12.8) with ESMTP id h7664re5026618
	for <akpm@osdl.org>; Tue, 5 Aug 2003 23:04:54 -0700
Received: from wli by holomorphy with local (Exim 3.36 #1 (Debian))
	id 19kHR4-00021e-00; Tue, 05 Aug 2003 23:06:10 -0700
Date: Tue, 5 Aug 2003 23:06:10 -0700
From: William Lee Irwin III <wli@holomorphy.com>
To: Andrew Morton <akpm@osdl.org>
Subject: Re: flush_cpumask atomicity?
Message-ID: <20030806060610.GJ8121@holomorphy.com>
References: <20030805185529.1f5ac3b9.akpm@osdl.org> <20030806020154.GH8121@holomorphy.com> <20030805191110.3f71f743.akpm@osdl.org> <20030806023116.GI8121@holomorphy.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20030806023116.GI8121@holomorphy.com>
Organization: The Domain of Holomorphy
User-Agent: Mutt/1.5.4i
X-Spam-Status: No, hits=-39.0 required=6.0
	tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PATCH_UNIFIED_DIFF,
	      QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES,
	      USER_AGENT_MUTT
	autolearn=ham version=2.53
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53 (1.174.2.15-2003-03-30-exp)

On Tue, Aug 05, 2003 at 07:31:16PM -0700, William Lee Irwin III wrote:
> I can doublecheck performance real quick before I stamp it. It should
> look a lot like page-flags.h that way.

Oh, yeah, it helps if I hit 'y' in mutt:

(a) replace arithmetic cpumasks' cpu-setting and clearing functions
	with the atomic operation equivalents
(b) explain what cpumask_arith means
(c) explain what cpumask_array means


-- wli

diff -prauN mm4-2.6.0-test2-3/include/asm-generic/cpumask_arith.h mm4-2.6.0-test2-4/include/asm-generic/cpumask_arith.h
--- mm4-2.6.0-test2-3/include/asm-generic/cpumask_arith.h	2003-08-05 12:07:33.000000000 -0700
+++ mm4-2.6.0-test2-4/include/asm-generic/cpumask_arith.h	2003-08-05 22:26:57.000000000 -0700
@@ -1,18 +1,15 @@
 #ifndef __ASM_GENERIC_CPUMASK_ARITH_H
 #define __ASM_GENERIC_CPUMASK_ARITH_H
 
-#define cpu_set(cpu, map)				\
-	do {						\
-		map |= ((cpumask_t)1) << (cpu);		\
-	} while (0)
-#define cpu_clear(cpu, map)				\
-	do {						\
-		map &= ~(((cpumask_t)1) << (cpu));	\
-	} while (0)
-#define cpu_isset(cpu, map)				\
-	((map) & (((cpumask_t)1) << (cpu)))
-#define cpu_test_and_set(cpu, map)			\
-	test_and_set_bit(cpu, (unsigned long *)(&(map)))
+/*
+ * Arithmetic type -based cpu bitmaps. A single unsigned long is used
+ * to contain the whole cpu bitmap.
+ */
+
+#define cpu_set(cpu, map)		set_bit(cpu, &(map))
+#define cpu_clear(cpu, map)		clear_bit(cpu, &(map))
+#define cpu_isset(cpu, map)		test_bit(cpu, &(map))
+#define cpu_test_and_set(cpu, map)	test_and_set_bit(cpu, &(map))
 
 #define cpus_and(dst,src1,src2)		do { dst = (src1) & (src2); } while (0)
 #define cpus_or(dst,src1,src2)		do { dst = (src1) | (src2); } while (0)
@@ -41,7 +38,6 @@
 #define cpumask_of_cpu(cpu)		({ ((cpumask_t)1) << (cpu); })
 
 #define first_cpu(map)			__ffs(map)
-#define next_cpu(cpu, map)				\
-	__ffs((map) & ~(((cpumask_t)1 << (cpu)) - 1))
+#define next_cpu(cpu, map)		find_next_bit(&(map), NR_CPUS, cpu + 1)
 
 #endif /* __ASM_GENERIC_CPUMASK_ARITH_H */
diff -prauN mm4-2.6.0-test2-3/include/asm-generic/cpumask_array.h mm4-2.6.0-test2-4/include/asm-generic/cpumask_array.h
--- mm4-2.6.0-test2-3/include/asm-generic/cpumask_array.h	2003-08-05 12:07:52.000000000 -0700
+++ mm4-2.6.0-test2-4/include/asm-generic/cpumask_array.h	2003-08-05 22:37:29.000000000 -0700
@@ -1,6 +1,12 @@
 #ifndef __ASM_GENERIC_CPUMASK_ARRAY_H
 #define __ASM_GENERIC_CPUMASK_ARRAY_H
 
+/*
+ * Array-based cpu bitmaps. An array of unsigned longs is used to contain
+ * the bitmap, and then contained in a structure so it may be passed by
+ * value.
+ */
+
 #define CPU_ARRAY_SIZE		BITS_TO_LONGS(NR_CPUS)
 
 #define cpu_set(cpu, map)		set_bit(cpu, (map).mask)
