Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5072041pxb; Mon, 15 Feb 2021 08:46:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4rylcZtsMmsLZoKBsXaSeRrwsIuLETVRSPigXmkWnpThpsh5GtWEhbEFsnUjizA66VSlq X-Received: by 2002:a17:906:4cca:: with SMTP id q10mr16382216ejt.379.1613407607420; Mon, 15 Feb 2021 08:46:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613407607; cv=none; d=google.com; s=arc-20160816; b=UtN0X7b1hlzUySQHBoqVFgpeevlD1CzKH7yDkYQI5GUa8D/edDXMS2q2sFK/JEgX1b nENI/PmVEzg5CJMdPrvAAC5oRyhNOU07UMSm9rV5y46V8KIy4OqISP7Vnl1zjj478bdQ oxrW3lThRAEAPu3xx9l+cvsLrnJe3cYI0SxYf2RNgRoo8JDP+wlnn1lKNiSyX3QjebB9 WNn0Ogw9VERfpqEICCU8a37z3BKc8+wx6FgDzvySVvvtv/MGj2I9TRBWPqpmSTUG5B48 Z/skxIInyXvKHISnaaPZJ3YqDyS1AXuBcxloFJFw8XozgyVJy6hz0sATQ4kDFzWsmt1S 4rxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OlaiTah5UetF3PMOX6rAkS5syV5y6ax4K2UU+zROYx8=; b=bcCFNyj4eUQ34AtpmrZR7R0XtRpUdQ+GgRDT3T5InwnR7p7WEJfkET17vaag92AYZt 2Wr7cKrIq4n9BNqMTEO1KngrRtJz6014k2cmCkkRASNn6QiStuAMoyqMz1k1BWme7rF1 YrDsXpZajtzf+TKFPvipeiT5qJhzAMSuXPeQW98tNO0C631qI/GLHCp/eN+7/yPv543W j7Xru4WdnC5OQWHrs/LhAMzTgLhdjJzj7mod/ZEKlcmGkvDwE7A2pTL4w2S/kzyFrTJp xgHbF/8t0A3PbEFwDacwQOu8ycak9HPSp/wlVdpK4y0rbobnhjZncrHkpQ41ZSIGLBOX ZkFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dGY2U7Ze; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si12880589edn.568.2021.02.15.08.46.24; Mon, 15 Feb 2021 08:46:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dGY2U7Ze; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232222AbhBOQna (ORCPT + 99 others); Mon, 15 Feb 2021 11:43:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:49598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231618AbhBOPiG (ORCPT ); Mon, 15 Feb 2021 10:38:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3CE5464EEC; Mon, 15 Feb 2021 15:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403241; bh=y7eQowfWRCiPs6rqvJgWxNBr3H42kcUQxHDrWQVFBLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dGY2U7ZeWRma1HuKoBix1lqA3z4HY29Y6zbYuQD2yT4wn9WfjJG54UpGlguKRJg4N ygLhQqC2dO27WvdbDeC496MuHJAwic1FPlefP1jc+nbiHCQDXIdzbVz8vOeB0GzrAb B6wkyMSv6vcLcsJwktrrul4QDTwEQfjNdeYEL1h8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Thomas Gleixner , Nitesh Narayan Lal , Marcelo Tosatti , abelits@marvell.com, davem@davemloft.net, Sasha Levin Subject: [PATCH 5.10 045/104] Revert "lib: Restrict cpumask_local_spread to houskeeping CPUs" Date: Mon, 15 Feb 2021 16:26:58 +0100 Message-Id: <20210215152720.928637631@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152719.459796636@linuxfoundation.org> References: <20210215152719.459796636@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit 2452483d9546de1c540f330469dc4042ff089731 ] This reverts commit 1abdfe706a579a702799fce465bceb9fb01d407c. This change is broken and not solving any problem it claims to solve. Robin reported that cpumask_local_spread() now returns any cpu out of cpu_possible_mask in case that NOHZ_FULL is disabled (runtime or compile time). It can also return any offline or not-present CPU in the housekeeping mask. Before that it was returning a CPU out of online_cpu_mask. While the function is racy against CPU hotplug if the caller does not protect against it, the actual use cases are not caring much about it as they use it mostly as hint for: - the user space affinity hint which is unused by the kernel - memory node selection which is just suboptimal - network queue affinity which might fail but is handled gracefully But the occasional fail vs. hotplug is very different from returning anything from possible_cpu_mask which can have a large amount of offline CPUs obviously. The changelog of the commit claims: "The current implementation of cpumask_local_spread() does not respect the isolated CPUs, i.e., even if a CPU has been isolated for Real-Time task, it will return it to the caller for pinning of its IRQ threads. Having these unwanted IRQ threads on an isolated CPU adds up to a latency overhead." The only correct part of this changelog is: "The current implementation of cpumask_local_spread() does not respect the isolated CPUs." Everything else is just disjunct from reality. Reported-by: Robin Murphy Signed-off-by: Thomas Gleixner Cc: Nitesh Narayan Lal Cc: Marcelo Tosatti Cc: abelits@marvell.com Cc: davem@davemloft.net Link: https://lore.kernel.org/r/87y2g26tnt.fsf@nanos.tec.linutronix.de Signed-off-by: Sasha Levin --- lib/cpumask.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/cpumask.c b/lib/cpumask.c index 85da6ab4fbb5a..fb22fb266f937 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -6,7 +6,6 @@ #include #include #include -#include /** * cpumask_next - get the next cpu in a cpumask @@ -206,27 +205,22 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask) */ unsigned int cpumask_local_spread(unsigned int i, int node) { - int cpu, hk_flags; - const struct cpumask *mask; + int cpu; - hk_flags = HK_FLAG_DOMAIN | HK_FLAG_MANAGED_IRQ; - mask = housekeeping_cpumask(hk_flags); /* Wrap: we always want a cpu. */ - i %= cpumask_weight(mask); + i %= num_online_cpus(); if (node == NUMA_NO_NODE) { - for_each_cpu(cpu, mask) { + for_each_cpu(cpu, cpu_online_mask) if (i-- == 0) return cpu; - } } else { /* NUMA first. */ - for_each_cpu_and(cpu, cpumask_of_node(node), mask) { + for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask) if (i-- == 0) return cpu; - } - for_each_cpu(cpu, mask) { + for_each_cpu(cpu, cpu_online_mask) { /* Skip NUMA nodes, done above. */ if (cpumask_test_cpu(cpu, cpumask_of_node(node))) continue; -- 2.27.0