mbox series

[v2,0/4] arm64: Dereference CPU operations indirectly

Message ID 20200203235107.190609-1-gshan@redhat.com (mailing list archive)
Headers show
Series arm64: Dereference CPU operations indirectly | expand

Message

Gavin Shan Feb. 3, 2020, 11:51 p.m. UTC
In current implementation, an array (@cpu_ops[NR_CPUS]) is maintained
to dereference the CPU operations. 2KB memory are consumed when NR_CPUS
is configured to 256. It's too much than what I expected. This series
reworks the implementation to dereference the CPU operations indirectly,
so that less memory (64 bytes) will be consumed for the same purpose.
The optimization bases on the assumption: these CPU operations aren't
dereferenced in hot path.

PATCH[1/4] isn't too much relevant, to declare ACPI parking protocol only
when CONFIG_ARM64_ACPI_PARKING_PROTOCOL has been enabled. PATCH[2/4]
renames cpu_read_ops() to init_cpu_ops(), which is obviously more precise
because it's initializing the CPU operations. PATCH[3/4] introduces
get_cpu_ops(), preparing for dereferencing CPU operations indirectly.
PATCH[4/4] makes dereferencing CPU operations indirectly happen.

Changelog
=========
v2:
   * Pack 4 CPUs' indexes into one byte. 64 bytes are consumed in order
     to get the CPU operations                            (Robin Murphy)
   * Use ARRAY_SIZE() to iterate @cpu_ops[]               (Robin Murphy)
   * Make index-0 valid                                   (Robin Murphy)

Gavin Shan (4):
  arm64: Declare ACPI parking protocol CPU operation if needed
  arm64: Rename cpu_read_ops() to init_cpu_ops()
  arm64: Introduce get_cpu_ops() helper function
  arm64: Dereference CPU operations indirectly

 arch/arm64/include/asm/cpu_ops.h |  8 ++---
 arch/arm64/kernel/cpu_ops.c      | 56 ++++++++++++++++--------------
 arch/arm64/kernel/cpuidle.c      |  9 ++---
 arch/arm64/kernel/setup.c        |  8 +++--
 arch/arm64/kernel/smp.c          | 59 ++++++++++++++++++++++----------
 5 files changed, 85 insertions(+), 55 deletions(-)

Comments

Gavin Shan Feb. 11, 2020, 1:47 a.m. UTC | #1
On 2/4/20 10:51 AM, Gavin Shan wrote:
> In current implementation, an array (@cpu_ops[NR_CPUS]) is maintained
> to dereference the CPU operations. 2KB memory are consumed when NR_CPUS
> is configured to 256. It's too much than what I expected. This series
> reworks the implementation to dereference the CPU operations indirectly,
> so that less memory (64 bytes) will be consumed for the same purpose.
> The optimization bases on the assumption: these CPU operations aren't
> dereferenced in hot path.
> 
> PATCH[1/4] isn't too much relevant, to declare ACPI parking protocol only
> when CONFIG_ARM64_ACPI_PARKING_PROTOCOL has been enabled. PATCH[2/4]
> renames cpu_read_ops() to init_cpu_ops(), which is obviously more precise
> because it's initializing the CPU operations. PATCH[3/4] introduces
> get_cpu_ops(), preparing for dereferencing CPU operations indirectly.
> PATCH[4/4] makes dereferencing CPU operations indirectly happen.
> 
> Changelog
> =========
> v2:
>     * Pack 4 CPUs' indexes into one byte. 64 bytes are consumed in order
>       to get the CPU operations                            (Robin Murphy)
>     * Use ARRAY_SIZE() to iterate @cpu_ops[]               (Robin Murphy)
>     * Make index-0 valid                                   (Robin Murphy)
> 

Robin, Please let me know if you have more comments on this series, thanks!

Thanks,
Gavin

> Gavin Shan (4):
>    arm64: Declare ACPI parking protocol CPU operation if needed
>    arm64: Rename cpu_read_ops() to init_cpu_ops()
>    arm64: Introduce get_cpu_ops() helper function
>    arm64: Dereference CPU operations indirectly
> 
>   arch/arm64/include/asm/cpu_ops.h |  8 ++---
>   arch/arm64/kernel/cpu_ops.c      | 56 ++++++++++++++++--------------
>   arch/arm64/kernel/cpuidle.c      |  9 ++---
>   arch/arm64/kernel/setup.c        |  8 +++--
>   arch/arm64/kernel/smp.c          | 59 ++++++++++++++++++++++----------
>   5 files changed, 85 insertions(+), 55 deletions(-)
>