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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F03FCC25B75 for ; Wed, 29 May 2024 08:48:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EAB16B00A9; Wed, 29 May 2024 04:48:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 499B36B00AB; Wed, 29 May 2024 04:48:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33CA76B00AC; Wed, 29 May 2024 04:48:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 100D46B00A9 for ; Wed, 29 May 2024 04:48:44 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BAFA3A0CF5 for ; Wed, 29 May 2024 08:48:43 +0000 (UTC) X-FDA: 82170807726.03.7033E9B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id E48851C0024 for ; Wed, 29 May 2024 08:48:41 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=In7miBU2; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716972522; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=znIpA3udPqKI4MZkxSxCZR6WCKKDK3sQ7qzxLXZGsaI=; b=lvd94dI56b0q8Mcz/CnLDHbAmUPJsjjCbn7IuJ4ZvkOYC/HTbMzOGX6avCo+irXpdkyHUz WHDN5qmW5mth6bYHh+yk8oYWGRO870B9TTPSLnn4icJagSm6tf3angO+5FPBC6KT39PPAR DExGmni/mi3RZsthBV9KeusK5cG2sXM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716972522; a=rsa-sha256; cv=none; b=yI4hktzewcnpmIxD8lFQZBYSiH85/Wm1dis1fhTTl+Jsrk3chgepDSmVNzRRgGJDx/X4kr bC3Yq+dcUrZQJ0447Tq8I1ZGXmuaBPjkHsIQ6HLAFNV4Vb31QznUlBpScxNd2Wgkq3LMBx xVH1Yy8nc7lKDZPIRyC2PJ2KzdHWuW4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=In7miBU2; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716972521; 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: in-reply-to:in-reply-to:references:references; bh=znIpA3udPqKI4MZkxSxCZR6WCKKDK3sQ7qzxLXZGsaI=; b=In7miBU205BHJqcmbYRN7dkSXzYRmcxx5I8pEgO2Fn989rgoRInV5N+M/DxQmWS356xWud VmbuMkUo2g34ZComvu5IRu1cHS6RCX632hMi2gX/pRDfxuxr0iIcolzn/gbeFXbO/Z3qO+ 9EKxxzZni3MgKvf/E9HtV6mQhd4VpeU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-fYMqePKiMEm9xRyDkphb7w-1; Wed, 29 May 2024 04:48:37 -0400 X-MC-Unique: fYMqePKiMEm9xRyDkphb7w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90DC185A58C; Wed, 29 May 2024 08:48:36 +0000 (UTC) Received: from localhost (unknown [10.72.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CDD611C0D104; Wed, 29 May 2024 08:48:34 +0000 (UTC) Date: Wed, 29 May 2024 16:48:31 +0800 From: Baoquan He To: Eric Chanudet Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Mike Rapoport , Andrew Morton , Michael Ellerman , Nick Piggin , 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 Subject: Re: [PATCH v3] mm/mm_init: use node's number of cpus in deferred_page_init_max_threads Message-ID: References: <20240528185455.643227-4-echanude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240528185455.643227-4-echanude@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspam-User: X-Stat-Signature: g1m6ykh5eo1eexbzdfz89k55mjmoj8ae X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E48851C0024 X-HE-Tag: 1716972521-909825 X-HE-Meta: U2FsdGVkX1/6cCzPJL4VnThu/Lu/CmS7K4zqCcqWRUeheMEE+l5fR/i1gRRGsINPUMv1sWY2P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kdEE95/El1+MoFVKHJUu/1K14lGtuUShcDsS7edRIRjrRil/7x25NEI/wMLffIeKduJzQU1pW223R0nNX0xrDhecweQp1F5ZhN39pUa7SrCt28OW+IVDKcrLqwxLgXO4e/nXVi+iXDaxapUFfQF6SQYZzR4zS7o8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 05/28/24 at 02:54pm, Eric Chanudet wrote: > 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(-) Reviewed-by: Baoquan He > > 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 >