LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] memcg: do not recalculate section unnecessarily in init_section_page_cgroup
@ 2008-10-30  4:38 Fernando Luis Vázquez Cao
  2008-10-30  6:45 ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 3+ messages in thread
From: Fernando Luis Vázquez Cao @ 2008-10-30  4:38 UTC (permalink / raw)
  To: akpm; +Cc: kamezawa.hiroyu, linux-kernel

Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
---

diff -urNp linux-2.6.28-rc2-mm1-orig/mm/page_cgroup.c linux-2.6.28-rc2-mm1/mm/page_cgroup.c
--- linux-2.6.28-rc2-mm1-orig/mm/page_cgroup.c	2008-10-30 12:49:27.000000000 +0900
+++ linux-2.6.28-rc2-mm1/mm/page_cgroup.c	2008-10-30 12:52:41.000000000 +0900
@@ -99,13 +99,11 @@ struct page_cgroup *lookup_page_cgroup(s
 
 int __meminit init_section_page_cgroup(unsigned long pfn)
 {
-	struct mem_section *section;
+	struct mem_section *section = __pfn_to_section(pfn);
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	int nid, index;
 
-	section = __pfn_to_section(pfn);
-
 	if (section->page_cgroup)
 		return 0;
 
@@ -131,7 +129,6 @@ int __meminit init_section_page_cgroup(u
 		__init_page_cgroup(pc, pfn + index);
 	}
 
-	section = __pfn_to_section(pfn);
 	section->page_cgroup = base - pfn;
 	total_usage += table_size;
 	return 0;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] memcg: do not recalculate section unnecessarily in init_section_page_cgroup
  2008-10-30  4:38 [PATCH] memcg: do not recalculate section unnecessarily in init_section_page_cgroup Fernando Luis Vázquez Cao
@ 2008-10-30  6:45 ` KAMEZAWA Hiroyuki
  2008-10-30  7:06   ` Fernando Luis Vázquez Cao
  0 siblings, 1 reply; 3+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-10-30  6:45 UTC (permalink / raw)
  To: Fernando Luis Vázquez Cao; +Cc: akpm, linux-kernel

On Thu, 30 Oct 2008 13:38:50 +0900
Fernando Luis Vázquez Cao <fernando@oss.ntt.co.jp> wrote:

> Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
> ---
> 
Thanks, but please add patch description "what this patch fixes".
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


> diff -urNp linux-2.6.28-rc2-mm1-orig/mm/page_cgroup.c linux-2.6.28-rc2-mm1/mm/page_cgroup.c
> --- linux-2.6.28-rc2-mm1-orig/mm/page_cgroup.c	2008-10-30 12:49:27.000000000 +0900
> +++ linux-2.6.28-rc2-mm1/mm/page_cgroup.c	2008-10-30 12:52:41.000000000 +0900
> @@ -99,13 +99,11 @@ struct page_cgroup *lookup_page_cgroup(s
>  
>  int __meminit init_section_page_cgroup(unsigned long pfn)
>  {
> -	struct mem_section *section;
> +	struct mem_section *section = __pfn_to_section(pfn);
>  	struct page_cgroup *base, *pc;
>  	unsigned long table_size;
>  	int nid, index;
>  
> -	section = __pfn_to_section(pfn);
> -
>  	if (section->page_cgroup)
>  		return 0;
>  
> @@ -131,7 +129,6 @@ int __meminit init_section_page_cgroup(u
>  		__init_page_cgroup(pc, pfn + index);
>  	}
>  
> -	section = __pfn_to_section(pfn);
>  	section->page_cgroup = base - pfn;
>  	total_usage += table_size;
>  	return 0;
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] memcg: do not recalculate section unnecessarily in init_section_page_cgroup
  2008-10-30  6:45 ` KAMEZAWA Hiroyuki
@ 2008-10-30  7:06   ` Fernando Luis Vázquez Cao
  0 siblings, 0 replies; 3+ messages in thread
From: Fernando Luis Vázquez Cao @ 2008-10-30  7:06 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: akpm, linux-kernel

In init_section_page_cgroup() the section a given pfn belongs to is
calculated at the top of the function and, despite the fact that the
pfn/section correspondence does not change, it is recalculated further
down the same function. By computing this just once and reusing that
value we save some bytes in the object file and do not waste CPU cycles.

Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---

diff -urNp linux-2.6.28-rc2-mm1-orig/mm/page_cgroup.c linux-2.6.28-rc2-mm1/mm/page_cgroup.c
--- linux-2.6.28-rc2-mm1-orig/mm/page_cgroup.c	2008-10-30 12:49:27.000000000 +0900
+++ linux-2.6.28-rc2-mm1/mm/page_cgroup.c	2008-10-30 12:52:41.000000000 +0900
@@ -99,13 +99,11 @@ struct page_cgroup *lookup_page_cgroup(s
 
 int __meminit init_section_page_cgroup(unsigned long pfn)
 {
-	struct mem_section *section;
+	struct mem_section *section = __pfn_to_section(pfn);
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	int nid, index;
 
-	section = __pfn_to_section(pfn);
-
 	if (section->page_cgroup)
 		return 0;
 
@@ -131,7 +129,6 @@ int __meminit init_section_page_cgroup(u
 		__init_page_cgroup(pc, pfn + index);
 	}
 
-	section = __pfn_to_section(pfn);
 	section->page_cgroup = base - pfn;
 	total_usage += table_size;
 	return 0;



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-30  7:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-30  4:38 [PATCH] memcg: do not recalculate section unnecessarily in init_section_page_cgroup Fernando Luis Vázquez Cao
2008-10-30  6:45 ` KAMEZAWA Hiroyuki
2008-10-30  7:06   ` Fernando Luis Vázquez Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).