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

Re: [PATCH v5 3/5] arm/sysctl: Implement cpu hotplug ops


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Tue, 3 Feb 2026 10:30:31 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=ZuJlEAEZUQfOv4NBsTAQ+dFXfQEQL1xDAZQMohHfLcs=; b=CP3N/h/D5BC6X9hyQMM1hDPetQwK5aMtl3BM5+Nr7Rhm0wNJRKZ5FRlbxwakiqDU91Xwvu5/Tv4S0HM4lJ56jHsMgqAnxNueoS+4XR5L7W5tfu6LWDa2cM+9Spo/xiJeTmQyvixfnutTWD8roALScLZ3Xa83CteRYp7f8AwyhUbZc+Xb82BG2/XWLgOSDXFO/PQS6rNBA5JWMbalwQB2PD/Oqm4+yQoAV5fsXqzaWfpHRNSqR82eYrML6d1EgYuUT3BFK9elggvmzhdRYZ8F0SdtFCv211MjyV0OxDWObUq2Ygxw1npMHVEBt0cc/4qqcKv7iHhURDzT+c7/BD3p0g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bhA5yvmpZE4zW3UILpC95vLObEct038WHF+F2AAEblfwiFbH++zcmoNr8Zf27u2FMHZn7MNTS54B2OQEXEB87iFo/hrGzA+THwasV+2nGshnIWCYQOWRqfkfI6PDf6I/VbWEBqrd9JYdh+CHUlIAt8eVtCYSSplGjXBGspYzmpu8hLNvgCcolDQwM15ULzSRwY9P4J13jQypBqdtPRCN0LIQkwkN49ITJpW9/PqHrjyZb650Qo9mantTW+xlP5cITSvE7+kRVRIG/J6tXNkkTsAfX9UMH/PVWpRss9HA1EC7YOq6fWsLZN7WZ3TPeu8d/543zTddOnYqqxYdIfsVZQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Timothy Pearson <tpearson@xxxxxxxxxxxxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 03 Feb 2026 10:30:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHchGj873UPBMyph02N0fqNmGIWE7VRbWqAgB96AQA=
  • Thread-topic: [PATCH v5 3/5] arm/sysctl: Implement cpu hotplug ops

On 14.01.26 11:49, Jan Beulich wrote:
> On 13.01.2026 09:45, Mykyta Poturai wrote:
>> Move XEN_SYSCTL_CPU_HOTPLUG_{ONLINE,OFFLINE} handlers to common code to
>> allow for enabling/disabling CPU cores in runtime on Arm64.
>>
>> SMT-disable enforcement check is moved into a separate
>> architecture-specific function.
>>
>> For now this operations only support Arm64. For proper Arm32 support,
>> there needs to be a mechanism to free per-cpu page tables, allocated in
>> init_domheap_mappings.  Also, hotplug is not supported if ITS, FFA, or
>> TEE is enabled, as they use non-static IRQ actions.
> 
> For all of these "not supported" cases, what if a user nevertheless tries?
> Wouldn't the request better be outright denied, rather leaving the system in
> a questionable state? Hmm, I see you ...
> 
>> --- a/xen/arch/arm/Kconfig
>> +++ b/xen/arch/arm/Kconfig
>> @@ -7,6 +7,7 @@ config ARM_64
>>      def_bool y
>>      depends on !ARM_32
>>      select 64BIT
>> +    select CPU_HOTPLUG if !TEE && !FFA && !HAS_ITS
> 
> ... make the select conditional. But do TEE, FFA, and HAS_ITS each mean the
> feature is actually in use when the hypervisor runs?
> 
The way interrupts are requested in these modules causes Xen to crash 
when trying to offline a cpu. It’s a fairly simple fix and I plan to 
send them eventually. I’ve decided to omit them now and do these fixes 
only for supported code to keep the series from ballooning with too many 
patches.

>> +    int ret = cpu_up(cpu);
>> +
>> +    /* Have one more go on EBUSY. */
>> +    if ( ret == -EBUSY )
>> +        ret = cpu_up(cpu);
>> +
>> +    if ( !ret && arch_smt_cpu_disable(cpu) )
> 
> As you validly note in a comment in do_sysctl(), SMT is an arch-specific 
> concept
> and perhaps even an arch-specific term. Hence using it in the name of an arch
> hook feels inappropriate. Plus - the hook could be used for other purposes. 
> What
> the arch needs to indicate is whether the CPU that was brought up may actually
> stay online. That more generic purpose is what imo the name wants to cover.
> 

Would arch_cpu_online_allowed() be okay, or maybe you have something 
more specific in mind?


>> +        case XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE:
>> +        case XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE:
>> +            /* Use arch specific handlers as SMT is very arch-dependent */
>> +            ret = arch_do_sysctl(op, u_sysctl);
>> +            copyback = 0;
>> +            goto out;
> 
> I wonder if it wouldn't be neater for this and actually also ...
> 
>> +        default:
>> +            ret = -EOPNOTSUPP;
>> +            break;
> 
> ... this to fall through to ...
> 
>> +        }
>> +
>> +        if ( !ret )
>> +            ret = plug ? xsm_resource_plug_core(XSM_HOOK)
>> +                       : xsm_resource_unplug_core(XSM_HOOK);
>> +
>> +        if ( !ret )
>> +            ret = continue_hypercall_on_cpu(0, fn, hcpu);
>> +        break;
>> +    }
>> +#endif
>> +
>>       default:
>>           ret = arch_do_sysctl(op, u_sysctl);
> 
> ... here. (Minimally the earlier default case wants uniformly forwarding to
> the arch handler, or else arch-specific additions would always require
> adjustment here.)
> 
> Jan

Would it be okay to mix goto and switch like this, or is it too convoluted?

         case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
             plug = false;
             fn = cpu_down_helper;
             hcpu = _p(cpu);
             break;

         default:
             goto outer_default;
         }

         if ( !ret )
             ret = plug ? xsm_resource_plug_core(XSM_HOOK)
                        : xsm_resource_unplug_core(XSM_HOOK);

         if ( !ret )
             ret = continue_hypercall_on_cpu(0, fn, hcpu);
         break;
     }
#endif

     default:
outer_default:
         ret = arch_do_sysctl(op, u_sysctl);
         copyback = 0;
         break;
     }



-- 
Mykyta

 


Rackspace

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