[lkml]   [2011]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subjectfault_in_pages_writeable/fault_in_pages_readable don't fault in everything

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

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;

[unhandled content-type:application/pgp-signature]
 \ /
  Last update: 2011-07-09 23:03    [W:0.043 / U:2.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site