Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 96040
b: refs/heads/master
c: b328ca1
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 5, 2008
1 parent f7fcfb5 commit bcaf97f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 104f64549c961a797ff5f7c59946a7caa335c5b0
refs/heads/master: b328ca182f01c2a04b85e0ee8a410720b104fbcc
66 changes: 65 additions & 1 deletion trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ static inline void resched_rq(struct rq *rq)
enum {
HRTICK_SET, /* re-programm hrtick_timer */
HRTICK_RESET, /* not a new slice */
HRTICK_BLOCK, /* stop hrtick operations */
};

/*
Expand All @@ -1202,6 +1203,8 @@ static inline int hrtick_enabled(struct rq *rq)
{
if (!sched_feat(HRTICK))
return 0;
if (unlikely(test_bit(HRTICK_BLOCK, &rq->hrtick_flags)))
return 0;
return hrtimer_is_hres_active(&rq->hrtick_timer);
}

Expand Down Expand Up @@ -1284,7 +1287,63 @@ static enum hrtimer_restart hrtick(struct hrtimer *timer)
return HRTIMER_NORESTART;
}

static inline void init_rq_hrtick(struct rq *rq)
static void hotplug_hrtick_disable(int cpu)
{
struct rq *rq = cpu_rq(cpu);
unsigned long flags;

spin_lock_irqsave(&rq->lock, flags);
rq->hrtick_flags = 0;
__set_bit(HRTICK_BLOCK, &rq->hrtick_flags);
spin_unlock_irqrestore(&rq->lock, flags);

hrtick_clear(rq);
}

static void hotplug_hrtick_enable(int cpu)
{
struct rq *rq = cpu_rq(cpu);
unsigned long flags;

spin_lock_irqsave(&rq->lock, flags);
__clear_bit(HRTICK_BLOCK, &rq->hrtick_flags);
spin_unlock_irqrestore(&rq->lock, flags);
}

static int
hotplug_hrtick(struct notifier_block *nfb, unsigned long action, void *hcpu)
{
int cpu = (int)(long)hcpu;

switch (action) {
case CPU_UP_CANCELED:
case CPU_UP_CANCELED_FROZEN:
case CPU_DOWN_PREPARE:
case CPU_DOWN_PREPARE_FROZEN:
case CPU_DEAD:
case CPU_DEAD_FROZEN:
hotplug_hrtick_disable(cpu);
return NOTIFY_OK;

case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
case CPU_DOWN_FAILED:
case CPU_DOWN_FAILED_FROZEN:
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
hotplug_hrtick_enable(cpu);
return NOTIFY_OK;
}

return NOTIFY_DONE;
}

static void init_hrtick(void)
{
hotcpu_notifier(hotplug_hrtick, 0);
}

static void init_rq_hrtick(struct rq *rq)
{
rq->hrtick_flags = 0;
hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
Expand Down Expand Up @@ -1321,6 +1380,10 @@ static inline void init_rq_hrtick(struct rq *rq)
void hrtick_resched(void)
{
}

static inline void init_hrtick(void)
{
}
#endif

/*
Expand Down Expand Up @@ -7943,6 +8006,7 @@ void __init sched_init_smp(void)
put_online_cpus();
/* XXX: Theoretical race here - CPU may be hotplugged now */
hotcpu_notifier(update_sched_domains, 0);
init_hrtick();

/* Move init over to a non-isolated CPU */
if (set_cpus_allowed_ptr(current, &non_isolated_cpus) < 0)
Expand Down

0 comments on commit bcaf97f

Please sign in to comment.