mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
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. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> [forward port to 3.18] Signed-off-by: Santosh 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: Olav Haugan <ohaugan@codeaurora.org> [rameezmustafa@codeaurora.org: Port to msm-4.9 and rebase to change patch dependency order.] Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org> [markivx: Port to 4.14, fix merge conflicts] Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org> Change-Id: I4795aeffd1be41830ac295a1e2e8f36fb05e98b7 [satyap@codeaurora.org: resolve trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
This commit is contained in:
parent
7cfe6ce3c1
commit
ec772d58b1
@ -209,6 +209,9 @@ extern int mod_timer_pending(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);
|
||||
|
@ -1816,14 +1816,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);
|
||||
}
|
||||
@ -1844,14 +1850,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]);
|
||||
@ -1859,18 +1864,25 @@ 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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user