All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Xenomai <xenomai@lists.linux.dev>,
	 Florian Bezdeka <florian.bezdeka@siemens.com>
Subject: Re: [dovetail][PATCH] irq_pipeline: tick: keep IRQ_TICK set on shutdown
Date: Thu, 19 Nov 2026 14:04:37 +0100	[thread overview]
Message-ID: <87wlq9nfa2.fsf@xenomai.org> (raw)
In-Reply-To: <42645f8a-126f-42dc-bae5-c23230041fe8@siemens.com> (Jan Kiszka's message of "Tue, 17 Nov 2026 19:32:53 +0100")

Jan Kiszka <jan.kiszka@siemens.com> writes:

> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> IRQ_TICK is set on the interrupt of a pipelined clock event device by
> tick_setup_device(), but cleared again by every call to
> clockevents_shutdown(). Several paths shut down a tick device and
> restart it later without going through tick_setup_device():
>
> - tick_suspend_local() / tick_resume_local(), on suspend to RAM and
>   on suspend to idle (tick_freeze/tick_unfreeze).
> - tick_broadcast_control(TICK_BROADCAST_ON) while the broadcast
>   device runs in periodic mode, undone by tick_setup_periodic() on
>   TICK_BROADCAST_OFF.
>
> In addition, per-CPU clock event devices share a single interrupt
> descriptor, so shutting down the device on one CPU clears the mark
> for all CPUs, including those still receiving ticks over it.
>
> Once the mark is lost, the pipeline entry code stops saving the
> interrupted registers for the in-band tick, which then accounts the
> CPU time and reports RCU quiescent states based on stale registers.
>
> Restoring the mark from clockevents_tick_resume() would only cover
> the suspend paths. Make it sticky instead: once an interrupt has
> driven a tick device, keep it marked. If the device stops being used
> for ticks, the mark only causes the registers of a more recent
> interrupt to be recorded, which is harmless.
>
> As irq_switch_tick(irq, false) is no longer used, rename it to
> irq_mark_tick() and clean up related bits.
>
> Assisted-by: opencode:Opus-5.5
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> This is now one option to address the issue brought forward in
> https://lore.kernel.org/xenomai/9b439d13-7d33-419d-9d4a-2b224bf5db7d@siemens.com/T/#u.
>
>  include/linux/irq.h       |  4 ++--
>  kernel/irq/manage.c       | 11 +++--------
>  kernel/irq/settings.h     |  5 -----
>  kernel/time/clockevents.c |  3 ---
>  kernel/time/tick-common.c |  7 ++++++-
>  5 files changed, 11 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/irq.h b/include/linux/irq.h
> index b9e4f12271ed3..0862d64b7ee4f 100644
> --- a/include/linux/irq.h
> +++ b/include/linux/irq.h
> @@ -1260,7 +1260,7 @@ static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
>  
>  #ifdef CONFIG_IRQ_PIPELINE
>  int irq_switch_oob(unsigned int irq, bool on);
> -void irq_switch_tick(unsigned int irq, bool on);
> +void irq_mark_tick(unsigned int irq);
>  void irq_clear_deferral(struct irq_desc *desc);
>  void irq_clear_forward(struct irq_desc *desc);
>  #else
> @@ -1269,7 +1269,7 @@ static inline int irq_switch_oob(unsigned int irq, bool on)
>  	return 0;
>  }
>  
> -static inline void irq_switch_tick(unsigned int irq, bool on)
> +static inline void irq_mark_tick(unsigned int irq)
>  {
>  }
>  
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index bbd7c0208444f..943541b1c9fff 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -950,16 +950,11 @@ int irq_switch_oob(unsigned int irq, bool on)
>  }
>  EXPORT_SYMBOL_GPL(irq_switch_oob);
>  
> -void irq_switch_tick(unsigned int irq, bool on)
> +void irq_mark_tick(unsigned int irq)
>  {
> -	scoped_irqdesc_get_and_lock(irq, 0) {
> -		if (on)
> -			irq_settings_set_tick(scoped_irqdesc);
> -		else
> -			irq_settings_clr_tick(scoped_irqdesc);
> -	}
> +	scoped_irqdesc_get_and_lock(irq, 0)
> +		irq_settings_set_tick(scoped_irqdesc);
>  }
> -EXPORT_SYMBOL_GPL(irq_switch_tick);
>  
>  #endif /* CONFIG_IRQ_PIPELINE */
>  
> diff --git a/kernel/irq/settings.h b/kernel/irq/settings.h
> index 0a57c2080cacd..d1336b82c248f 100644
> --- a/kernel/irq/settings.h
> +++ b/kernel/irq/settings.h
> @@ -218,11 +218,6 @@ static inline bool irq_settings_is_tick(struct irq_desc *desc)
>  	return desc->status_use_accessors & _IRQ_TICK;
>  }
>  
> -static inline void irq_settings_clr_tick(struct irq_desc *desc)
> -{
> -	desc->status_use_accessors &= ~_IRQ_TICK;
> -}
> -
>  static inline void irq_settings_set_tick(struct irq_desc *desc)
>  {
>  	desc->status_use_accessors |= _IRQ_TICK;
> diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
> index 3cf30dead25d1..5138c17fd567d 100644
> --- a/kernel/time/clockevents.c
> +++ b/kernel/time/clockevents.c
> @@ -12,7 +12,6 @@
>  #include <linux/init.h>
>  #include <linux/module.h>
>  #include <linux/smp.h>
> -#include <linux/irq.h>
>  #include <linux/device.h>
>  
>  #include "tick-internal.h"
> @@ -178,8 +177,6 @@ void clockevents_shutdown(struct clock_event_device *dev)
>  	clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
>  	dev->next_event = KTIME_MAX;
>  	dev->next_event_forced = 0;
> -	if (dev->features & CLOCK_EVT_FEAT_PIPELINE)
> -		irq_switch_tick(dev->irq, false);
>  }
>  
>  /**
> diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
> index bfb26d9d687ab..56e3ec9c754b3 100644
> --- a/kernel/time/tick-common.c
> +++ b/kernel/time/tick-common.c
> @@ -245,8 +245,13 @@ static void tick_setup_device(struct tick_device *td,
>  	if (!cpumask_equal(newdev->cpumask, cpumask))
>  		irq_set_affinity(newdev->irq, cpumask);
>  
> +	/*
> +	 * This mark is never cleared: tick devices may be shut down and
> +	 * restarted without passing here again (suspend, periodic broadcast),
> +	 * and per-CPU devices share a single interrupt descriptor.
> +	 */
>  	if (newdev->features & CLOCK_EVT_FEAT_PIPELINE)
> -		irq_switch_tick(newdev->irq, true);
> +		irq_mark_tick(newdev->irq);
>  
>  	/*
>  	 * When global broadcasting is active, check if the current

Merged, thanks.

-- 
Philippe.

      reply	other threads:[~2026-11-19 13:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 18:32 [dovetail][PATCH] irq_pipeline: tick: keep IRQ_TICK set on shutdown Jan Kiszka
2026-11-19 13:04 ` Philippe Gerum [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=87wlq9nfa2.fsf@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=florian.bezdeka@siemens.com \
    --cc=jan.kiszka@siemens.com \
    --cc=xenomai@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.