On Mon, Jul 01, 2019 at 03:08:41PM -0700, Subhra Mazumdar wrote:
On 7/1/19 1:03 AM, Viresh Kumar wrote:It very much does.
On 28-06-19, 18:16, Subhra Mazumdar wrote:I thought nr_running does not include the on-cpu thread.
On 6/25/19 10:06 PM, Viresh Kumar wrote:Why wouldn't the current set of checks be enough to guarantee that ?
@@ -5376,6 +5376,15 @@ static struct {Shouldn't this check if rq->curr is also sched idle?
#endif /* CONFIG_NO_HZ_COMMON */
+/* CPU only has SCHED_IDLE tasks enqueued */
+static int sched_idle_cpu(int cpu)
+{
+ struct rq *rq = cpu_rq(cpu);
+
+ return unlikely(rq->nr_running == rq->cfs.idle_h_nr_running &&
+ rq->nr_running);
+}
+
idle_cpu() will try very hard to declare a CPU !idle. But I don't seeidle_cpu() not only checks nr_running is 0 but also rq->curr == rq->idleAnd why not drop the rq->nr_running non zero check?Because CPU isn't sched-idle if nr_running and idle_h_nr_running are both 0,
i.e. it is an IDLE cpu in that case. And so I thought it is important to have
this check as well.
how that it relevant. sched_idle_cpu() will only return true if there
are only SCHED_IDLE tasks on the CPU. Viresh's test is simple and
straight forward.