[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4] xen: move per-cpu area management into common code
- To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Michal Orzel <michal.orzel@xxxxxxx>
- Date: Wed, 2 Oct 2024 15:41:31 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- 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=WVJo00h3ominfYVlQ3abMRqffcTEP869XveZHmn3nKE=; b=DiyebR3vTvYxPnyySl5/sc0RgJ83HgrmxNU0lwww1o2nOQQEV2c7aA0ayWQ7NsL3S6+LnhhSomEt6E/B7XZyDzEQNNFuU62rzO/waAO6anEgiWrRnStBzTvMT5B2HGlEVuGZymkiBZaRggFw0Nkt0Fktc/90sOndOndiwHZCfNpxG3k7+qZ83XFDzYhOUNJs5Wr2Pq5wmgEwWt1O/TIwXGvHQJLevdb9V/PksRmmNUdcNwUVjKdBIRd/gCc5Y/40a/NGkTus6kM7AoYo0BpybHYxrbIBHrNFH7nVyFEjqHaGbhylGZc5ae1+Feveg+m3SOG4k7d/ZNDheXWURB8zwA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AIsBVZPGf3ZFKznco2wv+nJYU1sAd4rwsiPolXbHlEIou2H3LfJTw5zMD0lgy7uLqDBrEK4UpwSVtEGacJBNpt5JVfNGjI+l/tJhLOW/Rxk9/F+uvljmGjzx49C1j4lhLJoOUysLY3o2OTuhGF5aI3B4uI55ZYcmwFyGyMG1NrywgtG6HR4JTFBmCEj72QxpFsils4i/bIOH7sEJA5H3l3pZ3DX/uMDhnbjrG21YQWGVfgReIFwmdKSvK8c2GwOU/PKx+Knt+xnsDoj6BmmRjbBTpU9+ZVwH5qA8M+GuIY3UHUkry0XwwHXmZM9tADqu4udMnqN2XIv/Xp+eTKjY5A==
- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, "Connor Davis" <connojdavis@xxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Wed, 02 Oct 2024 13:41:56 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 30/09/2024 18:39, Oleksii Kurochko wrote:
>
>
> Centralize per-cpu area management to reduce code duplication and
> enhance maintainability across architectures.
>
> The per-cpu area management code, which is largely common among
> architectures, is moved to a shared implementation in
> xen/common/percpu.c. This change includes:
> * Remove percpu.c from the X86 and Arm architectures.
> * For x86, define INVALID_PERCPU_AREAS and PARK_OFFLINE_CPUS_VAR.
> * Drop the declaration of __per_cpu_offset[] from stubs.c in
> PPC and RISC-V to facilitate the build of the common per-cpu code.
>
> No functional changes for x86.
>
> For Arm add support of CPU_RESUME_FAILED, CPU_REMOVE and freeing of
> percpu in the case when system_state != SYS_STATE_suspend.
Behaviorwise there is no change for Arm given that none of these actions can be
executed.
That said, by looking at the code I realized that we never call CPU_REMOVE so
it is effectively
a dead code.
As for the change itself:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
with one question below ...
[...]
> +static int cf_check cpu_percpu_callback(
> + struct notifier_block *nfb, unsigned long action, void *hcpu)
> +{
> + unsigned int cpu = (unsigned long)hcpu;
> + int rc = 0;
> +
> + switch ( action )
> + {
> + case CPU_UP_PREPARE:
> + rc = init_percpu_area(cpu);
> + break;
> + case CPU_UP_CANCELED:
> + case CPU_DEAD:
> + case CPU_RESUME_FAILED:
> + if ( !park_offline_cpus && system_state != SYS_STATE_suspend )
> + free_percpu_area(cpu);
> + break;
> + case CPU_REMOVE:
> + if ( park_offline_cpus )
> + free_percpu_area(cpu);
> + break;
Aren't we missing default statement here as per MISRA C 16.4?
I think we only allow to drop it for enums.
~Michal
|