Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23a5e1f9 authored by Viresh Kumar's avatar Viresh Kumar Committed by Satya Durga Srinivasu Prabhala
Browse files

timer: create timer_quiesce_cpu() to isolate CPU from timers



To isolate CPUs (isolate from timers) from sysfs using cpusets, we need some
support from the timer core. i.e. A routine timer_quiesce_cpu() which would
migrates away all the unpinned timers, but shouldn't touch the pinned ones.

This patch creates this routine.

Change-Id: I4795aeffd1be41830ac295a1e2e8f36fb05e98b7
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
[forward port to 3.18]
Signed-off-by: default avatarSantosh Shukla <santosh.shukla@linaro.org>
[ohaugan@codeaurora.org: Port to 4.4. Fixes for compilation error]
Git-commit: 313910b70ea0c73f8789d9189c11e1f339080646
Git-repo: git://git.linaro.org/people/mike.holmes/santosh.shukla/lng-isol.git


Signed-off-by: default avatarOlav Haugan <ohaugan@codeaurora.org>
[rameezmustafa@codeaurora.org: Port to msm-4.9 and rebase to change
					patch dependency order.]
Signed-off-by: default avatarSyed Rameez Mustafa <rameezmustafa@codeaurora.org>
[markivx: Port to 4.14, fix merge conflicts]
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>
[satyap@codeaurora.org: Port to 4.19 and resolve trivial merge conflicts]
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent 52e7ec28
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -168,6 +168,9 @@ extern int timer_reduce(struct timer_list *timer, unsigned long expires);
 */
#define NEXT_TIMER_MAX_DELTA	((1UL << 30) - 1)

/* To be used from cpusets, only */
extern void timer_quiesce_cpu(void *cpup);

extern void add_timer(struct timer_list *timer);

extern int try_to_del_timer_sync(struct timer_list *timer);
+22 −10
Original line number Diff line number Diff line
@@ -1869,14 +1869,20 @@ signed long __sched schedule_timeout_idle(signed long timeout)
EXPORT_SYMBOL(schedule_timeout_idle);

#ifdef CONFIG_HOTPLUG_CPU
static void migrate_timer_list(struct timer_base *new_base, struct hlist_head *head)
static void migrate_timer_list(struct timer_base *new_base,
			       struct hlist_head *head, bool remove_pinned)
{
	struct timer_list *timer;
	int cpu = new_base->cpu;
	struct hlist_node *n;
	int is_pinned;

	while (!hlist_empty(head)) {
		timer = hlist_entry(head->first, struct timer_list, entry);
		detach_timer(timer, false);
	hlist_for_each_entry_safe(timer, n, head, entry) {
		is_pinned = timer->flags & TIMER_PINNED;
		if (!remove_pinned && is_pinned)
			continue;

		detach_if_pending(timer, get_timer_base(timer->flags), false);
		timer->flags = (timer->flags & ~TIMER_BASEMASK) | cpu;
		internal_add_timer(new_base, timer);
	}
@@ -1897,14 +1903,13 @@ int timers_prepare_cpu(unsigned int cpu)
	return 0;
}

int timers_dead_cpu(unsigned int cpu)
static void __migrate_timers(unsigned int cpu, bool remove_pinned)
{
	struct timer_base *old_base;
	struct timer_base *new_base;
	unsigned long flags;
	int b, i;

	BUG_ON(cpu_online(cpu));

	for (b = 0; b < NR_BASES; b++) {
		old_base = per_cpu_ptr(&timer_bases[b], cpu);
		new_base = get_cpu_ptr(&timer_bases[b]);
@@ -1912,7 +1917,7 @@ int timers_dead_cpu(unsigned int cpu)
		 * The caller is globally serialized and nobody else
		 * takes two locks at once, deadlock is not possible.
		 */
		raw_spin_lock_irq(&new_base->lock);
		raw_spin_lock_irqsave(&new_base->lock, flags);
		raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);

		/*
@@ -1924,12 +1929,19 @@ int timers_dead_cpu(unsigned int cpu)
		BUG_ON(old_base->running_timer);

		for (i = 0; i < WHEEL_SIZE; i++)
			migrate_timer_list(new_base, old_base->vectors + i);
			migrate_timer_list(new_base, old_base->vectors + i,
					   remove_pinned);

		raw_spin_unlock(&old_base->lock);
		raw_spin_unlock_irq(&new_base->lock);
		raw_spin_unlock_irqrestore(&new_base->lock, flags);
		put_cpu_ptr(&timer_bases);
	}
}

int timers_dead_cpu(unsigned int cpu)
{
	BUG_ON(cpu_online(cpu));
	__migrate_timers(cpu, true);
	return 0;
}