From: Michal Hocko <mhocko@suse.com>
To: Li Xinhai <lixinhai.lxh@gmail.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
Roman Gushchin <guro@fb.com>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: Re: [PATCH V2] mm/hugetlb: try preferred node first when alloc gigantic page from cma
Date: Tue, 1 Sep 2020 17:04:05 +0200 [thread overview]
Message-ID: <20200901150405.GH16650@dhcp22.suse.cz> (raw)
In-Reply-To: <20200901144924.678195-1-lixinhai.lxh@gmail.com>
On Tue 01-09-20 22:49:24, Li Xinhai wrote:
> Since commit cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic
> hugepages using cma"), the gigantic page would be allocated from node
> which is not the preferred node, although there are pages available from
> that node. The reason is that the nid parameter has been ignored in
> alloc_gigantic_page().
>
> Besides, the __GFP_THISNODE also need be checked if user required to
> alloc only from the preferred node.
>
> After this patch, the preferred node is tried first before other allowed
> nodes, and don't try to allocate from other nodes if __GFP_THISNODE is
> specified.
>
> Fixes: cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic hugepages using cma")
> Cc: Roman Gushchin <guro@fb.com>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Cc: Michal Hocko <mhocko@kernel.org>
> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
LGTM
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> v1->v2:
> With review by Mike and Michal, need to check __GFP_THISNODE to avoid
> allocate from other nodes.
>
> mm/hugetlb.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index a301c2d672bf..d24986145087 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1256,15 +1256,24 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
> struct page *page;
> int node;
>
> - for_each_node_mask(node, *nodemask) {
> - if (!hugetlb_cma[node])
> - continue;
> -
> - page = cma_alloc(hugetlb_cma[node], nr_pages,
> - huge_page_order(h), true);
> + if (nid != NUMA_NO_NODE && hugetlb_cma[nid]) {
> + page = cma_alloc(hugetlb_cma[nid], nr_pages,
> + huge_page_order(h), true);
> if (page)
> return page;
> }
> +
> + if (!(gfp_mask & __GFP_THISNODE)) {
> + for_each_node_mask(node, *nodemask) {
> + if (node == nid || !hugetlb_cma[node])
> + continue;
> +
> + page = cma_alloc(hugetlb_cma[node], nr_pages,
> + huge_page_order(h), true);
> + if (page)
> + return page;
> + }
> + }
> }
> #endif
>
> --
> 2.18.4
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2020-09-01 15:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 14:49 Li Xinhai
2020-09-01 15:04 ` Michal Hocko [this message]
2020-09-01 18:43 ` Mike Kravetz
2020-09-02 2:12 ` Li Xinhai
2020-09-01 22:04 ` Roman Gushchin
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=20200901150405.GH16650@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=guro@fb.com \
--cc=linux-mm@kvack.org \
--cc=lixinhai.lxh@gmail.com \
--cc=mike.kravetz@oracle.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