From patchwork Wed May 22 20:38:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Chanudet X-Patchwork-Id: 13671087 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 1879DC25B7A for ; Wed, 22 May 2024 21:10:45 +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=mY1xI9ok9+JLfeMvszOSVBI4FVQZZD5xhIzC6CnhZ9A=; b=I1vIUFSBnOB75W TDXmX1tDepdrcsqv8/GcOZpVwRF+QURDMJYLXnGFSaNPo70GyWk6hgGRkhHtU39gZ6IJooBSxmeC3 PMssaks+L4N9NFX0U9UcycBnh30bmSF568KJ1i2qN3g01n0UMjN91uiRoIlWXLbTLFloIEdkgNGrE atVJ1Trlx7cnc8MMW2/zBnuXmZCm01x0bPGXHgG1SUKTBGcUFP8dTHELUHlBSI9pe9HvZzGqZ09sk bp43P217YgVXXf/3T1FspSWYSQ1wMiX0B66SmpXDE7JaUgDNGrMUoTQL0JvZ0F0sAv09fayvzkMle RQLFXUt8u4Sb0ZbVCrmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9tEG-000000047jZ-2ifX; Wed, 22 May 2024 21:10:32 +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 1s9tED-000000047iX-1QGE for linux-arm-kernel@lists.infradead.org; Wed, 22 May 2024 21:10:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716412227; 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=BFrd5ebkEcX4DAl9U00OWoi+E1totBiZiszJ1VoHyFU=; b=Lyc20h8v7wDH7UK7pWsSMNuntvkL+a6nJitIEs/e0YQT8wgM6jnLBsdgDjmNfuO6EjSE2+ lkHF46ybJZpFpfu2PnfFIlBXm3hVulaLsrTpjXyquBOQCSmyhXaL6MrfzOv/xEbmL6wnCT /WKWLtAM4wQcyjAqv6+KZIgaTwrY0EM= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-PgnuGQcLPAq_PTYq9pMY-g-1; Wed, 22 May 2024 17:10:05 -0400 X-MC-Unique: PgnuGQcLPAq_PTYq9pMY-g-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-43d1e3e7730so169065581cf.2 for ; Wed, 22 May 2024 14:10:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716412201; x=1717017001; 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=BFrd5ebkEcX4DAl9U00OWoi+E1totBiZiszJ1VoHyFU=; b=OZOQtLo3Uxnm3fs/nip/dThBrbTk51GXZC2wyaG1YgJysWGS12gdReZBW1vJZ8U/6g 5Jak9RTHwT9a3ChT+O4tNngaVWTCHLZPfdt842HG7saT5ugObK5oYcct6DnuGjoLKrId VhXtw2HGiPHu0kUJHHQzHNxZBa/A/ApzzTtSQXbXfLpBd0xzx8AXQl620aV9cQ3lAR0Q r+i+6KLwb2h19nwA9Opt936IxCda2u9SItffEQjC0SamQ9lcBjBSRdl+jKesmTZepBiN U6iYZqJsU+zlLGNr/38TNmbTKt/FXTZ1VUoNMgfPP5VMnfsjIZxx8eZyAIiFjgpfPqo+ qjSQ== X-Forwarded-Encrypted: i=1; AJvYcCW2a56K6G6cqPWFE/jByhnf2OEVMo3mlUgG7Azcd+UdoFIFwXcDuLSSctxDEh8cv0CcGObHcLJoCYBxVDOZdKq5/xy0DpFEdaV2YjggSh7RD6eV2l8= X-Gm-Message-State: AOJu0YxjaZAJxADBZOgiZjW9ZDNGz5mB3Apdzc2eRWDBtCWH3H6fARJU jXW17X3e+3IPQZ9EVkWUef9Gn+LvArXtA+sO8VK2b3BbvWIggxLJG1nKkY/2bMTcnS/DjUtTnfe UXJcwdumY8WrC6iBiMkIilCoY6W6QQXKJp5W6wGMeNNYJ4ZI6rDQDHCtpTlKd4HmKZ5R3W6Mw X-Received: by 2002:a05:6214:5b8a:b0:6a3:48af:8e82 with SMTP id 6a1803df08f44-6ab80900d8dmr35624606d6.46.1716412200543; Wed, 22 May 2024 14:10:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFReHW/gidOrXfSOPUsmAujbeGWtlLPFc/p6bBtQ535MfveRlLhqKqI7KsQ5F/jf8a4uc7Dvw== X-Received: by 2002:a05:6214:5b8a:b0:6a3:48af:8e82 with SMTP id 6a1803df08f44-6ab80900d8dmr35624146d6.46.1716412199899; Wed, 22 May 2024 14:09:59 -0700 (PDT) Received: from localhost (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6a35d0bfeabsm73204686d6.2.2024.05.22.14.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 14:09:59 -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 v2] mm/mm_init: use node's number of cpus in deferred_page_init_max_threads Date: Wed, 22 May 2024 16:38:01 -0400 Message-ID: <20240522203758.626932-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-20240522_141029_466844_5320FB2B X-CRM114-Status: GOOD ( 16.21 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org x86_64 is already using the node's cpu as maximum threads. Make that the default for all archs setting DEFERRED_STRUCT_PAGE_INIT. This returns to the behavior prior making the function arch-specific with commit ecd096506922 ("mm: make deferred init's max threads arch-specific"). Signed-off-by: Eric Chanudet Tested-by: Michael Ellerman (powerpc) --- 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%) | - 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). arch/x86/mm/init_64.c | 12 ------------ mm/mm_init.c | 2 +- 2 files changed, 1 insertion(+), 13 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/mm/mm_init.c b/mm/mm_init.c index f72b852bd5b8..e0023aa68555 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2126,7 +2126,7 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn, __weak int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) { - return 1; + return max_t(int, cpumask_weight(node_cpumask), 1); } /* Initialise remaining memory on a node */