From: Song Liu <songliubraving@fb.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Linux MM <linux-mm@kvack.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
Kirill Shutemov <kirill@shutemov.name>,
William Kucharski <william.kucharski@oracle.com>,
Johannes Weiner <jweiner@fb.com>
Subject: Re: [PATCH 1/3] mm: Add __page_cache_alloc_order
Date: Thu, 5 Sep 2019 18:58:53 +0000 [thread overview]
Message-ID: <75104154-A1A4-4FE3-920C-0069E1B5848D@fb.com> (raw)
In-Reply-To: <20190905182348.5319-2-willy@infradead.org>
> On Sep 5, 2019, at 11:23 AM, Matthew Wilcox <willy@infradead.org> wrote:
>
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
>
> This new function allows page cache pages to be allocated that are
> larger than an order-0 page.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/pagemap.h | 14 +++++++++++---
> mm/filemap.c | 11 +++++++----
> 2 files changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 103205494ea0..d2147215d415 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -208,14 +208,22 @@ static inline int page_cache_add_speculative(struct page *page, int count)
> }
>
> #ifdef CONFIG_NUMA
> -extern struct page *__page_cache_alloc(gfp_t gfp);
> +extern struct page *__page_cache_alloc_order(gfp_t gfp, unsigned int order);
I guess we need __page_cache_alloc(gfp_t gfp) here for CONFIG_NUMA.
> #else
> -static inline struct page *__page_cache_alloc(gfp_t gfp)
> +static inline
> +struct page *__page_cache_alloc_order(gfp_t gfp, unsigned int order)
> {
> - return alloc_pages(gfp, 0);
> + if (order > 0)
> + gfp |= __GFP_COMP;
> + return alloc_pages(gfp, order);
> }
> #endif
>
> +static inline struct page *__page_cache_alloc(gfp_t gfp)
> +{
> + return __page_cache_alloc_order(gfp, 0);
Maybe "return alloc_pages(gfp, 0);" here to avoid checking "order > 0"?
> +}
> +
> static inline struct page *page_cache_alloc(struct address_space *x)
> {
> return __page_cache_alloc(mapping_gfp_mask(x));
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 05a5aa82cd32..041c77c4ca56 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -957,24 +957,27 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
> EXPORT_SYMBOL_GPL(add_to_page_cache_lru);
>
> #ifdef CONFIG_NUMA
> -struct page *__page_cache_alloc(gfp_t gfp)
> +struct page *__page_cache_alloc_order(gfp_t gfp, unsigned int order)
> {
> int n;
> struct page *page;
>
> + if (order > 0)
> + gfp |= __GFP_COMP;
> +
I think it will be good to have separate __page_cache_alloc() for order 0,
so that we avoid checking "order > 0", but that may require too much
duplication. So I am on the fence for this one.
Thanks,
Song
> if (cpuset_do_page_mem_spread()) {
> unsigned int cpuset_mems_cookie;
> do {
> cpuset_mems_cookie = read_mems_allowed_begin();
> n = cpuset_mem_spread_node();
> - page = __alloc_pages_node(n, gfp, 0);
> + page = __alloc_pages_node(n, gfp, order);
> } while (!page && read_mems_allowed_retry(cpuset_mems_cookie));
>
> return page;
> }
> - return alloc_pages(gfp, 0);
> + return alloc_pages(gfp, order);
> }
> -EXPORT_SYMBOL(__page_cache_alloc);
> +EXPORT_SYMBOL(__page_cache_alloc_order);
> #endif
>
> /*
> --
> 2.23.0.rc1
>
next prev parent reply other threads:[~2019-09-05 19:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 18:23 [PATCH 0/3] Large pages in the page cache Matthew Wilcox
2019-09-05 18:23 ` [PATCH 1/3] mm: Add __page_cache_alloc_order Matthew Wilcox
2019-09-05 18:58 ` Song Liu [this message]
2019-09-05 19:02 ` Matthew Wilcox
2019-09-05 19:06 ` Song Liu
2019-09-05 18:23 ` [PATCH 2/3] mm: Allow large pages to be added to the page cache Matthew Wilcox
2019-09-05 18:28 ` Matthew Wilcox
2019-09-05 20:56 ` kbuild test robot
2019-09-06 12:09 ` Kirill A. Shutemov
2019-09-06 13:31 ` Matthew Wilcox
2019-09-05 18:23 ` [PATCH 3/3] mm: Allow find_get_page to be used for large pages Matthew Wilcox
2019-09-05 21:41 ` kbuild test robot
2019-09-05 22:04 ` kbuild test robot
2019-09-05 22:12 ` Matthew Wilcox
2019-09-09 0:42 ` [kbuild-all] " Rong Chen
2019-09-09 1:12 ` Matthew Wilcox
2019-09-06 12:59 ` Kirill A. Shutemov
2019-09-06 13:41 ` Matthew Wilcox
2019-09-06 13:52 ` Kirill A. Shutemov
2019-09-06 15:22 ` Matthew Wilcox
2019-09-06 15:59 ` [PATCH 4/3] Prepare transhuge pages properly Matthew Wilcox
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=75104154-A1A4-4FE3-920C-0069E1B5848D@fb.com \
--to=songliubraving@fb.com \
--cc=jweiner@fb.com \
--cc=kirill@shutemov.name \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=william.kucharski@oracle.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;
as well as URLs for NNTP newsgroup(s).