<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/mm/bootmem.c, branch v3.10.2</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/mm/bootmem.c?h=v3.10.2</id>
<link rel='self' href='https://git.amat.us/linux/atom/mm/bootmem.c?h=v3.10.2'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2013-01-30T03:32:59Z</updated>
<entry>
<title>mm: Add alloc_bootmem_low_pages_nopanic()</title>
<updated>2013-01-30T03:32:59Z</updated>
<author>
<name>Yinghai Lu</name>
<email>yinghai@kernel.org</email>
</author>
<published>2013-01-24T20:20:15Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=38fa4175e60d98fb1c9815fb14f8057576dade73'/>
<id>urn:sha1:38fa4175e60d98fb1c9815fb14f8057576dade73</id>
<content type='text'>
We don't need to panic in some case, like for swiotlb preallocating.

Signed-off-by: Yinghai Lu &lt;yinghai@kernel.org&gt;
Link: http://lkml.kernel.org/r/1359058816-7615-35-git-send-email-yinghai@kernel.org
Signed-off-by: H. Peter Anvin &lt;hpa@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>mm: bootmem: fix free_all_bootmem_core() with odd bitmap alignment</title>
<updated>2013-01-11T22:54:55Z</updated>
<author>
<name>Max Filippov</name>
<email>jcmvbkbc@gmail.com</email>
</author>
<published>2013-01-11T22:31:52Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=10d73e655cef6e86ea8589dca3df4e495e4900b0'/>
<id>urn:sha1:10d73e655cef6e86ea8589dca3df4e495e4900b0</id>
<content type='text'>
Currently free_all_bootmem_core ignores that node_min_pfn may be not
multiple of BITS_PER_LONG.  Eg commit 6dccdcbe2c3e ("mm: bootmem: fix
checking the bitmap when finally freeing bootmem") shifts vec by lower
bits of start instead of lower bits of idx.  Also

  if (IS_ALIGNED(start, BITS_PER_LONG) &amp;&amp; vec == ~0UL)

assumes that vec bit 0 corresponds to start pfn, which is only true when
node_min_pfn is a multiple of BITS_PER_LONG.  Also loop in the else
clause can double-free pages (e.g.  with node_min_pfn == start == 1,
map[0] == ~0 on 32-bit machine page 32 will be double-freed).

This bug causes the following message during xtensa kernel boot:

  bootmem::free_all_bootmem_core nid=0 start=1 end=8000
  BUG: Bad page state in process swapper  pfn:00001
  page:d04bd020 count:0 mapcount:-127 mapping:  (null) index:0x2
  page flags: 0x0()
  Call Trace:
    bad_page+0x8c/0x9c
    free_pages_prepare+0x5e/0x88
    free_hot_cold_page+0xc/0xa0
    __free_pages+0x24/0x38
    __free_pages_bootmem+0x54/0x56
    free_all_bootmem_core$part$11+0xeb/0x138
    free_all_bootmem+0x46/0x58
    mem_init+0x25/0xa4
    start_kernel+0x11e/0x25c
    should_never_return+0x0/0x3be7

The fix is the following:
 - always align vec so that its bit 0 corresponds to start
 - provide BITS_PER_LONG bits in vec, if those bits are available in the
   map
 - don't free pages past next start position in the else clause.

Signed-off-by: Max Filippov &lt;jcmvbkbc@gmail.com&gt;
Cc: Gavin Shan &lt;shangw@linux.vnet.ibm.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Yinghai Lu &lt;yinghai@kernel.org&gt;
Cc: Joonsoo Kim &lt;js1304@gmail.com&gt;
Cc: Prasad Koya &lt;prasad.koya@gmail.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm/bootmem.c: remove unused wrapper function reserve_bootmem_generic()</title>
<updated>2012-12-13T01:38:35Z</updated>
<author>
<name>Lin Feng</name>
<email>linfeng@cn.fujitsu.com</email>
</author>
<published>2012-12-12T21:52:39Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=98870901cce098bbe94d90d2c41d8d1fa8d94392'/>
<id>urn:sha1:98870901cce098bbe94d90d2c41d8d1fa8d94392</id>
<content type='text'>
reserve_bootmem_generic() has no caller,

Signed-off-by: Lin Feng &lt;linfeng@cn.fujitsu.com&gt;
Acked-by: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Yinghai Lu &lt;yinghai@kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm: introduce new field "managed_pages" to struct zone</title>
<updated>2012-12-13T01:38:34Z</updated>
<author>
<name>Jiang Liu</name>
<email>liuj97@gmail.com</email>
</author>
<published>2012-12-12T21:52:12Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=9feedc9d831e18ae6d0d15aa562e5e46ba53647b'/>
<id>urn:sha1:9feedc9d831e18ae6d0d15aa562e5e46ba53647b</id>
<content type='text'>
Currently a zone's present_pages is calcuated as below, which is
inaccurate and may cause trouble to memory hotplug.

	spanned_pages - absent_pages - memmap_pages - dma_reserve.

During fixing bugs caused by inaccurate zone-&gt;present_pages, we found
zone-&gt;present_pages has been abused.  The field zone-&gt;present_pages may
have different meanings in different contexts:

1) pages existing in a zone.
2) pages managed by the buddy system.

For more discussions about the issue, please refer to:
  http://lkml.org/lkml/2012/11/5/866
  https://patchwork.kernel.org/patch/1346751/

This patchset tries to introduce a new field named "managed_pages" to
struct zone, which counts "pages managed by the buddy system".  And revert
zone-&gt;present_pages to count "physical pages existing in a zone", which
also keep in consistence with pgdat-&gt;node_present_pages.

We will set an initial value for zone-&gt;managed_pages in function
free_area_init_core() and will adjust it later if the initial value is
inaccurate.

For DMA/normal zones, the initial value is set to:

	(spanned_pages - absent_pages - memmap_pages - dma_reserve)

Later zone-&gt;managed_pages will be adjusted to the accurate value when the
bootmem allocator frees all free pages to the buddy system in function
free_all_bootmem_node() and free_all_bootmem().

The bootmem allocator doesn't touch highmem pages, so highmem zones'
managed_pages is set to the accurate value "spanned_pages - absent_pages"
in function free_area_init_core() and won't be updated anymore.

This patch also adds a new field "managed_pages" to /proc/zoneinfo
and sysrq showmem.

[akpm@linux-foundation.org: small comment tweaks]
Signed-off-by: Jiang Liu &lt;jiang.liu@huawei.com&gt;
Cc: Wen Congyang &lt;wency@cn.fujitsu.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Maciej Rutecki &lt;maciej.rutecki@gmail.com&gt;
Tested-by: Chris Clayton &lt;chris2553@googlemail.com&gt;
Cc: "Rafael J . Wysocki" &lt;rjw@sisk.pl&gt;
Cc: Mel Gorman &lt;mgorman@suse.de&gt;
Cc: Minchan Kim &lt;minchan@kernel.org&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;
Cc: Jianguo Wu &lt;wujianguo@huawei.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>bootmem: remove alloc_arch_preferred_bootmem()</title>
<updated>2012-12-13T01:38:31Z</updated>
<author>
<name>Joonsoo Kim</name>
<email>js1304@gmail.com</email>
</author>
<published>2012-12-12T21:50:43Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=3f7dfe24b84c0ad698c461fc9c4ba3544bbfcebf'/>
<id>urn:sha1:3f7dfe24b84c0ad698c461fc9c4ba3544bbfcebf</id>
<content type='text'>
The name of this function is not suitable, and removing the function and
open-coding it into each call sites makes the code more understandable.

Additionally, we shouldn't do an allocation from bootmem when
slab_is_available(), so directly return kmalloc()'s return value.

Signed-off-by: Joonsoo Kim &lt;js1304@gmail.com&gt;
Cc: Haavard Skinnemoen &lt;hskinnemoen@gmail.com&gt;
Cc: Hans-Christian Egtvedt &lt;egtvedt@samfundet.no&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: FUJITA Tomonori &lt;fujita.tomonori@lab.ntt.co.jp&gt;
Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>bootmem: remove not implemented function call, bootmem_arch_preferred_node()</title>
<updated>2012-12-13T01:38:30Z</updated>
<author>
<name>Joonsoo Kim</name>
<email>js1304@gmail.com</email>
</author>
<published>2012-12-12T21:50:42Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=2d7a695604556913d9ef1ead47881b804d6c52b4'/>
<id>urn:sha1:2d7a695604556913d9ef1ead47881b804d6c52b4</id>
<content type='text'>
There is no implementation of bootmem_arch_preferred_node() and a call to
this function will cause a compilation error.  So remove it.

Signed-off-by: Joonsoo Kim &lt;js1304@gmail.com&gt;
Cc: Haavard Skinnemoen &lt;hskinnemoen@gmail.com&gt;
Cc: Hans-Christian Egtvedt &lt;egtvedt@samfundet.no&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: FUJITA Tomonori &lt;fujita.tomonori@lab.ntt.co.jp&gt;
Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>bootmem: fix wrong call parameter for free_bootmem()</title>
<updated>2012-12-12T01:22:28Z</updated>
<author>
<name>Joonsoo Kim</name>
<email>js1304@gmail.com</email>
</author>
<published>2012-12-12T00:03:10Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=81df9bff2609f07cef4690ac2ebda1611b55b05a'/>
<id>urn:sha1:81df9bff2609f07cef4690ac2ebda1611b55b05a</id>
<content type='text'>
It is strange that alloc_bootmem() returns a virtual address and
free_bootmem() requires a physical address.  Anyway, free_bootmem()'s
first parameter should be physical address.

There are some call sites for free_bootmem() with virtual address.  So fix
them.

[akpm@linux-foundation.org: improve free_bootmem() and free_bootmem_pate() documentation]
Signed-off-by: Joonsoo Kim &lt;js1304@gmail.com&gt;
Cc: Haavard Skinnemoen &lt;hskinnemoen@gmail.com&gt;
Cc: Hans-Christian Egtvedt &lt;egtvedt@samfundet.no&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: FUJITA Tomonori &lt;fujita.tomonori@lab.ntt.co.jp&gt;
Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>revert "mm: fix-up zone present pages"</title>
<updated>2012-11-16T22:33:04Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2012-11-16T22:15:06Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=5576646f3c1abd60d72d19829de6f5d8c2ca8ecf'/>
<id>urn:sha1:5576646f3c1abd60d72d19829de6f5d8c2ca8ecf</id>
<content type='text'>
Revert commit 7f1290f2f2a4 ("mm: fix-up zone present pages")

That patch tried to fix a issue when calculating zone-&gt;present_pages,
but it caused a regression on 32bit systems with HIGHMEM.  With that
change, reset_zone_present_pages() resets all zone-&gt;present_pages to
zero, and fixup_zone_present_pages() is called to recalculate
zone-&gt;present_pages when the boot allocator frees core memory pages into
buddy allocator.  Because highmem pages are not freed by bootmem
allocator, all highmem zones' present_pages becomes zero.

Various options for improving the situation are being discussed but for
now, let's return to the 3.6 code.

Cc: Jianguo Wu &lt;wujianguo@huawei.com&gt;
Cc: Jiang Liu &lt;jiang.liu@huawei.com&gt;
Cc: Petr Tesarik &lt;ptesarik@suse.cz&gt;
Cc: "Luck, Tony" &lt;tony.luck@intel.com&gt;
Cc: Mel Gorman &lt;mel@csn.ul.ie&gt;
Cc: Yinghai Lu &lt;yinghai@kernel.org&gt;
Cc: Minchan Kim &lt;minchan.kim@gmail.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Tested-by: Chris Clayton &lt;chris2553@googlemail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm: fix-up zone present pages</title>
<updated>2012-10-09T07:22:54Z</updated>
<author>
<name>Jianguo Wu</name>
<email>wujianguo@huawei.com</email>
</author>
<published>2012-10-08T23:33:06Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7f1290f2f2a4d2c3f1b7ce8e87256e052ca23125'/>
<id>urn:sha1:7f1290f2f2a4d2c3f1b7ce8e87256e052ca23125</id>
<content type='text'>
I think zone-&gt;present_pages indicates pages that buddy system can management,
it should be:

	zone-&gt;present_pages = spanned pages - absent pages - bootmem pages,

but is now:
	zone-&gt;present_pages = spanned pages - absent pages - memmap pages.

spanned pages: total size, including holes.
absent pages: holes.
bootmem pages: pages used in system boot, managed by bootmem allocator.
memmap pages: pages used by page structs.

This may cause zone-&gt;present_pages less than it should be.  For example,
numa node 1 has ZONE_NORMAL and ZONE_MOVABLE, it's memmap and other
bootmem will be allocated from ZONE_MOVABLE, so ZONE_NORMAL's
present_pages should be spanned pages - absent pages, but now it also
minus memmap pages(free_area_init_core), which are actually allocated from
ZONE_MOVABLE.  When offlining all memory of a zone, this will cause
zone-&gt;present_pages less than 0, because present_pages is unsigned long
type, it is actually a very large integer, it indirectly caused
zone-&gt;watermark[WMARK_MIN] becomes a large
integer(setup_per_zone_wmarks()), than cause totalreserve_pages become a
large integer(calculate_totalreserve_pages()), and finally cause memory
allocating failure when fork process(__vm_enough_memory()).

[root@localhost ~]# dmesg
-bash: fork: Cannot allocate memory

I think the bug described in

  http://marc.info/?l=linux-mm&amp;m=134502182714186&amp;w=2

is also caused by wrong zone present pages.

This patch intends to fix-up zone-&gt;present_pages when memory are freed to
buddy system on x86_64 and IA64 platforms.

Signed-off-by: Jianguo Wu &lt;wujianguo@huawei.com&gt;
Signed-off-by: Jiang Liu &lt;jiang.liu@huawei.com&gt;
Reported-by: Petr Tesarik &lt;ptesarik@suse.cz&gt;
Tested-by: Petr Tesarik &lt;ptesarik@suse.cz&gt;
Cc: "Luck, Tony" &lt;tony.luck@intel.com&gt;
Cc: Mel Gorman &lt;mel@csn.ul.ie&gt;
Cc: Yinghai Lu &lt;yinghai@kernel.org&gt;
Cc: Minchan Kim &lt;minchan.kim@gmail.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>bootmem: Fix the short description of reserve_bootmem()</title>
<updated>2012-08-27T14:57:21Z</updated>
<author>
<name>Javi Merino</name>
<email>javi.merino@arm.com</email>
</author>
<published>2012-08-24T17:09:31Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=0d4ba4d7b115bd37cfa64274273eb91e848bd236'/>
<id>urn:sha1:0d4ba4d7b115bd37cfa64274273eb91e848bd236</id>
<content type='text'>
It marks pages as reserved, as the long description says.

Signed-off-by: Javi Merino &lt;javi.merino@arm.com&gt;
Acked-by: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
</content>
</entry>
</feed>
