All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Zanussi <zanussi@comcast.net>
To: Masami Hiramatsu <mhiramat@redhat.com>
Cc: David Wilder <dwilder@us.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	systemtap-ml <systemtap@sources.redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	tzanussi@gmail.com
Subject: Re: [PATCH -mm] relayfs: support larger relay buffer
Date: Tue, 15 Apr 2008 23:22:49 -0500	[thread overview]
Message-ID: <1208319769.7893.16.camel@charm-linux> (raw)
In-Reply-To: <4804C95F.2080204@redhat.com>


On Tue, 2008-04-15 at 11:27 -0400, Masami Hiramatsu wrote:
> Use vmalloc() and memset() instead of kcalloc() to allocate a page* array
> when the array size is bigger than one page. This enables relayfs to support
> bigger relay buffers than 64MB on 4k-page system, 512MB on 16k-page system.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
> ---
> This is useful for a 64-bit system which has a plenty of memory (tens of
> giga bytes) and a large kernel memory space.
> 
> I tested it on x86-64 and ia64.
> 

Hi,

It looks ok to me, but it might be a little cleaner and avoid some
duplication if you add the new code as a couple of functions instead.
Just a suggestion...

Tom

>  kernel/relay.c |   22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> Index: 2.6.25-rc8-mm2/kernel/relay.c
> ===================================================================
> --- 2.6.25-rc8-mm2.orig/kernel/relay.c
> +++ 2.6.25-rc8-mm2/kernel/relay.c
> @@ -104,12 +104,20 @@ static int relay_mmap_buf(struct rchan_b
>  static void *relay_alloc_buf(struct rchan_buf *buf, size_t *size)
>  {
>  	void *mem;
> -	unsigned int i, j, n_pages;
> +	unsigned int i, j, n_pages, pa_size;
> 
>  	*size = PAGE_ALIGN(*size);
>  	n_pages = *size >> PAGE_SHIFT;
> +	pa_size = n_pages * sizeof(struct page *);
> 
> -	buf->page_array = kcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
> +	if (pa_size > PAGE_SIZE) {
> +		buf->page_array = vmalloc(pa_size);
> +		if (buf->page_array)
> +			memset(buf->page_array, 0, pa_size);
> +	} else {
> +		buf->page_array = kcalloc(n_pages, sizeof(struct page *),
> +					  GFP_KERNEL);
> +	}
>  	if (!buf->page_array)
>  		return NULL;
> 
> @@ -130,7 +138,10 @@ static void *relay_alloc_buf(struct rcha
>  depopulate:
>  	for (j = 0; j < i; j++)
>  		__free_page(buf->page_array[j]);
> -	kfree(buf->page_array);
> +	if (pa_size > PAGE_SIZE)
> +		vfree(buf->page_array);
> +	else
> +		kfree(buf->page_array);
>  	return NULL;
>  }
> 
> @@ -189,7 +200,10 @@ static void relay_destroy_buf(struct rch
>  		vunmap(buf->start);
>  		for (i = 0; i < buf->page_count; i++)
>  			__free_page(buf->page_array[i]);
> -		kfree(buf->page_array);
> +		if (buf->page_count * sizeof(struct page *) > PAGE_SIZE)
> +			vfree(buf->page_array);
> +		else
> +			kfree(buf->page_array);
>  	}
>  	chan->buf[buf->cpu] = NULL;
>  	kfree(buf->padding);


  reply	other threads:[~2008-04-16  4:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-15 15:27 [PATCH -mm] relayfs: support larger relay buffer Masami Hiramatsu
2008-04-16  4:22 ` Tom Zanussi [this message]
2008-04-16 16:19   ` Masami Hiramatsu
2008-04-16 18:03   ` [PATCH -mm] relayfs: support larger relay buffer take 2 Masami Hiramatsu
2008-04-16 18:21     ` Pekka J Enberg
2008-04-16 18:34       ` Masami Hiramatsu
2008-04-16 19:51         ` [PATCH -mm] relayfs: support larger relay buffer take 3 Masami Hiramatsu
2008-04-16 19:54           ` Pekka Enberg
2008-04-16 20:48           ` Andrew Morton
2008-04-16 21:00             ` Masami Hiramatsu
2008-04-17  4:05           ` Tom Zanussi
2008-04-16  8:33 ` [PATCH -mm] relayfs: support larger relay buffer Pekka Enberg
2008-04-16 14:36   ` Masami Hiramatsu

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=1208319769.7893.16.camel@charm-linux \
    --to=zanussi@comcast.net \
    --cc=akpm@linux-foundation.org \
    --cc=dwilder@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=systemtap@sources.redhat.com \
    --cc=tzanussi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.