All of lore.kernel.org
 help / color / mirror / Atom feed
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 04/10] xen/mask: Convert {cpu, node}mask_test() to be static inline
Date: Mon, 29 Jul 2019 13:11:58 +0100	[thread overview]
Message-ID: <20190729121204.13559-5-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20190729121204.13559-1-andrew.cooper3@citrix.com>

The buggy version of GCC isn't supported by Xen, so reimplement the helpers
with type checking, using Xen's latest type expectations.

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/srat.c        |  2 +-
 xen/common/page_alloc.c    |  2 +-
 xen/include/xen/cpumask.h  | 18 +++++-------------
 xen/include/xen/nodemask.h | 18 +++++++-----------
 4 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 47a4267220..506a56d66b 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -495,7 +495,7 @@ int __init acpi_scan_nodes(u64 start, u64 end)
 	for (i = 0; i < nr_cpu_ids; i++) {
 		if (cpu_to_node[i] == NUMA_NO_NODE)
 			continue;
-		if (!node_isset(cpu_to_node[i], processor_nodes_parsed))
+		if (!nodemask_test(cpu_to_node[i], &processor_nodes_parsed))
 			numa_set_node(i, NUMA_NO_NODE);
 	}
 	numa_init_array();
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index efa437c7df..77e649d065 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -878,7 +878,7 @@ static struct page_info *get_free_buddy(unsigned int zone_lo,
             return NULL;
 
         /* Pick next node. */
-        if ( !node_isset(node, nodemask) )
+        if ( !nodemask_test(node, &nodemask) )
         {
             /* Very first node may be caller-specified and outside nodemask. */
             ASSERT(!nodemask_retry);
diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h
index 9448f5c6f8..478ec66e5b 100644
--- a/xen/include/xen/cpumask.h
+++ b/xen/include/xen/cpumask.h
@@ -14,7 +14,7 @@
  * void cpumask_clear_cpu(cpu, mask)	turn off bit 'cpu' in mask
  * void cpumask_setall(mask)		set all bits
  * void cpumask_clear(mask)		clear all bits
- * int cpumask_test_cpu(cpu, mask)	true iff bit 'cpu' set in mask
+ * bool cpumask_test_cpu(cpu, mask)	true iff bit 'cpu' set in mask
  * int cpumask_test_and_set_cpu(cpu, mask) test and set bit 'cpu' in mask
  * int cpumask_test_and_clear_cpu(cpu, mask) test and clear bit 'cpu' in mask
  *
@@ -53,15 +53,6 @@
  * for_each_possible_cpu(cpu)		for-loop cpu over cpu_possible_map
  * for_each_online_cpu(cpu)		for-loop cpu over cpu_online_map
  * for_each_present_cpu(cpu)		for-loop cpu over cpu_present_map
- *
- * Subtlety:
- * 1) The 'type-checked' form of cpumask_test_cpu() causes gcc (3.3.2, anyway)
- *    to generate slightly worse code.  Note for example the additional
- *    40 lines of assembly code compiling the "for each possible cpu"
- *    loops buried in the disk_stat_read() macros calls when compiling
- *    drivers/block/genhd.c (arch i386, CONFIG_SMP=y).  So use a simple
- *    one-line #define for cpumask_test_cpu(), instead of wrapping an inline
- *    inside a macro, the way we do the other calls.
  */
 
 #include <xen/bitmap.h>
@@ -117,9 +108,10 @@ static inline void cpumask_clear(cpumask_t *dstp)
 	bitmap_zero(dstp->bits, nr_cpumask_bits);
 }
 
-/* No static inline type checking - see Subtlety (1) above. */
-#define cpumask_test_cpu(cpu, cpumask) \
-	test_bit(cpumask_check(cpu), (cpumask)->bits)
+static inline bool cpumask_test_cpu(unsigned int cpu, const cpumask_t *dst)
+{
+    return test_bit(cpumask_check(cpu), dst->bits);
+}
 
 static inline int cpumask_test_and_set_cpu(int cpu, volatile cpumask_t *addr)
 {
diff --git a/xen/include/xen/nodemask.h b/xen/include/xen/nodemask.h
index c28dd3c768..7ab8b794c6 100644
--- a/xen/include/xen/nodemask.h
+++ b/xen/include/xen/nodemask.h
@@ -14,7 +14,7 @@
  * 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
- * int node_isset(node, mask)		true iff bit 'node' set in mask
+ * 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
  *
  * void nodes_and(dst, src1, src2)	dst = src1 & src2  [intersection]
@@ -45,18 +45,12 @@
  *
  * int num_online_nodes()		Number of online Nodes
  *
- * int node_online(node)		Is some node online?
+ * bool node_online(node)		Is this node online?
  *
  * node_set_online(node)		set bit 'node' in node_online_map
  * node_set_offline(node)		clear bit 'node' in node_online_map
  *
  * for_each_online_node(node)		for-loop node over node_online_map
- *
- * Subtlety:
- * 1) The 'type-checked' form of node_isset() causes gcc (3.3.2, anyway)
- *    to generate slightly worse code.  So use a simple one-line #define
- *    for node_isset(), instead of wrapping an inline inside a macro, the
- *    way we do the other calls.
  */
 
 #include <xen/kernel.h>
@@ -90,8 +84,10 @@ static inline void __nodes_clear(nodemask_t *dstp, int nbits)
 	bitmap_zero(dstp->bits, nbits);
 }
 
-/* No static inline type checking - see Subtlety (1) above. */
-#define node_isset(node, nodemask) test_bit((node), (nodemask).bits)
+static inline bool nodemask_test(unsigned int node, const nodemask_t *dst)
+{
+    return test_bit(node, dst->bits);
+}
 
 #define node_test_and_set(node, nodemask) \
 			__node_test_and_set((node), &(nodemask))
@@ -276,7 +272,7 @@ extern nodemask_t node_online_map;
 
 #if MAX_NUMNODES > 1
 #define num_online_nodes()	nodes_weight(node_online_map)
-#define node_online(node)	node_isset((node), node_online_map)
+#define node_online(node)	nodemask_test(node, &node_online_map)
 #else
 #define num_online_nodes()	1
 #define node_online(node)	((node) == 0)
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  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 ` Andrew Cooper [this message]
2019-07-30  8:52   ` [Xen-devel] [PATCH v3 04/10] xen/mask: Convert {cpu, node}mask_test() to be static inline 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 ` [Xen-devel] [PATCH v3 07/10] xen/nodemask: Drop nodes_{setall, clear}() and improve the initialisers Andrew Cooper
2019-07-30  9:44   ` 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-5-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.