Re: [PATCH 1/5] mm/sparse: check size of struct mm_section
From: Michal Hocko <hidden>
Date: 2012-06-26 17:57:08
On Tue 26-06-12 16:24:39, Gavin Shan wrote:
quoted
quoted
quoted
quoted
quoted
quoted
In order to fully utilize the memory chunk allocated from bootmem allocator, it'd better to assure memory sector descriptor won't run across the boundary (PAGE_SIZE).OK, I misread this part of the changelog changelog.I should have clarified that more clear :-)quoted
quoted
quoted
Why? The memory is continuous, right?Yes, the memory is conginous and the capacity of specific entry in mem_section[NR_SECTION_ROOTS] has been defined as follows: #define SECTIONS_PER_ROOT (PAGE_SIZE / sizeof (struct mem_section)) Also, the memory is prone to be allocated from bootmem by function alloc_bootmem_node(), which has PAGE_SIZE alignment. So I think it's reasonable to introduce the extra check here from my personal view :-)No it is not necessary because we will never cross the page boundary because (SECTIONS_PER_ROOT uses an int division)Current situation is that we don't cross the page foundary, but somebody else might change the data struct (struct mem_section) in future.No, this is safe even if the structure size changes (unless it is bigger than PAGE_SIZE).Yeah, but it can't fully utilize the allocated memory chunk if the size of the struct isn't aligned well.
And you think that this is justification is sufficient to fail compilation? I don't think so...
Let me drop it in next revision :-) Thanks, Gavin
-- Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>