Skip to contentSkip to conversation

kfence: test: fail fast if disabled at boot

PATCH Applied Marco Elver 3 participants 3 messages Aug 25, 2021 – Aug 26, 2021

Subsystems (2)
lore
Share & tools
lore

Marco Elver

author maintainer
#0 lore raw

PATCH 1/1 kfence: test: fail fast if disabled at boot

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

---
 mm/kfence/kfence_test.c | 3 +++
 1 file changed, 3 insertions(+)
mm/kfence/kfence_test.c +3 -0
index eb6307c199ea..f1690cf54199 100644
@@ -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';
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Marco Elver

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

Quoted 21 lines
---
 mm/kfence/kfence_test.c | 3 +++
 1 file changed, 3 insertions(+)
mm/kfence/kfence_test.c +3 -1
index eb6307c199ea..f1690cf54199 100644
@@ -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

Signature · 10 lines
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
#2 lore raw
In reply to Marco Elver
Quoted 10 lines · Marco Elver

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

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