[patch 00/46] genirq: Cleanups and conversion to lock guards

Thomas Gleixner posted 46 patches 11 months ago
There is a newer version of this series
include/linux/irq.h     |    2
kernel/irq/autoprobe.c  |   26 -
kernel/irq/chip.c       |  640 ++++++++++----------------
kernel/irq/cpuhotplug.c |   10
kernel/irq/debugfs.c    |    3
kernel/irq/internals.h  |   47 -
kernel/irq/irqdesc.c    |  136 +----
kernel/irq/manage.c     | 1154 ++++++++++++++++++++----------------------------
kernel/irq/pm.c         |   38 -
kernel/irq/proc.c       |   65 --
kernel/irq/resend.c     |   50 --
kernel/irq/spurious.c   |  104 +---
12 files changed, 920 insertions(+), 1355 deletions(-)
[patch 00/46] genirq: Cleanups and conversion to lock guards
Posted by Thomas Gleixner 11 months ago
The generic interrupt core code has accumulated quite some inconsistencies
over time and a common pattern in various API functions is:

    unsigned long flags;
    struct irq_desc *desc = irq_get_desc_[bus]lock(irq, &flags, mode);

    if (!desc)
       return -EINVAL;
    ....
    irq_put_desc_[bus]unlock(desc, flags);

That's awkward and requires gotos in failure paths.

This series provides conditional lock guards and converts the core code
over to use those guards. Along with that it converts the other open coded
lock/unlock pairs and fixes up coding and kernel doc formatting.  The
conversions were partially done with Coccinelle where possible.

The series applies on Linus tree and is also available from git:

    git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git irq/core

Thanks,

	tglx
---
 include/linux/irq.h     |    2 
 kernel/irq/autoprobe.c  |   26 -
 kernel/irq/chip.c       |  640 ++++++++++----------------
 kernel/irq/cpuhotplug.c |   10 
 kernel/irq/debugfs.c    |    3 
 kernel/irq/internals.h  |   47 -
 kernel/irq/irqdesc.c    |  136 +----
 kernel/irq/manage.c     | 1154 ++++++++++++++++++++----------------------------
 kernel/irq/pm.c         |   38 -
 kernel/irq/proc.c       |   65 --
 kernel/irq/resend.c     |   50 --
 kernel/irq/spurious.c   |  104 +---
 12 files changed, 920 insertions(+), 1355 deletions(-)
Re: [patch 00/46] genirq: Cleanups and conversion to lock guards
Posted by Peter Zijlstra 11 months ago
On Thu, Mar 13, 2025 at 04:59:41PM +0100, Thomas Gleixner wrote:
> The generic interrupt core code has accumulated quite some inconsistencies
> over time and a common pattern in various API functions is:
> 
>     unsigned long flags;
>     struct irq_desc *desc = irq_get_desc_[bus]lock(irq, &flags, mode);
> 
>     if (!desc)
>        return -EINVAL;
>     ....
>     irq_put_desc_[bus]unlock(desc, flags);
> 
> That's awkward and requires gotos in failure paths.
> 
> This series provides conditional lock guards and converts the core code
> over to use those guards. Along with that it converts the other open coded
> lock/unlock pairs and fixes up coding and kernel doc formatting.  The
> conversions were partially done with Coccinelle where possible.

I see you've chosen for the scoped_guard() variant here, as opposed to
the scoped_cond_guard() one :-)

Anyway, cursory reading of the patches show no obvious weirdness.

>  include/linux/irq.h     |    2 
>  kernel/irq/autoprobe.c  |   26 -
>  kernel/irq/chip.c       |  640 ++++++++++----------------
>  kernel/irq/cpuhotplug.c |   10 
>  kernel/irq/debugfs.c    |    3 
>  kernel/irq/internals.h  |   47 -
>  kernel/irq/irqdesc.c    |  136 +----
>  kernel/irq/manage.c     | 1154 ++++++++++++++++++++----------------------------
>  kernel/irq/pm.c         |   38 -
>  kernel/irq/proc.c       |   65 --
>  kernel/irq/resend.c     |   50 --
>  kernel/irq/spurious.c   |  104 +---
>  12 files changed, 920 insertions(+), 1355 deletions(-)

Nice!