Re: [PATCH] use clear_page()/copy_page() in favor ofmemset()/memcpy() on whole pages

From: Miklos Szeredi
Date: Wed Sep 15 2010 - 02:33:04 EST


On Tue, 14 Sep 2010, Andrew Morton wrote:
> On Thu, 02 Sep 2010 13:30:37 +0100
> "Jan Beulich" <JBeulich@xxxxxxxxxx> wrote:
>
> > After all that's what they are intended for.
> >
> > ...
> >
> > --- linux-2.6.36-rc3/fs/fuse/dev.c
> > +++ 2.6.36-rc3-use-clear_page/fs/fuse/dev.c
> > @@ -811,7 +811,7 @@ static int fuse_copy_page(struct fuse_co
> >
> > if (page && zeroing && count < PAGE_SIZE) {
> > void *mapaddr = kmap_atomic(page, KM_USER1);
> > - memset(mapaddr, 0, PAGE_SIZE);
> > + clear_page(mapaddr);
> > kunmap_atomic(mapaddr, KM_USER1);
> > }
> > while (count) {
>
> fuse wanted to use clear_highpage() here. But clear_highpage() uses
> KM_USER0. I don't immediately see why fuse uses KM_USER1 here?

There used to be KM_USER0 kmaps in there, but now they've been
replaced with plain kmaps. So switching to clear_highpage() should be
fine.

Incremental patch appended.

Thanks,
Miklos
----

Subject: fuse: use clear_highpage() and KM_USER0 instead of KM_USER1
From: Miklos Szeredi <mszeredi@xxxxxxx>

Commit 7909b1c640 (fuse: don't use atomic kmap) removed KM_USER0 usage
from fuse/dev.c. Switch KM_USER1 uses to KM_USER0 for clarity. Also
replace open coded clear_highpage().

Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
---
fs/fuse/dev.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

Index: linux-2.6/fs/fuse/dev.c
===================================================================
--- linux-2.6.orig/fs/fuse/dev.c 2010-09-15 08:22:34.000000000 +0200
+++ linux-2.6/fs/fuse/dev.c 2010-09-15 08:24:30.000000000 +0200
@@ -809,11 +809,9 @@ static int fuse_copy_page(struct fuse_co
int err;
struct page *page = *pagep;

- if (page && zeroing && count < PAGE_SIZE) {
- void *mapaddr = kmap_atomic(page, KM_USER1);
- clear_page(mapaddr);
- kunmap_atomic(mapaddr, KM_USER1);
- }
+ if (page && zeroing && count < PAGE_SIZE)
+ clear_highpage(page);
+
while (count) {
if (cs->write && cs->pipebufs && page) {
return fuse_ref_page(cs, page, offset, count);
@@ -830,10 +828,10 @@ static int fuse_copy_page(struct fuse_co
}
}
if (page) {
- void *mapaddr = kmap_atomic(page, KM_USER1);
+ void *mapaddr = kmap_atomic(page, KM_USER0);
void *buf = mapaddr + offset;
offset += fuse_copy_do(cs, &buf, &count);
- kunmap_atomic(mapaddr, KM_USER1);
+ kunmap_atomic(mapaddr, KM_USER0);
} else
offset += fuse_copy_do(cs, NULL, &count);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/