Unverified Commit 8aa69e79 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3894 Add swap control for memcg

Merge Pull Request from: @ci-robot 
 
PR sync from: Jinjiang Tu <tujinjiang@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/7UCOO6PANTDXMXYD5KHILHPRQ7W27VGW/ 
This series patches add swap control for memory cgroup. Patch[1] add page
type in memory.reclaim interface to support reclaim anon pages. Patch[3]
add memory.force_swapin interface to support swap back pages proactively.
Patch[4-6] add memory.swapfile interface to limit available swap device
for memory cgroup. Patch[7] add memory.swap.max interface to limit usage
of swap for memory cgroup.

Jinjiang Tu (1):
  memcg: make sysctl registration more extensible

Liu Shixin (7):
  memcg: add page type to memory.reclaim interface
  memcg: introduce memcg swap qos feature
  memcg: introduce per-memcg swapin interface
  memcg: add restrict to swap to cgroup1
  mm/swapfile: introduce per-memcg swapfile control
  mm: swap_slots: add per-type slot cache
  config: enable memcg swap qos for x86_64 and arm64 by default

zhaoxiaoqiang11 (1):
  memcg/swap: add ability to disable memcg swap


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/I8QK6Q 
 
Link:https://gitee.com/openeuler/kernel/pulls/3894

 

Reviewed-by: default avatarLu Jialin <lujialin4@huawei.com>
Reviewed-by: default avatarLiu Chao <liuchao173@huawei.com>
Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 49f3cbc2 9f154c6a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -83,6 +83,10 @@ Brief summary of control files.
                                     This knob is deprecated and shouldn't be
                                     used.
 memory.force_empty		     trigger forced page reclaim
 memory.force_swapin		     trigger forced swapin anon page
 memory.swap.max		     set/show limit for the difference between memsw.usage
				     and memory.usage
 memory.swapfile		     set/show available swap file
 memory.pressure_level		     set memory pressure notifications
 memory.swappiness		     set/show swappiness parameter of vmscan
				     (See sysctl's vm.swappiness)
+6 −4
Original line number Diff line number Diff line
@@ -1247,15 +1247,17 @@ PAGE_SIZE multiple when read back.
	target cgroup.

	This file accepts a single key, the number of bytes to reclaim.
	No nested keys are currently supported.

	Example::

	  echo "1G" > memory.reclaim

	The interface can be later extended with nested keys to
	configure the reclaim behavior. For example, specify the
	type of memory to reclaim from (anon, file, ..).
	This file also accepts nested keys, the number of bytes to reclaim
	with the type of memory to reclaim.

	Example::
	  echo "1G type=file" > memory.reclaim
	  echo "1G type=anon" > memory.reclaim

	Please note that the kernel can over or under reclaim from
	the target cgroup. If less bytes are reclaimed than the
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ CONFIG_MEMCG=y
CONFIG_MEMCG_V1_RECLAIM=y
CONFIG_MEMCG_MEMFS_INFO=y
CONFIG_MEMCG_OOM_PRIORITY=y
CONFIG_MEMCG_SWAP_QOS=y
CONFIG_MEMCG_KMEM=y
CONFIG_BLK_CGROUP=y
CONFIG_CGROUP_WRITEBACK=y
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ CONFIG_MEMCG=y
CONFIG_MEMCG_V1_RECLAIM=y
CONFIG_MEMCG_MEMFS_INFO=y
CONFIG_MEMCG_OOM_PRIORITY=y
CONFIG_MEMCG_SWAP_QOS=y
CONFIG_MEMCG_KMEM=y
CONFIG_BLK_CGROUP=y
CONFIG_CGROUP_WRITEBACK=y
+35 −0
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@ enum memcg_memory_event {
	MEMCG_NR_MEMORY_EVENTS,
};

enum {
	SWAP_TYPE_ALL	= -1, /* allowd use all swap file */
	SWAP_TYPE_NONE	= -2, /* prohibited use any swapfile */
};

struct mem_cgroup_reclaim_cookie {
	pg_data_t *pgdat;
	unsigned int generation;
@@ -201,6 +206,11 @@ struct obj_cgroup {
	};
};

struct swap_device {
	unsigned long max;
	int type;
};

/*
 * The memory controller data structure. The memory controller controls both
 * page cache and RSS per cgroup. We would eventually like to provide
@@ -350,6 +360,10 @@ struct mem_cgroup {
	bool high_async_reclaim;
#endif

#ifdef CONFIG_MEMCG_SWAP_QOS
	struct swap_device *swap_dev;
#endif

	struct mem_cgroup_per_node *nodeinfo[];
};

@@ -367,6 +381,15 @@ static inline void memcg_print_bad_task(struct oom_control *oc)
}
#endif

#ifdef CONFIG_MEMCG_SWAP_QOS
DECLARE_STATIC_KEY_FALSE(memcg_swap_qos_key);

#define MEMCG_SWAP_STAT_DISABLE		0
#define MEMCG_SWAP_STAT_ALL		1
#define MEMCG_SWAP_STAT_NONE		2
#define MAX_MEMCG_SWAP_TYPE		MEMCG_SWAP_STAT_NONE
#endif

/*
 * size of first charge trial.
 * TODO: maybe necessary to use big numbers in big irons or dynamic based of the
@@ -1191,6 +1214,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
						gfp_t gfp_mask,
						unsigned long *total_scanned);

int memcg_get_swap_type(struct folio *folio);
void memcg_remove_swapfile(int type);

#else /* CONFIG_MEMCG */

#define MEM_CGROUP_ID_SHIFT	0
@@ -1627,6 +1653,15 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
static inline void memcg_print_bad_task(struct oom_control *oc)
{
}

static inline int memcg_get_swap_type(struct folio *folio)
{
	return SWAP_TYPE_ALL;
}

static inline void memcg_remove_swapfile(int type)
{
}
#endif /* CONFIG_MEMCG */

static inline void __inc_lruvec_kmem_state(void *p, enum node_stat_item idx)
Loading