From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 11E532E400 for ; Tue, 28 May 2024 19:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716922844; cv=none; b=WcEA+EF9jJpgdthy7JpqSTRxBN7ttUTOwn/nyNj+8I5KLNKy4xgdyRSr5a0Wr9oBQjJKOjG2WYwrlhGcNZnhNVDbjkH3TM810OgrXJaSugHgArtqisZQVkgQrBFKooUKy15qi+4atCTuNbFlbAKShpDS5RFlPpGMyG2gkbqmHwM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716922844; c=relaxed/simple; bh=f+voVYQgJ6rLsoG7iQDzb3odNjuXcpx3jZ1qlcYa4aY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-type; b=bdNKjcLxk/uizrsq9aTS7MGTZ5RQYNLf06o/nt4IQkzVDqr5vci3PZKYm95yDdone4Lz9uIkYSlbJtvGvU0xr0WSTYbynzNzBzpi4wnUTFJEOInt5cajOAjXeJCv+Y+opg0Byi0xqF5otKZMuIUvtleQ7crIlB7nU68bJJ3EWDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WE/CSpIS; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WE/CSpIS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716922841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EroyhAMtYZlwFiF+i06GpFh0h6zXLI4AvXcFdjRTODk=; b=WE/CSpISAN2XMbpdDZUEbE6eUfsq/jFIUAMb5ZN8Vm1o8573Nrv5kCC2JYV9ZIptHYQET4 bFicKq3X/3JnfpUGmzVsHOWBE6cbFK5861fWZZHYiqwKoTXqR02Ap06W5zVb8+Vc1HAZ4m jsRhZULhWMcDqno8Yj3kxO95ejh/+lU= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-tc1QNwtTNuCDaaEZtT8NUA-1; Tue, 28 May 2024 15:00:39 -0400 X-MC-Unique: tc1QNwtTNuCDaaEZtT8NUA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-43fde19a996so5653741cf.3 for ; Tue, 28 May 2024 12:00:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716922838; x=1717527638; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EroyhAMtYZlwFiF+i06GpFh0h6zXLI4AvXcFdjRTODk=; b=jEL4z4hIqTv3IVdohC+QEMnj2j/xQLu0j3p8jSVXKt4Cxt4MezsHdumkC2SRJnzwZF fUkehXl+Am+nWZTPsGOa4EHNH1ArrZ0DPaat9yCrljz+ghl9lm8rmNUsOrWML6pzF+Yp wMurWJjS0qquUQfSqH7uNviHTdto9uozmvsvtxMVTl1O4N9mFDGJB91XtWOve7ZhKY3+ T1qyy2HIcS3eijNQacYZ9MZmoXCwwqBrBpxQNzvgsTj0yJbzLUUnlpPE2J4S88DxJ0ZU wNr6tUygmaDvNhWEp6YKRxeVnTya6xRghL8yl1crhRvogRJSIcRxd2UzO/o3KfHK4QxA w2hQ== X-Forwarded-Encrypted: i=1; AJvYcCUCHxI3NVDlBHx9pYg82lOjSk9rvSJmModKIKVpsQxvSSkVS7YrhVSddAAxAsLe+UlE7E/Bz520+io667tuaIvQth6vDjBmO0dOqg== X-Gm-Message-State: AOJu0YxQ39Fzgybz2pLhznl44a0ZgWrm7SbwL1d4fmbY03Z5OLFfuDxP NetaOfJLxf9fC8YoVOLSi9ertSjZ0GkJd5suyKFNHTxXpXFMcoMF7YvUGi+ROkD3qbMvrxn18da OQTFEDZXR4fi/FPoP6as1bXlNnc7YzPhtSIlIEKastJPMuhDyMHziH4UIycg= X-Received: by 2002:a05:622a:10a:b0:43e:34ea:80ee with SMTP id d75a77b69052e-43fb0e8d809mr134384031cf.29.1716922837941; Tue, 28 May 2024 12:00:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLHIs0G4ODwLtaTgMc9fP7BM4N2EDamkPS2f5rSvXhQ/RuodqmrywBv65gQp5ZlO5A4PV4Ug== X-Received: by 2002:a05:622a:10a:b0:43e:34ea:80ee with SMTP id d75a77b69052e-43fb0e8d809mr134383451cf.29.1716922837199; Tue, 28 May 2024 12:00:37 -0700 (PDT) Received: from localhost (pool-71-184-142-128.bstnma.fios.verizon.net. [71.184.142.128]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43fb17f69ddsm44981881cf.41.2024.05.28.12.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 12:00:36 -0700 (PDT) From: Eric Chanudet To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Mike Rapoport , Andrew Morton , Baoquan He , Michael Ellerman , Nick Piggin Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Eric Chanudet Subject: [PATCH v3] mm/mm_init: use node's number of cpus in deferred_page_init_max_threads Date: Tue, 28 May 2024 14:54:58 -0400 Message-ID: <20240528185455.643227-4-echanude@redhat.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit When DEFERRED_STRUCT_PAGE_INIT=y, use a node's cpu count as maximum thread count for the deferred initialization of struct pages via padata. This should result in shorter boot times for these configurations by going through page_alloc_init_late() faster as systems tend not to be under heavy load that early in the bootstrap. Only x86_64 does that now. Make it archs agnostic when DEFERRED_STRUCT_PAGE_INIT is set. With the default defconfigs, that includes powerpc and s390. It used to be so before offering archs to override the function for tuning with commit ecd096506922 ("mm: make deferred init's max threads arch-specific"). Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions: | | x13s | SA8775p-ride | Ampere R137-P31 | Ampere HR330 | | | Metal, 32GB | VM, 36GB | VM, 58GB | Metal, 128GB | | | 8cpus | 8cpus | 8cpus | 32cpus | |---------|-------------|--------------|-----------------|--------------| | threads | ms (%) | ms (%) | ms (%) | ms (%) | |---------|-------------|--------------|-----------------|--------------| | 1 | 108 (0%) | 72 (0%) | 224 (0%) | 324 (0%) | | cpus | 24 (-77%) | 36 (-50%) | 40 (-82%) | 56 (-82%) | Michael Ellerman on a powerpc machine (1TB, 40 cores, 4KB pages) reports faster deferred_init_memmap from 210-240ms to 90-110ms between nodes. Signed-off-by: Eric Chanudet Tested-by: Michael Ellerman (powerpc) --- - v1: https://lore.kernel.org/linux-arm-kernel/20240520231555.395979-5-echanude@redhat.com - Changes since v1: - Make the generic function return the number of cpus of the node as max threads limit instead overriding it for arm64. - Drop Baoquan He's R-b on v1 since the logic changed. - Add CCs according to patch changes (ppc and s390 set DEFERRED_STRUCT_PAGE_INIT by default). - v2: https://lore.kernel.org/linux-arm-kernel/20240522203758.626932-4-echanude@redhat.com/ - Changes since v2: - deferred_page_init_max_threads returns unsigned and use max instead of max_t. - Make deferred_page_init_max_threads static since there are no more override. - Rephrase description. - Add T-b and report from Michael Ellerman. arch/x86/mm/init_64.c | 12 ------------ include/linux/memblock.h | 2 -- mm/mm_init.c | 5 ++--- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 7e177856ee4f..adec42928ec1 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1354,18 +1354,6 @@ void __init mem_init(void) preallocate_vmalloc_pages(); } -#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT -int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) -{ - /* - * More CPUs always led to greater speedups on tested systems, up to - * all the nodes' CPUs. Use all since the system is otherwise idle - * now. - */ - return max_t(int, cpumask_weight(node_cpumask), 1); -} -#endif - int kernel_set_to_readonly; void mark_rodata_ro(void) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index e2082240586d..40c62aca36ec 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -335,8 +335,6 @@ void __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, for (; i != U64_MAX; \ __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end)) -int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask); - #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ /** diff --git a/mm/mm_init.c b/mm/mm_init.c index f72b852bd5b8..acfeba508796 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2122,11 +2122,10 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn, } } -/* An arch may override for more concurrency. */ -__weak int __init +static unsigned int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) { - return 1; + return max(cpumask_weight(node_cpumask), 1U); } /* Initialise remaining memory on a node */ -- 2.44.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A01CC27C43 for ; Thu, 30 May 2024 22:33:54 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IeBdV/9j; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZOfuseJ9; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Vr1J02kX8z3cjr for ; Fri, 31 May 2024 08:33:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IeBdV/9j; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZOfuseJ9; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=echanude@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Vphg53Yk4z3wFj for ; Wed, 29 May 2024 05:00:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716922842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EroyhAMtYZlwFiF+i06GpFh0h6zXLI4AvXcFdjRTODk=; b=IeBdV/9jcqGNNyYozKP3D1mIkx/7YJEIIxvsd4/XHcIy2I5Qd/Qk2YIjGDR7ZGwPg7mpE1 EDH1JHZ8lfhj8sScrZKL82jQuVOrYqtAIjDwZu0WOGXI7wlUVjjfqT8KIR/RORlRmHK50k q1FveX9b6r5IbnXiB9CCpckrOnNy47k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716922843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EroyhAMtYZlwFiF+i06GpFh0h6zXLI4AvXcFdjRTODk=; b=ZOfuseJ9EDGaYH/iCWacWsbvyQT4BsRG4OxXWHS34QJd8JBOquotwDIL2xEqQcSZRCbJrd iBTLGsjmYgxd7oag/b5cGiyAFYnWdRI/vRiKfF02zI41iVZtRfRuIfknd1+GuFx7cskBnA 2/YZ9Fdwp2nAqVsO3Y1Aak85RKxXeN0= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-fOmUSTJPNZ26ethS8BG6NA-1; Tue, 28 May 2024 15:00:41 -0400 X-MC-Unique: fOmUSTJPNZ26ethS8BG6NA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-43fc7d851f5so12374241cf.0 for ; Tue, 28 May 2024 12:00:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716922838; x=1717527638; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EroyhAMtYZlwFiF+i06GpFh0h6zXLI4AvXcFdjRTODk=; b=T8fl+J3vX4V78Fj04NHqkXWIYtty4SqUYOKuRb1bDGQ43AVIp7Y9yavOmCT6Wo7D+B i08Twd+RbgjniVgoowzLNlMwhn16ZyJnRTIC9kJMFkgXNvppqG7dz5TnxTqrf44s/xpg CVor9knXNDO1EvX8UM9hE/AAEqdXZDVxn0f7yppWTtQLfP0SHaPJSa9tY5upuvfF4hzL vt/bNhEGBUqCIhbqt9aKdyg361sjXaBU5fO3dXI9p8hHQ76SGR09EZxFkgyiIQP56r3W PuMc9mkA1KNk2J7HYNBnWI8G9eysElcau5Cc8dq84RpcnKdnG9b+5y0UrfqWUxvF+ge9 sfEA== X-Forwarded-Encrypted: i=1; AJvYcCWbAgZjUrrD8eWPJBujefSvarApr3yuHGYNaIXXUs35UQUQeZimJotOAxFGDXWrdeh/OT2RKUGI85Kd7VvcKc6tfuYZEtr/+DYVuXhasw== X-Gm-Message-State: AOJu0YydR7YudfkjAaF5L3zobPVLwO8pfsIrL5bQrbaifRSIBYSeh+ld lUb6HZSOWtFjM9uiKqzcO3Z9yYjSLuulq7NFaIL1SvoklwAuSGt14vYeeUndh+sUgyyds+FoF7E 5prha5ctXrtYdej9qHvomqU303v22/0D785W0W/fo7fiVzWTgms49lG6OZoaWuI8= X-Received: by 2002:a05:622a:10a:b0:43e:34ea:80ee with SMTP id d75a77b69052e-43fb0e8d809mr134383941cf.29.1716922837921; Tue, 28 May 2024 12:00:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLHIs0G4ODwLtaTgMc9fP7BM4N2EDamkPS2f5rSvXhQ/RuodqmrywBv65gQp5ZlO5A4PV4Ug== X-Received: by 2002:a05:622a:10a:b0:43e:34ea:80ee with SMTP id d75a77b69052e-43fb0e8d809mr134383451cf.29.1716922837199; Tue, 28 May 2024 12:00:37 -0700 (PDT) Received: from localhost (pool-71-184-142-128.bstnma.fios.verizon.net. [71.184.142.128]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43fb17f69ddsm44981881cf.41.2024.05.28.12.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 12:00:36 -0700 (PDT) From: Eric Chanudet To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Mike Rapoport , Andrew Morton , Baoquan He , Michael Ellerman , Nick Piggin Subject: [PATCH v3] mm/mm_init: use node's number of cpus in deferred_page_init_max_threads Date: Tue, 28 May 2024 14:54:58 -0400 Message-ID: <20240528185455.643227-4-echanude@redhat.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 31 May 2024 08:19:55 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Eric Chanudet , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" When DEFERRED_STRUCT_PAGE_INIT=y, use a node's cpu count as maximum thread count for the deferred initialization of struct pages via padata. This should result in shorter boot times for these configurations by going through page_alloc_init_late() faster as systems tend not to be under heavy load that early in the bootstrap. Only x86_64 does that now. Make it archs agnostic when DEFERRED_STRUCT_PAGE_INIT is set. With the default defconfigs, that includes powerpc and s390. It used to be so before offering archs to override the function for tuning with commit ecd096506922 ("mm: make deferred init's max threads arch-specific"). Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions: | | x13s | SA8775p-ride | Ampere R137-P31 | Ampere HR330 | | | Metal, 32GB | VM, 36GB | VM, 58GB | Metal, 128GB | | | 8cpus | 8cpus | 8cpus | 32cpus | |---------|-------------|--------------|-----------------|--------------| | threads | ms (%) | ms (%) | ms (%) | ms (%) | |---------|-------------|--------------|-----------------|--------------| | 1 | 108 (0%) | 72 (0%) | 224 (0%) | 324 (0%) | | cpus | 24 (-77%) | 36 (-50%) | 40 (-82%) | 56 (-82%) | Michael Ellerman on a powerpc machine (1TB, 40 cores, 4KB pages) reports faster deferred_init_memmap from 210-240ms to 90-110ms between nodes. Signed-off-by: Eric Chanudet Tested-by: Michael Ellerman (powerpc) --- - v1: https://lore.kernel.org/linux-arm-kernel/20240520231555.395979-5-echanude@redhat.com - Changes since v1: - Make the generic function return the number of cpus of the node as max threads limit instead overriding it for arm64. - Drop Baoquan He's R-b on v1 since the logic changed. - Add CCs according to patch changes (ppc and s390 set DEFERRED_STRUCT_PAGE_INIT by default). - v2: https://lore.kernel.org/linux-arm-kernel/20240522203758.626932-4-echanude@redhat.com/ - Changes since v2: - deferred_page_init_max_threads returns unsigned and use max instead of max_t. - Make deferred_page_init_max_threads static since there are no more override. - Rephrase description. - Add T-b and report from Michael Ellerman. arch/x86/mm/init_64.c | 12 ------------ include/linux/memblock.h | 2 -- mm/mm_init.c | 5 ++--- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 7e177856ee4f..adec42928ec1 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1354,18 +1354,6 @@ void __init mem_init(void) preallocate_vmalloc_pages(); } -#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT -int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) -{ - /* - * More CPUs always led to greater speedups on tested systems, up to - * all the nodes' CPUs. Use all since the system is otherwise idle - * now. - */ - return max_t(int, cpumask_weight(node_cpumask), 1); -} -#endif - int kernel_set_to_readonly; void mark_rodata_ro(void) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index e2082240586d..40c62aca36ec 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -335,8 +335,6 @@ void __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, for (; i != U64_MAX; \ __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end)) -int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask); - #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ /** diff --git a/mm/mm_init.c b/mm/mm_init.c index f72b852bd5b8..acfeba508796 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2122,11 +2122,10 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn, } } -/* An arch may override for more concurrency. */ -__weak int __init +static unsigned int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) { - return 1; + return max(cpumask_weight(node_cpumask), 1U); } /* Initialise remaining memory on a node */ -- 2.44.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 849FDC25B78 for ; Tue, 28 May 2024 19:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+3nIqjuCx8cfh/RTGedABR4tZB07dzBt8HuI2R5QLYQ=; b=iNqQ5vAqEjKpqX w9/x6dLFBEpc36GkhZrifxSSqZVPbwbnnsMEQd54mJMqpOGPqy3fOcdb3UPGDig3szNhCZB+qsRah jeSBifX1MSxs713/QvNwTPkK6UneCloXX6Fc0YybajQEU8dzCW685TogH8hHkUjQV68A7tRbhkaFQ tQ4Lx2W+nXqb/4Uv3CuJk7Otk+ef44DHO31xKaCMpYwy2S07XC8pSTcf5agMfBWsE4FM6Y2pyATDO GcSKObfyIl6SgEk57nZHMadCCk2fV7w6rn+tUcmclCkqenHy54CCecC1PIiinsseyV7E9hbql8JEO P7Y194bjqSbD6dzkpMYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sC23z-00000001j6M-3SjT; Tue, 28 May 2024 19:00:47 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sC23w-00000001j4c-2YJw for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2024 19:00:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716922841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EroyhAMtYZlwFiF+i06GpFh0h6zXLI4AvXcFdjRTODk=; b=WE/CSpISAN2XMbpdDZUEbE6eUfsq/jFIUAMb5ZN8Vm1o8573Nrv5kCC2JYV9ZIptHYQET4 bFicKq3X/3JnfpUGmzVsHOWBE6cbFK5861fWZZHYiqwKoTXqR02Ap06W5zVb8+Vc1HAZ4m jsRhZULhWMcDqno8Yj3kxO95ejh/+lU= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-6c5c8Z8OMY65_p7e29UH9w-1; Tue, 28 May 2024 15:00:39 -0400 X-MC-Unique: 6c5c8Z8OMY65_p7e29UH9w-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-43fc7d851f5so12374001cf.0 for ; Tue, 28 May 2024 12:00:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716922838; x=1717527638; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EroyhAMtYZlwFiF+i06GpFh0h6zXLI4AvXcFdjRTODk=; b=XMwyuINnUMW+BTox8ntJ9r0iGPoRjIWfxiDiPx7byFI3Q09HQk0WzyAkFgZY/7wUyA kGQqU3aKDPgUGYeANQt/OdKcGknmfu+8sJFvFTIh5N8d96m60CPLv7VJd/RVC9bLyTg/ gqoterc2LLI/sIWcwTarQg6W4gVmDZl5trElaGCI9TWWrBkXvaN99XGLZGbsPmAky2u1 NhUXvbOwJOLA7gmg6jTZXwC5Vo69/lERLTR+gaCZhAa6foCMFlJJ7Mw2xnPIbucz3IsJ HpFtjKz78LR8ZwyP1kVzsKBbCCAgeiFbAB3V7isSto/9kRjdCzBzPqu9BMj137xJJjV3 B1Yg== X-Forwarded-Encrypted: i=1; AJvYcCVU/Um6Jt+2JqcEkMj3fnhuHElMAslimi3AJnCG067sLIclwayEb0a82sfzHhJt/ypNk5D75aSNSkcGoMx5PK3lEMZwC8xiKY4wvz1W4lweQFFrnTQ= X-Gm-Message-State: AOJu0Yy7bPSBirJi4YopYK3YbqiZCHVkYzLJZV7Qf69fiLn4iz8cx+JC z/3LVUHmPcISHzoDsSOXSZgSvko3UCiOR5bmTez6kkfPC+2zMNw8gQVpLnvPi52Iy0x59RoTAZl kxfJ2/6TJYZ+U7bZ+W+jnKydCu1LBU7LJ5E8yCAFxUVH/WIA+88Cnh29BZlhfuKFwddWoRn9T X-Received: by 2002:a05:622a:10a:b0:43e:34ea:80ee with SMTP id d75a77b69052e-43fb0e8d809mr134383981cf.29.1716922837929; Tue, 28 May 2024 12:00:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLHIs0G4ODwLtaTgMc9fP7BM4N2EDamkPS2f5rSvXhQ/RuodqmrywBv65gQp5ZlO5A4PV4Ug== X-Received: by 2002:a05:622a:10a:b0:43e:34ea:80ee with SMTP id d75a77b69052e-43fb0e8d809mr134383451cf.29.1716922837199; Tue, 28 May 2024 12:00:37 -0700 (PDT) Received: from localhost (pool-71-184-142-128.bstnma.fios.verizon.net. [71.184.142.128]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43fb17f69ddsm44981881cf.41.2024.05.28.12.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 12:00:36 -0700 (PDT) From: Eric Chanudet To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Mike Rapoport , Andrew Morton , Baoquan He , Michael Ellerman , Nick Piggin Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Eric Chanudet Subject: [PATCH v3] mm/mm_init: use node's number of cpus in deferred_page_init_max_threads Date: Tue, 28 May 2024 14:54:58 -0400 Message-ID: <20240528185455.643227-4-echanude@redhat.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_120044_803135_D3BC9112 X-CRM114-Status: GOOD ( 21.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When DEFERRED_STRUCT_PAGE_INIT=y, use a node's cpu count as maximum thread count for the deferred initialization of struct pages via padata. This should result in shorter boot times for these configurations by going through page_alloc_init_late() faster as systems tend not to be under heavy load that early in the bootstrap. Only x86_64 does that now. Make it archs agnostic when DEFERRED_STRUCT_PAGE_INIT is set. With the default defconfigs, that includes powerpc and s390. It used to be so before offering archs to override the function for tuning with commit ecd096506922 ("mm: make deferred init's max threads arch-specific"). Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions: | | x13s | SA8775p-ride | Ampere R137-P31 | Ampere HR330 | | | Metal, 32GB | VM, 36GB | VM, 58GB | Metal, 128GB | | | 8cpus | 8cpus | 8cpus | 32cpus | |---------|-------------|--------------|-----------------|--------------| | threads | ms (%) | ms (%) | ms (%) | ms (%) | |---------|-------------|--------------|-----------------|--------------| | 1 | 108 (0%) | 72 (0%) | 224 (0%) | 324 (0%) | | cpus | 24 (-77%) | 36 (-50%) | 40 (-82%) | 56 (-82%) | Michael Ellerman on a powerpc machine (1TB, 40 cores, 4KB pages) reports faster deferred_init_memmap from 210-240ms to 90-110ms between nodes. Signed-off-by: Eric Chanudet Tested-by: Michael Ellerman (powerpc) --- - v1: https://lore.kernel.org/linux-arm-kernel/20240520231555.395979-5-echanude@redhat.com - Changes since v1: - Make the generic function return the number of cpus of the node as max threads limit instead overriding it for arm64. - Drop Baoquan He's R-b on v1 since the logic changed. - Add CCs according to patch changes (ppc and s390 set DEFERRED_STRUCT_PAGE_INIT by default). - v2: https://lore.kernel.org/linux-arm-kernel/20240522203758.626932-4-echanude@redhat.com/ - Changes since v2: - deferred_page_init_max_threads returns unsigned and use max instead of max_t. - Make deferred_page_init_max_threads static since there are no more override. - Rephrase description. - Add T-b and report from Michael Ellerman. arch/x86/mm/init_64.c | 12 ------------ include/linux/memblock.h | 2 -- mm/mm_init.c | 5 ++--- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 7e177856ee4f..adec42928ec1 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1354,18 +1354,6 @@ void __init mem_init(void) preallocate_vmalloc_pages(); } -#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT -int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) -{ - /* - * More CPUs always led to greater speedups on tested systems, up to - * all the nodes' CPUs. Use all since the system is otherwise idle - * now. - */ - return max_t(int, cpumask_weight(node_cpumask), 1); -} -#endif - int kernel_set_to_readonly; void mark_rodata_ro(void) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index e2082240586d..40c62aca36ec 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -335,8 +335,6 @@ void __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, for (; i != U64_MAX; \ __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end)) -int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask); - #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ /** diff --git a/mm/mm_init.c b/mm/mm_init.c index f72b852bd5b8..acfeba508796 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2122,11 +2122,10 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn, } } -/* An arch may override for more concurrency. */ -__weak int __init +static unsigned int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) { - return 1; + return max(cpumask_weight(node_cpumask), 1U); } /* Initialise remaining memory on a node */ -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel