[ltt-dev] [PATCH 2/2] ltt-relay: cache page's address

Mathieu Desnoyers mathieu.desnoyers at polymtl.ca
Fri Feb 27 11:26:29 EST 2009


* Lai Jiangshan (laijs at cn.fujitsu.com) wrote:
> 
> page_address is not fast in some systems,
> we should cache it.
> 


Ah ! great patch. I look forward to measure the performance improvements
this patch provides.

Will merge, thanks,

Mathieu

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at polymtl.ca>

> 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);
>  
> 
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




More information about the lttng-dev mailing list