mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Frank Hofmann' <fhofmann@cloudflare.com>,
	Ivan Babrou <ivan@cloudflare.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-team@cloudflare.com" <kernel-team@cloudflare.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>, Theodore Ts'o <tytso@mit.edu>,
	Jonathan Corbet <corbet@lwn.net>,
	David Hildenbrand <david@redhat.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>,
	Mike Rapoport <rppt@kernel.org>,
	"Paul Gortmaker" <paul.gortmaker@windriver.com>,
	Kalesh Singh <kaleshsingh@google.com>
Subject: RE: [PATCH v2] proc: report open files as size in stat() for /proc/pid/fd
Date: Tue, 18 Oct 2022 08:25:14 +0000	[thread overview]
Message-ID: <57b146037b5744d4877fd77b1e4db262@AcuMS.aculab.com> (raw)
In-Reply-To: <CABEBQineydLjdHcc84+JuQnvEbGqkiXuVRXvcmk58bO=9X901Q@mail.gmail.com>

From: Frank Hofmann
> Sent: 18 October 2022 09:13
> 
> On Tue, Oct 18, 2022 at 6:02 AM Ivan Babrou <ivan@cloudflare.com> wrote:
> >
> > On Mon, Oct 17, 2022 at 6:47 PM Andrew Morton <akpm@linux-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

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2022-10-18  8:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 22:40 Ivan Babrou
2022-10-17 19:00 ` Ivan Babrou
2022-10-18  1:47 ` Andrew Morton
2022-10-18  5:02   ` Ivan Babrou
2022-10-18  8:12     ` Frank Hofmann
2022-10-18  8:25       ` David Laight [this message]
2022-10-18  8:48         ` Frank Hofmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57b146037b5744d4877fd77b1e4db262@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=fhofmann@cloudflare.com \
    --cc=hannes@cmpxchg.org \
    --cc=ivan@cloudflare.com \
    --cc=kaleshsingh@google.com \
    --cc=kernel-team@cloudflare.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail@christoph.anton.mitterer.name \
    --cc=paul.gortmaker@windriver.com \
    --cc=rppt@kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®