All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: yaozhenguo1@gmail.com
Cc: linux-mm@kvack.org
Subject: [bug report] hugetlbfs: extend the definition of hugepages parameter to support node allocation
Date: Fri, 1 Oct 2021 16:22:21 +0300	[thread overview]
Message-ID: <20211001132220.GA7666@kili> (raw)

Hello Zhenguo Yao,

The patch 67b2b441dc10: "hugetlbfs: extend the definition of
hugepages parameter to support node allocation" from Sep 29, 2021,
leads to the following
Smatch static checker warning:

	mm/hugetlb.c:2957 __alloc_bootmem_huge_page()
	warn: ignoring unreachable code.

mm/hugetlb.c
    2940 int __alloc_bootmem_huge_page(struct hstate *h, int nid)
    2941 {
    2942         struct huge_bootmem_page *m;
    2943         int nr_nodes, node;
    2944 
    2945         if (nid >= nr_online_nodes)
    2946                 return 0;
    2947         /* do node specific alloc */
    2948         if (nid != NUMA_NO_NODE) {
    2949                 m = memblock_alloc_try_nid_raw(huge_page_size(h), huge_page_size(h),
    2950                                 0, MEMBLOCK_ALLOC_ACCESSIBLE, nid);
    2951                 if (m)
    2952                         goto found;
    2953                 else
    2954                         return 0;
    2955         }
    2956         /* do all node balanced alloc */
                       ^^^^^^^^
This says that it's going to loop over "all nodes".

--> 2957         for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) {
    2958                 m = memblock_alloc_try_nid_raw(
    2959                                 huge_page_size(h), huge_page_size(h),
    2960                                 0, MEMBLOCK_ALLOC_ACCESSIBLE, node);
    2961                 /*
    2962                  * Use the beginning of the huge page to store the
    2963                  * huge_bootmem_page struct (until gather_bootmem
    2964                  * puts them into the mem_map).
    2965                  */
    2966                 if (m)
    2967                         goto found;
    2968                 else
    2969                         return 0;

But it only checks the first node and then returns.

    2970         }
    2971 
    2972 found:
    2973         /* Put them into a private list first because mem_map is not up yet */
    2974         INIT_LIST_HEAD(&m->list);
    2975         list_add(&m->list, &huge_boot_pages);
    2976         m->hstate = h;
    2977         return 1;
    2978 }

regards,
dan carpenter


             reply	other threads:[~2021-10-01 13:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 13:22 Dan Carpenter [this message]
2021-10-05  5:52 ` [bug report] hugetlbfs: extend the definition of hugepages parameter to support node allocation Zhenguo Yao

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=20211001132220.GA7666@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=yaozhenguo1@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.