Re: [PATCH 3/6] shmem: account for large order folios

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

 



On Fri, Sep 15, 2023 at 09:51:26AM +0000, Daniel Gomez wrote:
> +	xas_for_each(&xas, folio, max) {
> +		if (xas_retry(&xas, folio))
>  			continue;
> -		if (xa_is_value(page))
> -			swapped++;
> +		if (xa_is_value(folio))
> +			swapped += (folio_nr_pages(folio));

Unnecessary parens.

> @@ -1006,10 +1006,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
>  			folio = fbatch.folios[i];
>  
>  			if (xa_is_value(folio)) {
> +				long swaps_freed;
>  				if (unfalloc)
>  					continue;
> -				nr_swaps_freed += !shmem_free_swap(mapping,
> -							indices[i], folio);
> +				swaps_freed = folio_nr_pages(folio);
> +				if (!shmem_free_swap(mapping, indices[i], folio))
> +					nr_swaps_freed += swaps_freed;

Broader change (indeed, in a separate patch), why not make
shmem_free_swap() return the number of pages freed, rather than
returning an errno?

> @@ -1075,14 +1077,16 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
>  			folio = fbatch.folios[i];
>  
>  			if (xa_is_value(folio)) {
> +				long swaps_freed;
>  				if (unfalloc)
>  					continue;
> +				swaps_freed = folio_nr_pages(folio);
>  				if (shmem_free_swap(mapping, indices[i], folio)) {
>  					/* Swap was replaced by page: retry */
>  					index = indices[i];
>  					break;
>  				}
> -				nr_swaps_freed++;
> +				nr_swaps_freed += swaps_freed;
>  				continue;

... seems like both callers would prefer that.




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux