Skip to contentSkip to conversation

arm64: cpuidle: add __init section marker to arm_cpuidle_init

PATCH In review Jisheng Zhang 2 participants 4 messages Jul 2, 2015 arm64

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm64: cpuidle: add __init section marker to arm_cpuidle_init

It is not needed after booting, this patch moves the arm_cpuidle_init() function to the __init section.

---
 arch/arm64/include/asm/cpuidle.h | 2 +-
 arch/arm64/kernel/cpuidle.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/cpuidle.h +1 -1
index 0f74f05..5748d3b 100644
@@ -4,7 +4,7 @@
 #include <asm/proc-fns.h>
 
 #ifdef CONFIG_CPU_IDLE
-extern int arm_cpuidle_init(unsigned int cpu);
+extern int __init arm_cpuidle_init(unsigned int cpu);
 extern int arm_cpuidle_suspend(int index);
 #else
 static inline int arm_cpuidle_init(unsigned int cpu)
arch/arm64/kernel/cpuidle.c +1 -1
index 7ce589c..9047cab6 100644
@@ -15,7 +15,7 @@
 #include <asm/cpuidle.h>
 #include <asm/cpu_ops.h>
 
-int arm_cpuidle_init(unsigned int cpu)
+int __init arm_cpuidle_init(unsigned int cpu)
 {
 	int ret = -EOPNOTSUPP;
 
Signature · 1 line
2.1.4
#1 lore raw

2015-07-02 11:14 GMT+09:00 Jisheng Zhang <[email protected]>:

Quoted 14 lines

It is not needed after booting, this patch moves the arm_cpuidle_init() function to the __init section.

---
 arch/arm64/include/asm/cpuidle.h | 2 +-
 arch/arm64/kernel/cpuidle.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/cpuidle.h +0 -0
index 0f74f05..5748d3b 100644

arch/arm64/include/asm/cpuidle.h line 7

Quoted 5 lines
arch/arm64/include/asm/cpuidle.h +1 -1
@@ -4,7 +4,7 @@
 #include <asm/proc-fns.h>
 
 #ifdef CONFIG_CPU_IDLE
-extern int arm_cpuidle_init(unsigned int cpu);
+extern int __init arm_cpuidle_init(unsigned int cpu);

No, not here but...

arch/arm64/include/asm/cpuidle.h line 10

Quoted 3 lines
arch/arm64/include/asm/cpuidle.h +0 -0
 extern int arm_cpuidle_suspend(int index);
 #else
 static inline int arm_cpuidle_init(unsigned int cpu)

... here so the stub for !CONFIG_CPU_IDLE would be marked as well.

Best regards,
Krzysztof

#2 lore raw

Dear Krzysztof,

Quoted 23 lines · On Thu, 2 Jul 2015 12:59:44 +0900 Krzysztof Kozlowski…

2015-07-02 11:14 GMT+09:00 Jisheng Zhang <[email protected]>:

Quoted 14 lines

It is not needed after booting, this patch moves the arm_cpuidle_init() function to the __init section.

---
 arch/arm64/include/asm/cpuidle.h | 2 +-
 arch/arm64/kernel/cpuidle.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/cpuidle.h +0 -0
index 0f74f05..5748d3b 100644

arch/arm64/include/asm/cpuidle.h line 7

Quoted 5 lines
arch/arm64/include/asm/cpuidle.h +1 -1
@@ -4,7 +4,7 @@
 #include <asm/proc-fns.h>
 
 #ifdef CONFIG_CPU_IDLE
-extern int arm_cpuidle_init(unsigned int cpu);
+extern int __init arm_cpuidle_init(unsigned int cpu);

No, not here but...

Quoted 5 lines

arch/arm64/include/asm/cpuidle.h line 10

Quoted 3 lines
arch/arm64/include/asm/cpuidle.h +0 -0
 extern int arm_cpuidle_suspend(int index);
 #else
 static inline int arm_cpuidle_init(unsigned int cpu)

... here so the stub for !CONFIG_CPU_IDLE would be marked as well.

when !CONFIG_CPU_IDLE, arm_cpuidle_init() is inlined, and just return -EOPNOTSUPP; Per my understanding, it will be optimized out by compiler. I'm not sure whether there is any benefit to mark inlined function as __init. But Per my check, all other inlined functions in linux kernel have no __init. What do you think?

Thanks,
Jisheng

#3 lore raw
Quoted 32 lines · Jisheng Zhang

Dear Krzysztof,

Quoted 27 lines · On Thu, 2 Jul 2015 12:59:44 +0900 Krzysztof Kozlowski…

2015-07-02 11:14 GMT+09:00 Jisheng Zhang <[email protected]>:

Quoted 14 lines

It is not needed after booting, this patch moves the arm_cpuidle_init() function to the __init section.

---
 arch/arm64/include/asm/cpuidle.h | 2 +-
 arch/arm64/kernel/cpuidle.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/cpuidle.h +0 -0
index 0f74f05..5748d3b 100644

arch/arm64/include/asm/cpuidle.h line 7

Quoted 5 lines
arch/arm64/include/asm/cpuidle.h +1 -1
@@ -4,7 +4,7 @@
 #include <asm/proc-fns.h>
 
 #ifdef CONFIG_CPU_IDLE
-extern int arm_cpuidle_init(unsigned int cpu);
+extern int __init arm_cpuidle_init(unsigned int cpu);

No, not here but...

Quoted 3 lines
arch/arm64/include/asm/cpuidle.h +0 -0
 extern int arm_cpuidle_suspend(int index);
 #else
 static inline int arm_cpuidle_init(unsigned int cpu)
Quoted 6 lines
Quoted 1 line

... here so the stub for !CONFIG_CPU_IDLE would be marked as well.

when !CONFIG_CPU_IDLE, arm_cpuidle_init() is inlined, and just return -EOPNOTSUPP; Per my understanding, it will be optimized out by compiler. I'm not sure whether there is any benefit to mark inlined function as __init. But Per my check, all other inlined functions in linux kernel have no __init. What do you think?

Yes, you're right, the inline is sufficient so this means that actually the first patch was correct. The __init is not needed in extern declaration. For both versions then:

Best regards,
Krzysztof