[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABEBQimNm_Ba6j=2cAc8Gw68K_8nVccrT=10LsSkMnTMbo9s3g@mail.gmail.com>
Date: Tue, 18 Oct 2022 09:48:15 +0100
From: Frank Hofmann <fhofmann@...udflare.com>
To: David Laight <David.Laight@...lab.com>
Cc: Ivan Babrou <ivan@...udflare.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel-team@...udflare.com" <kernel-team@...udflare.com>,
Alexey Dobriyan <adobriyan@...il.com>,
Al Viro <viro@...iv.linux.org.uk>,
"Theodore Ts'o" <tytso@....edu>, Jonathan Corbet <corbet@....net>,
David Hildenbrand <david@...hat.com>,
Johannes Weiner <hannes@...xchg.org>,
Christoph Anton Mitterer <mail@...istoph.anton.mitterer.name>,
Mike Rapoport <rppt@...nel.org>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Kalesh Singh <kaleshsingh@...gle.com>
Subject: Re: [PATCH v2] proc: report open files as size in stat() for /proc/pid/fd
On Tue, Oct 18, 2022 at 9:25 AM David Laight <David.Laight@...lab.com> wrote:
>
> From: Frank Hofmann
> > Sent: 18 October 2022 09:13
> >
> > On Tue, Oct 18, 2022 at 6:02 AM Ivan Babrou <ivan@...udflare.com> wrote:
> > >
> > > On Mon, Oct 17, 2022 at 6:47 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
> > > > > +
> > > > > + fdt = files_fdtable(p->files);
> > > > > + size = fdt->max_fds;
> > > > > +
> > > > > + for (i = size / BITS_PER_LONG; i > 0;)
> > > > > + open_fds += hweight64(fdt->open_fds[--i]);
> > > >
> > > > Could BITMAP_WEIGHT() or __bitmap_weight() or bitmap_weight() be used here?
> > >
> > > That's a great suggestion. I tested it with bitmap_weight() and it
> > > looks much cleaner while providing the same result.
> > >
> > > I just sent the v3 with this suggestion applied.
> >
> > +1 from me on using bitmap_weight() - good spotting that.
>
> Does that have the optimisations for the value being 0, ~0u
> or 2**n-1 all of which are likely for the fd table.
> (Especially if there is no 'popcnt' instruction.)
>
> David
bitmap_weight() uses hweight_*() under the hood, which then falls
through to platform-specific popcnt where available.
Re, lib/bitmap.c and arch/.../asm/bitops.h or arch/.../hweight.S, for
the impl details.
FrankH.
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
Powered by blists - more mailing lists