From: Gang Li <gang.li@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
Steffen Klassert <steffen.klassert@secunet.com>,
Daniel Jordan <daniel.m.jordan@oracle.com>,
Jane Chu <jane.chu@oracle.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Muchun Song <muchun.song@linux.dev>, Gang Li <gang.li@linux.dev>,
Randy Dunlap <rdunlap@infradead.org>,
kernel test robot <lkp@intel.com>,
Gang Li <ligang.bdlg@bytedance.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH v1 2/2] hugetlb: process multiple lists in gather_bootmem_prealloc_parallel
Date: Tue, 13 Feb 2024 19:13:47 +0800 [thread overview]
Message-ID: <20240213111347.3189206-3-gang.li@linux.dev> (raw)
In-Reply-To: <20240213111347.3189206-1-gang.li@linux.dev>
gather_bootmem_prealloc_node currently only process one list in
huge_boot_pages array. So gather_bootmem_prealloc expects
padata_do_multithreaded to run num_node_state(N_MEMORY) instances of
gather_bootmem_prealloc_node to process all lists in huge_boot_pages.
This works well in current padata_do_multithreaded implementation.
It guarantees that size/min_chunk <= thread num <= max_threads.
```
/* Ensure at least one thread when size < min_chunk. */
nworks = max(job->size / max(job->min_chunk, job->align), 1ul);
nworks = min(nworks, job->max_threads);
ps.nworks = padata_work_alloc_mt(nworks, &ps, &works);
```
However, the comment of padata_do_multithreaded API only promises a
maximum value for the number of threads and does not specify a
minimum value. Which may pass multiple nodes to
gather_bootmem_prealloc_node and only one node will be processed.
To avoid potential errors, introduce gather_bootmem_prealloc_parallel
to handle the case where the number of threads does not meet the
requirement of max_threads.
Fixes: 0306f03dcbd7 ("hugetlb: parallelize 1G hugetlb initialization")
Signed-off-by: Gang Li <ligang.bdlg@bytedance.com>
---
mm/hugetlb.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 25069ca6ec248..2799a7ea098c1 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3414,10 +3414,8 @@ static void __init prep_and_add_bootmem_folios(struct hstate *h,
* Put bootmem huge pages into the standard lists after mem_map is up.
* Note: This only applies to gigantic (order > MAX_PAGE_ORDER) pages.
*/
-static void __init gather_bootmem_prealloc_node(unsigned long start, unsigned long end, void *arg)
-
+static void __init gather_bootmem_prealloc_node(unsigned long nid)
{
- int nid = start;
LIST_HEAD(folio_list);
struct huge_bootmem_page *m;
struct hstate *h = NULL, *prev_h = NULL;
@@ -3455,10 +3453,19 @@ static void __init gather_bootmem_prealloc_node(unsigned long start, unsigned lo
prep_and_add_bootmem_folios(h, &folio_list);
}
+static void __init gather_bootmem_prealloc_parallel(unsigned long start,
+ unsigned long end, void *arg)
+{
+ int nid;
+
+ for (nid = start; nid < end; nid++)
+ gather_bootmem_prealloc_node(nid);
+}
+
static void __init gather_bootmem_prealloc(void)
{
struct padata_mt_job job = {
- .thread_fn = gather_bootmem_prealloc_node,
+ .thread_fn = gather_bootmem_prealloc_parallel,
.fn_arg = NULL,
.start = 0,
.size = num_node_state(N_MEMORY),
--
2.20.1
next prev parent reply other threads:[~2024-02-13 11:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 11:13 [PATCH v1 0/2] hugetlb: two small improvements of hugetlb init parallelization Gang Li
2024-02-13 11:13 ` [PATCH v1 1/2] padata: downgrade padata_do_multithreaded to serial execution for non-SMP Gang Li
2024-02-13 14:52 ` Muchun Song
2024-02-13 15:15 ` Gang Li
2024-02-15 10:49 ` Muchun Song
2024-02-13 11:13 ` Gang Li [this message]
2024-02-13 14:54 ` [PATCH v1 2/2] hugetlb: process multiple lists in gather_bootmem_prealloc_parallel Muchun Song
2024-02-13 14:16 ` [PATCH v1 0/2] hugetlb: two small improvements of hugetlb init parallelization Paul E. McKenney
2024-02-19 3:03 ` Gang Li
2024-02-20 1:52 ` Andrew Morton
2024-02-20 6:17 ` Gang Li
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=20240213111347.3189206-3-gang.li@linux.dev \
--to=gang.li@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=daniel.m.jordan@oracle.com \
--cc=jane.chu@oracle.com \
--cc=ligang.bdlg@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=muchun.song@linux.dev \
--cc=paulmck@kernel.org \
--cc=rdunlap@infradead.org \
--cc=steffen.klassert@secunet.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.