@@ -3518,14 +3518,16 @@ 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 */
35203520static 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
3525- if (p -> nr_cpus_allowed > 1 && !is_migration_disabled (p ))
3526- cpu = p -> sched_class -> select_task_rq (p , cpu , wake_flags );
3527- else
3525+ if (p -> nr_cpus_allowed > 1 && !is_migration_disabled (p )) {
3526+ cpu = p -> sched_class -> select_task_rq (p , cpu , * wake_flags );
3527+ * wake_flags |= WF_RQ_SELECTED ;
3528+ } else {
35283529 cpu = cpumask_any (p -> cpus_ptr );
3530+ }
35293531
35303532 /*
35313533 * In order not to call set_task_cpu() on a blocking task we need
@@ -3659,6 +3661,8 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags,
36593661 rq -> nr_uninterruptible -- ;
36603662
36613663#ifdef CONFIG_SMP
3664+ if (wake_flags & WF_RQ_SELECTED )
3665+ en_flags |= ENQUEUE_RQ_SELECTED ;
36623666 if (wake_flags & WF_MIGRATED )
36633667 en_flags |= ENQUEUE_MIGRATED ;
36643668 else
@@ -4120,6 +4124,8 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
41204124 guard (preempt )();
41214125 int cpu , success = 0 ;
41224126
4127+ wake_flags |= WF_TTWU ;
4128+
41234129 if (p == current ) {
41244130 /*
41254131 * We're waking current, this means 'p->on_rq' and 'task_cpu(p)
@@ -4252,7 +4258,7 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
42524258 */
42534259 smp_cond_load_acquire (& p -> on_cpu , !VAL );
42544260
4255- cpu = select_task_rq (p , p -> wake_cpu , wake_flags | WF_TTWU );
4261+ cpu = select_task_rq (p , p -> wake_cpu , & wake_flags );
42564262 if (task_cpu (p ) != cpu ) {
42574263 if (p -> in_iowait ) {
42584264 delayacct_blkio_end (p );
@@ -4793,6 +4799,7 @@ void wake_up_new_task(struct task_struct *p)
47934799{
47944800 struct rq_flags rf ;
47954801 struct rq * rq ;
4802+ int wake_flags = WF_FORK ;
47964803
47974804 raw_spin_lock_irqsave (& p -> pi_lock , rf .flags );
47984805 WRITE_ONCE (p -> __state , TASK_RUNNING );
@@ -4807,15 +4814,15 @@ void wake_up_new_task(struct task_struct *p)
48074814 */
48084815 p -> recent_used_cpu = task_cpu (p );
48094816 rseq_migrate (p );
4810- __set_task_cpu (p , select_task_rq (p , task_cpu (p ), WF_FORK ));
4817+ __set_task_cpu (p , select_task_rq (p , task_cpu (p ), & wake_flags ));
48114818#endif
48124819 rq = __task_rq_lock (p , & rf );
48134820 update_rq_clock (rq );
48144821 post_init_entity_util_avg (p );
48154822
48164823 activate_task (rq , p , ENQUEUE_NOCLOCK | ENQUEUE_INITIAL );
48174824 trace_sched_wakeup_new (p );
4818- wakeup_preempt (rq , p , WF_FORK );
4825+ wakeup_preempt (rq , p , wake_flags );
48194826#ifdef CONFIG_SMP
48204827 if (p -> sched_class -> task_woken ) {
48214828 /*
0 commit comments