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>
This commit is contained in:
parent
004018e2c0
commit
00ae4064b1
4 changed files with 28 additions and 24 deletions
|
@ -1920,7 +1920,7 @@ and is between 256 and 4096 characters. It is defined in the file
|
||||||
See arch/parisc/kernel/pdc_chassis.c
|
See arch/parisc/kernel/pdc_chassis.c
|
||||||
|
|
||||||
percpu_alloc= [X86] Select which percpu first chunk allocator to use.
|
percpu_alloc= [X86] Select which percpu first chunk allocator to use.
|
||||||
Allowed values are one of "lpage", "embed" and "4k".
|
Allowed values are one of "lpage", "embed" and "page".
|
||||||
See comments in arch/x86/kernel/setup_percpu.c for
|
See comments in arch/x86/kernel/setup_percpu.c for
|
||||||
details on each allocator. This parameter is primarily
|
details on each allocator. This parameter is primarily
|
||||||
for debugging and performance comparison.
|
for debugging and performance comparison.
|
||||||
|
|
|
@ -249,21 +249,22 @@ static ssize_t __init setup_pcpu_embed(size_t static_size, bool chosen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4k allocator
|
* Page allocator
|
||||||
*
|
*
|
||||||
* Boring fallback 4k allocator. This allocator puts more pressure on
|
* Boring fallback 4k page allocator. This allocator puts more
|
||||||
* PTE TLBs but other than that behaves nicely on both UMA and NUMA.
|
* pressure on PTE TLBs but other than that behaves nicely on both UMA
|
||||||
|
* and NUMA.
|
||||||
*/
|
*/
|
||||||
static void __init pcpu4k_populate_pte(unsigned long addr)
|
static void __init pcpup_populate_pte(unsigned long addr)
|
||||||
{
|
{
|
||||||
populate_extra_pte(addr);
|
populate_extra_pte(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t __init setup_pcpu_4k(size_t static_size)
|
static ssize_t __init setup_pcpu_page(size_t static_size)
|
||||||
{
|
{
|
||||||
return pcpu_4k_first_chunk(static_size, PERCPU_FIRST_CHUNK_RESERVE,
|
return pcpu_page_first_chunk(static_size, PERCPU_FIRST_CHUNK_RESERVE,
|
||||||
pcpu_fc_alloc, pcpu_fc_free,
|
pcpu_fc_alloc, pcpu_fc_free,
|
||||||
pcpu4k_populate_pte);
|
pcpup_populate_pte);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for explicit first chunk allocator selection */
|
/* for explicit first chunk allocator selection */
|
||||||
|
@ -307,7 +308,7 @@ void __init setup_per_cpu_areas(void)
|
||||||
*/
|
*/
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
if (strlen(pcpu_chosen_alloc)) {
|
if (strlen(pcpu_chosen_alloc)) {
|
||||||
if (strcmp(pcpu_chosen_alloc, "4k")) {
|
if (strcmp(pcpu_chosen_alloc, "page")) {
|
||||||
if (!strcmp(pcpu_chosen_alloc, "lpage"))
|
if (!strcmp(pcpu_chosen_alloc, "lpage"))
|
||||||
ret = setup_pcpu_lpage(static_size, true);
|
ret = setup_pcpu_lpage(static_size, true);
|
||||||
else if (!strcmp(pcpu_chosen_alloc, "embed"))
|
else if (!strcmp(pcpu_chosen_alloc, "embed"))
|
||||||
|
@ -317,7 +318,7 @@ void __init setup_per_cpu_areas(void)
|
||||||
"specified\n", pcpu_chosen_alloc);
|
"specified\n", pcpu_chosen_alloc);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
pr_warning("PERCPU: %s allocator failed (%zd), "
|
pr_warning("PERCPU: %s allocator failed (%zd), "
|
||||||
"falling back to 4k\n",
|
"falling back to page size\n",
|
||||||
pcpu_chosen_alloc, ret);
|
pcpu_chosen_alloc, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -326,7 +327,7 @@ void __init setup_per_cpu_areas(void)
|
||||||
ret = setup_pcpu_embed(static_size, false);
|
ret = setup_pcpu_embed(static_size, false);
|
||||||
}
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
ret = setup_pcpu_4k(static_size);
|
ret = setup_pcpu_page(static_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
panic("cannot allocate static percpu area (%zu bytes, err=%zd)",
|
panic("cannot allocate static percpu area (%zu bytes, err=%zd)",
|
||||||
static_size, ret);
|
static_size, ret);
|
||||||
|
|
|
@ -74,7 +74,7 @@ extern ssize_t __init pcpu_embed_first_chunk(
|
||||||
size_t static_size, size_t reserved_size,
|
size_t static_size, size_t reserved_size,
|
||||||
ssize_t dyn_size);
|
ssize_t dyn_size);
|
||||||
|
|
||||||
extern ssize_t __init pcpu_4k_first_chunk(
|
extern ssize_t __init pcpu_page_first_chunk(
|
||||||
size_t static_size, size_t reserved_size,
|
size_t static_size, size_t reserved_size,
|
||||||
pcpu_fc_alloc_fn_t alloc_fn,
|
pcpu_fc_alloc_fn_t alloc_fn,
|
||||||
pcpu_fc_free_fn_t free_fn,
|
pcpu_fc_free_fn_t free_fn,
|
||||||
|
|
25
mm/percpu.c
25
mm/percpu.c
|
@ -1497,15 +1497,15 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pcpu_4k_first_chunk - map the first chunk using PAGE_SIZE pages
|
* pcpu_page_first_chunk - map the first chunk using PAGE_SIZE pages
|
||||||
* @static_size: the size of static percpu area in bytes
|
* @static_size: the size of static percpu area in bytes
|
||||||
* @reserved_size: the size of reserved percpu area in bytes
|
* @reserved_size: the size of reserved percpu area in bytes
|
||||||
* @alloc_fn: function to allocate percpu page, always called with PAGE_SIZE
|
* @alloc_fn: function to allocate percpu page, always called with PAGE_SIZE
|
||||||
* @free_fn: funtion to free percpu page, always called with PAGE_SIZE
|
* @free_fn: funtion to free percpu page, always called with PAGE_SIZE
|
||||||
* @populate_pte_fn: function to populate pte
|
* @populate_pte_fn: function to populate pte
|
||||||
*
|
*
|
||||||
* This is a helper to ease setting up embedded first percpu chunk and
|
* This is a helper to ease setting up page-remapped first percpu
|
||||||
* can be called where pcpu_setup_first_chunk() is expected.
|
* chunk and can be called where pcpu_setup_first_chunk() is expected.
|
||||||
*
|
*
|
||||||
* This is the basic allocator. Static percpu area is allocated
|
* This is the basic allocator. Static percpu area is allocated
|
||||||
* page-by-page into vmalloc area.
|
* 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,
|
||||||
* The determined pcpu_unit_size which can be used to initialize
|
* The determined pcpu_unit_size which can be used to initialize
|
||||||
* percpu access on success, -errno on failure.
|
* percpu access on success, -errno on failure.
|
||||||
*/
|
*/
|
||||||
ssize_t __init pcpu_4k_first_chunk(size_t static_size, size_t reserved_size,
|
ssize_t __init pcpu_page_first_chunk(size_t static_size, size_t reserved_size,
|
||||||
pcpu_fc_alloc_fn_t alloc_fn,
|
pcpu_fc_alloc_fn_t alloc_fn,
|
||||||
pcpu_fc_free_fn_t free_fn,
|
pcpu_fc_free_fn_t free_fn,
|
||||||
pcpu_fc_populate_pte_fn_t populate_pte_fn)
|
pcpu_fc_populate_pte_fn_t populate_pte_fn)
|
||||||
{
|
{
|
||||||
static struct vm_struct vm;
|
static struct vm_struct vm;
|
||||||
|
char psize_str[16];
|
||||||
int unit_pages;
|
int unit_pages;
|
||||||
size_t pages_size;
|
size_t pages_size;
|
||||||
struct page **pages;
|
struct page **pages;
|
||||||
|
@ -1527,6 +1528,8 @@ ssize_t __init pcpu_4k_first_chunk(size_t static_size, size_t reserved_size,
|
||||||
int i, j;
|
int i, j;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
|
snprintf(psize_str, sizeof(psize_str), "%luK", PAGE_SIZE >> 10);
|
||||||
|
|
||||||
unit_pages = PFN_UP(max_t(size_t, static_size + reserved_size,
|
unit_pages = PFN_UP(max_t(size_t, static_size + reserved_size,
|
||||||
PCPU_MIN_UNIT_SIZE));
|
PCPU_MIN_UNIT_SIZE));
|
||||||
|
|
||||||
|
@ -1542,8 +1545,8 @@ ssize_t __init pcpu_4k_first_chunk(size_t static_size, size_t reserved_size,
|
||||||
|
|
||||||
ptr = alloc_fn(cpu, PAGE_SIZE);
|
ptr = alloc_fn(cpu, PAGE_SIZE);
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
pr_warning("PERCPU: failed to allocate "
|
pr_warning("PERCPU: failed to allocate %s page "
|
||||||
"4k page for cpu%u\n", cpu);
|
"for cpu%u\n", psize_str, cpu);
|
||||||
goto enomem;
|
goto enomem;
|
||||||
}
|
}
|
||||||
pages[j++] = virt_to_page(ptr);
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we're ready, commit */
|
/* we're ready, commit */
|
||||||
pr_info("PERCPU: %d 4k pages/cpu @%p s%zu r%zu\n",
|
pr_info("PERCPU: %d %s pages/cpu @%p s%zu r%zu\n",
|
||||||
unit_pages, vm.addr, static_size, reserved_size);
|
unit_pages, psize_str, vm.addr, static_size, reserved_size);
|
||||||
|
|
||||||
ret = pcpu_setup_first_chunk(static_size, reserved_size, -1,
|
ret = pcpu_setup_first_chunk(static_size, reserved_size, -1,
|
||||||
unit_pages << PAGE_SHIFT, vm.addr, NULL);
|
unit_pages << PAGE_SHIFT, vm.addr, NULL);
|
||||||
|
|
Loading…
Reference in a new issue