diff options
author | Mel Gorman <mgorman@suse.de> | 2014-04-03 17:47:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-03 19:20:58 -0400 |
commit | d26914d11751b23ca2e8747725f2cae10c2f2c1b (patch) | |
tree | 020b606fb9223e29292f54922a11111239e3a3f4 /mm/slab.c | |
parent | 91ca9186484809c57303b33778d841cc28f696ed (diff) |
mm: optimize put_mems_allowed() usage
Since put_mems_allowed() is strictly optional, its a seqcount retry, we
don't need to evaluate the function if the allocation was in fact
successful, saving a smp_rmb some loads and comparisons on some relative
fast-paths.
Since the naming, get/put_mems_allowed() does suggest a mandatory
pairing, rename the interface, as suggested by Mel, to resemble the
seqcount interface.
This gives us: read_mems_allowed_begin() and read_mems_allowed_retry(),
where it is important to note that the return value of the latter call
is inverted from its previous incarnation.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -3073,7 +3073,7 @@ static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags) | |||
3073 | local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK); | 3073 | local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK); |
3074 | 3074 | ||
3075 | retry_cpuset: | 3075 | retry_cpuset: |
3076 | cpuset_mems_cookie = get_mems_allowed(); | 3076 | cpuset_mems_cookie = read_mems_allowed_begin(); |
3077 | zonelist = node_zonelist(slab_node(), flags); | 3077 | zonelist = node_zonelist(slab_node(), flags); |
3078 | 3078 | ||
3079 | retry: | 3079 | retry: |
@@ -3131,7 +3131,7 @@ retry: | |||
3131 | } | 3131 | } |
3132 | } | 3132 | } |
3133 | 3133 | ||
3134 | if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !obj)) | 3134 | if (unlikely(!obj && read_mems_allowed_retry(cpuset_mems_cookie))) |
3135 | goto retry_cpuset; | 3135 | goto retry_cpuset; |
3136 | return obj; | 3136 | return obj; |
3137 | } | 3137 | } |