linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/5] mm: Add vma_alloc_zeroed_movable_folio()
Date: Thu, 19 Jan 2023 13:57:36 +0000	[thread overview]
Message-ID: <Y8lMUGgM5bu1qndi@casper.infradead.org> (raw)
In-Reply-To: <Y8kYbL5rZswU++NN@kernel.org>

On Thu, Jan 19, 2023 at 12:16:12PM +0200, Mike Rapoport wrote:
> > +static inline
> > +struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma,
> >  				   unsigned long vaddr)
> >  {
> > -	struct page *page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vaddr);
> > +	struct folio *folio;
> >  
> > -	if (page)
> > -		clear_user_highpage(page, vaddr);
> > +	folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr, false);
> 
> Add __GFP_ZERO and simply return vma_alloc_folio(...)?
> 
> > +	if (folio)
> > +		clear_user_highpage(&folio->page, vaddr);

This page is about to be mapped into userspace; the kernel isn't going
to touch the data in it.  So we don't care if the kernel's view of this
page contains zeroes, only that the userspace view of this page contains
zeroes.  The architectures that override this do exactly what you
suggest, but they know they have a physical cache and so that works for
them.  For virtually indexed caches, this is more efficient.



  reply	other threads:[~2023-01-19 13:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 19:18 [PATCH 0/5] Convert various functions in memory.c to use folios Matthew Wilcox (Oracle)
2023-01-16 19:18 ` [PATCH 1/5] mm: Add vma_alloc_zeroed_movable_folio() Matthew Wilcox (Oracle)
2023-01-19 10:16   ` Mike Rapoport
2023-01-19 13:57     ` Matthew Wilcox [this message]
2023-01-19 18:22   ` Zi Yan
2023-01-16 19:18 ` [PATCH 2/5] mm: Convert do_anonymous_page() to use a folio Matthew Wilcox (Oracle)
2023-01-19 18:23   ` Zi Yan
2023-01-16 19:18 ` [PATCH 3/5] mm: Convert wp_page_copy() to use folios Matthew Wilcox (Oracle)
2023-01-19 18:29   ` Zi Yan
2023-01-16 19:18 ` [PATCH 4/5] mm: Use a folio in copy_pte_range() Matthew Wilcox (Oracle)
2023-01-19 18:32   ` Zi Yan
2023-01-16 19:18 ` [PATCH 5/5] mm: Use a folio in copy_present_pte() Matthew Wilcox (Oracle)
2023-01-19 18:33   ` Zi Yan
2023-01-21  9:22 ` [PATCH 0/5] Convert various functions in memory.c to use folios Mike Rapoport

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=Y8lMUGgM5bu1qndi@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.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