diff options
-rw-r--r-- | kernel/sched.c | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 3919aa419356..4481638f9178 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -2406,20 +2406,43 @@ static void update_avg(u64 *avg, u64 sample) | |||
2406 | } | 2406 | } |
2407 | #endif | 2407 | #endif |
2408 | 2408 | ||
2409 | static inline void ttwu_activate(struct task_struct *p, struct rq *rq, | 2409 | static void |
2410 | bool is_sync, bool is_migrate, bool is_local, | 2410 | ttwu_stat(struct rq *rq, struct task_struct *p, int cpu, int wake_flags) |
2411 | unsigned long en_flags) | ||
2412 | { | 2411 | { |
2412 | #ifdef CONFIG_SCHEDSTATS | ||
2413 | #ifdef CONFIG_SMP | ||
2414 | int this_cpu = smp_processor_id(); | ||
2415 | |||
2416 | if (cpu == this_cpu) { | ||
2417 | schedstat_inc(rq, ttwu_local); | ||
2418 | schedstat_inc(p, se.statistics.nr_wakeups_local); | ||
2419 | } else { | ||
2420 | struct sched_domain *sd; | ||
2421 | |||
2422 | schedstat_inc(p, se.statistics.nr_wakeups_remote); | ||
2423 | for_each_domain(this_cpu, sd) { | ||
2424 | if (cpumask_test_cpu(cpu, sched_domain_span(sd))) { | ||
2425 | schedstat_inc(sd, ttwu_wake_remote); | ||
2426 | break; | ||
2427 | } | ||
2428 | } | ||
2429 | } | ||
2430 | #endif /* CONFIG_SMP */ | ||
2431 | |||
2432 | schedstat_inc(rq, ttwu_count); | ||
2413 | schedstat_inc(p, se.statistics.nr_wakeups); | 2433 | schedstat_inc(p, se.statistics.nr_wakeups); |
2414 | if (is_sync) | 2434 | |
2435 | if (wake_flags & WF_SYNC) | ||
2415 | schedstat_inc(p, se.statistics.nr_wakeups_sync); | 2436 | schedstat_inc(p, se.statistics.nr_wakeups_sync); |
2416 | if (is_migrate) | 2437 | |
2438 | if (cpu != task_cpu(p)) | ||
2417 | schedstat_inc(p, se.statistics.nr_wakeups_migrate); | 2439 | schedstat_inc(p, se.statistics.nr_wakeups_migrate); |
2418 | if (is_local) | ||
2419 | schedstat_inc(p, se.statistics.nr_wakeups_local); | ||
2420 | else | ||
2421 | schedstat_inc(p, se.statistics.nr_wakeups_remote); | ||
2422 | 2440 | ||
2441 | #endif /* CONFIG_SCHEDSTATS */ | ||
2442 | } | ||
2443 | |||
2444 | static void ttwu_activate(struct rq *rq, struct task_struct *p, int en_flags) | ||
2445 | { | ||
2423 | activate_task(rq, p, en_flags); | 2446 | activate_task(rq, p, en_flags); |
2424 | 2447 | ||
2425 | /* if a worker is waking up, notify workqueue */ | 2448 | /* if a worker is waking up, notify workqueue */ |
@@ -2481,12 +2504,12 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2481 | if (!(p->state & state)) | 2504 | if (!(p->state & state)) |
2482 | goto out; | 2505 | goto out; |
2483 | 2506 | ||
2507 | cpu = task_cpu(p); | ||
2508 | |||
2484 | if (p->se.on_rq) | 2509 | if (p->se.on_rq) |
2485 | goto out_running; | 2510 | goto out_running; |
2486 | 2511 | ||
2487 | cpu = task_cpu(p); | ||
2488 | orig_cpu = cpu; | 2512 | orig_cpu = cpu; |
2489 | |||
2490 | #ifdef CONFIG_SMP | 2513 | #ifdef CONFIG_SMP |
2491 | if (unlikely(task_running(rq, p))) | 2514 | if (unlikely(task_running(rq, p))) |
2492 | goto out_activate; | 2515 | goto out_activate; |
@@ -2527,27 +2550,12 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2527 | WARN_ON(task_cpu(p) != cpu); | 2550 | WARN_ON(task_cpu(p) != cpu); |
2528 | WARN_ON(p->state != TASK_WAKING); | 2551 | WARN_ON(p->state != TASK_WAKING); |
2529 | 2552 | ||
2530 | #ifdef CONFIG_SCHEDSTATS | ||
2531 | schedstat_inc(rq, ttwu_count); | ||
2532 | if (cpu == this_cpu) | ||
2533 | schedstat_inc(rq, ttwu_local); | ||
2534 | else { | ||
2535 | struct sched_domain *sd; | ||
2536 | for_each_domain(this_cpu, sd) { | ||
2537 | if (cpumask_test_cpu(cpu, sched_domain_span(sd))) { | ||
2538 | schedstat_inc(sd, ttwu_wake_remote); | ||
2539 | break; | ||
2540 | } | ||
2541 | } | ||
2542 | } | ||
2543 | #endif /* CONFIG_SCHEDSTATS */ | ||
2544 | |||
2545 | out_activate: | 2553 | out_activate: |
2546 | #endif /* CONFIG_SMP */ | 2554 | #endif /* CONFIG_SMP */ |
2547 | ttwu_activate(p, rq, wake_flags & WF_SYNC, orig_cpu != cpu, | 2555 | ttwu_activate(rq, p, en_flags); |
2548 | cpu == this_cpu, en_flags); | ||
2549 | out_running: | 2556 | out_running: |
2550 | ttwu_post_activation(p, rq, wake_flags); | 2557 | ttwu_post_activation(p, rq, wake_flags); |
2558 | ttwu_stat(rq, p, cpu, wake_flags); | ||
2551 | success = 1; | 2559 | success = 1; |
2552 | out: | 2560 | out: |
2553 | task_rq_unlock(rq, &flags); | 2561 | task_rq_unlock(rq, &flags); |
@@ -2575,14 +2583,11 @@ static void try_to_wake_up_local(struct task_struct *p) | |||
2575 | if (!(p->state & TASK_NORMAL)) | 2583 | if (!(p->state & TASK_NORMAL)) |
2576 | return; | 2584 | return; |
2577 | 2585 | ||
2578 | if (!p->se.on_rq) { | 2586 | if (!p->se.on_rq) |
2579 | if (likely(!task_running(rq, p))) { | 2587 | ttwu_activate(rq, p, ENQUEUE_WAKEUP); |
2580 | schedstat_inc(rq, ttwu_count); | 2588 | |
2581 | schedstat_inc(rq, ttwu_local); | ||
2582 | } | ||
2583 | ttwu_activate(p, rq, false, false, true, ENQUEUE_WAKEUP); | ||
2584 | } | ||
2585 | ttwu_post_activation(p, rq, 0); | 2589 | ttwu_post_activation(p, rq, 0); |
2590 | ttwu_stat(rq, p, smp_processor_id(), 0); | ||
2586 | } | 2591 | } |
2587 | 2592 | ||
2588 | /** | 2593 | /** |