From: Baoquan He <bhe@redhat.com>
To: Oscar Salvador <osalvador@suse.de>
Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com,
n-horiguchi@ah.jp.nec.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/hugetlb: Get rid of NODEMASK_ALLOC
Date: Wed, 3 Apr 2019 15:52:36 +0800 [thread overview]
Message-ID: <20190403075236.GB31828@MiWiFi-R3L-srv> (raw)
In-Reply-To: <20190402133415.21983-1-osalvador@suse.de>
On 04/02/19 at 03:34pm, Oscar Salvador wrote:
> NODEMASK_ALLOC is used to allocate a nodemask bitmap, ant it does it by
~ and
> first determining whether it should be allocated in the stack or dinamically
dynamically^^
> depending on NODES_SHIFT.
> Right now, it goes the dynamic path whenever the nodemask_t is above 32
> bytes.
>
> Although we could bump it to a reasonable value, the largest a nodemask_t
> can get is 128 bytes, so since __nr_hugepages_store_common is called from
> a rather shore stack we can just get rid of the NODEMASK_ALLOC call here.
>
> This reduces some code churn and complexity.
>
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
> mm/hugetlb.c | 36 +++++++++++-------------------------
> 1 file changed, 11 insertions(+), 25 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index f79ae4e42159..9cb2f91af897 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -2447,44 +2447,30 @@ static ssize_t __nr_hugepages_store_common(bool obey_mempolicy,
> unsigned long count, size_t len)
> {
> int err;
> - NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
> + nodemask_t nodes_allowed, *n_mask;
>
> - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) {
> - err = -EINVAL;
> - goto out;
> - }
> + if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())
> + return -EINVAL;
>
> if (nid == NUMA_NO_NODE) {
> /*
> * global hstate attribute
> */
> if (!(obey_mempolicy &&
> - init_nodemask_of_mempolicy(nodes_allowed))) {
> - NODEMASK_FREE(nodes_allowed);
> - nodes_allowed = &node_states[N_MEMORY];
> - }
> - } else if (nodes_allowed) {
> + init_nodemask_of_mempolicy(&nodes_allowed)))
> + n_mask = &node_states[N_MEMORY];
> + else
> + n_mask = &nodes_allowed;
> + } else {
> /*
> * Node specific request. count adjustment happens in
> * set_max_huge_pages() after acquiring hugetlb_lock.
> */
> - init_nodemask_of_node(nodes_allowed, nid);
> - } else {
> - /*
> - * Node specific request, but we could not allocate the few
> - * words required for a node mask. We are unlikely to hit
> - * this condition. Since we can not pass down the appropriate
> - * node mask, just return ENOMEM.
> - */
> - err = -ENOMEM;
> - goto out;
> + init_nodemask_of_node(&nodes_allowed, nid);
> + n_mask = &nodes_allowed;
> }
>
> - err = set_max_huge_pages(h, count, nid, nodes_allowed);
> -
> -out:
> - if (nodes_allowed != &node_states[N_MEMORY])
> - NODEMASK_FREE(nodes_allowed);
> + err = set_max_huge_pages(h, count, nid, n_mask);
>
> return err ? err : len;
> }
> --
> 2.13.7
>
prev parent reply other threads:[~2019-04-03 7:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 13:34 [PATCH] mm/hugetlb: Get rid of NODEMASK_ALLOC Oscar Salvador
2019-04-02 18:37 ` Mike Kravetz
2019-04-02 20:01 ` Andrew Morton
2019-04-02 20:09 ` Mike Kravetz
2019-04-02 20:16 ` Oscar Salvador
2019-04-03 5:44 ` Naoya Horiguchi
2019-04-03 7:52 ` Baoquan He [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=20190403075236.GB31828@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=osalvador@suse.de \
/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).