From nobody Thu May 14 07:13:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47DB4C433EF for ; Thu, 7 Apr 2022 21:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231126AbiDGVJ5 (ORCPT ); Thu, 7 Apr 2022 17:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230473AbiDGVJy (ORCPT ); Thu, 7 Apr 2022 17:09:54 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F8F817A2E2 for ; Thu, 7 Apr 2022 14:07:53 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id b17so5987275qvf.12 for ; Thu, 07 Apr 2022 14:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hxKxY+DBpoByF0mtjo+UB7bPjCEPBSOvES4J4XomWfw=; b=jwQg9dQrHOSiG8lPloLqQ/bp8O7sK5UOZyz9D/aVa4j2kiHcO2my5h+zwWBcJxgOC0 z6UbFO8G2TDI4B9chEJiAFxEa79J08iPbDo3ggVSuH2+rR9uPX++uhbY28MqAULtWQvO JoiusccmH4T9pSjjUbI19eDJ4crl6IHyUGXQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hxKxY+DBpoByF0mtjo+UB7bPjCEPBSOvES4J4XomWfw=; b=4btgZrOa2qJ6Gt1zeo85cjfAyYb8g9UgQ1XkQn37pW4lluNSg0cY6ufy8j44KR8pQT ssWezWk9agKlDEuFWLhA/y5mJmud6Gt7lhk8vqYRFaifkRfG/ZSOK7wpVTTo3TJdegR9 xkrD7kbw3C11PSE9NGsH35F2HWPdWKcjxA0O8UyTDoo2jU0heLIGRQeXXksYrwYd0mb7 4i8F13QQL5kkIgX5/xqZ3VeOvW3R+9cO8o4+rWwXGLlqjAhVzQhCZQV1Gj1IBnjkyR8b Jqvz3mywUssIGo3oUcm3MiDU/7jtRS3iJJYqTLWZPLI1bgwRAFAnikBqTkgMzeReSvcB BX8w== X-Gm-Message-State: AOAM532l/hlO/Bko2JmkQ+t0Wy0A1j6bkfZy2rDTRlTOj//moDxsqap7 5ZWwuGKQv61Ur8noF6RwfRAS75oqfoQ2wA== X-Google-Smtp-Source: ABdhPJzwtvpZaHmk9lriKJMPmnSalngNgvvJoX3cZ2JPuR2Hll7aVpCqu3lWkR/jk381xr2DKPRpGA== X-Received: by 2002:a05:6214:4017:b0:443:e335:efd3 with SMTP id kd23-20020a056214401700b00443e335efd3mr14132649qvb.131.1649365672835; Thu, 07 Apr 2022 14:07:52 -0700 (PDT) Received: from joelboxx.c.googlers.com.com (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id d3-20020a05622a15c300b002eb9af4c945sm18230376qty.3.2022.04.07.14.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:07:52 -0700 (PDT) From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: Joel Fernandes , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: [PATCH RFC] rcu/nocb: Provide default all-CPUs mask for RCU_NOCB_CPU=y Date: Thu, 7 Apr 2022 21:07:33 +0000 Message-Id: <20220407210734.2548973-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On systems with CONFIG_RCU_NOCB_CPU=3Dy, there is no default mask provided which ends up not offloading any CPU. This patch removes yet another dependency from the bootloader having to know about RCU, about how many CPUs the system has, and about how to provide the mask. Basically, I think we should stop pretending that the user knows what they are doing :). In other words, if NO_CB_CPU is enabled, lets make use of it. My goal is to make RCU as zero-config as possible with sane defaults. If user wants to provide rcu_nocbs=3D or nohz_full=3D options, then those will take precedence and this patch will have no effect. I tested providing rcu_nocbs=3D option, ensuring that is preferred over thi= s. Signed-off-by: Joel Fernandes --- kernel/rcu/tree_nocb.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index eeafb546a7a0..607fbf843467 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1165,12 +1165,25 @@ EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload); void __init rcu_init_nohz(void) { int cpu; - bool need_rcu_nocb_mask =3D false; + bool need_rcu_nocb_mask =3D false, set_nocb_mask_all =3D false; struct rcu_data *rdp; =20 + /* + * In case rcu_nocbs=3D was not passed on the kernel command line, + * provide a sane default by offloading all CPUs. This provides a + * sane default for rcu_nocbs and prevents users overlooking these + * details. + */ + if (!rcu_nocb_is_setup) { + need_rcu_nocb_mask =3D true; + set_nocb_mask_all =3D true; + } + #if defined(CONFIG_NO_HZ_FULL) - if (tick_nohz_full_running && cpumask_weight(tick_nohz_full_mask)) + if (tick_nohz_full_running && cpumask_weight(tick_nohz_full_mask)) { need_rcu_nocb_mask =3D true; + set_nocb_mask_all =3D false; /* NO_HZ_FULL provides its own mask. */ + } #endif /* #if defined(CONFIG_NO_HZ_FULL) */ =20 if (need_rcu_nocb_mask) { @@ -1191,6 +1204,9 @@ void __init rcu_init_nohz(void) cpumask_or(rcu_nocb_mask, rcu_nocb_mask, tick_nohz_full_mask); #endif /* #if defined(CONFIG_NO_HZ_FULL) */ =20 + if (set_nocb_mask_all) + cpumask_setall(rcu_nocb_mask); + if (!cpumask_subset(rcu_nocb_mask, cpu_possible_mask)) { pr_info("\tNote: kernel parameter 'rcu_nocbs=3D', 'nohz_full', or 'isolc= pus=3D' contains nonexistent CPUs.\n"); cpumask_and(rcu_nocb_mask, cpu_possible_mask, --=20 2.35.1.1178.g4f1659d476-goog