Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp496969lqb; Wed, 29 May 2024 01:52:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4+Z2EDLsrmzNAPrYE6yJaJhELGM5hQg87hcXCF81OhpuiWT/hwQVU0dPcptaVZ3waG384VdT338gsxX1kHo1LCSrvPkA0uza4qkiSWw== X-Google-Smtp-Source: AGHT+IFWdlDFTFik1tXsXqP75uLTSiCiRKv+LY4JrlvLiMemChvJfdt6boOIR3atcHF5YouU7pp7 X-Received: by 2002:a05:6214:3201:b0:6a9:673f:de3 with SMTP id 6a1803df08f44-6abcd139693mr145830116d6.48.1716972747634; Wed, 29 May 2024 01:52:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716972747; cv=pass; d=google.com; s=arc-20160816; b=AtEEiJoIy1qqq2/mOZw9OImZGMK2oEjKpymM8+xF2OPWsCVDVQ5HT/8ZXAMcu7HxHO PmtA7h71lSObfGLQkslV6LpG3dg+h6AiQYUyOWL6z/OuiQxl8LULxyo15ZbJ4R4i7Vbh 9AYhDqiZ5hGzgOfA7UiNfujWP/He/3leV6XRkvEAqXZC1iX7gyYow6OAyEak38iCyArI PuhlVtl7DyzhUPyZCRAGxr6lBNJ7c7DbQWk1/qC97k/zGK1IONsEwbRPvzSEMSA9DW8p 6YkB1yDdVhEjqRbD1LqAefsOfhIs3/mb6ljTL6UXvfkj6WVB/Qhg0fhw+dnoZQrLE84i 8ucw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=znIpA3udPqKI4MZkxSxCZR6WCKKDK3sQ7qzxLXZGsaI=; fh=WgU02omxYJO0l7aWL7mNpmgdxyNUAMkX7Bg2u16zY+E=; b=Ghf5ZWtuCx7IOZsxwbmR5GwfdU6SH7erntmeCcnRUmlIY8lsTN2bw0JZli25CdY7OA AsOmFSbdLlIqUYxrqYEPbqYUf5jHGuFgQDxqic5gcike5FLh0MGSJtnW063DducQ5YxL m6AM/MYUDHfifWl7HPQgpAP3KyQDjePMhF1nSO0yk1driypdhv5xSpG06NDYsnsYE1e8 aXBjfFi/q92ivt7aRRrP93GZjoqirlWlSM/3oPlpQTBA8mPEtv9kIBrzmCbAGH0v+VOd 1YPy45ArpystjnoZJmnp0j7c5xhnxvJUyPTdYwford8uLfn84Kr+Gma0zd4WRWrtftXE QUuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="I/wJZpQT"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-193796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac162b3837si123485676d6.438.2024.05.29.01.52.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 01:52:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="I/wJZpQT"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-193796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 5156C1C2346B for ; Wed, 29 May 2024 08:52:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDE8B17B404; Wed, 29 May 2024 08:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I/wJZpQT" 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 E127617995B for ; Wed, 29 May 2024 08:48: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=1716972524; cv=none; b=F4PjIcmRPqlv5Jk67+etUViBkSXo7XhA8Y2Rl+L9i+nFWuB2Q5LVoWElC5mJSPhsKKFzDtTfa7aVNFWXImJ9I7viFeJt8rjlY9JdDDYuYzH8MOj91dKX3K4KM4rJ1Dnj3Rz7wepx/Q0es/QzIi1zzG93Stn8mFLmclGz0FuH360= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716972524; c=relaxed/simple; bh=+i8HiSPRhTKcPyCksq58UaPubny0a8rrctX46TVvSMk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RGZmCSrws2cFhByF8RjIa0m7qoqn72dHCSfgfGrb7Vvhhz8jNPSpZRUU7Q7bsvzAybjXq90fzcv5BC5Bz4NcBq1mfi118OMBedERiO1TXqG7s6/LSDZ7f9geO8ts6sE4ZpcdNiNJXJ7hpoDsitJA7xyUmbcIai2ZL+FzeiFpqMs= 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=I/wJZpQT; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716972520; 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=I/wJZpQTje82vgG33dIsyJFn45REaNDqy0607Dkl7KJY/sjqTB9t1WbrbV/iXEeBMKLk4w E+rQ+lvchzBISTXoU5XlZLM6/5BSFd8SQmYWKuuxKsO8BaAjptYbjr4PNDTVbtf7FDWEi4 EVKZFLQESw6hOTT250KvZp3nSANIZvY= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 >