From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: George Spelvin <lkml@sdf.org>, linux-kernel@vger.kernel.org
Cc: Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
ocfs2-devel@oss.oracle.com
Subject: Re: [RFC PATCH v1 29/50] fs/ocfs2/journal: Use prandom_u32() and not /dev/random for timeout
Date: Mon, 30 Mar 2020 20:09:33 +0800 [thread overview]
Message-ID: <016c2bdc-68eb-245f-2292-d00d0d8e45a5@linux.alibaba.com> (raw)
In-Reply-To: <202003281643.02SGhIOY022599@sdf.org>
Sorry for the late reply since I might miss this mail.
On 2019/3/21 11:07, George Spelvin wrote:
> get_random_bytes() is expensive crypto-quality random numbers.
> If we're just doing random backoff, prandom_u32() is plenty.
>
> (Not to mention fetching 8 bytes of seed material only to
> reduce it modulo 5000 is a huge waste.)
>
> Also, convert timeouts to jiffies at compile time; convert
> milliseconds to jiffies before picking a random number in the
> range to take advantage of compile-time constant folding.
>
> Signed-off-by: George Spelvin <lkml@sdf.org>
> Cc: Mark Fasheh <mark@fasheh.com>
> Cc: Joel Becker <jlbec@evilplan.org>
> Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
> Cc: ocfs2-devel@oss.oracle.com
> ---
> fs/ocfs2/journal.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 68ba354cf3610..939a12e57fa8b 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -1884,11 +1884,8 @@ int ocfs2_mark_dead_nodes(struct ocfs2_super *osb)
> */
> static inline unsigned long ocfs2_orphan_scan_timeout(void)
> {
> - unsigned long time;
> -
> - get_random_bytes(&time, sizeof(time));
> - time = ORPHAN_SCAN_SCHEDULE_TIMEOUT + (time % 5000);
> - return msecs_to_jiffies(time);
> + return msecs_to_jiffies(ORPHAN_SCAN_SCHEDULE_TIMEOUT) +
> + prandom_u32_max(5 * HZ);
Seems better include the prandom_u32_max() into msecs_to_jiffies()?
Thanks,
Joseph
> }
>
> /*
>
next prev parent reply other threads:[~2020-03-30 12:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 3:07 George Spelvin
2020-03-30 12:09 ` Joseph Qi [this message]
2020-03-30 16:34 ` George Spelvin
2020-03-31 0:56 ` Joseph Qi
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=016c2bdc-68eb-245f-2292-d00d0d8e45a5@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@sdf.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@oss.oracle.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
Powered by JetHome