Commit 674b892e authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

mm: restore KERNEL_DS optimisations

Restore the KERNEL_DS optimisation, especially helpful to the 2copy write
path.

This may be a pretty questionable gain in most cases, especially after the
legacy 2copy write path is removed, but it doesn't cost much.
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8268f5a7
...@@ -2061,7 +2061,7 @@ static ssize_t generic_perform_write_2copy(struct file *file, ...@@ -2061,7 +2061,7 @@ static ssize_t generic_perform_write_2copy(struct file *file,
* cannot take a pagefault with the destination page locked. * cannot take a pagefault with the destination page locked.
* So pin the source page to copy it. * So pin the source page to copy it.
*/ */
if (!PageUptodate(page)) { if (!PageUptodate(page) && !segment_eq(get_fs(), KERNEL_DS)) {
unlock_page(page); unlock_page(page);
src_page = alloc_page(GFP_KERNEL); src_page = alloc_page(GFP_KERNEL);
...@@ -2186,6 +2186,13 @@ static ssize_t generic_perform_write(struct file *file, ...@@ -2186,6 +2186,13 @@ static ssize_t generic_perform_write(struct file *file,
const struct address_space_operations *a_ops = mapping->a_ops; const struct address_space_operations *a_ops = mapping->a_ops;
long status = 0; long status = 0;
ssize_t written = 0; ssize_t written = 0;
unsigned int flags = 0;
/*
* Copies from kernel address space cannot fail (NFSD is a big user).
*/
if (segment_eq(get_fs(), KERNEL_DS))
flags |= AOP_FLAG_UNINTERRUPTIBLE;
do { do {
struct page *page; struct page *page;
...@@ -2217,7 +2224,7 @@ again: ...@@ -2217,7 +2224,7 @@ again:
break; break;
} }
status = a_ops->write_begin(file, mapping, pos, bytes, 0, status = a_ops->write_begin(file, mapping, pos, bytes, flags,
&page, &fsdata); &page, &fsdata);
if (unlikely(status)) if (unlikely(status))
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment