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

Commit ac4b2c42 authored by Vinayak Menon's avatar Vinayak Menon Committed by Swathi Sridhar
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.

Change-Id: I54f54489db84cabb206569dd62d61a8a7a898991
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
Signed-off-by: default avatarCharan Teja Reddy <charante@codeaurora.org>
[swatsrid@codeaurora.org: Fix trivial merge conflicts]
Signed-off-by: default avatarSwathi Sridhar <swatsrid@codeaurora.org>
parent 422c5709
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
@@ -178,6 +178,7 @@ enum {

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

#define SWAP_MAP_MAX	0x3e	/* Max duplication count, in first swap_map */
#define SWAP_MAP_BAD	0x3f	/* Note pageblock is bad, in first swap_map */
@@ -273,6 +274,8 @@ struct swap_info_struct {
					 */
	struct work_struct discard_work; /* discard worker */
	struct swap_cluster_list discard_clusters; /* discard clusters list */
	unsigned int write_pending;
	unsigned int max_writes;
};

#ifdef CONFIG_64BIT
@@ -355,6 +358,8 @@ extern unsigned long mem_cgroup_shrink_node(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
@@ -8,9 +8,14 @@
 */
extern spinlock_t swap_lock;
extern struct plist_head swap_active_head;
extern spinlock_t swap_avail_lock;
extern struct plist_head *swap_avail_heads;
extern struct swap_info_struct *swap_info[];
extern int try_to_unuse(unsigned int, bool, unsigned long);
extern unsigned long generic_max_swapfile_size(void);
extern unsigned long max_swapfile_size(void);
extern int swap_ratio(struct swap_info_struct **si, int node);
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
@@ -1672,6 +1672,22 @@ static struct ctl_table vm_table[] = {
		.extra1		= (void *)&mmap_rnd_compat_bits_min,
		.extra2		= (void *)&mmap_rnd_compat_bits_max,
	},
#endif
#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
@@ -54,7 +54,7 @@ ifdef CONFIG_MMU
endif
obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o

obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o swap_slots.o
obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o swap_slots.o swap_ratio.o
obj-$(CONFIG_FRONTSWAP)	+= frontswap.o
obj-$(CONFIG_ZSWAP)	+= zswap.o
obj-$(CONFIG_HAS_DMA)	+= dmapool.o
Loading