All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] core-parking: shrink and relocate core_parking_cpunum[]
@ 2025-11-12 15:38 Jan Beulich
  2026-03-06 14:20 ` Roger Pau Monné
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2025-11-12 15:38 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
	Michal Orzel, Roger Pau Monné

This NR_CPUS-dimensioned array is likely unused on most installations.
Therefore it is especially wasteful for it to consume more space than
really needed. Use the smallest possible type.

Further the array having all fields set to -1 is actually useless. Nothing
relies on it, and core_parking_remove() doesn't restore the sentinel for
vacated slots. Drop the initializers, moving the array to .bss.

Finally take the opportunity and update an adjacent variable's type, where
a fixed-width type was pretty clearly inappropriate to use.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
I assume there is a reason this is acting (mostly) as a LIFO. Else a
simple cpumask_t would suffice.

An alternative would be to use the new BRK allocator, at least for NR_CPUS
above a certain threshold.

--- a/xen/common/core_parking.c
+++ b/xen/common/core_parking.c
@@ -27,8 +27,16 @@
 #define CORE_PARKING_DECREMENT 2
 
 static DEFINE_SPINLOCK(accounting_lock);
-static uint32_t cur_idle_nums;
-static unsigned int core_parking_cpunum[NR_CPUS] = {[0 ... NR_CPUS-1] = -1};
+static unsigned int cur_idle_nums;
+static
+#if CONFIG_NR_CPUS <= (1U << BITS_PER_BYTE)
+    unsigned char
+#elif CONFIG_NR_CPUS <= (1U << (BITS_PER_BYTE * __SIZEOF_SHORT__))
+    unsigned short
+#else
+    unsigned int
+#endif
+    core_parking_cpunum[CONFIG_NR_CPUS];
 
 struct cp_policy {
     char name[30];


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

end of thread, other threads:[~2026-03-09  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-12 15:38 [PATCH] core-parking: shrink and relocate core_parking_cpunum[] Jan Beulich
2026-03-06 14:20 ` Roger Pau Monné
2026-03-09  8:01   ` Jan Beulich
2026-03-09  9:21     ` Roger Pau Monné

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.