linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about the sparse memory section size
@ 2015-09-22  8:14 chenfeng
  2015-09-22 11:17 ` Dave Martin
  0 siblings, 1 reply; 3+ messages in thread
From: chenfeng @ 2015-09-22  8:14 UTC (permalink / raw)
  To: catalin.marinas, will.deacon, mark.rutland, ard.biesheuvel,
	lauraa, linux-arm-kernel, linux-kernel
  Cc: Yiping Xu, oliver.fu, suzhuangluan, Dan zhao, Peter Panshilin, qijiwen

Hi all,
The sparse memory section size, SECTION_SIZE_BITS, currently is 1GB for arm64 by default. However, it might generate wasted memmap memory space for those memory sections less than 1GB. e.g.
for 512MB memory section, still 14MB(sizeof(struct page) * PAGES_PER_SECTION) memmap needs to be reserved. The wasted memmap space could be eliminated by changing memory section size from 1GB to 512M, but still some questions to be answered,

1) why arm64 uses 1GB as default setting?
2) any risk to change section size from 1GB to 512MB? like, any impact to performance since memory section number is increased.


Any help will be appreciated.

Puck


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about the sparse memory section size
  2015-09-22  8:14 Question about the sparse memory section size chenfeng
@ 2015-09-22 11:17 ` Dave Martin
       [not found]   ` <13BC74040D0EF941B37FE727464B56DA8A5E2696@szxema508-mbx.china.huawei.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Martin @ 2015-09-22 11:17 UTC (permalink / raw)
  To: chenfeng
  Cc: catalin.marinas, will.deacon, mark.rutland, ard.biesheuvel,
	lauraa, linux-arm-kernel, linux-kernel, Dan zhao, Yiping Xu,
	suzhuangluan, qijiwen, oliver.fu, Peter Panshilin

On Tue, Sep 22, 2015 at 04:14:21PM +0800, chenfeng wrote:
> Hi all,
> The sparse memory section size, SECTION_SIZE_BITS, currently is 1GB
> for arm64 by default. However, it might generate wasted memmap memory
> space for those memory sections less than 1GB. e.g.
> 
> for 512MB memory section, still 14MB(sizeof(struct page) *
> PAGES_PER_SECTION) memmap needs to be reserved. The wasted memmap
> space could be eliminated by changing memory section size from 1GB to
> 512M, but still some questions to be answered,
> 
> 1) why arm64 uses 1GB as default setting?
> 2) any risk to change section size from 1GB to 512MB? like, any
> impact to performance since memory section number is increased.

For arm64 we have SPARSEMEM_VMEMMAP enabled by default, which enables
much of the wasted memmap backing memory to be reclaimed.

Take a look at arch/arm64/mm/init.c:free_unused_memmap().

This should reduce the amount of actual memory wasted on unused parts
of memmap.  The virtual space stays wasted as you describe, but that's
plentiful on 64-bit arches.

You could try sticking some printks in there is you want to see how much
of the memmap the code successfully frees.

Cheers
---Dave


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 答复: Question about the sparse memory section size
       [not found]   ` <13BC74040D0EF941B37FE727464B56DA8A5E2696@szxema508-mbx.china.huawei.com>
@ 2015-09-23 12:08     ` Dave P Martin
  0 siblings, 0 replies; 3+ messages in thread
From: Dave P Martin @ 2015-09-23 12:08 UTC (permalink / raw)
  To: Qijiwen
  Cc: Chenfeng (puck),
	Catalin Marinas, Will Deacon, Mark Rutland, ard.biesheuvel,
	lauraa, linux-arm-kernel, linux-kernel, Dan zhao, Xuyiping,
	Suzhuangluan, fujun (F), Panshilin (Peter)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 2842 bytes --]

On Wed, Sep 23, 2015 at 02:16:45AM +0100, Qijiwen wrote:
> In fact the free_unused_memmap function is not invoked when CONFIG_SPARSEMEM_VMEMMAP is enabled. 
> The reason is that the memmap region is mapped in unit of 2MB, not in unit of 4KB.
> 
> Below is the source code in arch/arm64/mm/init.c:
> void __init mem_init(void)
> {
> 	swiotlb_init(1);
> 
> 	set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
> 
> #ifndef CONFIG_SPARSEMEM_VMEMMAP
> 	free_unused_memmap();
> #endif

Oops, you're right.  But if we're not already doing so, it could still
make sense to unmap useless backing memory from the vmemmap, or try
harder to avoid mapping it in the first place.

However, whether this is is worth it depends on what fraction of
memory is wasted on your platform.  After all, every page struct is
"wasted" memory.  Which means 1-2% of RAM is always "wasted" for
a kernel with 4KB page size anyway.

Cheers
---Dave

[...]

> 
> Best regards,
> 
> Jiwen Qi
> 
> -----邮件原件-----
> 发件人: Dave Martin [mailto:Dave.Martin@arm.com] 
> 发送时间: 2015年9月22日 19:17
> 收件人: Chenfeng (puck)
> 抄送: catalin.marinas@arm.com; will.deacon@arm.com; mark.rutland@arm.com; ard.biesheuvel@linaro.org; lauraa@codeaurora.org; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Dan zhao; Xuyiping; Suzhuangluan; Qijiwen; fujun (F); Panshilin (Peter)
> 主题: Re: Question about the sparse memory section size
> 
> On Tue, Sep 22, 2015 at 04:14:21PM +0800, chenfeng wrote:
> > Hi all,
> > The sparse memory section size, SECTION_SIZE_BITS, currently is 1GB 
> > for arm64 by default. However, it might generate wasted memmap memory 
> > space for those memory sections less than 1GB. e.g.
> > 
> > for 512MB memory section, still 14MB(sizeof(struct page) *
> > PAGES_PER_SECTION) memmap needs to be reserved. The wasted memmap 
> > space could be eliminated by changing memory section size from 1GB to 
> > 512M, but still some questions to be answered,
> > 
> > 1) why arm64 uses 1GB as default setting?
> > 2) any risk to change section size from 1GB to 512MB? like, any impact 
> > to performance since memory section number is increased.
> 
> For arm64 we have SPARSEMEM_VMEMMAP enabled by default, which enables much of the wasted memmap backing memory to be reclaimed.
> 
> Take a look at arch/arm64/mm/init.c:free_unused_memmap().
> 
> This should reduce the amount of actual memory wasted on unused parts of memmap.  The virtual space stays wasted as you describe, but that's plentiful on 64-bit arches.
> 
> You could try sticking some printks in there is you want to see how much of the memmap the code successfully frees.
> 
> Cheers
> ---Dave
> 

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-23 12:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22  8:14 Question about the sparse memory section size chenfeng
2015-09-22 11:17 ` Dave Martin
     [not found]   ` <13BC74040D0EF941B37FE727464B56DA8A5E2696@szxema508-mbx.china.huawei.com>
2015-09-23 12:08     ` 答复: " Dave P Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).