LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [f2fs-dev] [PATCH v1 3/5] treewide: use get_random_u32() when possib

To: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Subject: Re: [f2fs-dev] [PATCH v1 3/5] treewide: use get_random_u32() when possible
Cc: Jan Kara <jack@xxxxxxx>, Andrew Lunn <andrew@xxxxxxx>, "Darrick J . Wong" <djwong@xxxxxxxxxx>, Ulf Hansson <ulf.hansson@xxxxxxxxxx>, dri-devel@xxxxxxxxxxxxxxxxxxxxx, Andrii Nakryiko <andrii@xxxxxxxxxx>, Hans Verkuil <hverkuil@xxxxxxxxx>, linux-sctp@xxxxxxxxxxxxxxx, "Md . Haris Iqbal" <haris.iqbal@xxxxxxxxx>, Miquel Raynal <miquel.raynal@xxxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Andy Gospodarek <andy@xxxxxxxxxxxxx>, Sergey Matyukevich <geomatsi@xxxxxxxxx>, Rohit Maheshwari <rohitm@xxxxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, ceph-devel@xxxxxxxxxxxxxxx, Christophe Leroy <christophe.leroy@xxxxxxxxxx>, Jozsef Kadlecsik <kadlec@xxxxxxxxxxxxx>, Nilesh Javali <njavali@xxxxxxxxxxx>, Jean-Paul Roubelat <jpr@xxxxxxxxx>, Dick Kennedy <dick.kennedy@xxxxxxxxxxxx>, Jay Vosburgh <j.vosburgh@xxxxxxxxx>, Potnuri Bharat Teja <bharat@xxxxxxxxxxx>, Vinay Kumar Yadav <vinay.yadav@xxxxxxxxxxx>, linux-nfs@xxxxxxxxxxxxxxx, Nicholas Piggin <npiggin@xxxxxxxxx>, Igor Mitsyanko <imitsyanko@xxxxxxxxxxxxx>, Andy Lutomirski <luto@xxxxxxxxxx>, linux-hams@xxxxxxxxxxxxxxx, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>, linux-raid@xxxxxxxxxxxxxxx, Neil Horman <nhorman@xxxxxxxxxxxxx>, Hante Meuleman <hante.meuleman@xxxxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, linux-usb@xxxxxxxxxxxxxxx, Michael Chan <michael.chan@xxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, Varun Prakash <varun@xxxxxxxxxxx>, Chuck Lever <chuck.lever@xxxxxxxxxx>, netfilter-devel@xxxxxxxxxxxxxxx, Masami Hiramatsu <mhiramat@xxxxxxxxxx>, Jiri Olsa <jolsa@xxxxxxxxxx>, Jan Kara <jack@xxxxxxxx>, linux-fsdevel@xxxxxxxxxxxxxxx, Lars Ellenberg <lars.ellenberg@xxxxxxxxxx>, linux-media@xxxxxxxxxxxxxxx, Claudiu Beznea <claudiu.beznea@xxxxxxxxxxxxx>, Sharvari Harisangam <sharvari.harisangam@xxxxxxx>, linux-fbdev@xxxxxxxxxxxxxxx, linux-doc@xxxxxxxxxxxxxxx, linux-mmc@xxxxxxxxxxxxxxx, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, Song Liu <song@xxxxxxxxxx>, Eric Dumazet <edumazet@xxxxxxxxxx>, target-devel@xxxxxxxxxxxxxxx, John Stultz <jstultz@xxxxxxxxxx>, Stanislav Fomichev <sdf@xxxxxxxxxx>, Gregory Greenman <gregory.greenman@xxxxxxxxx>, drbd-dev@xxxxxxxxxxxxxxxx, dev@xxxxxxxxxxxxxxx, Leon Romanovsky <leon@xxxxxxxxxx>, Helge Deller <deller@xxxxxx>, Hugh Dickins <hughd@xxxxxxxxxx>, James Smart <james.smart@xxxxxxxxxxxx>, Anil S Keshavamurthy <anil.s.keshavamurthy@xxxxxxxxx>, Pravin B Shelar <pshelar@xxxxxxx>, Julian Anastasov <ja@xxxxxx>, coreteam@xxxxxxxxxxxxx, Veaceslav Falico <vfalico@xxxxxxxxx>, Yonghong Song <yhs@xxxxxx>, Namjae Jeon <linkinjeon@xxxxxxxxxx>, linux-crypto@xxxxxxxxxxxxxxx, Santosh Shilimkar <santosh.shilimkar@xxxxxxxxxx>, Ganapathi Bhat <ganapathi017@xxxxxxxxx>, linux-actions@xxxxxxxxxxxxxxxxxxx, Simon Horman <horms@xxxxxxxxxxxx>, Jaegeuk Kim <jaegeuk@xxxxxxxxxx>, Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>, Hao Luo <haoluo@xxxxxxxxxx>, "Theodore Ts'o" <tytso@xxxxxxx>, Stephen Boyd <sboyd@xxxxxxxxxx>, Dennis Dalessandro <dennis.dalessandro@xxxxxxxxxxxxxxxxxxxx>, Florian Westphal <fw@xxxxxxxxx>, Andreas Färber <afaerber@xxxxxxx>, Jon Maloy <jmaloy@xxxxxxxxxx>, Vlad Yasevich <vyasevich@xxxxxxxxx>, Anna Schumaker <anna@xxxxxxxxxx>, Yehezkel Bernat <YehezkelShB@xxxxxxxxx>, Haoyue Xu <xuhaoyue1@xxxxxxxxxxxxx>, Heiner Kallweit <hkallweit1@xxxxxxxxx>, linux-wireless@xxxxxxxxxxxxxxx, Marcelo Ricardo Leitner <marcelo.leitner@xxxxxxxxx>, Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>, linux-nvme@xxxxxxxxxxxxxxxxxxx, Michal Januszewski <spock@xxxxxxxxxx>, linux-mtd@xxxxxxxxxxxxxxxxxxx, kasan-dev@xxxxxxxxxxxxxxxx, Cong Wang <xiyou.wangcong@xxxxxxxxx>, Thomas Sailer <t.sailer@xxxxxxxxxxxxxx>, Ajay Singh <ajay.kathat@xxxxxxxxxxxxx>, Xiubo Li <xiubli@xxxxxxxxxx>, Sagi Grimberg <sagi@xxxxxxxxxxx>, Daniel Borkmann <daniel@xxxxxxxxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, linux-rdma@xxxxxxxxxxxxxxx, lvs-devel@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, "Naveen N . Rao" <naveen.n.rao@xxxxxxxxxxxxx>, Ilya Dryomov <idryomov@xxxxxxxxx>, Paolo Abeni <pabeni@xxxxxxxxxx>, Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>, Marco Elver <elver@xxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, Yury Norov <yury.norov@xxxxxxxxx>, "James E . J . Bottomley" <jejb@xxxxxxxxxxxxx>, Jamal Hadi Salim <jhs@xxxxxxxxxxxx>, KP Singh <kpsingh@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Keith Busch <kbusch@xxxxxxxxxx>, Dan Williams <dan.j.williams@xxxxxxxxx>, Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>, Franky Lin <franky.lin@xxxxxxxxxxxx>, Arend van Spriel <aspriel@xxxxxxxxx>, linux-ext4@xxxxxxxxxxxxxxx, Wenpeng Liang <liangwenpeng@xxxxxxxxxx>, "Martin K . Petersen" <martin.petersen@xxxxxxxxxx>, Xinming Hu <huxinming820@xxxxxxxxx>, linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx, Jeff Layton <jlayton@xxxxxxxxxx>, linux-xfs@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, Ying Xue <ying.xue@xxxxxxxxxxxxx>, Manish Rangankar <mrangankar@xxxxxxxxxxx>, "David S . Miller" <davem@xxxxxxxxxxxxx>, Toke Høiland-Jørgensen <toke@xxxxxxx>, Vignesh Raghavendra <vigneshr@xxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, "H . Peter Anvin" <hpa@xxxxxxxxx>, Alexandre Torgue <alexandre.torgue@xxxxxxxxxxx>, Amitkumar Karwar <amitkarwar@xxxxxxxxx>, linux-mm@xxxxxxxxx, Andreas Dilger <adilger.kernel@xxxxxxxxx>, Ayush Sawal <ayush.sawal@xxxxxxxxxxx>, Andreas Noever <andreas.noever@xxxxxxxxx>, Jiri Pirko <jiri@xxxxxxxxxxx>, linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx, Jack Wang <jinpu.wang@xxxxxxxxx>, Steffen Klassert <steffen.klassert@xxxxxxxxxxx>, rds-devel@xxxxxxxxxxxxxx, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>, linux-scsi@xxxxxxxxxxxxxxx, dccp@xxxxxxxxxxxxxxx, Richard Weinberger <richard@xxxxxx>, Russell King <linux@xxxxxxxxxxxxxxx>, Jason Gunthorpe <jgg@xxxxxxxx>, SHA-cyfmac-dev-list@xxxxxxxxxxxx, Ingo Molnar <mingo@xxxxxxxxxx>, Jakub Kicinski <kuba@xxxxxxxxxx>, John Fastabend <john.fastabend@xxxxxxxxx>, Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx>, Manivannan Sadhasivam <mani@xxxxxxxxxx>, Michael Jamet <michael.jamet@xxxxxxxxx>, Kalle Valo <kvalo@xxxxxxxxxx>, Akinobu Mita <akinobu.mita@xxxxxxxxx>, linux-block@xxxxxxxxxxxxxxx, dmaengine@xxxxxxxxxxxxxxx, Hannes Reinecke <hare@xxxxxxx>, Dmitry Vyukov <dvyukov@xxxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>, cake@xxxxxxxxxxxxxxxxxxxxx, brcm80211-dev-list.pdl@xxxxxxxxxxxx, Yishai Hadas <yishaih@xxxxxxxxxx>, Hideaki YOSHIFUJI <yoshfuji@xxxxxxxxxxxxxx>, linuxppc-dev@xxxxxxxxxxxxxxxx, David Ahern <dsahern@xxxxxxxxxx>, Philipp Reisner <philipp.reisner@xxxxxxxxxx>, Stephen Hemminger <stephen@xxxxxxxxxxxxxxxxxx>, Christoph Böhmwalder <christoph.boehmwalder@xxxxxxxxxx>, Vinod Koul <vkoul@xxxxxxxxxx>, tipc-discussion@xxxxxxxxxxxxxxxxxxxxx, Thomas Graf <tgraf@xxxxxxx>, Johannes Berg <johannes@xxxxxxxxxxxxxxxx>, Sungjong Seo <sj1557.seo@xxxxxxxxxxx>, Martin KaFai Lau <martin.lau@xxxxxxxxx>
From: "Jason A. Donenfeld" <Jason@xxxxxxxxx>
Date: Thu, 6 Oct 2022 07:07:24 -0600
On Thu, Oct 6, 2022 at 7:01 AM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Thu, Oct 06, 2022 at 06:33:15AM -0600, Jason A. Donenfeld wrote:
> > On Thu, Oct 06, 2022 at 10:43:31AM +0200, Jan Kara wrote:
>
> ...
>
> > > The code here is effectively doing the
> > >
> > >     parent_group = prandom_u32_max(ngroups);
> > >
> > > Similarly here we can use prandom_u32_max(ngroups) like:
> > >
> > >             if (qstr) {
> > >                     ...
> > >                     parent_group = hinfo.hash % ngroups;
> > >             } else
> > >                     parent_group = prandom_u32_max(ngroups);
> >
> > Nice catch. I'll move these to patch #1.
>
> I believe coccinelle is able to handle this kind of code as well

I'd be extremely surprised. The details were kind of non obvious. I
just spent a decent amount of time manually checking those blocks, to
make sure we didn't wind up with different behavior, given the
variable reuse.

Jason

<Prev in Thread] Current Thread [Next in Thread>