Message ID | 20221019225939.1646349-1-yury.norov@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp575827wrs; Wed, 19 Oct 2022 16:03:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MRK8xY0vnuDt9RxUovSMoSzs6YOF7GMy3k10Z93xB6/SdEYT5wq8mIoa/vH3HIutHJGZG X-Received: by 2002:a17:906:8470:b0:78d:b531:7d10 with SMTP id hx16-20020a170906847000b0078db5317d10mr8744165ejc.275.1666220614774; Wed, 19 Oct 2022 16:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666220614; cv=none; d=google.com; s=arc-20160816; b=0JxJVQaDXqpACyFiOQ23Q00cI5i1WrBoEi9rkPbg32nWd/lu1lGjHPG9D+cDGY9R1s noIb0Dglz7Zcbbow3Kw59Lg9EfNdn+oR27lbZXoNUh2wqHHfIDhyGVrdocSAFktlIUiN NwBDbLlUf7z7UY+G9ujbZh56J4u6uUNdkjyqNlxNw+4Npm/qB98nRHUqQsXjR32Qm7S7 ZV1H+gycF46kgfwUh6qJ8c16Y7stkawWjpcklJJ4NJ88ELmhO4pVT3qDaKVqoDk2+6iZ BJ8Ip91Yqjl3aox4iruHZ6fJqOILU4fmLyDwTyQPPYKz5ezvJ2q7UKmyGKtAoPR6Vh65 kKvg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=b7+Y9Us5vY6Sok7RqhqU+hdfsfZgw3dMiSDjIRAqLFg=; b=Vv6xzwkghFIr6LxajgLY6VmEVGzQCgWmzbqyoUalAmme341VdZHI1UUBwliMlZjiqP tCabU+5RRMUzpaRRTRBB+6OmOwLZNEzPNp2UwQC4MNjofurXfNTUsPG+voPvB6iyMAKu 1zRxvFu3jefjlSsFOCRCYQCQxySKzqyF6lBnSXhJxOeoqG2SbvRBT1XTzfRCbt4mvCWH YoG7DjJR1b6sQsXc2upcwoRv25ueJUtdQsR2MFUDqJ3xv8oxolbIkv933sDQArdDfpZ5 Azv3qXz9Gx5l7t1SM7eafsB9o+GkTsPNTQCuWqNXp8pOcIcOGfQp1okg8yM83AB5YAY4 2Inw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mRY5SF7e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb36-20020a1709071ca400b0078ddffd4660si17368572ejc.651.2022.10.19.16.03.05; Wed, 19 Oct 2022 16:03:34 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mRY5SF7e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231531AbiJSXCa (ORCPT <rfc822;samuel.l.nystrom@gmail.com> + 99 others); Wed, 19 Oct 2022 19:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbiJSXCL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Oct 2022 19:02:11 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A13A1D4407 for <linux-kernel@vger.kernel.org>; Wed, 19 Oct 2022 16:02:01 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id d18-20020a05683025d200b00661c6f1b6a4so10393449otu.1 for <linux-kernel@vger.kernel.org>; Wed, 19 Oct 2022 16:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b7+Y9Us5vY6Sok7RqhqU+hdfsfZgw3dMiSDjIRAqLFg=; b=mRY5SF7eMnsrZtZ6gxEpdWht+U7yEwBB4BqUxXK8hMcKjuo7YSkgLMeztyILk82kf8 eU4Dw7LTmtMjJcNiNVqlozYj5JsN4SRVJnYyg7xdBqU7H3niBYU76TXOsv/z3N1+s0lo kEt/2CznYsL6LciJGsdf66JIe6NE/XK16lP9ew/pMXmDRGad5P2ddckVl7R60jQ0Zu31 6ZX2d6XIrHNMoF67jLlktmo8GVL4LmB3E7jMkUfXFPFKBPg5KXzzlo5OaXt1D1SVEY1F qNCASacT4nWfWZjf+xndhXfUeAh09yBqQjCSz6F9vwcs1xFr5L0c7ZWKjjh0ZHQ+sKkQ JaAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b7+Y9Us5vY6Sok7RqhqU+hdfsfZgw3dMiSDjIRAqLFg=; b=7GrA5oUCA0sf6JegTFKvL7A8CoXLUl/YpFilNYDiceJar/wapw0i2V5m04S0OSag7z xVX2dqHNBQ6C4tKyWsD0NDIgjCmF9H8sRvmkORl/r8B/LW0YWCEUGdRMfB3H9xWOBWcC O9nXCekX3FdK+U0dCeCOrnVvkA1/Oiyh9goPeae3MQ7ktdTdZTXTuKzKWW8MSFgM8NKn U85bur7vE0twfxSDh5S6nSiG6oN4/+bLCcdDWX3mBDpxTEJ8KI9n8qbiVehucb3zUlEa 0eyl2GHdi0bL6OFt3ZjOivB/2BNyBJqAVm/7J4CZUv0YCeTiwdic+UqhHFrZRD1oxLUy TOAw== X-Gm-Message-State: ACrzQf3RmFLH4l9Yr16vjAMIbX26ibZ277KCZV7TWjYx1CdCjlVcPKGc AhN6U/TpX0SQScnouW7CdH8Cv7V1vXk= X-Received: by 2002:a05:6830:1dba:b0:662:968:75c0 with SMTP id z26-20020a0568301dba00b00662096875c0mr1803632oti.158.1666220513698; Wed, 19 Oct 2022 16:01:53 -0700 (PDT) Received: from localhost ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id n20-20020a9d4d14000000b006618e23df48sm7529008otf.39.2022.10.19.16.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 16:01:53 -0700 (PDT) From: Yury Norov <yury.norov@gmail.com> To: linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert@linux-m68k.org>, Linus Torvalds <torvalds@linux-foundation.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Rasmus Villemoes <linux@rasmusvillemoes.dk>, Andrew Morton <akpm@linux-foundation.org>, Stephen Rothwell <sfr@canb.auug.org.au>, Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, "Paul E . McKenney" <paulmck@kernel.org>, Vlastimil Babka <vbabka@suse.cz>, Dmitry Vyukov <dvyukov@google.com>, Valentin Schneider <vschneid@redhat.com>, Sander Vanheule <sander@svanheule.net>, Alexey Klimov <klimov.linux@gmail.com>, Eric Biggers <ebiggers@google.com> Cc: Yury Norov <yury.norov@gmail.com> Subject: [PATCH v2] cpumask: limit visibility of FORCE_NR_CPUS Date: Wed, 19 Oct 2022 15:59:39 -0700 Message-Id: <20221019225939.1646349-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747158947614968048?= X-GMAIL-MSGID: =?utf-8?q?1747158947614968048?= |
Series |
[v2] cpumask: limit visibility of FORCE_NR_CPUS
|
|
Commit Message
Yury Norov
Oct. 19, 2022, 10:59 p.m. UTC
In current form, FORCE_NR_CPUS is visible to all users building their
kernels, even not experts. It is also set in allmodconfig or allyesconfig,
which is not a correct behavior.
The 'choice' and unused config UNFORCE_NR_CPUS are used to ensure that
auto-generated configs that try to enable as much options as possible,
like allmodconfig, don't enable FORCE_NR_CPUS.
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
v2: extend commit message with an explanation for what we need 'choice'.
lib/Kconfig | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
Comments
On 19/10/22 15:59, Yury Norov wrote: > In current form, FORCE_NR_CPUS is visible to all users building their > kernels, even not experts. It is also set in allmodconfig or allyesconfig, > which is not a correct behavior. > > The 'choice' and unused config UNFORCE_NR_CPUS are used to ensure that > auto-generated configs that try to enable as much options as possible, > like allmodconfig, don't enable FORCE_NR_CPUS. > > Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org> > Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> > Signed-off-by: Yury Norov <yury.norov@gmail.com> > --- > v2: extend commit message with an explanation for what we need 'choice'. > > lib/Kconfig | 31 ++++++++++++++++++++++++------- > 1 file changed, 24 insertions(+), 7 deletions(-) > > diff --git a/lib/Kconfig b/lib/Kconfig > index 9bbf8a4b2108..1ada12f5dda6 100644 > --- a/lib/Kconfig > +++ b/lib/Kconfig > @@ -528,14 +528,31 @@ config CPUMASK_OFFSTACK > them on the stack. This is a bit more expensive, but avoids > stack overflow. > > +choice > + prompt "Number of CPUs detection method" > + default UNFORCE_NR_CPUS > + depends on SMP && EXPERT What about moving the 'depends on EXPERT' onto FORCE_NR_CPUS? I find it makes it easier to figure out the requirements for that option, and is similar to how e.g. CONFIG_PREEMPT_RT is handled. > + help > + Select between boot-time and compile-time detection of number > + of CPUs. If it's possible to provide exact number of CPUs at > + compile-time, kernel code may be optimized better. > + For general-purpose kernel, choose "boot time" option. > + > +config UNFORCE_NR_CPUS > + bool "Set number of CPUs at boot time" > + help > + Choose it if you build general-purpose kernel and want to rely > + on kernel to detect actual number of CPUs. > + > config FORCE_NR_CPUS > - bool "NR_CPUS is set to an actual number of CPUs" > - depends on SMP > - help > - Say Yes if you have NR_CPUS set to an actual number of possible > - CPUs in your system, not to a default value. This forces the core > - code to rely on compile-time value and optimize kernel routines > - better. > + bool "Set number of CPUs at compile time" > + help > + Choose it if NR_CPUS corresponds to an actual number of > + possible CPUs in your system. This forces the core code > + to rely on compile-time value and optimize kernel routines > + better. > + > +endchoice > > config CPU_RMAP > bool > -- > 2.34.1
On Fri, Nov 04, 2022 at 05:43:53PM +0000, Valentin Schneider wrote: > On 19/10/22 15:59, Yury Norov wrote: > > In current form, FORCE_NR_CPUS is visible to all users building their > > kernels, even not experts. It is also set in allmodconfig or allyesconfig, > > which is not a correct behavior. > > > > The 'choice' and unused config UNFORCE_NR_CPUS are used to ensure that > > auto-generated configs that try to enable as much options as possible, > > like allmodconfig, don't enable FORCE_NR_CPUS. > > > > Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org> > > Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> > > Signed-off-by: Yury Norov <yury.norov@gmail.com> > > --- > > v2: extend commit message with an explanation for what we need 'choice'. > > > > lib/Kconfig | 31 ++++++++++++++++++++++++------- > > 1 file changed, 24 insertions(+), 7 deletions(-) > > > > diff --git a/lib/Kconfig b/lib/Kconfig > > index 9bbf8a4b2108..1ada12f5dda6 100644 > > --- a/lib/Kconfig > > +++ b/lib/Kconfig > > @@ -528,14 +528,31 @@ config CPUMASK_OFFSTACK > > them on the stack. This is a bit more expensive, but avoids > > stack overflow. > > > > +choice > > + prompt "Number of CPUs detection method" > > + default UNFORCE_NR_CPUS > > + depends on SMP && EXPERT > > What about moving the 'depends on EXPERT' onto FORCE_NR_CPUS? I find it > makes it easier to figure out the requirements for that option, and is > similar to how e.g. CONFIG_PREEMPT_RT is handled. In case of PREEMPT_RT, there are some other options to choose. In case of FORCE_NR_CPUS there will be a choice with a single option, and it would be weird that the option is never used. I'd prefer to hide this choice for non-experts entirely.
On 04/11/22 15:36, Yury Norov wrote: > On Fri, Nov 04, 2022 at 05:43:53PM +0000, Valentin Schneider wrote: >> On 19/10/22 15:59, Yury Norov wrote: >> > +choice >> > + prompt "Number of CPUs detection method" >> > + default UNFORCE_NR_CPUS >> > + depends on SMP && EXPERT >> >> What about moving the 'depends on EXPERT' onto FORCE_NR_CPUS? I find it >> makes it easier to figure out the requirements for that option, and is >> similar to how e.g. CONFIG_PREEMPT_RT is handled. > > In case of PREEMPT_RT, there are some other options to choose. In case of > FORCE_NR_CPUS there will be a choice with a single option, and it would be > weird that the option is never used. > True, this would have been neater as a single config, but AIUI it's a required "trick" for allyesconfig. I would have expected other configs to have hit similar issues in the past, but didn't find any. > I'd prefer to hide this choice for non-experts entirely. Sure. Reviewed-by: Valentin Schneider <vschneid@redhat.com>
On Mon, Nov 7, 2022 at 4:45 AM Valentin Schneider <vschneid@redhat.com> wrote: > > True, this would have been neater as a single config, but AIUI it's a > required "trick" for allyesconfig. I would have expected other configs to > have hit similar issues in the past, but didn't find any. Actually, the standard trick for allmodconfig and allyesconfig is to use the "COMPILE_TEST" config variable. It's basically a variable for "I'm not going to *run* the result, but I want to make sure to get build coverage". And both allmodconfig and allyesconfig set that config option. In most cases, the "COMPILE_TEST" config variable is used to enable things that wouldn't make sense on the chosen hardware platform, so you have things like depends on ARCH_DAVINCI || COMPILE_TEST because some driver only makes sense on ARCH_DAVINCI, but people still want the build coverage. But sometimes it's used the other way around, so fro example on x86 we have config X86_DECODER_SELFTEST which explicitly depends on COMPILE_TEST *not* being set, because it's a test that takes forever to run (particularly for huge kernels), and so it's actually disabled for the common all{yes,mod}config cases. Same goes for things like LTO_CLANG_FULL. It's just expensive for big build tests, plus causes too many issues for now. End result: if some option actually *reduces* test coverage, or has some other reason why it makes no sense for build tests, use that depends on !COMPILE_TEST to not have allmodconfig and allyesconfig pick it. Linus
On Mon, Nov 07, 2022 at 09:55:34AM -0800, Linus Torvalds wrote: > On Mon, Nov 7, 2022 at 4:45 AM Valentin Schneider <vschneid@redhat.com> wrote: > > > > True, this would have been neater as a single config, but AIUI it's a > > required "trick" for allyesconfig. I would have expected other configs to > > have hit similar issues in the past, but didn't find any. > > Actually, the standard trick for allmodconfig and allyesconfig is to > use the "COMPILE_TEST" config variable. > > It's basically a variable for "I'm not going to *run* the result, but > I want to make sure to get build coverage". > > And both allmodconfig and allyesconfig set that config option. > > In most cases, the "COMPILE_TEST" config variable is used to enable > things that wouldn't make sense on the chosen hardware platform, so > you have things like > > depends on ARCH_DAVINCI || COMPILE_TEST > > because some driver only makes sense on ARCH_DAVINCI, but people still > want the build coverage. > > But sometimes it's used the other way around, so fro example on x86 we have > > config X86_DECODER_SELFTEST > > which explicitly depends on COMPILE_TEST *not* being set, because it's > a test that takes forever to run (particularly for huge kernels), and > so it's actually disabled for the common all{yes,mod}config cases. > > Same goes for things like LTO_CLANG_FULL. It's just expensive for big > build tests, plus causes too many issues for now. > > End result: if some option actually *reduces* test coverage, or has > some other reason why it makes no sense for build tests, use that > > depends on !COMPILE_TEST > > to not have allmodconfig and allyesconfig pick it. Thanks, I'll send v3 than. Thanks, Yury
diff --git a/lib/Kconfig b/lib/Kconfig index 9bbf8a4b2108..1ada12f5dda6 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -528,14 +528,31 @@ config CPUMASK_OFFSTACK them on the stack. This is a bit more expensive, but avoids stack overflow. +choice + prompt "Number of CPUs detection method" + default UNFORCE_NR_CPUS + depends on SMP && EXPERT + help + Select between boot-time and compile-time detection of number + of CPUs. If it's possible to provide exact number of CPUs at + compile-time, kernel code may be optimized better. + For general-purpose kernel, choose "boot time" option. + +config UNFORCE_NR_CPUS + bool "Set number of CPUs at boot time" + help + Choose it if you build general-purpose kernel and want to rely + on kernel to detect actual number of CPUs. + config FORCE_NR_CPUS - bool "NR_CPUS is set to an actual number of CPUs" - depends on SMP - help - Say Yes if you have NR_CPUS set to an actual number of possible - CPUs in your system, not to a default value. This forces the core - code to rely on compile-time value and optimize kernel routines - better. + bool "Set number of CPUs at compile time" + help + Choose it if NR_CPUS corresponds to an actual number of + possible CPUs in your system. This forces the core code + to rely on compile-time value and optimize kernel routines + better. + +endchoice config CPU_RMAP bool