Unverified Commit 7602779e authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1228 Per-memcg swap control

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

v2->v3: Enable memcg swap qos for x86_64 and arm64 by default.
v1->v2: Rebase on the latest version and fix merge conflicts.

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

Yosry Ahmed (1):
  mm: vmpressure: don't count proactive reclaim in vmpressure


-- 
2.25.1
 
 
Link:https://gitee.com/openeuler/kernel/pulls/1228

 

Reviewed-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 8bc2955c 2b97c78c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ Brief summary of control files.
 memory.stat			     show various statistics
 memory.use_hierarchy		     set/show hierarchical account enabled
 memory.force_empty		     trigger forced page reclaim
 memory.force_swapin		     trigger forced swapin anon page
 memory.swap.max		     set/show limit for swap
 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)
+12 −4
Original line number Diff line number Diff line
@@ -1196,20 +1196,28 @@ 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

	Please note that the kernel can over or under reclaim from
	the target cgroup. If less bytes are reclaimed than the
	specified amount, -EAGAIN is returned.

	Please note that the proactive reclaim (triggered by this
	interface) is not meant to indicate memory pressure on the
	memory cgroup. Therefore socket memory balancing triggered by
	the memory reclaim normally is not exercised in this case.
	This means that the networking layer will not adapt based on
	reclaim induced by memory.reclaim.

  memory.oom.group
	A read-write single value file which exists on non-root
	cgroups.  The default value is "0".
+1 −0
Original line number Diff line number Diff line
@@ -1092,6 +1092,7 @@ CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y
CONFIG_CLEANCACHE=y
CONFIG_FRONTSWAP=y
CONFIG_MEMCG_QOS=y
CONFIG_MEMCG_SWAP_QOS=y
CONFIG_ETMEM_SCAN=m
CONFIG_ETMEM_SWAP=m
CONFIG_ETMEM=y
+1 −0
Original line number Diff line number Diff line
@@ -1042,6 +1042,7 @@ CONFIG_THP_SWAP=y
CONFIG_CLEANCACHE=y
CONFIG_FRONTSWAP=y
CONFIG_MEMCG_QOS=y
CONFIG_MEMCG_SWAP_QOS=y
CONFIG_ETMEM_SCAN=m
CONFIG_ETMEM_SWAP=m
CONFIG_ETMEM=y
+31 −0
Original line number Diff line number Diff line
@@ -50,6 +50,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;
@@ -240,6 +245,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
@@ -402,7 +412,12 @@ struct mem_cgroup {
#else
	KABI_RESERVE(6)
#endif
#ifdef CONFIG_MEMCG_SWAP_QOS
	/* per-memcg swap device control; protected by swap_lock */
	KABI_USE(7, struct swap_device *swap_dev)
#else
	KABI_RESERVE(7)
#endif
	KABI_RESERVE(8)

	struct mem_cgroup_per_node *nodeinfo[0];
@@ -424,6 +439,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.
@@ -1294,6 +1313,9 @@ static inline bool memcg_has_children(struct mem_cgroup *memcg)

int mem_cgroup_force_empty(struct mem_cgroup *memcg);

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

#else /* CONFIG_MEMCG */

#define MEM_CGROUP_ID_SHIFT	0
@@ -1701,6 +1723,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 page *page)
{
	return SWAP_TYPE_ALL;
}

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

/* idx can be of type enum memcg_stat_item or node_stat_item */
Loading