From: npiggin@suse.de
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [patch 16/18] mm: special mapping nopage
Date: Wed, 05 Dec 2007 18:16:03 +1100 [thread overview]
Message-ID: <20071205071628.484654000@nick.local0.net> (raw)
In-Reply-To: 20071205071547.701344000@nick.local0.net
[-- Attachment #1: special-mapping-nopage.patch --]
[-- Type: text/plain, Size: 2340 bytes --]
Convert special mapping install from nopage to fault. This requires a
small special case in the do_linear_fault calculation in order to handle
vmas without ->vm_file set.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
mm/memory.c | 10 +++++++---
mm/mmap.c | 19 +++++++++----------
2 files changed, 16 insertions(+), 13 deletions(-)
Index: linux-2.6/mm/memory.c
===================================================================
--- linux-2.6.orig/mm/memory.c
+++ linux-2.6/mm/memory.c
@@ -2352,9 +2352,13 @@ static int do_linear_fault(struct mm_str
unsigned long address, pte_t *page_table, pmd_t *pmd,
int write_access, pte_t orig_pte)
{
- pgoff_t pgoff = (((address & PAGE_MASK)
- - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
- unsigned int flags = (write_access ? FAULT_FLAG_WRITE : 0);
+ pgoff_t pgoff;
+ unsigned int flags;
+
+ pgoff = (((address) - vma->vm_start) >> PAGE_SHIFT);
+ if (likely(vma->vm_file))
+ pgoff += vma->vm_pgoff;
+ flags = (write_access ? FAULT_FLAG_WRITE : 0);
pte_unmap(page_table);
return __do_fault(mm, vma, address, pmd, pgoff, flags, orig_pte);
Index: linux-2.6/mm/mmap.c
===================================================================
--- linux-2.6.orig/mm/mmap.c
+++ linux-2.6/mm/mmap.c
@@ -2149,24 +2149,23 @@ int may_expand_vm(struct mm_struct *mm,
}
-static struct page *special_mapping_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static int special_mapping_fault(struct vm_area_struct *vma,
+ struct vm_fault *vmf)
{
+ pgoff_t pgoff = vmf->pgoff;
struct page **pages;
- BUG_ON(address < vma->vm_start || address >= vma->vm_end);
-
- address -= vma->vm_start;
- for (pages = vma->vm_private_data; address > 0 && *pages; ++pages)
- address -= PAGE_SIZE;
+ for (pages = vma->vm_private_data; pgoff && *pages; ++pages)
+ pgoff--;
if (*pages) {
struct page *page = *pages;
get_page(page);
- return page;
+ vmf->page = page;
+ return 0;
}
- return NOPAGE_SIGBUS;
+ return VM_FAULT_SIGBUS;
}
/*
@@ -2178,7 +2177,7 @@ static void special_mapping_close(struct
static struct vm_operations_struct special_mapping_vmops = {
.close = special_mapping_close,
- .nopage = special_mapping_nopage,
+ .fault = special_mapping_fault,
};
/*
--
next prev parent reply other threads:[~2007-12-05 7:59 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-05 7:15 [patch 00/18] remove nopage npiggin
2007-12-05 7:15 ` [patch 01/18] ia64: ia32 nopage npiggin
2007-12-05 7:15 ` [patch 02/18] relay: nopage npiggin
2007-12-05 7:15 ` [patch 03/18] drm: nopage npiggin
2007-12-05 9:05 ` Dave Airlie
2007-12-05 9:17 ` Nick Piggin
2007-12-05 7:15 ` [patch 04/18] uio: nopage npiggin
2007-12-05 10:04 ` Hans-Jürgen Koch
2007-12-05 10:10 ` Nick Piggin
2007-12-05 10:25 ` Hans-Jürgen Koch
2007-12-05 10:37 ` Nick Piggin
2007-12-05 7:15 ` [patch 05/18] kvm: nopage npiggin
2007-12-05 10:40 ` Avi Kivity
2007-12-05 7:15 ` [patch 06/18] ieee1394: nopage npiggin
2007-12-05 13:09 ` Stefan Richter
2007-12-05 13:15 ` Stefan Richter
2007-12-05 23:52 ` Nick Piggin
2007-12-05 23:51 ` Nick Piggin
2007-12-15 13:04 ` Stefan Richter
2007-12-15 13:01 ` Stefan Richter
2007-12-05 7:15 ` [patch 07/18] v4l: nopage npiggin
2007-12-08 0:31 ` Andrew Morton
2007-12-08 9:15 ` Ingo Molnar
2007-12-08 10:15 ` Andrew Morton
2007-12-09 17:10 ` Randy Dunlap
2007-12-10 5:06 ` [patch] x64/page.h: convert some macros to inlines Randy Dunlap
2007-12-10 8:34 ` Ingo Molnar
2007-12-05 7:15 ` [patch 08/18] fb: defio nopage npiggin
2007-12-05 7:15 ` [patch 09/18] agp: alpha nopage npiggin
2007-12-05 7:15 ` [patch 10/18] sg: nopage npiggin
2008-02-08 3:45 ` Douglas Gilbert
2007-12-05 7:15 ` [patch 11/18] ib: nopage npiggin
2007-12-05 7:15 ` [patch 12/18] usb: mon nopage npiggin
2007-12-05 16:39 ` Pete Zaitcev
2007-12-05 23:54 ` Nick Piggin
2007-12-05 7:16 ` [patch 13/18] alsa: nopage npiggin
2007-12-13 15:35 ` Takashi Iwai
2007-12-05 7:16 ` [patch 14/18] oss: via nopage npiggin
2007-12-05 7:16 ` [patch 15/18] alsa: usx2y nopage npiggin
2007-12-13 15:35 ` Takashi Iwai
2007-12-05 7:16 ` npiggin [this message]
2007-12-05 7:16 ` [patch 17/18] mm: remove nopage npiggin
2007-12-05 22:47 ` Andrew Morton
2007-12-05 23:23 ` Nick Piggin
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=20071205071628.484654000@nick.local0.net \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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