Skip to content

Commit b62933e

Browse files
committed
sched/core: Make select_task_rq() take the pointer to wake_flags instead of value
This will be used to allow select_task_rq() to indicate whether ->select_task_rq() was called by modifying *wake_flags. This makes try_to_wake_up() call all functions that take wake_flags with WF_TTWU set. Previously, only select_task_rq() was. Using the same flags is more consistent, and, as the flag is only tested by ->select_task_rq() implementations, it doesn't cause any behavior differences. Signed-off-by: Tejun Heo <[email protected]> Acked-by: David Vernet <[email protected]>
1 parent ec01033 commit b62933e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

kernel/sched/core.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3518,12 +3518,12 @@ static int select_fallback_rq(int cpu, struct task_struct *p)
35183518
* The caller (fork, wakeup) owns p->pi_lock, ->cpus_ptr is stable.
35193519
*/
35203520
static inline
3521-
int select_task_rq(struct task_struct *p, int cpu, int wake_flags)
3521+
int select_task_rq(struct task_struct *p, int cpu, int *wake_flags)
35223522
{
35233523
lockdep_assert_held(&p->pi_lock);
35243524

35253525
if (p->nr_cpus_allowed > 1 && !is_migration_disabled(p))
3526-
cpu = p->sched_class->select_task_rq(p, cpu, wake_flags);
3526+
cpu = p->sched_class->select_task_rq(p, cpu, *wake_flags);
35273527
else
35283528
cpu = cpumask_any(p->cpus_ptr);
35293529

@@ -4120,6 +4120,8 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
41204120
guard(preempt)();
41214121
int cpu, success = 0;
41224122

4123+
wake_flags |= WF_TTWU;
4124+
41234125
if (p == current) {
41244126
/*
41254127
* We're waking current, this means 'p->on_rq' and 'task_cpu(p)
@@ -4252,7 +4254,7 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
42524254
*/
42534255
smp_cond_load_acquire(&p->on_cpu, !VAL);
42544256

4255-
cpu = select_task_rq(p, p->wake_cpu, wake_flags | WF_TTWU);
4257+
cpu = select_task_rq(p, p->wake_cpu, &wake_flags);
42564258
if (task_cpu(p) != cpu) {
42574259
if (p->in_iowait) {
42584260
delayacct_blkio_end(p);
@@ -4793,6 +4795,7 @@ void wake_up_new_task(struct task_struct *p)
47934795
{
47944796
struct rq_flags rf;
47954797
struct rq *rq;
4798+
int wake_flags = WF_FORK;
47964799

47974800
raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
47984801
WRITE_ONCE(p->__state, TASK_RUNNING);
@@ -4807,15 +4810,15 @@ void wake_up_new_task(struct task_struct *p)
48074810
*/
48084811
p->recent_used_cpu = task_cpu(p);
48094812
rseq_migrate(p);
4810-
__set_task_cpu(p, select_task_rq(p, task_cpu(p), WF_FORK));
4813+
__set_task_cpu(p, select_task_rq(p, task_cpu(p), &wake_flags));
48114814
#endif
48124815
rq = __task_rq_lock(p, &rf);
48134816
update_rq_clock(rq);
48144817
post_init_entity_util_avg(p);
48154818

48164819
activate_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_INITIAL);
48174820
trace_sched_wakeup_new(p);
4818-
wakeup_preempt(rq, p, WF_FORK);
4821+
wakeup_preempt(rq, p, wake_flags);
48194822
#ifdef CONFIG_SMP
48204823
if (p->sched_class->task_woken) {
48214824
/*

0 commit comments

Comments
 (0)