diff mbox series

mm: fix shrink nr.unqueued_dirty counter issue

Message ID 20240112012353.1387-1-justinjiang@vivo.com (mailing list archive)
State New
Headers show
Series mm: fix shrink nr.unqueued_dirty counter issue | expand

Commit Message

zhiguojiang Jan. 12, 2024, 1:23 a.m. UTC
It is needed to ensure sc->nr.unqueued_dirty > 0, which can avoid to
set PGDAT_DIRTY flag when sc->nr.unqueued_dirty and sc->nr.file_taken
are both zero at the same time.

Signed-off-by: Zhiguo Jiang <justinjiang@vivo.com>
---
 mm/vmscan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 mm/vmscan.c

Comments

Andrew Morton Sept. 25, 2024, 8:51 p.m. UTC | #1
On Fri, 12 Jan 2024 09:23:52 +0800 Zhiguo Jiang <justinjiang@vivo.com> wrote:

> It is needed to ensure sc->nr.unqueued_dirty > 0, which can avoid to
> set PGDAT_DIRTY flag when sc->nr.unqueued_dirty and sc->nr.file_taken
> are both zero at the same time.
> 
> ...
>
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -5957,7 +5957,8 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
>  			set_bit(PGDAT_WRITEBACK, &pgdat->flags);
>  
>  		/* Allow kswapd to start writing pages during reclaim.*/
> -		if (sc->nr.unqueued_dirty == sc->nr.file_taken)
> +		if (sc->nr.unqueued_dirty &&
> +			sc->nr.unqueued_dirty == sc->nr.file_taken)
>  			set_bit(PGDAT_DIRTY, &pgdat->flags);
>  

Seems sensible.  Was this discovered by code inspection, or is there
some observable runtime effect?  If the latter, can you please describe
that effect?
diff mbox series

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 91e7d334a7ca..7c0cd7ecdfab
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -5957,7 +5957,8 @@  static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 			set_bit(PGDAT_WRITEBACK, &pgdat->flags);
 
 		/* Allow kswapd to start writing pages during reclaim.*/
-		if (sc->nr.unqueued_dirty == sc->nr.file_taken)
+		if (sc->nr.unqueued_dirty &&
+			sc->nr.unqueued_dirty == sc->nr.file_taken)
 			set_bit(PGDAT_DIRTY, &pgdat->flags);
 
 		/*