linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gow <davidgow@google.com>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: Daniel Latypov <dlatypov@google.com>,
	Brendan Higgins <brendanhiggins@google.com>,
	Andy Shevchenko <andriy.shevchenko@intel.com>,
	Trent Piepho <tpiepho@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	andy@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
	Oskar Schirmer <oskar@scara.com>, Yiyuan Guo <yguoaz@gmail.com>
Subject: Re: [PATCH] lib/math/rational.c: Fix divide by zero
Date: Tue, 25 May 2021 09:57:57 +0800	[thread overview]
Message-ID: <CABVgOSmTq37kVdvq0f1xmA-BVJ5k_z=QqZRE6DTkRZk-PaLJtg@mail.gmail.com> (raw)
In-Reply-To: <caaab2dd-b1b6-b105-6b2f-9a2bc8438a82@infradead.org>

On Tue, May 25, 2021 at 9:49 AM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> On 5/24/21 5:42 PM, David Gow wrote:
> > On Tue, May 25, 2021 at 7:38 AM Daniel Latypov <dlatypov@google.com> wrote:
> >>
> >> On Mon, May 24, 2021 at 4:30 PM Randy Dunlap <rdunlap@infradead.org> wrote:
> >>>
> >>> On 5/24/21 3:56 PM, Daniel Latypov wrote:
> >>>> On Mon, May 24, 2021 at 3:04 PM Randy Dunlap <rdunlap@infradead.org> wrote:
> >>>>>
> >>>>> On 5/24/21 9:55 AM, Daniel Latypov wrote:
> >>>>>> diff --git a/lib/math/Kconfig b/lib/math/Kconfig
> >>>>>> index f19bc9734fa7..20460b567493 100644
> >>>>>> --- a/lib/math/Kconfig
> >>>>>> +++ b/lib/math/Kconfig
> >>>>>> @@ -15,3 +15,14 @@ config PRIME_NUMBERS
> >>>>>>
> >>>>>>  config RATIONAL
> >>>>>>         bool
> >>>>>> +
> >>>>>> +config RATIONAL_KUNIT_TEST
> >>>>>> +       tristate "KUnit test for rational number support" if !KUNIT_ALL_TESTS
> >>>>>> +       # depends on KUNIT && RATIONAL  # this is how it should work, but
> >>>>>> +       depends on KUNIT
> >>>>>> +       select RATIONAL # I don't grok kconfig enough to know why this
> >>>>>
> >>>>> Only to set the symbol CONFIG_RATIONAL.
> >>>>> Then when 'make' descends into the lib/math/ subdir and looks at its Makefile,
> >>>>> it will decide to build the binary rational.o.
> >>>>>
> >>>>> obj-$(CONFIG_RATIONAL)          += rational.o
> >>>>>
> >>>>
> >>>> Ack, I understand that much.
> >>>
> >>> Oh! Clearly I misunderstood the problem.
> >>>
> >>> I had to look thru 60 config files before I found one where CONFIG_RATIONAL
> >>> was not set.
> >>>
> >>> And I'm still not sure, but I believe that it's because it has to be set
> >>> by some other Kconfig entry doing a 'select' on it.
> >>>
> >>> Here are the kconfigs that select it (on i386, where I found it not set):
> >>>
> >>> - COMMON_CLK [=n] && !HAVE_LEGACY_CLK [=n]
> >>> - SERIAL_8250_LPSS [=n] && TTY [=n] && HAS_IOMEM [=y] && SERIAL_8250 [=n] && PCI [=n] && (X86 [=y] || COMPILE_TEST [=y])
> >>> - SERIAL_8250_MID [=n] && TTY [=n] && HAS_IOMEM [=y] && SERIAL_8250 [=n] && PCI [=n] && (X86 [=y] || COMPILE_TEST [=y])
> >>> - SERIAL_IMX [=n] && TTY [=n] && HAS_IOMEM [=y] && (ARCH_MXC || COMPILE_TEST [=y])
> >>> - VIDEO_V4L2 [=n] && MEDIA_SUPPORT [=n] && (I2C [=y] || I2C [=y]=n) && VIDEO_DEV [=n]
> >>> - SND_SOC_ROCKCHIP_PDM [=n] && SOUND [=n] && !UML && SND [=n] && SND_SOC [=n] && CLKDEV_LOOKUP [=n] && SND_SOC_ROCKCHIP [=n]
> >>> - COMMON_CLK_QCOM [=n] && COMMON_CLK [=n] && OF [=y] && (ARCH_QCOM || COMPILE_TEST [=y])
> >>>
> >>> but my test config has none of those enabled, so I cannot set RATIONAL.
> >>>
> >>> I guess the easiest solution is to have KUNIT or some sub-KUNIT test
> >>> just select RATIONAL.
> >>
> >> Yeah, the easiest thing would be to keep the `select RATIONAL` that I
> >> showed in the example patch.
> >>
> >> +David Gow +Brendan Higgins as they both particularly wanted to avoid
> >> having any tests `select` their dependencies, however.
> >>
> >
> > This came from a thread[1], and one of the causes behind it was not
> > wanting to have KUNIT_ALL_TESTS enable things like filesystems and
> > drivers which wouldn't otherwise be built.
>
> Ah yes, I recognize that thread.
>
> > Personally, I think that RATIONAL is probably an okay thing to select
> > here: it's not as heavyweight as drivers/filesystems/etc, and our
> > general guidance here is "avoid select where sensible to do so", not
> > "don't use it under any circumstances".
>
> RATIONAL does not have a prompt string, so depending on it would not
> be reliable.  I.e., it is meant to be selected.

Yeah: let's just select it then.

It's better to have KUNIT_ALL_TESTS pull in something extra than to
have tests we've no reliable way of enabling, IMHO.

> > The other option would be to have a separate config entry which just
> > selected RATIONAL, but even I think that's probably uglier, however
> > nice it is for guaranteeing flexibility.
>
> Yes, that's even worse.
>
> > [1]: https://lore.kernel.org/linux-ext4/52959e99-4105-3de9-730c-c46894b82bdd@infradead.org/T/#t
> >
> >>>
> >>>> My confusion is why this doesn't work:
> >>>>
> >>>> $ ./tools/testing/kunit/kunit.py run --kunitconfig /dev/stdin <<EOF
> >>>> CONFIG_KUNIT=y
> >>>> CONFIG_RATIONAL=y
> >>>> EOF
> >>>> ...
> >>>> ERROR:root:Provided Kconfig is not contained in validated .config.
> >>>> Following fields found in kunitconfig, but not in .config:
> >>>> CONFIG_RATIONAL=y
> >>>>
> >>>> What it's complaining about is that `make  ARCH=um olddefconfig` is
> >>>> leaving CONFIG_RATIONAL=y unset.
> >>>>
> >>>> Stripping out kunit.py, it's this:
> >>>>
> >>>> $ echo -e 'CONFIG_KUNIT=y\nCONFIG_RATIONAL=y' > .kunit/.config
> >>>> $ make ARCH=um olddefconfig O=.kunit
> >>>> $ grep RATIONAL .kunit/.config
> >>>>
> >>>> I'm not versed in Kconfig enough to know why CONFIG_RATIONAL=y is
> >>>> getting removed.
> >>>>
> >>>>>
> >>>>>> is necessary
> >>>>>> +       default KUNIT_ALL_TESTS
> >>>>>> +       help
> >>>>>> +               This builds unit tests for the rational number support.
> >>>>>> +
> >>>>>> +               If unsure, say N.
>
>
> --
> ~Randy
>

  reply	other threads:[~2021-05-25  1:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-23  0:18 [PATCH] lib/math/rational.c: Fix divide by zero Trent Piepho
2021-05-24 10:51 ` Andy Shevchenko
2021-05-24 16:55   ` Daniel Latypov
2021-05-24 22:04     ` Randy Dunlap
2021-05-24 22:56       ` Daniel Latypov
2021-05-24 23:30         ` Randy Dunlap
2021-05-24 23:38           ` Daniel Latypov
2021-05-25  0:42             ` David Gow
2021-05-25  1:49               ` Randy Dunlap
2021-05-25  1:57                 ` David Gow [this message]
2021-05-25  5:08                 ` Trent Piepho
2021-05-24 20:17   ` Trent Piepho
2021-05-24 20:35     ` Daniel Latypov
2021-05-25  9:02     ` Andy Shevchenko
2021-05-25  9:21       ` Trent Piepho
2021-05-25 12:03         ` Andy Shevchenko
2021-05-25 17:10       ` Daniel Latypov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABVgOSmTq37kVdvq0f1xmA-BVJ5k_z=QqZRE6DTkRZk-PaLJtg@mail.gmail.com' \
    --to=davidgow@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=brendanhiggins@google.com \
    --cc=dlatypov@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oskar@scara.com \
    --cc=rdunlap@infradead.org \
    --cc=tpiepho@gmail.com \
    --cc=yguoaz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).