linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
@ 2019-08-27 15:18 Andy Shevchenko
  2019-08-27 15:18 ` [PATCH v1 2/2] PCI/AER: Update parameter descriptions to satisfy kernel-doc validator Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Andy Shevchenko @ 2019-08-27 15:18 UTC (permalink / raw)
  To: Russell Currey, Sam Bobroff, Oliver O'Halloran, linuxppc-dev,
	Bjorn Helgaas, linux-pci
  Cc: Andy Shevchenko

This simplifies and standardizes slot manipulation code
by using for_each_set_bit() library function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pci/pcie/aer.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index b45bc47d04fe..f883f81d759a 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -15,6 +15,7 @@
 #define pr_fmt(fmt) "AER: " fmt
 #define dev_fmt pr_fmt
 
+#include <linux/bitops.h>
 #include <linux/cper.h>
 #include <linux/pci.h>
 #include <linux/pci-acpi.h>
@@ -657,7 +658,8 @@ const struct attribute_group aer_stats_attr_group = {
 static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
 				   struct aer_err_info *info)
 {
-	int status, i, max = -1;
+	unsigned long status = info->status & ~info->mask;
+	int i, max = -1;
 	u64 *counter = NULL;
 	struct aer_stats *aer_stats = pdev->aer_stats;
 
@@ -682,10 +684,8 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
 		break;
 	}
 
-	status = (info->status & ~info->mask);
-	for (i = 0; i < max; i++)
-		if (status & (1 << i))
-			counter[i]++;
+	for_each_set_bit(i, &status, max)
+		counter[i]++;
 }
 
 static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
@@ -717,14 +717,11 @@ static void __print_tlp_header(struct pci_dev *dev,
 static void __aer_print_error(struct pci_dev *dev,
 			      struct aer_err_info *info)
 {
-	int i, status;
+	unsigned long status = info->status & ~info->mask;
 	const char *errmsg = NULL;
-	status = (info->status & ~info->mask);
-
-	for (i = 0; i < 32; i++) {
-		if (!(status & (1 << i)))
-			continue;
+	int i;
 
+	for_each_set_bit(i, &status, 32) {
 		if (info->severity == AER_CORRECTABLE)
 			errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
 				aer_correctable_error_string[i] : NULL;
-- 
2.23.0.rc1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/2] PCI/AER: Update parameter descriptions to satisfy kernel-doc validator
  2019-08-27 15:18 [PATCH v1 1/2] PCI/AER: Use for_each_set_bit() Andy Shevchenko
@ 2019-08-27 15:18 ` Andy Shevchenko
  2019-08-27 17:06   ` Kuppuswamy Sathyanarayanan
  2019-08-27 17:06 ` [PATCH v1 1/2] PCI/AER: Use for_each_set_bit() Kuppuswamy Sathyanarayanan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2019-08-27 15:18 UTC (permalink / raw)
  To: Russell Currey, Sam Bobroff, Oliver O'Halloran, linuxppc-dev,
	Bjorn Helgaas, linux-pci
  Cc: Andy Shevchenko

Kernel-doc validator complains:

aer.c:207: warning: Function parameter or member 'str' not described in 'pcie_ecrc_get_policy'
aer.c:1209: warning: Function parameter or member 'irq' not described in 'aer_isr'
aer.c:1209: warning: Function parameter or member 'context' not described in 'aer_isr'
aer.c:1209: warning: Excess function parameter 'work' description in 'aer_isr'

Fix the above accordingly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pci/pcie/aer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index f883f81d759a..6073eaab099d 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -202,6 +202,7 @@ void pcie_set_ecrc_checking(struct pci_dev *dev)
 
 /**
  * pcie_ecrc_get_policy - parse kernel command-line ecrc option
+ * @str: ECRC policy from kernel command line to use
  */
 void pcie_ecrc_get_policy(char *str)
 {
@@ -1201,7 +1202,8 @@ static void aer_isr_one_error(struct aer_rpc *rpc,
 
 /**
  * aer_isr - consume errors detected by root port
- * @work: definition of this work item
+ * @irq: IRQ assigned to Root Port
+ * @context: pointer to Root Port data structure
  *
  * Invoked, as DPC, when root port records new detected error
  */
-- 
2.23.0.rc1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
  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-09-27 10:44 ` Bjorn Helgaas
  2019-09-27 12:39 ` Bjorn Helgaas
  3 siblings, 0 replies; 9+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2019-08-27 17:06 UTC (permalink / raw)
  To: Andy Shevchenko, Russell Currey, Sam Bobroff,
	Oliver O'Halloran, linuxppc-dev, Bjorn Helgaas, linux-pci


On 8/27/19 8:18 AM, Andy Shevchenko wrote:
> This simplifies and standardizes slot manipulation code
> by using for_each_set_bit() library function.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan 
<sathyanarayanan.kuppuswamy@linux.intel.com>
> ---
>   drivers/pci/pcie/aer.c | 19 ++++++++-----------
>   1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index b45bc47d04fe..f883f81d759a 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -15,6 +15,7 @@
>   #define pr_fmt(fmt) "AER: " fmt
>   #define dev_fmt pr_fmt
>   
> +#include <linux/bitops.h>
>   #include <linux/cper.h>
>   #include <linux/pci.h>
>   #include <linux/pci-acpi.h>
> @@ -657,7 +658,8 @@ const struct attribute_group aer_stats_attr_group = {
>   static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
>   				   struct aer_err_info *info)
>   {
> -	int status, i, max = -1;
> +	unsigned long status = info->status & ~info->mask;
> +	int i, max = -1;
>   	u64 *counter = NULL;
>   	struct aer_stats *aer_stats = pdev->aer_stats;
>   
> @@ -682,10 +684,8 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
>   		break;
>   	}
>   
> -	status = (info->status & ~info->mask);
> -	for (i = 0; i < max; i++)
> -		if (status & (1 << i))
> -			counter[i]++;
> +	for_each_set_bit(i, &status, max)
> +		counter[i]++;
>   }
>   
>   static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
> @@ -717,14 +717,11 @@ static void __print_tlp_header(struct pci_dev *dev,
>   static void __aer_print_error(struct pci_dev *dev,
>   			      struct aer_err_info *info)
>   {
> -	int i, status;
> +	unsigned long status = info->status & ~info->mask;
>   	const char *errmsg = NULL;
> -	status = (info->status & ~info->mask);
> -
> -	for (i = 0; i < 32; i++) {
> -		if (!(status & (1 << i)))
> -			continue;
> +	int i;
>   
> +	for_each_set_bit(i, &status, 32) {
>   		if (info->severity == AER_CORRECTABLE)
>   			errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
>   				aer_correctable_error_string[i] : NULL;

-- 
Sathyanarayanan Kuppuswamy
Linux kernel developer


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 2/2] PCI/AER: Update parameter descriptions to satisfy kernel-doc validator
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2019-08-27 17:06 UTC (permalink / raw)
  To: Andy Shevchenko, Russell Currey, Sam Bobroff,
	Oliver O'Halloran, linuxppc-dev, Bjorn Helgaas, linux-pci


On 8/27/19 8:18 AM, Andy Shevchenko wrote:
> Kernel-doc validator complains:
>
> aer.c:207: warning: Function parameter or member 'str' not described in 'pcie_ecrc_get_policy'
> aer.c:1209: warning: Function parameter or member 'irq' not described in 'aer_isr'
> aer.c:1209: warning: Function parameter or member 'context' not described in 'aer_isr'
> aer.c:1209: warning: Excess function parameter 'work' description in 'aer_isr'
>
> Fix the above accordingly.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan 
<sathyanarayanan.kuppuswamy@linux.intel.com>
> ---
>   drivers/pci/pcie/aer.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index f883f81d759a..6073eaab099d 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -202,6 +202,7 @@ void pcie_set_ecrc_checking(struct pci_dev *dev)
>   
>   /**
>    * pcie_ecrc_get_policy - parse kernel command-line ecrc option
> + * @str: ECRC policy from kernel command line to use
>    */
>   void pcie_ecrc_get_policy(char *str)
>   {
> @@ -1201,7 +1202,8 @@ static void aer_isr_one_error(struct aer_rpc *rpc,
>   
>   /**
>    * aer_isr - consume errors detected by root port
> - * @work: definition of this work item
> + * @irq: IRQ assigned to Root Port
> + * @context: pointer to Root Port data structure
>    *
>    * Invoked, as DPC, when root port records new detected error
>    */

-- 
Sathyanarayanan Kuppuswamy
Linux kernel developer


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 2/2] PCI/AER: Update parameter descriptions to satisfy kernel-doc validator
  2019-08-27 17:06   ` Kuppuswamy Sathyanarayanan
@ 2019-08-28 10:07     ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2019-08-28 10:07 UTC (permalink / raw)
  To: Kuppuswamy Sathyanarayanan
  Cc: Russell Currey, Sam Bobroff, Oliver O'Halloran, linuxppc-dev,
	Bjorn Helgaas, linux-pci

On Tue, Aug 27, 2019 at 10:06:54AM -0700, Kuppuswamy Sathyanarayanan wrote:
> 
> On 8/27/19 8:18 AM, Andy Shevchenko wrote:
> > Kernel-doc validator complains:
> > 
> > aer.c:207: warning: Function parameter or member 'str' not described in 'pcie_ecrc_get_policy'
> > aer.c:1209: warning: Function parameter or member 'irq' not described in 'aer_isr'
> > aer.c:1209: warning: Function parameter or member 'context' not described in 'aer_isr'
> > aer.c:1209: warning: Excess function parameter 'work' description in 'aer_isr'
> > 
> > Fix the above accordingly.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Reviewed-by: Kuppuswamy Sathyanarayanan
> <sathyanarayanan.kuppuswamy@linux.intel.com>

Thanks!
JFYI: Keep your tag on one line. Some bots require this IIRC (patchwork).

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
  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 ` [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
  3 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2019-09-27 10:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Russell Currey, Sam Bobroff, Oliver O'Halloran, linuxppc-dev,
	linux-pci, Kuppuswamy Sathyanarayanan

On Tue, Aug 27, 2019 at 06:18:22PM +0300, Andy Shevchenko wrote:
> This simplifies and standardizes slot manipulation code
> by using for_each_set_bit() library function.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied both with Kuppuswamy's reviewed-by to pci/aer for v5.5,
thanks!

> ---
>  drivers/pci/pcie/aer.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index b45bc47d04fe..f883f81d759a 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -15,6 +15,7 @@
>  #define pr_fmt(fmt) "AER: " fmt
>  #define dev_fmt pr_fmt
>  
> +#include <linux/bitops.h>
>  #include <linux/cper.h>
>  #include <linux/pci.h>
>  #include <linux/pci-acpi.h>
> @@ -657,7 +658,8 @@ const struct attribute_group aer_stats_attr_group = {
>  static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
>  				   struct aer_err_info *info)
>  {
> -	int status, i, max = -1;
> +	unsigned long status = info->status & ~info->mask;
> +	int i, max = -1;
>  	u64 *counter = NULL;
>  	struct aer_stats *aer_stats = pdev->aer_stats;
>  
> @@ -682,10 +684,8 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
>  		break;
>  	}
>  
> -	status = (info->status & ~info->mask);
> -	for (i = 0; i < max; i++)
> -		if (status & (1 << i))
> -			counter[i]++;
> +	for_each_set_bit(i, &status, max)
> +		counter[i]++;
>  }
>  
>  static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
> @@ -717,14 +717,11 @@ static void __print_tlp_header(struct pci_dev *dev,
>  static void __aer_print_error(struct pci_dev *dev,
>  			      struct aer_err_info *info)
>  {
> -	int i, status;
> +	unsigned long status = info->status & ~info->mask;
>  	const char *errmsg = NULL;
> -	status = (info->status & ~info->mask);
> -
> -	for (i = 0; i < 32; i++) {
> -		if (!(status & (1 << i)))
> -			continue;
> +	int i;
>  
> +	for_each_set_bit(i, &status, 32) {
>  		if (info->severity == AER_CORRECTABLE)
>  			errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
>  				aer_correctable_error_string[i] : NULL;
> -- 
> 2.23.0.rc1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
  2019-08-27 15:18 [PATCH v1 1/2] PCI/AER: Use for_each_set_bit() Andy Shevchenko
                   ` (2 preceding siblings ...)
  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
  3 siblings, 2 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2019-09-27 12:39 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Russell Currey, Sam Bobroff, Oliver O'Halloran, linuxppc-dev,
	linux-pci

On Tue, Aug 27, 2019 at 06:18:22PM +0300, Andy Shevchenko wrote:
> This simplifies and standardizes slot manipulation code
> by using for_each_set_bit() library function.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pci/pcie/aer.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index b45bc47d04fe..f883f81d759a 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -15,6 +15,7 @@
>  #define pr_fmt(fmt) "AER: " fmt
>  #define dev_fmt pr_fmt
>  
> +#include <linux/bitops.h>
>  #include <linux/cper.h>
>  #include <linux/pci.h>
>  #include <linux/pci-acpi.h>
> @@ -657,7 +658,8 @@ const struct attribute_group aer_stats_attr_group = {
>  static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
>  				   struct aer_err_info *info)
>  {
> -	int status, i, max = -1;
> +	unsigned long status = info->status & ~info->mask;
> +	int i, max = -1;
>  	u64 *counter = NULL;
>  	struct aer_stats *aer_stats = pdev->aer_stats;
>  
> @@ -682,10 +684,8 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
>  		break;
>  	}
>  
> -	status = (info->status & ~info->mask);
> -	for (i = 0; i < max; i++)
> -		if (status & (1 << i))
> -			counter[i]++;
> +	for_each_set_bit(i, &status, max)

I applied this, but I confess to being a little ambivalent.  It's
arguably a little easier to read, but it's not nearly as efficient
(not a great concern here) and more importantly much harder to verify
that it's correct because you have to chase through
for_each_set_bit(), find_first_bit(), _ffs(), etc, etc.  No doubt it's
great for bitmaps of arbitrary size, but for a simple 32-bit register
I'm a little hesitant.  But I applied it anyway.

> +		counter[i]++;
>  }
>  
>  static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
> @@ -717,14 +717,11 @@ static void __print_tlp_header(struct pci_dev *dev,
>  static void __aer_print_error(struct pci_dev *dev,
>  			      struct aer_err_info *info)
>  {
> -	int i, status;
> +	unsigned long status = info->status & ~info->mask;
>  	const char *errmsg = NULL;
> -	status = (info->status & ~info->mask);
> -
> -	for (i = 0; i < 32; i++) {
> -		if (!(status & (1 << i)))
> -			continue;
> +	int i;
>  
> +	for_each_set_bit(i, &status, 32) {
>  		if (info->severity == AER_CORRECTABLE)
>  			errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
>  				aer_correctable_error_string[i] : NULL;
> -- 
> 2.23.0.rc1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
  2019-09-27 12:39 ` Bjorn Helgaas
@ 2019-09-30 12:13   ` Andy Shevchenko
  2019-10-02 10:27   ` David Howells
  1 sibling, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2019-09-30 12:13 UTC (permalink / raw)
  To: Bjorn Helgaas, David Howells
  Cc: Russell Currey, Sam Bobroff, Oliver O'Halloran, linuxppc-dev,
	linux-pci

On Fri, Sep 27, 2019 at 07:39:13AM -0500, Bjorn Helgaas wrote:
> On Tue, Aug 27, 2019 at 06:18:22PM +0300, Andy Shevchenko wrote:
> > This simplifies and standardizes slot manipulation code
> > by using for_each_set_bit() library function.

> > +	unsigned long status = info->status & ~info->mask;
> > +	int i, max = -1;

> > -	for (i = 0; i < max; i++)
> > -		if (status & (1 << i))
> > -			counter[i]++;
> > +	for_each_set_bit(i, &status, max)
> 
> I applied this,

Thank you!

> 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)

> and more importantly much harder to verify
> that it's correct because you have to chase through
> for_each_set_bit(), find_first_bit(), _ffs(), etc, etc.

If for_each_set_bit() or any other fundamental bit operation helper is broken,
PCI subsystem is a little concern here.

> No doubt it's
> great for bitmaps of arbitrary size, but for a simple 32-bit register
> I'm a little hesitant.  But I applied it anyway.
> 
> > +		counter[i]++;

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
  2019-09-27 12:39 ` Bjorn Helgaas
  2019-09-30 12:13   ` Andy Shevchenko
@ 2019-10-02 10:27   ` David Howells
  1 sibling, 0 replies; 9+ messages in thread
From: David Howells @ 2019-10-02 10:27 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: dhowells, Bjorn Helgaas, Russell Currey, Sam Bobroff,
	Oliver O'Halloran, linuxppc-dev, linux-pci

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-02 10:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).