From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752423AbbJJS4c (ORCPT ); Sat, 10 Oct 2015 14:56:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52544 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752274AbbJJS4a (ORCPT ); Sat, 10 Oct 2015 14:56:30 -0400 Date: Sat, 10 Oct 2015 20:53:09 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: heiko.carstens@de.ibm.com, Tejun Heo , Ingo Molnar , Rik van Riel , Thomas Gleixner , Vitaly Kuznetsov , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] sched: select_task_rq() should check cpu_active() like select_fallback_rq() Message-ID: <20151010185309.GA24089@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151010185255.GA24075@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I do not understand the cpu_active() check in select_fallback_rq(). x86 doesn't need it, and the recent commit dd9d3843755d "sched: Fix cpu_active_mask/cpu_online_mask race" documents the fact that on any architecture we can ignore !active starting from CPU_ONLINE stage. But any possible reason why do we need this check in "fallback" must equally apply to select_task_rq(). Signed-off-by: Oleg Nesterov --- kernel/sched/core.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5fe9086..a2ef0cf 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1297,6 +1297,11 @@ void kick_process(struct task_struct *p) } EXPORT_SYMBOL_GPL(kick_process); +static inline bool cpu_allowed(int cpu) +{ + return cpu_online(cpu) && cpu_active(cpu); +} + /* * ->cpus_allowed is protected by both rq->lock and p->pi_lock */ @@ -1317,9 +1322,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p) /* Look for allowed, online CPU in same node. */ for_each_cpu(dest_cpu, nodemask) { - if (!cpu_online(dest_cpu)) - continue; - if (!cpu_active(dest_cpu)) + if (!cpu_allowed(dest_cpu)) continue; if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p))) return dest_cpu; @@ -1329,9 +1332,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p) for (;;) { /* Any allowed, online CPU? */ for_each_cpu(dest_cpu, tsk_cpus_allowed(p)) { - if (!cpu_online(dest_cpu)) - continue; - if (!cpu_active(dest_cpu)) + if (!cpu_allowed(dest_cpu)) continue; goto out; } @@ -1390,7 +1391,7 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags) * not worry about this generic constraint ] */ if (unlikely(!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)) || - !cpu_online(cpu))) + !cpu_allowed(cpu))) cpu = select_fallback_rq(task_cpu(p), p); return cpu; -- 1.5.5.1