From: Hugh Dickins anon_vma will need to pass vma to put_dirty_page, so change it and its various callers (setup_arg_pages and its 32-on-64-bit arch variants); and please, let's rename it to install_arg_page. Earlier attempt to do this (rmap 26 __setup_arg_pages) tried to clean up those callers instead, but failed to boot: so now apply rmap 27's memset initialization of vmas to these callers too; which relieves them from needing the recently included linux/mempolicy.h. While there, moved install_arg_page's flush_dcache_page up before page_table_lock - doesn't in fact matter at all, just saves one worry when researching flush_dcache_page locking constraints. --- 25-akpm/arch/ia64/ia32/binfmt_elf32.c | 10 +++------- 25-akpm/arch/ia64/kernel/perfmon.c | 1 - 25-akpm/arch/ia64/mm/init.c | 3 +-- 25-akpm/arch/s390/kernel/compat_exec.c | 9 +++------ 25-akpm/arch/x86_64/ia32/ia32_binfmt.c | 10 +++------- 25-akpm/fs/exec.c | 20 ++++++++++---------- 25-akpm/include/linux/mm.h | 3 +-- 7 files changed, 21 insertions(+), 35 deletions(-) diff -puN arch/ia64/ia32/binfmt_elf32.c~rmap-33-install_arg_page-vma arch/ia64/ia32/binfmt_elf32.c --- 25/arch/ia64/ia32/binfmt_elf32.c~rmap-33-install_arg_page-vma 2004-05-15 21:58:17.976880488 -0700 +++ 25-akpm/arch/ia64/ia32/binfmt_elf32.c 2004-05-15 21:58:17.987878816 -0700 @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -169,6 +168,8 @@ ia32_setup_arg_pages (struct linux_binpr return -ENOMEM; } + memset(mpnt, 0, sizeof(*mpnt)); + down_write(¤t->mm->mmap_sem); { mpnt->vm_mm = current->mm; @@ -182,11 +183,6 @@ ia32_setup_arg_pages (struct linux_binpr mpnt->vm_flags = VM_STACK_FLAGS; mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC)? PAGE_COPY_EXEC: PAGE_COPY; - mpnt->vm_ops = NULL; - mpnt->vm_pgoff = 0; - mpnt->vm_file = NULL; - mpnt->vm_private_data = 0; - mpol_set_vma_default(mpnt); insert_vm_struct(current->mm, mpnt); current->mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; } @@ -195,7 +191,7 @@ ia32_setup_arg_pages (struct linux_binpr struct page *page = bprm->page[i]; if (page) { bprm->page[i] = NULL; - put_dirty_page(current, page, stack_base, mpnt->vm_page_prot); + install_arg_page(mpnt, page, stack_base); } stack_base += PAGE_SIZE; } diff -puN arch/ia64/kernel/perfmon.c~rmap-33-install_arg_page-vma arch/ia64/kernel/perfmon.c --- 25/arch/ia64/kernel/perfmon.c~rmap-33-install_arg_page-vma 2004-05-15 21:58:17.978880184 -0700 +++ 25-akpm/arch/ia64/kernel/perfmon.c 2004-05-15 21:58:17.991878208 -0700 @@ -37,7 +37,6 @@ #include #include #include -#include #include #include diff -puN arch/ia64/mm/init.c~rmap-33-install_arg_page-vma arch/ia64/mm/init.c --- 25/arch/ia64/mm/init.c~rmap-33-install_arg_page-vma 2004-05-15 21:58:17.979880032 -0700 +++ 25-akpm/arch/ia64/mm/init.c 2004-05-15 21:58:17.992878056 -0700 @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -218,7 +217,7 @@ free_initrd_mem (unsigned long start, un } /* - * This is like put_dirty_page() but installs a clean page in the kernel's page table. + * This installs a clean page in the kernel's page table. */ struct page * put_kernel_page (struct page *page, unsigned long address, pgprot_t pgprot) diff -puN arch/s390/kernel/compat_exec.c~rmap-33-install_arg_page-vma arch/s390/kernel/compat_exec.c --- 25/arch/s390/kernel/compat_exec.c~rmap-33-install_arg_page-vma 2004-05-15 21:58:17.980879880 -0700 +++ 25-akpm/arch/s390/kernel/compat_exec.c 2004-05-15 21:58:17.993877904 -0700 @@ -58,6 +58,8 @@ int setup_arg_pages32(struct linux_binpr return -ENOMEM; } + memset(mpnt, 0, sizeof(*mpnt)); + down_write(&mm->mmap_sem); { mpnt->vm_mm = mm; @@ -66,11 +68,6 @@ int setup_arg_pages32(struct linux_binpr /* executable stack setting would be applied here */ mpnt->vm_page_prot = PAGE_COPY; mpnt->vm_flags = VM_STACK_FLAGS; - mpnt->vm_ops = NULL; - mpnt->vm_pgoff = 0; - mpnt->vm_file = NULL; - mpol_set_vma_default(mpnt); - mpnt->vm_private_data = (void *) 0; insert_vm_struct(mm, mpnt); mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; } @@ -79,7 +76,7 @@ int setup_arg_pages32(struct linux_binpr struct page *page = bprm->page[i]; if (page) { bprm->page[i] = NULL; - put_dirty_page(current,page,stack_base,PAGE_COPY); + install_arg_page(mpnt, page, stack_base); } stack_base += PAGE_SIZE; } diff -puN arch/x86_64/ia32/ia32_binfmt.c~rmap-33-install_arg_page-vma arch/x86_64/ia32/ia32_binfmt.c --- 25/arch/x86_64/ia32/ia32_binfmt.c~rmap-33-install_arg_page-vma 2004-05-15 21:58:17.981879728 -0700 +++ 25-akpm/arch/x86_64/ia32/ia32_binfmt.c 2004-05-15 21:58:17.993877904 -0700 @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -350,6 +349,8 @@ int setup_arg_pages(struct linux_binprm return -ENOMEM; } + memset(mpnt, 0, sizeof(*mpnt)); + down_write(&mm->mmap_sem); { mpnt->vm_mm = mm; @@ -363,11 +364,6 @@ int setup_arg_pages(struct linux_binprm mpnt->vm_flags = vm_stack_flags32; mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC) ? PAGE_COPY_EXEC : PAGE_COPY; - mpnt->vm_ops = NULL; - mpnt->vm_pgoff = 0; - mpnt->vm_file = NULL; - mpol_set_vma_default(mpnt); - mpnt->vm_private_data = (void *) 0; insert_vm_struct(mm, mpnt); mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; } @@ -376,7 +372,7 @@ int setup_arg_pages(struct linux_binprm struct page *page = bprm->page[i]; if (page) { bprm->page[i] = NULL; - put_dirty_page(current,page,stack_base,mpnt->vm_page_prot); + install_arg_page(mpnt, page, stack_base); } stack_base += PAGE_SIZE; } diff -puN fs/exec.c~rmap-33-install_arg_page-vma fs/exec.c --- 25/fs/exec.c~rmap-33-install_arg_page-vma 2004-05-15 21:58:17.983879424 -0700 +++ 25-akpm/fs/exec.c 2004-05-15 21:58:17.994877752 -0700 @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -294,17 +293,19 @@ EXPORT_SYMBOL(copy_strings_kernel); * This routine is used to map in a page into an address space: needed by * execve() for the initial stack and environment pages. * - * tsk->mm->mmap_sem is held for writing. + * vma->vm_mm->mmap_sem is held for writing. */ -void put_dirty_page(struct task_struct *tsk, struct page *page, - unsigned long address, pgprot_t prot) +void install_arg_page(struct vm_area_struct *vma, + struct page *page, unsigned long address) { - struct mm_struct *mm = tsk->mm; + struct mm_struct *mm = vma->vm_mm; pgd_t * pgd; pmd_t * pmd; pte_t * pte; + flush_dcache_page(page); pgd = pgd_offset(mm, address); + spin_lock(&mm->page_table_lock); pmd = pmd_alloc(mm, pgd, address); if (!pmd) @@ -318,8 +319,8 @@ void put_dirty_page(struct task_struct * } mm->rss++; lru_cache_add_active(page); - flush_dcache_page(page); - set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(page, prot)))); + set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte( + page, vma->vm_page_prot)))); page_add_anon_rmap(page, mm, address); pte_unmap(pte); spin_unlock(&mm->page_table_lock); @@ -329,7 +330,7 @@ void put_dirty_page(struct task_struct * out: spin_unlock(&mm->page_table_lock); __free_page(page); - force_sig(SIGKILL, tsk); + force_sig(SIGKILL, current); } int setup_arg_pages(struct linux_binprm *bprm, int executable_stack) @@ -435,8 +436,7 @@ int setup_arg_pages(struct linux_binprm struct page *page = bprm->page[i]; if (page) { bprm->page[i] = NULL; - put_dirty_page(current, page, stack_base, - mpnt->vm_page_prot); + install_arg_page(mpnt, page, stack_base); } stack_base += PAGE_SIZE; } diff -puN include/linux/mm.h~rmap-33-install_arg_page-vma include/linux/mm.h --- 25/include/linux/mm.h~rmap-33-install_arg_page-vma 2004-05-15 21:58:17.984879272 -0700 +++ 25-akpm/include/linux/mm.h 2004-05-15 21:58:17.996877448 -0700 @@ -530,8 +530,7 @@ extern int install_file_pte(struct mm_st extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access); extern int make_pages_present(unsigned long addr, unsigned long end); extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); -void put_dirty_page(struct task_struct *tsk, struct page *page, - unsigned long address, pgprot_t prot); +void install_arg_page(struct vm_area_struct *, struct page *, unsigned long); int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int len, int write, int force, struct page **pages, struct vm_area_struct **vmas); _