diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 26e63f6ccb3d5b6b71cfa0191a07412d2719cdfe..cda72de5fe8c7ded7f7ceb3241c3bdd3e8be2870 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -935,10 +935,6 @@ static inline bool is_wmark_ok(struct mem_cgroup *memcg, bool high) int memcg_get_wmark_min_adj(struct task_struct *curr); void memcg_check_wmark_min_adj(struct task_struct *curr, struct alloc_context *ac); - -extern void memcg_lat_stat_update(enum mem_lat_stat_item sidx, u64 duration); -extern void memcg_lat_stat_start(u64 *start); -extern u64 memcg_lat_stat_end(u64 start); #else /* CONFIG_MEMCG */ #define MEM_CGROUP_ID_SHIFT 0 @@ -1289,7 +1285,13 @@ static inline void memcg_check_wmark_min_adj(struct task_struct *curr, struct alloc_context *ac) { } +#endif /* CONFIG_MEMCG */ +#ifdef CONFIG_MEMSLI +extern void memcg_lat_stat_update(enum mem_lat_stat_item sidx, u64 duration); +extern void memcg_lat_stat_start(u64 *start); +extern u64 memcg_lat_stat_end(u64 start); +#else static inline void memcg_lat_stat_update(enum mem_lat_stat_item sidx, u64 duration) { @@ -1303,7 +1305,7 @@ static inline u64 memcg_lat_stat_end(u64 start) { return 0; } -#endif /* CONFIG_MEMCG */ +#endif /* CONFIG_MEMSLI */ /* idx can be of type enum memcg_stat_item or node_stat_item */ static inline void __inc_memcg_state(struct mem_cgroup *memcg, diff --git a/mm/Kconfig b/mm/Kconfig index cc79c4ef55df6fc382a1baf54113680e0c0955d0..f2446bfcfd0300078a2166915d02bfaf865d6f2e 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -786,4 +786,13 @@ config KIDLED See Documentation/vm/kidled.rst for more details. +config MEMSLI + bool "Support memory latency histogram, a.k.a, memsli" + depends on MEMCG + default Y + help + This probes and calculates various kinds of memory latency, and then + groups into the corresponding latency histogram in every memory + cgroup, respectively. + endmenu diff --git a/mm/memcontrol.c b/mm/memcontrol.c index f11f4ebc12b638467f9f8c06273e1e9d18ba7bea..41a19e6506cba3eacd8611ce918ece969bfdfad0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4523,6 +4523,7 @@ void memcg_check_wmark_min_adj(struct task_struct *curr, } } +#ifdef CONFIG_MEMSLI #define MEMCG_LAT_STAT_SMP_WRITE(name, sidx) \ static void smp_write_##name(void *info) \ { \ @@ -4663,6 +4664,7 @@ u64 memcg_lat_stat_end(u64 start) else return 0; } +#endif /* CONFIG_MEMSLI */ static void __mem_cgroup_threshold(struct mem_cgroup *memcg, bool swap) { @@ -5563,6 +5565,7 @@ static struct cftype mem_cgroup_legacy_files[] = { .seq_show = memory_wmark_min_adj_show, .write = memory_wmark_min_adj_write, }, +#ifdef CONFIG_MEMSLI { .name = "direct_reclaim_global_latency", .private = MEM_LAT_GLOBAL_DIRECT_RECLAIM, @@ -5599,6 +5602,7 @@ static struct cftype mem_cgroup_legacy_files[] = { .write_u64 = memcg_lat_stat_write, .seq_show = memcg_lat_stat_show, }, +#endif /* CONFIG_MEMSLI */ { .name = "force_empty", .write = mem_cgroup_force_empty_write, @@ -7777,6 +7781,7 @@ static int __init enable_cgroup_writeback_v1(char *s) __setup("cgwb_v1", enable_cgroup_writeback_v1); #endif +#ifdef CONFIG_MEMSLI static int memsli_enabled_show(struct seq_file *m, void *v) { seq_printf(m, "%d\n", !static_key_enabled(&cgroup_memory_nosli)); @@ -7826,6 +7831,7 @@ static const struct file_operations memsli_enabled_fops = { .llseek = seq_lseek, .release = single_release, }; +#endif /* CONFIG_MEMSLI */ /* * subsys_initcall() for memory controller. @@ -7847,6 +7853,7 @@ static int __init mem_cgroup_init(void) if (!memcg_wmark_wq) return -ENOMEM; +#ifdef CONFIG_MEMSLI memsli_dir = proc_mkdir("memsli", NULL); if (!memsli_dir) return -ENOMEM; @@ -7857,6 +7864,7 @@ static int __init mem_cgroup_init(void) remove_proc_entry("memsli", NULL); return -ENOMEM; } +#endif /* CONFIG_MEMSLI */ #ifdef CONFIG_MEMCG_KMEM /*