From: Alexander van Heukelum <heukelum@mailshack.com>
To: Paul Jackson <pj@sgi.com>, Mike Travis <travis@sgi.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
linux-arch <linux-arch@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
heukelum@fastmail.fm
Subject: [RFC/PATCH] Make for_each_node_mask out-of-line
Date: Sun, 11 May 2008 18:06:58 +0200 [thread overview]
Message-ID: <20080511160658.GA3398@mailshack.com> (raw)
In-Reply-To: <20080511091403.a75f5b78.pj@sgi.com>
The for_each_node_mask loop makes use of two inlined functions:
first_node and next_node. This patch changes for_each_node_mask
to use only one out-of-line function: find_next_node_mask. An
x86_64 defconfig kernel is about 1500 bytes smaller with this
patch applied:
text data bss dec hex filename
5395732 976736 734280 7106748 6c70bc vmlinux.orig
5394174 976736 734280 7105190 6c6aa6 vmlinux
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
Hello,
> Alexander wrote:
> > This patch
> > changes for_each_cpu_mask to use only one function: a newly
> > introduced find_next_cpu.
>
> I believe that it's for_each_cpu_mask which is newly introduced,
> not find_next_cpu ... just a typo, granted.
I meant find_next_cpu_mask. That was a last-minute change of mind
about the name :/.
> Any chance that you could make the same change to nodemask.h?
> Where practical, I like to keep cpumask.h and nodemask.h the same.
Sure. This patch introduces lib/nodemask.c, but I'm not quite sure
if building it should depend on CONFIG_SMP or something else (NUMA?).
When is MAX_NUMNODES 1?
It seems to work on qemu x86_64-smp and i386-up.
I'ld be happy to take a stab at aligning the cpumask and nodemask
code even more by uninlining some more functions and using stubs
for the MAX_NUMNODES=1 case.
Greetings,
Alexander
include/linux/nodemask.h | 11 +++++++----
lib/Makefile | 2 +-
lib/nodemask.c | 10 ++++++++++
3 files changed, 18 insertions(+), 5 deletions(-)
create mode 100644 lib/nodemask.c
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 848025c..dbc80f0 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -239,6 +239,8 @@ static inline int __next_node(int n, const nodemask_t *srcp)
return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
}
+int find_next_node_mask(int n, const nodemask_t *srcp);
+
#define nodemask_of_node(node) \
({ \
typeof(_unused_nodemask_arg_) m; \
@@ -347,10 +349,11 @@ static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp,
}
#if MAX_NUMNODES > 1
-#define for_each_node_mask(node, mask) \
- for ((node) = first_node(mask); \
- (node) < MAX_NUMNODES; \
- (node) = next_node((node), (mask)))
+#define for_each_node_mask(node, mask) \
+ for ((node) = 0; \
+ (node) = find_next_node_mask((node), &(mask)), \
+ (node) < MAX_NUMNODES; \
+ (node)++)
#else /* MAX_NUMNODES == 1 */
#define for_each_node_mask(node, mask) \
if (!nodes_empty(mask)) \
diff --git a/lib/Makefile b/lib/Makefile
index 74b0cfb..48fc85c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -9,7 +9,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
proportions.o prio_heap.o ratelimit.o
lib-$(CONFIG_MMU) += ioremap.o
-lib-$(CONFIG_SMP) += cpumask.o
+lib-$(CONFIG_SMP) += cpumask.o nodemask.o
lib-y += kobject.o kref.o klist.o
diff --git a/lib/nodemask.c b/lib/nodemask.c
new file mode 100644
index 0000000..08341d3
--- /dev/null
+++ b/lib/nodemask.c
@@ -0,0 +1,10 @@
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+#include <linux/nodemask.h>
+#include <linux/module.h>
+
+int find_next_node_mask(int n, const nodemask_t *srcp)
+{
+ return find_next_bit(srcp->bits, NR_CPUS, n);
+}
+EXPORT_SYMBOL(find_next_node_mask);
next prev parent reply other threads:[~2008-05-11 16:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-11 13:50 [PATCH] Make for_each_cpu_mask a bit smaller Alexander van Heukelum
2008-05-11 13:57 ` Paul Jackson
2008-05-11 14:14 ` Paul Jackson
2008-05-11 16:06 ` Alexander van Heukelum [this message]
2008-05-11 21:01 ` [RFC/PATCH] Make for_each_node_mask out-of-line Paul Jackson
2008-05-12 12:04 ` Alexander van Heukelum
2008-05-12 16:45 ` Mike Travis
2008-05-12 19:00 ` [PATCHv2] Make for_each_cpu_mask a bit smaller Alexander van Heukelum
2008-05-12 21:45 ` Andreas Schwab
2008-05-13 9:28 ` [PATCHv3] " Alexander van Heukelum
2008-05-13 12:02 ` Ingo Molnar
2008-05-11 15:24 ` [PATCH] " Matthew Wilcox
2008-05-11 16:19 ` Alexander van Heukelum
2008-05-11 22:01 ` Matthew Wilcox
2008-05-12 11:04 ` Alexander van Heukelum
2008-05-12 11:56 ` Matthew Wilcox
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=20080511160658.GA3398@mailshack.com \
--to=heukelum@mailshack.com \
--cc=akpm@linux-foundation.org \
--cc=heukelum@fastmail.fm \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=pj@sgi.com \
--cc=tglx@linutronix.de \
--cc=travis@sgi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.