Re: [PATCH] hrtimer:Add get_hrtimer_cpu_base()

From: Enlin Mu
Date: Thu Mar 14 2024 - 23:13:09 EST


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.
>

OK, Thanks, I got it.

If this pathc is following(exprot hrtimer_bases):
---
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..259462ad6e4a 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 hrtimer_cpu_base, hrtimer_bases);

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..f649d3509060 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -175,7 +175,6 @@ static inline void timers_update_nohz(void) { }
#define tick_nohz_active (0)
#endif

-DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);

extern u64 get_next_timer_interrupt(unsigned long basej, u64 basem);
u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle);
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 1c311c46da50..877b9130cd64 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -14,6 +14,7 @@
#include <linux/nmi.h>

#include <linux/uaccess.h>
+#include <linux/hrtimer.h>

#include "tick-internal.h"

--

Please review and comment.
Thanks.