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

Re: [PATCH v2] core-parking: shrink core_parking_cpunum[]


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 10 Mar 2026 10:56:10 +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=lEbQUuU1SGwprGIKvAjqcdRp4avOR0fy/79RpehbaYk=; b=xDBx3du19HL1q1jq4MpDv570OJK6+iDT3nS4tbGLxQkqhhfGnWIV4ao3nH7wHoPFwKW49SRgcQWSfmbmQ9g6lpEuTgpZenI78UpUSirCGKwrv4X7Cje/5ou0raYY1/TrCeHoFXk3Xup0zBQW4QgeMwoWDSce8j2+4cQVpGQKvo/+0xJWPiamFabkesdHzz7UZ2QaLKXZemS2bGhBHF6a9UV/vTKcf3mp957wRaKHowO8rrWfJJY8f5YUhnNPcX6Ss6KDseE/5OS0RGlYTzvRqzt7EKV6/9ohTmrp1+QrW8fiBZbMsqzn4x4EHlY18Ha24HsueLBij6R2yQCfExB5KA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ASc4FhDSWb36YGyDh8oet+7fcVfQQvpDA4JoAbPzTnwSJJgAAMBAheiM7beMvjPlHERnzOWkefgxk0w9ZhcsNUKdzl+URzJY+4OgPlz//j20NjQp4fixFl/30vCFh8TFTK26HXwXl3XRc6ZYloulZDdHPOK6WnFHKUcEUGACEu8Ru1ZTeJB0cCKtNANAb3UgKBykwaqVWzyI76Ml0qrYsdaS0AcFFWFH8ej93xsCw7DfFt82ntHaU738hPSqa6bNove0iIKNAZ9A0PE9++lGfyAiP69yBdP6FWt550X80mi5lCpe43g7RLWnQH1uEYHbxlvlI52IIHj8jP4vgUeqow==
  • 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: Tue, 10 Mar 2026 09:56:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Mar 10, 2026 at 10:20:53AM +0100, Jan Beulich wrote:
> On 10.03.2026 10:07, Roger Pau Monné wrote:
> > You possibly want to adjust the subject, instead of shrink I would use
> > "dynamically allocate" or similar.
> 
> I've changed it, albeit the goal really is the shrinking.
> 
> > On Mon, Mar 09, 2026 at 04:35:34PM +0100, Jan Beulich wrote:
> >> --- a/xen/common/core_parking.c
> >> +++ b/xen/common/core_parking.c
> >> @@ -20,6 +20,7 @@
> >>  #include <xen/cpumask.h>
> >>  #include <xen/init.h>
> >>  #include <xen/param.h>
> >> +#include <xen/xvmalloc.h>
> >>  
> >>  #include <asm/smp.h>
> >>  
> >> @@ -27,8 +28,8 @@
> >>  #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 unsigned int *__ro_after_init core_parking_cpunum;
> > 
> > Don't you need some kind of check in core_parking_remove() to prevent a
> > NULL pointer dereference if core_parking_cpunum hasn't been allocated?
> > 
> > Callers of XEN_SYSCTL_cpu_hotplug can set fn = smt_up_down_helper, and
> > that would call core_parking_remove().  core_parking_helper() already
> > contains a check that prevents accessing core_parking_cpunum if no
> > policy has been registered.
> 
> Because of this check, cur_idle_nums can never become non-zero when the
> array couldn't be allocated. Hence core_parking_remove() will be a
> somewhat expensive no-op in that case, with no deref of core_parking_cpunum.

Oh, I see, both loops in core_parking_remove() are bounded to
cur_idle_nums.

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks, Roger.



 


Rackspace

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