public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: Paul Jackson <pj@sgi.com>
Cc: colpatch@us.ibm.com, wli@holomorphy.com, linux-kernel@vger.kernel.org
Subject: [Patch 24a/23] mask v2 - UP fix, faster mask_of_bit, MASK_ALL* names
Date: Sat, 3 Apr 2004 22:16:41 -0800	[thread overview]
Message-ID: <20040403221641.646351a0.pj@sgi.com> (raw)
In-Reply-To: <20040401122802.23521599.pj@sgi.com>

This patch replaces 24/23.  Patch 24/23 was fouled up beyond all recall.

This patch 24a/23 applies after the 23 mask v2 patches 1/23 - 23/23,
based on the 2.6.4 Linux kernel.

It closely follows some excellent suggestions from Matthew.

1) It corrects a build error for UP (1 CPU, no SMP).
   Real cpu_online_map and cpu_possible_map data words are
   needed, so that cpumask_of_cpu() will evalutate correctly
   when in used in contexts requiring a real lvalue, as in
   sys_sched_getaffinity().

2) Since the MASK_ALL* implementation alternatives (for the
   single long and multiple long cases) are split across the
   base mask.h file and the derived cpumask.h/nodemask.h files,
   rename them to MASK_ALL_SINGLE_LONG/MASK_ALL_MULTIPLE_LONG,
   as suggested by Matthew, for code clarity.

3) Optimize the single word flavor of mask_of_bit (resulting
   in better code on small systems for cpumask_of_cpu).

The mask.h header is once again (still, if you don't count 24/23) usable
in its own right.

Diffstat:
 include/linux/cpumask.h  |   11 ++++-------
 include/linux/mask.h     |   12 ++++++++----
 include/linux/nodemask.h |    4 ++--
 kernel/sched.c           |    5 +++++
 4 files changed, 19 insertions(+), 13 deletions(-)

diff -Naur Apr01/include/linux/cpumask.h Apr03/include/linux/cpumask.h
--- Apr01/include/linux/cpumask.h	2004-04-03 19:51:42.000000000 -0800
+++ Apr03/include/linux/cpumask.h	2004-04-03 19:41:04.000000000 -0800
@@ -92,9 +92,9 @@
 #define next_cpu(cpu, mask)	     mask_next((cpu), (mask), NR_CPUS)
 #define cpumask_of_cpu(cpu)	     mask_of_bit((cpu), _unused_cpumask_arg_)
 #if NR_CPUS <= BITS_PER_LONG
-#define CPU_MASK_ALL		     MASK_ALL1(NR_CPUS)
+#define CPU_MASK_ALL		     MASK_ALL_SINGLE_LONG(NR_CPUS)
 #else
-#define CPU_MASK_ALL		     MASK_ALL2(NR_CPUS)
+#define CPU_MASK_ALL		     MASK_ALL_MULTIPLE_LONG(NR_CPUS)
 #endif
 #define CPU_MASK_NONE		     MASK_NONE(NR_CPUS)
 #define cpus_addr(mask)		     mask_addr(mask)
@@ -108,11 +108,11 @@
  * on them manage all (possible) and online cpus.
  */
 
-#ifdef CONFIG_SMP
-
 extern cpumask_t cpu_online_map;
 extern cpumask_t cpu_possible_map;
 
+#ifdef CONFIG_SMP
+
 #define num_online_cpus()	     cpus_weight(cpu_online_map)
 #define num_possible_cpus()	     cpus_weight(cpu_possible_map)
 #define cpu_online(cpu)		     cpu_isset((cpu), cpu_online_map)
@@ -134,9 +134,6 @@
 
 #else /* !CONFIG_SMP */
 
-#define	cpu_online_map		     cpumask_of_cpu(0)
-#define	cpu_possible_map	     cpumask_of_cpu(0)
-
 #define num_online_cpus()	     1
 #define num_possible_cpus()	     1
 #define cpu_online(cpu)		     ({ BUG_ON((cpu) != 0); 1; })
diff -Naur Apr01/include/linux/mask.h Apr03/include/linux/mask.h
--- Apr01/include/linux/mask.h	2004-04-03 19:51:41.000000000 -0800
+++ Apr03/include/linux/mask.h	2004-04-03 20:21:19.000000000 -0800
@@ -334,19 +334,23 @@
 #define mask_of_bit(bit, T)						\
 ({									\
 	typeof(T) m;							\
-	mask_clearall(m, 8*sizeof(m));					\
-	mask_setbit((bit), m);						\
+	if (sizeof(m) == sizeof(unsigned long))				\
+		m._m[0] = 1UL<<(bit);					\
+	else {								\
+		mask_clearall(m, 8*sizeof(m));				\
+		mask_setbit((bit), m);					\
+	}								\
 	m;								\
 })
 
 /* Use if nbits <= BITS_PER_LONG */
-#define MASK_ALL1(nbits)						\
+#define MASK_ALL_SINGLE_LONG(nbits)					\
 { {									\
 	[BITS_TO_LONGS(nbits)-1] = MASK_LAST_WORD(nbits)		\
 } }
 
 /* Use if nbits > BITS_PER_LONG */
-#define MASK_ALL2(nbits)						\
+#define MASK_ALL_MULTIPLE_LONG(nbits)					\
 { {									\
 	[0 ... BITS_TO_LONGS(nbits)-2] = ~0UL,				\
 	[BITS_TO_LONGS(nbits)-1] = MASK_LAST_WORD(nbits)		\
diff -Naur Apr01/include/linux/nodemask.h Apr03/include/linux/nodemask.h
--- Apr01/include/linux/nodemask.h	2004-04-03 19:51:42.000000000 -0800
+++ Apr03/include/linux/nodemask.h	2004-04-03 19:41:04.000000000 -0800
@@ -93,9 +93,9 @@
 #define nodemask_of_node(node)		\
 			mask_of_bit((node), _unused_nodemask_arg_)
 #if MAX_NUMNODES <= BITS_PER_LONG
-#define NODE_MASK_ALL			MASK_ALL1(MAX_NUMNODES)
+#define NODE_MASK_ALL			MASK_ALL_SINGLE_LONG(MAX_NUMNODES)
 #else
-#define NODE_MASK_ALL			MASK_ALL2(MAX_NUMNODES)
+#define NODE_MASK_ALL			MASK_ALL_MULTIPLE_LONG(MAX_NUMNODES)
 #endif
 #define NODE_MASK_NONE			MASK_NONE(MAX_NUMNODES)
 #define nodes_addr(mask)			mask_addr(mask)
diff -Naur Apr01/kernel/sched.c Apr03/kernel/sched.c
--- Apr01/kernel/sched.c	2004-04-03 19:51:42.000000000 -0800
+++ Apr03/kernel/sched.c	2004-04-03 19:41:05.000000000 -0800
@@ -2340,6 +2340,11 @@
 	return retval;
 }
 
+#ifndef CONFIG_SMP
+cpumask_t cpu_online_map = CPU_MASK_ALL;
+cpumask_t cpu_possible_map = CPU_MASK_ALL;
+#endif
+
 /**
  * sys_sched_getaffinity - get the cpu affinity of a process
  * @pid: pid of the process


-- 
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <pj@sgi.com> 1.650.933.1373

      parent reply	other threads:[~2004-04-04  6:17 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-01 20:28 [Patch 0/23] mask v2 - Second version of mask, cpumask and nodemask consolidation Paul Jackson
2004-04-01 21:10 ` [Patch 1/23] mask v2 - Document bitmap.c bit model Paul Jackson
2004-04-01 21:10 ` [Patch 2/23] mask v2 - Tighten unused bitmap bit handling Paul Jackson
2004-04-01 21:11 ` [Patch 3/23] mask v2 - New bitmap operators Paul Jackson
2004-04-01 21:11 ` [Patch 4/23] mask v2 - two missing 'const' qualifiers Paul Jackson
2004-04-01 21:11 ` [Patch 5/23] mask v2 - Add new mask.h file Paul Jackson
2004-04-02 20:26   ` Matthew Dobson
2004-04-03  5:12     ` Paul Jackson
2004-04-01 21:11 ` [Patch 6/23] mask v2 - Replace cpumask_t with one using mask Paul Jackson
2004-04-02 22:24   ` Matthew Dobson
2004-04-02 23:35     ` Paul Jackson
2004-04-03  1:09       ` Matthew Dobson
2004-04-03  6:00         ` Paul Jackson
2004-04-04  5:57           ` Paul Jackson
2004-04-03  5:23     ` Paul Jackson
2004-04-01 21:11 ` [Patch 7/23] mask v2 - Remove i386 obsolete cpumask ops Paul Jackson
2004-04-01 21:11 ` [Patch 8/23] mask v2 - Remove ppc64 " Paul Jackson
2004-04-01 21:11 ` [Patch 9/23] mask v2 - Remove x86_64 " Paul Jackson
2004-04-01 21:12 ` [Patch 10/23] mask v2 - Remove obsolete cpumask emulation Paul Jackson
2004-04-01 21:12 ` [Patch 11/23] mask v2 - Add new nodemasks.h file Paul Jackson
2004-04-01 21:12 ` [Patch 12/23] mask v2 - [1/7] mmzone.h changes for nodemask Paul Jackson
2004-04-01 21:12 ` [Patch 13/23] mask v2 - [2/7] nodemask_t core changes Paul Jackson
2004-04-01 21:12 ` [Patch 14/23] mask v2 - [3/7] nodemask_t_i386_changes Paul Jackson
2004-04-01 21:12 ` [Patch 15/23] mask v2 - [4/7] nodemask_t_pp64_changes Paul Jackson
2004-04-01 21:12 ` [Patch 16/23] mask v2 - [5/7] nodemask_t_x86_64_changes Paul Jackson
2004-04-01 21:12 ` [Patch 17/23] mask v2 = [6/7] nodemask_t_ia64_changes Paul Jackson
2004-04-06 11:37   ` Paul Jackson
2004-04-07  5:55     ` Denis Vlasenko
2004-04-07  6:50       ` Paul Jackson
2004-04-07  7:44         ` Paul Jackson
2004-04-07 14:13           ` Nick Piggin
2004-04-07 14:44             ` Paul Jackson
2004-04-07 15:02               ` Nick Piggin
2004-04-07 15:21                 ` Paul Jackson
2004-04-09  7:54           ` Denis Vlasenko
2004-04-09 17:53             ` Paul Jackson
2004-04-09 20:04               ` Denis Vlasenko
2004-04-10  2:54                 ` Paul Jackson
2004-04-07 11:27         ` Paul Jackson
2004-04-09 18:54           ` Paul Jackson
2004-04-01 21:12 ` [Patch 18/23] mask v2 - [7/7] nodemask_t_other_arch_changes Paul Jackson
2004-04-01 21:12 ` [Patch 19/23] mask v2 - Simplify sparc64 cpumask loop code Paul Jackson
2004-04-01 21:12 ` [Patch 20/23] mask v2 - Optimize i386 cpumask macro usage Paul Jackson
2004-04-01 21:13 ` [Patch 21/23] mask v2 - Dyadic physids_complement() Paul Jackson
2004-04-01 21:13 ` [Patch 22/23] mask v2 - Fix cpumask in asm-x86_64/topology.h Paul Jackson
2004-04-01 21:13 ` [Patch 23/23] mask v2 - Cpumask tweak in kernel/sched.c Paul Jackson
2004-04-02  8:15 ` [Patch 24/23] mask v2 - Small system optimizations Paul Jackson
2004-04-04  5:56   ` Paul Jackson
2004-04-04  6:16 ` Paul Jackson [this message]

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=20040403221641.646351a0.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=colpatch@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wli@holomorphy.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