From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
"Wei Liu" <wl@xen.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Julien Grall" <julien.grall@arm.com>,
"Jan Beulich" <JBeulich@suse.com>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v3 07/10] xen/nodemask: Drop nodes_{setall, clear}() and improve the initialisers
Date: Mon, 29 Jul 2019 13:12:01 +0100 [thread overview]
Message-ID: <20190729121204.13559-8-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20190729121204.13559-1-andrew.cooper3@citrix.com>
There is no need to use runtime variable-length clearing when MAX_NUMNODES is
known to the compiler. Drop these functions and use the initialisers instead.
numa_initmem_init() opencodes nodemask_of_node(), but its implemention is
still poor, so replace it with NODEMASK_OF() which is calculated at compile
time, and without the use of a locked set_bit() operation.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
v3:
* New
---
xen/arch/x86/dom0_build.c | 2 +-
xen/arch/x86/numa.c | 3 +-
xen/common/domain.c | 4 +--
xen/include/xen/nodemask.h | 85 +++++++++++++++++-----------------------------
4 files changed, 35 insertions(+), 59 deletions(-)
diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
index c69570920c..06500c87c6 100644
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -231,7 +231,7 @@ unsigned int __init dom0_max_vcpus(void)
if ( pv_shim )
{
- nodes_setall(dom0_nodes);
+ dom0_nodes = NODEMASK_ALL;
/*
* When booting in shim mode APs are not started until the guest brings
diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
index 7e1f563012..7473f83b7b 100644
--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -269,8 +269,7 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
/* setup dummy node covering all memory */
memnode_shift = BITS_PER_LONG - 1;
memnodemap = _memnodemap;
- nodes_clear(node_online_map);
- node_set_online(0);
+ node_online_map = NODEMASK_OF(0);
for ( i = 0; i < nr_cpu_ids; i++ )
numa_set_node(i, 0);
cpumask_copy(&node_to_cpumask[0], cpumask_of(0));
diff --git a/xen/common/domain.c b/xen/common/domain.c
index e8e850796e..11565a64b3 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -384,7 +384,7 @@ struct domain *domain_create(domid_t domid,
INIT_PAGE_LIST_HEAD(&d->xenpage_list);
spin_lock_init(&d->node_affinity_lock);
- d->node_affinity = NODE_MASK_ALL;
+ d->node_affinity = NODEMASK_ALL;
d->auto_node_affinity = 1;
spin_lock_init(&d->shutdown_lock);
@@ -615,7 +615,7 @@ void domain_update_node_affinity(struct domain *d)
dom_affinity = cpumask_empty(dom_cpumask_soft) ?
dom_cpumask : dom_cpumask_soft;
- nodes_clear(d->node_affinity);
+ d->node_affinity = NODEMASK_NONE;
for_each_cpu ( cpu, dom_affinity )
node_set(cpu_to_node(cpu), d->node_affinity);
}
diff --git a/xen/include/xen/nodemask.h b/xen/include/xen/nodemask.h
index 1dd6c7458e..9933fec5c4 100644
--- a/xen/include/xen/nodemask.h
+++ b/xen/include/xen/nodemask.h
@@ -12,8 +12,6 @@
*
* void node_set(node, mask) turn on bit 'node' in mask
* void node_clear(node, mask) turn off bit 'node' in mask
- * void nodes_setall(mask) set all bits
- * void nodes_clear(mask) clear all bits
* bool nodemask_test(node, mask) true iff bit 'node' set in mask
* int node_test_and_set(node, mask) test and set bit 'node' in mask
*
@@ -36,9 +34,9 @@
* int cycle_node(node, mask) Next node cycling from 'node', or
* MAX_NUMNODES
*
- * nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
- * NODE_MASK_ALL Initializer - all bits set
- * NODE_MASK_NONE Initializer - no bits set
+ * nodemask_t NODEMASK_OF(node) Initializer - bit 'node' set
+ * NODEMASK_ALL Initializer - all bits set
+ * NODEMASK_NONE Initializer - no bits set
* unsigned long *nodemask_bits(mask) Array of unsigned long's in mask
*
* for_each_node_mask(node, mask) for-loop node over mask
@@ -67,7 +65,34 @@ typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
#define nodemask_bits(src) ((src)->bits)
-extern nodemask_t _unused_nodemask_arg_;
+#define NODEMASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES)
+
+#define NODEMASK_NONE \
+((nodemask_t) {{ \
+ [0 ... BITS_TO_LONGS(MAX_NUMNODES) - 1] = 0 \
+}})
+
+#if MAX_NUMNODES <= BITS_PER_LONG
+
+#define NODEMASK_ALL ((nodemask_t) {{ NODEMASK_LAST_WORD }})
+#define NODEMASK_OF(node) ((nodemask_t) {{ 1UL << (node) }})
+
+#else /* MAX_NUMNODES > BITS_PER_LONG */
+
+#define NODEMASK_ALL \
+((nodemask_t) {{ \
+ [0 ... BITS_TO_LONGS(MAX_NUMNODES) - 2] = ~0UL, \
+ [BITS_TO_LONGS(MAX_NUMNODES) - 1] = NODEMASK_LAST_WORD \
+}})
+
+#define NODEMASK_OF(node) \
+({ \
+ nodemask_t m = NODES_NONE; \
+ m.bits[(node) / BITS_PER_LONG] = 1UL << ((node) % BITS_PER_LONG); \
+ m; \
+})
+
+#endif /* MAX_NUMNODES */
#define node_set(node, dst) __node_set((node), &(dst))
static inline void __node_set(int node, volatile nodemask_t *dstp)
@@ -81,18 +106,6 @@ static inline void __node_clear(int node, volatile nodemask_t *dstp)
clear_bit(node, dstp->bits);
}
-#define nodes_setall(dst) __nodes_setall(&(dst), MAX_NUMNODES)
-static inline void __nodes_setall(nodemask_t *dstp, int nbits)
-{
- bitmap_fill(dstp->bits, nbits);
-}
-
-#define nodes_clear(dst) __nodes_clear(&(dst), MAX_NUMNODES)
-static inline void __nodes_clear(nodemask_t *dstp, int nbits)
-{
- bitmap_zero(dstp->bits, nbits);
-}
-
static inline bool nodemask_test(unsigned int node, const nodemask_t *dst)
{
return test_bit(node, dst->bits);
@@ -213,18 +226,6 @@ static inline int __last_node(const nodemask_t *srcp, int nbits)
return pnode;
}
-#define nodemask_of_node(node) \
-({ \
- typeof(_unused_nodemask_arg_) m; \
- if (sizeof(m) == sizeof(unsigned long)) { \
- m.bits[0] = 1UL<<(node); \
- } else { \
- nodes_clear(m); \
- node_set((node), m); \
- } \
- m; \
-})
-
#define cycle_node(n, src) __cycle_node((n), &(src), MAX_NUMNODES)
static inline int __cycle_node(int n, const nodemask_t *maskp, int nbits)
{
@@ -235,30 +236,6 @@ static inline int __cycle_node(int n, const nodemask_t *maskp, int nbits)
return nxt;
}
-#define NODE_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES)
-
-#if MAX_NUMNODES <= BITS_PER_LONG
-
-#define NODE_MASK_ALL \
-((nodemask_t) { { \
- [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \
-} })
-
-#else
-
-#define NODE_MASK_ALL \
-((nodemask_t) { { \
- [0 ... BITS_TO_LONGS(MAX_NUMNODES)-2] = ~0UL, \
- [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \
-} })
-
-#endif
-
-#define NODE_MASK_NONE \
-((nodemask_t) { { \
- [0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] = 0UL \
-} })
-
#if MAX_NUMNODES > 1
#define for_each_node_mask(node, mask) \
for ((node) = first_node(mask); \
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-07-29 12:12 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 12:11 [Xen-devel] [PATCH v3 00/10] xen/nodemask: API cleanup and fixes Andrew Cooper
2019-07-29 12:11 ` [Xen-devel] [PATCH v3 01/10] page-alloc: Clamp get_free_buddy() to online nodes Andrew Cooper
2019-07-29 15:48 ` Jan Beulich
2019-07-29 17:26 ` Andrew Cooper
2019-07-30 8:09 ` Jan Beulich
2019-07-30 17:32 ` Andrew Cooper
2019-07-31 8:22 ` Jan Beulich
2019-07-31 9:01 ` Andrew Cooper
2019-07-29 12:11 ` [Xen-devel] [PATCH v3 02/10] xen/bitmap: Drop {bitmap, cpumask, nodes}_shift_{left, right}() Andrew Cooper
2019-07-29 15:50 ` Jan Beulich
2019-07-29 12:11 ` [Xen-devel] [PATCH v3 03/10] xen/nodemask: Drop any_online_node() and first_unset_node() Andrew Cooper
2019-07-29 15:51 ` Jan Beulich
2019-07-29 12:11 ` [Xen-devel] [PATCH v3 04/10] xen/mask: Convert {cpu, node}mask_test() to be static inline Andrew Cooper
2019-07-30 8:52 ` Jan Beulich
2019-07-30 9:03 ` Andrew Cooper
2019-07-29 12:11 ` [Xen-devel] [PATCH v3 05/10] xen/cpumask: Introduce a CPUMASK_PR() wrapper for printing Andrew Cooper
2019-07-30 8:55 ` Jan Beulich
2019-07-29 12:12 ` [Xen-devel] [PATCH v3 06/10] xen/nodemask: Introduce a NODEMASK_PR() " Andrew Cooper
2019-07-30 8:58 ` Jan Beulich
2019-07-30 9:09 ` Andrew Cooper
2019-07-29 12:12 ` Andrew Cooper [this message]
2019-07-30 9:44 ` [Xen-devel] [PATCH v3 07/10] xen/nodemask: Drop nodes_{setall, clear}() and improve the initialisers Jan Beulich
2019-07-31 12:49 ` Andrew Cooper
2019-07-31 13:12 ` Jan Beulich
2019-07-31 13:32 ` Andrew Cooper
2019-07-29 12:12 ` [Xen-devel] [PATCH v3 08/10] xen/nodemask: Introduce unlocked __nodemask_{set, clear}() helpers Andrew Cooper
2019-07-30 11:26 ` Jan Beulich
2019-07-30 17:48 ` Andrew Cooper
2019-07-31 8:41 ` Jan Beulich
2019-07-29 12:12 ` [Xen-devel] [PATCH v3 09/10] xen/nodemask: Sanitise the remainder of the nodemask API Andrew Cooper
2019-07-30 11:43 ` Jan Beulich
2019-07-29 12:12 ` [Xen-devel] [PATCH v3 10/10] xen/nodemask: Drop remaining refeces to linux Andrew Cooper
2019-07-30 11:44 ` Jan Beulich
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=20190729121204.13559-8-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=julien.grall@arm.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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 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.