lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9b4e181abab0bec20dae93d35fe962b8167c73c9.camel@svanheule.net>
Date:   Wed, 20 Jul 2022 14:43:49 +0200
From:   Sander Vanheule <sander@...nheule.net>
To:     David Gow <davidgow@...gle.com>,
        Maíra Canal <mairacanal@...eup.net>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        bp@...en8.de, dave.hansen@...ux.intel.com,
        Marco Elver <elver@...gle.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>, hpa@...or.com,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>, tglx@...utronix.de,
        vschneid@...hat.com, x86@...nel.org, yury.norov@...il.com,
        Brendan Higgins <brendanhiggins@...gle.com>
Subject: Re: [PATCH v4 3/5] lib/test: Introduce cpumask KUnit test suite

Hi David, Maíra,

On Wed, 2022-07-20 at 13:24 +0800, David Gow wrote:
> On Wed, Jul 20, 2022 at 5:31 AM Maíra Canal <mairacanal@...eup.net> wrote:
> > 
> > > Add a basic suite of tests for cpumask, providing some tests for empty
> > > and completely filled cpumasks.
> > > 
> > > Signed-off-by: Sander Vanheule <sander@...nheule.net>
> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> > 
> > The tests test_cpumask_weight and test_cpumask_last are failing on all
> > architectures, as can be seen on [1]. Also this test doesn't follow the
> > standard style for KUnit tests [2].
> > 
> > [1]
> > https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20220718/testrun/10865066/suite/kunit/tests/
> > [2] https://docs.kernel.org/dev-tools/kunit/style.html
> > 
> > CC: Brendan Higgins <brendanhiggins@...gle.com>
> > CC: David Gow <davidgow@...gle.com>
> > 
> > Best Regards,
> > - Maíra Canal
> > 
> 
> Hmm... this test passes on the default kunit_tool configs for UML and
> x86_64, which are all without SMP.
> 
> It looks like the flaw is that, if CONFIG_NR_CPUS is greater than the
> actual number of CPUs present, then the cpu_possible_mask (correctly)
> won't be full.
> 
> I'm not sure what the right fix is: but removing the checks for
> cpu_possible_mask being full is probably the way to go. Unless we want
> to plumb through some actual detail about the underlying system and
> check against that, it doesn't make sense. (Or, we could generate an
> artificial "possilbe_mask" which is always full, and test the cpu
> against that. But we sort-of already do that with mask_all anyway.)

The description of cpu_possible_mask does indeed allow for it to not be filled
completely.

> 
> So, my recommendation for a fix would be:
> - Get rid of "KUNIT_EXPECT_TRUE(test, cpumask_full(cpu_possible_mask));"

As per the above, I'll remove this (faulty) check.

> - Replace "KUNIT_EXPECT_EQ(test, nr_cpumask_bits - 1,
> cpumask_last(cpu_possible_mask));" with a KUNIT_EXPECT_GE()

I think we can actually use KUNIT_EXPECT_EQ(test, nr_cpu_ids - 1, ...) here.

Since cpumask_first() on the same mask must return at most nr_cpu_ids - 1 for a
valid result, cpumask_last() cannot return anything larger than this value. 
This implies that cpu_possible_mask cannot contain gaps if its weight equals
nr_cpu_ids (which is checked in test_cpumask_weight).

> - _Maybe_ add some debug logging with the cpumask value being checked,
> as it's a pain to tell from the expectation failure messages. e.g.,
> kunit_info(test, "cpu_possible_mask = '%*pb[l]'\n",
> cpumask_pr_args(cpu_possible_mask));

That would be a useful addition, I'll see where I can add it.

Best,
Sander
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ