Skip to contentSkip to conversation

x86/kexec: crash_vmclear_local_vmcss needs __rcu

PATCH Superseded Zhang Yanfei 3 participants 7 messages Dec 7, 2012 – Dec 11, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/kexec: crash_vmclear_local_vmcss needs __rcu

This removes the sparse warning:
arch/x86/kernel/crash.c:49:32: sparse: incompatible types in comparison expression (different address spaces)

---
 arch/x86/include/asm/kexec.h |    4 +++-
 arch/x86/kernel/crash.c      |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/asm/kexec.h +3 -1
index 28feeba..16882cd 100644
@@ -163,7 +163,9 @@ struct kimage_arch {
 };
 #endif
 
-extern void (*crash_vmclear_loaded_vmcss)(void);
+extern void __rcu (*crash_vmclear_loaded_vmcss)(void);
+#define vmclear_func_rcu(vmclear_func) \
+	((void (*)(void)) rcu_dereference(vmclear_func))
 
 #endif /* __ASSEMBLY__ */
 
arch/x86/kernel/crash.c +2 -2
index 2f6b8e8..50ce1d6 100644
@@ -38,7 +38,7 @@ int in_crash_kexec;
  *
  * protected by rcu.
  */
-void (*crash_vmclear_loaded_vmcss)(void) = NULL;
+void __rcu (*crash_vmclear_loaded_vmcss)(void) = NULL;
 EXPORT_SYMBOL_GPL(crash_vmclear_loaded_vmcss);
 
 static inline void cpu_crash_vmclear_loaded_vmcss(void)
@@ -46,7 +46,7 @@ static inline void cpu_crash_vmclear_loaded_vmcss(void)
 	void (*do_vmclear_operation)(void) = NULL;
 
 	rcu_read_lock();
-	do_vmclear_operation = rcu_dereference(crash_vmclear_loaded_vmcss);
+	do_vmclear_operation = vmclear_func_rcu(crash_vmclear_loaded_vmcss);
 	if (do_vmclear_operation)
 		do_vmclear_operation();
 	rcu_read_unlock();
Signature · 1 line
1.7.1
#1 lore raw
Quoted 30 lines · Zhang Yanfei

This removes the sparse warning:
arch/x86/kernel/crash.c:49:32: sparse: incompatible types in comparison expression (different address spaces)

---
 arch/x86/include/asm/kexec.h |    4 +++-
 arch/x86/kernel/crash.c      |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/asm/kexec.h +3 -1
index 28feeba..16882cd 100644
@@ -163,7 +163,9 @@ struct kimage_arch {
 };
 #endif
 
-extern void (*crash_vmclear_loaded_vmcss)(void);
+extern void __rcu (*crash_vmclear_loaded_vmcss)(void);
+#define vmclear_func_rcu(vmclear_func) \
+	((void (*)(void)) rcu_dereference(vmclear_func))
 
 #endif /* __ASSEMBLY__ */
 
arch/x86/kernel/crash.c +0 -0
index 2f6b8e8..50ce1d6 100644

arch/x86/kernel/crash.c int in_crash_kexec; · line 41

Quoted 5 lines
arch/x86/kernel/crash.c +1 -1
@@ -38,7 +38,7 @@ int in_crash_kexec;
  *
  * protected by rcu.
  */
-void (*crash_vmclear_loaded_vmcss)(void) = NULL;
+void __rcu (*crash_vmclear_loaded_vmcss)(void) = NULL;

Isnt this (__rcu AS tag) sufficient? After all, sparse is complaining about namespaces.

Creating a #define to cast seems excessive.

#2 lore raw
Quoted 40 lines · Marcelo Tosatti
Quoted 30 lines · Zhang Yanfei

This removes the sparse warning:
arch/x86/kernel/crash.c:49:32: sparse: incompatible types in comparison expression (different address spaces)

---
 arch/x86/include/asm/kexec.h |    4 +++-
 arch/x86/kernel/crash.c      |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/asm/kexec.h +3 -1
index 28feeba..16882cd 100644
@@ -163,7 +163,9 @@ struct kimage_arch {
 };
 #endif
 
-extern void (*crash_vmclear_loaded_vmcss)(void);
+extern void __rcu (*crash_vmclear_loaded_vmcss)(void);
+#define vmclear_func_rcu(vmclear_func) \
+	((void (*)(void)) rcu_dereference(vmclear_func))
 
 #endif /* __ASSEMBLY__ */
 
arch/x86/kernel/crash.c +0 -0
index 2f6b8e8..50ce1d6 100644

arch/x86/kernel/crash.c int in_crash_kexec; · line 41

Quoted 5 lines
arch/x86/kernel/crash.c +1 -1
@@ -38,7 +38,7 @@ int in_crash_kexec;
  *
  * protected by rcu.
  */
-void (*crash_vmclear_loaded_vmcss)(void) = NULL;
+void __rcu (*crash_vmclear_loaded_vmcss)(void) = NULL;

Isnt this (__rcu AS tag) sufficient? After all, sparse is complaining about namespaces.

Quoted 3 lines

Creating a #define to cast seems excessive.

I am not very familiar with the rcu.
Adding __rcu tag could solve the problem. But it imported another warning when I try to assign rcu_dereference(crash_vmclear_loaded_vmcss) to do_vmclear_operation:

arch/x86/kernel/crash.c:49:30: warning: incorrect type in assignment (different modifiers)
arch/x86/kernel/crash.c:49:30: expected void ( *do_vmclear_operation )( ... )
arch/x86/kernel/crash.c:49:30: got void ( [noderef] *<noident> )( ... )
arch/x86/kernel/crash.c:49:30: warning: incorrect type in assignment (different modifiers)
arch/x86/kernel/crash.c:49:30: expected void ( *do_vmclear_operation )( ... )
arch/x86/kernel/crash.c:49:30: got void ( [noderef] *<noident> )( ... )

So I made the #define to cast its type.

If you have any suggestion, that'll be helpful.

Thanks
Zhang Yanfei

#3 lore raw
Quoted 57 lines · Zhang Yanfei
Quoted 40 lines · Marcelo Tosatti
Quoted 30 lines · Zhang Yanfei

This removes the sparse warning:
arch/x86/kernel/crash.c:49:32: sparse: incompatible types in comparison expression (different address spaces)

---
 arch/x86/include/asm/kexec.h |    4 +++-
 arch/x86/kernel/crash.c      |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/asm/kexec.h +3 -1
index 28feeba..16882cd 100644
@@ -163,7 +163,9 @@ struct kimage_arch {
 };
 #endif
 
-extern void (*crash_vmclear_loaded_vmcss)(void);
+extern void __rcu (*crash_vmclear_loaded_vmcss)(void);
+#define vmclear_func_rcu(vmclear_func) \
+	((void (*)(void)) rcu_dereference(vmclear_func))
 
 #endif /* __ASSEMBLY__ */
 
arch/x86/kernel/crash.c +0 -0
index 2f6b8e8..50ce1d6 100644

arch/x86/kernel/crash.c int in_crash_kexec; · line 41

Quoted 5 lines
arch/x86/kernel/crash.c +1 -1
@@ -38,7 +38,7 @@ int in_crash_kexec;
  *
  * protected by rcu.
  */
-void (*crash_vmclear_loaded_vmcss)(void) = NULL;
+void __rcu (*crash_vmclear_loaded_vmcss)(void) = NULL;

Isnt this (__rcu AS tag) sufficient? After all, sparse is complaining about namespaces.

Quoted 3 lines

Creating a #define to cast seems excessive.

I am not very familiar with the rcu.
Adding __rcu tag could solve the problem. But it imported another warning when I try to assign rcu_dereference(crash_vmclear_loaded_vmcss) to do_vmclear_operation:

arch/x86/kernel/crash.c:49:30: warning: incorrect type in assignment (different modifiers)
arch/x86/kernel/crash.c:49:30: expected void ( *do_vmclear_operation )( ... )
arch/x86/kernel/crash.c:49:30: got void ( [noderef] *<noident> )( ... )
arch/x86/kernel/crash.c:49:30: warning: incorrect type in assignment (different modifiers)
arch/x86/kernel/crash.c:49:30: expected void ( *do_vmclear_operation )( ... )
arch/x86/kernel/crash.c:49:30: got void ( [noderef] *<noident> )( ... )

Quoted 4 lines

So I made the #define to cast its type.

If you have any suggestion, that'll be helpful.

Try to use typedef.

--
Gleb.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
Quoted 58 lines · Gleb Natapov
Quoted 57 lines · Zhang Yanfei
Quoted 40 lines · Marcelo Tosatti
Quoted 30 lines · Zhang Yanfei

This removes the sparse warning:
arch/x86/kernel/crash.c:49:32: sparse: incompatible types in comparison expression (different address spaces)

---
 arch/x86/include/asm/kexec.h |    4 +++-
 arch/x86/kernel/crash.c      |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/asm/kexec.h +3 -1
index 28feeba..16882cd 100644
@@ -163,7 +163,9 @@ struct kimage_arch {
 };
 #endif
 
-extern void (*crash_vmclear_loaded_vmcss)(void);
+extern void __rcu (*crash_vmclear_loaded_vmcss)(void);
+#define vmclear_func_rcu(vmclear_func) \
+	((void (*)(void)) rcu_dereference(vmclear_func))
 
 #endif /* __ASSEMBLY__ */
 
arch/x86/kernel/crash.c +0 -0
index 2f6b8e8..50ce1d6 100644

arch/x86/kernel/crash.c int in_crash_kexec; · line 41

Quoted 5 lines
arch/x86/kernel/crash.c +1 -1
@@ -38,7 +38,7 @@ int in_crash_kexec;
  *
  * protected by rcu.
  */
-void (*crash_vmclear_loaded_vmcss)(void) = NULL;
+void __rcu (*crash_vmclear_loaded_vmcss)(void) = NULL;

Isnt this (__rcu AS tag) sufficient? After all, sparse is complaining about namespaces.

Quoted 3 lines

Creating a #define to cast seems excessive.

I am not very familiar with the rcu.
Adding __rcu tag could solve the problem. But it imported another warning when I try to assign rcu_dereference(crash_vmclear_loaded_vmcss) to do_vmclear_operation:

arch/x86/kernel/crash.c:49:30: warning: incorrect type in assignment (different modifiers)
arch/x86/kernel/crash.c:49:30: expected void ( *do_vmclear_operation )( ... )
arch/x86/kernel/crash.c:49:30: got void ( [noderef] *<noident> )( ... )
arch/x86/kernel/crash.c:49:30: warning: incorrect type in assignment (different modifiers)
arch/x86/kernel/crash.c:49:30: expected void ( *do_vmclear_operation )( ... )
arch/x86/kernel/crash.c:49:30: got void ( [noderef] *<noident> )( ... )

Quoted 6 lines
Quoted 4 lines

So I made the #define to cast its type.

If you have any suggestion, that'll be helpful.

Try to use typedef.

Thanks. typedef works.

#5 lore raw

PATCH RESEND 1/1 x86/kexec: crash_vmclear_local_vmcss needs __rcu

In reply to Zhang Yanfei

This removes the sparse warning:
arch/x86/kernel/crash.c:49:32: sparse: incompatible types in comparison expression (different address spaces)

---
 arch/x86/include/asm/kexec.h |    3 ++-
 arch/x86/kernel/crash.c      |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/include/asm/kexec.h +2 -1
index 28feeba..6080d26 100644
@@ -163,7 +163,8 @@ struct kimage_arch {
 };
 #endif
 
-extern void (*crash_vmclear_loaded_vmcss)(void);
+typedef void crash_vmclear_fn(void);
+extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss;
 
 #endif /* __ASSEMBLY__ */
 
arch/x86/kernel/crash.c +2 -2
index 2f6b8e8..74467fe 100644
@@ -38,12 +38,12 @@ int in_crash_kexec;
  *
  * protected by rcu.
  */
-void (*crash_vmclear_loaded_vmcss)(void) = NULL;
+crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss = NULL;
 EXPORT_SYMBOL_GPL(crash_vmclear_loaded_vmcss);
 
 static inline void cpu_crash_vmclear_loaded_vmcss(void)
 {
-	void (*do_vmclear_operation)(void) = NULL;
+	crash_vmclear_fn *do_vmclear_operation = NULL;
 
 	rcu_read_lock();
 	do_vmclear_operation = rcu_dereference(crash_vmclear_loaded_vmcss);
Signature · 1 line
1.7.1