[Intel-gfx] [PATCH CI 1/2] Revert "freezer, sched: Rewrite core freezer logic fix"
Ville Syrjala
ville.syrjala at linux.intel.com
Fri Nov 4 12:04:01 UTC 2022
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
This reverts commit f3387d5883ad92e9a54306fa3dff97d4f0581d78.
---
kernel/sched/core.c | 49 ++++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 32 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f519f44cd4c7..cb2aa2b54c7a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4200,37 +4200,6 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
return success;
}
-static bool __task_needs_rq_lock(struct task_struct *p)
-{
- unsigned int state = READ_ONCE(p->__state);
-
- /*
- * Since pi->lock blocks try_to_wake_up(), we don't need rq->lock when
- * the task is blocked. Make sure to check @state since ttwu() can drop
- * locks at the end, see ttwu_queue_wakelist().
- */
- if (state == TASK_RUNNING || state == TASK_WAKING)
- return true;
-
- /*
- * Ensure we load p->on_rq after p->__state, otherwise it would be
- * possible to, falsely, observe p->on_rq == 0.
- *
- * See try_to_wake_up() for a longer comment.
- */
- smp_rmb();
- if (p->on_rq)
- return true;
-
-#ifdef CONFIG_SMP
- smp_rmb();
- if (p->on_cpu)
- return true;
-#endif
-
- return false;
-}
-
/**
* task_call_func - Invoke a function on task in fixed state
* @p: Process for which the function is to be invoked, can be @current.
@@ -4248,12 +4217,28 @@ static bool __task_needs_rq_lock(struct task_struct *p)
int task_call_func(struct task_struct *p, task_call_f func, void *arg)
{
struct rq *rq = NULL;
+ unsigned int state;
struct rq_flags rf;
int ret;
raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
- if (__task_needs_rq_lock(p))
+ state = READ_ONCE(p->__state);
+
+ /*
+ * Ensure we load p->on_rq after p->__state, otherwise it would be
+ * possible to, falsely, observe p->on_rq == 0.
+ *
+ * See try_to_wake_up() for a longer comment.
+ */
+ smp_rmb();
+
+ /*
+ * Since pi->lock blocks try_to_wake_up(), we don't need rq->lock when
+ * the task is blocked. Make sure to check @state since ttwu() can drop
+ * locks at the end, see ttwu_queue_wakelist().
+ */
+ if (state == TASK_RUNNING || state == TASK_WAKING || p->on_rq)
rq = __task_rq_lock(p, &rf);
/*
--
2.37.4
More information about the Intel-gfx
mailing list