[PATCH 33/35] tick: Make hrtimer broadcasting opt-in

From: Peter Zijlstra
Date: Mon Feb 16 2015 - 08:11:23 EST


From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

We keep adding unconditional stuff to the core code which just bloats
the text and data size for no value. hrtimer based broadcasting is
currently only used on arm64 and powerpc. Make it conditional.

While at it move these tick related interfaces out of the clockchips
header file.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Preeti U Murthy <preeti@xxxxxxxxxxxxxxxxxx>
Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx>
---
arch/arm/kernel/smp.c | 2 +-
arch/arm64/Kconfig | 1 +
arch/arm64/kernel/smp.c | 1 +
arch/arm64/kernel/time.c | 2 +-
arch/mips/kernel/smp.c | 1 +
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/smp.c | 1 +
arch/powerpc/kernel/time.c | 2 +-
include/linux/clockchips.h | 26 +-------------------------
include/linux/tick.h | 25 +++++++++++++++++++++++--
kernel/time/Kconfig | 4 ++++
kernel/time/Makefile | 6 ++----
kernel/time/tick-broadcast.c | 4 +++-
13 files changed, 41 insertions(+), 35 deletions(-)

Index: linux/arch/arm/kernel/smp.c
===================================================================
--- linux.orig/arch/arm/kernel/smp.c
+++ linux/arch/arm/kernel/smp.c
@@ -22,7 +22,7 @@
#include <linux/seq_file.h>
#include <linux/irq.h>
#include <linux/percpu.h>
-#include <linux/clockchips.h>
+#include <linux/tick.h>
#include <linux/completion.h>
#include <linux/cpufreq.h>
#include <linux/irq_work.h>
Index: linux/arch/arm64/Kconfig
===================================================================
--- linux.orig/arch/arm64/Kconfig
+++ linux/arch/arm64/Kconfig
@@ -25,6 +25,7 @@ config ARM64
select GENERIC_ALLOCATOR
select GENERIC_CLOCKEVENTS
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+ select GENERIC_CLOCKEVENTS_HRTIMER_BROADCAST if SMP
select GENERIC_CPU_AUTOPROBE
select GENERIC_EARLY_IOREMAP
select GENERIC_IRQ_PROBE
Index: linux/arch/arm64/kernel/smp.c
===================================================================
--- linux.orig/arch/arm64/kernel/smp.c
+++ linux/arch/arm64/kernel/smp.c
@@ -36,6 +36,7 @@
#include <linux/completion.h>
#include <linux/of.h>
#include <linux/irq_work.h>
+#include <linux/tick.h>

#include <asm/alternative.h>
#include <asm/atomic.h>
Index: linux/arch/arm64/kernel/time.c
===================================================================
--- linux.orig/arch/arm64/kernel/time.c
+++ linux/arch/arm64/kernel/time.c
@@ -18,11 +18,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

-#include <linux/clockchips.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/time.h>
+#include <linux/tick.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/smp.h>
Index: linux/arch/mips/kernel/smp.c
===================================================================
--- linux.orig/arch/mips/kernel/smp.c
+++ linux/arch/mips/kernel/smp.c
@@ -33,6 +33,7 @@
#include <linux/cpu.h>
#include <linux/err.h>
#include <linux/ftrace.h>
+#include <linux/tick.h>

#include <linux/atomic.h>
#include <asm/cpu.h>
Index: linux/arch/powerpc/Kconfig
===================================================================
--- linux.orig/arch/powerpc/Kconfig
+++ linux/arch/powerpc/Kconfig
@@ -135,6 +135,7 @@ config PPC
select GENERIC_TIME_VSYSCALL_OLD
select GENERIC_CLOCKEVENTS
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+ select GENERIC_CLOCKEVENTS_HRTIMER_BROADCAST if SMP
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
Index: linux/arch/powerpc/kernel/smp.c
===================================================================
--- linux.orig/arch/powerpc/kernel/smp.c
+++ linux/arch/powerpc/kernel/smp.c
@@ -31,6 +31,7 @@
#include <linux/cpu.h>
#include <linux/notifier.h>
#include <linux/topology.h>
+#include <linux/tick.h>

#include <asm/ptrace.h>
#include <linux/atomic.h>
Index: linux/arch/powerpc/kernel/time.c
===================================================================
--- linux.orig/arch/powerpc/kernel/time.c
+++ linux/arch/powerpc/kernel/time.c
@@ -42,7 +42,7 @@
#include <linux/timex.h>
#include <linux/kernel_stat.h>
#include <linux/time.h>
-#include <linux/clockchips.h>
+#include <linux/tick.h>
#include <linux/init.h>
#include <linux/profile.h>
#include <linux/cpu.h>
Index: linux/include/linux/clockchips.h
===================================================================
--- linux.orig/include/linux/clockchips.h
+++ linux/include/linux/clockchips.h
@@ -155,29 +155,5 @@ extern void clockevents_set_mode(struct
enum clock_event_mode mode);
extern int clockevents_program_event(struct clock_event_device *dev,
ktime_t expires, bool force);
-
-#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
-#ifdef CONFIG_ARCH_HAS_TICK_BROADCAST
-extern void tick_broadcast(const struct cpumask *mask);
-#else
-#define tick_broadcast NULL
-#endif
-extern int tick_receive_broadcast(void);
-#endif
-
-#if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && defined(CONFIG_TICK_ONESHOT)
-extern void tick_setup_hrtimer_broadcast(void);
-extern int tick_check_broadcast_expired(void);
-#else
-static inline int tick_check_broadcast_expired(void) { return 0; }
-static inline void tick_setup_hrtimer_broadcast(void) {};
-#endif
-
-#else /* CONFIG_GENERIC_CLOCKEVENTS */
-
-static inline int tick_check_broadcast_expired(void) { return 0; }
-static inline void tick_setup_hrtimer_broadcast(void) {};
-
-#endif
-
+#endif /* CONFIG_GENERIC_CLOCKEVENTS */
#endif
Index: linux/include/linux/tick.h
===================================================================
--- linux.orig/include/linux/tick.h
+++ linux/include/linux/tick.h
@@ -65,10 +65,8 @@ static inline void tick_broadcast_contro

#if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && defined(CONFIG_TICK_ONESHOT)
extern int tick_broadcast_oneshot_control(enum tick_broadcast_state state);
-extern void tick_takeover(int deadcpu);
#else
static inline int tick_broadcast_oneshot_control(enum tick_broadcast_state state) { return 0; }
-static inline void tick_takeover(int deadcpu) { }
#endif

static inline void tick_broadcast_enable(void)
@@ -181,4 +179,27 @@ static inline void tick_nohz_task_switch
__tick_nohz_task_switch(tsk);
}

+#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
+#ifdef CONFIG_ARCH_HAS_TICK_BROADCAST
+extern void tick_broadcast(const struct cpumask *mask);
+#else
+#define tick_broadcast NULL
+#endif
+extern int tick_receive_broadcast(void);
+#endif
+
+#if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && defined(CONFIG_TICK_ONESHOT)
+extern int tick_check_broadcast_expired(void);
+#else
+static inline int tick_check_broadcast_expired(void) { return 0; }
+#endif
+
+#ifdef CONFIG_GENERIC_CLOCKEVENTS_HRTIMER_BROADCAST
+extern void tick_setup_hrtimer_broadcast(void);
+extern void tick_takeover(int deadcpu);
+#else
+static inline void tick_setup_hrtimer_broadcast(void) { };
+static inline void tick_takeover(int deadcpu) { }
+#endif
+
#endif
Index: linux/kernel/time/Kconfig
===================================================================
--- linux.orig/kernel/time/Kconfig
+++ linux/kernel/time/Kconfig
@@ -42,6 +42,10 @@ config GENERIC_CLOCKEVENTS_BROADCAST
bool
depends on GENERIC_CLOCKEVENTS

+config GENERIC_CLOCKEVENTS_HRTIMER_BROADCAST
+ bool
+ depends on GENERIC_CLOCKEVENTS && TICK_ONESHOT
+
# Automatically adjust the min. reprogramming time for
# clock event device
config GENERIC_CLOCKEVENTS_MIN_ADJUST
Index: linux/kernel/time/Makefile
===================================================================
--- linux.orig/kernel/time/Makefile
+++ linux/kernel/time/Makefile
@@ -3,10 +3,8 @@ obj-y += timekeeping.o ntp.o clocksource
obj-y += timeconv.o posix-clock.o alarmtimer.o

obj-$(CONFIG_GENERIC_CLOCKEVENTS) += clockevents.o tick-common.o
-ifeq ($(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST),y)
- obj-y += tick-broadcast.o
- obj-$(CONFIG_TICK_ONESHOT) += tick-broadcast-hrtimer.o
-endif
+obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += tick-broadcast.o
+obj-$(CONFIG_GENERIC_CLOCKEVENTS_HRTIMER_BROADCAST) += tick-broadcast-hrtimer.o
obj-$(CONFIG_GENERIC_SCHED_CLOCK) += sched_clock.o
obj-$(CONFIG_TICK_ONESHOT) += tick-oneshot.o tick-sched.o
obj-$(CONFIG_TIMER_STATS) += timer_stats.o
Index: linux/kernel/time/tick-broadcast.c
===================================================================
--- linux.orig/kernel/time/tick-broadcast.c
+++ linux/kernel/time/tick-broadcast.c
@@ -908,6 +908,7 @@ void tick_broadcast_switch_to_oneshot(vo
}

#ifdef CONFIG_HOTPLUG_CPU
+#ifdef CONFIG_GENERIC_CLOCKEVENTS_HRTIMER_BROADCAST
/*
* Called from the cpu hotplug code after a cpu is dead. This ensures
* that a hrtimer based broad cast device is taken over.
@@ -916,7 +917,7 @@ void tick_broadcast_switch_to_oneshot(vo
* which pushes the hrtimer over to a different cpu from
* tick_shutdown_broadcast_oneshot()
*/
-void tick_broadcast_takeover_bc(int deadcpu)
+void tick_takeover(int deadcpu)
{
struct clock_event_device *bc;
unsigned long flags;
@@ -929,6 +930,7 @@ void tick_broadcast_takeover_bc(int dead
}
raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
}
+#endif

/*
* Remove a dead CPU from broadcasting, called with broadcast lock


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/