From patchwork Thu Mar 21 03:07:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Spelvin X-Patchwork-Id: 11465807 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 609F7912 for ; Mon, 30 Mar 2020 15:22:15 +0000 (UTC) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3AE3D20732 for ; Mon, 30 Mar 2020 15:22:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AE3D20732 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sdf.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=ocfs2-devel-bounces@oss.oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02UFIjXn115411; Mon, 30 Mar 2020 15:21:48 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 303aqhau7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Mar 2020 15:21:48 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02UFKJU1171328; Mon, 30 Mar 2020 15:21:47 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 302g9vcksm-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Mon, 30 Mar 2020 15:21:47 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jIwEU-0000EB-QK; Mon, 30 Mar 2020 08:21:46 -0700 Received: from aserp3030.oracle.com ([141.146.126.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jIEYw-0006uv-Q4 for ocfs2-devel@oss.oracle.com; Sat, 28 Mar 2020 09:43:58 -0700 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SGg0Em051175 for ; Sat, 28 Mar 2020 16:43:58 GMT Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserp3030.oracle.com with ESMTP id 301vm8ufbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 28 Mar 2020 16:43:58 +0000 Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SGhNq3035055 for ; Sat, 28 Mar 2020 16:43:57 GMT Received: from mx.sdf.org (mx.sdf.org [205.166.94.20]) by userp2040.oracle.com with ESMTP id 301w6q2btx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 28 Mar 2020 16:43:57 +0000 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 02SGhIFR001177 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sat, 28 Mar 2020 16:43:18 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02SGhIOY022599; Sat, 28 Mar 2020 16:43:18 GMT Message-Id: <202003281643.02SGhIOY022599@sdf.org> From: George Spelvin Date: Wed, 20 Mar 2019 23:07:46 -0400 To: linux-kernel@vger.kernel.org, lkml@sdf.org X-PDR: PASS X-Source-IP: 205.166.94.20 X-ServerName: mx.sdf.org X-Proofpoint-SPF-Result: None X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9574 signatures=668685 X-Proofpoint-Spam-Details: rule=tap_spam_policies_notspam policy=tap_spam_policies score=0 mlxlogscore=824 priorityscore=381 suspectscore=7 bulkscore=0 clxscore=102 phishscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280159 X-Spam: Clean X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=1 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=953 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280159 X-Mailman-Approved-At: Mon, 30 Mar 2020 08:21:45 -0700 Cc: ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [RFC PATCH v1 29/50] fs/ocfs2/journal: Use prandom_u32() and not /dev/random for timeout X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9576 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003300143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9576 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1011 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003300143 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 Acked-by: Joseph Qi --- 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); } /*