From: Andrew Morton <akpm@osdl.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: viro@ftp.linux.org.uk, kernel-stuff@comcast.net,
linux-kernel@vger.kernel.org, alex-kernel@digriz.org.uk,
jun.nakajima@intel.com, davej@redhat.com
Subject: Re: OOPS: 2.6.16-rc6 cpufreq_conservative
Date: Sun, 19 Mar 2006 14:35:13 -0800 [thread overview]
Message-ID: <20060319143513.05f8ac94.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0603191412270.3826@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> wrote:
>
> How does this patch look?
>
Wonderful - coz it's just like mine ;)
(4 patches temp-joined below)
- I made SMP=n next_cpu() just a constant "1".
- It's odd that the code uses (NR_CPUS>1) rather than CONFIG_SMP. On x86
(at least), SMP=y,NR_CPUS==1 isn't allowed anyway.
From: Andrew Morton <akpm@osdl.org>
text data bss dec hex filename
before: 3490577 1322408 360000 5172985 4eeef9 vmlinux
after: 3488027 1322496 360128 5170651 4ee5db vmlinux
Cc: Paul Jackson <pj@sgi.com>
DESC
cpumask: uninline next_cpu()
EDESC
From: Andrew Morton <akpm@osdl.org>
text data bss dec hex filename
before: 3488027 1322496 360128 5170651 4ee5db vmlinux
after: 3485112 1322480 359968 5167560 4ed9c8 vmlinux
2931 bytes saved
Cc: Paul Jackson <pj@sgi.com>
DESC
cpumask: uninline highest_possible_processor_id()
EDESC
From: Andrew Morton <akpm@osdl.org>
Shrinks the only caller (net/bridge/netfilter/ebtables.c) by 174 bytes.
Also, optimise highest_possible_processor_id() out of existence on
CONFIG_SMP=n.
Cc: Paul Jackson <pj@sgi.com>
DESC
cpumask: uninline any_online_cpu()
EDESC
From: Andrew Morton <akpm@osdl.org>
text data bss dec hex filename
before: 3605597 1363528 363328 5332453 515de5 vmlinux
after: 3605295 1363612 363200 5332107 515c8b vmlinux
218 bytes saved.
Also, optimise any_online_cpu() out of existence on CONFIG_SMP=n.
This function seems inefficient. Can't we simply AND the two masks, then use
find_first_bit()?
Cc: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---
include/linux/cpumask.h | 46 ++++++++++++++------------------------
lib/Makefile | 2 +
lib/cpumask.c | 45 +++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+), 29 deletions(-)
diff -puN include/linux/cpumask.h~cpumask-uninline-first_cpu include/linux/cpumask.h
--- devel/include/linux/cpumask.h~cpumask-uninline-first_cpu 2006-03-19 14:26:35.000000000 -0800
+++ devel-akpm/include/linux/cpumask.h 2006-03-19 14:28:45.000000000 -0800
@@ -212,17 +212,15 @@ static inline void __cpus_shift_left(cpu
bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
}
-#define first_cpu(src) __first_cpu(&(src), NR_CPUS)
-static inline int __first_cpu(const cpumask_t *srcp, int nbits)
-{
- return min_t(int, nbits, find_first_bit(srcp->bits, nbits));
-}
-
-#define next_cpu(n, src) __next_cpu((n), &(src), NR_CPUS)
-static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
-{
- return min_t(int, nbits, find_next_bit(srcp->bits, nbits, n+1));
-}
+#ifdef CONFIG_SMP
+int __first_cpu(const cpumask_t *srcp);
+#define first_cpu(src) __first_cpu(&(src))
+int __next_cpu(int n, const cpumask_t *srcp);
+#define next_cpu(n, src) __next_cpu((n), &(src))
+#else
+#define first_cpu(src) 0
+#define next_cpu(n, src) 1
+#endif
#define cpumask_of_cpu(cpu) \
({ \
@@ -398,27 +396,17 @@ extern cpumask_t cpu_present_map;
#define cpu_present(cpu) ((cpu) == 0)
#endif
-#define any_online_cpu(mask) \
-({ \
- int cpu; \
- for_each_cpu_mask(cpu, (mask)) \
- if (cpu_online(cpu)) \
- break; \
- cpu; \
-})
+#ifdef CONFIG_SMP
+int highest_possible_processor_id(void);
+#define any_online_cpu(mask) __any_online_cpu(&(mask))
+int __any_online_cpu(const cpumask_t *mask);
+#else
+#define highest_possible_processor_id() 0
+#define any_online_cpu(mask) 0
+#endif
#define for_each_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map)
#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
-/* Find the highest possible smp_processor_id() */
-#define highest_possible_processor_id() \
-({ \
- unsigned int cpu, highest = 0; \
- for_each_cpu_mask(cpu, cpu_possible_map) \
- highest = cpu; \
- highest; \
-})
-
-
#endif /* __LINUX_CPUMASK_H */
diff -puN /dev/null lib/cpumask.c
--- /dev/null 2003-09-15 06:40:47.000000000 -0700
+++ devel-akpm/lib/cpumask.c 2006-03-19 14:28:45.000000000 -0800
@@ -0,0 +1,45 @@
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+#include <linux/cpumask.h>
+#include <linux/module.h>
+
+int __first_cpu(const cpumask_t *srcp)
+{
+ return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
+}
+EXPORT_SYMBOL(__first_cpu);
+
+int __next_cpu(int n, const cpumask_t *srcp)
+{
+ return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
+}
+EXPORT_SYMBOL(__next_cpu);
+
+/*
+ * Find the highest possible smp_processor_id()
+ *
+ * Note: if we're prepared to assume that cpu_possible_map never changes
+ * (reasonable) then this function should cache its return value.
+ */
+int highest_possible_processor_id(void)
+{
+ unsigned int cpu;
+ unsigned highest = 0;
+
+ for_each_cpu_mask(cpu, cpu_possible_map)
+ highest = cpu;
+ return highest;
+}
+EXPORT_SYMBOL(highest_possible_processor_id);
+
+int __any_online_cpu(const cpumask_t *mask)
+{
+ int cpu;
+
+ for_each_cpu_mask(cpu, *mask) {
+ if (cpu_online(cpu))
+ break;
+ }
+ return cpu;
+}
+EXPORT_SYMBOL(__any_online_cpu);
diff -puN lib/Makefile~cpumask-uninline-first_cpu lib/Makefile
--- devel/lib/Makefile~cpumask-uninline-first_cpu 2006-03-19 14:26:35.000000000 -0800
+++ devel-akpm/lib/Makefile 2006-03-19 14:26:35.000000000 -0800
@@ -7,6 +7,8 @@ lib-y := errno.o ctype.o string.o vsprin
idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
sha1.o
+lib-$(CONFIG_SMP) += cpumask.o
+
lib-y += kobject.o kref.o kobject_uevent.o klist.o
obj-y += sort.o parser.o halfmd4.o iomap_copy.o
_
next prev parent reply other threads:[~2006-03-19 22:38 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-18 20:25 Parag Warudkar
2006-03-18 21:40 ` Linus Torvalds
2006-03-18 22:09 ` Parag Warudkar
2006-03-18 23:12 ` Linus Torvalds
2006-03-18 22:26 ` Parag Warudkar
2006-03-19 0:53 ` Andrew Morton
2006-03-19 2:38 ` Linus Torvalds
2006-03-19 5:08 ` Paul Jackson
2006-03-19 17:43 ` Linus Torvalds
2006-03-19 18:46 ` Linus Torvalds
2006-03-19 19:02 ` Linus Torvalds
2006-03-19 19:33 ` Linus Torvalds
2006-03-19 19:40 ` Al Viro
2006-03-19 20:01 ` Linus Torvalds
2006-03-19 20:31 ` Linus Torvalds
2006-03-19 20:47 ` Andrew Morton
2006-03-19 22:18 ` Linus Torvalds
2006-03-19 22:35 ` Andrew Morton [this message]
2006-03-19 22:55 ` Linus Torvalds
2006-03-19 22:46 ` Linus Torvalds
2006-03-19 23:04 ` Andrew Morton
2006-03-19 20:57 ` Parag Warudkar
2006-03-20 6:12 ` Willy Tarreau
2006-03-20 6:26 ` Linus Torvalds
2006-03-20 7:18 ` Willy Tarreau
2006-03-21 6:32 ` Willy Tarreau
2006-03-20 8:22 ` Peter T. Breuer
2006-03-19 6:34 ` Parag Warudkar
2006-03-19 12:00 ` Alexander Clouter
2006-03-19 14:06 ` Parag Warudkar
2006-03-19 17:34 ` Alexander Clouter
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=20060319143513.05f8ac94.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=alex-kernel@digriz.org.uk \
--cc=davej@redhat.com \
--cc=jun.nakajima@intel.com \
--cc=kernel-stuff@comcast.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=viro@ftp.linux.org.uk \
/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
all inboxes | Powered by JetHome®