From patchwork Fri Sep 15 12:03:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 140474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a55:b0:13f:353d:d1ed with SMTP id 21csp360071rwb; Fri, 15 Sep 2023 07:37:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnfBSJy0rFkPQUiAvSS/n+yxWi/7wHQDy94yDWwhYY3NUZWgKNYNfcu+HPypLpuKsiAD4H X-Received: by 2002:a17:90b:80d:b0:268:f987:305f with SMTP id bk13-20020a17090b080d00b00268f987305fmr1638475pjb.46.1694788638528; Fri, 15 Sep 2023 07:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694788638; cv=none; d=google.com; s=arc-20160816; b=HUbIpD7VBK0TvF5yrJ0jMVExYD/tW1ZG8SEpqGxeL0VPJLHU0wuwmx02zt56FZIkE8 3uTHwDweQPf5OKZyEcPtFi231u9eNgM8a4jTY4OvoBm3DmSOj8D95NHWfrCo2nFcWoAq XNTuV6Ur2W2FP/7BQUH8sqAwpGahRzjsiv2g9QQ4rtIEE4ihnyVSzf0BqoE9gWM2xCsE G5+/uHyfbCYY9DlcTx1IwPJEUujpJM78hUYWNeYSZ1fv0iPCh2B04dW+9Gk93rbdcgUn U3cE+YPMjYC4cXG7O3LHWWVawU5uGYP2DaAAiMXhqzbeGtiadKO3ILGoD+gQ6Yajov51 SLtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=m7xp2X0Q8S/UayPYw7OGxOiHU450hlKqChD/eZZVcCs=; fh=eKeIeQq6ZJEPpCVRKsN4VFa+FaRfE4kjc161Ip6RZyg=; b=RHkfkxA4Yp2zCckONGlTGbKHJHlZQaHu11Vx9w7oVCYgWv9/v6y08NJl5FANGPgj/0 Puv6tpSrP2SV4szD4+uTt0+ADOsiPiFM+fK7JwVNYgulDQ0vRFbRHey3g/ImCTz20S2S 4YRTU1NsjCmwuyeiKGC4NbNdDW6zGvpK98DJrlk67XXfGlmmgjndk5smFU572al+mvtz 72Uag4i55cQYbDJZps6POsXcGoWuk04xiDOijaQvr6prYITGdXdLT6rD48IXFrTAJw/N +5jWgf5EMWc4TxjxYtiyPyd/vyhTzwp4m0eex3+JsWUd/JjMduhLDcgS2/fuckLDD7Jo viYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Hirae0Lr; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id nl13-20020a17090b384d00b00269584b6a10si3794829pjb.15.2023.09.15.07.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:37:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Hirae0Lr; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E78AC81A9EFF; Fri, 15 Sep 2023 05:06:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234596AbjIOMF4 (ORCPT + 32 others); Fri, 15 Sep 2023 08:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232836AbjIOMFz (ORCPT ); Fri, 15 Sep 2023 08:05:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B88A42D69; Fri, 15 Sep 2023 05:03:29 -0700 (PDT) Date: Fri, 15 Sep 2023 12:03:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694779408; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m7xp2X0Q8S/UayPYw7OGxOiHU450hlKqChD/eZZVcCs=; b=Hirae0LrG0bLpw07ZY4W7bV7I4wTnVTmEXli7fCJdPnPWnYZBDfylWRhZuvic8Qt8bQFFK 88XIbWPiXNWRvQr+fzoZwkjkOBr1CN6cU8ixvriM4uhJUA9Lck91q+MVmVeHyleJC5GTte IVAiUp33si+gfiQQ7WQ3n1JYbbpB+fveCzEFJAhGExwNF8UDjyiHftmZXqMnOhgQtKZrh1 86/k4c7K1yLHzrl4F9Md9VMFRpag2cIzBr/5OSAYoVNgnaP55lobC6VbgUiuXmQj9T24m5 x/SJVSyzB0TeSdAf/IHbp+cG4SPcTocNJU8K0E+DLiIUDcchArMc2Qt8kPVhUg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694779408; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m7xp2X0Q8S/UayPYw7OGxOiHU450hlKqChD/eZZVcCs=; b=yHAMCmnFUsnH1KgsSFDYFIGpnHy1xGG2jfTXs8Ob+CZ1WXc5wHE/AD2q6eObxiZMoG1pYE 7Q8TEefphUgewWCg== From: "tip-bot2 for Yury Norov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/topology: Handle NUMA_NO_NODE in sched_numa_find_nth_cpu() Cc: Yury Norov , Ingo Molnar , Mel Gorman , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230819141239.287290-6-yury.norov@gmail.com> References: <20230819141239.287290-6-yury.norov@gmail.com> MIME-Version: 1.0 Message-ID: <169477940743.27769.15976789729426503596.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 15 Sep 2023 05:06:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777114691122830045 X-GMAIL-MSGID: 1777114691122830045 The following commit has been merged into the sched/core branch of tip: Commit-ID: 9ecea9ae4d3127a09fb5dfcea87f248937a39ff5 Gitweb: https://git.kernel.org/tip/9ecea9ae4d3127a09fb5dfcea87f248937a39ff5 Author: Yury Norov AuthorDate: Sat, 19 Aug 2023 07:12:37 -07:00 Committer: Ingo Molnar CommitterDate: Fri, 15 Sep 2023 13:48:11 +02:00 sched/topology: Handle NUMA_NO_NODE in sched_numa_find_nth_cpu() sched_numa_find_nth_cpu() doesn't handle NUMA_NO_NODE properly, and may crash kernel if passed with it. On the other hand, the only user of sched_numa_find_nth_cpu() has to check NUMA_NO_NODE case explicitly. It would be easier for users if this logic will get moved into sched_numa_find_nth_cpu(). Signed-off-by: Yury Norov Signed-off-by: Ingo Molnar Cc: Mel Gorman Link: https://lore.kernel.org/r/20230819141239.287290-6-yury.norov@gmail.com --- kernel/sched/topology.c | 3 +++ lib/cpumask.c | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 423d089..a60ecf4 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2126,6 +2126,9 @@ int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node) struct cpumask ***hop_masks; int hop, ret = nr_cpu_ids; + if (node == NUMA_NO_NODE) + return cpumask_nth_and(cpu, cpus, cpu_online_mask); + rcu_read_lock(); /* CPU-less node entries are uninitialized in sched_domains_numa_masks */ diff --git a/lib/cpumask.c b/lib/cpumask.c index a7fd02b..34335c1 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -146,9 +146,7 @@ unsigned int cpumask_local_spread(unsigned int i, int node) /* Wrap: we always want a cpu. */ i %= num_online_cpus(); - cpu = (node == NUMA_NO_NODE) ? - cpumask_nth(i, cpu_online_mask) : - sched_numa_find_nth_cpu(cpu_online_mask, i, node); + cpu = sched_numa_find_nth_cpu(cpu_online_mask, i, node); WARN_ON(cpu >= nr_cpu_ids); return cpu;