Skip to contentSkip to conversation

memory-failure: fix section mismatch

PATCH In review Nick Desaulniers 3 participants 3 messages Mar 4, 2018 – Mar 16, 2018

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

PATCH 1/1 memory-failure: fix section mismatch

Clang complains when a variable is declared extern twice, but with two different sections. num_poisoned_pages is marked extern and __read_mostly in include/linux/swapops.h, but only extern in include/linux/mm.h. Some c source files must include both, and thus see the conflicting declarations.

---
 include/linux/mm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mm.h +1 -1
index ad06d42adb1a..bd4bd59f02c1 100644
@@ -2582,7 +2582,7 @@ extern int get_hwpoison_page(struct page *page);
 extern int sysctl_memory_failure_early_kill;
 extern int sysctl_memory_failure_recovery;
 extern void shake_page(struct page *p, int access);
-extern atomic_long_t num_poisoned_pages;
+extern atomic_long_t num_poisoned_pages __read_mostly;
 extern int soft_offline_page(struct page *page, int flags);
 
 
Signature · 7 lines
2.14.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 5 lines · Nick Desaulniers

Clang complains when a variable is declared extern twice, but with two different sections. num_poisoned_pages is marked extern and __read_mostly in include/linux/swapops.h, but only extern in include/linux/mm.h. Some c source files must include both, and thus see the conflicting declarations.

Why do we need declarations in both places? This sounds like a mess to me.

Quoted 21 lines
---
 include/linux/mm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mm.h +1 -1
index ad06d42adb1a..bd4bd59f02c1 100644
@@ -2582,7 +2582,7 @@ extern int get_hwpoison_page(struct page *page);
 extern int sysctl_memory_failure_early_kill;
 extern int sysctl_memory_failure_recovery;
 extern void shake_page(struct page *p, int access);
-extern atomic_long_t num_poisoned_pages;
+extern atomic_long_t num_poisoned_pages __read_mostly;
 extern int soft_offline_page(struct page *page, int flags);
 
 
Signature · 1 line
2.14.1
Signature · 2 lines
Michal Hocko
SUSE Labs
#2 lore raw
In reply to Nick Desaulniers

El Sat, Mar 03, 2018 at 11:16:11PM -0800 Nick Desaulniers ha dit:

Quoted 16 lines

Clang complains when a variable is declared extern twice, but with two different sections. num_poisoned_pages is marked extern and __read_mostly in include/linux/swapops.h, but only extern in include/linux/mm.h. Some c source files must include both, and thus see the conflicting declarations.

---
 include/linux/mm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mm.h +0 -0
index ad06d42adb1a..bd4bd59f02c1 100644

include/linux/mm.h extern int get_hwpoison_page(struct page *page); · line 2586

Quoted 6 lines
include/linux/mm.h +1 -1
@@ -2582,7 +2582,7 @@ extern int get_hwpoison_page(struct page *page);
 extern int sysctl_memory_failure_early_kill;
 extern int sysctl_memory_failure_recovery;
 extern void shake_page(struct page *p, int access);
-extern atomic_long_t num_poisoned_pages;
+extern atomic_long_t num_poisoned_pages __read_mostly;
 extern int soft_offline_page(struct page *page, int flags);

An equivalent patch was posted by Guenter Roeck and has been picked up by Andrew: https://patchwork.kernel.org/patch/10243919/