From: Mel Gorman <mel@csn.ul.ie>
To: Lee.Schermerhorn@hp.com, ak@suse.de, clameter@sgi.com
Cc: Mel Gorman <mel@csn.ul.ie>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 6/6] Use macros instead of static inline functions for zonelist iterators
Date: Fri, 31 Aug 2007 21:53:39 +0100 (IST) [thread overview]
Message-ID: <20070831205339.22283.40267.sendpatchset@skynet.skynet.ie> (raw)
In-Reply-To: <20070831205139.22283.71284.sendpatchset@skynet.skynet.ie>
gcc-3.4 and probably older compiler versions produce worse code for static
inline functions than they do for macros. Due to the fact the allocator
path is a hotpath, there is approximately a 0.2% performance difference on
kernbench's System CPU times when using static inline functions. This is
not a problem on gcc 4.1.
This patch should be ignored because the static inline functions come with
type-checking and there doesn't need to be concern about macro arguements
having funky side-effects. However, as the performance problem is noticable
on older compilers, the compiler version and this patch should be checked
as the potential source and solution to a performance regression.
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
---
include/linux/gfp.h | 8 ++++----
include/linux/mmzone.h | 31 +++++++++++++++++++------------
2 files changed, 23 insertions(+), 16 deletions(-)
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.23-rc3-mm1-040_use_one_zonelist/include/linux/gfp.h linux-2.6.23-rc3-mm1-045_macro_not_inline/include/linux/gfp.h
--- linux-2.6.23-rc3-mm1-040_use_one_zonelist/include/linux/gfp.h 2007-08-31 17:22:55.000000000 +0100
+++ linux-2.6.23-rc3-mm1-045_macro_not_inline/include/linux/gfp.h 2007-08-31 17:23:10.000000000 +0100
@@ -156,11 +156,11 @@ static inline gfp_t set_migrateflags(gfp
*
* For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets
* optimized to &contig_page_data at compile-time.
+ *
+ * See the explanation above zonelist_zone() in include/linux/mmzone.h as
+ * to why this is a macro and not a static inline
*/
-static inline struct zonelist *node_zonelist(int nid)
-{
- return &NODE_DATA(nid)->node_zonelist;
-}
+#define node_zonelist(nid) (&NODE_DATA(nid)->node_zonelist)
#ifndef HAVE_ARCH_FREE_PAGE
static inline void arch_free_page(struct page *page, int order) { }
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.23-rc3-mm1-040_use_one_zonelist/include/linux/mmzone.h linux-2.6.23-rc3-mm1-045_macro_not_inline/include/linux/mmzone.h
--- linux-2.6.23-rc3-mm1-040_use_one_zonelist/include/linux/mmzone.h 2007-08-31 18:06:59.000000000 +0100
+++ linux-2.6.23-rc3-mm1-045_macro_not_inline/include/linux/mmzone.h 2007-08-31 17:23:10.000000000 +0100
@@ -687,15 +687,16 @@ extern struct zone *next_zone(struct zon
#endif
#define ZONELIST_ZONEIDX_MASK ((1UL << ZONES_SHIFT) - 1)
-static inline struct zone *zonelist_zone(unsigned long zone_addr)
-{
- return (struct zone *)(zone_addr & ~ZONELIST_ZONEIDX_MASK);
-}
-static inline int zonelist_zone_idx(unsigned long zone_addr)
-{
- return zone_addr & ZONELIST_ZONEIDX_MASK;
-}
+/*
+ * Subtle: These are macros, not static inlines because gcc 3.4 at least
+ * produces worse code with static inline functions. The effect is about 0.4%
+ * regression in kernbench tests. The problem doesn't appear to exist on
+ * gcc 4.1
+ */
+#define zonelist_zone_idx(zone_addr) ((zone_addr) & ZONELIST_ZONEIDX_MASK)
+#define zonelist_zone(zone_addr) \
+ ((struct zone *)((zone_addr) & ~ZONELIST_ZONEIDX_MASK))
static inline unsigned long encode_zone_idx(struct zone *zone)
{
@@ -706,13 +707,19 @@ static inline unsigned long encode_zone_
return encoded;
}
-static inline int zone_in_nodemask(unsigned long zone_addr, nodemask_t *nodes)
-{
#ifdef CONFIG_NUMA
- return node_isset(zonelist_zone(zone_addr)->node, *nodes);
+#define zone_in_nodemask(zone_addr, nodes) \
+ (node_isset(zonelist_zone(zone_addr)->node, *nodes))
#else
- return 1;
+#define zone_in_nodemask(zone_addr, nodes) (1)
#endif /* CONFIG_NUMA */
+
+static inline int zone_in_nodemask(unsigned long zone_addr, nodemask_t *nodes)
+{
+ if (NUMA_BUILD)
+ return node_isset(zonelist_zone(zone_addr)->node, *nodes);
+
+ return 1;
}
/* Returns the first zone at or below highest_zoneidx in a zonelist */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2007-08-31 20:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-31 20:51 [PATCH 0/6] Use one zonelist per node instead of multiple zonelists v5 Mel Gorman
2007-08-31 20:51 ` [PATCH 1/6] Use zonelists instead of zones when direct reclaiming pages Mel Gorman
2007-08-31 20:52 ` [PATCH 2/6] Use two zonelist that are filtered by GFP mask Mel Gorman
2007-08-31 20:52 ` [PATCH 3/6] Embed zone_id information within the zonelist->zones pointer Mel Gorman
2007-08-31 20:52 ` [PATCH 4/6] Filter based on a nodemask as well as a gfp_mask Mel Gorman
2007-09-01 0:30 ` Christoph Lameter
2007-08-31 20:53 ` [PATCH 5/6] Use one zonelist that is filtered by nodemask Mel Gorman
2007-09-01 0:34 ` Christoph Lameter
2007-09-02 11:10 ` Mel Gorman
2007-09-01 0:35 ` Christoph Lameter
2007-08-31 20:53 ` Mel Gorman [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=20070831205339.22283.40267.sendpatchset@skynet.skynet.ie \
--to=mel@csn.ul.ie \
--cc=Lee.Schermerhorn@hp.com \
--cc=ak@suse.de \
--cc=clameter@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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