Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4187994pxb; Mon, 21 Feb 2022 14:19:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkhc7Eit4vJpop2LFhjLSDDCFbIQ2Rb1E+okoYcBrdcZXwBdlQBBWB+FRPmAVDcw1irzV+ X-Received: by 2002:a50:c446:0:b0:40f:612b:e294 with SMTP id w6-20020a50c446000000b0040f612be294mr23504198edf.240.1645481977672; Mon, 21 Feb 2022 14:19:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645481977; cv=none; d=google.com; s=arc-20160816; b=SOjjZ64LtFTWJPG9u2OCth/J3aIN9/Lv8fzWYxe39JoSTlZ47bB0UrWcfD6HWPwavu Ge+Rfq+oQApZCnECCk7ycFUxcRsOJnwqXwBI+WLxbkuBb+EKxyfBYKFl7okYjtz8QE2l wHttc0IFz43xFlfStfZcQYIXLOp+Jh2Rn07xfZBtvAG9ENrkArHl/OzYosGMPsIg+YbC l08C+HqZ0qYiTW21mqeNsB6ynsCFMaqWo5xki6qvpNS9YDmX8vgp7xbTaEY80lYukWY7 Q0IT3ZuHFjciz+oLdwcV6xPqmk/qRNSvvMK/sd0oa/8GXFsYyZX//72Qve1O104GFq8X w3HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=lKTnVg6jrl83i3sm4RdFOs8KKHjbxLPAqjejZxgOMvY=; b=nti/rJ30MlAZp4J9IWAFrjhfkpK/0FtrBToHAtQWAURJjUUWgg9OTQZGsOC+Oz2knZ E1TLlBu5JW9x3lo/7IdYY1hvWaCEVylQv30qVD/54TidgWidW/b4pp1DWImRQwtW1YGm kSZOQzj3vl08WVbNcIpF1CJ6lqAw31SkZP/cO+6yJLG868+XOvKBFn7MkluDPdrwd6zH xHs0xgZGcrgz3aZwK6PwEd/yccl31NmlWIE7NTlyru4mPT9G9b22kYGZRF5LGH80/B+y +ciAV3w9dHp8EMBPWOS/lZXFkyozenaxJjL6RyFFlo/c6ed3V9OMKXE2ZjTI5fx68M1F Eybw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=windriver.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12si5218505ejf.798.2022.02.21.14.19.15; Mon, 21 Feb 2022 14:19:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=windriver.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231158AbiBUSak (ORCPT + 99 others); Mon, 21 Feb 2022 13:30:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbiBUS0s (ORCPT ); Mon, 21 Feb 2022 13:26:48 -0500 X-Greylist: delayed 273 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 21 Feb 2022 10:26:25 PST Received: from mail1.wrs.com (unknown-3-146.windriver.com [147.11.3.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2242CC5 for ; Mon, 21 Feb 2022 10:26:25 -0800 (PST) Received: from mail.windriver.com (mail.wrs.com [147.11.1.11]) by mail1.wrs.com (8.15.2/8.15.2) with ESMTPS id 21LIKaY7027189 (version=TLSv1.1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 21 Feb 2022 10:20:37 -0800 Received: from ala-exchng01.corp.ad.wrs.com (ala-exchng01.corp.ad.wrs.com [147.11.82.252]) by mail.windriver.com (8.15.2/8.15.2) with ESMTPS id 21LIKYlq026458 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 Feb 2022 10:20:34 -0800 (PST) Received: from ala-exchng01.corp.ad.wrs.com (147.11.82.252) by ala-exchng01.corp.ad.wrs.com (147.11.82.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 21 Feb 2022 10:20:34 -0800 Received: from yow-pgortmak-d4.wrs.com (128.224.56.60) by ala-exchng01.corp.ad.wrs.com (147.11.82.252) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Mon, 21 Feb 2022 10:20:33 -0800 From: Paul Gortmaker To: , Frederic Weisbecker , Peter Zijlstra CC: Paul Gortmaker , Thomas Gleixner , "Paul E . McKenney" , Ingo Molnar Subject: [PATCH 1/2] sched/isolation: really align nohz_full with rcu_nocbs Date: Mon, 21 Feb 2022 13:20:08 -0500 Message-ID: <20220221182009.1283-2-paul.gortmaker@windriver.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220221182009.1283-1-paul.gortmaker@windriver.com> References: <20220221182009.1283-1-paul.gortmaker@windriver.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_FAIL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At the moment it is currently possible to sneak a core into nohz_full that lies between nr_possible and NR_CPUS - but you won't "see" it because cpumask_pr_args() implicitly hides anything above nr_cpu_ids. This becomes a problem when the nohz_full CPU set doesn't contain at least one other valid nohz CPU - in which case we end up with the tick_nohz_full_running set and no tick core specified, which trips an endless sequence of WARN() and renders the machine unusable. I inadvertently opened the door for this when fixing an overly restrictive nohz_full conditional in the below Fixes: commit - and then courtesy of my optimistic ACPI reporting nr_possible of 64 (the default Kconfig for NR_CPUS) and the not-so helpful implict filtering done by cpumask_pr_args, I unfortunately did not spot it during my testing. So here, I don't rely on what was printed anymore, but code exactly what our restrictions should be in order to be aligned with rcu_nocbs - which was the original goal. Since the checks lie in "__init" code it is largely free for us to do this anyway. Building with NOHZ_FULL and NR_CPUS=128 on an otherwise defconfig, and booting with "rcu_nocbs=8-127 nohz_full=96-127" on the same 16 core T5500 Dell machine now results in the following (only relevant lines shown): smpboot: Allowing 64 CPUs, 48 hotplug CPUs setup_percpu: NR_CPUS:128 nr_cpumask_bits:128 nr_cpu_ids:64 nr_node_ids:2 housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' contains nonexistent CPUs. housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' has no valid CPUs. rcu: RCU restricting CPUs from NR_CPUS=128 to nr_cpu_ids=64. rcu: Note: kernel parameter 'rcu_nocbs=', 'nohz_full', or 'isolcpus=' contains nonexistent CPUs. rcu: Offload RCU callbacks from CPUs: 8-63. One can see both new housekeeping checks are triggered in the above. The same invalid boot arg combination would have previously resulted in an infinitely scrolling mix of WARN from all cores per tick on this box. We may need to revisit these sanity checks when nohz_full is accepted as a stand alone keyword "enable" w/o a cpuset (see rcu/nohz d2cf0854d728). Fixes: 915a2bc3c6b7 ("sched/isolation: Reconcile rcu_nocbs= and nohz_full=") Cc: Frederic Weisbecker Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Paul E. McKenney Cc: Ingo Molnar Signed-off-by: Paul Gortmaker --- kernel/sched/isolation.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index b4d10815c45a..f7d2406c1f1d 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -126,6 +126,17 @@ static int __init housekeeping_setup(char *str, unsigned long flags) goto free_non_housekeeping_mask; } + if (!cpumask_subset(non_housekeeping_mask, cpu_possible_mask)) { + pr_info("housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' contains nonexistent CPUs.\n"); + cpumask_and(non_housekeeping_mask, cpu_possible_mask, + non_housekeeping_mask); + } + + if (cpumask_empty(non_housekeeping_mask)) { + pr_info("housekeeping: kernel parameter 'nohz_full=' or 'isolcpus=' has no valid CPUs.\n"); + goto free_non_housekeeping_mask; + } + alloc_bootmem_cpumask_var(&housekeeping_staging); cpumask_andnot(housekeeping_staging, cpu_possible_mask, non_housekeeping_mask); -- 2.17.1