public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: tglx@linutronix.de, dvhart@linux.intel.com,
	linux-kernel@vger.kernel.org, mingo@elte.hu,
	a.p.zijlstra@chello.nl
Cc: kosaki.motohiro@jp.fujitsu.com
Subject: [RFC PATCH] futex: replace get_user_pages() with get_user_pages_fast()
Date: Thu, 23 Jun 2011 15:21:52 +0900	[thread overview]
Message-ID: <4E02DB80.10303@jp.fujitsu.com> (raw)

Hello,

Is there any reason to take mmap_sem explicitly here?
Should we change gup_fast() to allow NULL argument (ie for avoid get_page)?

============================
  down_read(&mm->mmap_sem);
  get_user_pages(current, current->mm)
  up_read(&mm->mmap_sem);

and

  get_user_pages_fast()

make an equivalent result, And latter would be better when mamp_sem
highly contended case, because it can avoid to take mmap_sem if
the target page doesn't need a page fault.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 kernel/futex.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index fe28dc2..9f7b1ae 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -351,13 +351,11 @@ static inline void put_futex_key(union futex_key *key)
  */
 static int fault_in_user_writeable(u32 __user *uaddr)
 {
-	struct mm_struct *mm = current->mm;
 	int ret;
+	struct page *page;

-	down_read(&mm->mmap_sem);
-	ret = get_user_pages(current, mm, (unsigned long)uaddr,
-			     1, 1, 0, NULL, NULL);
-	up_read(&mm->mmap_sem);
+	ret = get_user_pages_fast((unsigned long)uaddr, 1, 1, &page);
+	put_page(page);

 	return ret < 0 ? ret : 0;
 }
-- 
1.7.3.1



             reply	other threads:[~2011-06-23  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23  6:21 KOSAKI Motohiro [this message]
2011-06-23 15:11 ` [RFC PATCH] futex: replace get_user_pages() with get_user_pages_fast() Darren Hart
2011-06-23 15:44   ` Peter Zijlstra

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=4E02DB80.10303@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dvhart@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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