aboutsummaryrefslogtreecommitdiffstats
path: root/mm/bootmem.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:42:48 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:42:48 -0500
commit40ba587923ae67090d9f141c1d3c951be5c1420e (patch)
tree342a72fc0ee13a0d2496ef970b64dfeadf1355d2 /mm/bootmem.c
parent54c2c5761febcca46c8037d3a81612991e6c209a (diff)
parent6b550f9495947fc279d12c38feaf98500e8d0646 (diff)
Merge branch 'akpm' (aka "Andrew's patch-bomb")
Andrew elucidates: - First installmeant of MM. We have a HUGE number of MM patches this time. It's crazy. - MAINTAINERS updates - backlight updates - leds - checkpatch updates - misc ELF stuff - rtc updates - reiserfs - procfs - some misc other bits * akpm: (124 commits) user namespace: make signal.c respect user namespaces workqueue: make alloc_workqueue() take printf fmt and args for name procfs: add hidepid= and gid= mount options procfs: parse mount options procfs: introduce the /proc/<pid>/map_files/ directory procfs: make proc_get_link to use dentry instead of inode signal: add block_sigmask() for adding sigmask to current->blocked sparc: make SA_NOMASK a synonym of SA_NODEFER reiserfs: don't lock root inode searching reiserfs: don't lock journal_init() reiserfs: delay reiserfs lock until journal initialization reiserfs: delete comments referring to the BKL drivers/rtc/interface.c: fix alarm rollover when day or month is out-of-range drivers/rtc/rtc-twl.c: add DT support for RTC inside twl4030/twl6030 drivers/rtc/: remove redundant spi driver bus initialization drivers/rtc/rtc-jz4740.c: make jz4740_rtc_driver static drivers/rtc/rtc-mc13xxx.c: make mc13xxx_rtc_idtable static rtc: convert drivers/rtc/* to use module_platform_driver() drivers/rtc/rtc-wm831x.c: convert to devm_kzalloc() drivers/rtc/rtc-wm831x.c: remove unused period IRQ handler ...
Diffstat (limited to 'mm/bootmem.c')
-rw-r--r--mm/bootmem.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 1a77012ecdb3..668e94df8cf2 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -56,7 +56,7 @@ early_param("bootmem_debug", bootmem_debug_setup);
56 56
57static unsigned long __init bootmap_bytes(unsigned long pages) 57static unsigned long __init bootmap_bytes(unsigned long pages)
58{ 58{
59 unsigned long bytes = (pages + 7) / 8; 59 unsigned long bytes = DIV_ROUND_UP(pages, 8);
60 60
61 return ALIGN(bytes, sizeof(long)); 61 return ALIGN(bytes, sizeof(long));
62} 62}
@@ -171,7 +171,6 @@ void __init free_bootmem_late(unsigned long addr, unsigned long size)
171 171
172static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) 172static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
173{ 173{
174 int aligned;
175 struct page *page; 174 struct page *page;
176 unsigned long start, end, pages, count = 0; 175 unsigned long start, end, pages, count = 0;
177 176
@@ -181,14 +180,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
181 start = bdata->node_min_pfn; 180 start = bdata->node_min_pfn;
182 end = bdata->node_low_pfn; 181 end = bdata->node_low_pfn;
183 182
184 /* 183 bdebug("nid=%td start=%lx end=%lx\n",
185 * If the start is aligned to the machines wordsize, we might 184 bdata - bootmem_node_data, start, end);
186 * be able to free pages in bulks of that order.
187 */
188 aligned = !(start & (BITS_PER_LONG - 1));
189
190 bdebug("nid=%td start=%lx end=%lx aligned=%d\n",
191 bdata - bootmem_node_data, start, end, aligned);
192 185
193 while (start < end) { 186 while (start < end) {
194 unsigned long *map, idx, vec; 187 unsigned long *map, idx, vec;
@@ -196,12 +189,17 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
196 map = bdata->node_bootmem_map; 189 map = bdata->node_bootmem_map;
197 idx = start - bdata->node_min_pfn; 190 idx = start - bdata->node_min_pfn;
198 vec = ~map[idx / BITS_PER_LONG]; 191 vec = ~map[idx / BITS_PER_LONG];
199 192 /*
200 if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) { 193 * If we have a properly aligned and fully unreserved
194 * BITS_PER_LONG block of pages in front of us, free
195 * it in one go.
196 */
197 if (IS_ALIGNED(start, BITS_PER_LONG) && vec == ~0UL) {
201 int order = ilog2(BITS_PER_LONG); 198 int order = ilog2(BITS_PER_LONG);
202 199
203 __free_pages_bootmem(pfn_to_page(start), order); 200 __free_pages_bootmem(pfn_to_page(start), order);
204 count += BITS_PER_LONG; 201 count += BITS_PER_LONG;
202 start += BITS_PER_LONG;
205 } else { 203 } else {
206 unsigned long off = 0; 204 unsigned long off = 0;
207 205
@@ -214,8 +212,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
214 vec >>= 1; 212 vec >>= 1;
215 off++; 213 off++;
216 } 214 }
215 start = ALIGN(start + 1, BITS_PER_LONG);
217 } 216 }
218 start += BITS_PER_LONG;
219 } 217 }
220 218
221 page = virt_to_page(bdata->node_bootmem_map); 219 page = virt_to_page(bdata->node_bootmem_map);