From: Christoph Lameter <clameter@sgi.com>
To: akpm@linux-foundation.org
Cc: Nate Diller <nate.diller@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] zero_user_page uses in fs/buffer.c and fs/libfs.c
Date: Sun, 29 Apr 2007 23:14:40 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0704292313060.3018@schroedinger.engr.sgi.com> (raw)
There are a couple of places where kmap_atomic is surrounding two
memory operations. Usually only one of them is performed. So it is
possible to also use zero_user_page there.
Cc: Nate Diller <nate.diller@gmail.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/buffer.c | 29 ++++++++++-------------------
fs/libfs.c | 12 ++++++------
2 files changed, 16 insertions(+), 25 deletions(-)
Index: linux-2.6.21-rc7-mm1/fs/buffer.c
===================================================================
--- linux-2.6.21-rc7-mm1.orig/fs/buffer.c 2007-04-25 00:20:35.000000000 -0700
+++ linux-2.6.21-rc7-mm1/fs/buffer.c 2007-04-25 00:24:05.000000000 -0700
@@ -1796,19 +1796,12 @@ static int __block_prepare_write(struct
set_buffer_uptodate(bh);
continue;
}
- if (block_end > to || block_start < from) {
- void *kaddr;
-
- kaddr = kmap_atomic(page, KM_USER0);
- if (block_end > to)
- memset(kaddr+to, 0,
- block_end-to);
- if (block_start < from)
- memset(kaddr+block_start,
- 0, from-block_start);
- flush_dcache_page(page);
- kunmap_atomic(kaddr, KM_USER0);
- }
+ if (block_end > to)
+ zero_user_page(page, to,
+ block_end - to, KM_USER0);
+ if (block_start < from)
+ zero_user_page(page, block_start,
+ from - block_start, KM_USER0);
continue;
}
}
@@ -2224,7 +2217,6 @@ int nobh_prepare_write(struct page *page
unsigned block_in_page;
unsigned block_start;
sector_t block_in_file;
- char *kaddr;
int nr_reads = 0;
int i;
int ret = 0;
@@ -2264,13 +2256,12 @@ int nobh_prepare_write(struct page *page
if (PageUptodate(page))
continue;
if (buffer_new(&map_bh) || !buffer_mapped(&map_bh)) {
- kaddr = kmap_atomic(page, KM_USER0);
if (block_start < from)
- memset(kaddr+block_start, 0, from-block_start);
+ zero_user_page(page, block_start,
+ from - block_start, KM_USER0);
if (block_end > to)
- memset(kaddr + to, 0, block_end - to);
- flush_dcache_page(page);
- kunmap_atomic(kaddr, KM_USER0);
+ zero_user_page(page, to,
+ block_end - to, KM_USER0);
continue;
}
if (buffer_uptodate(&map_bh))
Index: linux-2.6.21-rc7-mm1/fs/libfs.c
===================================================================
--- linux-2.6.21-rc7-mm1.orig/fs/libfs.c 2007-04-25 00:24:10.000000000 -0700
+++ linux-2.6.21-rc7-mm1/fs/libfs.c 2007-04-25 00:25:56.000000000 -0700
@@ -337,12 +337,12 @@ int simple_prepare_write(struct file *fi
unsigned from, unsigned to)
{
if (!PageUptodate(page)) {
- if (to - from != PAGE_CACHE_SIZE) {
- void *kaddr = kmap_atomic(page, KM_USER0);
- memset(kaddr, 0, from);
- memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
- flush_dcache_page(page);
- kunmap_atomic(kaddr, KM_USER0);
+ if (to - from != PAGE_CACHE_SIZE)
+ if (from)
+ zero_user_page(page, 0, from, KM_USER0);
+ if (to < PAGE_CACHE_SIZE)
+ zero_user_page(page, to,
+ PAGE_CACHE_SIZE - to, KM_USER0);
}
}
return 0;
next reply other threads:[~2007-04-30 6:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-30 6:14 Christoph Lameter [this message]
2007-04-30 6:53 ` Satyam Sharma
2007-04-30 7:04 ` Christoph Lameter
2007-05-02 0:26 ` Andrew Morton
2007-05-02 1:09 ` Christoph Lameter
2007-05-02 2:16 ` Nate Diller
2007-05-02 2:27 ` Nate Diller
2007-05-02 3:58 ` Christoph Lameter
2007-05-02 4:09 ` 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=Pine.LNX.4.64.0704292313060.3018@schroedinger.engr.sgi.com \
--to=clameter@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nate.diller@gmail.com \
/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
all inboxes | Powered by JetHome®