[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] core-parking: shrink and relocate core_parking_cpunum[]


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 9 Mar 2026 10:21:18 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DCyJRSxi8Ee2tAMTwB+64n2mYRJXbAoslZsTiGaa2TE=; b=JnZASNDYUeSxEiXdV+JGITpkCd3zxbualZcHhswxXaJGCN0f9tZ0c9OnIFhf3q4Up7Foutu6NbFlBPmsHqkNqio+t3JuAOViDsjexZwfk+POAfBvoxkkep7JuY3vYcoFP6CWDJVJOHsNU1rkgWL0kSFCggyb35NQhQdvmHSqLHsJYv24d771DLbXxnXaMgTmah7CTCDpATpN3XAs/Z0zNTgv1z+4YTYdmIe5jQ0vTLT3DICrV8RTeYmmM3VGAWeUEfjVaC82Cb6GFDQa1SVK5ITKUbACj+VeoglPssKPY4CUavFcjRJUKA7lOmCak9Wgi+nQ4My+XmUkwZJHr0WcQQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=giDUUfhdXUGAJg5eIfqbMDYy2HuO4dejAhx6ILZONa8uTpGYvpk4DSuW5eQRnoscqqOjiL1tj1vOMJKBenwrRyJtnfb7sYRLqh+JJ/Al8MtdTCePDHo4Lv439nnclqNHNwo88iah9EubcVFTLf9j/v2d6qGjOOgHqL0tMgCeFs0+RWENvTagJrmY8zS+HuqyvMqf8p6L95mhKf1+tXPxCOVkpaJm3xmhVcg31yuhBXI0iVA0YhU5+cQ6MPDEFsZ5WqkjfpMdl8QcYFQpBIHX4XADAiMydzP39GI+noegW5ztjlwYyNTnMHbvsv6dwZlatU/eDLG8cfFKrhtmfO4q9w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Mon, 09 Mar 2026 09:23:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Mar 09, 2026 at 09:01:35AM +0100, Jan Beulich wrote:
> On 06.03.2026 15:20, Roger Pau Monné wrote:
> > On Wed, Nov 12, 2025 at 04:38:13PM +0100, Jan Beulich wrote:
> >> 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@xxxxxxxx>
> >> ---
> >> 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.
> > 
> > Can't we just allocate this memory using xvzalloc_array()?  If we do
> > care about it being too big certainly allocating only when needed, and
> > based on the number of possible CPUs on the system would be much
> > better than playing games with the array type?
> 
> Hmm, yes, how did it not occur to me to dynamically allocate the array?
> It can't be used ahead of core_parking_init(). (Not shrinking the array
> element type will still be a little wasteful, but perhaps that's
> acceptable to keep the code simple.)

We don't shrink other similar element types based on the supported CPU
count.  Iff we ever wanted to do this (which I'm not sure) we should
introduce a new typedef that generalizes the optimization rather than
open coding it (ie: cpu_id_t or similar?)

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.