aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-08-14 02:00:49 -0400
committerTejun Heo <tj@kernel.org>2009-08-14 02:00:49 -0400
commit00ae4064b1445524752575dd84df227c0687c99d (patch)
treebfe3400aed0d9f97c15ac991ba09af32387056ae
parent004018e2c06b9c650e88dddd973ae36799ed72b9 (diff)
percpu: rename 4k first chunk allocator to page
Page size isn't always 4k depending on arch and configuration. Rename 4k first chunk allocator to page. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: David Howells <dhowells@redhat.com>
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--arch/x86/kernel/setup_percpu.c23
-rw-r--r--include/linux/percpu.h2
-rw-r--r--mm/percpu.c25
4 files changed, 28 insertions, 24 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 7936b801fe6a..12e9eb77ee0d 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1920,7 +1920,7 @@ and is between 256 and 4096 characters. It is defined in the file
1920 See arch/parisc/kernel/pdc_chassis.c 1920 See arch/parisc/kernel/pdc_chassis.c
1921 1921
1922 percpu_alloc= [X86] Select which percpu first chunk allocator to use. 1922 percpu_alloc= [X86] Select which percpu first chunk allocator to use.
1923 Allowed values are one of "lpage", "embed" and "4k". 1923 Allowed values are one of "lpage", "embed" and "page".
1924 See comments in arch/x86/kernel/setup_percpu.c for 1924 See comments in arch/x86/kernel/setup_percpu.c for
1925 details on each allocator. This parameter is primarily 1925 details on each allocator. This parameter is primarily
1926 for debugging and performance comparison. 1926 for debugging and performance comparison.
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index a26ff61e2fb0..1e17711c29d6 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -249,21 +249,22 @@ static ssize_t __init setup_pcpu_embed(size_t static_size, bool chosen)
249} 249}
250 250
251/* 251/*
252 * 4k allocator 252 * Page allocator
253 * 253 *
254 * Boring fallback 4k allocator. This allocator puts more pressure on 254 * Boring fallback 4k page allocator. This allocator puts more
255 * PTE TLBs but other than that behaves nicely on both UMA and NUMA. 255 * pressure on PTE TLBs but other than that behaves nicely on both UMA
256 * and NUMA.
256 */ 257 */
257static void __init pcpu4k_populate_pte(unsigned long addr) 258static void __init pcpup_populate_pte(unsigned long addr)
258{ 259{
259 populate_extra_pte(addr); 260 populate_extra_pte(addr);
260} 261}
261 262
262static ssize_t __init setup_pcpu_4k(size_t static_size) 263static ssize_t __init setup_pcpu_page(size_t static_size)
263{ 264{
264 return pcpu_4k_first_chunk(static_size, PERCPU_FIRST_CHUNK_RESERVE, 265 return pcpu_page_first_chunk(static_size, PERCPU_FIRST_CHUNK_RESERVE,
265 pcpu_fc_alloc, pcpu_fc_free, 266 pcpu_fc_alloc, pcpu_fc_free,
266 pcpu4k_populate_pte); 267 pcpup_populate_pte);
267} 268}
268 269
269/* for explicit first chunk allocator selection */ 270/* for explicit first chunk allocator selection */
@@ -307,7 +308,7 @@ void __init setup_per_cpu_areas(void)
307 */ 308 */
308 ret = -EINVAL; 309 ret = -EINVAL;
309 if (strlen(pcpu_chosen_alloc)) { 310 if (strlen(pcpu_chosen_alloc)) {
310 if (strcmp(pcpu_chosen_alloc, "4k")) { 311 if (strcmp(pcpu_chosen_alloc, "page")) {
311 if (!strcmp(pcpu_chosen_alloc, "lpage")) 312 if (!strcmp(pcpu_chosen_alloc, "lpage"))
312 ret = setup_pcpu_lpage(static_size, true); 313 ret = setup_pcpu_lpage(static_size, true);
313 else if (!strcmp(pcpu_chosen_alloc, "embed")) 314 else if (!strcmp(pcpu_chosen_alloc, "embed"))
@@ -317,7 +318,7 @@ void __init setup_per_cpu_areas(void)
317 "specified\n", pcpu_chosen_alloc); 318 "specified\n", pcpu_chosen_alloc);
318 if (ret < 0) 319 if (ret < 0)
319 pr_warning("PERCPU: %s allocator failed (%zd), " 320 pr_warning("PERCPU: %s allocator failed (%zd), "
320 "falling back to 4k\n", 321 "falling back to page size\n",
321 pcpu_chosen_alloc, ret); 322 pcpu_chosen_alloc, ret);
322 } 323 }
323 } else { 324 } else {
@@ -326,7 +327,7 @@ void __init setup_per_cpu_areas(void)
326 ret = setup_pcpu_embed(static_size, false); 327 ret = setup_pcpu_embed(static_size, false);
327 } 328 }
328 if (ret < 0) 329 if (ret < 0)
329 ret = setup_pcpu_4k(static_size); 330 ret = setup_pcpu_page(static_size);
330 if (ret < 0) 331 if (ret < 0)
331 panic("cannot allocate static percpu area (%zu bytes, err=%zd)", 332 panic("cannot allocate static percpu area (%zu bytes, err=%zd)",
332 static_size, ret); 333 static_size, ret);
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index e134c8229631..7989f61b03f3 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -74,7 +74,7 @@ extern ssize_t __init pcpu_embed_first_chunk(
74 size_t static_size, size_t reserved_size, 74 size_t static_size, size_t reserved_size,
75 ssize_t dyn_size); 75 ssize_t dyn_size);
76 76
77extern ssize_t __init pcpu_4k_first_chunk( 77extern ssize_t __init pcpu_page_first_chunk(
78 size_t static_size, size_t reserved_size, 78 size_t static_size, size_t reserved_size,
79 pcpu_fc_alloc_fn_t alloc_fn, 79 pcpu_fc_alloc_fn_t alloc_fn,
80 pcpu_fc_free_fn_t free_fn, 80 pcpu_fc_free_fn_t free_fn,
diff --git a/mm/percpu.c b/mm/percpu.c
index cbddcbdab681..6feac7934904 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1497,15 +1497,15 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size,
1497} 1497}
1498 1498
1499/** 1499/**
1500 * pcpu_4k_first_chunk - map the first chunk using PAGE_SIZE pages 1500 * pcpu_page_first_chunk - map the first chunk using PAGE_SIZE pages
1501 * @static_size: the size of static percpu area in bytes 1501 * @static_size: the size of static percpu area in bytes
1502 * @reserved_size: the size of reserved percpu area in bytes 1502 * @reserved_size: the size of reserved percpu area in bytes
1503 * @alloc_fn: function to allocate percpu page, always called with PAGE_SIZE 1503 * @alloc_fn: function to allocate percpu page, always called with PAGE_SIZE
1504 * @free_fn: funtion to free percpu page, always called with PAGE_SIZE 1504 * @free_fn: funtion to free percpu page, always called with PAGE_SIZE
1505 * @populate_pte_fn: function to populate pte 1505 * @populate_pte_fn: function to populate pte
1506 * 1506 *
1507 * This is a helper to ease setting up embedded first percpu chunk and 1507 * This is a helper to ease setting up page-remapped first percpu
1508 * can be called where pcpu_setup_first_chunk() is expected. 1508 * chunk and can be called where pcpu_setup_first_chunk() is expected.
1509 * 1509 *
1510 * This is the basic allocator. Static percpu area is allocated 1510 * This is the basic allocator. Static percpu area is allocated
1511 * page-by-page into vmalloc area. 1511 * page-by-page into vmalloc area.
@@ -1514,12 +1514,13 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size,
1514 * The determined pcpu_unit_size which can be used to initialize 1514 * The determined pcpu_unit_size which can be used to initialize
1515 * percpu access on success, -errno on failure. 1515 * percpu access on success, -errno on failure.
1516 */ 1516 */
1517ssize_t __init pcpu_4k_first_chunk(size_t static_size, size_t reserved_size, 1517ssize_t __init pcpu_page_first_chunk(size_t static_size, size_t reserved_size,
1518 pcpu_fc_alloc_fn_t alloc_fn, 1518 pcpu_fc_alloc_fn_t alloc_fn,
1519 pcpu_fc_free_fn_t free_fn, 1519 pcpu_fc_free_fn_t free_fn,
1520 pcpu_fc_populate_pte_fn_t populate_pte_fn) 1520 pcpu_fc_populate_pte_fn_t populate_pte_fn)
1521{ 1521{
1522 static struct vm_struct vm; 1522 static struct vm_struct vm;
1523 char psize_str[16];
1523 int unit_pages; 1524 int unit_pages;
1524 size_t pages_size; 1525 size_t pages_size;
1525 struct page **pages; 1526 struct page **pages;
@@ -1527,6 +1528,8 @@ ssize_t __init pcpu_4k_first_chunk(size_t static_size, size_t reserved_size,
1527 int i, j; 1528 int i, j;
1528 ssize_t ret; 1529 ssize_t ret;
1529 1530
1531 snprintf(psize_str, sizeof(psize_str), "%luK", PAGE_SIZE >> 10);
1532
1530 unit_pages = PFN_UP(max_t(size_t, static_size + reserved_size, 1533 unit_pages = PFN_UP(max_t(size_t, static_size + reserved_size,
1531 PCPU_MIN_UNIT_SIZE)); 1534 PCPU_MIN_UNIT_SIZE));
1532 1535
@@ -1542,8 +1545,8 @@ ssize_t __init pcpu_4k_first_chunk(size_t static_size, size_t reserved_size,
1542 1545
1543 ptr = alloc_fn(cpu, PAGE_SIZE); 1546 ptr = alloc_fn(cpu, PAGE_SIZE);
1544 if (!ptr) { 1547 if (!ptr) {
1545 pr_warning("PERCPU: failed to allocate " 1548 pr_warning("PERCPU: failed to allocate %s page "
1546 "4k page for cpu%u\n", cpu); 1549 "for cpu%u\n", psize_str, cpu);
1547 goto enomem; 1550 goto enomem;
1548 } 1551 }
1549 pages[j++] = virt_to_page(ptr); 1552 pages[j++] = virt_to_page(ptr);
@@ -1580,8 +1583,8 @@ ssize_t __init pcpu_4k_first_chunk(size_t static_size, size_t reserved_size,
1580 } 1583 }
1581 1584
1582 /* we're ready, commit */ 1585 /* we're ready, commit */
1583 pr_info("PERCPU: %d 4k pages/cpu @%p s%zu r%zu\n", 1586 pr_info("PERCPU: %d %s pages/cpu @%p s%zu r%zu\n",
1584 unit_pages, vm.addr, static_size, reserved_size); 1587 unit_pages, psize_str, vm.addr, static_size, reserved_size);
1585 1588
1586 ret = pcpu_setup_first_chunk(static_size, reserved_size, -1, 1589 ret = pcpu_setup_first_chunk(static_size, reserved_size, -1,
1587 unit_pages << PAGE_SHIFT, vm.addr, NULL); 1590 unit_pages << PAGE_SHIFT, vm.addr, NULL);