public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat•com>
To: Andy Shevchenko <andriy.shevchenko@linux•intel.com>
Cc: Sam Bobroff <sbobroff@linux•ibm.com>,
	linux-pci@vger•kernel.org, dhowells@redhat•com,
	Oliver O'Halloran <oohall@gmail•com>,
	Bjorn Helgaas <helgaas@kernel•org>,
	linuxppc-dev@lists•ozlabs.org
Subject: Re: [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
Date: Wed, 02 Oct 2019 11:27:59 +0100	[thread overview]
Message-ID: <11309.1570012079@warthog.procyon.org.uk> (raw)
In-Reply-To: <20190930121313.GV32742@smile.fi.intel.com>

Andy Shevchenko <andriy.shevchenko@linux•intel.com> wrote:

> > but I confess to being a little ambivalent.  It's
> > arguably a little easier to read,
> 
> I have another opinion here. Instead of parsing body of for-loop, the name of
> the function tells you exactly what it's done. Besides the fact that reading
> and parsing two lines, with zero conditionals, is faster.
> 
> > but it's not nearly as efficient
> > (not a great concern here)
> 
> David, do you know why for_each_set_bit() has no optimization for the cases
> when nbits <= BITS_PER_LONG? (Actually find_*bit() family of functions)

I've not had anything to do with for_each_set_bit() itself.

By 'nbits', I presume you mean the size parameter - max in the sample bit of
code.

It would need per-arch optimisation.  Some arches have an instruction to find
the next bit and some don't.

Using for_each_set_bit() like this is definitely suboptimal, since
find_first_bit() and find_next_bit() may well be out of line.

It should probably be using something like __ffs() if size <= BITS_PER_LONG.

David

      reply	other threads:[~2019-10-02 10:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 15:18 [PATCH v1 1/2] PCI/AER: Use for_each_set_bit() Andy Shevchenko
2019-08-27 15:18 ` [PATCH v1 2/2] PCI/AER: Update parameter descriptions to satisfy kernel-doc validator Andy Shevchenko
2019-08-27 17:06   ` Kuppuswamy Sathyanarayanan
2019-08-28 10:07     ` Andy Shevchenko
2019-08-27 17:06 ` [PATCH v1 1/2] PCI/AER: Use for_each_set_bit() Kuppuswamy Sathyanarayanan
2019-09-27 10:44 ` Bjorn Helgaas
2019-09-27 12:39 ` Bjorn Helgaas
2019-09-30 12:13   ` Andy Shevchenko
2019-10-02 10:27     ` David Howells [this message]

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=11309.1570012079@warthog.procyon.org.uk \
    --to=dhowells@redhat$(echo .)com \
    --cc=andriy.shevchenko@linux$(echo .)intel.com \
    --cc=helgaas@kernel$(echo .)org \
    --cc=linux-pci@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=oohall@gmail$(echo .)com \
    --cc=sbobroff@linux$(echo .)ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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