summaryrefslogtreecommitdiff
path: root/include/linux/nodemask.h
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2022-10-20 09:09:00 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2022-10-20 09:09:00 +0200
commit1aca5ce036e3499336d1a2ace3070f908381c055 (patch)
tree32b53fca3cff8c6c084d9c1d94d1761c3618e739 /include/linux/nodemask.h
parent01f2cf53844b01e691516b465df1b6ab01b03230 (diff)
parent9abf2313adc1ca1b6180c508c25f22f9395cc780 (diff)
Merge drm/drm-fixes into drm-misc-fixes
Backmerging to get v6.1-rc1. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Diffstat (limited to 'include/linux/nodemask.h')
-rw-r--r--include/linux/nodemask.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 4b71a96190a8..efef68c9352a 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -493,6 +493,7 @@ static inline int num_node_state(enum node_states state)
#define first_online_node 0
#define first_memory_node 0
#define next_online_node(nid) (MAX_NUMNODES)
+#define next_memory_node(nid) (MAX_NUMNODES)
#define nr_node_ids 1U
#define nr_online_nodes 1U
@@ -504,12 +505,20 @@ static inline int num_node_state(enum node_states state)
static inline int node_random(const nodemask_t *maskp)
{
#if defined(CONFIG_NUMA) && (MAX_NUMNODES > 1)
- int w, bit = NUMA_NO_NODE;
+ int w, bit;
w = nodes_weight(*maskp);
- if (w)
- bit = bitmap_ord_to_pos(maskp->bits,
- get_random_int() % w, MAX_NUMNODES);
+ switch (w) {
+ case 0:
+ bit = NUMA_NO_NODE;
+ break;
+ case 1:
+ bit = first_node(*maskp);
+ break;
+ default:
+ bit = find_nth_bit(maskp->bits, MAX_NUMNODES, prandom_u32_max(w));
+ break;
+ }
return bit;
#else
return 0;