Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: add link from struct lruvec to struct zone

This is the first stage of struct mem_cgroup_zone removal. Further
patches replace struct mem_cgroup_zone with a pointer to struct lruvec.

If CONFIG_CGROUP_MEM_RES_CTLR=n lruvec_zone() is just container_of().

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Konstantin Khlebnikov and committed by
Linus Torvalds
7f5e86c2 9e3b2f8c

+30 -10
+14
include/linux/mmzone.h
··· 201 201 struct lruvec { 202 202 struct list_head lists[NR_LRU_LISTS]; 203 203 struct zone_reclaim_stat reclaim_stat; 204 + #ifdef CONFIG_CGROUP_MEM_RES_CTLR 205 + struct zone *zone; 206 + #endif 204 207 }; 205 208 206 209 /* Mask used at gathering information at once (see memcontrol.c) */ ··· 731 728 extern int init_currently_empty_zone(struct zone *zone, unsigned long start_pfn, 732 729 unsigned long size, 733 730 enum memmap_context context); 731 + 732 + extern void lruvec_init(struct lruvec *lruvec, struct zone *zone); 733 + 734 + static inline struct zone *lruvec_zone(struct lruvec *lruvec) 735 + { 736 + #ifdef CONFIG_CGROUP_MEM_RES_CTLR 737 + return lruvec->zone; 738 + #else 739 + return container_of(lruvec, struct zone, lruvec); 740 + #endif 741 + } 734 742 735 743 #ifdef CONFIG_HAVE_MEMORY_PRESENT 736 744 void memory_present(int nid, unsigned long start, unsigned long end);
+1 -3
mm/memcontrol.c
··· 4738 4738 { 4739 4739 struct mem_cgroup_per_node *pn; 4740 4740 struct mem_cgroup_per_zone *mz; 4741 - enum lru_list lru; 4742 4741 int zone, tmp = node; 4743 4742 /* 4744 4743 * This routine is called against possible nodes. ··· 4755 4756 4756 4757 for (zone = 0; zone < MAX_NR_ZONES; zone++) { 4757 4758 mz = &pn->zoneinfo[zone]; 4758 - for_each_lru(lru) 4759 - INIT_LIST_HEAD(&mz->lruvec.lists[lru]); 4759 + lruvec_init(&mz->lruvec, &NODE_DATA(node)->node_zones[zone]); 4760 4760 mz->usage_in_excess = 0; 4761 4761 mz->on_tree = false; 4762 4762 mz->memcg = memcg;
+14
mm/mmzone.c
··· 86 86 return 1; 87 87 } 88 88 #endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */ 89 + 90 + void lruvec_init(struct lruvec *lruvec, struct zone *zone) 91 + { 92 + enum lru_list lru; 93 + 94 + memset(lruvec, 0, sizeof(struct lruvec)); 95 + 96 + for_each_lru(lru) 97 + INIT_LIST_HEAD(&lruvec->lists[lru]); 98 + 99 + #ifdef CONFIG_CGROUP_MEM_RES_CTLR 100 + lruvec->zone = zone; 101 + #endif 102 + }
+1 -7
mm/page_alloc.c
··· 4358 4358 for (j = 0; j < MAX_NR_ZONES; j++) { 4359 4359 struct zone *zone = pgdat->node_zones + j; 4360 4360 unsigned long size, realsize, memmap_pages; 4361 - enum lru_list lru; 4362 4361 4363 4362 size = zone_spanned_pages_in_node(nid, j, zones_size); 4364 4363 realsize = size - zone_absent_pages_in_node(nid, j, ··· 4407 4408 zone->zone_pgdat = pgdat; 4408 4409 4409 4410 zone_pcp_init(zone); 4410 - for_each_lru(lru) 4411 - INIT_LIST_HEAD(&zone->lruvec.lists[lru]); 4412 - zone->lruvec.reclaim_stat.recent_rotated[0] = 0; 4413 - zone->lruvec.reclaim_stat.recent_rotated[1] = 0; 4414 - zone->lruvec.reclaim_stat.recent_scanned[0] = 0; 4415 - zone->lruvec.reclaim_stat.recent_scanned[1] = 0; 4411 + lruvec_init(&zone->lruvec, zone); 4416 4412 zap_zone_vm_stats(zone); 4417 4413 zone->flags = 0; 4418 4414 if (!size)