mm: sparse: use __aligned() instead of manual padding in mem_section
Subsystems (3)
PATCH 1/1 mm: sparse: use __aligned() instead of manual padding in mem_section
Instead of leaving a trap for the next person who comes along and wants to add something to mem_section, add an __aligned() and remove the manual padding added for MEMCG.
--- include/linux/mmzone.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
---
Also, does anyone know what causes this alignment to be required here? I found this was breaking things in a patchset I'm working on (WARNs in sysfs code about duplicate filenames when initing mem_sections). Adding some documentation for the reason would be appreciated.
include/linux/mmzone.h +1 -2
@@ -1125,9 +1125,8 @@ struct mem_section {* section. (see memcontrol.h/page_cgroup.h about this.) */ struct page_cgroup *page_cgroup; -unsigned long pad;#endif -}; +}__aligned(2 * sizeof(unsigned long)) ;#ifdef CONFIG_SPARSEMEM_EXTREME #define SECTIONS_PER_ROOT (PAGE_SIZE / sizeof (struct mem_section))
Signature · 7 lines
1.8.3 -- 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>
Quoted 9 lines · Cody P Schafer
Instead of leaving a trap for the next person who comes along and wants to add something to
mem_section, add an__aligned()and remove the manual padding added for MEMCG.Signed-off-by Cody P Schafer <[email protected]>--- include/linux/mmzone.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 6 lines
---
Also, does anyone know what causes this alignment to be required here? I found this was breaking things in a patchset I'm working on (WARNs in sysfs code about duplicate filenames when initing
mem_sections). Adding some documentation for the reason would be appreciated.
Hi Cody,
I think the alignment requirement is caused by the way themem_section array is
organized. Basically it requires that PAGE_SIZE could be divided by sizeof(struct mem_section).
So your change seems risky too because it should be aligned to power of two instead
of 2 * sizeof(long).
Regards!
Gerry
Quoted 6 lines
include/linux/mmzone.h +0
-0
include/linux/mmzone.h struct mem_section { · line 1132
Quoted 10 lines
include/linux/mmzone.h +1
-2@@ -1125,9 +1125,8 @@ struct mem_section {* section. (see memcontrol.h/page_cgroup.h about this.) */ struct page_cgroup *page_cgroup; -unsigned long pad;#endif -}; +}__aligned(2 * sizeof(unsigned long)) ;#ifdef CONFIG_SPARSEMEM_EXTREME #define SECTIONS_PER_ROOT (PAGE_SIZE / sizeof (struct mem_section))
--
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>
Quoted 5 lines · Jiang Liu
Quoted 4 lines · Cody P Schafer
Also, does anyone know what causes this alignment to be required here? I found this was breaking things in a patchset I'm working on (WARNs in sysfs code about duplicate filenames when initing
mem_sections). Adding some documentation for the reason would be appreciated.
Quoted 8 lines
Hi Cody,
I think the alignment requirement is caused by the way themem_sectionarray is
organized. Basically it requires thatPAGE_SIZEcould be divided bysizeof(struct mem_section).
So your change seems risky too because it should be aligned to power of two instead
of 2 * sizeof(long).
Well, if that's the case then this patch is wrong, and manual padding may be the only way to go. :(
--
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>
Quoted 3 lines · Cody P Schafer
Instead of leaving a trap for the next person who comes along and wants to add something to
mem_section, add an__aligned()and remove the manual padding added for MEMCG.
It doesn't need to be aligned technically. It needs to be a power-of-2:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.2/03077.html
I'd be quite happy for someone to resurrect that patch, though. We need a big fat comment in there.
PATCH 1/1 sparsemem: BUILD_BUG_ON when sizeof mem_section is non-power-of-2
Instead of leaving a hidden trap for the next person who comes along and wants to add something to mem_section, add a big fat warning about it needing to be a power-of-2, and insert a BUILD_BUG_ON() in sparse_init() to catch mistakes.
Right now non-power-of-2 mem_sections cause a number of WARNs at boot (which don't clearly point to the size of mem_section as an issue), but the system limps on (temporarily, at least).
This is based upon Dave Hansen's earlier RFC where he ran into the same issue:
"sparsemem: fix boot when SECTIONS_PER_ROOT is not power-of-2" http://lkml.indiana.edu/hypermail/linux/kernel/1205.2/03077.html
---
Dave: Consider it resurrected.
---
include/linux/mmzone.h | 4 ++++ mm/sparse.c | 3 +++ 2 files changed, 7 insertions(+)
include/linux/mmzone.h +4 -0
@@ -1127,6 +1127,10 @@ struct mem_section {struct page_cgroup *page_cgroup;unsigned long pad;#endif +/* +* WARNING: mem_section must be a power-of-2 in size for the +* calculation and use of SECTION_ROOT_MASK to make sense. +*/ };#ifdef CONFIG_SPARSEMEM_EXTREME
mm/sparse.c +3 -0
@@ -481,6 +481,9 @@ void __init sparse_init(void)struct page **map_map;#endif +/* see include/linux/mmzone.h 'struct mem_section' definition */ +BUILD_BUG_ON (!is_power_of_2 (sizeof (struct mem_section ))); +/* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */ set_pageblock_order ();
Signature · 1 line
1.8.3
Re: [PATCH] sparsemem: BUILD_BUG_ON when sizeof mem_section is non-power-of-2
Quoted 5 lines · Cody P Schafer
Instead of leaving a hidden trap for the next person who comes along and wants to add something to
mem_section, add a big fat warning about it needing to be a power-of-2, and insert aBUILD_BUG_ON()insparse_init()to catch mistakes.
Quoted 8 lines
Right now non-power-of-2
mem_sectionscause a number of WARNs at boot (which don't clearly point to the size ofmem_sectionas an issue), but the system limps on (temporarily, at least).This is based upon Dave Hansen's earlier RFC where he ran into the same issue:
"sparsemem: fix boot when SECTIONS_PER_ROOT is not power-of-2" http://lkml.indiana.edu/hypermail/linux/kernel/1205.2/03077.html
Thanks for doing that, Cody. At the risk of patting myself on the back:
--
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>