Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0753b0ef authored by Fernando Luis Vazquez Cao's avatar Fernando Luis Vazquez Cao Committed by Linus Torvalds
Browse files

memcg: do not recalculate section unnecessarily in init_section_page_cgroup



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: default avatarFernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 01b1ae63
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -103,13 +103,11 @@ struct page_cgroup *lookup_page_cgroup(struct page *page)
/* __alloc_bootmem...() is protected by !slab_available() */
/* __alloc_bootmem...() is protected by !slab_available() */
static int __init_refok init_section_page_cgroup(unsigned long pfn)
static int __init_refok init_section_page_cgroup(unsigned long pfn)
{
{
	struct mem_section *section;
	struct mem_section *section = __pfn_to_section(pfn);
	struct page_cgroup *base, *pc;
	struct page_cgroup *base, *pc;
	unsigned long table_size;
	unsigned long table_size;
	int nid, index;
	int nid, index;


	section = __pfn_to_section(pfn);

	if (!section->page_cgroup) {
	if (!section->page_cgroup) {
		nid = page_to_nid(pfn_to_page(pfn));
		nid = page_to_nid(pfn_to_page(pfn));
		table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
		table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
@@ -145,7 +143,6 @@ static int __init_refok init_section_page_cgroup(unsigned long pfn)
		__init_page_cgroup(pc, pfn + index);
		__init_page_cgroup(pc, pfn + index);
	}
	}


	section = __pfn_to_section(pfn);
	section->page_cgroup = base - pfn;
	section->page_cgroup = base - pfn;
	total_usage += table_size;
	total_usage += table_size;
	return 0;
	return 0;