Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	Jane Chu <jane.chu@oracle.com>,
	linux-mm@kvack.org
Cc: Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	David Hildenbrand <david@kernel.org>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Naoya Horiguchi <nao.horiguchi@gmail.com>,
	Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org,
	Christian Brauner <christian@brauner.io>,
	Jiaqi Yan <jiaqiyan@google.com>
Subject: Re: [PATCH v5 11/12] filemap: Add support for authoritative mappings
Date: Mon, 27 Jul 2026 16:55:37 +0100	[thread overview]
Message-ID: <amd_eb908Co9JeyH@casper.infradead.org> (raw)
In-Reply-To: <20260725160042.1557264-12-willy@infradead.org>

Sashiko:
> --- Patch [11]: [PATCH v5 11/12] filemap: Add support for authoritative mappings ---
> commit 7b270a787d853107f7a64dd3127d799a28d3142e
> Author: Matthew Wilcox (Oracle) <willy@infradead.org>
> 
> filemap: Add support for authoritative mappings
> 
> An authoritative mapping knows about all the folios in the mapping.
> If read() finds a missing folio, there's no reason to allocate one and
> try to read it because we know it's a zero region of the file.  We can
> just call iov_iter_zero() instead.
> 
> > diff --git a/mm/filemap.c b/mm/filemap.c
> > index 26a5f18121f90..5a8cc20e624e4 100644
> > --- a/mm/filemap.c
> > +++ b/mm/filemap.c
> > @@ -2697,6 +2697,8 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count,
> >  	if (!folio_batch_count(fbatch)) {
> >  		DEFINE_READAHEAD(ractl, filp, &filp->f_ra, mapping, index);
> >  
> > +		if (mapping_is_authoritative(mapping))
> > +			return 0;
> 
> Does returning 0 here cause an infinite loop in filemap_splice_read()?

As before, hugetlb doesn't use splice_read() so adding support would be
dead untestable code.  We'll add support here when we need it.

> > @@ -2853,6 +2855,22 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
> >  			goto put_folios;
> >  		end_offset = min_t(loff_t, isize, iocb->ki_pos + iter->count);
> >  
> > +		if (!folio_batch_count(&fbatch)) {
> > +			size_t fsize = mapping_min_folio_nrbytes(mapping);
> > +			size_t offset = iocb->ki_pos & (fsize - 1);
> > +			size_t bytes = min_t(loff_t, end_offset - iocb->ki_pos,
> > +					     fsize - offset);
> > +			size_t copied = iov_iter_zero(bytes, iter);
> > +
> > +			already_read += copied;
> > +			iocb->ki_pos += copied;
> > +			last_pos = iocb->ki_pos;
> > +
> > +			if (copied < bytes)
> > +				error = -EFAULT;
> > +			continue;
> > +		}
> 
> Should filemap_fault() also be updated to handle authoritative mappings?

Eventually, if hugetlbfs is ever converted to use filemap_fault().
As above, it'd be dead code.


That's it for interesting Sashiko reviews.  I've omitted some which
are suplicates, either within this patch series or have been reported
against previous patch series.  Feels like we're close!


  reply	other threads:[~2026-07-27 15:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25 16:00 [PATCH v5 00/12] Use generic_file_read_iter() in hugetlbfs Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 01/12] memory-failure: Fix hardware poison check in unpoison_memory() again Matthew Wilcox (Oracle)
2026-07-27 14:43   ` Matthew Wilcox
2026-07-27 19:40     ` Andrew Morton
2026-07-25 16:00 ` [PATCH v5 02/12] mm: Rename folio_contain_hwpoison_page() to folio_has_hwpoison_page() Matthew Wilcox (Oracle)
2026-07-27 14:51   ` Matthew Wilcox
2026-07-25 16:00 ` [PATCH v5 03/12] hugetlb: Mark some function arguments as const Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 04/12] guest_memfd: Use folio_has_hwpoisoned_page() Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 05/12] hugetlb: Use the has_hwpoisoned flag Matthew Wilcox (Oracle)
2026-07-27 15:19   ` Matthew Wilcox
2026-07-25 16:00 ` [PATCH v5 06/12] mm: Remove locking mf_mutex in is_raw_hwpoison_page_in_hugepage() Matthew Wilcox (Oracle)
2026-07-27 15:32   ` Matthew Wilcox
2026-07-25 16:00 ` [PATCH v5 07/12] mm: Check individual hugetlb pages for poison Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 08/12] filemap: Add hwpoison handling to filemap_read() Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 09/12] filemap: Remove checks in mapping_set_folio_order_range() Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 10/12] hugetlb: Set mapping folio order Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 11/12] filemap: Add support for authoritative mappings Matthew Wilcox (Oracle)
2026-07-27 15:55   ` Matthew Wilcox [this message]
2026-07-25 16:00 ` [PATCH v5 12/12] hugetlb: replace hugetlbfs_read_iter() with generic_file_read_iter() Matthew Wilcox (Oracle)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=amd_eb908Co9JeyH@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=christian@brauner.io \
    --cc=david@kernel.org \
    --cc=jack@suse.cz \
    --cc=jane.chu@oracle.com \
    --cc=jiaqiyan@google.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=nao.horiguchi@gmail.com \
    --cc=osalvador@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox