page-alloc: Clamp get_free_buddy() to online nodes
PATCH 1/1 page-alloc: Clamp get_free_buddy() to online nodes
d->node_affinity defaults to NODE_MASK_ALL which has bits set outside of node_online_map. This in turn causes the loop in get_free_buddy() to waste effort iterating over offline nodes.
Always clamp d->node_affinity to node_online_map when in use.
This in turn involves implementing nodes_copy() which was previously missing.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: George Dunlap <[email protected]>
This patch hides the issue identified in the "UBSAN report in find_next_bit()" so probably doesn't want applying until that is resolved.
A lower overhead option would be to do:
nodes_and(nodemask, node_online_map, d ? d->node_affinity : node_online_map);
however this doesn't work because the nodeset_t API has a hidden &(param) throughout the API. I've got half a mind to undo this nonsense and have nodemask_t work in exactly the same way as cpumask_t.
--- xen/common/page_alloc.c | 7 ++++++- xen/include/xen/nodemask.h | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
xen/common/page_alloc.c +6 -1
@@ -811,11 +811,16 @@ static struct page_info *get_free_buddy(unsigned int zone_lo, const struct domain *d) {nodeid_t first_node, node =MEMF_get_node (memflags), req_node = node; -nodemask_t nodemask = d ? d->node_affinity : node_online_map; +nodemask_t nodemask;unsigned int j, zone, nodemask_retry =0 ;struct page_info *pg;bool use_unscrubbed = (memflags & MEMF_no_scrub); +/* Clamp nodemask to node_online_map and optionally d->node_affinity. */ +nodes_copy (nodemask, node_online_map); +if ( d ) +nodes_and (nodemask, nodemask, d->node_affinity); +if ( node ==NUMA_NO_NODE ) {if ( d !=NULL )
xen/include/xen/nodemask.h +6 -0
@@ -189,6 +189,12 @@ static inline int __nodes_weight(const nodemask_t *srcp, int nbits)return bitmap_weight (srcp->bits, nbits); } +#define nodes_copy (dst, src) __nodes_copy(&(dst), &(src)) +static inline void __nodes_copy (nodemask_t *dst,nodemask_t *src) +{ +return bitmap_copy (dst->bits, src->bits,MAX_NUMNODES ); +} +#define nodes_shift_right (dst, src, n) \ __nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES) static inline void __nodes_shift_right(nodemask_t *dstp,
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 24.06.19 at 20:01, <[email protected]> wrote:
This patch hides the issue identified in the "UBSAN report in
find_next_bit()" so probably doesn't want applying until that is resolved.
It does so on systems with less than 64 nodes, afaict.
Quoted 7 lines
A lower overhead option would be to do:
nodes_and(nodemask, node_online_map, d ? d->node_affinity : node_online_map);however this doesn't work because the
nodeset_tAPI has a hidden &(param) throughout the API. I've got half a mind to undo this nonsense and havenodemask_twork in exactly the same way ascpumask_t.
Right, we should do such a transformation eventually.
xen/include/xen/nodemask.h static inline int __nodes_weight(const nodemask_t *srcp, int nbits) · line 196
Quoted 11 lines
xen/include/xen/nodemask.h +5
-0@@ -189,6 +189,12 @@ static inline int __nodes_weight(const nodemask_t *srcp, int nbits)return bitmap_weight (srcp->bits, nbits); } +#define nodes_copy (dst, src) __nodes_copy(&(dst), &(src)) +static inline void __nodes_copy (nodemask_t *dst,nodemask_t *src) +{ +return bitmap_copy (dst->bits, src->bits,MAX_NUMNODES ); +}
Rather than introducing this, I think structure assignment is meant to be used (as was the case prior to your change). But if you really feel like introducing this, then please constify "src". With either adjustment made,
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel