Skip to contentSkip to conversation

mm, swap: VMA based swap readahead

PATCH Applied Huang, Ying 3 participants 19 messages Aug 7, 2017 – Sep 15, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover mm, swap: VMA based swap readahead

The swap readahead is an important mechanism to reduce the swap in latency. Although pure sequential memory access pattern isn't very popular for anonymous memory, the space locality is still considered valid.

In the original swap readahead implementation, the consecutive blocks in swap device are readahead based on the global space locality estimation. But the consecutive blocks in swap device just reflect the order of page reclaiming, don't necessarily reflect the access pattern in virtual memory space. And the different tasks in the system may have different access patterns, which makes the global space locality estimation incorrect.

In this patchset, when page fault occurs, the virtual pages near the fault address will be readahead instead of the swap slots near the fault swap slot in swap device. This avoid to readahead the unrelated swap slots. At the same time, the swap readahead is changed to work on per-VMA from globally. So that the different access patterns of the different VMAs could be distinguished, and the different readahead policy could be applied accordingly. The original core readahead detection and scaling algorithm is reused, because it is an effect algorithm to detect the space locality.

In addition to the swap readahead changes, some new sysfs interface is added to show the efficiency of the readahead algorithm and some other swap statistics.

This new implementation will incur more small random read, on SSD, the improved correctness of estimation and readahead target should beat the potential increased overhead, this is also illustrated in the test results below. But on HDD, the overhead may beat the benefit, so the original implementation will be used by default.

The test and result is as follow,

Common test condition
=====================

Test Machine: Xeon E5 v3 (2 sockets, 72 threads, 32G RAM) Swap device: NVMe disk

Micro-benchmark with combined access pattern
============================================

vm-scalability, sequential swap test case, 4 processes to eat 50G virtual memory space, repeat the sequential memory writing until 300 seconds. The first round writing will trigger swap out, the following rounds will trigger sequential swap in and out.

At the same time, run vm-scalability random swap test case in background, 8 processes to eat 30G virtual memory space, repeat the random memory write until 300 seconds. This will trigger random swap-in in the background.

This is a combined workload with sequential and random memory accessing at the same time. The result (for sequential workload) is as follow,

			Base		Optimized
			----		---------

throughput 345413 KB/s 414029 KB/s (+19.9%)
latency.average 97.14 us 61.06 us (-37.1%)
latency.50th 2 us 1 us
latency.60th 2 us 1 us
latency.70th 98 us 2 us
latency.80th 160 us 2 us
latency.90th 260 us 217 us
latency.95th 346 us 369 us
latency.99th 1.34 ms 1.09 ms
ra_hit% 52.69% 99.98%

The original swap readahead algorithm is confused by the background random access workload, so readahead hit rate is lower. The VMA-base readahead algorithm works much better.

Linpack
=======

The test memory size is bigger than RAM to trigger swapping.

			Base		Optimized
			----		---------

elapsed_time 393.49 s 329.88 s (-16.2%)
ra_hit% 86.21% 98.82%

The score of base and optimized kernel hasn't visible changes. But the elapsed time reduced and readahead hit rate improved, so the optimized kernel runs better for startup and tear down stages. And the absolute value of readahead hit rate is high, shows that the space locality is still valid in some practical workloads.

Changelogs:

v4:

- Rebased on latest -mm tree.

- Remove swap cache statistics interface, because we found that the interface for readahead statistics should be sufficient.

- Use /proc/vmstat for swap readahead statistics, because that is the interface used by other similar statistics.

- Add ABI document for newly added sysfs interface.

v3:

- Rebased on latest -mm tree

- Use percpu_counter for swap readahead statistics per Dave Hansen's comment.

Best Regards,
Huang, Ying

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

PATCH 1/5 mm, swap: Add swap readahead hit statistics

From: Huang Ying <[email protected]>

The statistics for total readahead pages and total readahead hits are recorded and exported via the following sysfs interface.

/sys/kernel/mm/swap/ra_hits
/sys/kernel/mm/swap/ra_total

With them, the efficiency of the swap readahead could be measured, so that the swap readahead algorithm and parameters could be tuned accordingly.

Cc Johannes Weiner <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Fengguang Wu <[email protected]>
Cc Tim Chen <[email protected]>
Cc Dave Hansen <[email protected]>
---
 include/linux/vm_event_item.h | 2 ++
 mm/swap_state.c               | 9 +++++++--
 mm/vmstat.c                   | 3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)
include/linux/vm_event_item.h +2 -0
index e02820fc2861..27e3339cfd65 100644
@@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		VMACACHE_FIND_HITS,
 		VMACACHE_FULL_FLUSHES,
 #endif
+		SWAP_RA,
+		SWAP_RA_HIT,
 		NR_VM_EVENT_ITEMS
 };
 
mm/swap_state.c +7 -2
index b68c93014f50..d1bdb31cab13 100644
@@ -305,8 +305,10 @@ struct page * lookup_swap_cache(swp_entry_t entry)
 
 	if (page && likely(!PageTransCompound(page))) {
 		INC_CACHE_INFO(find_success);
-		if (TestClearPageReadahead(page))
+		if (TestClearPageReadahead(page)) {
 			atomic_inc(&swapin_readahead_hits);
+			count_vm_event(SWAP_RA_HIT);
+		}
 	}
 
 	INC_CACHE_INFO(find_total);
@@ -516,8 +518,11 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
 						gfp_mask, vma, addr, false);
 		if (!page)
 			continue;
-		if (offset != entry_offset && likely(!PageTransCompound(page)))
+		if (offset != entry_offset &&
+		    likely(!PageTransCompound(page))) {
 			SetPageReadahead(page);
+			count_vm_event(SWAP_RA);
+		}
 		put_page(page);
 	}
 	blk_finish_plug(&plug);
mm/vmstat.c +3 -0
index ba9b202e8500..4c2121a8b877 100644
@@ -1095,6 +1095,9 @@ const char * const vmstat_text[] = {
 	"vmacache_find_hits",
 	"vmacache_full_flushes",
 #endif
+
+	"swap_ra",
+	"swap_ra_hit",
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
Signature · 7 lines
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

PATCH 2/5 mm, swap: Fix swap readahead marking

In reply to Huang, Ying

From: Huang Ying <[email protected]>

In the original implementation, it is possible that the existing pages in the swap cache (not newly readahead) could be marked as the readahead pages. This will cause the statistics of swap readahead be wrong and influence the swap readahead algorithm too.

This is fixed via marking a page as the readahead page only if it is newly allocated and read from the disk.

When testing with linpack, after the fixing the swap readahead hit rate increased from ~66% to ~86%.

Cc Johannes Weiner <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Fengguang Wu <[email protected]>
Cc Tim Chen <[email protected]>
Cc Dave Hansen <[email protected]>
---
 mm/swap_state.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
mm/swap_state.c +11 -7
index d1bdb31cab13..a901afe9da61 100644
@@ -498,7 +498,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
 	unsigned long start_offset, end_offset;
 	unsigned long mask;
 	struct blk_plug plug;
-	bool do_poll = true;
+	bool do_poll = true, page_allocated;
 
 	mask = swapin_nr_pages(offset) - 1;
 	if (!mask)
@@ -514,14 +514,18 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
 	blk_start_plug(&plug);
 	for (offset = start_offset; offset <= end_offset ; offset++) {
 		/* Ok, do the async read-ahead now */
-		page = read_swap_cache_async(swp_entry(swp_type(entry), offset),
-						gfp_mask, vma, addr, false);
+		page = __read_swap_cache_async(
+			swp_entry(swp_type(entry), offset),
+			gfp_mask, vma, addr, &page_allocated);
 		if (!page)
 			continue;
-		if (offset != entry_offset &&
-		    likely(!PageTransCompound(page))) {
-			SetPageReadahead(page);
-			count_vm_event(SWAP_RA);
+		if (page_allocated) {
+			swap_readpage(page, false);
+			if (offset != entry_offset &&
+			    likely(!PageTransCompound(page))) {
+				SetPageReadahead(page);
+				count_vm_event(SWAP_RA);
+			}
 		}
 		put_page(page);
 	}
Signature · 7 lines
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw

PATCH 3/5 mm, swap: VMA based swap readahead

In reply to Huang, Ying

From: Huang Ying <[email protected]>

The swap readahead is an important mechanism to reduce the swap in latency. Although pure sequential memory access pattern isn't very popular for anonymous memory, the space locality is still considered valid.

In the original swap readahead implementation, the consecutive blocks in swap device are readahead based on the global space locality estimation. But the consecutive blocks in swap device just reflect the order of page reclaiming, don't necessarily reflect the access pattern in virtual memory. And the different tasks in the system may have different access patterns, which makes the global space locality estimation incorrect.

In this patch, when page fault occurs, the virtual pages near the fault address will be readahead instead of the swap slots near the fault swap slot in swap device. This avoid to readahead the unrelated swap slots. At the same time, the swap readahead is changed to work on per-VMA from globally. So that the different access patterns of the different VMAs could be distinguished, and the different readahead policy could be applied accordingly. The original core readahead detection and scaling algorithm is reused, because it is an effect algorithm to detect the space locality.

The test and result is as follow,

Common test condition
=====================

Test Machine: Xeon E5 v3 (2 sockets, 72 threads, 32G RAM) Swap device: NVMe disk

Micro-benchmark with combined access pattern
============================================

vm-scalability, sequential swap test case, 4 processes to eat 50G virtual memory space, repeat the sequential memory writing until 300 seconds. The first round writing will trigger swap out, the following rounds will trigger sequential swap in and out.

At the same time, run vm-scalability random swap test case in background, 8 processes to eat 30G virtual memory space, repeat the random memory write until 300 seconds. This will trigger random swap-in in the background.

This is a combined workload with sequential and random memory accessing at the same time. The result (for sequential workload) is as follow,

			Base		Optimized
			----		---------

throughput 345413 KB/s 414029 KB/s (+19.9%)
latency.average 97.14 us 61.06 us (-37.1%)
latency.50th 2 us 1 us
latency.60th 2 us 1 us
latency.70th 98 us 2 us
latency.80th 160 us 2 us
latency.90th 260 us 217 us
latency.95th 346 us 369 us
latency.99th 1.34 ms 1.09 ms
ra_hit% 52.69% 99.98%

The original swap readahead algorithm is confused by the background random access workload, so readahead hit rate is lower. The VMA-base readahead algorithm works much better.

Linpack
=======

The test memory size is bigger than RAM to trigger swapping.

			Base		Optimized
			----		---------

elapsed_time 393.49 s 329.88 s (-16.2%)
ra_hit% 86.21% 98.82%

The score of base and optimized kernel hasn't visible changes. But the elapsed time reduced and readahead hit rate improved, so the optimized kernel runs better for startup and tear down stages. And the absolute value of readahead hit rate is high, shows that the space locality is still valid in some practical workloads.

Cc Johannes Weiner <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Fengguang Wu <[email protected]>
Cc Tim Chen <[email protected]>
Cc Dave Hansen <[email protected]>
---
 include/linux/mm_types.h |   1 +
 include/linux/swap.h     |  57 ++++++++++++-
 mm/memory.c              |  23 +++--
 mm/shmem.c               |   2 +-
 mm/swap_state.c          | 215 +++++++++++++++++++++++++++++++++++++++++++----
 5 files changed, 273 insertions(+), 25 deletions(-)
include/linux/mm_types.h +1 -0
index 7f384bb62d8e..5c02027050a2 100644
@@ -335,6 +335,7 @@ struct vm_area_struct {
 	struct file * vm_file;		/* File we map to (can be NULL). */
 	void * vm_private_data;		/* was vm_pte (shared mem) */
 
+	atomic_long_t swap_readahead_info;
 #ifndef CONFIG_MMU
 	struct vm_region *vm_region;	/* NOMMU mapping region */
 #endif
include/linux/swap.h +55 -2

92 lines not on this page · raw message

mm/memory.c +18 -5
index 5cd37032ca67..e44fba697fd7 100644
@@ -2733,16 +2733,23 @@ noinline int swap_lock_page_or_retry(struct page *page, struct mm_struct *mm,
 int do_swap_page(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
-	struct page *page, *swapcache;
+	struct page *page = NULL, *swapcache;
 	struct mem_cgroup *memcg;
+	struct vma_swap_readahead swap_ra;
 	swp_entry_t entry;
 	pte_t pte;
 	int locked;
 	int exclusive = 0;
 	int ret = 0;
+	bool vma_readahead = swap_use_vma_readahead();
 
-	if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte))
+	if (vma_readahead)
+		page = swap_readahead_detect(vmf, &swap_ra);
+	if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) {
+		if (page)
+			put_page(page);
 		goto out;
+	}
 
 	entry = pte_to_swp_entry(vmf->orig_pte);
 	if (unlikely(non_swap_entry(entry))) {
@@ -2758,10 +2765,16 @@ int do_swap_page(struct vm_fault *vmf)
 		goto out;
 	}
 	delayacct_set_flag(DELAYACCT_PF_SWAPIN);
-	page = lookup_swap_cache(entry);
+	if (!page)
+		page = lookup_swap_cache(entry, vma_readahead ? vma : NULL,
+					 vmf->address);
 	if (!page) {
-		page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, vma,
-					vmf->address);
+		if (vma_readahead)
+			page = do_swap_page_readahead(entry,
+				GFP_HIGHUSER_MOVABLE, vmf, &swap_ra);
+		else
+			page = swapin_readahead(entry,
+				GFP_HIGHUSER_MOVABLE, vma, vmf->address);
 		if (!page) {
 			/*
 			 * Back out if somebody else faulted in this pte
mm/shmem.c +1 -1
index 3c381ef18c30..3d366c6e5608 100644
@@ -1645,7 +1645,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
 
 	if (swap.val) {
 		/* Look it up and read it in.. */
-		page = lookup_swap_cache(swap);
+		page = lookup_swap_cache(swap, NULL, 0);
 		if (!page) {
 			/* Or update major stats only when swapin succeeds?? */
 			if (fault_type) {
mm/swap_state.c +198 -17

266 lines not on this page · raw message

Signature · 7 lines
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#17 lore raw

PATCH 4/5 mm, swap: Add sysfs interface for VMA based swap readahead

In reply to Huang, Ying

From: Huang Ying <[email protected]>

The sysfs interface to control the VMA based swap readahead is added as follow,

/sys/kernel/mm/swap/vma_ra_enabled

Enable the VMA based swap readahead algorithm, or use the original global swap readahead algorithm.

/sys/kernel/mm/swap/vma_ra_max_order

Set the max order of the readahead window size for the VMA based swap readahead algorithm.

The corresponding ABI documentation is added too.

Cc Johannes Weiner <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Fengguang Wu <[email protected]>
Cc Tim Chen <[email protected]>
Cc Dave Hansen <[email protected]>
---
 Documentation/ABI/testing/sysfs-kernel-mm-swap | 26 +++++++++
 mm/swap_state.c                                | 80 ++++++++++++++++++++++++++
 2 files changed, 106 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-kernel-mm-swap
Documentation/ABI/testing/sysfs-kernel-mm-swap new file +26 -0
new file mode 100644
index 000000000000..587db52084c7
@@ -0,0 +1,26 @@
+What:		/sys/kernel/mm/swap/
+Date:		August 2017
+Contact:	Linux memory management mailing list <[email protected]>
+Description:	Interface for swapping
+
+What:		/sys/kernel/mm/swap/vma_ra_enabled
+Date:		August 2017
+Contact:	Linux memory management mailing list <[email protected]>
+Description:	Enable/disable VMA based swap readahead.
+
+		If set to true, the VMA based swap readahead algorithm
+		will be used for swappable anonymous pages mapped in a
+		VMA, and the global swap readahead algorithm will be
+		still used for tmpfs etc. other users.  If set to
+		false, the global swap readahead algorithm will be
+		used for all swappable pages.
+
+What:		/sys/kernel/mm/swap/vma_ra_max_order
+Date:		August 2017
+Contact:	Linux memory management mailing list <[email protected]>
+Description:	The max readahead size in order for VMA based swap readahead
+
+		VMA based swap readahead algorithm will readahead at
+		most 1 << max_order pages for each readahead.  The
+		real readahead size for each readahead will be scaled
+		according to the estimation algorithm.
mm/swap_state.c +80 -0

83 lines not on this page · raw message

Signature · 7 lines
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#18 lore raw

PATCH 5/5 mm, swap: Don't use VMA based swap readahead if HDD is used as swap

In reply to Huang, Ying

From: Huang Ying <[email protected]>

VMA based swap readahead will readahead the virtual pages that is continuous in the virtual address space. While the original swap readahead will readahead the swap slots that is continuous in the swap device. Although VMA based swap readahead is more correct for the swap slots to be readahead, it will trigger more small random readings, which may cause the performance of HDD (hard disk) to degrade heavily, and may finally exceed the benefit.

To avoid the issue, in this patch, if the HDD is used as swap, the VMA based swap readahead will be disabled, and the original swap readahead will be used instead.

Cc Johannes Weiner <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Fengguang Wu <[email protected]>
Cc Tim Chen <[email protected]>
Cc Dave Hansen <[email protected]>
---
 include/linux/swap.h | 11 ++++++-----
 mm/swapfile.c        |  8 +++++++-
 2 files changed, 13 insertions(+), 6 deletions(-)
include/linux/swap.h +6 -5
index 61d63379e956..9c4ae6f14eea 100644
@@ -400,16 +400,17 @@ extern struct page *do_swap_page_readahead(swp_entry_t fentry, gfp_t gfp_mask,
 					   struct vm_fault *vmf,
 					   struct vma_swap_readahead *swap_ra);
 
-static inline bool swap_use_vma_readahead(void)
-{
-	return READ_ONCE(swap_vma_readahead);
-}
-
 /* linux/mm/swapfile.c */
 extern atomic_long_t nr_swap_pages;
 extern long total_swap_pages;
+extern atomic_t nr_rotate_swap;
 extern bool has_usable_swap(void);
 
+static inline bool swap_use_vma_readahead(void)
+{
+	return READ_ONCE(swap_vma_readahead) && !atomic_read(&nr_rotate_swap);
+}
+
 /* Swap 50% full? Release swapcache more aggressively.. */
 static inline bool vm_swap_full(void)
 {
mm/swapfile.c +7 -1
index 42eff9e4e972..4f8b3e08a547 100644
@@ -96,6 +96,8 @@ static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
 /* Activity counter to indicate that a swapon or swapoff has occurred */
 static atomic_t proc_poll_event = ATOMIC_INIT(0);
 
+atomic_t nr_rotate_swap = ATOMIC_INIT(0);
+
 static inline unsigned char swap_count(unsigned char ent)
 {
 	return ent & ~SWAP_HAS_CACHE;	/* may include SWAP_HAS_CONT flag */
@@ -2569,6 +2571,9 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
 	if (p->flags & SWP_CONTINUED)
 		free_swap_count_continuations(p);
 
+	if (!p->bdev || !blk_queue_nonrot(bdev_get_queue(p->bdev)))
+		atomic_dec(&nr_rotate_swap);
+
 	mutex_lock(&swapon_mutex);
 	spin_lock(&swap_lock);
 	spin_lock(&p->lock);
@@ -3145,7 +3150,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 			cluster = per_cpu_ptr(p->percpu_cluster, cpu);
 			cluster_set_null(&cluster->index);
 		}
-	}
+	} else
+		atomic_inc(&nr_rotate_swap);
 
 	error = swap_cgroup_swapon(p->type, maxpages);
 	if (error)
Signature · 7 lines
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#2 lore raw

Re: [PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

In reply to Huang, Ying
Quoted 17 lines · Ying

From: Huang Ying <[email protected]>

The statistics for total readahead pages and total readahead hits are recorded and exported via the following sysfs interface.

/sys/kernel/mm/swap/ra_hits
/sys/kernel/mm/swap/ra_total

With them, the efficiency of the swap readahead could be measured, so that the swap readahead algorithm and parameters could be tuned accordingly.

...

include/linux/vm_event_item.h enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, · line 112

Quoted 7 lines
include/linux/vm_event_item.h +2 -0
@@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		VMACACHE_FIND_HITS,
 		VMACACHE_FULL_FLUSHES,
 #endif
+		SWAP_RA,
+		SWAP_RA_HIT,
 		NR_VM_EVENT_ITEMS
 };

swap_state.o isn't even compiled if CONFIG_SWAP=n so there doesn't seem much point in displaying these?

include/linux/vm_event_item.h renamed from include/linux/vm_event_item.h~mm-swap-add-swap-readahead-hit-statistics-fix +2 -0
@@ -106,8 +106,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
 		VMACACHE_FIND_HITS,
 		VMACACHE_FULL_FLUSHES,
 #endif
+#ifdef CONFIG_SWAP
 		SWAP_RA,
 		SWAP_RA_HIT,
+#endif
 		NR_VM_EVENT_ITEMS
 };
 
mm/vmstat.c renamed from mm/vmstat.c~mm-swap-add-swap-readahead-hit-statistics-fix +2 -1
@@ -1098,9 +1098,10 @@ const char * const vmstat_text[] = {
 	"vmacache_find_hits",
 	"vmacache_full_flushes",
 #endif
-
+#ifdef CONFIG_SWAP
 	"swap_ra",
 	"swap_ra_hit",
+#endif
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */

_

#3 lore raw

Re: [PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

Quoted 16 lines · Andrew Morton
Quoted 14 lines · Ying

From: Huang Ying <[email protected]>

The statistics for total readahead pages and total readahead hits are recorded and exported via the following sysfs interface.

/sys/kernel/mm/swap/ra_hits
/sys/kernel/mm/swap/ra_total

With them, the efficiency of the swap readahead could be measured, so that the swap readahead algorithm and parameters could be tuned accordingly.

...

Quoted 13 lines

include/linux/vm_event_item.h enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, · line 112

Quoted 10 lines
include/linux/vm_event_item.h +2 -0
@@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		VMACACHE_FIND_HITS,
 		VMACACHE_FULL_FLUSHES,
 #endif
+		SWAP_RA,
+		SWAP_RA_HIT,
 		NR_VM_EVENT_ITEMS
 };

swap_state.o isn't even compiled if CONFIG_SWAP=n so there doesn't seem much point in displaying these?

Oh, Yes! Thanks for pointing this out.

Best Regards,
Huang, Ying

Quoted 27 lines
include/linux/vm_event_item.h renamed from include/linux/vm_event_item.h~mm-swap-add-swap-readahead-hit-statistics-fix +2 -0
@@ -106,8 +106,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
 		VMACACHE_FIND_HITS,
 		VMACACHE_FULL_FLUSHES,
 #endif
+#ifdef CONFIG_SWAP
 		SWAP_RA,
 		SWAP_RA_HIT,
+#endif
 		NR_VM_EVENT_ITEMS
 };
 
mm/vmstat.c renamed from mm/vmstat.c~mm-swap-add-swap-readahead-hit-statistics-fix +2 -1
@@ -1098,9 +1098,10 @@ const char * const vmstat_text[] = {
 	"vmacache_find_hits",
 	"vmacache_full_flushes",
 #endif
-
+#ifdef CONFIG_SWAP
 	"swap_ra",
 	"swap_ra_hit",
+#endif
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
Quoted 1 line

_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
In reply to Huang, Ying
Quoted 15 lines · Ying

From: Huang Ying <[email protected]>

The swap readahead is an important mechanism to reduce the swap in latency. Although pure sequential memory access pattern isn't very popular for anonymous memory, the space locality is still considered valid.

In the original swap readahead implementation, the consecutive blocks in swap device are readahead based on the global space locality estimation. But the consecutive blocks in swap device just reflect the order of page reclaiming, don't necessarily reflect the access pattern in virtual memory. And the different tasks in the system may have different access patterns, which makes the global space locality estimation incorrect.

Quoted 9 lines

In this patch, when page fault occurs, the virtual pages near the fault address will be readahead instead of the swap slots near the fault swap slot in swap device. This avoid to readahead the unrelated swap slots. At the same time, the swap readahead is changed to work on per-VMA from globally. So that the different access patterns of the different VMAs could be distinguished, and the different readahead policy could be applied accordingly. The original core readahead detection and scaling algorithm is reused, because it is an effect algorithm to detect the space locality.

Andrew,

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

The discussion is never productive so it's time to follow maintainer's opinion. Could you share your opinion?

Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#7 lore raw
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

Hi, Andrew,

Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

This sounds good for me.

Hi, Minchan, what do you think about this? I think for low-end android device, the end-user may have no opportunity to upgrade to the latest kernel, the device vendor should care about this. For desktop users, the warning proposed by Andrew may help to remind them for the new knob.

Best Regards,
Huang, Ying

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw
In reply to Andrew Morton
Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

It was my last resort. If we cannot find other ways after all, yes, it would be a minimum we should do. But it still breaks users don't/can't read/modify alert and program.

How about this?

Can't we make vma-based readahead config option?
With that, users who no interest on readahead don't enable vma-based readahead. In this case, page-cluster works as expected "disable readahead completely" so it doesn't break anything.

People who want to use upcoming vma-based readahead can enable the feature and we can say such unfortunate things in config/document description somewhere so upcoming users will be aware of that unforunate two knobs.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw
In reply to Huang, Ying
Quoted 38 lines · Ying

Hi, Andrew,

Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

Quoted 6 lines

This sounds good for me.

Hi, Minchan, what do you think about this? I think for low-end android device, the end-user may have no opportunity to upgrade to the latest kernel, the device vendor should care about this. For desktop users, the warning proposed by Andrew may help to remind them for the new knob.

Yes, it would be option. At least, we should alert to the user to make a chance to fix. However, can't we make vma-based readahead new config option? Please look at the detail in my reply of andrew.

With that, there is no regression with current users and as a bonus, user can measure both algorithm with their real workload with both algorithm rather than artificial benchmark. I think recency vs spartial locality would have each pros and cons so that kind soft landing would be safer option rather than sudden replacing.
After a while, we can set new algorithm as default.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw
In reply to Minchan Kim
Quoted 39 lines · Minchan Kim
Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

It was my last resort. If we cannot find other ways after all, yes, it would be a minimum we should do. But it still breaks users don't/can't read/modify alert and program.

Quoted 6 lines

How about this?

Can't we make vma-based readahead config option?
With that, users who no interest on readahead don't enable vma-based readahead. In this case, page-cluster works as expected "disable readahead completely" so it doesn't break anything.

Now. Users can choose between VMA based readahead and original readahead via a knob as follow at runtime,

/sys/kernel/mm/swap/vma_ra_enabled

Best Regards,
Huang, Ying

Quoted 3 lines

People who want to use upcoming vma-based readahead can enable the feature and we can say such unfortunate things in config/document description somewhere so upcoming users will be aware of that unforunate two knobs.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw
Quoted 48 lines · Ying
Quoted 39 lines · Minchan Kim
Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

It was my last resort. If we cannot find other ways after all, yes, it would be a minimum we should do. But it still breaks users don't/can't read/modify alert and program.

Quoted 6 lines

How about this?

Can't we make vma-based readahead config option?
With that, users who no interest on readahead don't enable vma-based readahead. In this case, page-cluster works as expected "disable readahead completely" so it doesn't break anything.

Quoted 4 lines

Now. Users can choose between VMA based readahead and original readahead via a knob as follow at runtime,

/sys/kernel/mm/swap/vma_ra_enabled

It's not a config option and is enabled by default. IOW, it's under the radar so current users cannot notice it. That's why we want to emit big fat warnning. when old user set 0 to page-cluster. However, as Andrew said, it's lame.

If we make it config option, product maker/kernel upgrade user can have a chance to notice and read description so they could be aware of two weird knobs and help to solve the problem in advance without printk_once warn. If user has no interest about swap-readahead or skip the new config option by mistake, it works physcial readahead which means no regression.

Quoted 8 lines

Best Regards,
Huang, Ying

Quoted 3 lines

People who want to use upcoming vma-based readahead can enable the feature and we can say such unfortunate things in config/document description somewhere so upcoming users will be aware of that unforunate two knobs.

maintainer
#13 lore raw
Quoted 9 lines · On Thu, 14 Sep 2017 22:14:46 +0900 Minchan Kim <[email protected]> wrote:
Quoted 4 lines

Now. Users can choose between VMA based readahead and original readahead via a knob as follow at runtime,

/sys/kernel/mm/swap/vma_ra_enabled

It's not a config option and is enabled by default. IOW, it's under the radar so current users cannot notice it. That's why we want to emit big fat warnning. when old user set 0 to page-cluster. However, as Andrew said, it's lame.

Quoted 5 lines

If we make it config option, product maker/kernel upgrade user can have a chance to notice and read description so they could be aware of two weird knobs and help to solve the problem in advance without printk_once warn. If user has no interest about swap-readahead or skip the new config option by mistake, it works physcial readahead which means no regression.

Yup, a Kconfig option sounds like a good idea. And that's a bit more friendly to tiny kernels as well.

#14 lore raw
In reply to Minchan Kim
Quoted 58 lines · Minchan Kim
Quoted 48 lines · Ying
Quoted 39 lines · Minchan Kim
Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

It was my last resort. If we cannot find other ways after all, yes, it would be a minimum we should do. But it still breaks users don't/can't read/modify alert and program.

Quoted 6 lines

How about this?

Can't we make vma-based readahead config option?
With that, users who no interest on readahead don't enable vma-based readahead. In this case, page-cluster works as expected "disable readahead completely" so it doesn't break anything.

Quoted 4 lines

Now. Users can choose between VMA based readahead and original readahead via a knob as follow at runtime,

/sys/kernel/mm/swap/vma_ra_enabled

It's not a config option and is enabled by default. IOW, it's under the radar so current users cannot notice it. That's why we want to emit big fat warnning. when old user set 0 to page-cluster. However, as Andrew said, it's lame.

Quoted 5 lines

If we make it config option, product maker/kernel upgrade user can have a chance to notice and read description so they could be aware of two weird knobs and help to solve the problem in advance without printk_once warn. If user has no interest about swap-readahead or skip the new config option by mistake, it works physcial readahead which means no regression.

I am OK to make it config option. But I think VMA based swap readahead should be enabled by default. Because per my understanding, default option should be set for most common desktop users. And VMA based swap readahead should benefit them. People needs to turn off swap readahead is some special users, the original swap readahead default configuration isn't for them too.

Best Regards,
Huang, Ying

Quoted 8 lines
Quoted 8 lines

Best Regards,
Huang, Ying

Quoted 3 lines

People who want to use upcoming vma-based readahead can enable the feature and we can say such unfortunate things in config/document description somewhere so upcoming users will be aware of that unforunate two knobs.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw
Quoted 66 lines · Ying
Quoted 58 lines · Minchan Kim
Quoted 48 lines · Ying
Quoted 39 lines · Minchan Kim
Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

It was my last resort. If we cannot find other ways after all, yes, it would be a minimum we should do. But it still breaks users don't/can't read/modify alert and program.

Quoted 6 lines

How about this?

Can't we make vma-based readahead config option?
With that, users who no interest on readahead don't enable vma-based readahead. In this case, page-cluster works as expected "disable readahead completely" so it doesn't break anything.

Quoted 4 lines

Now. Users can choose between VMA based readahead and original readahead via a knob as follow at runtime,

/sys/kernel/mm/swap/vma_ra_enabled

It's not a config option and is enabled by default. IOW, it's under the radar so current users cannot notice it. That's why we want to emit big fat warnning. when old user set 0 to page-cluster. However, as Andrew said, it's lame.

Quoted 5 lines

If we make it config option, product maker/kernel upgrade user can have a chance to notice and read description so they could be aware of two weird knobs and help to solve the problem in advance without printk_once warn. If user has no interest about swap-readahead or skip the new config option by mistake, it works physcial readahead which means no regression.

Quoted 6 lines

I am OK to make it config option. But I think VMA based swap readahead should be enabled by default. Because per my understanding, default option should be set for most common desktop users. And VMA based swap readahead should benefit them. People needs to turn off swap readahead is some special users, the original swap readahead default configuration isn't for them too.

Okay. I don't care either one is default if it is a config option. It still gives a chance to notice a new algorithm so users can decide it It is absolutely better than silent regressoin and printk tric. Please add more description about those parallel two readahead algorithms in somewhere(e.g., vm.txt) so he can understand the situation exactly and can handle both tunable knobs at the same time.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#16 lore raw
Quoted 74 lines · Minchan Kim
Quoted 66 lines · Ying
Quoted 58 lines · Minchan Kim
Quoted 48 lines · Ying
Quoted 39 lines · Minchan Kim
Quoted 25 lines · Andrew Morton
Quoted 13 lines · On Wed, 13 Sep 2017 10:40:19 +0900 Minchan Kim <[email protected]> wrote:

Every zram users like low-end android device has used 0 page-cluster to disable swap readahead because it has no seek cost and works as synchronous IO operation so if we do readahead multiple pages, swap falut latency would be (4K * readahead window size). IOW, readahead is meaningful only if it doesn't bother faulted page's latency.

However, this patch introduces additional knob /sys/kernel/mm/swap/ vma_ra_max_order as well as page-cluster. It means existing users has used disabled swap readahead doesn't work until they should be aware of new knob and modification of their script/code to disable vma_ra_max_order as well as page-cluster.

Quoted 5 lines

I say it's a *regression* and wanted to fix it but Huang's opinion is that it's not a functional regression so userspace should be fixed by themselves.
Please look into detail of discussion in
http://lkml.kernel.org/r/%[email protected]%3E

hm, tricky problem. I do agree that linking the physical and virtual readahead schemes in the proposed fashion is unfortunate. I also agree that breaking existing setups (a bit) is also unfortunate.

Quoted 8 lines

Would it help if, when page-cluster is written to zero, we do

printk_once("physical readahead disabled, virtual readahead still enabled. Disable virtual readhead via /sys/kernel/mm/swap/vma_ra_max_order").

Or something like that. It's pretty lame, but it should help alert the zram-readahead-disabling people to the issue?

It was my last resort. If we cannot find other ways after all, yes, it would be a minimum we should do. But it still breaks users don't/can't read/modify alert and program.

Quoted 6 lines

How about this?

Can't we make vma-based readahead config option?
With that, users who no interest on readahead don't enable vma-based readahead. In this case, page-cluster works as expected "disable readahead completely" so it doesn't break anything.

Quoted 4 lines

Now. Users can choose between VMA based readahead and original readahead via a knob as follow at runtime,

/sys/kernel/mm/swap/vma_ra_enabled

It's not a config option and is enabled by default. IOW, it's under the radar so current users cannot notice it. That's why we want to emit big fat warnning. when old user set 0 to page-cluster. However, as Andrew said, it's lame.

Quoted 5 lines

If we make it config option, product maker/kernel upgrade user can have a chance to notice and read description so they could be aware of two weird knobs and help to solve the problem in advance without printk_once warn. If user has no interest about swap-readahead or skip the new config option by mistake, it works physcial readahead which means no regression.

Quoted 6 lines

I am OK to make it config option. But I think VMA based swap readahead should be enabled by default. Because per my understanding, default option should be set for most common desktop users. And VMA based swap readahead should benefit them. People needs to turn off swap readahead is some special users, the original swap readahead default configuration isn't for them too.

Quoted 6 lines

Okay. I don't care either one is default if it is a config option. It still gives a chance to notice a new algorithm so users can decide it It is absolutely better than silent regressoin and printk tric. Please add more description about those parallel two readahead algorithms in somewhere(e.g., vm.txt) so he can understand the situation exactly and can handle both tunable knobs at the same time.

Sure.

Best Regards,
Huang, Ying