From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42C50C433FE for ; Wed, 12 Oct 2022 21:44:46 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1oijWt-000244-Jo; Wed, 12 Oct 2022 21:44:43 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oijWs-00023y-G2 for linux-f2fs-devel@lists.sourceforge.net; Wed, 12 Oct 2022 21:44:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :In-Reply-To:References:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DLr+AazHKqvd37FIJspzgJ5v0CvIeseJ+7IB12p8OSQ=; b=jaVoRprJuw/iPRr2SoOwcOIu6N Txf3iGrIHtX2m7ku8GoSXU0bCDokv+DfCdr3Tqcg/md0/YhRso4g+ZHuI4lBhO7mwpSzPEC1jo+fr ezy7k8d8VWJTN011VXN+4R3n0MU45MdscJvp6DiwQJnzgmxJYl+YgOIajlSRO/GObYUo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:In-Reply-To: References:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DLr+AazHKqvd37FIJspzgJ5v0CvIeseJ+7IB12p8OSQ=; b=CKrdkYXY6ONoJk440tGn6Yc/Ah rQG53K4ROl5xpG5tOp2EYh161Qv6oGIuSd/pv55qcfYW5ZUnAXLEiajXG7kENi4cBWjEFz3Xj9WZD ZKfL8jzFG+0R+R7XFlHhztwcZXR9lK4JiO+fQRHoE3RiIGkliYmX9xt1Y0cd4UWy4urQ=; Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1oijWq-001aEh-3B for linux-f2fs-devel@lists.sourceforge.net; Wed, 12 Oct 2022 21:44:42 +0000 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-269-WPghBqosPyeNkdeVSYELTw-1; Wed, 12 Oct 2022 22:29:04 +0100 X-MC-Unique: WPghBqosPyeNkdeVSYELTw-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 12 Oct 2022 22:29:02 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.040; Wed, 12 Oct 2022 22:29:02 +0100 From: David Laight To: 'Joe Perches' , "Jason A. Donenfeld" , "linux-kernel@vger.kernel.org" Thread-Topic: [PATCH v1 3/5] treewide: use get_random_u32() when possible Thread-Index: AQHY3m9QJDmwhr5XuUa4Hi/RfD23ja4LRXVg Date: Wed, 12 Oct 2022 21:29:02 +0000 Message-ID: References: <20221005214844.2699-1-Jason@zx2c4.com> <20221005214844.2699-4-Jason@zx2c4.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US X-Headers-End: 1oijWq-001aEh-3B Subject: Re: [f2fs-dev] [PATCH v1 3/5] treewide: use get_random_u32() when possible X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-fbdev@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-mmc@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "linux-mm@kvack.org" , "linux-sctp@vger.kernel.org" , "target-devel@vger.kernel.org" , "linux-mtd@lists.infradead.org" , "linux-stm32@st-md-mailman.stormreply.com" , "drbd-dev@lists.linbit.com" , "dev@openvswitch.org" , "rds-devel@oss.oracle.com" , "linux-scsi@vger.kernel.org" , "dccp@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "kasan-dev@googlegroups.com" , "lvs-devel@vger.kernel.org" , "SHA-cyfmac-dev-list@infineon.com" , "coreteam@netfilter.org" , "netfilter-devel@vger.kernel.org" , "linux-ext4@vger.kernel.org" , "linux-media@vger.kernel.org" , "linux-actions@lists.infradead.org" , "brcm80211-dev-list.pdl@broadcom.com" , "linux-block@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-nvme@lists.infradead.org" , "linux-hams@vger.kernel.org" , "ceph-devel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "cake@lists.bufferbloat.net" , "linux-nfs@vger.kernel.org" , "linux-raid@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-xfs@vger.kernel.org" , "tipc-discussion@lists.sourceforge.net" , "linux-crypto@vger.kernel.org" , "dmaengine@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Joe Perches > Sent: 12 October 2022 20:17 > > On Wed, 2022-10-05 at 23:48 +0200, Jason A. Donenfeld wrote: > > The prandom_u32() function has been a deprecated inline wrapper around > > get_random_u32() for several releases now, and compiles down to the > > exact same code. Replace the deprecated wrapper with a direct call to > > the real function. > [] > > diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c > [] > > @@ -734,7 +734,7 @@ static int send_connect(struct c4iw_ep *ep) > > &ep->com.remote_addr; > > int ret; > > enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type; > > - u32 isn = (prandom_u32() & ~7UL) - 1; > > + u32 isn = (get_random_u32() & ~7UL) - 1; > > trivia: > > There are somewhat odd size mismatches here. > > I had to think a tiny bit if random() returned a value from 0 to 7 > and was promoted to a 64 bit value then truncated to 32 bit. > > Perhaps these would be clearer as ~7U and not ~7UL That makes no difference - the compiler will generate the same code. The real question is WTF is the code doing? The '& ~7u' clears the bottom 3 bits. The '- 1' then sets the bottom 3 bits and decrements the (random) high bits. So is the same as get_random_u32() | 7. But I bet the coder had something else in mind. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel