public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Keith Packard" <keithp@keithp.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: fault_in_pages_writeable/fault_in_pages_readable don't fault in everything
Date: Sat, 09 Jul 2011 14:01:24 -0700	[thread overview]
Message-ID: <yunr55zf9sr.fsf@aiko.keithp.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]


fault_in_pages_writeable and fault_in_pages_readable are only willing to
fault two pages at the most. I can't find any place where this is a good
idea, and in fact ntfs has replaced fault_in_pages_readable with a
private version which does the right thing.

Here's an (untested) patch which makes fault_in_pages_writeable hit
every page instead of just the first and last. It seems like this might
improve performance of larger read operations which may now end up
taking the slow path when an intermediate page is faulted in
__copy_to_user_inatomic.

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 716875e..f355f29 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -418,7 +418,13 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size)
 	 * Writing zeroes into userspace here is OK, because we know that if
 	 * the zero gets there, we'll be overwriting it.
 	 */
-	ret = __put_user(0, uaddr);
+	for (;;) {
+		ret = __put_user(0, uaddr);
+		if (size < PAGE_SIZE)
+			break;
+		size -= PAGE_SIZE;
+		uaddr += PAGE_SIZE;
+	}
 	if (ret == 0) {
 		char __user *end = uaddr + size - 1;
 

-- 
keith.packard@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2011-07-09 21:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-09 21:01 Keith Packard [this message]
2011-07-27 21:10 ` fault_in_pages_writeable/fault_in_pages_readable don't fault in everything Andrew Morton

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=yunr55zf9sr.fsf@aiko.keithp.com \
    --to=keithp@keithp.com \
    --cc=linux-kernel@vger.kernel.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