linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike kravetz <mike.kravetz@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-man@vger.kernel.org, linux-mm@kvack.org,
	David Hildenbrand <david@redhat.com>,
	Muchun Song <songmuchun@bytedance.com>,
	Naoya Horiguchi <naoya.horiguchi@linux.dev>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Michal Hocko <mhocko@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] hugetlbfs: zero partial pages during fallocate hole punch
Date: Mon, 13 Jun 2022 11:36:30 -0700	[thread overview]
Message-ID: <YqeDriDTVtoPrY+t@monkey> (raw)
In-Reply-To: <YqeCPljxCJfMgA2Y@casper.infradead.org>

On Mon, Jun 13, 2022 at 07:30:22PM +0100”, Matthew Wilcox wrote:
> On Mon, Jun 13, 2022 at 11:08:58AM -0700, Mike Kravetz wrote:
> > diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> > index eca1d0fabd7e..b0d0947a7e9b 100644
> > --- a/fs/hugetlbfs/inode.c
> > +++ b/fs/hugetlbfs/inode.c
> > @@ -584,41 +584,79 @@ static void hugetlb_vmtruncate(struct inode *inode, loff_t offset)
> >  	remove_inode_hugepages(inode, offset, LLONG_MAX);
> >  }
> >  
> > +static void hugetlbfs_zero_partial_page(struct hstate *h,
> > +					struct address_space *mapping,
> > +					unsigned long start,
> 
> This should be loff_t.  Otherwise we can truncate on 32-bit machines.
> 

Thanks!  I missed that.

> > +					unsigned long end)
> > +{
> > +	pgoff_t idx = start >> huge_page_shift(h);
> > +	struct page *page;
> > +
> > +	page = find_lock_page(mapping, idx);
> > +	if (!page)
> > +		return;
> > +
> > +	start = start & ~huge_page_mask(h);
> > +	end = end & ~huge_page_mask(h);
> > +	if (!end)
> > +		end = huge_page_size(h);
> > +
> > +	zero_user_segment(page, (unsigned int)start, (unsigned int)end);
> > +
> > +	unlock_page(page);
> > +	put_page(page);
> 
> We haven't started converting hugetlbfs to folios yet, but here's how
> that would look (which will save us converting it later):
> 
> 	folio = filemap_lock_folio(mapping, idx);
> 	if (!folio)
> 		return;
> ...
> 	folio_zero_segment(folio, start, end);
> 	folio_unlock(folio);
> 	folio_put(folio);
> 
> Pretty much a 1-for-1 replacement.
> 

Great.  The folio conversion is on my todo list, but I would not be
offended if someone beat me to it.
-- 
Mike Kravetz


  reply	other threads:[~2022-06-13 18:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 18:08 Mike Kravetz
2022-06-13 18:30 ` Matthew Wilcox
2022-06-13 18:36   ` Mike kravetz [this message]
2022-06-13 18:57     ` Andrew Morton
2022-06-13 20:11       ` Mike Kravetz
2022-06-13 20:46 ` Mike Kravetz
2022-06-14 15:03   ` Muchun Song

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=YqeDriDTVtoPrY+t@monkey \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=dave.hansen@intel.com \
    --cc=david@redhat.com \
    --cc=linux-man@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=naoya.horiguchi@linux.dev \
    --cc=songmuchun@bytedance.com \
    --cc=willy@infradead.org \
    /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