Skip to contentSkip to conversation

lib/nodemask.c: Use cheaper prandom_u32_max() in node_random()

RFC PATCH In review George Spelvin 1 participant 1 message Mar 28, 2020 Library code

lore
Share & tools
lore
#0 lore raw

RFC PATCH 31/50 lib/nodemask.c: Use cheaper prandom_u32_max() in node_random()

This function is to spread things around uniformly; cryptographic unguessability is not required.

Cc Michal Hocko <[email protected]>
Cc Mel Gorman <[email protected]>
---
 lib/nodemask.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/nodemask.c +1 -1
index 3aa454c54c0de..330f9c7d3da97 100644
@@ -25,7 +25,7 @@ int node_random(const nodemask_t *maskp)
 	w = nodes_weight(*maskp);
 	if (w)
 		bit = bitmap_ord_to_pos(maskp->bits,
-			get_random_int() % w, MAX_NUMNODES);
+			prandom_u32_max(w), MAX_NUMNODES);
 	return bit;
 }
 #endif
Signature · 1 line
2.26.0