Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 250a3511 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "vmscan: Support multiple kswapd threads per node"

parents 917f3516 7e78bc0a
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ Currently, these files are in /proc/sys/vm:
- extfrag_threshold
- extra_free_kbytes
- hugetlb_shm_group
- kswapd_threads
- laptop_mode
- legacy_va_layout
- lowmem_reserve_ratio
@@ -300,6 +301,28 @@ shared memory segment using hugetlb page.

==============================================================

kswapd_threads

kswapd_threads allows you to control the number of kswapd threads per node
running on the system. This provides the ability to devote additional CPU
resources toward proactive page replacement with the goal of reducing
direct reclaims. When direct reclaims are prevented, the CPU consumed
by them is prevented as well. Depending on the workload, the result can
cause aggregate CPU usage on the system to go up, down or stay the same.

More aggressive page replacement can reduce direct reclaims which cause
latency for tasks and decrease throughput when doing filesystem IO through
the pagecache. Direct reclaims are recorded using the allocstall counter
in /proc/vmstat.

The default value is 1 and the range of acceptible values are 1-16.
Always start with lower values in the 2-6 range. Higher values should
be justified with testing. If direct reclaims occur in spite of high
values, the cost of direct reclaims (in latency) that occur can be
higher due to increased lock contention.

==============================================================

laptop_mode

laptop_mode is a knob that controls "laptop mode". All the things that are
+2 −0
Original line number Diff line number Diff line
@@ -2331,6 +2331,7 @@ extern void set_dma_reserve(unsigned long new_dma_reserve);
extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long,
		enum memmap_context, struct vmem_altmap *);
extern void setup_per_zone_wmarks(void);
extern void update_kswapd_threads(void);
extern int __meminit init_per_zone_wmark_min(void);
extern void mem_init(void);
extern void __init mmap_init(void);
@@ -2351,6 +2352,7 @@ extern void zone_pcp_update(struct zone *zone);
extern void zone_pcp_reset(struct zone *zone);

/* page_alloc.c */
extern int kswapd_threads;
extern int min_free_kbytes;
extern int watermark_boost_factor;
extern int watermark_scale_factor;
+8 −2
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@
 */
#define PAGE_ALLOC_COSTLY_ORDER 3

#define MAX_KSWAPD_THREADS 16

enum migratetype {
	MIGRATE_UNMOVABLE,
	MIGRATE_MOVABLE,
@@ -676,8 +678,10 @@ typedef struct pglist_data {
	int node_id;
	wait_queue_head_t kswapd_wait;
	wait_queue_head_t pfmemalloc_wait;
	struct task_struct *kswapd;	/* Protected by
					   mem_hotplug_begin/end() */
	/*
	 * Protected by mem_hotplug_begin/end()
	 */
	struct task_struct *kswapd[MAX_KSWAPD_THREADS];
	int kswapd_order;
	enum zone_type kswapd_classzone_idx;

@@ -904,6 +908,8 @@ static inline int is_highmem(struct zone *zone)

/* These two functions are used to setup the per zone pages min values */
struct ctl_table;
int kswapd_threads_sysctl_handler(struct ctl_table *, int,
					void __user *, size_t *, loff_t *);
int min_free_kbytes_sysctl_handler(struct ctl_table *, int,
					void __user *, size_t *, loff_t *);
int watermark_boost_factor_sysctl_handler(struct ctl_table *, int,
+10 −0
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ static int ten_thousand = 10000;
#ifdef CONFIG_PERF_EVENTS
static int six_hundred_forty_kb = 640 * 1024;
#endif
static int max_kswapd_threads = MAX_KSWAPD_THREADS;
static int two_hundred_fifty_five = 255;
static int __maybe_unused two_hundred_million = 200000000;

@@ -1773,6 +1774,15 @@ static struct ctl_table vm_table[] = {
		.proc_handler	= watermark_boost_factor_sysctl_handler,
		.extra1		= &zero,
	},
	{
		.procname	= "kswapd_threads",
		.data		= &kswapd_threads,
		.maxlen		= sizeof(kswapd_threads),
		.mode		= 0644,
		.proc_handler	= kswapd_threads_sysctl_handler,
		.extra1		= &one,
		.extra2		= &max_kswapd_threads,
	},
	{
		.procname	= "watermark_scale_factor",
		.data		= &watermark_scale_factor,
+15 −0
Original line number Diff line number Diff line
@@ -7872,6 +7872,21 @@ int watermark_boost_factor_sysctl_handler(struct ctl_table *table, int write,
	return 0;
}

int kswapd_threads_sysctl_handler(struct ctl_table *table, int write,
	void __user *buffer, size_t *length, loff_t *ppos)
{
	int rc;

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

	if (write)
		update_kswapd_threads();

	return 0;
}

int watermark_scale_factor_sysctl_handler(struct ctl_table *table, int write,
	void __user *buffer, size_t *length, loff_t *ppos)
{
Loading