mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@suse.de>
To: Jiri Slaby <jslaby@suse.cz>
Cc: Linux-Stable <stable@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, Mel Gorman <mgorman@suse.de>
Subject: [PATCH 71/97] mm: page_alloc: use jump labels to avoid checking number_of_cpusets
Date: Thu, 28 Aug 2014 19:35:19 +0100	[thread overview]
Message-ID: <1409250945-30874-72-git-send-email-mgorman@suse.de> (raw)
In-Reply-To: <1409250945-30874-1-git-send-email-mgorman@suse.de>

commit 664eeddeef6539247691197c1ac124d4aa872ab6 upstream.

If cpusets are not in use then we still check a global variable on every
page allocation.  Use jump labels to avoid the overhead.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Jan Kara <jack@suse.cz>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mel Gorman <mgorman@suse.de>
---
 include/linux/cpuset.h | 29 ++++++++++++++++++++++++++---
 kernel/cpuset.c        | 14 ++++----------
 mm/page_alloc.c        |  3 ++-
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 6f30672..a7ebb89 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -12,10 +12,31 @@
 #include <linux/cpumask.h>
 #include <linux/nodemask.h>
 #include <linux/mm.h>
+#include <linux/jump_label.h>
 
 #ifdef CONFIG_CPUSETS
 
-extern int number_of_cpusets;	/* How many cpusets are defined in system? */
+extern struct static_key cpusets_enabled_key;
+static inline bool cpusets_enabled(void)
+{
+	return static_key_false(&cpusets_enabled_key);
+}
+
+static inline int nr_cpusets(void)
+{
+	/* jump label reference count + the top-level cpuset */
+	return static_key_count(&cpusets_enabled_key) + 1;
+}
+
+static inline void cpuset_inc(void)
+{
+	static_key_slow_inc(&cpusets_enabled_key);
+}
+
+static inline void cpuset_dec(void)
+{
+	static_key_slow_dec(&cpusets_enabled_key);
+}
 
 extern int cpuset_init(void);
 extern void cpuset_init_smp(void);
@@ -32,13 +53,13 @@ extern int __cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask);
 
 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
 {
-	return number_of_cpusets <= 1 ||
+	return nr_cpusets() <= 1 ||
 		__cpuset_node_allowed_softwall(node, gfp_mask);
 }
 
 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
 {
-	return number_of_cpusets <= 1 ||
+	return nr_cpusets() <= 1 ||
 		__cpuset_node_allowed_hardwall(node, gfp_mask);
 }
 
@@ -120,6 +141,8 @@ static inline void set_mems_allowed(nodemask_t nodemask)
 
 #else /* !CONFIG_CPUSETS */
 
+static inline bool cpusets_enabled(void) { return false; }
+
 static inline int cpuset_init(void) { return 0; }
 static inline void cpuset_init_smp(void) {}
 
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 15ae2b7..c828913 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -61,12 +61,7 @@
 #include <linux/cgroup.h>
 #include <linux/wait.h>
 
-/*
- * Tracks how many cpusets are currently defined in system.
- * When there is only one cpuset (the root cpuset) we can
- * short circuit some hooks.
- */
-int number_of_cpusets __read_mostly;
+struct static_key cpusets_enabled_key __read_mostly = STATIC_KEY_INIT_FALSE;
 
 /* See "Frequency meter" comments, below. */
 
@@ -611,7 +606,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
 		goto done;
 	}
 
-	csa = kmalloc(number_of_cpusets * sizeof(cp), GFP_KERNEL);
+	csa = kmalloc(nr_cpusets() * sizeof(cp), GFP_KERNEL);
 	if (!csa)
 		goto done;
 	csn = 0;
@@ -1986,7 +1981,7 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
 	if (is_spread_slab(parent))
 		set_bit(CS_SPREAD_SLAB, &cs->flags);
 
-	number_of_cpusets++;
+	cpuset_inc();
 
 	if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags))
 		goto out_unlock;
@@ -2037,7 +2032,7 @@ static void cpuset_css_offline(struct cgroup_subsys_state *css)
 	if (is_sched_load_balance(cs))
 		update_flag(CS_SCHED_LOAD_BALANCE, cs, 0);
 
-	number_of_cpusets--;
+	cpuset_dec();
 	clear_bit(CS_ONLINE, &cs->flags);
 
 	mutex_unlock(&cpuset_mutex);
@@ -2092,7 +2087,6 @@ int __init cpuset_init(void)
 	if (!alloc_cpumask_var(&cpus_attach, GFP_KERNEL))
 		BUG();
 
-	number_of_cpusets = 1;
 	return 0;
 }
 
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 68e0349..5e0f137 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1920,7 +1920,8 @@ zonelist_scan:
 		if (IS_ENABLED(CONFIG_NUMA) && zlc_active &&
 			!zlc_zone_worth_trying(zonelist, z, allowednodes))
 				continue;
-		if ((alloc_flags & ALLOC_CPUSET) &&
+		if (cpusets_enabled() &&
+			(alloc_flags & ALLOC_CPUSET) &&
 			!cpuset_zone_allowed_softwall(zone, gfp_mask))
 				continue;
 		BUILD_BUG_ON(ALLOC_NO_WATERMARKS < NR_WMARK);
-- 
1.8.4.5


  parent reply	other threads:[~2014-08-28 18:49 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 18:34 [PATCH 00/97] Misc series of functional/performance fixes for 3.12-stable Mel Gorman
2014-08-28 18:34 ` [PATCH 01/97] mm: thp: cleanup: mv alloc_hugepage to better place Mel Gorman
2014-08-28 18:34 ` [PATCH 02/97] mm: thp: khugepaged: add policy for finding target node Mel Gorman
2014-08-28 18:34 ` [PATCH 03/97] slab: correct pfmemalloc check Mel Gorman
2014-08-28 18:34 ` [PATCH 04/97] mm: prevent setting of a value less than 0 to min_free_kbytes Mel Gorman
2014-08-28 18:34 ` [PATCH 05/97] mm: fix bad rss-counter if remap_file_pages raced migration Mel Gorman
2014-08-28 18:34 ` [PATCH 06/97] hugetlb: ensure hugepage access is denied if hugepages are not supported Mel Gorman
2014-08-28 18:34 ` [PATCH 07/97] mm: exclude memoryless nodes from zone_reclaim Mel Gorman
2014-08-28 18:34 ` [PATCH 08/97] mm, thp: do not allow thp faults to avoid cpuset restrictions Mel Gorman
2014-09-26  9:53   ` Jiri Slaby
2014-10-13 15:17     ` Mel Gorman
2014-08-28 18:34 ` [PATCH 09/97] swap: change swap_info singly-linked list to list_head Mel Gorman
2014-08-28 18:34 ` [PATCH 10/97] lib/plist: add helper functions Mel Gorman
2014-08-28 18:34 ` [PATCH 11/97] lib/plist: add plist_requeue Mel Gorman
2014-08-28 18:34 ` [PATCH 12/97] swap: change swap_list_head to plist, add swap_avail_head Mel Gorman
2014-08-28 18:34 ` [PATCH 13/97] readahead: fix sequential read cache miss detection Mel Gorman
2014-08-28 18:34 ` [PATCH 14/97] mm: get rid of unnecessary overhead of trace_mm_page_alloc_extfrag() Mel Gorman
2014-08-28 18:34 ` [PATCH 15/97] mm: __rmqueue_fallback() should respect pageblock type Mel Gorman
2014-08-28 18:34 ` [PATCH 16/97] mm, x86: Account for TLB flushes only when debugging Mel Gorman
2014-08-28 18:34 ` [PATCH 17/97] x86/mm: Clean up inconsistencies when flushing TLB ranges Mel Gorman
2014-08-28 18:34 ` [PATCH 18/97] x86/mm: Eliminate redundant page table walk during TLB range flushing Mel Gorman
2014-08-28 18:34 ` [PATCH 19/97] mm: compaction: trace compaction begin and end Mel Gorman
2014-08-28 18:34 ` [PATCH 20/97] mm: compaction: encapsulate defer reset logic Mel Gorman
2014-08-28 18:34 ` [PATCH 21/97] mm: compaction: do not mark unmovable pageblocks as skipped in async compaction Mel Gorman
2014-08-28 18:34 ` [PATCH 22/97] mm: compaction: reset scanner positions immediately when they meet Mel Gorman
2014-08-28 18:34 ` [PATCH 23/97] swap: add a simple detector for inappropriate swapin readahead Mel Gorman
2014-08-28 18:34 ` [PATCH 24/97] mm: vmscan: shrink all slab objects if tight on memory Mel Gorman
2014-08-28 18:34 ` [PATCH 25/97] mm: vmscan: call NUMA-unaware shrinkers irrespective of nodemask Mel Gorman
2014-08-28 18:34 ` [PATCH 26/97] mm: get rid of unnecessary pageblock scanning in setup_zone_migrate_reserve Mel Gorman
2014-08-28 18:34 ` [PATCH 27/97] mm, compaction: avoid isolating pinned pages Mel Gorman
2014-08-28 18:34 ` [PATCH 28/97] mm/compaction: disallow high-order page for migration target Mel Gorman
2014-08-28 18:34 ` [PATCH 29/97] mm/compaction: do not call suitable_migration_target() on every page Mel Gorman
2014-08-28 18:34 ` [PATCH 30/97] mm/compaction: change the timing to check to drop the spinlock Mel Gorman
2014-08-28 18:34 ` [PATCH 31/97] mm/compaction: check pageblock suitability once per pageblock Mel Gorman
2014-08-28 18:34 ` [PATCH 32/97] mm/compaction: clean-up code on success of ballon isolation Mel Gorman
2014-08-28 18:34 ` [PATCH 33/97] mm, compaction: determine isolation mode only once Mel Gorman
2014-08-28 18:34 ` [PATCH 34/97] mm, compaction: ignore pageblock skip when manually invoking compaction Mel Gorman
2014-08-28 18:34 ` [PATCH 35/97] mm/readahead.c: fix readahead failure for memoryless NUMA nodes and limit readahead pages Mel Gorman
2014-08-28 18:34 ` [PATCH 36/97] mm: optimize put_mems_allowed() usage Mel Gorman
2014-08-28 18:34 ` [PATCH 37/97] mm/filemap.c: avoid always dirtying mapping->flags on O_DIRECT Mel Gorman
2014-08-28 18:34 ` [PATCH 38/97] mm: vmscan: respect NUMA policy mask when shrinking slab on direct reclaim Mel Gorman
2014-08-28 18:34 ` [PATCH 39/97] mm: vmscan: shrink_slab: rename max_pass -> freeable Mel Gorman
2014-08-28 18:34 ` [PATCH 40/97] vmscan: reclaim_clean_pages_from_list() must use mod_zone_page_state() Mel Gorman
2014-08-28 18:34 ` [PATCH 41/97] mm: per-thread vma caching Mel Gorman
2014-08-28 18:34 ` [PATCH 42/97] mm: don't pointlessly use BUG_ON() for sanity check Mel Gorman
2014-08-28 18:34 ` [PATCH 43/97] lib: radix-tree: add radix_tree_delete_item() Mel Gorman
2014-08-28 18:34 ` [PATCH 44/97] mm: shmem: save one radix tree lookup when truncating swapped pages Mel Gorman
2014-08-28 18:34 ` [PATCH 45/97] mm: filemap: move radix tree hole searching here Mel Gorman
2014-08-28 18:34 ` [PATCH 46/97] mm + fs: prepare for non-page entries in page cache radix trees Mel Gorman
2014-08-28 18:34 ` [PATCH 47/97] mm: madvise: fix MADV_WILLNEED on shmem swapouts Mel Gorman
2014-08-28 18:34 ` [PATCH 48/97] mm: remove read_cache_page_async() Mel Gorman
2014-08-28 18:34 ` [PATCH 49/97] callers of iov_copy_from_user_atomic() don't need pagecache_disable() Mel Gorman
2014-08-28 18:34 ` [PATCH 50/97] mm/readahead.c: inline ra_submit Mel Gorman
2014-08-28 18:34 ` [PATCH 51/97] mm/compaction: clean up unused code lines Mel Gorman
2014-08-28 18:35 ` [PATCH 52/97] mm/compaction: cleanup isolate_freepages() Mel Gorman
2014-08-28 18:35 ` [PATCH 53/97] mm, migration: add destination page freeing callback Mel Gorman
2014-08-28 18:35 ` [PATCH 54/97] mm, compaction: return failed migration target pages back to freelist Mel Gorman
2014-08-28 18:35 ` [PATCH 55/97] mm, compaction: add per-zone migration pfn cache for async compaction Mel Gorman
2014-08-28 18:35 ` [PATCH 56/97] mm, compaction: embed migration mode in compact_control Mel Gorman
2014-08-28 18:35 ` [PATCH 57/97] mm, compaction: terminate async compaction when rescheduling Mel Gorman
2014-08-28 18:35 ` [PATCH 58/97] mm/compaction: do not count migratepages when unnecessary Mel Gorman
2014-08-28 18:35 ` [PATCH 59/97] mm/compaction: avoid rescanning pageblocks in isolate_freepages Mel Gorman
2014-08-28 18:35 ` [PATCH 60/97] mm, compaction: properly signal and act upon lock and need_sched() contention Mel Gorman
2014-08-28 18:35 ` [PATCH 61/97] x86/mm: In the PTE swapout page reclaim case clear the accessed bit instead of flushing the TLB Mel Gorman
2014-08-28 18:35 ` [PATCH 62/97] mm: fix direct reclaim writeback regression Mel Gorman
2014-08-28 18:35 ` [PATCH 63/97] fs/superblock: unregister sb shrinker before ->kill_sb() Mel Gorman
2014-08-28 18:35 ` [PATCH 64/97] fs/superblock: avoid locking counting inodes and dentries before reclaiming them Mel Gorman
2014-08-28 18:35 ` [PATCH 65/97] mm: vmscan: use proportional scanning during direct reclaim and full scan at DEF_PRIORITY Mel Gorman
2014-08-28 18:35 ` [PATCH 66/97] mm/page_alloc: prevent MIGRATE_RESERVE pages from being misplaced Mel Gorman
2014-08-28 18:35 ` [PATCH 67/97] mm/swap.c: clean up *lru_cache_add* functions Mel Gorman
2014-08-28 18:35 ` [PATCH 68/97] mm: page_alloc: do not update zlc unless the zlc is active Mel Gorman
2014-08-28 18:35 ` [PATCH 69/97] mm: page_alloc: do not treat a zone that cannot be used for dirty pages as "full" Mel Gorman
2014-08-28 18:35 ` [PATCH 70/97] include/linux/jump_label.h: expose the reference count Mel Gorman
2014-08-28 18:35 ` Mel Gorman [this message]
2014-08-28 18:35 ` [PATCH 72/97] mm: page_alloc: calculate classzone_idx once from the zonelist ref Mel Gorman
2014-08-28 18:35 ` [PATCH 73/97] mm: page_alloc: only check the zone id check if pages are buddies Mel Gorman
2014-08-28 18:35 ` [PATCH 74/97] mm: page_alloc: only check the alloc flags and gfp_mask for dirty once Mel Gorman
2014-08-28 18:35 ` [PATCH 75/97] mm: page_alloc: take the ALLOC_NO_WATERMARK check out of the fast path Mel Gorman
2014-08-28 18:35 ` [PATCH 76/97] mm: page_alloc: use unsigned int for order in more places Mel Gorman
2014-08-28 18:35 ` [PATCH 77/97] mm: page_alloc: reduce number of times page_to_pfn is called Mel Gorman
2014-08-28 18:35 ` [PATCH 78/97] mm: page_alloc: convert hot/cold parameter and immediate callers to bool Mel Gorman
2014-08-28 18:35 ` [PATCH 79/97] mm: page_alloc: lookup pageblock migratetype with IRQs enabled during free Mel Gorman
2014-08-28 18:35 ` [PATCH 80/97] mm: shmem: avoid atomic operation during shmem_getpage_gfp Mel Gorman
2014-08-28 18:35 ` [PATCH 81/97] mm: do not use atomic operations when releasing pages Mel Gorman
2014-08-28 18:35 ` [PATCH 82/97] mm: do not use unnecessary atomic operations when adding pages to the LRU Mel Gorman
2014-08-28 18:35 ` [PATCH 83/97] fs: buffer: do not use unnecessary atomic operations when discarding buffers Mel Gorman
2014-08-28 18:35 ` [PATCH 84/97] mm: non-atomically mark page accessed during page cache allocation where possible Mel Gorman
2014-08-28 18:35 ` [PATCH 85/97] mm: avoid unnecessary atomic operations during end_page_writeback() Mel Gorman
2014-08-28 18:35 ` [PATCH 86/97] shmem: fix init_page_accessed use to stop !PageLRU bug Mel Gorman
2014-08-28 18:35 ` [PATCH 87/97] mm/memory.c: use entry = ACCESS_ONCE(*pte) in handle_pte_fault() Mel Gorman
2014-08-28 18:35 ` [PATCH 88/97] mm, thp: only collapse hugepages to nodes with affinity for zone_reclaim_mode Mel Gorman
2014-08-28 18:35 ` [PATCH 89/97] mm: make copy_pte_range static again Mel Gorman
2014-08-28 18:35 ` [PATCH 90/97] vmalloc: use rcu list iterator to reduce vmap_area_lock contention Mel Gorman
2014-08-28 18:35 ` [PATCH 91/97] memcg, vmscan: Fix forced scan of anonymous pages Mel Gorman
2014-08-28 18:35 ` [PATCH 92/97] mm: pagemap: avoid unnecessary overhead when tracepoints are deactivated Mel Gorman
2014-08-28 18:35 ` [PATCH 93/97] mm: rearrange zone fields into read-only, page alloc, statistics and page reclaim lines Mel Gorman
2014-08-28 18:35 ` [PATCH 94/97] mm: move zone->pages_scanned into a vmstat counter Mel Gorman
2014-08-28 18:35 ` [PATCH 95/97] mm: vmscan: only update per-cpu thresholds for online CPU Mel Gorman
2014-08-28 18:35 ` [PATCH 96/97] mm: page_alloc: abort fair zone allocation policy when remotes nodes are encountered Mel Gorman
2014-08-28 18:35 ` [PATCH 97/97] mm: page_alloc: reduce cost of the fair zone allocation policy Mel Gorman
2015-01-28  1:13 ` [PATCH 00/97] Misc series of functional/performance fixes for 3.12-stable Greg KH

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=1409250945-30874-72-git-send-email-mgorman@suse.de \
    --to=mgorman@suse.de \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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

all inboxes | Powered by JetHome®