[PATCH 00/14] paravirt: cleanup and reorg

Juergen Gross posted 14 patches 2 days, 20 hours ago
Only 5 patches received!
There is a newer version of this series
arch/Kconfig                                  |   3 +
arch/arm/Kconfig                              |   1 +
arch/arm/include/asm/paravirt.h               |  22 ---
arch/arm/include/asm/paravirt_api_clock.h     |   1 -
arch/arm/kernel/Makefile                      |   1 -
arch/arm/kernel/paravirt.c                    |  23 ---
arch/arm64/Kconfig                            |   1 +
arch/arm64/include/asm/paravirt.h             |  14 --
arch/arm64/include/asm/paravirt_api_clock.h   |   1 -
arch/arm64/kernel/paravirt.c                  |  11 +-
arch/loongarch/Kconfig                        |   1 +
arch/loongarch/include/asm/paravirt.h         |  13 --
.../include/asm/paravirt_api_clock.h          |   1 -
arch/loongarch/kernel/paravirt.c              |  10 +-
arch/powerpc/include/asm/paravirt.h           |   3 -
arch/powerpc/include/asm/paravirt_api_clock.h |   2 -
arch/powerpc/platforms/pseries/setup.c        |   4 +-
arch/riscv/Kconfig                            |   1 +
arch/riscv/include/asm/paravirt.h             |  14 --
arch/riscv/include/asm/paravirt_api_clock.h   |   1 -
arch/riscv/kernel/paravirt.c                  |  11 +-
arch/x86/Kconfig                              |   8 +-
arch/x86/entry/entry_64.S                     |   1 -
arch/x86/entry/vsyscall/vsyscall_64.c         |   1 -
arch/x86/hyperv/hv_spinlock.c                 |   1 -
arch/x86/include/asm/apic.h                   |   4 -
arch/x86/include/asm/highmem.h                |   1 -
arch/x86/include/asm/mmu_context.h            |   1 -
arch/x86/include/asm/mshyperv.h               |   1 -
arch/x86/include/asm/paravirt.h               | 166 ------------------
arch/x86/include/asm/paravirt_api_clock.h     |   1 -
arch/x86/include/asm/paravirt_types.h         |  82 +++++++--
arch/x86/include/asm/pgtable_32.h             |   1 -
arch/x86/include/asm/qspinlock.h              |  49 +++++-
arch/x86/include/asm/spinlock.h               |   1 -
arch/x86/include/asm/timer.h                  |   1 +
arch/x86/include/asm/tlbflush.h               |   4 -
arch/x86/kernel/apm_32.c                      |   1 -
arch/x86/kernel/callthunks.c                  |   1 -
arch/x86/kernel/cpu/bugs.c                    |   1 -
arch/x86/kernel/cpu/vmware.c                  |   1 +
arch/x86/kernel/kvm.c                         |   1 +
arch/x86/kernel/kvmclock.c                    |   1 +
arch/x86/kernel/paravirt.c                    |  16 --
arch/x86/kernel/tsc.c                         |  10 +-
arch/x86/kernel/vsmp_64.c                     |   1 -
arch/x86/kernel/x86_init.c                    |   1 -
arch/x86/lib/cache-smp.c                      |   1 -
arch/x86/mm/init.c                            |   1 -
arch/x86/xen/spinlock.c                       |   1 -
arch/x86/xen/time.c                           |   2 +
drivers/clocksource/hyperv_timer.c            |   2 +
drivers/xen/time.c                            |   2 +-
include/linux/sched/cputime.h                 |  18 ++
kernel/sched/core.c                           |   5 +
kernel/sched/cputime.c                        |  13 ++
kernel/sched/sched.h                          |   3 +-
57 files changed, 182 insertions(+), 362 deletions(-)
delete mode 100644 arch/arm/include/asm/paravirt.h
delete mode 100644 arch/arm/include/asm/paravirt_api_clock.h
delete mode 100644 arch/arm/kernel/paravirt.c
delete mode 100644 arch/arm64/include/asm/paravirt_api_clock.h
delete mode 100644 arch/loongarch/include/asm/paravirt_api_clock.h
delete mode 100644 arch/powerpc/include/asm/paravirt_api_clock.h
delete mode 100644 arch/riscv/include/asm/paravirt_api_clock.h
delete mode 100644 arch/x86/include/asm/paravirt_api_clock.h
[PATCH 00/14] paravirt: cleanup and reorg
Posted by Juergen Gross 2 days, 20 hours ago
Some cleanups and reorg of paravirt code and headers:

- The first 2 patches should be not controversial at all, as they
  remove just some no longer needed #include and struct forward
  declarations.

- The 3rd patch is removing CONFIG_PARAVIRT_DEBUG, which IMO has
  no real value, as it just changes a crash to a BUG() (the stack
  trace will basically be the same). As the maintainer of the main
  paravirt user (Xen) I have never seen this crash/BUG() to happen.

- The 4th patch is just a movement of code.

- I don't know for what reason asm/paravirt_api_clock.h was added,
  as all archs supporting it do it exactly in the same way. Patch
  5 is removing it.

- Patches 6-12 are streamlining the paravirt clock interfaces by
  using a common implementation across architectures where possible
  and by moving the related code into common sched code, as this is
  where it should live.

- Patches 13+14 are more like RFC material: patch 13 is doing some
  preparation work to enable patch 14 to move all spinlock related
  paravirt functions into qspinlock.h. If this approach is accepted,
  I'd like to continue with this work by moving most (or all?)
  paravirt functions from paravirt.h into the headers where their
  native counterparts are defined. This is meant to keep the native
  and paravirt function definitions together in one place and
  hopefully to be able to reduce the include hell with paravirt.

Juergen Gross (14):
  x86/paravirt: remove not needed includes of paravirt.h
  x86/paravirt: remove some unneeded struct declarations
  x86/paravirt: remove PARAVIRT_DEBUG config option
  x86/paravirt: move thunk macros to paravirt_types.h
  paravirt: remove asm/paravirt_api_clock.h
  sched: move clock related paravirt code to kernel/sched
  arm/paravirt: use common code for paravirt_steal_clock()
  arm64/paravirt: use common code for paravirt_steal_clock()
  loongarch/paravirt: use common code for paravirt_steal_clock()
  riscv/paravirt: use common code for paravirt_steal_clock()
  x86/paravirt: use common code for paravirt_steal_clock()
  x86/paravirt: move paravirt_sched_clock() related code into tsc.c
  x86/paravirt: allow pv-calls outside paravirt.h
  x86/pvlocks: move paravirt spinlock functions into qspinlock.h

 arch/Kconfig                                  |   3 +
 arch/arm/Kconfig                              |   1 +
 arch/arm/include/asm/paravirt.h               |  22 ---
 arch/arm/include/asm/paravirt_api_clock.h     |   1 -
 arch/arm/kernel/Makefile                      |   1 -
 arch/arm/kernel/paravirt.c                    |  23 ---
 arch/arm64/Kconfig                            |   1 +
 arch/arm64/include/asm/paravirt.h             |  14 --
 arch/arm64/include/asm/paravirt_api_clock.h   |   1 -
 arch/arm64/kernel/paravirt.c                  |  11 +-
 arch/loongarch/Kconfig                        |   1 +
 arch/loongarch/include/asm/paravirt.h         |  13 --
 .../include/asm/paravirt_api_clock.h          |   1 -
 arch/loongarch/kernel/paravirt.c              |  10 +-
 arch/powerpc/include/asm/paravirt.h           |   3 -
 arch/powerpc/include/asm/paravirt_api_clock.h |   2 -
 arch/powerpc/platforms/pseries/setup.c        |   4 +-
 arch/riscv/Kconfig                            |   1 +
 arch/riscv/include/asm/paravirt.h             |  14 --
 arch/riscv/include/asm/paravirt_api_clock.h   |   1 -
 arch/riscv/kernel/paravirt.c                  |  11 +-
 arch/x86/Kconfig                              |   8 +-
 arch/x86/entry/entry_64.S                     |   1 -
 arch/x86/entry/vsyscall/vsyscall_64.c         |   1 -
 arch/x86/hyperv/hv_spinlock.c                 |   1 -
 arch/x86/include/asm/apic.h                   |   4 -
 arch/x86/include/asm/highmem.h                |   1 -
 arch/x86/include/asm/mmu_context.h            |   1 -
 arch/x86/include/asm/mshyperv.h               |   1 -
 arch/x86/include/asm/paravirt.h               | 166 ------------------
 arch/x86/include/asm/paravirt_api_clock.h     |   1 -
 arch/x86/include/asm/paravirt_types.h         |  82 +++++++--
 arch/x86/include/asm/pgtable_32.h             |   1 -
 arch/x86/include/asm/qspinlock.h              |  49 +++++-
 arch/x86/include/asm/spinlock.h               |   1 -
 arch/x86/include/asm/timer.h                  |   1 +
 arch/x86/include/asm/tlbflush.h               |   4 -
 arch/x86/kernel/apm_32.c                      |   1 -
 arch/x86/kernel/callthunks.c                  |   1 -
 arch/x86/kernel/cpu/bugs.c                    |   1 -
 arch/x86/kernel/cpu/vmware.c                  |   1 +
 arch/x86/kernel/kvm.c                         |   1 +
 arch/x86/kernel/kvmclock.c                    |   1 +
 arch/x86/kernel/paravirt.c                    |  16 --
 arch/x86/kernel/tsc.c                         |  10 +-
 arch/x86/kernel/vsmp_64.c                     |   1 -
 arch/x86/kernel/x86_init.c                    |   1 -
 arch/x86/lib/cache-smp.c                      |   1 -
 arch/x86/mm/init.c                            |   1 -
 arch/x86/xen/spinlock.c                       |   1 -
 arch/x86/xen/time.c                           |   2 +
 drivers/clocksource/hyperv_timer.c            |   2 +
 drivers/xen/time.c                            |   2 +-
 include/linux/sched/cputime.h                 |  18 ++
 kernel/sched/core.c                           |   5 +
 kernel/sched/cputime.c                        |  13 ++
 kernel/sched/sched.h                          |   3 +-
 57 files changed, 182 insertions(+), 362 deletions(-)
 delete mode 100644 arch/arm/include/asm/paravirt.h
 delete mode 100644 arch/arm/include/asm/paravirt_api_clock.h
 delete mode 100644 arch/arm/kernel/paravirt.c
 delete mode 100644 arch/arm64/include/asm/paravirt_api_clock.h
 delete mode 100644 arch/loongarch/include/asm/paravirt_api_clock.h
 delete mode 100644 arch/powerpc/include/asm/paravirt_api_clock.h
 delete mode 100644 arch/riscv/include/asm/paravirt_api_clock.h
 delete mode 100644 arch/x86/include/asm/paravirt_api_clock.h

-- 
2.51.0
Re: [PATCH 00/14] paravirt: cleanup and reorg
Posted by Peter Zijlstra 2 days, 19 hours ago
On Thu, Sep 11, 2025 at 08:34:19AM +0200, Juergen Gross wrote:
> Some cleanups and reorg of paravirt code and headers:
> 
> - The first 2 patches should be not controversial at all, as they
>   remove just some no longer needed #include and struct forward
>   declarations.
> 
> - The 3rd patch is removing CONFIG_PARAVIRT_DEBUG, which IMO has
>   no real value, as it just changes a crash to a BUG() (the stack
>   trace will basically be the same). As the maintainer of the main
>   paravirt user (Xen) I have never seen this crash/BUG() to happen.
> 
> - The 4th patch is just a movement of code.
> 
> - I don't know for what reason asm/paravirt_api_clock.h was added,
>   as all archs supporting it do it exactly in the same way. Patch
>   5 is removing it.
> 
> - Patches 6-12 are streamlining the paravirt clock interfaces by
>   using a common implementation across architectures where possible
>   and by moving the related code into common sched code, as this is
>   where it should live.
> 
> - Patches 13+14 are more like RFC material: patch 13 is doing some
>   preparation work to enable patch 14 to move all spinlock related
>   paravirt functions into qspinlock.h. If this approach is accepted,
>   I'd like to continue with this work by moving most (or all?)
>   paravirt functions from paravirt.h into the headers where their
>   native counterparts are defined. This is meant to keep the native
>   and paravirt function definitions together in one place and
>   hopefully to be able to reduce the include hell with paravirt.
> 
> Juergen Gross (14):
>   x86/paravirt: remove not needed includes of paravirt.h
>   x86/paravirt: remove some unneeded struct declarations
>   x86/paravirt: remove PARAVIRT_DEBUG config option
>   x86/paravirt: move thunk macros to paravirt_types.h
>   paravirt: remove asm/paravirt_api_clock.h
>   sched: move clock related paravirt code to kernel/sched
>   arm/paravirt: use common code for paravirt_steal_clock()
>   arm64/paravirt: use common code for paravirt_steal_clock()
>   loongarch/paravirt: use common code for paravirt_steal_clock()
>   riscv/paravirt: use common code for paravirt_steal_clock()
>   x86/paravirt: use common code for paravirt_steal_clock()
>   x86/paravirt: move paravirt_sched_clock() related code into tsc.c
>   x86/paravirt: allow pv-calls outside paravirt.h
>   x86/pvlocks: move paravirt spinlock functions into qspinlock.h

With the note that tip typically likes a capital after the prefix, like:

  x86/paravirt: Remove unneeded includes of paravirt.h

For 1-12:

  Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>


Now, as to the last two, I'm not sure. Leaking those macros out of PV
isn't particularly nice, then again, not the end of the world either.
Just not sure.
Re: [PATCH 00/14] paravirt: cleanup and reorg
Posted by Jürgen Groß 2 days, 19 hours ago
On 11.09.25 09:48, Peter Zijlstra wrote:
> On Thu, Sep 11, 2025 at 08:34:19AM +0200, Juergen Gross wrote:
>> Some cleanups and reorg of paravirt code and headers:
>>
>> - The first 2 patches should be not controversial at all, as they
>>    remove just some no longer needed #include and struct forward
>>    declarations.
>>
>> - The 3rd patch is removing CONFIG_PARAVIRT_DEBUG, which IMO has
>>    no real value, as it just changes a crash to a BUG() (the stack
>>    trace will basically be the same). As the maintainer of the main
>>    paravirt user (Xen) I have never seen this crash/BUG() to happen.
>>
>> - The 4th patch is just a movement of code.
>>
>> - I don't know for what reason asm/paravirt_api_clock.h was added,
>>    as all archs supporting it do it exactly in the same way. Patch
>>    5 is removing it.
>>
>> - Patches 6-12 are streamlining the paravirt clock interfaces by
>>    using a common implementation across architectures where possible
>>    and by moving the related code into common sched code, as this is
>>    where it should live.
>>
>> - Patches 13+14 are more like RFC material: patch 13 is doing some
>>    preparation work to enable patch 14 to move all spinlock related
>>    paravirt functions into qspinlock.h. If this approach is accepted,
>>    I'd like to continue with this work by moving most (or all?)
>>    paravirt functions from paravirt.h into the headers where their
>>    native counterparts are defined. This is meant to keep the native
>>    and paravirt function definitions together in one place and
>>    hopefully to be able to reduce the include hell with paravirt.
>>
>> Juergen Gross (14):
>>    x86/paravirt: remove not needed includes of paravirt.h
>>    x86/paravirt: remove some unneeded struct declarations
>>    x86/paravirt: remove PARAVIRT_DEBUG config option
>>    x86/paravirt: move thunk macros to paravirt_types.h
>>    paravirt: remove asm/paravirt_api_clock.h
>>    sched: move clock related paravirt code to kernel/sched
>>    arm/paravirt: use common code for paravirt_steal_clock()
>>    arm64/paravirt: use common code for paravirt_steal_clock()
>>    loongarch/paravirt: use common code for paravirt_steal_clock()
>>    riscv/paravirt: use common code for paravirt_steal_clock()
>>    x86/paravirt: use common code for paravirt_steal_clock()
>>    x86/paravirt: move paravirt_sched_clock() related code into tsc.c
>>    x86/paravirt: allow pv-calls outside paravirt.h
>>    x86/pvlocks: move paravirt spinlock functions into qspinlock.h
> 
> With the note that tip typically likes a capital after the prefix, like:
> 
>    x86/paravirt: Remove unneeded includes of paravirt.h

Noted, thanks.

> 
> For 1-12:
> 
>    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> 
> 
> Now, as to the last two, I'm not sure. Leaking those macros out of PV
> isn't particularly nice, then again, not the end of the world either.
> Just not sure.

Yes, that's why I didn't continue with all of the other potential movement of
paravirt functions. I want some feedback first. :-)

Its a tradeoff between having functions with / without paravirt in one file
against hiding the paravirt stuff from "normal" readers (not writers, as those
probably need to touch the paravirt variant, too).

BTW, I think the macro leaking isn't the main problem. There are other macros
leaking already.


Juergen