From: Hugh Dickins <hugh@veritas.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Tony Luck <tony.luck@intel.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 08/21] mm: ia64 use expand_upwards
Date: Thu, 13 Oct 2005 01:53:38 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.61.0510130152240.4060@goblin.wat.veritas.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0510130143240.4060@goblin.wat.veritas.com>
ia64 has expand_backing_store function for growing its Register Backing
Store vma upwards. But more complete code for this purpose is found in
the CONFIG_STACK_GROWSUP part of mm/mmap.c. Uglify its #ifdefs further
to provide expand_upwards for ia64 as well as expand_stack for parisc.
The Register Backing Store vma should be marked VM_ACCOUNT. Implement
the intention of growing it only a page at a time, instead of passing an
address outside of the vma to handle_mm_fault, with unknown consequences.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
arch/ia64/mm/fault.c | 34 +++++++---------------------------
arch/ia64/mm/init.c | 2 +-
include/linux/mm.h | 3 ++-
mm/mmap.c | 17 ++++++++++++++---
4 files changed, 24 insertions(+), 32 deletions(-)
--- mm07/arch/ia64/mm/fault.c 2005-09-30 11:58:53.000000000 +0100
+++ mm08/arch/ia64/mm/fault.c 2005-10-11 23:55:38.000000000 +0100
@@ -20,32 +20,6 @@
extern void die (char *, struct pt_regs *, long);
/*
- * This routine is analogous to expand_stack() but instead grows the
- * register backing store (which grows towards higher addresses).
- * Since the register backing store is access sequentially, we
- * disallow growing the RBS by more than a page at a time. Note that
- * the VM_GROWSUP flag can be set on any VM area but that's fine
- * because the total process size is still limited by RLIMIT_STACK and
- * RLIMIT_AS.
- */
-static inline long
-expand_backing_store (struct vm_area_struct *vma, unsigned long address)
-{
- unsigned long grow;
-
- grow = PAGE_SIZE >> PAGE_SHIFT;
- if (address - vma->vm_start > current->signal->rlim[RLIMIT_STACK].rlim_cur
- || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->signal->rlim[RLIMIT_AS].rlim_cur))
- return -ENOMEM;
- vma->vm_end += PAGE_SIZE;
- vma->vm_mm->total_vm += grow;
- if (vma->vm_flags & VM_LOCKED)
- vma->vm_mm->locked_vm += grow;
- vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
- return 0;
-}
-
-/*
* Return TRUE if ADDRESS points at a page in the kernel's mapped segment
* (inside region 5, on ia64) and that page is present.
*/
@@ -185,7 +159,13 @@ ia64_do_page_fault (unsigned long addres
if (REGION_NUMBER(address) != REGION_NUMBER(vma->vm_start)
|| REGION_OFFSET(address) >= RGN_MAP_LIMIT)
goto bad_area;
- if (expand_backing_store(vma, address))
+ /*
+ * Since the register backing store is accessed sequentially,
+ * we disallow growing it by more than a page at a time.
+ */
+ if (address > vma->vm_end + PAGE_SIZE - sizeof(long))
+ goto bad_area;
+ if (expand_upwards(vma, address))
goto bad_area;
}
goto good_area;
--- mm07/arch/ia64/mm/init.c 2005-09-21 12:16:14.000000000 +0100
+++ mm08/arch/ia64/mm/init.c 2005-10-11 23:55:38.000000000 +0100
@@ -158,7 +158,7 @@ ia64_init_addr_space (void)
vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
vma->vm_end = vma->vm_start + PAGE_SIZE;
vma->vm_page_prot = protection_map[VM_DATA_DEFAULT_FLAGS & 0x7];
- vma->vm_flags = VM_DATA_DEFAULT_FLAGS | VM_GROWSUP;
+ vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
down_write(¤t->mm->mmap_sem);
if (insert_vm_struct(current->mm, vma)) {
up_write(¤t->mm->mmap_sem);
--- mm07/include/linux/mm.h 2005-10-11 23:54:33.000000000 +0100
+++ mm08/include/linux/mm.h 2005-10-11 23:55:38.000000000 +0100
@@ -904,7 +904,8 @@ void handle_ra_miss(struct address_space
unsigned long max_sane_readahead(unsigned long nr);
/* Do stack extension */
-extern int expand_stack(struct vm_area_struct * vma, unsigned long address);
+extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
+extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
--- mm07/mm/mmap.c 2005-10-11 23:54:33.000000000 +0100
+++ mm08/mm/mmap.c 2005-10-11 23:55:38.000000000 +0100
@@ -1504,11 +1504,15 @@ static int acct_stack_growth(struct vm_a
return 0;
}
-#ifdef CONFIG_STACK_GROWSUP
+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
/*
- * vma is the first one with address > vma->vm_end. Have to extend vma.
+ * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
+ * vma is the last one with address > vma->vm_end. Have to extend vma.
*/
-int expand_stack(struct vm_area_struct * vma, unsigned long address)
+#ifdef CONFIG_STACK_GROWSUP
+static inline
+#endif
+int expand_upwards(struct vm_area_struct *vma, unsigned long address)
{
int error;
@@ -1546,6 +1550,13 @@ int expand_stack(struct vm_area_struct *
anon_vma_unlock(vma);
return error;
}
+#endif /* CONFIG_STACK_GROWSUP || CONFIG_IA64 */
+
+#ifdef CONFIG_STACK_GROWSUP
+int expand_stack(struct vm_area_struct *vma, unsigned long address)
+{
+ return expand_upwards(vma, address);
+}
struct vm_area_struct *
find_extend_vma(struct mm_struct *mm, unsigned long addr)
next prev parent reply other threads:[~2005-10-13 0:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-13 0:44 [PATCH 00/21] mm: page fault scalability nearer Hugh Dickins
2005-10-13 0:45 ` [PATCH 01/21] mm: copy_one_pte inc rss Hugh Dickins
2005-10-13 0:46 ` [PATCH 02/21] mm: zap_pte_range dec rss Hugh Dickins
2005-10-13 0:47 ` [PATCH 03/21] mm: do_swap_page race major Hugh Dickins
2005-10-13 0:47 ` [PATCH 04/21] mm: do_mremap current mm Hugh Dickins
2005-10-13 0:48 ` [PATCH 05/21] mm: zap_pte out of line Hugh Dickins
2005-10-13 0:50 ` [PATCH 06/21] mm: update_hiwaters just in time Hugh Dickins
2005-10-13 1:17 ` Christoph Lameter
2005-10-13 19:18 ` Jay Lan
2005-10-13 0:52 ` [PATCH 07/21] mm: mm_struct hiwaters moved Hugh Dickins
2005-10-13 0:53 ` Hugh Dickins [this message]
2005-10-13 0:55 ` [PATCH 09/21] mm: init_mm without ptlock Hugh Dickins
2005-10-13 0:55 ` [PATCH 10/21] mm: ptd_alloc inline and out Hugh Dickins
2005-10-13 0:56 ` [PATCH 11/21] mm: ptd_alloc take ptlock Hugh Dickins
2005-10-13 0:59 ` [PATCH 12/21] mm: arches skip ptlock Hugh Dickins
2005-10-13 1:13 ` [PATCH 13/21] mm: page fault handler locking Hugh Dickins
2005-10-13 1:14 ` [PATCH 14/21] mm: pte_offset_map_lock loops Hugh Dickins
2005-10-13 1:16 ` [PATCH 15/21] mm: flush_tlb_range outside ptlock Hugh Dickins
2005-10-13 1:17 ` [PATCH 16/21] mm: unlink vma before pagetables Hugh Dickins
2005-10-13 1:18 ` [PATCH 17/21] mm: unmap_vmas with inner ptlock Hugh Dickins
2005-10-13 1:20 ` [PATCH 18/21] mm: xip_unmap ZERO_PAGE fix Hugh Dickins
2005-10-13 12:39 ` Carsten Otte
2005-10-13 1:21 ` [PATCH 19/21] mm: rmap with inner ptlock Hugh Dickins
2005-10-13 1:22 ` [PATCH 20/21] mm: kill check_user_page_readable Hugh Dickins
2005-10-13 1:23 ` [PATCH 21/21] mm: follow_page with inner ptlock Hugh Dickins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.61.0510130152240.4060@goblin.wat.veritas.com \
--to=hugh@veritas.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®