Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2378705ybb; Mon, 30 Mar 2020 05:10:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtN+E95v+2K0gbomxNy+KupvYuz21DcwqIWPerdVdo4URZPOOLApDVDAJBBdnLvPJPfv0H5 X-Received: by 2002:a9d:6358:: with SMTP id y24mr9256040otk.49.1585570225750; Mon, 30 Mar 2020 05:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585570225; cv=none; d=google.com; s=arc-20160816; b=cCX+Fh7Zo0DNBnVqEqRQzqtHh0C0BlsutsMNMhYzXgqwZohK9/fqx2tylbESuNRe+Z l1ZxIGM15bpT3yAX5eI8deFNcejvc3slGX1hx3bJmQm0wRQy95Cl1gkZfPkQxElHTLtI MMze46tF93aQoizMI/68JwtTGsffevw/oIzvMDNY+pbiUJg2l4fjmdzC8ZMlkVxB/6ze O3xgo8uvPhjwanai0j5OwLPbxQ9wSaH42hD258kbSDo2vKAmWLfUlQsOTXGx+7g5cf7a BLgHdFqDJnkhHE3/z6xsnaGMD9Svj99n/jr0H/BeibOcjVhcll6Bir8hA56hBd+YEfLA 9bFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Uv6uobb9n7+89gDZ1PPjL9V+r+Dp+/7nFjMDRgWgIb4=; b=lvL4jt6i+Hwn2OyigdyGnGkZkF7dB2cN5Vqm400n71uhzXIAUCM2IsX8paXNP31NX9 KYZfoWXhL7A9uU/9qKYItJpLzDjIUd8xGZjxPPGorA+tsC/+v2vchmtetTWEncA/ixJ3 4aGx0SsftmmnDUWEBsopQA5V1q10qk7lSg9IcNrrbaMWgXNN0sej0I3oTTweArvhMeNp zEn/pmkPe2EvxEn3L2kGemZhQISUGI7i4yP2FKjFthdrZq7UJtazKBny0+GIPLcKGtaB t2Bo/I/9Lm6//CKszZhkk2UGvalnRxAIBxaxeiTNkRdQhMb07BuyGgrkRCadESqVH5Xb /g8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n125si5710301oib.97.2020.03.30.05.10.08; Mon, 30 Mar 2020 05:10:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730084AbgC3MJn (ORCPT + 99 others); Mon, 30 Mar 2020 08:09:43 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:51715 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729627AbgC3MJm (ORCPT ); Mon, 30 Mar 2020 08:09:42 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Tu2RGTX_1585570174; Received: from JosephdeMacBook-Pro.local(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0Tu2RGTX_1585570174) by smtp.aliyun-inc.com(127.0.0.1); Mon, 30 Mar 2020 20:09:34 +0800 Subject: Re: [RFC PATCH v1 29/50] fs/ocfs2/journal: Use prandom_u32() and not /dev/random for timeout To: George Spelvin , linux-kernel@vger.kernel.org Cc: Mark Fasheh , Joel Becker , ocfs2-devel@oss.oracle.com References: <202003281643.02SGhIOY022599@sdf.org> From: Joseph Qi Message-ID: <016c2bdc-68eb-245f-2292-d00d0d8e45a5@linux.alibaba.com> Date: Mon, 30 Mar 2020 20:09:33 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <202003281643.02SGhIOY022599@sdf.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > Cc: Mark Fasheh > Cc: Joel Becker > Cc: Joseph Qi > 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 > } > > /* >