Fix issues and factorize arm/arm64 capacity information code
Subsystems (5)
cover Fix issues and factorize arm/arm64 capacity information code
Hi,
arm and arm64 topology.c share a lot of code related to parsing of capacity information. This set of patches proposes a solution (based on Will's, Catalin's and Mark's off-line suggestions) to move such common code in a single
place: drivers/base/arch_topology.c (by creating such file and conditionally compiling it for arm and arm64 only).
First 5 patches are actually fixes for the current code.
Patch 6 is the actual refactoring.
Last patch removes one of the extern symbols by changing a bit the now common code. We still remain with some other externs, which are not nice. Moving them in some header file solves the issue, should I just create a new include/ linux/arch_topology.h file and move them there?
The set is based on top of linux/master (4.10-rc4 fb1d8e0e2c50) and it is also available from:
git://linux-arm.org/linux-jl.git upstream/default_caps_factorize
Best,
- Juri
Juri Lelli (7):
Documentation: arm: fix wrong reference number in DT definition Documentation/ABI: add information about cpu_capacity
arm: fix return value of parse_cpu_capacity
arm: remove wrong CONFIG_PROC_SYSCTL ifdef
arm64: remove wrong CONFIG_PROC_SYSCTL ifdef
arm, arm64: factorize common cpu capacity default code arm,arm64,drivers: reduce scope of cap_parsing_failed
Documentation/ABI/testing/sysfs-devices-system-cpu | 7 + Documentation/devicetree/bindings/arm/cpus.txt | 4 +- arch/arm/Kconfig | 1 + arch/arm/kernel/topology.c | 216 +------------------ arch/arm64/Kconfig | 1 + arch/arm64/kernel/topology.c | 218 +------------------ drivers/base/Kconfig | 8 + drivers/base/Makefile | 1 + drivers/base/arch_topology.c | 240 +++++++++++++++++++++ 9 files changed, 269 insertions(+), 427 deletions(-) create mode 100644 drivers/base/arch_topology.c
Signature · 1 line
2.10.0
PATCH 1/7 Documentation: arm: fix wrong reference number in DT definition
Reference to cpu capacity binding has a wrong number. Fix it.
--- Documentation/devicetree/bindings/arm/cpus.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/arm/cpus.txt +2 -2
@@ -246,7 +246,7 @@ nodes to be present and contain the properties described below. Usage: Optional Value type: <u32> Definition: - # u32 value representing CPU capacity [3] in + # u32 value representing CPU capacity [4] in DMIPS/MHz, relative to highest capacity-dmips-mhz in the system.
@@ -473,5 +473,5 @@ cpus { [2] arm/msm/qcom,kpss-acc.txt [3] ARM Linux kernel documentation - idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt -[3] ARM Linux kernel documentation - cpu capacity bindings +[4] ARM Linux kernel documentation - cpu capacity bindings Documentation/devicetree/bindings/arm/cpu-capacity.txt
Signature · 1 line
2.10.0
PATCH 2/7 Documentation/ABI: add information about cpu_capacity
In reply to Juri Lelli/sys/devices/system/cpu/cpu#/cpu_capacity describe information about CPUs heterogeneity (ref. to Documentation/devicetree/bindings/arm/ cpu-capacity.txt).
Add such description.
--- Documentation/ABI/testing/sysfs-devices-system-cpu | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +7 -0
@@ -366,3 +366,10 @@ Contact: Linux ARM Kernel Mailing list <[email protected]> Description: AArch64 CPU registers 'identification' directory exposes the CPU ID registers for identifying model and revision of the CPU. + +What: /sys/devices/system/cpu/cpu#/cpu_capacity +Date: December 2016 +Contact: Linux kernel mailing list <[email protected]> +Description: information about CPUs heterogeneity. + + cpu_capacity: capacity of cpu#.
Signature · 1 line
2.10.0
PATCH 3/7 arm: fix return value of parse_cpu_capacity
In reply to Juri Lelliparse_cpu_capacity() has to return 0 on failure, but it currently returns 1 instead if raw_capacity kcalloc failed.
Fix it by removing the negation of the return value.
--- arch/arm/kernel/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/topology.c +1 -1
@@ -165,7 +165,7 @@ static int __init parse_cpu_capacity(struct device_node *cpu_node, int cpu)if (!raw_capacity) {pr_err ("cpu_capacity: failed to allocate memory for raw capacities\n" ); cap_parsing_failed = true; -return !ret; +return ret; } } capacity_scale =max (cpu_capacity, capacity_scale);
Signature · 1 line
2.10.0
PATCH 4/7 arm: remove wrong CONFIG_PROC_SYSCTL ifdef
In reply to Juri LelliThe sysfs cpu_capacity entry for each CPU has nothing to do with PROC_FS, nor it's in /proc/sys path.
Remove such ifdef.
--- arch/arm/kernel/topology.c | 2 -- 1 file changed, 2 deletions(-)
arch/arm/kernel/topology.c +0 -2
@@ -56,7 +56,6 @@ static void set_capacity_scale(unsigned int cpu, unsigned long capacity)per_cpu (cpu_scale, cpu) = capacity; } -#ifdef CONFIG_PROC_SYSCTL static ssize_t cpu_capacity_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -113,7 +112,6 @@ static int register_cpu_capacity_sysctl(void)return 0 ; }subsys_initcall (register_cpu_capacity_sysctl); -#endif #ifdef CONFIG_OF struct cpu_efficiency {
Signature · 1 line
2.10.0
PATCH 5/7 arm64: remove wrong CONFIG_PROC_SYSCTL ifdef
In reply to Juri LelliThe sysfs cpu_capacity entry for each CPU has nothing to do with PROC_FS, nor it's in /proc/sys path.
Remove such ifdef.
--- arch/arm64/kernel/topology.c | 2 -- 1 file changed, 2 deletions(-)
arch/arm64/kernel/topology.c +0 -2
@@ -40,7 +40,6 @@ static void set_capacity_scale(unsigned int cpu, unsigned long capacity)per_cpu (cpu_scale, cpu) = capacity; } -#ifdef CONFIG_PROC_SYSCTL static ssize_t cpu_capacity_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -97,7 +96,6 @@ static int register_cpu_capacity_sysctl(void)return 0 ; }subsys_initcall (register_cpu_capacity_sysctl); -#endif static u32 capacity_scale;static u32 *raw_capacity;
Signature · 1 line
2.10.0
PATCH 6/7 arm, arm64: factorize common cpu capacity default code
In reply to Juri Lelliarm and arm64 share lot of code relative to parsing CPU capacity information from DT, using that information for appropriate scaling and exposing a sysfs interface for chaging such values at runtime.
Factorize such code in a common place (driver/base/arch_topology.c) in preparation for further additions.
--- arch/arm/Kconfig | 1 + arch/arm/kernel/topology.c | 213 ++------------------------------------ arch/arm64/Kconfig | 1 + arch/arm64/kernel/topology.c | 213 +------------------------------------- drivers/base/Kconfig | 8 ++ drivers/base/Makefile | 1 + drivers/base/arch_topology.c | 240 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 260 insertions(+), 417 deletions(-) create mode 100644 drivers/base/arch_topology.c
arch/arm/Kconfig +1 -0
@@ -19,6 +19,7 @@ config ARM select EDAC_SUPPORT select EDAC_ATOMIC_SCRUB select GENERIC_ALLOCATOR + select GENERIC_ARCH_TOPOLOGY select GENERIC_ATOMIC64 if (CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI) select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GENERIC_EARLY_IOREMAP
arch/arm/kernel/topology.c +6 -207
226 lines not on this page · raw message
arch/arm64/Kconfig +1 -0
@@ -36,6 +36,7 @@ config ARM64 select EDAC_SUPPORT select FRAME_POINTER select GENERIC_ALLOCATOR + select GENERIC_ARCH_TOPOLOGY select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST select GENERIC_CPU_AUTOPROBE
arch/arm64/kernel/topology.c +3 -210
224 lines not on this page · raw message
drivers/base/Kconfig +8 -0
@@ -339,4 +339,12 @@ config CMA_ALIGNMENT endif +config GENERIC_ARCH_TOPOLOGY + bool + help + Enable support for architectures common topology code: e.g., parsing + CPU capacity information from DT, usage of such information for + appropriate scaling, sysfs interface for changing capacity values at + runtime. + endmenu
drivers/base/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_SOC_BUS) += soc.o obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_DEV_COREDUMP) += devcoredump.o obj-$(CONFIG_GENERIC_MSI_IRQ_DOMAIN) += platform-msi.o +obj-$(CONFIG_GENERIC_ARCH_TOPOLOGY) += arch_topology.o obj-y += test/
drivers/base/arch_topology.c new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
2.10.0
PATCH 7/7 arm,arm64,drivers: reduce scope of cap_parsing_failed
In reply to Juri LelliReduce the scope of cap_parsing_failed (making it static in drivers/base/arch_topology.c) by slightly changing {arm,arm64} DT parsing code.
--- arch/arm/kernel/topology.c | 3 +-- arch/arm64/kernel/topology.c | 5 +---- drivers/base/arch_topology.c | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-)
arch/arm/kernel/topology.c +1 -2
@@ -75,7 +75,6 @@ static unsigned long *__cpu_capacity;static unsigned long middle_capacity =1 ;static bool cap_from_dt = true; -extern bool cap_parsing_failed;extern void normalize_cpu_capacity (void );extern int __init parse_cpu_capacity (struct device_node *cpu_node,int cpu);
@@ -164,7 +163,7 @@ static void __init parse_dt_topology(void) middle_capacity = ((max_capacity /3 ) >> (SCHED_CAPACITY_SHIFT -1 )) +1 ; -if (cap_from_dt && !cap_parsing_failed) +if (cap_from_dt)normalize_cpu_capacity (); }
arch/arm64/kernel/topology.c +1 -4
@@ -26,7 +26,6 @@#include <asm/cputype.h> #include <asm/topology.h> -extern bool cap_parsing_failed;extern void normalize_cpu_capacity (void );extern int __init parse_cpu_capacity (struct device_node *cpu_node,int cpu);
@@ -186,10 +185,8 @@ static int __init parse_dt_topology(void)* cluster with restricted subnodes. */ map =of_get_child_by_name (cn,"cpu-map" ); -if (!map) { - cap_parsing_failed = true; +if (!map) goto out; - } ret =parse_cluster (map,0 );if (ret !=0 )
drivers/base/arch_topology.c +2 -2
@@ -99,7 +99,7 @@ subsys_initcall(register_cpu_capacity_sysctl);u32 capacity_scale;u32 *raw_capacity; -bool cap_parsing_failed; +static bool cap_parsing_failed;void normalize_cpu_capacity (void ) {
@@ -209,7 +209,7 @@ static struct notifier_block init_cpu_capacity_notifier = {static int __init register_cpufreq_notifier (void ) { -if (cap_parsing_failed) +if (!raw_capacity)return -EINVAL ;if (!alloc_cpumask_var (&cpus_to_visit,GFP_KERNEL )) {
Signature · 1 line
2.10.0
Russell King - ARM Linux
maintainerRe: [PATCH 6/7] arm, arm64: factorize common cpu capacity default code
In reply to Juri Lelliarch/arm/kernel/topology.c line 49
Quoted 3 lines · Juri Lelli
arch/arm/kernel/topology.c +3
-0+extern unsigned long +arch_scale_cpu_capacity (struct sched_domain *sd,int cpu); +extern void set_capacity_scale (unsigned int cpu,unsigned long capacity);
These should be in a header file (please run your code through sparse).
arch/arm/kernel/topology.c static unsigned long *__cpu_capacity; · line 80
Quoted 3 lines
arch/arm/kernel/topology.c +3
-0+extern bool cap_parsing_failed; +extern void normalize_cpu_capacity (void ); +extern int __init parse_cpu_capacity (struct device_node *cpu_node,int cpu);
Same for these.
Quoted 9 lines
drivers/base/arch_topology.c new file +3
-0@@ -0,0 +1,240 @@ +/* +* driver/base/arch_topology.c - Arch specific cpu topology information +*
drivers/base/arch_topology.c line 13
Quoted 10 lines
drivers/base/arch_topology.c new file +10
-0+* Written by: Juri Lelli, ARM Ltd. +* +* Copyright (C) 2016, ARM Ltd. +* +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version.
The files that you've taken this code from are GPLv2, but you've thrown a GPLv2+ header on a file that's merely a copy of the original code. As some of the code you've moved to this new file is from Nicolas and Vincent, you need to seek their approval to make this change of license terms, or keep the original license terms.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Re: [PATCH 6/7] arm, arm64: factorize common cpu capacity default code
Hi,
Quoted 7 lines · Russell King - ARM Linux
arch/arm/kernel/topology.c line 49
Quoted 3 lines · Juri Lelli
arch/arm/kernel/topology.c +3
-0+extern unsigned long +arch_scale_cpu_capacity (struct sched_domain *sd,int cpu); +extern void set_capacity_scale (unsigned int cpu,unsigned long capacity);These should be in a header file (please run your code through sparse).
Quoted 6 lines
arch/arm/kernel/topology.c static unsigned long *__cpu_capacity; · line 80
Quoted 3 lines
arch/arm/kernel/topology.c +3
-0+extern bool cap_parsing_failed; +extern void normalize_cpu_capacity (void ); +extern int __init parse_cpu_capacity (struct device_node *cpu_node,int cpu);Same for these.
Right, I was wondering where to put these in the cover letter. New header file (e.g., include/linux/arch_topology.h) or some existing one?
Quoted 17 lines
Quoted 17 lines
drivers/base/arch_topology.c new file +11
-0@@ -0,0 +1,240 @@ +/* +* driver/base/arch_topology.c - Arch specific cpu topology information +* +* Written by: Juri Lelli, ARM Ltd. +* +* Copyright (C) 2016, ARM Ltd. +* +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by
Quoted 9 lines
drivers/base/arch_topology.c line 13
Quoted 2 lines
drivers/base/arch_topology.c new file +2
-0+* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. The files that you've taken this code from are GPLv2, but you've thrown a GPLv2+ header on a file that's merely a copy of the original code. As some of the code you've moved to this new file is from Nicolas and Vincent, you need to seek their approval to make this change of license terms, or keep the original license terms.
Apologies. I'd say we keep the original one. I'll modify it in the next version.
Thanks,
- Juri
Re: [PATCH 6/7] arm, arm64: factorize common cpu capacity default code
In reply to Juri LelliQuoted 25 lines · Juri Lelli
arm and arm64 share lot of code relative to parsing CPU capacity information from DT, using that information for appropriate scaling and exposing a sysfs interface for chaging such values at runtime.
Factorize such code in a common place (
driver/base/arch_topology.c) in preparation for further additions.Suggested-by Will Deacon <[email protected]>Suggested-by Mark Rutland <[email protected]>Suggested-by Catalin Marinas <[email protected]>Cc Russell King <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Juri Lelli <[email protected]>--- arch/arm/Kconfig | 1 + arch/arm/kernel/topology.c | 213 ++------------------------------------ arch/arm64/Kconfig | 1 + arch/arm64/kernel/topology.c | 213 +------------------------------------- drivers/base/Kconfig | 8 ++ drivers/base/Makefile | 1 + drivers/base/arch_topology.c | 240 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 260 insertions(+), 417 deletions(-) create mode 100644 drivers/base/arch_topology.c
[...]
arch/arm/kernel/topology.c line 48
Quoted 2 lines
arch/arm/kernel/topology.c +2
-0+extern unsigned long +arch_scale_cpu_capacity (struct sched_domain *sd,int cpu);
How about adding a driver specific prefix 'foo_' to all driver interfaces?
I'm asking because I would rather like to do a
#define arch_scale_cpu_capacity foo_scale_cpu_capacity
then a
#define arch_scale_cpu_capacity arch_scale_cpu_capacity
in arch/arm64/include/asm/topology.h
later to wire cpu-invariant load-tracking support up to the task scheduler for ARM64.
That's probably true too for all the 'driver' interfaces which get used in arch/arm{,64}/kernel/topology.c.
[...]
Re: [PATCH 6/7] arm, arm64: factorize common cpu capacity default code
Hi Dietmar,
Quoted 42 lines · Dietmar Eggemann
Quoted 25 lines · Juri Lelli
arm and arm64 share lot of code relative to parsing CPU capacity information from DT, using that information for appropriate scaling and exposing a sysfs interface for chaging such values at runtime.
Factorize such code in a common place (
driver/base/arch_topology.c) in preparation for further additions.Suggested-by Will Deacon <[email protected]>Suggested-by Mark Rutland <[email protected]>Suggested-by Catalin Marinas <[email protected]>Cc Russell King <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Juri Lelli <[email protected]>--- arch/arm/Kconfig | 1 + arch/arm/kernel/topology.c | 213 ++------------------------------------ arch/arm64/Kconfig | 1 + arch/arm64/kernel/topology.c | 213 +------------------------------------- drivers/base/Kconfig | 8 ++ drivers/base/Makefile | 1 + drivers/base/arch_topology.c | 240 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 260 insertions(+), 417 deletions(-) create mode 100644 drivers/base/arch_topology.c[...]
arch/arm/kernel/topology.c line 48
Quoted 2 lines
arch/arm/kernel/topology.c +2
-0+extern unsigned long +arch_scale_cpu_capacity (struct sched_domain *sd,int cpu);How about adding a driver specific prefix '
foo_' to all driver interfaces?I'm asking because I would rather like to do a
#define
arch_scale_cpu_capacityfoo_scale_cpu_capacitythen a
#define
arch_scale_cpu_capacityarch_scale_cpu_capacity
Quoted 8 lines
in
arch/arm64/include/asm/topology.hlater to wire cpu-invariant load-tracking support up to the task scheduler for ARM64.
That's probably true too for all the 'driver' interfaces which get used in
arch/arm{,64}/kernel/topology.c.
Looks like a good way to improve clarity to me. I'll add a patch for the next version doing this and we see what people think.
Best,
- Juri
Re: [PATCH 1/7] Documentation: arm: fix wrong reference number in DT definition
In reply to Juri LelliQuoted 7 lines · Juri Lelli
Reference to cpu capacity binding has a wrong number. Fix it.
Reported-by Lorenzo Pieralisi <[email protected]>Signed-off-by Juri Lelli <[email protected]>--- Documentation/devicetree/bindings/arm/cpus.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Hi,
ping.
I'd need more advice on this set, especially on how and if patch 6 could fly.
Thanks,
- Juri
Quoted 50 lines · Juri Lelli
Hi,
arm and arm64
topology.cshare a lot of code related to parsing of capacity information. This set of patches proposes a solution (based on Will's, Catalin's and Mark's off-line suggestions) to move such common code in a single
place:drivers/base/arch_topology.c(by creating such file and conditionally compiling it for arm and arm64 only).First 5 patches are actually fixes for the current code.
Patch 6 is the actual refactoring.
Last patch removes one of the extern symbols by changing a bit the now common code. We still remain with some other externs, which are not nice. Moving them in some header file solves the issue, should I just create a new
include/linux/arch_topology.hfile and move them there?The set is based on top of linux/master (4.10-rc4
fb1d8e0e2c50) and it is also available from:
git://linux-arm.org/linux-jl.gitupstream/default_caps_factorizeBest,
- Juri
Juri Lelli (7):
Documentation: arm: fix wrong reference number in DT definitionDocumentation/ABI: add information aboutcpu_capacity
arm: fix return value ofparse_cpu_capacity
arm: remove wrongCONFIG_PROC_SYSCTLifdef
arm64: remove wrongCONFIG_PROC_SYSCTLifdef
arm, arm64: factorize common cpu capacity default code arm,arm64,drivers: reduce scope ofcap_parsing_failedDocumentation/ABI/testing/sysfs-devices-system-cpu | 7 + Documentation/devicetree/bindings/arm/cpus.txt | 4 +- arch/arm/Kconfig | 1 + arch/arm/kernel/topology.c | 216 +------------------ arch/arm64/Kconfig | 1 + arch/arm64/kernel/topology.c | 218 +------------------ drivers/base/Kconfig | 8 + drivers/base/Makefile | 1 + drivers/base/arch_topology.c | 240 +++++++++++++++++++++ 9 files changed, 269 insertions(+), 427 deletions(-) create mode 100644 drivers/base/arch_topology.cSignature · 1 line
2.10.0
Catalin Marinas
maintainerQuoted 1 line · Juri Lelli
I'd need more advice on this set, especially on how and if patch 6 could fly.
Since you got some comments and said that you are going to fix them in the next version, I guess people are waiting for you to post a new series.
Signature · 1 line
Catalin
Hi Catalin,
Quoted 7 lines · Catalin Marinas
Quoted 1 line · Juri Lelli
I'd need more advice on this set, especially on how and if patch 6 could fly.
Since you got some comments and said that you are going to fix them in the next version, I guess people are waiting for you to post a new series.
While this is true for Dietmar's and part of Russell's comments, I was still waiting to understand where people think is better to move the externs (as Russell pointed out), though, and if the whole idea could fly.
I could certainly come up with a proposal on this point, but I didn't simply want to spam people's mailboxes with a v2 (addressing relatively minor points, IMHO) if v1 was already completely off. Apologies if that wasn't clear from my replies.
Maybe you are saying that no comments are a good sign after all. :)
Best,
- Juri