linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Peng Zhang <zhangpeng362@huawei.com>,
	linux-mm@kvack.org, willy@infradead.org
Cc: akpm@linux-foundation.org, wangkefeng.wang@huawei.com,
	sunnanyong@huawei.com
Subject: Re: [PATCH v2] mm/secretmem: use a folio in secretmem_fault()
Date: Wed, 16 Aug 2023 11:17:45 +0200	[thread overview]
Message-ID: <6d58c4b4-b1d4-bc88-282c-10f90c59084b@redhat.com> (raw)
In-Reply-To: <20230812062612.3184990-1-zhangpeng362@huawei.com>

On 12.08.23 08:26, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
> 
> Saves four implicit call to compound_head().
> 
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> v2: update commit message per Matthew Wilcox
> ---
>   mm/secretmem.c | 14 ++++++++------
>   1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/secretmem.c b/mm/secretmem.c
> index 86442a15d12f..3afb5ad701e1 100644
> --- a/mm/secretmem.c
> +++ b/mm/secretmem.c
> @@ -55,6 +55,7 @@ static vm_fault_t secretmem_fault(struct vm_fault *vmf)
>   	gfp_t gfp = vmf->gfp_mask;
>   	unsigned long addr;
>   	struct page *page;
> +	struct folio *folio;
>   	vm_fault_t ret;
>   	int err;
>   
> @@ -66,23 +67,24 @@ static vm_fault_t secretmem_fault(struct vm_fault *vmf)
>   retry:
>   	page = find_lock_page(mapping, offset);
>   	if (!page) {
> -		page = alloc_page(gfp | __GFP_ZERO);
> -		if (!page) {
> +		folio = folio_alloc(gfp | __GFP_ZERO, 0);
> +		if (!folio) {
>   			ret = VM_FAULT_OOM;
>   			goto out;
>   		}
>   
> +		page = &folio->page;
>   		err = set_direct_map_invalid_noflush(page);
>   		if (err) {
> -			put_page(page);
> +			folio_put(folio);
>   			ret = vmf_error(err);
>   			goto out;
>   		}
>   
> -		__SetPageUptodate(page);
> -		err = add_to_page_cache_lru(page, mapping, offset, gfp);
> +		__folio_mark_uptodate(folio);
> +		err = filemap_add_folio(mapping, folio, offset, gfp);
>   		if (unlikely(err)) {
> -			put_page(page);
> +			folio_put(folio);
>   			/*
>   			 * If a split of large page was required, it
>   			 * already happened when we marked the page invalid

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



      reply	other threads:[~2023-08-16  9:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-12  6:26 [PATCH v2] mm/secretmem: use a folio in secretmem_fault() Peng Zhang
2023-08-16  9:17 ` David Hildenbrand [this message]

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=6d58c4b4-b1d4-bc88-282c-10f90c59084b@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=sunnanyong@huawei.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=zhangpeng362@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).