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

Commit 5c1d906d authored by Vinayak Menon's avatar Vinayak Menon
Browse files

mm: swap: swap ratio support



Add support to receive a static ratio from userspace to
divide the swap pages between ZRAM and disk based swap
devices. The existing infrastructure allows to keep
same priority for multiple swap devices, which results
in round robin distribution of pages. With this patch,
the ratio can be defined.

CRs-fixed: 968416
Change-Id: I54f54489db84cabb206569dd62d61a8a7a898991
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent a1a6afd9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -266,6 +266,9 @@ static inline int plist_node_empty(const struct plist_node *node)
#define plist_next(pos) \
	list_next_entry(pos, node_list)

#define plist_next_entry(pos, type, member)   \
	container_of(plist_next(pos), type, member)

/**
 * plist_prev - get the prev entry in list
 * @pos:	the type * to cursor
+5 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ enum {

#define SWAP_CLUSTER_MAX 32UL
#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
#define SWAPFILE_CLUSTER	256

/*
 * Ratio between zone->managed_pages and the "gap" that above the per-zone
@@ -255,6 +256,8 @@ struct swap_info_struct {
	struct work_struct discard_work; /* discard worker */
	struct swap_cluster_info discard_cluster_head; /* list head of discard clusters */
	struct swap_cluster_info discard_cluster_tail; /* list tail of discard clusters */
	unsigned int write_pending;
	unsigned int max_writes;
};

/* linux/mm/workingset.c */
@@ -338,6 +341,8 @@ extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
						unsigned long *nr_scanned);
extern unsigned long shrink_all_memory(unsigned long nr_pages);
extern int vm_swappiness;
extern int sysctl_swap_ratio;
extern int sysctl_swap_ratio_enable;
extern int remove_mapping(struct address_space *mapping, struct page *page);
extern unsigned long vm_total_pages;

+5 −0
Original line number Diff line number Diff line
@@ -7,7 +7,12 @@
 */
extern spinlock_t swap_lock;
extern struct plist_head swap_active_head;
extern spinlock_t swap_avail_lock;
extern struct plist_head swap_avail_head;
extern struct swap_info_struct *swap_info[];
extern int try_to_unuse(unsigned int, bool, unsigned long);
extern int swap_ratio(struct swap_info_struct **si);
extern void setup_swap_ratio(struct swap_info_struct *p, int prio);
extern bool is_swap_ratio_group(int prio);

#endif /* _LINUX_SWAPFILE_H */
+16 −0
Original line number Diff line number Diff line
@@ -1752,6 +1752,22 @@ static struct ctl_table vm_table[] = {
		.mode		= 0644,
		.proc_handler	= proc_doulongvec_minmax,
	},
#ifdef CONFIG_SWAP
	{
		.procname	= "swap_ratio",
		.data		= &sysctl_swap_ratio,
		.maxlen		= sizeof(sysctl_swap_ratio),
		.mode		= 0644,
		.proc_handler	= proc_dointvec_minmax,
	},
	{
		.procname	= "swap_ratio_enable",
		.data		= &sysctl_swap_ratio_enable,
		.maxlen		= sizeof(sysctl_swap_ratio_enable),
		.mode		= 0644,
		.proc_handler	= proc_dointvec_minmax,
	},
#endif
	{ }
};

+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ ifdef CONFIG_MMU
endif
obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o

obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o
obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o swap_ratio.o
obj-$(CONFIG_FRONTSWAP)	+= frontswap.o
obj-$(CONFIG_ZSWAP)	+= zswap.o
obj-$(CONFIG_ZCACHE)	+= zcache.o
Loading