Message ID | 20190729121204.13559-7-andrew.cooper3@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xen/nodemask: API cleanup and fixes | expand |
On 29.07.2019 14:12, Andrew Cooper wrote: > Rework nodes_addr() into nodemask_bits() and change the indirection to match > its cpumask_bits() counterpart, and update the caller. > > Use NODEMASK_PR() to fix up one opencoded access into nodemask.bits in > dump_domains(). > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> albeit I think that ... > @@ -58,6 +58,15 @@ > #include <xen/numa.h> > > typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t; > + > +/* > + * printf arguments for a nodemask. Shorthand for using '%*pb[l]' when > + * printing a nodemask. > + */ > +#define NODEMASK_PR(src) MAX_NUMNODES, nodemask_bits(src) > + > +#define nodemask_bits(src) ((src)->bits) ... it would be nice if nodemask_bits() was defined before its first use, no matter that such ordering is irrelevant for macros. Jan
On 30/07/2019 09:58, Jan Beulich wrote: > On 29.07.2019 14:12, Andrew Cooper wrote: >> Rework nodes_addr() into nodemask_bits() and change the indirection to match >> its cpumask_bits() counterpart, and update the caller. >> >> Use NODEMASK_PR() to fix up one opencoded access into nodemask.bits in >> dump_domains(). >> >> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> > Reviewed-by: Jan Beulich <jbeulich@suse.com> > albeit I think that ... > >> @@ -58,6 +58,15 @@ >> #include <xen/numa.h> >> >> typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t; >> + >> +/* >> + * printf arguments for a nodemask. Shorthand for using '%*pb[l]' when >> + * printing a nodemask. >> + */ >> +#define NODEMASK_PR(src) MAX_NUMNODES, nodemask_bits(src) >> + >> +#define nodemask_bits(src) ((src)->bits) > ... it would be nice if nodemask_bits() was defined before its first > use, no matter that such ordering is irrelevant for macros. In this case, I decided that having NODEMASK_PR() closer to the nodemask_t is more important, overall. In practice, they are adjacent and remain so at the end of the series. ~Andrew
diff --git a/xen/common/domctl.c b/xen/common/domctl.c index fa260ce5fb..9ed9f57f0d 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -123,14 +123,14 @@ int xenctl_bitmap_to_cpumask(cpumask_var_t *cpumask, static int nodemask_to_xenctl_bitmap(struct xenctl_bitmap *xenctl_nodemap, const nodemask_t *nodemask) { - return bitmap_to_xenctl_bitmap(xenctl_nodemap, nodes_addr(*nodemask), + return bitmap_to_xenctl_bitmap(xenctl_nodemap, nodemask_bits(nodemask), MAX_NUMNODES); } static int xenctl_bitmap_to_nodemask(nodemask_t *nodemask, const struct xenctl_bitmap *xenctl_nodemap) { - return xenctl_bitmap_to_bitmap(nodes_addr(*nodemask), xenctl_nodemap, + return xenctl_bitmap_to_bitmap(nodemask_bits(nodemask), xenctl_nodemap, MAX_NUMNODES); } diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index a5e95e2fe9..57b360ee4b 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -293,7 +293,7 @@ static void dump_domains(unsigned char key) dump_pageframe_info(d); printk("NODE affinity for domain %d: [%*pbl]\n", - d->domain_id, MAX_NUMNODES, d->node_affinity.bits); + d->domain_id, NODEMASK_PR(&d->node_affinity)); printk("VCPU information and callbacks for domain %u:\n", d->domain_id); diff --git a/xen/include/xen/nodemask.h b/xen/include/xen/nodemask.h index 7ab8b794c6..1dd6c7458e 100644 --- a/xen/include/xen/nodemask.h +++ b/xen/include/xen/nodemask.h @@ -39,7 +39,7 @@ * 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 - * unsigned long *nodes_addr(mask) Array of unsigned long's in mask + * unsigned long *nodemask_bits(mask) Array of unsigned long's in mask * * for_each_node_mask(node, mask) for-loop node over mask * @@ -58,6 +58,15 @@ #include <xen/numa.h> typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t; + +/* + * printf arguments for a nodemask. Shorthand for using '%*pb[l]' when + * printing a nodemask. + */ +#define NODEMASK_PR(src) MAX_NUMNODES, nodemask_bits(src) + +#define nodemask_bits(src) ((src)->bits) + extern nodemask_t _unused_nodemask_arg_; #define node_set(node, dst) __node_set((node), &(dst)) @@ -250,8 +259,6 @@ static inline int __cycle_node(int n, const nodemask_t *maskp, int nbits) [0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] = 0UL \ } }) -#define nodes_addr(src) ((src).bits) - #if MAX_NUMNODES > 1 #define for_each_node_mask(node, mask) \ for ((node) = first_node(mask); \
Rework nodes_addr() into nodemask_bits() and change the indirection to match its cpumask_bits() counterpart, and update the caller. Use NODEMASK_PR() to fix up one opencoded access into nodemask.bits in dump_domains(). 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/common/domctl.c | 4 ++-- xen/common/keyhandler.c | 2 +- xen/include/xen/nodemask.h | 13 ++++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-)