Thread (31 messages) 31 messages, 8 authors, 2022-10-13

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

From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: 2022-10-06 13:08:53
Also in: ceph-devel, dmaengine, dri-devel, linux-block, linux-crypto, linux-doc, linux-ext4, linux-f2fs-devel, linux-fbdev, linux-fsdevel, linux-hams, linux-media, linux-mmc, linux-nfs, linux-nvme, linux-raid, linux-rdma, linux-scsi, linux-sctp, linux-usb, linux-wireless, linux-xfs, lkml, lvs-devel, netdev, netfilter-devel, target-devel

On Thu, Oct 6, 2022 at 7:01 AM Andy Shevchenko
[off-list ref] wrote:
On Thu, Oct 06, 2022 at 06:33:15AM -0600, Jason A. Donenfeld wrote:
quoted
On Thu, Oct 06, 2022 at 10:43:31AM +0200, Jan Kara wrote:
...
quoted
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help