mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: George Spelvin <lkml@sdf.org>
To: linux-kernel@vger.kernel.org, lkml@sdf.org
Cc: Michal Hocko <mhocko@suse.com>, Mel Gorman <mgorman@suse.de>
Subject: [RFC PATCH v1 31/50] lib/nodemask.c: Use cheaper prandom_u32_max() in node_random()
Date: Fri, 29 Nov 2019 16:44:33 -0500	[thread overview]
Message-ID: <202003281643.02SGhJ8Y024747@sdf.org> (raw)

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

Signed-off-by: George Spelvin <lkml@sdf.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@suse.de>
---
 lib/nodemask.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/nodemask.c b/lib/nodemask.c
index 3aa454c54c0de..330f9c7d3da97 100644
--- a/lib/nodemask.c
+++ b/lib/nodemask.c
@@ -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
-- 
2.26.0


                 reply	other threads:[~2020-03-28 16:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202003281643.02SGhJ8Y024747@sdf.org \
    --to=lkml@sdf.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®