From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbbJJS4f (ORCPT ); Sat, 10 Oct 2015 14:56:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55343 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752440AbbJJS4d (ORCPT ); Sat, 10 Oct 2015 14:56:33 -0400 Date: Sat, 10 Oct 2015 20:53:12 +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 2/3] sched: change select_fallback_rq() to use for_each_cpu_and() Message-ID: <20151010185312.GA24096@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 We can make "cpumask *nodemask" more local and use for_each_cpu_and() to simplify this code a little bit. And NUMA_NO_NODE looks better than "-1". Signed-off-by: Oleg Nesterov --- kernel/sched/core.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a2ef0cf..e4fa6be 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1308,24 +1308,22 @@ static inline bool cpu_allowed(int cpu) static int select_fallback_rq(int cpu, struct task_struct *p) { int nid = cpu_to_node(cpu); - const struct cpumask *nodemask = NULL; enum { cpuset, possible, fail } state = cpuset; int dest_cpu; /* * If the node that the cpu is on has been offlined, cpu_to_node() - * will return -1. There is no cpu on the node, and we should - * select the cpu on the other node. + * will return NUMA_NO_NODE. There is no cpu on the node, and we + * should select the cpu on the other node. */ - if (nid != -1) { - nodemask = cpumask_of_node(nid); + if (nid != NUMA_NO_NODE) { + const struct cpumask *nodemask = cpumask_of_node(nid); /* Look for allowed, online CPU in same node. */ - for_each_cpu(dest_cpu, nodemask) { + for_each_cpu_and(dest_cpu, nodemask, tsk_cpus_allowed(p)) { if (!cpu_allowed(dest_cpu)) continue; - if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p))) - return dest_cpu; + return dest_cpu; } } -- 1.5.5.1