linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, vbabka@suse.cz, sj@kernel.org,
	Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH mm-unstable] mm: introduce folio_is_pfmemalloc
Date: Fri,  6 Jan 2023 23:23:52 +0000	[thread overview]
Message-ID: <20230106232352.1520-1-sj@kernel.org> (raw)
In-Reply-To: <20230106215251.599222-1-sidhartha.kumar@oracle.com>

Hi Sidhartha,


On Fri, 6 Jan 2023 15:52:51 -0600 Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote:

> Add a folio equivalent for page_is_pfmemalloc. This removes two instances
> of page_is_pfmemalloc(folio_page(folio, 0)) so the folio can be used
> directly.
> 
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

> ---
>  include/linux/mm.h | 15 +++++++++++++++
>  mm/slab.c          |  2 +-
>  mm/slub.c          |  2 +-
>  3 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index c37f9330f14e..79d5a0cbf4c3 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1906,6 +1906,21 @@ static inline bool page_is_pfmemalloc(const struct page *page)
>  	return (uintptr_t)page->lru.next & BIT(1);
>  }
>  
> +/*
> + * Return true only if the folio has been allocated with
> + * ALLOC_NO_WATERMARKS and the low watermark was not
> + * met implying that the system is under some pressure.
> + */
> +static inline bool folio_is_pfmemalloc(const struct folio *folio)
> +{
> +	/*
> +	 * lru.next has bit 1 set if the page is allocated from the
> +	 * pfmemalloc reserves.  Callers may simply overwrite it if
> +	 * they do not need to preserve that information.
> +	 */
> +	return (uintptr_t)folio->lru.next & BIT(1);
> +}
> +
>  /*
>   * Only to be called by the page allocator on a freshly allocated
>   * page.
> diff --git a/mm/slab.c b/mm/slab.c
> index 7a269db050ee..01291ecbc0d8 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1373,7 +1373,7 @@ static struct slab *kmem_getpages(struct kmem_cache *cachep, gfp_t flags,
>  	/* Make the flag visible before any changes to folio->mapping */
>  	smp_wmb();
>  	/* Record if ALLOC_NO_WATERMARKS was set when allocating the slab */
> -	if (sk_memalloc_socks() && page_is_pfmemalloc(folio_page(folio, 0)))
> +	if (sk_memalloc_socks() && folio_is_pfmemalloc(folio))
>  		slab_set_pfmemalloc(slab);
>  
>  	return slab;
> diff --git a/mm/slub.c b/mm/slub.c
> index 13459c69095a..0cbe6eff23fa 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1859,7 +1859,7 @@ static inline struct slab *alloc_slab_page(gfp_t flags, int node,
>  	__folio_set_slab(folio);
>  	/* Make the flag visible before any changes to folio->mapping */
>  	smp_wmb();
> -	if (page_is_pfmemalloc(folio_page(folio, 0)))
> +	if (folio_is_pfmemalloc(folio))
>  		slab_set_pfmemalloc(slab);
>  
>  	return slab;
> -- 
> 2.39.0
> 
> 


  parent reply	other threads:[~2023-01-06 23:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 21:52 Sidhartha Kumar
2023-01-06 23:07 ` Matthew Wilcox
2023-01-06 23:23 ` SeongJae Park [this message]
2023-01-11 15:43 ` Vlastimil Babka

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=20230106232352.1520-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sidhartha.kumar@oracle.com \
    --cc=vbabka@suse.cz \
    --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