aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-07-05 12:50:20 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2020-07-05 12:50:20 -0700
commitbb5a93aaf25261321db0c499cde7da6ee9d8b164 (patch)
treec99e1b0fea8e3d3fe0b6013a550203ac8b740997
parent72674d480076067d627e708c0a062dd900438bd7 (diff)
downloadlinux-stericsson-bb5a93aaf25261321db0c499cde7da6ee9d8b164.tar.gz
x86/ldt: use "pr_info_once()" instead of open-coding it badly
Using a mutex for "print this warning only once" is so overdesigned as to be actively offensive to my sensitive stomach. Just use "pr_info_once()" that already does this, although in a (harmlessly) racy manner that can in theory cause the message to be printed twice if more than one CPU races on that "is this the first time" test. [ If somebody really cares about that harmless data race (which sounds very unlikely indeed), that person can trivially fix printk_once() by using a simple atomic access, preferably with an optimistic non-atomic test first before even bothering to treat the pointless "make sure it is _really_ just once" case. A mutex is most definitely never the right primitive to use for something like this. ] Yes, this is a small and meaningless detail in a code path that hardly matters. But let's keep some code quality standards here, and not accept outrageously bad code. Link: https://lore.kernel.org/lkml/CAHk-=wgV9toS7GU3KmNpj8hCS9SeF+A0voHS8F275_mgLhL4Lw@mail.gmail.com/ Cc: Andy Lutomirski <luto@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/x86/kernel/ldt.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 34e918ad34d4..b8aee71840ae 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -559,16 +559,7 @@ static bool allow_16bit_segments(void)
* is worthwhile, disallow 16-bit segments under Xen PV.
*/
if (xen_pv_domain()) {
- static DEFINE_MUTEX(xen_warning);
- static bool warned;
-
- mutex_lock(&xen_warning);
- if (!warned) {
- pr_info("Warning: 16-bit segments do not work correctly in a Xen PV guest\n");
- warned = true;
- }
- mutex_unlock(&xen_warning);
-
+ pr_info_once("Warning: 16-bit segments do not work correctly in a Xen PV guest\n");
return false;
}
#endif