From patchwork Tue Feb 13 11:13:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gang Li X-Patchwork-Id: 200371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp464856dyb; Tue, 13 Feb 2024 03:14:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXHUupjudmIpk9JWORcMUKFVN1HGr3LjQdMB90ihx8q8j42FaP3E0PjKZUo+u7iU9d7T5BHF05t2OVPW0m9bqQpZ1OfmA== X-Google-Smtp-Source: AGHT+IHaB/vCrOlirzLOVAXEbfoAqXuzz02PuqbvdcBTwFNJWE3EdbRtjsQek59iShTunQfaoOmv X-Received: by 2002:a0c:dc8e:0:b0:68e:eb4b:56c8 with SMTP id n14-20020a0cdc8e000000b0068eeb4b56c8mr691966qvk.11.1707822880785; Tue, 13 Feb 2024 03:14:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707822880; cv=pass; d=google.com; s=arc-20160816; b=UTX79w7N6Nwar59+govEDulaWfA9MwmcmyfKXpuKcWopT2NnSZABksg3plypiskOz9 w3kPHZvbNb+CVUkN93W3DnSdN8w6gMUO34hLLT2ALAJWII+M2ZVHAjbKGlUH8IqDDAH+ GfHnphC5RREQFhRePGbP5TtWhthfO9IjoVFis9qd/x85o9iw4fELZfdARZV1fyvl+bpx /NOww8ykaUoENsRBzgLvyoTf7LtK3xCnV+0pCogxZoDFu+XMsbHzGwG4wLKnoF/3QgMQ lLS9bVDhCz8qoKP4j3si0bOlwin0QEnugR7ZhG1o/+HFMOD0Wo/0vlTT6k/oSYcJp7gj YhPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3HNW+BWPQLZLSA9Wsdie7SM7+Z9Dq4YTo1Xwh/Ut0N0=; fh=dO1R+uSEsH0z1CsX9bihBlSHLEZjJ5pwXBO2V5cfWE8=; b=rfqCT2pFFPdv9A8Nn92lhMe2VROWIi6DHekPtE0KCut+iZkCg9EMD/35qXK7LFmrEF ApwJSHHEdYEcSN4k60Pxpx7jdidZnhSTJvzGqK4LY1C8Tx/duzJKd2D42U1ZUC3ZgLop XwDulN0rs0IhFpzJotdALx/ZtWqhhuXkaeswyWhgxrnCfytvzybe5KoNAIyJHDyRkmAb 38Xp6peMK4a6vXjNoFLBhbswQCbAIttKzDOIyGGjYYnEUzVMuDTXEpovWAGooaYLm/A6 QNX+94dBSm9TydXBoU715PP1mlEgXaCCE9J0/0WCuIliK/ew35qc7Q7FKSVsr4xAVR67 fz0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ZPI670aF; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63404-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63404-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCXkO0H2IvSVtR1E0iKjwPNSNOWVqL/5ZM8zV07Z16c5E+saWrq2VaLej067jey4p1baBH8TpbjUlzapCfxkdDoHc2X4fw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a9-20020a0562140c2900b0068cb7c033d6si2550800qvd.24.2024.02.13.03.14.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 03:14:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63404-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ZPI670aF; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63404-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63404-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 93AD81C21464 for ; Tue, 13 Feb 2024 11:14:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E964381C6; Tue, 13 Feb 2024 11:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ZPI670aF" Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D32137157 for ; Tue, 13 Feb 2024 11:14:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707822848; cv=none; b=h+ajqUy0iEvzgNfFPZTDnh0dttYLJWbTNRR/4TmWBPez7HMy6kL+SuILFhudSdMGbQQ3vQO/6dqV4ik6AfjTE0BG/jUXQDykp2eJfZwWRqtag2HXo2XUdVj5PK314qXvY45FPypORpaH1VDZUWGuG0MIXtpxWQOkpWcWUoLuD84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707822848; c=relaxed/simple; bh=Pp4c82WxUcYPpLVo+HDh/cBM14HTiOMmYLsLLHJOEgE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sy7C/M5hAEW7BNSuuCvADwDExniiqkIw1LNJcCp51qGOu6TYUVcfZ731l46Eh6K6kQItXiXYPlL58aCwjC8v0ifLL+u5evprpcK/s133DlYI5JGbmyh1vwc73y8OrK3X/OqSb3apZ0BqMdKpe7MZycKDq/TPsbpsPh7BPL8nQIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ZPI670aF; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707822844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3HNW+BWPQLZLSA9Wsdie7SM7+Z9Dq4YTo1Xwh/Ut0N0=; b=ZPI670aF7l5C2zzwKvIqmcFcaMTzMQXxlEsYJ10wrPsJHywJ67w1IkzFeJ/ZcwvX7xafSW yXfXogGU+DMHmth/vH46c00MhNvLCEPEGGBlvc7AN/c1ZL/3/ha2zPzbUzKY1h4fRsHcas pZeE8v64mDTmFPEItAV5JpOFcIUSt4s= From: Gang Li To: Andrew Morton , Steffen Klassert , Daniel Jordan , Jane Chu , "Paul E . McKenney" , Muchun Song , Gang Li , Randy Dunlap , kernel test robot , Gang Li Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 1/2] padata: downgrade padata_do_multithreaded to serial execution for non-SMP Date: Tue, 13 Feb 2024 19:13:46 +0800 Message-Id: <20240213111347.3189206-2-gang.li@linux.dev> In-Reply-To: <20240213111347.3189206-1-gang.li@linux.dev> References: <20240213111347.3189206-1-gang.li@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790782085275523942 X-GMAIL-MSGID: 1790782085275523942 Randy Dunlap and kernel test robot reported a warning: ``` WARNING: unmet direct dependencies detected for PADATA Depends on [n]: SMP [=n] Selected by [y]: - HUGETLBFS [=y] && (X86 [=y] || SPARC64 || ARCH_SUPPORTS_HUGETLBFS [=n] || BROKEN [=n]) && (SYSFS [=y] || SYSCTL [=n]) ``` hugetlb parallelization depends on PADATA, and PADATA depends on SMP. PADATA consists of two distinct functionality: One part is padata_do_multithreaded which disregards order and simply divides tasks into several groups for parallel execution. Hugetlb init parallelization depends on padata_do_multithreaded. The other part is composed of a set of APIs that, while handling data in an out-of-order parallel manner, can eventually return the data with ordered sequence. Currently Only `crypto/pcrypt.c` use them. All users of PADATA of non-SMP case currently only use padata_do_multithreaded. It is easy to implement a serial one in include/linux/padata.h. And it is not necessary to implement another functionality unless the only user of crypto/pcrypt.c does not depend on SMP in the future. Fixes: a2cefb08be66 ("hugetlb: have CONFIG_HUGETLBFS select CONFIG_PADATA") Reported-by: Randy Dunlap Closes: https://lore.kernel.org/lkml/ec5dc528-2c3c-4444-9e88-d2c48395b433@infradead.org/ Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402020454.6EPkP1hi-lkp@intel.com/ Signed-off-by: Gang Li --- fs/Kconfig | 2 +- include/linux/padata.h | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/Kconfig b/fs/Kconfig index 4a51331f172e5..7963939592d70 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -261,7 +261,7 @@ menuconfig HUGETLBFS depends on X86 || SPARC64 || ARCH_SUPPORTS_HUGETLBFS || BROKEN depends on (SYSFS || SYSCTL) select MEMFD_CREATE - select PADATA + select PADATA if SMP help hugetlbfs is a filesystem backing for HugeTLB pages, based on ramfs. For architectures that support it, say Y here and read diff --git a/include/linux/padata.h b/include/linux/padata.h index 8f418711351bc..7b84eb7d73e7f 100644 --- a/include/linux/padata.h +++ b/include/linux/padata.h @@ -180,10 +180,6 @@ struct padata_instance { #ifdef CONFIG_PADATA extern void __init padata_init(void); -#else -static inline void __init padata_init(void) {} -#endif - extern struct padata_instance *padata_alloc(const char *name); extern void padata_free(struct padata_instance *pinst); extern struct padata_shell *padata_alloc_shell(struct padata_instance *pinst); @@ -194,4 +190,13 @@ extern void padata_do_serial(struct padata_priv *padata); extern void __init padata_do_multithreaded(struct padata_mt_job *job); extern int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, cpumask_var_t cpumask); +#else +static inline void __init padata_init(void) {} +static inline void __init padata_do_multithreaded(struct padata_mt_job *job) +{ + if (job->size) + job->thread_fn(job->start, job->start + job->size, job->fn_arg); +} +#endif + #endif From patchwork Tue Feb 13 11:13:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gang Li X-Patchwork-Id: 200372 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp464960dyb; Tue, 13 Feb 2024 03:14:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXTpc4mlRrfNnxpLQ0xdYOQsKlnijLDzYqWir7LKeeJ7a0XGdIVKeBWbO1islImm+nIk5mpD5/+DpPx1q+EMlN0UD+dYg== X-Google-Smtp-Source: AGHT+IE1SIA8qJGY1apTFIJ9MD5U/Ukw3qPjsNI5cyzib6r4dILwg5NFPq5gZR65bPrXY7pniw2e X-Received: by 2002:a17:906:5955:b0:a3c:b136:e607 with SMTP id g21-20020a170906595500b00a3cb136e607mr3368243ejr.43.1707822894831; Tue, 13 Feb 2024 03:14:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707822894; cv=pass; d=google.com; s=arc-20160816; b=fHCK0jm5aAxbwr4M1bKwCQB96EmCdGY72UQQoBtxuw4YpEUXPEd+PaPYJMrU63Cwtn KH0pMmuHAPjezQb1R4JDGBawWjvaprxfDyYsRl8+ka5vqH17zvn/TlKmwQOH7T0HV5R0 6NTMi4wkUtb4hT92udomFFnefSDu55JykoTASENPzehDiqDEJfzxT+5+Lep57uFbduyI n+UmRNOE8klCiYeRDo4g+c2pyiMJeDHE2v5nnF86LntosYAy1e5J4zIz0qanwtM/ICsb wlrpsZ1DC8aq/auMr2icGiz9CT05pWVZ1aL3A5oQ/pzGkSh1+2o7f6xTMCp0AStgd2yJ eu7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=v+0w6vgAkx480UaKM14cyn/7okLKV9MHO3nKluWgIkY=; fh=7GG+77PaFn5Ktfwp58Ug5YMElEADqBTEXySWmajQ1+k=; b=aMHI9ACv0StyFH0IPzMIYWeJKzCMSmh4u13Pr9cp1PaA0pUcwnZGOF85T4H07KB5ko IM/GivjW2t5Ucj9m4dNUY4JNQYaw9AOndaPfvER35EgRnRWlmoITEDETBhwHRkPOTfSL Xpxqnz46Ohi5lbd7jw8zDVHuPy+4q1PUJb/XViIZEunSfIAMhzsHpayQWrrmJWCKBIRK CgegdkGMhhkV7180ITUr3XVr00NJLsEKRvO6DtlyOtxzvVXepJXWSBIeUuND2bUAEnlx tq+u9KXzpjCFayz7XeehyIiB5ifWE1+osbc5F8ZEWmSnXH0/PlxxDUgF3AM/Ix8Xd+xz 8DDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=K6wyJoAZ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63405-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63405-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCUIBv7FqU7pNOQb7qjUrZ0QaFnAuH9dRCEPFgdFAA45tS7+/DVlCeggNPU+kxGQZ1+CQJyt7i/7nohop56qOHxZV4vn3g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n12-20020a170906724c00b00a3c2f78c2b3si1164949ejk.750.2024.02.13.03.14.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 03:14:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63405-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=K6wyJoAZ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63405-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63405-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 72FD61F270B4 for ; Tue, 13 Feb 2024 11:14:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6649438DF5; Tue, 13 Feb 2024 11:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="K6wyJoAZ" Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13D9F37711 for ; Tue, 13 Feb 2024 11:14:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707822851; cv=none; b=FY4naBZA3YPUFqRXxRcJgVUlnuPtzSXE6e/MHQRTU9h+EMxiRMkdFx1RF/pF7IaPvxywNwsNritJEyMjdQw7L8jEe+mZL8aep8vJZh7fl/8z3FsKF7IDSuaWDXpmWP9TNVb8w3i0ITxHcZ4zz8hE6n8AxQhXktotOabRKZbgyJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707822851; c=relaxed/simple; bh=d6/hUbDiaSKbaKZPPqsgtYI6MyO67KcFseD9Tax9SNk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e9VM0N4qQvPEi1G9c9zmIYx0DlSFON9f/CbAw5KjESS64KEtmvPpx6XOtMTZxqTsOyyxda8Q3/g6qFWEbH/5UFTkXk10v8pf1cR3AlJGkkKj60QO0CaoM4DfRJbFw5Awypi1gNEJjJFYdpSaEDmFOXqU+0tJypUa48M3dwZhZG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=K6wyJoAZ; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707822848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v+0w6vgAkx480UaKM14cyn/7okLKV9MHO3nKluWgIkY=; b=K6wyJoAZJmiAzz8+5pYM3XytCKwKH7mDSv+DR8+IWYQXu64yniCYgylUCM1PW/LdkJ+TWB NapD8/7k+iGm2K5CRO8w6/sOqUjGsvTCxz0YMU4U5TIqeUNCDkNoX510dFoS4Y+6Dmeq/e lo6UmME7aGnRqdGCGovmp/a6yGx/yD8= From: Gang Li To: Andrew Morton , Steffen Klassert , Daniel Jordan , Jane Chu , "Paul E . McKenney" , Muchun Song , Gang Li , Randy Dunlap , kernel test robot , Gang Li 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 Message-Id: <20240213111347.3189206-3-gang.li@linux.dev> In-Reply-To: <20240213111347.3189206-1-gang.li@linux.dev> References: <20240213111347.3189206-1-gang.li@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790782099655828697 X-GMAIL-MSGID: 1790782099655828697 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 Reviewed-by: Muchun Song --- 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),