[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] xen/lib: Introduce printk_once() and replace some opencoded examples
commit a5ae5b67a926f34fb369fdaa7327a2f70b1c2c20 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Fri May 17 19:30:47 2019 +0100 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Fri May 31 19:11:29 2019 +0100 xen/lib: Introduce printk_once() and replace some opencoded examples Reflow the ZynqMP message for grepability, and fix the omission of a newline. There is a race condition where multiple cpus could race to set once_ boolean. However, the use of this construct is mainly useful for boot time code, and the only consequence of the race is a repeated print message. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Julien Grall <julien.grall@xxxxxxx> --- xen/arch/arm/cpuerrata.c | 18 ++---------------- xen/arch/arm/platforms/xilinx-zynqmp.c | 9 ++------- xen/include/xen/lib.h | 11 +++++++++++ 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/cpuerrata.c b/xen/arch/arm/cpuerrata.c index 4431b244fd..8904939aca 100644 --- a/xen/arch/arm/cpuerrata.c +++ b/xen/arch/arm/cpuerrata.c @@ -336,18 +336,11 @@ static bool has_ssbd_mitigation(const struct arm_cpu_capabilities *entry) switch ( ssbd_state ) { case ARM_SSBD_FORCE_DISABLE: - { - static bool once = true; - - if ( once ) - printk("%s disabled from command-line\n", entry->desc); - once = false; + printk_once("%s disabled from command-line\n", entry->desc); arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 0, NULL); required = false; - break; - } case ARM_SSBD_RUNTIME: if ( required ) @@ -359,18 +352,11 @@ static bool has_ssbd_mitigation(const struct arm_cpu_capabilities *entry) break; case ARM_SSBD_FORCE_ENABLE: - { - static bool once = true; - - if ( once ) - printk("%s forced from command-line\n", entry->desc); - once = false; + printk_once("%s forced from command-line\n", entry->desc); arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL); required = true; - break; - } default: ASSERT_UNREACHABLE(); diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c b/xen/arch/arm/platforms/xilinx-zynqmp.c index 08e3e11e1b..3060d79b34 100644 --- a/xen/arch/arm/platforms/xilinx-zynqmp.c +++ b/xen/arch/arm/platforms/xilinx-zynqmp.c @@ -35,14 +35,9 @@ static bool zynqmp_smc(struct cpu_user_regs *regs) */ if ( !cpus_have_const_cap(ARM_SMCCC_1_1) ) { - static bool once = true; + printk_once(XENLOG_WARNING + "ZynqMP firmware Error: no SMCCC 1.1 support. Disabling firmware calls\n"); - if ( once ) - { - printk(XENLOG_WARNING "ZynqMP firmware Error: no SMCCC 1.1 " - "support. Disabling firmware calls."); - once = false; - } return false; } return zynqmp_eemi(regs); diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 91ed56c703..ce231c5f4f 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -105,6 +105,17 @@ debugtrace_printk(const char *fmt, ...) {} #define _p(_x) ((void *)(unsigned long)(_x)) extern void printk(const char *format, ...) __attribute__ ((format (printf, 1, 2))); + +#define printk_once(fmt, args...) \ +({ \ + static bool __read_mostly once_; \ + if ( unlikely(!once_) ) \ + { \ + once_ = true; \ + printk(fmt, ## args); \ + } \ +}) + extern void guest_printk(const struct domain *d, const char *format, ...) __attribute__ ((format (printf, 2, 3))); extern void noreturn panic(const char *format, ...) -- generated by git-patchbot for /home/xen/git/xen.git#staging _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |