Skip to content

Commit 385386c

Browse files
hnaztorvalds
authored andcommitted
mm: vmstat: move slab statistics from zone to node counters
Patch series "mm: per-lruvec slab stats" Josef is working on a new approach to balancing slab caches and the page cache. For this to work, he needs slab cache statistics on the lruvec level. These patches implement that by adding infrastructure that allows updating and reading generic VM stat items per lruvec, then switches some existing VM accounting sites, including the slab accounting ones, to this new cgroup-aware API. I'll follow up with more patches on this, because there is actually substantial simplification that can be done to the memory controller when we replace private memcg accounting with making the existing VM accounting sites cgroup-aware. But this is enough for Josef to base his slab reclaim work on, so here goes. This patch (of 5): To re-implement slab cache vs. page cache balancing, we'll need the slab counters at the lruvec level, which, ever since lru reclaim was moved from the zone to the node, is the intersection of the node, not the zone, and the memcg. We could retain the per-zone counters for when the page allocator dumps its memory information on failures, and have counters on both levels - which on all but NUMA node 0 is usually redundant. But let's keep it simple for now and just move them. If anybody complains we can restore the per-zone counters. [hannes@cmpxchg.org: fix oops] Link: http://lkml.kernel.org/r/20170605183511.GA8915@cmpxchg.org Link: http://lkml.kernel.org/r/20170530181724.27197-3-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Josef Bacik <josef@toxicpanda.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2b2695f commit 385386c

7 files changed

Lines changed: 19 additions & 20 deletions

File tree

‎drivers/base/node.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,19 @@ static ssize_t node_read_meminfo(struct device *dev,
129129
nid, K(node_page_state(pgdat, NR_UNSTABLE_NFS)),
130130
nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)),
131131
nid, K(node_page_state(pgdat, NR_WRITEBACK_TEMP)),
132-
nid, K(sum_zone_node_page_state(nid, NR_SLAB_RECLAIMABLE) +
133-
sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)),
134-
nid, K(sum_zone_node_page_state(nid, NR_SLAB_RECLAIMABLE)),
132+
nid, K(node_page_state(pgdat, NR_SLAB_RECLAIMABLE) +
133+
node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE)),
134+
nid, K(node_page_state(pgdat, NR_SLAB_RECLAIMABLE)),
135135
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
136-
nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)),
136+
nid, K(node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE)),
137137
nid, K(node_page_state(pgdat, NR_ANON_THPS) *
138138
HPAGE_PMD_NR),
139139
nid, K(node_page_state(pgdat, NR_SHMEM_THPS) *
140140
HPAGE_PMD_NR),
141141
nid, K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) *
142142
HPAGE_PMD_NR));
143143
#else
144-
nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)));
144+
nid, K(node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE)));
145145
#endif
146146
n += hugetlb_report_node_meminfo(nid, buf + n);
147147
return n;

‎include/linux/mmzone.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ enum zone_stat_item {
125125
NR_ZONE_UNEVICTABLE,
126126
NR_ZONE_WRITE_PENDING, /* Count of dirty, writeback and unstable pages */
127127
NR_MLOCK, /* mlock()ed pages found and moved off LRU */
128-
NR_SLAB_RECLAIMABLE,
129-
NR_SLAB_UNRECLAIMABLE,
130128
NR_PAGETABLE, /* used for pagetables */
131129
NR_KERNEL_STACK_KB, /* measured in KiB */
132130
/* Second 128 byte cacheline */
@@ -152,6 +150,8 @@ enum node_stat_item {
152150
NR_INACTIVE_FILE, /* " " " " " */
153151
NR_ACTIVE_FILE, /* " " " " " */
154152
NR_UNEVICTABLE, /* " " " " " */
153+
NR_SLAB_RECLAIMABLE,
154+
NR_SLAB_UNRECLAIMABLE,
155155
NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */
156156
NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */
157157
WORKINGSET_REFAULT,

‎mm/page_alloc.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4643,8 +4643,6 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
46434643
" present:%lukB"
46444644
" managed:%lukB"
46454645
" mlocked:%lukB"
4646-
" slab_reclaimable:%lukB"
4647-
" slab_unreclaimable:%lukB"
46484646
" kernel_stack:%lukB"
46494647
" pagetables:%lukB"
46504648
" bounce:%lukB"
@@ -4666,8 +4664,6 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
46664664
K(zone->present_pages),
46674665
K(zone->managed_pages),
46684666
K(zone_page_state(zone, NR_MLOCK)),
4669-
K(zone_page_state(zone, NR_SLAB_RECLAIMABLE)),
4670-
K(zone_page_state(zone, NR_SLAB_UNRECLAIMABLE)),
46714667
zone_page_state(zone, NR_KERNEL_STACK_KB),
46724668
K(zone_page_state(zone, NR_PAGETABLE)),
46734669
K(zone_page_state(zone, NR_BOUNCE)),
@@ -5153,6 +5149,7 @@ static void build_zonelists(pg_data_t *pgdat)
51535149
*/
51545150
static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch);
51555151
static DEFINE_PER_CPU(struct per_cpu_pageset, boot_pageset);
5152+
static DEFINE_PER_CPU(struct per_cpu_nodestat, boot_nodestats);
51565153
static void setup_zone_pageset(struct zone *zone);
51575154

51585155
/*
@@ -6053,6 +6050,8 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)
60536050
spin_lock_init(&pgdat->lru_lock);
60546051
lruvec_init(node_lruvec(pgdat));
60556052

6053+
pgdat->per_cpu_nodestats = &boot_nodestats;
6054+
60566055
for (j = 0; j < MAX_NR_ZONES; j++) {
60576056
struct zone *zone = pgdat->node_zones + j;
60586057
unsigned long size, realsize, freesize, memmap_pages;

‎mm/slab.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,10 +1425,10 @@ static struct page *kmem_getpages(struct kmem_cache *cachep, gfp_t flags,
14251425

14261426
nr_pages = (1 << cachep->gfporder);
14271427
if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
1428-
add_zone_page_state(page_zone(page),
1428+
add_node_page_state(page_pgdat(page),
14291429
NR_SLAB_RECLAIMABLE, nr_pages);
14301430
else
1431-
add_zone_page_state(page_zone(page),
1431+
add_node_page_state(page_pgdat(page),
14321432
NR_SLAB_UNRECLAIMABLE, nr_pages);
14331433

14341434
__SetPageSlab(page);
@@ -1459,10 +1459,10 @@ static void kmem_freepages(struct kmem_cache *cachep, struct page *page)
14591459
kmemcheck_free_shadow(page, order);
14601460

14611461
if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
1462-
sub_zone_page_state(page_zone(page),
1462+
sub_node_page_state(page_pgdat(page),
14631463
NR_SLAB_RECLAIMABLE, nr_freed);
14641464
else
1465-
sub_zone_page_state(page_zone(page),
1465+
sub_node_page_state(page_pgdat(page),
14661466
NR_SLAB_UNRECLAIMABLE, nr_freed);
14671467

14681468
BUG_ON(!PageSlab(page));

‎mm/slub.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
16151615
if (!page)
16161616
return NULL;
16171617

1618-
mod_zone_page_state(page_zone(page),
1618+
mod_node_page_state(page_pgdat(page),
16191619
(s->flags & SLAB_RECLAIM_ACCOUNT) ?
16201620
NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
16211621
1 << oo_order(oo));
@@ -1655,7 +1655,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
16551655

16561656
kmemcheck_free_shadow(page, compound_order(page));
16571657

1658-
mod_zone_page_state(page_zone(page),
1658+
mod_node_page_state(page_pgdat(page),
16591659
(s->flags & SLAB_RECLAIM_ACCOUNT) ?
16601660
NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
16611661
-pages);

‎mm/vmscan.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3874,7 +3874,7 @@ int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order)
38743874
* unmapped file backed pages.
38753875
*/
38763876
if (node_pagecache_reclaimable(pgdat) <= pgdat->min_unmapped_pages &&
3877-
sum_zone_node_page_state(pgdat->node_id, NR_SLAB_RECLAIMABLE) <= pgdat->min_slab_pages)
3877+
node_page_state(pgdat, NR_SLAB_RECLAIMABLE) <= pgdat->min_slab_pages)
38783878
return NODE_RECLAIM_FULL;
38793879

38803880
/*

‎mm/vmstat.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,6 @@ const char * const vmstat_text[] = {
928928
"nr_zone_unevictable",
929929
"nr_zone_write_pending",
930930
"nr_mlock",
931-
"nr_slab_reclaimable",
932-
"nr_slab_unreclaimable",
933931
"nr_page_table_pages",
934932
"nr_kernel_stack",
935933
"nr_bounce",
@@ -952,6 +950,8 @@ const char * const vmstat_text[] = {
952950
"nr_inactive_file",
953951
"nr_active_file",
954952
"nr_unevictable",
953+
"nr_slab_reclaimable",
954+
"nr_slab_unreclaimable",
955955
"nr_isolated_anon",
956956
"nr_isolated_file",
957957
"workingset_refault",

0 commit comments

Comments
 (0)