All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Rogachev <rogachevsergei@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: iamjoonsoo.kim@lge.com, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] mm/page_ext: remove unnecessary stack_trace field
Date: Wed, 28 Jan 2015 23:08:47 +0400	[thread overview]
Message-ID: <20150128230847.16cc8e4fbb5f601dc667d94d@gmail.com> (raw)
In-Reply-To: <20150127144319.f3a161e5f5d562a0a605371e@linux-foundation.org>

On Tue, 27 Jan 2015 14:43:19 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Tue, 27 Jan 2015 00:52:12 +0300 Sergei Rogachev <rogachevsergei@gmail.com> wrote:
> 
> > Page owner uses the page_ext structure to keep meta-information
> > for every page in the system. The structure also contains a field
> > of type 'struct stack_trace', page owner uses this field during
> > invocation of the function save_stack_trace. It is easy to notice
> > that keeping a copy of this structure for every page in the system
> > is very inefficiently in terms of memory.
> > 
> > The patch removes this unnecessary field of page_ext and forces
> > page owner to use a stack_trace structure allocated on the stack.
> > 
> 
> Fair enough.
> 
> What do you think of the below tweaks?  Seems a bit neater, and it will
> cause all unmentioned fields to be zeroed out.  It's not a bug to leave
> .max_entries uninitialised in print_page_owner(), but it's nice not to
> leave loose ends.

Yes, with your fix the code looks much better!

> 
> --- a/mm/page_owner.c~mm-page_ext-remove-unnecessary-stack_trace-field-fix
> +++ a/mm/page_owner.c
> @@ -59,15 +59,14 @@ void __reset_page_owner(struct page *pag
>  
>  void __set_page_owner(struct page *page, unsigned int order, gfp_t gfp_mask)
>  {
> -	struct page_ext *page_ext;
> -	struct stack_trace trace;
> +	struct page_ext *page_ext = lookup_page_ext(page);
> +	struct stack_trace trace = {
> +		.nr_entries = 0,
> +		.max_entries = ARRAY_SIZE(page_ext->trace_entries),
> +		.entries = &page_ext->trace_entries[0],
> +		.skip = 3,
> +	};
>  
> -	page_ext = lookup_page_ext(page);
> -
> -	trace.nr_entries = 0;
> -	trace.max_entries = ARRAY_SIZE(page_ext->trace_entries);
> -	trace.entries = &page_ext->trace_entries[0];
> -	trace.skip = 3;
>  	save_stack_trace(&trace);
>  
>  	page_ext->order = order;
> @@ -83,8 +82,11 @@ print_page_owner(char __user *buf, size_
>  {
>  	int ret;
>  	int pageblock_mt, page_mt;
> -	struct stack_trace trace;
>  	char *kbuf;
> +	struct stack_trace trace = {
> +		.nr_entries = page_ext->nr_entries,
> +		.entries = &page_ext->trace_entries[0],
> +	};
>  
>  	kbuf = kmalloc(count, GFP_KERNEL);
>  	if (!kbuf)
> @@ -122,9 +124,6 @@ print_page_owner(char __user *buf, size_
>  	if (ret >= count)
>  		goto err;
>  
> -	trace.nr_entries = page_ext->nr_entries;
> -	trace.entries = &page_ext->trace_entries[0];
> -
>  	ret += snprint_stack_trace(kbuf + ret, count - ret, &trace, 0);
>  	if (ret >= count)
>  		goto err;
> _
> 

      reply	other threads:[~2015-01-28 20:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 21:52 [PATCH 0/1] mm/page_ext: remove unnecessary stack_trace field Sergei Rogachev
2015-01-26 21:52 ` [PATCH 1/1] " Sergei Rogachev
2015-01-27  8:36   ` Joonsoo Kim
2015-01-27 22:43   ` Andrew Morton
2015-01-28 19:08     ` Sergei Rogachev [this message]

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=20150128230847.16cc8e4fbb5f601dc667d94d@gmail.com \
    --to=rogachevsergei@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.