linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kfence: test: fail fast if disabled at boot
@ 2021-08-25 10:55 Marco Elver
  2021-08-25 10:57 ` Alexander Potapenko
  2021-08-26  4:21 ` Kefeng Wang
  0 siblings, 2 replies; 3+ messages in thread
From: Marco Elver @ 2021-08-25 10:55 UTC (permalink / raw)
  To: elver, akpm
  Cc: glider, dvyukov, linux-kernel, linux-mm, kasan-dev, Kefeng Wang

Fail kfence_test fast if KFENCE was disabled at boot, instead of each
test case trying several seconds to allocate from KFENCE and failing.
KUnit will fail all test cases if kunit_suite::init returns an error.

Even if KFENCE was disabled, we still want the test to fail, so that CI
systems that parse KUnit output will alert on KFENCE being disabled
(accidentally or otherwise).

Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Marco Elver <elver@google.com>
---
 mm/kfence/kfence_test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c
index eb6307c199ea..f1690cf54199 100644
--- a/mm/kfence/kfence_test.c
+++ b/mm/kfence/kfence_test.c
@@ -800,6 +800,9 @@ static int test_init(struct kunit *test)
 	unsigned long flags;
 	int i;
 
+	if (!__kfence_pool)
+		return -EINVAL;
+
 	spin_lock_irqsave(&observed.lock, flags);
 	for (i = 0; i < ARRAY_SIZE(observed.lines); i++)
 		observed.lines[i][0] = '\0';
-- 
2.33.0.rc2.250.ged5fa647cd-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kfence: test: fail fast if disabled at boot
  2021-08-25 10:55 [PATCH] kfence: test: fail fast if disabled at boot Marco Elver
@ 2021-08-25 10:57 ` Alexander Potapenko
  2021-08-26  4:21 ` Kefeng Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Potapenko @ 2021-08-25 10:57 UTC (permalink / raw)
  To: Marco Elver
  Cc: Andrew Morton, Dmitriy Vyukov, LKML,
	Linux Memory Management List, kasan-dev, Kefeng Wang

On Wed, Aug 25, 2021 at 12:55 PM Marco Elver <elver@google.com> wrote:
>
> Fail kfence_test fast if KFENCE was disabled at boot, instead of each
> test case trying several seconds to allocate from KFENCE and failing.
> KUnit will fail all test cases if kunit_suite::init returns an error.
>
> Even if KFENCE was disabled, we still want the test to fail, so that CI
> systems that parse KUnit output will alert on KFENCE being disabled
> (accidentally or otherwise).
>
> Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Signed-off-by: Marco Elver <elver@google.com>
Acked-by: Alexander Potapenko <glider@google.com>


> ---
>  mm/kfence/kfence_test.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c
> index eb6307c199ea..f1690cf54199 100644
> --- a/mm/kfence/kfence_test.c
> +++ b/mm/kfence/kfence_test.c
> @@ -800,6 +800,9 @@ static int test_init(struct kunit *test)
>         unsigned long flags;
>         int i;
>
> +       if (!__kfence_pool)
> +               return -EINVAL;
> +
>         spin_lock_irqsave(&observed.lock, flags);
>         for (i = 0; i < ARRAY_SIZE(observed.lines); i++)
>                 observed.lines[i][0] = '\0';
> --
> 2.33.0.rc2.250.ged5fa647cd-goog
>


-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kfence: test: fail fast if disabled at boot
  2021-08-25 10:55 [PATCH] kfence: test: fail fast if disabled at boot Marco Elver
  2021-08-25 10:57 ` Alexander Potapenko
@ 2021-08-26  4:21 ` Kefeng Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Kefeng Wang @ 2021-08-26  4:21 UTC (permalink / raw)
  To: Marco Elver, akpm; +Cc: glider, dvyukov, linux-kernel, linux-mm, kasan-dev


On 2021/8/25 18:55, Marco Elver wrote:
> Fail kfence_test fast if KFENCE was disabled at boot, instead of each
> test case trying several seconds to allocate from KFENCE and failing.
> KUnit will fail all test cases if kunit_suite::init returns an error.
>
> Even if KFENCE was disabled, we still want the test to fail, so that CI
> systems that parse KUnit output will alert on KFENCE being disabled
> (accidentally or otherwise).
>
> Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Signed-off-by: Marco Elver <elver@google.com>

Finally find this, it's better, and tested, thanks


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-26  4:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 10:55 [PATCH] kfence: test: fail fast if disabled at boot Marco Elver
2021-08-25 10:57 ` Alexander Potapenko
2021-08-26  4:21 ` Kefeng Wang

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).