Revert "sched/psi: Use task->psi_flags to clear in CPU migration"

This reverts commit 371e1a0e38 which is
commit 52b33d87b9 upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: Ic3741eb342637ace98373f24857a4d302cf7cfc7
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2025-03-06 06:07:48 +00:00
parent 0b3a7df78d
commit 3df8fd8f21
3 changed files with 22 additions and 5 deletions

View File

@@ -900,6 +900,9 @@ struct task_struct {
unsigned sched_reset_on_fork:1; unsigned sched_reset_on_fork:1;
unsigned sched_contributes_to_load:1; unsigned sched_contributes_to_load:1;
unsigned sched_migrated:1; unsigned sched_migrated:1;
#ifdef CONFIG_PSI
unsigned sched_psi_wake_requeue:1;
#endif
/* Force alignment to the next boundary: */ /* Force alignment to the next boundary: */
unsigned :0; unsigned :0;

View File

@@ -2110,7 +2110,7 @@ static inline void enqueue_task(struct rq *rq, struct task_struct *p, int flags)
if (!(flags & ENQUEUE_RESTORE)) { if (!(flags & ENQUEUE_RESTORE)) {
sched_info_enqueue(rq, p); sched_info_enqueue(rq, p);
psi_enqueue(p, (flags & ENQUEUE_WAKEUP) && !(flags & ENQUEUE_MIGRATED)); psi_enqueue(p, flags & ENQUEUE_WAKEUP);
} }
uclamp_rq_inc(rq, p); uclamp_rq_inc(rq, p);

View File

@@ -132,9 +132,11 @@ static inline void psi_enqueue(struct task_struct *p, bool wakeup)
if (p->in_memstall) if (p->in_memstall)
set |= TSK_MEMSTALL_RUNNING; set |= TSK_MEMSTALL_RUNNING;
if (!wakeup) { if (!wakeup || p->sched_psi_wake_requeue) {
if (p->in_memstall) if (p->in_memstall)
set |= TSK_MEMSTALL; set |= TSK_MEMSTALL;
if (p->sched_psi_wake_requeue)
p->sched_psi_wake_requeue = 0;
} else { } else {
if (p->in_iowait) if (p->in_iowait)
clear |= TSK_IOWAIT; clear |= TSK_IOWAIT;
@@ -145,6 +147,8 @@ static inline void psi_enqueue(struct task_struct *p, bool wakeup)
static inline void psi_dequeue(struct task_struct *p, bool sleep) static inline void psi_dequeue(struct task_struct *p, bool sleep)
{ {
int clear = TSK_RUNNING;
if (static_branch_likely(&psi_disabled)) if (static_branch_likely(&psi_disabled))
return; return;
@@ -157,7 +161,10 @@ static inline void psi_dequeue(struct task_struct *p, bool sleep)
if (sleep) if (sleep)
return; return;
psi_task_change(p, p->psi_flags, 0); if (p->in_memstall)
clear |= (TSK_MEMSTALL | TSK_MEMSTALL_RUNNING);
psi_task_change(p, clear, 0);
} }
static inline void psi_ttwu_dequeue(struct task_struct *p) static inline void psi_ttwu_dequeue(struct task_struct *p)
@@ -169,12 +176,19 @@ static inline void psi_ttwu_dequeue(struct task_struct *p)
* deregister its sleep-persistent psi states from the old * deregister its sleep-persistent psi states from the old
* queue, and let psi_enqueue() know it has to requeue. * queue, and let psi_enqueue() know it has to requeue.
*/ */
if (unlikely(p->psi_flags)) { if (unlikely(p->in_iowait || p->in_memstall)) {
struct rq_flags rf; struct rq_flags rf;
struct rq *rq; struct rq *rq;
int clear = 0;
if (p->in_iowait)
clear |= TSK_IOWAIT;
if (p->in_memstall)
clear |= TSK_MEMSTALL;
rq = __task_rq_lock(p, &rf); rq = __task_rq_lock(p, &rf);
psi_task_change(p, p->psi_flags, 0); psi_task_change(p, clear, 0);
p->sched_psi_wake_requeue = 1;
__task_rq_unlock(rq, &rf); __task_rq_unlock(rq, &rf);
} }
} }