Re: [PATCH] mm/memfd_luo: use real folio index in retrieve error logs

Pratyush Yadav <[email protected]>
Newsgroups org.infradead.lists.kexec,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On Thu, Aug 06 2026, Giorgi Tchankvetadze wrote:

> From: Giorgi Tchankvetadze <[email protected]>
>
> memfd_luo_retrieve_folios() logs "folio index %ld" on its error paths
> but passes the loop counter 'i' instead of the folio's actual index
> held in the local 'index' variable (pfolio->index).
>
> Pass 'index' to the three pr_err() calls so the logged index matches
> the folio that actually failed. Since the saved index is a u64, use %llu with an
> unsigned long long cast when printing it.
>
> Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd")
> Signed-off-by: Giorgi Tchankvetadze <[email protected]>
> ---
>  mm/memfd_luo.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
> index 59de210bee5f..652dd21e6ef0 100644
> --- a/mm/memfd_luo.c
> +++ b/mm/memfd_luo.c
> @@ -451,16 +451,16 @@ static int memfd_luo_retrieve_folios(struct file *file,
>  
>  		err = mem_cgroup_charge(folio, NULL, mapping_gfp_mask(mapping));
>  		if (err) {
> -			pr_err("shmem: failed to charge folio index %ld: %d\n",
> -			       i, err);
> +			pr_err("shmem: failed to charge folio index %llu: %d\n",
> +			       (unsigned long long)index, err);

Why the cast here? u64 is always printed by %llu. See
Documentation/core-api/printk-formats.rst.

>  			goto unlock_folio;
>  		}
>  
>  		err = shmem_add_to_page_cache(folio, mapping, index, NULL,
>  					      mapping_gfp_mask(mapping));
>  		if (err) {
> -			pr_err("shmem: failed to add to page cache folio index %ld: %d\n",
> -			       i, err);
> +			pr_err("shmem: failed to add to page cache folio index %llu: %d\n",
> +			       (unsigned long long)index, err);
>  			goto unlock_folio;
>  		}
>  
> @@ -472,8 +472,8 @@ static int memfd_luo_retrieve_folios(struct file *file,
>  		npages = folio_nr_pages(folio);
>  		err = shmem_inode_acct_blocks(inode, npages);
>  		if (err) {
> -			pr_err("shmem: failed to account folio index %ld(%ld pages): %d\n",
> -			       i, npages, err);
> +			pr_err("shmem: failed to account folio index %llu(%ld pages): %d\n",
> +			       (unsigned long long)index, npages, err);
>  			goto remove_from_cache;
>  		}

-- 
Regards,
Pratyush Yadav
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.