mbox series

[v1,0/2] Move percpu code to common

Message ID cover.1726746877.git.oleksii.kurochko@gmail.com (mailing list archive)
Headers show
Series Move percpu code to common | expand

Message

Oleksii Kurochko Sept. 19, 2024, 3:59 p.m. UTC
The per-CPU area management code, which is largely common across architectures,
is a strong candidate for consolidation into common code.

Currently, there are three architectural-specific aspects that are not yet
unified ( if they can be unified at all ):
1. INVALID_PERCPU_AREA:
  ARM:
    #define INVALID_PERCPU_AREA (-(long)__per_cpu_start)
  x86:
    #define INVALID_PERCPU_AREA (0x8000000000000000UL - (unsigned long)__per_cpu_start)
2. Return value when __per_cpu_offset Is Already Initialized:
  Arm:
    if (__per_cpu_offset[cpu] != INVALID_PERCPU_AREA)
      return -EBUSY;
  x86:
    if (__per_cpu_offset[cpu] != INVALID_PERCPU_AREA)
      return 0;
3. Handling of CPU_RESUME_FAILED and CPU_REMOVE in cpu_percpu_callback:
  Arm:
    switch (action)
    {
    case CPU_UP_CANCELED:
    case CPU_DEAD:
        free_percpu_area(cpu);
        break;
    }
  x86:
    switch (action)
    {
    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;
    }

These changes do not affect the functional behavior.


Oleksii Kurochko (2):
  xen: introduce common macros for per-CPU sections defintion
  xen: move per-cpu area management into common code

 xen/arch/arm/Makefile             |   1 -
 xen/arch/arm/percpu.c             |  85 --------------------
 xen/arch/arm/xen.lds.S            |   9 +--
 xen/arch/ppc/stubs.c              |   1 -
 xen/arch/ppc/xen.lds.S            |   9 +--
 xen/arch/riscv/stubs.c            |   1 -
 xen/arch/x86/include/asm/Makefile |   1 -
 xen/arch/x86/include/asm/percpu.h |  18 +++++
 xen/arch/x86/percpu.c             |  92 ++--------------------
 xen/arch/x86/xen.lds.S            |   9 +--
 xen/common/Makefile               |   1 +
 xen/common/percpu.c               | 127 ++++++++++++++++++++++++++++++
 xen/include/asm-generic/percpu.h  |   8 ++
 xen/include/xen/xen.lds.h         |  10 +++
 14 files changed, 172 insertions(+), 200 deletions(-)
 delete mode 100644 xen/arch/arm/percpu.c
 create mode 100644 xen/arch/x86/include/asm/percpu.h
 create mode 100644 xen/common/percpu.c