Re: [PATCH] hrtimer:Add get_hrtimer_cpu_base()

From: Enlin Mu
Date: Thu Mar 14 2024 - 22:21:06 EST


Enlin Mu <enlinmu@xxxxxxxxx> 于2024年3月15日周五 10:07写道:
>
> Thomas Gleixner <tglx@xxxxxxxxxxxxx> 于2024年3月14日周四 19:59写道:
> >
> > On Thu, Mar 14 2024 at 18:45, Enlin Mu wrote:
> > > Thomas Gleixner <tglx@xxxxxxxxxxxxx> 于2024年3月14日周四 18:22写道:
> > >>
> > >> On Wed, Mar 13 2024 at 05:30, Enlin Mu wrote:
> > >> > From: Enlin Mu <enlin.mu@xxxxxxxxxx>
> > >> >
> > >> > On the Arm platform,arch_timer may occur irq strom,
> > >> > By using the next_timer of hrtimer_cpu_base, it is
> > >> > possible to quickly locate abnormal timers.
> > >> > As it is an out of tree modules,the function needs
> > >> > to be exproted.
> > >>
> > >> No. We are not exporting for out of tree code.
> > > Can you explain it?
> >
> > Exporting functions or variables requires an in tree usecase.
> >
> Thands, I got it.
>
> If patch is following:
> ---
> include/linux/hrtimer.h | 1 +
> kernel/time/hrtimer.c | 1 +
> kernel/time/tick-internal.h | 1 -
> kernel/time/timer_list.c | 1 +
> 4 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
> index 2a37d2a8e808..a0eaed4a3edc 100644
> --- a/include/linux/hrtimer.h
> +++ b/include/linux/hrtimer.h
> @@ -278,6 +278,7 @@ static inline void hrtimer_start(struct hrtimer
> *timer, ktime_t tim,
> extern int hrtimer_cancel(struct hrtimer *timer);
> extern int hrtimer_try_to_cancel(struct hrtimer *timer);
> extern struct hrtimer_cpu_base *get_hrtimer_cpu_base(int cpu);
> +DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
>
> static inline void hrtimer_start_expires(struct hrtimer *timer,
> enum hrtimer_mode mode)
> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index f7cf7d48b91d..49024d07c61b 100644
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -113,6 +113,7 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
> },
> }
> };
> +EXPORT_PER_CPU_SYMBOL(hrtimer_bases);
>
> static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = {
> /* Make sure we catch unsupported clockids */
> diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
> index 5f2105e637bd..96df7d21506c 100644
> --- a/kernel/time/tick-internal.h
> +++ b/kernel/time/tick-internal.h
> @@ -18,7 +18,6 @@ struct timer_events {
> # define TICK_DO_TIMER_NONE -1
> # define TICK_DO_TIMER_BOOT -2
>
> -DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
> extern ktime_t tick_next_period;
> extern int tick_do_timer_cpu __read_mostly;
>
> diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
> index 1c311c46da50..b6fee42e3861 100644
> --- a/kernel/time/timer_list.c
> +++ b/kernel/time/timer_list.c
> @@ -16,6 +16,7 @@
> #include <linux/uaccess.h>
>
> #include "tick-internal.h"
> +#include <linux/hrtimer.h>
>
> struct timer_list_iter {
> int cpu;
> --
>
> please review and comment.
>
> Thanks

Hi Thomas

Sorry, I made a mistake
Please ignore this comment