Skip to content

Commit 05279a2

Browse files
sohilmehIngo Molnar
authored andcommitted
x86/nmi: Clean up NMI selftest
The expected_testcase_failures variable in the NMI selftest has never been set since its introduction. Remove this unused variable along with the related checks to simplify the code. While at it, replace printk() with the corresponding pr_{cont,info}() calls. Also, get rid of the superfluous testname wrapper and the redundant file path comment. Signed-off-by: Sohil Mehta <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7324d7d commit 05279a2

File tree

1 file changed

+16
-36
lines changed

1 file changed

+16
-36
lines changed

arch/x86/kernel/nmi_selftest.c

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* arch/x86/kernel/nmi-selftest.c
4-
*
53
* Testsuite for NMI: IPIs
64
*
75
* Started by Don Zickus:
@@ -30,7 +28,6 @@ static DECLARE_BITMAP(nmi_ipi_mask, NR_CPUS) __initdata;
3028

3129
static int __initdata testcase_total;
3230
static int __initdata testcase_successes;
33-
static int __initdata expected_testcase_failures;
3431
static int __initdata unexpected_testcase_failures;
3532
static int __initdata unexpected_testcase_unknowns;
3633

@@ -120,65 +117,48 @@ static void __init dotest(void (*testcase_fn)(void), int expected)
120117
unexpected_testcase_failures++;
121118

122119
if (nmi_fail == FAILURE)
123-
printk(KERN_CONT "FAILED |");
120+
pr_cont("FAILED |");
124121
else if (nmi_fail == TIMEOUT)
125-
printk(KERN_CONT "TIMEOUT|");
122+
pr_cont("TIMEOUT|");
126123
else
127-
printk(KERN_CONT "ERROR |");
124+
pr_cont("ERROR |");
128125
dump_stack();
129126
} else {
130127
testcase_successes++;
131-
printk(KERN_CONT " ok |");
128+
pr_cont(" ok |");
132129
}
133-
testcase_total++;
130+
pr_cont("\n");
134131

132+
testcase_total++;
135133
reset_nmi();
136134
}
137135

138-
static inline void __init print_testname(const char *testname)
139-
{
140-
printk("%12s:", testname);
141-
}
142-
143136
void __init nmi_selftest(void)
144137
{
145138
init_nmi_testsuite();
146139

147140
/*
148141
* Run the testsuite:
149142
*/
150-
printk("----------------\n");
151-
printk("| NMI testsuite:\n");
152-
printk("--------------------\n");
143+
pr_info("----------------\n");
144+
pr_info("| NMI testsuite:\n");
145+
pr_info("--------------------\n");
153146

154-
print_testname("remote IPI");
147+
pr_info("%12s:", "remote IPI");
155148
dotest(remote_ipi, SUCCESS);
156-
printk(KERN_CONT "\n");
157-
print_testname("local IPI");
149+
150+
pr_info("%12s:", "local IPI");
158151
dotest(local_ipi, SUCCESS);
159-
printk(KERN_CONT "\n");
160152

161153
cleanup_nmi_testsuite();
162154

155+
pr_info("--------------------\n");
163156
if (unexpected_testcase_failures) {
164-
printk("--------------------\n");
165-
printk("BUG: %3d unexpected failures (out of %3d) - debugging disabled! |\n",
157+
pr_info("BUG: %3d unexpected failures (out of %3d) - debugging disabled! |\n",
166158
unexpected_testcase_failures, testcase_total);
167-
printk("-----------------------------------------------------------------\n");
168-
} else if (expected_testcase_failures && testcase_successes) {
169-
printk("--------------------\n");
170-
printk("%3d out of %3d testcases failed, as expected. |\n",
171-
expected_testcase_failures, testcase_total);
172-
printk("----------------------------------------------------\n");
173-
} else if (expected_testcase_failures && !testcase_successes) {
174-
printk("--------------------\n");
175-
printk("All %3d testcases failed, as expected. |\n",
176-
expected_testcase_failures);
177-
printk("----------------------------------------\n");
178159
} else {
179-
printk("--------------------\n");
180-
printk("Good, all %3d testcases passed! |\n",
160+
pr_info("Good, all %3d testcases passed! |\n",
181161
testcase_successes);
182-
printk("---------------------------------\n");
183162
}
163+
pr_info("-----------------------------------------------------------------\n");
184164
}

0 commit comments

Comments
 (0)