Commit 65b18684 authored by Liu Shixin's avatar Liu Shixin Committed by Jinjiang Tu
Browse files

memcg: introduce memcg swap qos feature

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


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>
Signed-off-by: default avatarJinjiang Tu <tujinjiang@huawei.com>
parent 74b93d07
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -367,6 +367,10 @@ static inline void memcg_print_bad_task(struct oom_control *oc)
}
}
#endif
#endif


#ifdef CONFIG_MEMCG_SWAP_QOS
DECLARE_STATIC_KEY_FALSE(memcg_swap_qos_key);
#endif

/*
/*
 * size of first charge trial.
 * size of first charge trial.
 * TODO: maybe necessary to use big numbers in big irons or dynamic based of the
 * TODO: maybe necessary to use big numbers in big irons or dynamic based of the
+9 −0
Original line number Original line Diff line number Diff line
@@ -973,6 +973,15 @@ config MEMCG_OOM_PRIORITY


	  If unsure, say "n".
	  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 MEMCG_KMEM
config MEMCG_KMEM
	bool
	bool
	depends on MEMCG
	depends on MEMCG
+48 −0
Original line number Original line Diff line number Diff line
@@ -4236,6 +4236,43 @@ static int sysctl_memcg_oom_prio_handler(struct ctl_table *table, int write,
#endif
#endif
#endif
#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;
	int qos_stat_old = sysctl_memcg_swap_qos_stat;

	ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
	if (ret)
		return ret;

	if (write) {
		if (qos_stat_old == sysctl_memcg_swap_qos_stat)
			return 0;

		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;
}
#endif
#endif

#ifdef CONFIG_NUMA
#ifdef CONFIG_NUMA


#define LRU_ALL_FILE (BIT(LRU_INACTIVE_FILE) | BIT(LRU_ACTIVE_FILE))
#define LRU_ALL_FILE (BIT(LRU_INACTIVE_FILE) | BIT(LRU_ACTIVE_FILE))
@@ -8022,6 +8059,17 @@ static struct ctl_table mem_cgroup_sysctls[] = {
		.extra2		= SYSCTL_ONE,
		.extra2		= SYSCTL_ONE,
	},
	},
#endif
#endif
#ifdef CONFIG_MEMCG_SWAP_QOS
	{
		.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,
	},
#endif
};
};


static __init int mem_cgroup_sysctls_init(void)
static __init int mem_cgroup_sysctls_init(void)