From: laijs@cn.fujitsu.com (Lai Jiangshan)
Subject: [ltt-dev] [PATCH 2/2] ltt-relay: cache page's address
Date: Fri, 27 Feb 2009 16:11:49 +0800 [thread overview]
Message-ID: <49A7A045.9@cn.fujitsu.com> (raw)
page_address is not fast in some systems,
we should cache it.
Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
diff --git a/include/linux/ltt-relay.h b/include/linux/ltt-relay.h
index 8d23352..20908ec 100644
--- a/include/linux/ltt-relay.h
+++ b/include/linux/ltt-relay.h
@@ -34,6 +34,7 @@ struct rchan_buf;
struct buf_page {
struct page *page;
+ void *virt; /* page address of the struct page */
size_t offset; /* page offset in the buffer */
struct list_head list; /* buffer linked list */
};
@@ -275,8 +276,7 @@ static inline int ltt_relay_write(struct rchan_buf *buf, size_t offset,
page = ltt_relay_cache_page(buf, &buf->wpage, page, offset);
pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
- ltt_relay_do_copy(page_address(page->page)
- + (offset & ~PAGE_MASK), src, pagecpy);
+ ltt_relay_do_copy(page->virt + (offset & ~PAGE_MASK), src, pagecpy);
if (unlikely(len != pagecpy))
_ltt_relay_write(buf, offset, src, len, page, pagecpy);
diff --git a/ltt/ltt-relay-alloc.c b/ltt/ltt-relay-alloc.c
index 91c12d4..a10fa4b 100644
--- a/ltt/ltt-relay-alloc.c
+++ b/ltt/ltt-relay-alloc.c
@@ -54,6 +54,7 @@ static int relay_alloc_buf(struct rchan_buf *buf, size_t *size)
goto depopulate;
}
list_add_tail(&buf_page->list, &buf->pages);
+ buf_page->virt = page_address(buf_page->page);
buf_page->offset = (size_t)i << PAGE_SHIFT;
set_page_private(buf_page->page, (unsigned long)buf_page);
if (i == 0) {
@@ -524,8 +525,8 @@ void _ltt_relay_write(struct rchan_buf *buf, size_t offset,
page = ltt_relay_cache_page(buf, &buf->wpage, page, offset);
pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
- ltt_relay_do_copy(page_address(page->page)
- + (offset & ~PAGE_MASK), src, pagecpy);
+ ltt_relay_do_copy(page->virt
+ + (offset & ~PAGE_MASK), src, pagecpy);
} while (unlikely(len != pagecpy));
}
EXPORT_SYMBOL_GPL(_ltt_relay_write);
@@ -551,8 +552,7 @@ int ltt_relay_read(struct rchan_buf *buf, size_t offset,
for (;;) {
page = ltt_relay_cache_page(buf, &buf->rpage, page, offset);
pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
- memcpy(dest, page_address(page->page) + (offset & ~PAGE_MASK),
- pagecpy);
+ memcpy(dest, page->virt + (offset & ~PAGE_MASK), pagecpy);
len -= pagecpy;
if (likely(!len))
break;
@@ -605,7 +605,7 @@ void *ltt_relay_offset_address(struct rchan_buf *buf, size_t offset)
if (offset < page->offset || offset >= page->offset + PAGE_SIZE)
buf->hpage[odd] = page = buf->wpage;
page = ltt_relay_cache_page(buf, &buf->hpage[odd], page, offset);
- return page_address(page->page) + (offset & ~PAGE_MASK);
+ return page->virt + (offset & ~PAGE_MASK);
}
EXPORT_SYMBOL_GPL(ltt_relay_offset_address);
next reply other threads:[~2009-02-27 8:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-27 8:11 Lai Jiangshan [this message]
2009-02-27 16:26 ` Mathieu Desnoyers
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=49A7A045.9@cn.fujitsu.com \
--to=laijs@cn.fujitsu.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