Re: [RFC PATCH v1 08/10] mm: refactor clearing dirty stats into helper function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2025-07-31 at 17:21 -0700, Joanne Koong wrote:
> Move logic for clearing dirty stats into a helper function
> both folio_account_cleaned() and __folio_clear_dirty_for_io() invoke.
> 
> Signed-off-by: Joanne Koong <joannelkoong@xxxxxxxxx>
> ---
>  mm/page-writeback.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index c1fec76ee869..f5916711db2d 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2703,6 +2703,14 @@ static void folio_account_dirtied(struct folio *folio,
>  	}
>  }
>  
> +static void __clear_dirty_for_io_stats(struct folio *folio,
> +			struct bdi_writeback *wb, long nr_pages)
> +{
> +	lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, -nr_pages);
> +	zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr_pages);
> +	wb_stat_mod(wb, WB_RECLAIMABLE, -nr_pages);
> +}
> +
>  /*
>   * Helper function for deaccounting dirty page without writeback.
>   *
> @@ -2711,9 +2719,7 @@ void folio_account_cleaned(struct folio *folio, struct bdi_writeback *wb)
>  {
>  	long nr = folio_nr_pages(folio);
>  
> -	lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, -nr);
> -	zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr);
> -	wb_stat_mod(wb, WB_RECLAIMABLE, -nr);
> +	__clear_dirty_for_io_stats(folio, wb, nr);
>  	task_io_account_cancelled_write(nr * PAGE_SIZE);
>  }
>  
> @@ -2977,14 +2983,9 @@ static bool __folio_clear_dirty_for_io(struct folio *folio, bool update_stats)
>  		 */
>  		wb = unlocked_inode_to_wb_begin(inode, &cookie);
>  		if (folio_test_clear_dirty(folio)) {
> -			if (update_stats) {
> -				long nr = folio_nr_pages(folio);
> -				lruvec_stat_mod_folio(folio, NR_FILE_DIRTY,
> -						      -nr);
> -				zone_stat_mod_folio(folio,
> -						    NR_ZONE_WRITE_PENDING, -nr);
> -				wb_stat_mod(wb, WB_RECLAIMABLE, -nr);
> -			}
> +			if (update_stats)
> +				__clear_dirty_for_io_stats(folio, wb,
> +						folio_nr_pages(folio));
>  			ret = true;
>  		}
>  		unlocked_inode_to_wb_end(inode, &cookie);


This seems like a nice cleanup that isn't dependent on the rest of the
series.

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux