Commit 4e6a126f authored by zhangwei123171's avatar zhangwei123171
Browse files

mm/swapfile: fixed the repeated setting logic of memcg_swap_qos_enable

jingdong inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8526M



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

Now when echo 1 > /proc/sys/vm/memcg_swap_qos_enable multiple times,
memcg_swap_qos_reset will be called every time.

In a production environment, when memcg swap qos is working normally,
operations Engineer may execute 'sysctl -p' for other reasons, destroying
the relationship between each container and its corresponding swapfile.

Fixes: eefe54b2 ("memcg: introduce memcg swap qos feature")
Signed-off-by: default avatarzhangwei123171 <zhangwei123171@jd.com>
Reviewed-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent 369da114
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -4080,11 +4080,13 @@ static int sysctl_memcg_swap_qos_handler(struct ctl_table *table, int write,
	if (ret)
		return ret;
	if (write) {
		if (sysctl_memcg_swap_qos_stat) {
		if (sysctl_memcg_swap_qos_stat &&
				!static_branch_likely(&memcg_swap_qos_key)) {
			memcg_swap_qos_reset();
			static_branch_enable(&memcg_swap_qos_key);
			enable_swap_slots_cache_max();
		} else {
		} else if (!sysctl_memcg_swap_qos_stat &&
				static_branch_likely(&memcg_swap_qos_key)) {
			static_branch_disable(&memcg_swap_qos_key);
		}
	}