Commit eefe54b2 authored by Liu Shixin's avatar Liu Shixin
Browse files

memcg: introduce memcg swap qos feature

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I7CGGT


CVE: NA

--------------------------------

Introduce memcg swap qos including subsequent sub-features.
Add CONFIG_MEMCG_SWAP_QOS and static key memcg_swap_qos_key.

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent 0f6acee1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -424,6 +424,10 @@ extern int sysctl_memcg_qos_handler(struct ctl_table *table,
void memcg_print_bad_task(struct oom_control *oc);
#endif

#ifdef CONFIG_MEMCG_SWAP_QOS
DECLARE_STATIC_KEY_FALSE(memcg_swap_qos_key);
#endif

/*
 * size of first charge trial. "32" comes from vmscan.c's magic value.
 * TODO: maybe necessary to use big numbers in big irons.
+9 −0
Original line number Diff line number Diff line
@@ -512,6 +512,15 @@ config MEMCG_QOS

	  If unsure, say "n".

config MEMCG_SWAP_QOS
	bool "Enable Memory Cgroup Swap Control"
	depends on MEMCG_SWAP
	depends on X86 || ARM64
	default n
	help
	  memcg swap control include memory force swapin, swapfile control
	  and swap limit.

config ETMEM_SCAN
	tristate "module: etmem page scan for etmem support"
	depends on ETMEM
+53 −0
Original line number Diff line number Diff line
@@ -4055,6 +4055,59 @@ void memcg_print_bad_task(struct oom_control *oc)

#endif

#ifdef CONFIG_MEMCG_SWAP_QOS
DEFINE_STATIC_KEY_FALSE(memcg_swap_qos_key);

#ifdef CONFIG_SYSCTL
static int sysctl_memcg_swap_qos_stat;

static void memcg_swap_qos_reset(void)
{
}

static int sysctl_memcg_swap_qos_handler(struct ctl_table *table, int write,
			void __user *buffer, size_t *length, loff_t *ppos)
{
	int ret;

	ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
	if (ret)
		return ret;
	if (write) {
		if (sysctl_memcg_swap_qos_stat) {
			memcg_swap_qos_reset();
			static_branch_enable(&memcg_swap_qos_key);
		} else {
			static_branch_disable(&memcg_swap_qos_key);
		}
	}
	return 0;
}

static struct ctl_table memcg_swap_qos_sysctls[] = {
	{
		.procname	= "memcg_swap_qos_enable",
		.data		= &sysctl_memcg_swap_qos_stat,
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.proc_handler	= sysctl_memcg_swap_qos_handler,
		.extra1		= SYSCTL_ZERO,
		.extra2		= SYSCTL_ONE,
	},
	{ }
};

static __init int memcg_swap_qos_sysctls_init(void)
{
	if (mem_cgroup_disabled() || cgroup_memory_noswap)
		return 0;
	register_sysctl_init("vm", memcg_swap_qos_sysctls);
	return 0;
}
late_initcall(memcg_swap_qos_sysctls_init);
#endif
#endif

#ifdef CONFIG_NUMA

#define LRU_ALL_FILE (BIT(LRU_INACTIVE_FILE) | BIT(LRU_ACTIVE_FILE))