From: Minchan Kim <minchan.kim@gmail.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: cl@linux-foundation.org, "linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [RFC MM 4/4] speculative page fault
Date: Sat, 14 Nov 2009 00:59:56 +0900 [thread overview]
Message-ID: <28c262360911130759tb9ffde4n8101bd27f31b5669@mail.gmail.com> (raw)
In-Reply-To: <20091113164134.79805c13.kamezawa.hiroyu@jp.fujitsu.com>
On Fri, Nov 13, 2009 at 4:41 PM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@jp.fujitsu.com> wrote:
> Speculative page fault.
>
> This patch tries to implement speculative page fault.
> Do page fault without taking mm->semaphore and check tag mm->generation
> after taking page table lock. If generation is modified, someone took
> write lock on mm->semaphore and we need to take read lock.
>
> Now, hugepage is not handled. And stack page is not handled because
> it can change [vm_start, vm_end).
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> ---
> arch/x86/mm/fault.c | 54 ++++++++++++++++++++++++++--------------
> include/linux/mm.h | 2 -
> mm/memory.c | 70 ++++++++++++++++++++++++++++++++--------------------
> 3 files changed, 81 insertions(+), 45 deletions(-)
>
> Index: mmotm-2.6.32-Nov2/arch/x86/mm/fault.c
> ===================================================================
> --- mmotm-2.6.32-Nov2.orig/arch/x86/mm/fault.c
> +++ mmotm-2.6.32-Nov2/arch/x86/mm/fault.c
> @@ -11,6 +11,7 @@
> #include <linux/kprobes.h> /* __kprobes, ... */
> #include <linux/mmiotrace.h> /* kmmio_handler, ... */
> #include <linux/perf_event.h> /* perf_sw_event */
> +#include <linux/hugetlb.h> /* is_vm_hugetlbe_page()... */
>
> #include <asm/traps.h> /* dotraplinkage, ... */
> #include <asm/pgalloc.h> /* pgd_*(), ... */
> @@ -952,7 +953,8 @@ do_page_fault(struct pt_regs *regs, unsi
> struct mm_struct *mm;
> int write;
> int fault;
> - int cachehit = 0;
> + int cachehit;
> + unsigned int key;
>
> tsk = current;
> mm = tsk->mm;
> @@ -1057,6 +1059,18 @@ do_page_fault(struct pt_regs *regs, unsi
> * validate the source. If this is invalid we can skip the address
> * space check, thus avoiding the deadlock:
> */
> + if ((error_code & PF_USER) &&
> + (mm->generation == current->mm_generation) && current->vma_cache) {
> + vma = current->vma_cache;
> + if ((vma->vm_start <= address) && (address < vma->vm_end)) {
> + key = mm->generation;
> + cachehit = 1;
> + goto got_vma;
> + }
> + }
> +speculative_fault_retry:
> + cachehit = 0;
> + vma = NULL;
> if (unlikely(!mm_reader_trylock(mm))) {
> if ((error_code & PF_USER) == 0 &&
> !search_exception_tables(regs->ip)) {
> @@ -1072,13 +1086,9 @@ do_page_fault(struct pt_regs *regs, unsi
> */
> might_sleep();
> }
> - if ((mm->generation == current->mm_generation) && current->vma_cache) {
> - vma = current->vma_cache;
> - if ((vma->vm_start <= address) && (address < vma->vm_end))
> - cachehit = 1;
> - }
> - if (!cachehit)
> - vma = find_vma(mm, address);
> + key = mm->generation;
> + vma = find_vma(mm, address);
> +got_vma:
> if (unlikely(!vma)) {
> bad_area(regs, error_code, address);
> return;
> @@ -1123,13 +1133,17 @@ good_area:
> * make sure we exit gracefully rather than endlessly redo
> * the fault:
> */
> - fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0);
> + fault = handle_mm_fault(mm, vma, address,
> + write ? FAULT_FLAG_WRITE : 0, key);
>
> if (unlikely(fault & VM_FAULT_ERROR)) {
> mm_fault_error(regs, error_code, address, fault);
> return;
> }
>
> + if (mm->generation != key)
> + goto speculative_fault_retry;
> +
You can use match_key in here again. :)
--
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-11-13 15:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 7:35 [RFC MM] " KAMEZAWA Hiroyuki
2009-11-13 7:37 ` [RFC MM 1/4] mm accessor (updated) KAMEZAWA Hiroyuki
2009-11-13 7:38 ` [RFC MM 2/4] refcnt for vm_area_struct KAMEZAWA Hiroyuki
2009-11-13 7:40 ` [RFC MM 3/4] add mm version number KAMEZAWA Hiroyuki
2009-11-13 15:27 ` Minchan Kim
2009-11-13 16:26 ` KAMEZAWA Hiroyuki
2009-11-13 7:41 ` [RFC MM 4/4] speculative page fault KAMEZAWA Hiroyuki
2009-11-13 15:59 ` Minchan Kim [this message]
2009-11-13 16:28 ` KAMEZAWA Hiroyuki
2009-11-13 16:20 ` [RFC MM] " Minchan Kim
2009-11-13 16:38 ` KAMEZAWA Hiroyuki
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=28c262360911130759tb9ffde4n8101bd27f31b5669@mail.gmail.com \
--to=minchan.kim@gmail.com \
--cc=cl@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--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