Re: [tip: locking/core] lockdep: Add hrtimer context tracing bits
From: Frederic Weisbecker
Date: Sat Mar 21 2020 - 12:46:47 EST
On Sat, Mar 21, 2020 at 03:53:45PM -0000, tip-bot2 for Sebastian Andrzej Siewior wrote:
> The following commit has been merged into the locking/core branch of tip:
>
> Commit-ID: 40db173965c05a1d803451240ed41707d5bd978d
> Gitweb: https://git.kernel.org/tip/40db173965c05a1d803451240ed41707d5bd978d
> Author: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> AuthorDate: Sat, 21 Mar 2020 12:26:02 +01:00
> Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> CommitterDate: Sat, 21 Mar 2020 16:00:24 +01:00
>
> lockdep: Add hrtimer context tracing bits
>
> Set current->irq_config = 1 for hrtimers which are not marked to expire in
> hard interrupt context during hrtimer_init(). These timers will expire in
> softirq context on PREEMPT_RT.
>
> Setting this allows lockdep to differentiate these timers. If a timer is
> marked to expire in hard interrupt context then the timer callback is not
> supposed to acquire a regular spinlock instead of a raw_spinlock in the
> expiry callback.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> Link: https://lkml.kernel.org/r/20200321113242.534508206@xxxxxxxxxxxxx
> ---
> include/linux/irqflags.h | 15 +++++++++++++++
> include/linux/sched.h | 1 +
> kernel/locking/lockdep.c | 2 +-
> kernel/time/hrtimer.c | 6 +++++-
> 4 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
> index fdaf286..9c17f9c 100644
> --- a/include/linux/irqflags.h
> +++ b/include/linux/irqflags.h
> @@ -56,6 +56,19 @@ do { \
> do { \
> current->softirq_context--; \
> } while (0)
> +
> +# define lockdep_hrtimer_enter(__hrtimer) \
> + do { \
> + if (!__hrtimer->is_hard) \
> + current->irq_config = 1; \
> + } while (0)
> +
> +# define lockdep_hrtimer_exit(__hrtimer) \
> + do { \
> + if (!__hrtimer->is_hard) \
> + current->irq_config = 0; \
> + } while (0)
> +
> #else
> # define trace_hardirqs_on() do { } while (0)
> # define trace_hardirqs_off() do { } while (0)
> @@ -68,6 +81,8 @@ do { \
> # define trace_hardirq_exit() do { } while (0)
> # define lockdep_softirq_enter() do { } while (0)
> # define lockdep_softirq_exit() do { } while (0)
> +# define lockdep_hrtimer_enter(__hrtimer) do { } while (0)
> +# define lockdep_hrtimer_exit(__hrtimer) do { } while (0)
> #endif
>
> #if defined(CONFIG_IRQSOFF_TRACER) || \
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 4d3b9ec..933914c 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -983,6 +983,7 @@ struct task_struct {
> unsigned int softirq_enable_event;
> int softirqs_enabled;
> int softirq_context;
> + int irq_config;
There really need to be some explanation/comment/symbols to clarify
what this field is about and the meaning of the values it can take.
Thanks.