All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch v3 1/2] x86/smp: count the number of online physical processor in the system
@ 2018-05-08 22:01 Chao Gao
  2018-05-08 22:01 ` [Patch v3 2/2] x86/microcode: Synchronize late microcode loading Chao Gao
  2018-05-16 12:54 ` [Patch v3 1/2] x86/smp: count the number of online physical processor in the system Jan Beulich
  0 siblings, 2 replies; 12+ messages in thread
From: Chao Gao @ 2018-05-08 22:01 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Jan Beulich, Chao Gao

Mainly for the patch behind which relies on 'nr_phys_cpus' to estimate
the time needed for microcode update in the worst case.

Signed-off-by: Chao Gao <chao.gao@intel.com>
---
v3:
 - new

---
 xen/arch/x86/smpboot.c    | 13 +++++++++++++
 xen/include/asm-x86/smp.h |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 86fa410..c3c3558 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -67,6 +67,8 @@ unsigned int __read_mostly nr_sockets;
 cpumask_t **__read_mostly socket_cpumask;
 static cpumask_t *secondary_socket_cpumask;
 
+unsigned int __read_mostly nr_phys_cpus;
+
 struct cpuinfo_x86 cpu_data[NR_CPUS];
 
 u32 x86_cpu_to_apicid[NR_CPUS] __read_mostly =
@@ -262,6 +264,10 @@ static void set_cpu_sibling_map(int cpu)
         cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
     }
 
+    /* Increase physical processor count when a new cpu comes up */
+    if ( cpumask_weight(per_cpu(cpu_sibling_mask, cpu)) == 1 )
+        nr_phys_cpus++;
+
     if ( c[cpu].x86_max_cores == 1 )
     {
         cpumask_copy(per_cpu(cpu_core_mask, cpu),
@@ -1156,6 +1162,13 @@ remove_siblinginfo(int cpu)
             cpu_data[sibling].booted_cores--;
     }
 
+    /*
+     * Decrease physical processor count when all threads of a physical
+     * processor go down
+     */
+    if ( cpumask_weight(per_cpu(cpu_sibling_mask, cpu)) == 1 )
+        nr_phys_cpus--;
+
     for_each_cpu(sibling, per_cpu(cpu_sibling_mask, cpu))
         cpumask_clear_cpu(cpu, per_cpu(cpu_sibling_mask, sibling));
     cpumask_clear(per_cpu(cpu_sibling_mask, cpu));
diff --git a/xen/include/asm-x86/smp.h b/xen/include/asm-x86/smp.h
index 4e5f673..910888a 100644
--- a/xen/include/asm-x86/smp.h
+++ b/xen/include/asm-x86/smp.h
@@ -65,6 +65,9 @@ uint32_t get_cur_idle_nums(void);
  */
 extern unsigned int nr_sockets;
 
+/* The number of online physical CPUs in this system */
+extern unsigned int nr_phys_cpus;
+
 void set_nr_sockets(void);
 
 /* Representing HT and core siblings in each socket. */
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-11-13  9:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-08 22:01 [Patch v3 1/2] x86/smp: count the number of online physical processor in the system Chao Gao
2018-05-08 22:01 ` [Patch v3 2/2] x86/microcode: Synchronize late microcode loading Chao Gao
2018-05-16 13:10   ` Jan Beulich
2018-05-16 13:25     ` Andrew Cooper
2018-05-16 13:46       ` Jan Beulich
2018-05-18  7:21         ` Chao Gao
2018-05-22  8:59           ` Chao Gao
2018-05-22  9:26             ` Jan Beulich
2018-05-22 20:14               ` Raj, Ashok
2018-11-13  9:08   ` Chao Gao
2018-11-13  9:09     ` Andrew Cooper
2018-05-16 12:54 ` [Patch v3 1/2] x86/smp: count the number of online physical processor in the system Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.