2005-09-17 10:27:51 +08:00
|
|
|
/*
|
2008-02-05 14:30:53 +08:00
|
|
|
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2008-02-05 14:30:53 +08:00
|
|
|
#include <linux/stddef.h>
|
2011-08-19 03:14:10 +08:00
|
|
|
#include <linux/module.h>
|
2018-10-31 06:09:21 +08:00
|
|
|
#include <linux/memblock.h>
|
2008-02-05 14:30:53 +08:00
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/swap.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-02-05 14:30:53 +08:00
|
|
|
#include <asm/fixmap.h>
|
|
|
|
#include <asm/page.h>
|
2012-10-08 10:27:32 +08:00
|
|
|
#include <as-layout.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <kern.h>
|
|
|
|
#include <kern_util.h>
|
|
|
|
#include <mem_user.h>
|
|
|
|
#include <os.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-10 17:44:18 +08:00
|
|
|
/* allocated in paging_init, zeroed in mem_init, and unchanged thereafter */
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long *empty_zero_page = NULL;
|
2011-08-19 03:14:10 +08:00
|
|
|
EXPORT_SYMBOL(empty_zero_page);
|
2008-02-05 14:31:17 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialized during boot, and readonly for initializing page tables
|
|
|
|
* afterwards
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
pgd_t swapper_pg_dir[PTRS_PER_PGD];
|
2008-02-05 14:31:17 +08:00
|
|
|
|
|
|
|
/* Initialized at boot time, and readonly after that */
|
2006-03-31 18:30:09 +08:00
|
|
|
unsigned long long highmem;
|
2005-04-17 06:20:36 +08:00
|
|
|
int kmalloc_ok = 0;
|
|
|
|
|
2008-02-05 14:31:17 +08:00
|
|
|
/* Used during early boot */
|
2005-04-17 06:20:36 +08:00
|
|
|
static unsigned long brk_end;
|
|
|
|
|
2007-07-24 09:43:48 +08:00
|
|
|
void __init mem_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-10 17:44:10 +08:00
|
|
|
/* clear the zero-page */
|
2008-02-05 14:30:41 +08:00
|
|
|
memset(empty_zero_page, 0, PAGE_SIZE);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Map in the area just after the brk now that kmalloc is about
|
|
|
|
* to be turned on.
|
|
|
|
*/
|
|
|
|
brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
|
2008-02-05 14:31:24 +08:00
|
|
|
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
|
2018-10-31 06:09:21 +08:00
|
|
|
memblock_free(__pa(brk_end), uml_reserved - brk_end);
|
2005-04-17 06:20:36 +08:00
|
|
|
uml_reserved = brk_end;
|
|
|
|
|
|
|
|
/* this will put all low memory onto the freelists */
|
2018-10-31 06:09:30 +08:00
|
|
|
memblock_free_all();
|
2018-12-28 16:34:29 +08:00
|
|
|
max_low_pfn = totalram_pages();
|
2018-12-28 16:34:20 +08:00
|
|
|
max_pfn = max_low_pfn;
|
2013-07-04 06:04:16 +08:00
|
|
|
mem_init_print_info(NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
kmalloc_ok = 1;
|
|
|
|
}
|
|
|
|
|
2005-05-21 04:59:12 +08:00
|
|
|
/*
|
|
|
|
* Create a page table and place a pointer to it in a middle page
|
|
|
|
* directory entry.
|
|
|
|
*/
|
|
|
|
static void __init one_page_table_init(pmd_t *pmd)
|
|
|
|
{
|
|
|
|
if (pmd_none(*pmd)) {
|
2018-10-31 06:08:54 +08:00
|
|
|
pte_t *pte = (pte_t *) memblock_alloc_low(PAGE_SIZE,
|
|
|
|
PAGE_SIZE);
|
2019-03-12 14:30:31 +08:00
|
|
|
if (!pte)
|
|
|
|
panic("%s: Failed to allocate %lu bytes align=%lx\n",
|
|
|
|
__func__, PAGE_SIZE, PAGE_SIZE);
|
|
|
|
|
2005-05-21 04:59:12 +08:00
|
|
|
set_pmd(pmd, __pmd(_KERNPG_TABLE +
|
|
|
|
(unsigned long) __pa(pte)));
|
|
|
|
if (pte != pte_offset_kernel(pmd, 0))
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init one_md_table_init(pud_t *pud)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_3_LEVEL_PGTABLES
|
2018-10-31 06:08:54 +08:00
|
|
|
pmd_t *pmd_table = (pmd_t *) memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
|
2019-03-12 14:30:31 +08:00
|
|
|
if (!pmd_table)
|
|
|
|
panic("%s: Failed to allocate %lu bytes align=%lx\n",
|
|
|
|
__func__, PAGE_SIZE, PAGE_SIZE);
|
|
|
|
|
2005-05-21 04:59:12 +08:00
|
|
|
set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table)));
|
|
|
|
if (pmd_table != pmd_offset(pud, 0))
|
|
|
|
BUG();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-02-05 14:30:53 +08:00
|
|
|
static void __init fixrange_init(unsigned long start, unsigned long end,
|
2005-04-17 06:20:36 +08:00
|
|
|
pgd_t *pgd_base)
|
|
|
|
{
|
|
|
|
pgd_t *pgd;
|
2005-05-21 04:59:12 +08:00
|
|
|
pud_t *pud;
|
2005-04-17 06:20:36 +08:00
|
|
|
pmd_t *pmd;
|
|
|
|
int i, j;
|
|
|
|
unsigned long vaddr;
|
|
|
|
|
|
|
|
vaddr = start;
|
|
|
|
i = pgd_index(vaddr);
|
|
|
|
j = pmd_index(vaddr);
|
|
|
|
pgd = pgd_base + i;
|
|
|
|
|
|
|
|
for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) {
|
2005-05-21 04:59:12 +08:00
|
|
|
pud = pud_offset(pgd, vaddr);
|
|
|
|
if (pud_none(*pud))
|
|
|
|
one_md_table_init(pud);
|
|
|
|
pmd = pmd_offset(pud, vaddr);
|
2008-02-05 14:30:55 +08:00
|
|
|
for (; (j < PTRS_PER_PMD) && (vaddr < end); pmd++, j++) {
|
2005-05-21 04:59:12 +08:00
|
|
|
one_page_table_init(pmd);
|
2005-04-17 06:20:36 +08:00
|
|
|
vaddr += PMD_SIZE;
|
|
|
|
}
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init fixaddr_user_init( void)
|
|
|
|
{
|
2005-09-08 06:21:11 +08:00
|
|
|
#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
|
2005-04-17 06:20:36 +08:00
|
|
|
long size = FIXADDR_USER_END - FIXADDR_USER_START;
|
|
|
|
pgd_t *pgd;
|
|
|
|
pud_t *pud;
|
|
|
|
pmd_t *pmd;
|
|
|
|
pte_t *pte;
|
2008-02-05 14:30:55 +08:00
|
|
|
phys_t p;
|
|
|
|
unsigned long v, vaddr = FIXADDR_USER_START;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-05 14:30:55 +08:00
|
|
|
if (!size)
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir);
|
2018-10-31 06:08:54 +08:00
|
|
|
v = (unsigned long) memblock_alloc_low(size, PAGE_SIZE);
|
2019-03-12 14:30:31 +08:00
|
|
|
if (!v)
|
|
|
|
panic("%s: Failed to allocate %lu bytes align=%lx\n",
|
|
|
|
__func__, size, PAGE_SIZE);
|
|
|
|
|
2008-02-05 14:30:55 +08:00
|
|
|
memcpy((void *) v , (void *) FIXADDR_USER_START, size);
|
|
|
|
p = __pa(v);
|
2008-02-05 14:30:53 +08:00
|
|
|
for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
|
2008-02-05 14:30:55 +08:00
|
|
|
p += PAGE_SIZE) {
|
2005-04-17 06:20:36 +08:00
|
|
|
pgd = swapper_pg_dir + pgd_index(vaddr);
|
|
|
|
pud = pud_offset(pgd, vaddr);
|
|
|
|
pmd = pmd_offset(pud, vaddr);
|
|
|
|
pte = pte_offset_kernel(pmd, vaddr);
|
2008-02-05 14:30:55 +08:00
|
|
|
pte_set_val(*pte, p, PAGE_READONLY);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-05-07 05:51:11 +08:00
|
|
|
void __init paging_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned long zones_size[MAX_NR_ZONES], vaddr;
|
|
|
|
int i;
|
|
|
|
|
2018-10-31 06:08:54 +08:00
|
|
|
empty_zero_page = (unsigned long *) memblock_alloc_low(PAGE_SIZE,
|
|
|
|
PAGE_SIZE);
|
2019-03-12 14:30:31 +08:00
|
|
|
if (!empty_zero_page)
|
|
|
|
panic("%s: Failed to allocate %lu bytes align=%lx\n",
|
|
|
|
__func__, PAGE_SIZE, PAGE_SIZE);
|
|
|
|
|
2008-02-05 14:30:53 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(zones_size); i++)
|
2005-04-17 06:20:36 +08:00
|
|
|
zones_size[i] = 0;
|
2006-09-26 14:33:00 +08:00
|
|
|
|
2006-09-27 16:50:34 +08:00
|
|
|
zones_size[ZONE_NORMAL] = (end_iomem >> PAGE_SHIFT) -
|
|
|
|
(uml_physmem >> PAGE_SHIFT);
|
2005-04-17 06:20:36 +08:00
|
|
|
free_area_init(zones_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fixed mappings, only the page table structure has to be
|
|
|
|
* created - mappings will be set by set_fixmap():
|
|
|
|
*/
|
|
|
|
vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
|
|
|
|
fixrange_init(vaddr, FIXADDR_TOP, swapper_pg_dir);
|
|
|
|
|
|
|
|
fixaddr_user_init();
|
|
|
|
}
|
|
|
|
|
uml: header untangling
Untangle UML headers somewhat and add some includes where they were
needed explicitly, but gotten accidentally via some other header.
arch/um/include/um_uaccess.h loses asm/fixmap.h because it uses no
fixmap stuff and gains elf.h, because it needs FIXADDR_USER_*, and
archsetjmp.h, because it needs jmp_buf.
pmd_alloc_one is uninlined because it needs mm_struct, and that's
inconvenient to provide in asm-um/pgtable-3level.h.
elf_core_copy_fpregs is also uninlined from elf-i386.h and
elf-x86_64.h, which duplicated the code anyway, to
arch/um/kernel/process.c, so that the reference to current_thread
doesn't pull sched.h or anything related into asm/elf.h.
arch/um/sys-i386/ldt.c, arch/um/kernel/tlb.c and
arch/um/kernel/skas/uaccess.c got sched.h because they dereference
task_structs. Its includes of linux and asm headers got turned from
"" to <>.
arch/um/sys-i386/bug.c gets asm/errno.h because it needs errno
constants.
asm/elf-i386 gets asm/user.h because it needs user_regs_struct.
asm/fixmap.h gets page.h because it needs PAGE_SIZE and PAGE_MASK and
system.h for BUG_ON.
asm/pgtable doesn't need sched.h.
asm/processor-generic.h defined mm_segment_t, but didn't use it. So,
that definition is moved to uaccess.h, which defines a bunch of
mm_segment_t-related stuff. thread_info.h uses mm_segment_t, and
includes uaccess.h, which causes a recursion. So, the definition is
placed above the include of thread_info. in uaccess.h. thread_info.h
also gets page.h because it needs PAGE_SIZE.
ObCheckpatchViolationJustification - I'm not adding a typedef; I'm
moving mm_segment_t from one place to another.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 14:30:53 +08:00
|
|
|
/*
|
|
|
|
* This can't do anything because nothing in the kernel image can be freed
|
2005-04-17 06:20:36 +08:00
|
|
|
* since it's not in kernel physical memory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void free_initmem(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_BLK_DEV_INITRD
|
|
|
|
void free_initrd_mem(unsigned long start, unsigned long end)
|
|
|
|
{
|
2013-07-04 06:02:51 +08:00
|
|
|
free_reserved_area((void *)start, (void *)end, -1, "initrd");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
uml: header untangling
Untangle UML headers somewhat and add some includes where they were
needed explicitly, but gotten accidentally via some other header.
arch/um/include/um_uaccess.h loses asm/fixmap.h because it uses no
fixmap stuff and gains elf.h, because it needs FIXADDR_USER_*, and
archsetjmp.h, because it needs jmp_buf.
pmd_alloc_one is uninlined because it needs mm_struct, and that's
inconvenient to provide in asm-um/pgtable-3level.h.
elf_core_copy_fpregs is also uninlined from elf-i386.h and
elf-x86_64.h, which duplicated the code anyway, to
arch/um/kernel/process.c, so that the reference to current_thread
doesn't pull sched.h or anything related into asm/elf.h.
arch/um/sys-i386/ldt.c, arch/um/kernel/tlb.c and
arch/um/kernel/skas/uaccess.c got sched.h because they dereference
task_structs. Its includes of linux and asm headers got turned from
"" to <>.
arch/um/sys-i386/bug.c gets asm/errno.h because it needs errno
constants.
asm/elf-i386 gets asm/user.h because it needs user_regs_struct.
asm/fixmap.h gets page.h because it needs PAGE_SIZE and PAGE_MASK and
system.h for BUG_ON.
asm/pgtable doesn't need sched.h.
asm/processor-generic.h defined mm_segment_t, but didn't use it. So,
that definition is moved to uaccess.h, which defines a bunch of
mm_segment_t-related stuff. thread_info.h uses mm_segment_t, and
includes uaccess.h, which causes a recursion. So, the definition is
placed above the include of thread_info. in uaccess.h. thread_info.h
also gets page.h because it needs PAGE_SIZE.
ObCheckpatchViolationJustification - I'm not adding a typedef; I'm
moving mm_segment_t from one place to another.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 14:30:53 +08:00
|
|
|
/* Allocate and free page tables. */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
pgd_t *pgd_alloc(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
|
|
|
|
|
|
|
|
if (pgd) {
|
|
|
|
memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
|
2008-02-05 14:30:53 +08:00
|
|
|
memcpy(pgd + USER_PTRS_PER_PGD,
|
|
|
|
swapper_pg_dir + USER_PTRS_PER_PGD,
|
2005-04-17 06:20:36 +08:00
|
|
|
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
|
|
|
}
|
|
|
|
return pgd;
|
|
|
|
}
|
|
|
|
|
2008-02-05 14:29:14 +08:00
|
|
|
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
free_page((unsigned long) pgd);
|
|
|
|
}
|
|
|
|
|
mm: treewide: remove unused address argument from pte_alloc functions
Patch series "Add support for fast mremap".
This series speeds up the mremap(2) syscall by copying page tables at
the PMD level even for non-THP systems. There is concern that the extra
'address' argument that mremap passes to pte_alloc may do something
subtle architecture related in the future that may make the scheme not
work. Also we find that there is no point in passing the 'address' to
pte_alloc since its unused. This patch therefore removes this argument
tree-wide resulting in a nice negative diff as well. Also ensuring
along the way that the enabled architectures do not do anything funky
with the 'address' argument that goes unnoticed by the optimization.
Build and boot tested on x86-64. Build tested on arm64. The config
enablement patch for arm64 will be posted in the future after more
testing.
The changes were obtained by applying the following Coccinelle script.
(thanks Julia for answering all Coccinelle questions!).
Following fix ups were done manually:
* Removal of address argument from pte_fragment_alloc
* Removal of pte_alloc_one_fast definitions from m68k and microblaze.
// Options: --include-headers --no-includes
// Note: I split the 'identifier fn' line, so if you are manually
// running it, please unsplit it so it runs for you.
virtual patch
@pte_alloc_func_def depends on patch exists@
identifier E2;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
type T2;
@@
fn(...
- , T2 E2
)
{ ... }
@pte_alloc_func_proto_noarg depends on patch exists@
type T1, T2, T3, T4;
identifier fn =~ "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
(
- T3 fn(T1, T2);
+ T3 fn(T1);
|
- T3 fn(T1, T2, T4);
+ T3 fn(T1, T2);
)
@pte_alloc_func_proto depends on patch exists@
identifier E1, E2, E4;
type T1, T2, T3, T4;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
(
- T3 fn(T1 E1, T2 E2);
+ T3 fn(T1 E1);
|
- T3 fn(T1 E1, T2 E2, T4 E4);
+ T3 fn(T1 E1, T2 E2);
)
@pte_alloc_func_call depends on patch exists@
expression E2;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
fn(...
-, E2
)
@pte_alloc_macro depends on patch exists@
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
identifier a, b, c;
expression e;
position p;
@@
(
- #define fn(a, b, c) e
+ #define fn(a, b) e
|
- #define fn(a, b) e
+ #define fn(a) e
)
Link: http://lkml.kernel.org/r/20181108181201.88826-2-joelaf@google.com
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Suggested-by: Kirill A. Shutemov <kirill@shutemov.name>
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 07:28:34 +08:00
|
|
|
pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
pte_t *pte;
|
|
|
|
|
2016-06-25 05:48:47 +08:00
|
|
|
pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
|
2005-04-17 06:20:36 +08:00
|
|
|
return pte;
|
|
|
|
}
|
|
|
|
|
mm: treewide: remove unused address argument from pte_alloc functions
Patch series "Add support for fast mremap".
This series speeds up the mremap(2) syscall by copying page tables at
the PMD level even for non-THP systems. There is concern that the extra
'address' argument that mremap passes to pte_alloc may do something
subtle architecture related in the future that may make the scheme not
work. Also we find that there is no point in passing the 'address' to
pte_alloc since its unused. This patch therefore removes this argument
tree-wide resulting in a nice negative diff as well. Also ensuring
along the way that the enabled architectures do not do anything funky
with the 'address' argument that goes unnoticed by the optimization.
Build and boot tested on x86-64. Build tested on arm64. The config
enablement patch for arm64 will be posted in the future after more
testing.
The changes were obtained by applying the following Coccinelle script.
(thanks Julia for answering all Coccinelle questions!).
Following fix ups were done manually:
* Removal of address argument from pte_fragment_alloc
* Removal of pte_alloc_one_fast definitions from m68k and microblaze.
// Options: --include-headers --no-includes
// Note: I split the 'identifier fn' line, so if you are manually
// running it, please unsplit it so it runs for you.
virtual patch
@pte_alloc_func_def depends on patch exists@
identifier E2;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
type T2;
@@
fn(...
- , T2 E2
)
{ ... }
@pte_alloc_func_proto_noarg depends on patch exists@
type T1, T2, T3, T4;
identifier fn =~ "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
(
- T3 fn(T1, T2);
+ T3 fn(T1);
|
- T3 fn(T1, T2, T4);
+ T3 fn(T1, T2);
)
@pte_alloc_func_proto depends on patch exists@
identifier E1, E2, E4;
type T1, T2, T3, T4;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
(
- T3 fn(T1 E1, T2 E2);
+ T3 fn(T1 E1);
|
- T3 fn(T1 E1, T2 E2, T4 E4);
+ T3 fn(T1 E1, T2 E2);
)
@pte_alloc_func_call depends on patch exists@
expression E2;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
fn(...
-, E2
)
@pte_alloc_macro depends on patch exists@
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
identifier a, b, c;
expression e;
position p;
@@
(
- #define fn(a, b, c) e
+ #define fn(a, b) e
|
- #define fn(a, b) e
+ #define fn(a) e
)
Link: http://lkml.kernel.org/r/20181108181201.88826-2-joelaf@google.com
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Suggested-by: Kirill A. Shutemov <kirill@shutemov.name>
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 07:28:34 +08:00
|
|
|
pgtable_t pte_alloc_one(struct mm_struct *mm)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct page *pte;
|
2007-02-10 17:44:10 +08:00
|
|
|
|
2016-06-25 05:48:47 +08:00
|
|
|
pte = alloc_page(GFP_KERNEL|__GFP_ZERO);
|
2013-11-15 06:31:44 +08:00
|
|
|
if (!pte)
|
|
|
|
return NULL;
|
|
|
|
if (!pgtable_page_ctor(pte)) {
|
|
|
|
__free_page(pte);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
return pte;
|
|
|
|
}
|
uml: header untangling
Untangle UML headers somewhat and add some includes where they were
needed explicitly, but gotten accidentally via some other header.
arch/um/include/um_uaccess.h loses asm/fixmap.h because it uses no
fixmap stuff and gains elf.h, because it needs FIXADDR_USER_*, and
archsetjmp.h, because it needs jmp_buf.
pmd_alloc_one is uninlined because it needs mm_struct, and that's
inconvenient to provide in asm-um/pgtable-3level.h.
elf_core_copy_fpregs is also uninlined from elf-i386.h and
elf-x86_64.h, which duplicated the code anyway, to
arch/um/kernel/process.c, so that the reference to current_thread
doesn't pull sched.h or anything related into asm/elf.h.
arch/um/sys-i386/ldt.c, arch/um/kernel/tlb.c and
arch/um/kernel/skas/uaccess.c got sched.h because they dereference
task_structs. Its includes of linux and asm headers got turned from
"" to <>.
arch/um/sys-i386/bug.c gets asm/errno.h because it needs errno
constants.
asm/elf-i386 gets asm/user.h because it needs user_regs_struct.
asm/fixmap.h gets page.h because it needs PAGE_SIZE and PAGE_MASK and
system.h for BUG_ON.
asm/pgtable doesn't need sched.h.
asm/processor-generic.h defined mm_segment_t, but didn't use it. So,
that definition is moved to uaccess.h, which defines a bunch of
mm_segment_t-related stuff. thread_info.h uses mm_segment_t, and
includes uaccess.h, which causes a recursion. So, the definition is
placed above the include of thread_info. in uaccess.h. thread_info.h
also gets page.h because it needs PAGE_SIZE.
ObCheckpatchViolationJustification - I'm not adding a typedef; I'm
moving mm_segment_t from one place to another.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 14:30:53 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_3_LEVEL_PGTABLES
|
|
|
|
pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
|
|
|
|
{
|
|
|
|
pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
|
|
|
|
|
|
|
|
if (pmd)
|
|
|
|
memset(pmd, 0, PAGE_SIZE);
|
|
|
|
|
|
|
|
return pmd;
|
|
|
|
}
|
|
|
|
#endif
|
2008-05-13 05:01:52 +08:00
|
|
|
|
|
|
|
void *uml_kmalloc(int size, int flags)
|
|
|
|
{
|
|
|
|
return kmalloc(size, flags);
|
|
|
|
}
|