Commit ebc5d83d authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov Committed by Linus Torvalds

mm/memcontrol: use vmstat names for printing statistics

Use common names from vmstat array when possible.  This gives not much
difference in code size for now, but should help in keeping interfaces
consistent.

  add/remove: 0/2 grow/shrink: 2/0 up/down: 70/-72 (-2)
  Function                                     old     new   delta
  memory_stat_format                           984    1050     +66
  memcg_stat_show                              957     961      +4
  memcg1_event_names                            32       -     -32
  mem_cgroup_lru_names                          40       -     -40
  Total: Before=14485337, After=14485335, chg -0.00%

Link: http://lkml.kernel.org/r/157113012508.453.80391533767219371.stgit@buzzSigned-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9d7ea9a2
...@@ -420,7 +420,7 @@ static inline const char *writeback_stat_name(enum writeback_stat_item item) ...@@ -420,7 +420,7 @@ static inline const char *writeback_stat_name(enum writeback_stat_item item)
item]; item];
} }
#ifdef CONFIG_VM_EVENT_COUNTERS #if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
static inline const char *vm_event_name(enum vm_event_item item) static inline const char *vm_event_name(enum vm_event_item item)
{ {
return vmstat_text[NR_VM_ZONE_STAT_ITEMS + return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
...@@ -429,6 +429,6 @@ static inline const char *vm_event_name(enum vm_event_item item) ...@@ -429,6 +429,6 @@ static inline const char *vm_event_name(enum vm_event_item item)
NR_VM_WRITEBACK_STAT_ITEMS + NR_VM_WRITEBACK_STAT_ITEMS +
item]; item];
} }
#endif /* CONFIG_VM_EVENT_COUNTERS */ #endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
#endif /* _LINUX_VMSTAT_H */ #endif /* _LINUX_VMSTAT_H */
...@@ -98,14 +98,6 @@ static bool do_memsw_account(void) ...@@ -98,14 +98,6 @@ static bool do_memsw_account(void)
return !cgroup_subsys_on_dfl(memory_cgrp_subsys) && do_swap_account; return !cgroup_subsys_on_dfl(memory_cgrp_subsys) && do_swap_account;
} }
static const char *const mem_cgroup_lru_names[] = {
"inactive_anon",
"active_anon",
"inactive_file",
"active_file",
"unevictable",
};
#define THRESHOLDS_EVENTS_TARGET 128 #define THRESHOLDS_EVENTS_TARGET 128
#define SOFTLIMIT_EVENTS_TARGET 1024 #define SOFTLIMIT_EVENTS_TARGET 1024
...@@ -1421,7 +1413,7 @@ static char *memory_stat_format(struct mem_cgroup *memcg) ...@@ -1421,7 +1413,7 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
PAGE_SIZE); PAGE_SIZE);
for (i = 0; i < NR_LRU_LISTS; i++) for (i = 0; i < NR_LRU_LISTS; i++)
seq_buf_printf(&s, "%s %llu\n", mem_cgroup_lru_names[i], seq_buf_printf(&s, "%s %llu\n", lru_list_name(i),
(u64)memcg_page_state(memcg, NR_LRU_BASE + i) * (u64)memcg_page_state(memcg, NR_LRU_BASE + i) *
PAGE_SIZE); PAGE_SIZE);
...@@ -1434,8 +1426,10 @@ static char *memory_stat_format(struct mem_cgroup *memcg) ...@@ -1434,8 +1426,10 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
/* Accumulated memory events */ /* Accumulated memory events */
seq_buf_printf(&s, "pgfault %lu\n", memcg_events(memcg, PGFAULT)); seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGFAULT),
seq_buf_printf(&s, "pgmajfault %lu\n", memcg_events(memcg, PGMAJFAULT)); memcg_events(memcg, PGFAULT));
seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGMAJFAULT),
memcg_events(memcg, PGMAJFAULT));
seq_buf_printf(&s, "workingset_refault %lu\n", seq_buf_printf(&s, "workingset_refault %lu\n",
memcg_page_state(memcg, WORKINGSET_REFAULT)); memcg_page_state(memcg, WORKINGSET_REFAULT));
...@@ -1444,22 +1438,27 @@ static char *memory_stat_format(struct mem_cgroup *memcg) ...@@ -1444,22 +1438,27 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
seq_buf_printf(&s, "workingset_nodereclaim %lu\n", seq_buf_printf(&s, "workingset_nodereclaim %lu\n",
memcg_page_state(memcg, WORKINGSET_NODERECLAIM)); memcg_page_state(memcg, WORKINGSET_NODERECLAIM));
seq_buf_printf(&s, "pgrefill %lu\n", memcg_events(memcg, PGREFILL)); seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGREFILL),
memcg_events(memcg, PGREFILL));
seq_buf_printf(&s, "pgscan %lu\n", seq_buf_printf(&s, "pgscan %lu\n",
memcg_events(memcg, PGSCAN_KSWAPD) + memcg_events(memcg, PGSCAN_KSWAPD) +
memcg_events(memcg, PGSCAN_DIRECT)); memcg_events(memcg, PGSCAN_DIRECT));
seq_buf_printf(&s, "pgsteal %lu\n", seq_buf_printf(&s, "pgsteal %lu\n",
memcg_events(memcg, PGSTEAL_KSWAPD) + memcg_events(memcg, PGSTEAL_KSWAPD) +
memcg_events(memcg, PGSTEAL_DIRECT)); memcg_events(memcg, PGSTEAL_DIRECT));
seq_buf_printf(&s, "pgactivate %lu\n", memcg_events(memcg, PGACTIVATE)); seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGACTIVATE),
seq_buf_printf(&s, "pgdeactivate %lu\n", memcg_events(memcg, PGDEACTIVATE)); memcg_events(memcg, PGACTIVATE));
seq_buf_printf(&s, "pglazyfree %lu\n", memcg_events(memcg, PGLAZYFREE)); seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGDEACTIVATE),
seq_buf_printf(&s, "pglazyfreed %lu\n", memcg_events(memcg, PGLAZYFREED)); memcg_events(memcg, PGDEACTIVATE));
seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGLAZYFREE),
memcg_events(memcg, PGLAZYFREE));
seq_buf_printf(&s, "%s %lu\n", vm_event_name(PGLAZYFREED),
memcg_events(memcg, PGLAZYFREED));
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
seq_buf_printf(&s, "thp_fault_alloc %lu\n", seq_buf_printf(&s, "%s %lu\n", vm_event_name(THP_FAULT_ALLOC),
memcg_events(memcg, THP_FAULT_ALLOC)); memcg_events(memcg, THP_FAULT_ALLOC));
seq_buf_printf(&s, "thp_collapse_alloc %lu\n", seq_buf_printf(&s, "%s %lu\n", vm_event_name(THP_COLLAPSE_ALLOC),
memcg_events(memcg, THP_COLLAPSE_ALLOC)); memcg_events(memcg, THP_COLLAPSE_ALLOC));
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
...@@ -3742,13 +3741,6 @@ static const unsigned int memcg1_events[] = { ...@@ -3742,13 +3741,6 @@ static const unsigned int memcg1_events[] = {
PGMAJFAULT, PGMAJFAULT,
}; };
static const char *const memcg1_event_names[] = {
"pgpgin",
"pgpgout",
"pgfault",
"pgmajfault",
};
static int memcg_stat_show(struct seq_file *m, void *v) static int memcg_stat_show(struct seq_file *m, void *v)
{ {
struct mem_cgroup *memcg = mem_cgroup_from_seq(m); struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
...@@ -3757,7 +3749,6 @@ static int memcg_stat_show(struct seq_file *m, void *v) ...@@ -3757,7 +3749,6 @@ static int memcg_stat_show(struct seq_file *m, void *v)
unsigned int i; unsigned int i;
BUILD_BUG_ON(ARRAY_SIZE(memcg1_stat_names) != ARRAY_SIZE(memcg1_stats)); BUILD_BUG_ON(ARRAY_SIZE(memcg1_stat_names) != ARRAY_SIZE(memcg1_stats));
BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) { for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) {
if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
...@@ -3768,11 +3759,11 @@ static int memcg_stat_show(struct seq_file *m, void *v) ...@@ -3768,11 +3759,11 @@ static int memcg_stat_show(struct seq_file *m, void *v)
} }
for (i = 0; i < ARRAY_SIZE(memcg1_events); i++) for (i = 0; i < ARRAY_SIZE(memcg1_events); i++)
seq_printf(m, "%s %lu\n", memcg1_event_names[i], seq_printf(m, "%s %lu\n", vm_event_name(memcg1_events[i]),
memcg_events_local(memcg, memcg1_events[i])); memcg_events_local(memcg, memcg1_events[i]));
for (i = 0; i < NR_LRU_LISTS; i++) for (i = 0; i < NR_LRU_LISTS; i++)
seq_printf(m, "%s %lu\n", mem_cgroup_lru_names[i], seq_printf(m, "%s %lu\n", lru_list_name(i),
memcg_page_state_local(memcg, NR_LRU_BASE + i) * memcg_page_state_local(memcg, NR_LRU_BASE + i) *
PAGE_SIZE); PAGE_SIZE);
...@@ -3797,11 +3788,12 @@ static int memcg_stat_show(struct seq_file *m, void *v) ...@@ -3797,11 +3788,12 @@ static int memcg_stat_show(struct seq_file *m, void *v)
} }
for (i = 0; i < ARRAY_SIZE(memcg1_events); i++) for (i = 0; i < ARRAY_SIZE(memcg1_events); i++)
seq_printf(m, "total_%s %llu\n", memcg1_event_names[i], seq_printf(m, "total_%s %llu\n",
vm_event_name(memcg1_events[i]),
(u64)memcg_events(memcg, memcg1_events[i])); (u64)memcg_events(memcg, memcg1_events[i]));
for (i = 0; i < NR_LRU_LISTS; i++) for (i = 0; i < NR_LRU_LISTS; i++)
seq_printf(m, "total_%s %llu\n", mem_cgroup_lru_names[i], seq_printf(m, "total_%s %llu\n", lru_list_name(i),
(u64)memcg_page_state(memcg, NR_LRU_BASE + i) * (u64)memcg_page_state(memcg, NR_LRU_BASE + i) *
PAGE_SIZE); PAGE_SIZE);
......
...@@ -1084,7 +1084,8 @@ int fragmentation_index(struct zone *zone, unsigned int order) ...@@ -1084,7 +1084,8 @@ int fragmentation_index(struct zone *zone, unsigned int order)
} }
#endif #endif
#if defined(CONFIG_PROC_FS) || defined(CONFIG_SYSFS) || defined(CONFIG_NUMA) #if defined(CONFIG_PROC_FS) || defined(CONFIG_SYSFS) || \
defined(CONFIG_NUMA) || defined(CONFIG_MEMCG)
#ifdef CONFIG_ZONE_DMA #ifdef CONFIG_ZONE_DMA
#define TEXT_FOR_DMA(xx) xx "_dma", #define TEXT_FOR_DMA(xx) xx "_dma",
#else #else
...@@ -1172,7 +1173,7 @@ const char * const vmstat_text[] = { ...@@ -1172,7 +1173,7 @@ const char * const vmstat_text[] = {
"nr_dirty_threshold", "nr_dirty_threshold",
"nr_dirty_background_threshold", "nr_dirty_background_threshold",
#ifdef CONFIG_VM_EVENT_COUNTERS #if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
/* enum vm_event_item counters */ /* enum vm_event_item counters */
"pgpgin", "pgpgin",
"pgpgout", "pgpgout",
...@@ -1291,9 +1292,9 @@ const char * const vmstat_text[] = { ...@@ -1291,9 +1292,9 @@ const char * const vmstat_text[] = {
"swap_ra", "swap_ra",
"swap_ra_hit", "swap_ra_hit",
#endif #endif
#endif /* CONFIG_VM_EVENTS_COUNTERS */ #endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
}; };
#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */ #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
#if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)) || \ #if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)) || \
defined(CONFIG_PROC_FS) defined(CONFIG_PROC_FS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment