linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] swap: do not skip lowest_bit in scan_swap_map() scan loop
@ 2014-01-22  2:21 Jamie Liu
  2014-01-22  7:00 ` Hugh Dickins
  0 siblings, 1 reply; 2+ messages in thread
From: Jamie Liu @ 2014-01-22  2:21 UTC (permalink / raw)
  To: Andrew Morton, Shaohua Li, Hugh Dickins
  Cc: Minchan Kim, Akinobu Mita, linux-mm, linux-kernel, Jamie Liu

In the second half of scan_swap_map()'s scan loop, offset is set to
si->lowest_bit and then incremented before entering the loop for the
first time, causing si->swap_map[si->lowest_bit] to be skipped.

Signed-off-by: Jamie Liu <jamieliu@google.com>
---
 mm/swapfile.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 612a7c9..6635081 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -616,7 +616,7 @@ scan:
 		}
 	}
 	offset = si->lowest_bit;
-	while (++offset < scan_base) {
+	while (offset < scan_base) {
 		if (!si->swap_map[offset]) {
 			spin_lock(&si->lock);
 			goto checks;
@@ -629,6 +629,7 @@ scan:
 			cond_resched();
 			latency_ration = LATENCY_LIMIT;
 		}
+		offset++;
 	}
 	spin_lock(&si->lock);
 
-- 
1.8.5.3

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] swap: do not skip lowest_bit in scan_swap_map() scan loop
  2014-01-22  2:21 [PATCH] swap: do not skip lowest_bit in scan_swap_map() scan loop Jamie Liu
@ 2014-01-22  7:00 ` Hugh Dickins
  0 siblings, 0 replies; 2+ messages in thread
From: Hugh Dickins @ 2014-01-22  7:00 UTC (permalink / raw)
  To: Jamie Liu
  Cc: Andrew Morton, Shaohua Li, Minchan Kim, Akinobu Mita, linux-mm,
	linux-kernel

On Tue, 21 Jan 2014, Jamie Liu wrote:

> In the second half of scan_swap_map()'s scan loop, offset is set to
> si->lowest_bit and then incremented before entering the loop for the
> first time, causing si->swap_map[si->lowest_bit] to be skipped.
> 
> Signed-off-by: Jamie Liu <jamieliu@google.com>

Acked-by: Hugh Dickins <hughd@google.com>

Good catch.  At first I was puzzled that this off-by-one could have
gone unnoticed for so long (ever since 2.6.29); but now I think that
almost always we have a good amount of slack, in those pages duplicated
between swap and swapcache, which can be reclaimed at the vm_swap_full()
check, and so conceal this loss of a single slot.

> ---
>  mm/swapfile.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 612a7c9..6635081 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -616,7 +616,7 @@ scan:
>  		}
>  	}
>  	offset = si->lowest_bit;
> -	while (++offset < scan_base) {
> +	while (offset < scan_base) {
>  		if (!si->swap_map[offset]) {
>  			spin_lock(&si->lock);
>  			goto checks;
> @@ -629,6 +629,7 @@ scan:
>  			cond_resched();
>  			latency_ration = LATENCY_LIMIT;
>  		}
> +		offset++;
>  	}
>  	spin_lock(&si->lock);
>  
> -- 
> 1.8.5.3
> 
> 

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-22  7:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-22  2:21 [PATCH] swap: do not skip lowest_bit in scan_swap_map() scan loop Jamie Liu
2014-01-22  7:00 ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox