lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 28 Mar 2017 09:11:37 +0800
From:   Wei Yang <richard.weiyang@...il.com>
To:     mgorman@...hsingularity.net, jiang.liu@...ux.intel.com,
        mhocko@...e.com, akpm@...ux-foundation.org, tj@...nel.org,
        mingo@...nel.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: [RFC] calc_memmap_size() isn't accurate and one suggestion to improve

Hi, masters,

# What I found

I found the function calc_memmap_size() may not be that accurate to get the
pages for memmap.

The reason is:

> memmap is allocated on a node base,
> while the calculation is on a zone base

This applies both to SPARSEMEM and FLATMEM.

For example, on my laptop with 6G memory, all the memmap space is allocated
from ZONE_NORMAL.

# My suggestion 

Current code path is:

    sparse_init()                          <- memmap allocated
    zone_sizes_init()
        free_area_init_nodes()
	    calculate_node_totalpages()
	    free_area_init_core()          <- where we do the calculation

From the code snippet, memmap is already allocated in memblock, which
means we can get the information by comparing memblock.memory and
memblock.reserved.

My suggestion is to record this information in pg_data_t in
calculate_node_totalpages(), which is already doing the calculation on each
zone's spanned_pages and present_pages.

# Other solutions came to my mind

1. Assume all the memmap is allocated from the highest zone.

Pro:

Easy to calculate

Cor:

Not good to do this assumption. How to set the boundary. And there is the case
memory is allocated bottom-up.

2. Record the memmap area for each allocation

Pro:

Accurate and exact the size and zone index is recorded.

Cor:

Too expensive, especially when VMEMMAP && !ALLOC_MEM_MAP_TOGETHER. There would
be too many.

# Look for you comment

This code path applies to most of the arch, while I am not 100% for sure this
applies to all the arch. If isn't, this change may not be a good one.

The solution looks good to me, while I may miss some corner case or some
important facts.

Willing to hear from you :-)

-- 
Wei Yang
Help you, Help me

-- 
Wei Yang
Help you, Help me

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists