linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/page-writeback.c: write_cache_pages(): deduplicate identical checks
@ 2020-02-18 22:17 Mauricio Faria de Oliveira
  2020-02-19  0:20 ` Ira Weiny
  0 siblings, 1 reply; 2+ messages in thread
From: Mauricio Faria de Oliveira @ 2020-02-18 22:17 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

There used to be a 'retry' label in between the two (identical) checks
when first introduced in commit f446daaea9d4 ("mm: implement writeback
livelock avoidance using page tagging"), and later modified/updated in
commit 6e6938b6d313 ("writeback: introduce .tagged_writepages for the
WB_SYNC_NONE sync stage").

The label has been removed in commit 64081362e8ff ("mm/page-writeback.c:
fix range_cyclic writeback vs writepages deadlock"), and the (identical)
checks are now present / performed immediately one after another.

So, remove/deduplicate the latter check, moving tag_pages_for_writeback()
into the former check before the 'tag' variable assignment, so it's clear
that it's not used in this (similarly-named) function call but only later
in pagevec_lookup_range_tag().

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
---

 v2: add the missing braces to the conditional statement
     with more than a single statement.. doh; and to the
     else branch (w/a single statement, per coding style.)

 mm/page-writeback.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 2caf780a42e7..ab5a3cee8ad3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2182,12 +2182,12 @@ int write_cache_pages(struct address_space *mapping,
 		if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
 			range_whole = 1;
 	}
-	if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
+	if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) {
+		tag_pages_for_writeback(mapping, index, end);
 		tag = PAGECACHE_TAG_TOWRITE;
-	else
+	} else {
 		tag = PAGECACHE_TAG_DIRTY;
-	if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
-		tag_pages_for_writeback(mapping, index, end);
+	}
 	done_index = index;
 	while (!done && (index <= end)) {
 		int i;
-- 
2.20.1



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

* Re: [PATCH v2] mm/page-writeback.c: write_cache_pages(): deduplicate identical checks
  2020-02-18 22:17 [PATCH v2] mm/page-writeback.c: write_cache_pages(): deduplicate identical checks Mauricio Faria de Oliveira
@ 2020-02-19  0:20 ` Ira Weiny
  0 siblings, 0 replies; 2+ messages in thread
From: Ira Weiny @ 2020-02-19  0:20 UTC (permalink / raw)
  To: Mauricio Faria de Oliveira; +Cc: Andrew Morton, linux-mm, linux-kernel

On Tue, Feb 18, 2020 at 07:17:16PM -0300, Mauricio Faria de Oliveira wrote:
> There used to be a 'retry' label in between the two (identical) checks
> when first introduced in commit f446daaea9d4 ("mm: implement writeback
> livelock avoidance using page tagging"), and later modified/updated in
> commit 6e6938b6d313 ("writeback: introduce .tagged_writepages for the
> WB_SYNC_NONE sync stage").
> 
> The label has been removed in commit 64081362e8ff ("mm/page-writeback.c:
> fix range_cyclic writeback vs writepages deadlock"), and the (identical)
> checks are now present / performed immediately one after another.
> 
> So, remove/deduplicate the latter check, moving tag_pages_for_writeback()
> into the former check before the 'tag' variable assignment, so it's clear
> that it's not used in this (similarly-named) function call but only later
> in pagevec_lookup_range_tag().
> 
> Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> ---
> 
>  v2: add the missing braces to the conditional statement
>      with more than a single statement.. doh; and to the
>      else branch (w/a single statement, per coding style.)
> 
>  mm/page-writeback.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 2caf780a42e7..ab5a3cee8ad3 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2182,12 +2182,12 @@ int write_cache_pages(struct address_space *mapping,
>  		if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
>  			range_whole = 1;
>  	}
> -	if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> +	if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) {
> +		tag_pages_for_writeback(mapping, index, end);
>  		tag = PAGECACHE_TAG_TOWRITE;
> -	else
> +	} else {
>  		tag = PAGECACHE_TAG_DIRTY;
> -	if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> -		tag_pages_for_writeback(mapping, index, end);
> +	}
>  	done_index = index;
>  	while (!done && (index <= end)) {
>  		int i;
> -- 
> 2.20.1
> 


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

end of thread, other threads:[~2020-02-19  0:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 22:17 [PATCH v2] mm/page-writeback.c: write_cache_pages(): deduplicate identical checks Mauricio Faria de Oliveira
2020-02-19  0:20 ` Ira Weiny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).