]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
x86: Use printk_once() instead of opencoding it
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 10 May 2023 19:21:12 +0000 (20:21 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 20 Jun 2023 16:20:01 +0000 (17:20 +0100)
Technically our helper post-dates all of these examples, but it's good cleanup
nevertheless.  None of these examples should be using fully locked
test_and_set_bool() in the first place.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/cpu/amd.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/srat.c
xen/arch/x86/time.c

index 0d3143031b5b66faa10e04aa9608842bdedc4f03..0eaef82e514536d5deab806e2bdc410576233eae 100644 (file)
@@ -493,7 +493,6 @@ void amd_check_disable_c1e(unsigned int port, u8 value)
 static void check_syscfg_dram_mod_en(void)
 {
        uint64_t syscfg;
-       static bool_t printed = 0;
 
        if (!((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
                (boot_cpu_data.x86 >= 0x0f)))
@@ -503,9 +502,7 @@ static void check_syscfg_dram_mod_en(void)
        if (!(syscfg & SYSCFG_MTRR_FIX_DRAM_MOD_EN))
                return;
 
-       if (!test_and_set_bool(printed))
-               printk(KERN_ERR "MTRR: SYSCFG[MtrrFixDramModEn] not "
-                       "cleared by BIOS, clearing this bit\n");
+        printk_once(KERN_ERR "MTRR: SYSCFG[MtrrFixDramModEn] found set; clearing\n");
 
        syscfg &= ~SYSCFG_MTRR_FIX_DRAM_MOD_EN;
        wrmsrl(MSR_K8_SYSCFG, syscfg);
@@ -1107,25 +1104,19 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 
                rdmsrl(MSR_AMD64_LS_CFG, value);
                if (!(value & (1 << 15))) {
-                       static bool_t warned;
-
-                       if (c == &boot_cpu_data || opt_cpu_info ||
-                           !test_and_set_bool(warned))
-                               printk(KERN_WARNING
-                                      "CPU%u: Applying workaround for erratum 793\n",
-                                      smp_processor_id());
+                       if (c == &boot_cpu_data || opt_cpu_info)
+                               printk_once(XENLOG_WARNING
+                                           "CPU%u: Applying workaround for erratum 793\n",
+                                           smp_processor_id());
                        wrmsrl(MSR_AMD64_LS_CFG, value | (1 << 15));
                }
        } else if (c->x86 == 0x12) {
                rdmsrl(MSR_AMD64_DE_CFG, value);
                if (!(value & (1U << 31))) {
-                       static bool warned;
-
-                       if (c == &boot_cpu_data || opt_cpu_info ||
-                           !test_and_set_bool(warned))
-                               printk(KERN_WARNING
-                                      "CPU%u: Applying workaround for erratum 665\n",
-                                      smp_processor_id());
+                       if (c == &boot_cpu_data || opt_cpu_info)
+                               printk_once(XENLOG_WARNING
+                                           "CPU%u: Applying workaround for erratum 665\n",
+                                           smp_processor_id());
                        wrmsrl(MSR_AMD64_DE_CFG, value | (1U << 31));
                }
        }
index 40767b94c30b3593021bf3fa2d9723ce36d88f1d..c686e6990cc9f1377e74760617f793bed535874a 100644 (file)
@@ -1207,16 +1207,11 @@ static void cf_check vmx_get_segment_register(
      */
     if ( unlikely(!vmx_vmcs_try_enter(v)) )
     {
-        static bool_t warned;
+        printk_once(XENLOG_WARNING "Segment register inaccessible for %pv\n"
+                    "(If you see this outside of debugging activity,"
+                    " please report to xen-devel@lists.xenproject.org)\n",
+                    v);
 
-        if ( !warned )
-        {
-            warned = 1;
-            printk(XENLOG_WARNING "Segment register inaccessible for %pv\n"
-                   "(If you see this outside of debugging activity,"
-                   " please report to xen-devel@lists.xenproject.org)\n",
-                   v);
-        }
         memset(reg, 0, sizeof(*reg));
         return;
     }
@@ -2325,10 +2320,9 @@ static bool cf_check vmx_test_pir(const struct vcpu *v, uint8_t vec)
 static void cf_check vmx_handle_eoi(uint8_t vector, int isr)
 {
     uint8_t old_svi = set_svi(isr);
-    static bool warned;
 
-    if ( vector != old_svi && !test_and_set_bool(warned) )
-        printk(XENLOG_WARNING "EOI for %02x but SVI=%02x\n", vector, old_svi);
+    if ( vector != old_svi )
+        printk_once(XENLOG_WARNING "EOI for %02x but SVI=%02x\n", vector, old_svi);
 }
 
 static void cf_check vmx_enable_msr_interception(struct domain *d, uint32_t msr)
index 56749ddca526933a685c04a253a3336a11322705..3f70338e6e235079ff262fa1fd212cf5b3c301c5 100644 (file)
@@ -55,7 +55,6 @@ nodeid_t setup_node(unsigned pxm)
 {
        nodeid_t node;
        unsigned idx;
-       static bool warned;
        static unsigned nodes_found;
 
        BUILD_BUG_ON(MAX_NUMNODES >= NUMA_NO_NODE);
@@ -75,11 +74,8 @@ nodeid_t setup_node(unsigned pxm)
                if (pxm2node[idx].node == NUMA_NO_NODE)
                        goto finish;
 
-       if (!warned) {
-               printk(KERN_WARNING "SRAT: Too many proximity domains (%#x)\n",
-                      pxm);
-               warned = true;
-       }
+       printk_once(XENLOG_WARNING "SRAT: Too many proximity domains (%#x)\n",
+                   pxm);
 
        return NUMA_NO_NODE;
 
index bc75e1ae7d42b7e89a33e43326ed77c0ae619335..f5e30d4e02368c655469e642c4d04af3f11301df 100644 (file)
@@ -876,13 +876,8 @@ static void cf_check plt_overflow(void *unused)
         plt_stamp64 += plt_mask + 1;
     }
     if ( i != 0 )
-    {
-        static bool warned_once;
-
-        if ( !test_and_set_bool(warned_once) )
-            printk("Platform timer appears to have unexpectedly wrapped "
-                   "%u%s times.\n", i, (i == 10) ? " or more" : "");
-    }
+        printk_once("Platform timer appears to have unexpectedly wrapped "
+                    "%u%s times.\n", i, (i == 10) ? " or more" : "");
 
     spin_unlock_irq(&platform_timer_lock);
 
@@ -2156,14 +2151,8 @@ void init_percpu_time(void)
         }
         else if ( adj != tsc_adjust[socket] )
         {
-            static bool __read_mostly warned;
-
-            if ( !warned )
-            {
-                warned = true;
-                printk(XENLOG_WARNING
-                       "Differing TSC ADJUST values within socket(s) - fixing all\n");
-            }
+            printk_once(XENLOG_WARNING
+                        "Differing TSC ADJUST values within socket(s) - fixing all\n");
             wrmsrl(MSR_IA32_TSC_ADJUST, tsc_adjust[socket]);
         }
     }