[PATCH 0/5] Make it easier to use nested locking for interrupt descriptors

Bart Van Assche posted 5 patches 1 year ago
arch/powerpc/sysdev/fsl_msi.c             |  5 ---
drivers/base/regmap/regmap-irq.c          |  4 ---
drivers/gpio/gpio-bcm-kona.c              |  8 -----
drivers/gpio/gpio-brcmstb.c               | 10 ------
drivers/gpio/gpio-mxc.c                   |  3 +-
drivers/gpio/gpio-mxs.c                   |  3 +-
drivers/gpio/gpiolib-devres.c             | 12 +++----
drivers/gpio/gpiolib.c                    | 30 ++++-------------
drivers/gpu/drm/msm/msm_mdss.c            |  3 --
drivers/irqchip/irq-imgpdc.c              |  3 +-
drivers/irqchip/irq-renesas-intc-irqpin.c | 11 ------
drivers/irqchip/irq-renesas-irqc.c        |  2 +-
drivers/mfd/arizona-irq.c                 |  5 ---
drivers/net/dsa/mv88e6xxx/chip.c          |  8 -----
drivers/pinctrl/pinctrl-at91-pio4.c       |  8 -----
drivers/pinctrl/pinctrl-single.c          | 11 ------
drivers/pinctrl/sunxi/pinctrl-sunxi.c     |  9 -----
drivers/spmi/spmi-pmic-arb.c              |  5 ---
drivers/thermal/qcom/lmh.c                |  7 ----
include/linux/gpio/driver.h               | 41 ++---------------------
include/linux/irq.h                       |  4 ---
include/linux/irqdesc.h                   | 14 +++-----
include/linux/lockdep.h                   |  5 +++
kernel/irq/generic-chip.c                 | 15 ---------
kernel/irq/irqdesc.c                      | 30 +++++------------
kernel/locking/lockdep.c                  | 22 ++++++++++--
26 files changed, 54 insertions(+), 224 deletions(-)
[PATCH 0/5] Make it easier to use nested locking for interrupt descriptors
Posted by Bart Van Assche 1 year ago
Hi Thomas,

The number of irq_set_lockdep_class() calls and IRQ_GC_INIT_NESTED_LOCK
occurrences in the kernel tree shows that nested locking is common for
interrupt descriptors. This patch series makes it easier to use nested
locking by removing the function irq_set_lockdep_class() and also the
IRQ_GC_INIT_NESTED_LOCK flag.

As one can tell from the diffstat, this patch series removes more code
than it adds.

Please consider this patch series for the next merge window.

Thanks,

Bart.

Bart Van Assche (5):
  lockdep: Introduce lockdep_unregister_key_nosync()
  irqdesc: Use dynamic lockdep keys for interrupt descriptors
  irq: Remove irq_set_lockdep_class() and __irq_set_lockdep_class()
  irq: Remove the IRQ_GC_INIT_NESTED_LOCK flag
  irq: Simplify gpiochip_add_data()

 arch/powerpc/sysdev/fsl_msi.c             |  5 ---
 drivers/base/regmap/regmap-irq.c          |  4 ---
 drivers/gpio/gpio-bcm-kona.c              |  8 -----
 drivers/gpio/gpio-brcmstb.c               | 10 ------
 drivers/gpio/gpio-mxc.c                   |  3 +-
 drivers/gpio/gpio-mxs.c                   |  3 +-
 drivers/gpio/gpiolib-devres.c             | 12 +++----
 drivers/gpio/gpiolib.c                    | 30 ++++-------------
 drivers/gpu/drm/msm/msm_mdss.c            |  3 --
 drivers/irqchip/irq-imgpdc.c              |  3 +-
 drivers/irqchip/irq-renesas-intc-irqpin.c | 11 ------
 drivers/irqchip/irq-renesas-irqc.c        |  2 +-
 drivers/mfd/arizona-irq.c                 |  5 ---
 drivers/net/dsa/mv88e6xxx/chip.c          |  8 -----
 drivers/pinctrl/pinctrl-at91-pio4.c       |  8 -----
 drivers/pinctrl/pinctrl-single.c          | 11 ------
 drivers/pinctrl/sunxi/pinctrl-sunxi.c     |  9 -----
 drivers/spmi/spmi-pmic-arb.c              |  5 ---
 drivers/thermal/qcom/lmh.c                |  7 ----
 include/linux/gpio/driver.h               | 41 ++---------------------
 include/linux/irq.h                       |  4 ---
 include/linux/irqdesc.h                   | 14 +++-----
 include/linux/lockdep.h                   |  5 +++
 kernel/irq/generic-chip.c                 | 15 ---------
 kernel/irq/irqdesc.c                      | 30 +++++------------
 kernel/locking/lockdep.c                  | 22 ++++++++++--
 26 files changed, 54 insertions(+), 224 deletions(-)
Re: [PATCH 0/5] Make it easier to use nested locking for interrupt descriptors
Posted by Thomas Gleixner 1 year ago
Bart!

On Mon, Feb 03 2025 at 09:59, Bart Van Assche wrote:
> The number of irq_set_lockdep_class() calls and IRQ_GC_INIT_NESTED_LOCK
> occurrences in the kernel tree shows that nested locking is common for
> interrupt descriptors.

I can see why you think it's cumbersome to nest interrupts, but calling
it common is pretty exaggerated. If my mental arithmetic is not
completely off, then this affects less than 5% of the interrupt
chip/handler implementations.

The restriction is there on purpose because nesting interrupts is the
exception and not the common case. If there is no real reason, i.e. a
hardware constraint, then interrupt nesting is a bug by definition.

> This patch series makes it easier to use nested
> locking by removing the function irq_set_lockdep_class() and also the
> IRQ_GC_INIT_NESTED_LOCK flag.
>
> As one can tell from the diffstat, this patch series removes more code
> than it adds.

Sure, but with that it removes a debug mechanism for the common case,
which is not nested. Line count is not a measure for quality, neither in
one nor in the other direction.

So if you want to go there, then you have to come up with a proper
explanation why removing the 'yell, if not annotated nesting'
functionality is not a problem and the 'simplificaiton' is actually
worth it.

Thanks,

        tglx