lkml.org 
[lkml]   [2010]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] pagemap: early return on unmapped areas
On Thu, Jan 14, 2010 at 04:30:48PM +0800, Andi Kleen wrote:
> > ---
> > pagemap: early return on unmapped areas
>
> Yes seems like a reasonable idea.

Thanks!

I just changed the ">" to ">=", because it happen to make a difference
for cp/cat, which does 4k sized read:

4k read buffer = 4k/8 pages = 512 pages = NR_PMD_PAGES

So the change to ">=" makes cp exit immediately (4k buffer matches
exactly one PMD hole).

before
dd if=/proc/$$/pagemap of=/dev/null bs=4k
512+0 records in
512+0 records out
2097152 bytes (2.1 MB) copied, 0.0225796 s, 92.9 MB/s

after
dd if=/proc/$$/pagemap of=/dev/null bs=4k
0+0 records in
0+0 records out
0 bytes (0 B) copied, 2.8029e-05 s, 0.0 kB/s

page-types still works (only faster;) with this patch.

Thanks,
Fengguang
---
pagemap: early return on unmapped areas

This helps stop dumb cp/cat early instead of loop for days:

http://bugzilla.kernel.org/show_bug.cgi?id=15041

This also serves as an optimization to normal pagemap users (eg.
page-types).

CC: Andi Kleen <andi@firstfloor.org>
CC: Matt Mackall <mpm@selenic.com>
CC: <stable@kernel.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
fs/proc/task_mmu.c | 4 ++++
1 file changed, 4 insertions(+)

--- linux-mm.orig/fs/proc/task_mmu.c 2010-01-14 13:38:44.000000000 +0800
+++ linux-mm/fs/proc/task_mmu.c 2010-01-14 16:38:49.000000000 +0800
@@ -586,6 +586,10 @@ static int pagemap_pte_hole(unsigned lon
struct pagemapread *pm = walk->private;
unsigned long addr;
int err = 0;
+
+ if ((end - start) / PAGE_SIZE >= pm->end - pm->out)
+ return PM_END_OF_BUFFER;
+
for (addr = start; addr < end; addr += PAGE_SIZE) {
err = add_to_pagemap(addr, PM_NOT_PRESENT, pm);
if (err)

\
 
 \ /
  Last update: 2010-01-14 09:55    [W:0.050 / U:1.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site