From patchwork Sun Mar 19 21:59:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 71908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp901331wrt; Sun, 19 Mar 2023 15:29:20 -0700 (PDT) X-Google-Smtp-Source: AK7set/qKU0jwZUbiVm5JatqiD8dVbvaUNb5am1yPQOM8oCyw6di6B0Hf/UdNi03WXAenodap9KZ X-Received: by 2002:a17:90b:3b4d:b0:233:ee50:d28b with SMTP id ot13-20020a17090b3b4d00b00233ee50d28bmr16700646pjb.16.1679264959734; Sun, 19 Mar 2023 15:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679264959; cv=none; d=google.com; s=arc-20160816; b=pbvj7bfpdNaM5l1r8y+ClzdYyno8NuKpAgbavCk7DWwQEeRV1yathjC6qyls0/APu1 nt+EkK1HemWZ+VTA9wVarmyyLpYAvserg51G5Z60zOYqM09DT2Yzl0Gk7REGhBJtjrtf pUZB6mjvrkt6bZ9iGzcpkKFb1Xfy7HTYVKfUymyHvvChfynOnOqNR0BBnJeLB1ho/LJZ sIerbOmlIBxSNbTXo+P5h2hFq2hApU0BDawti0uqfR4v6MYyzHF2W+Vg+L03S0n+W7x+ S21fiO/v34Z2ETloxHsq7ALSC9HSHwr93JHXKKNK6QzsaMFYfChqSQtwTawQ5CPoNdYL mX7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HGST2anScb4FjWhK/kqFOnDwJJopTO7Qtn7SPmlR7lU=; b=C80wcV1otb0Rw+g6V3k/pZOISxL6iGo+1MohSuKIQ+YzneJbrmnCD9GM2PVzUpjxN0 7lBl6RDHqX7+a60tt5eIyOmIo5pNwf9SDCiRYCC7a0sINfo6rRMgyVgP7u5GICiLpEWQ NUlmI6r3M3STDEc0YqPvvIAgXHoVNC50rjiXPPaYn8H8RKv1SFlxHaLBA7RBde6octQ7 +nJ2T2ILOPEG+y08/jJRTwzxlDT5i44/Ph41Kq3iBrK0OYjrjFTXj8Hps7xJb0Oneall RQCDk2iDOejP1XVPsLLkr9jYutjlRn3/59qQ0SaaQ9l2HjO5Xv1S0UH1Ouswmyiz+P3V 9ZUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cKXnkkoH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a170902a60900b0019e88c6d81csi8310773plq.503.2023.03.19.15.29.07; Sun, 19 Mar 2023 15:29:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cKXnkkoH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230089AbjCSWBQ (ORCPT + 99 others); Sun, 19 Mar 2023 18:01:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230228AbjCSWAu (ORCPT ); Sun, 19 Mar 2023 18:00:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15251D926; Sun, 19 Mar 2023 15:00:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3D829B80B8A; Sun, 19 Mar 2023 22:00:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB2E8C433A0; Sun, 19 Mar 2023 22:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679263241; bh=P8FXnqE0dz8+EFTBTuViTvRWyj1tIPqZHteVCKqB69c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cKXnkkoHgl0euhog4fZoR5wa1c1Sd1phnsl14UWKcX5nkks8OeN3Jxnh6Fc9iJydM DzTs8rBsC1k3D1xz99rAr1FAM4G1QaAtbwlmRgyLhloYNQdUTrdTseiSply+39hlVB J7unwXUSRZjkZBtSLNT46Su7PVQfoEmN4alECNByK10OBwwFvM4I4brCN67bkGyqdw +8Axk9QL2Ld8K7ysWax2H47g1RkxYxAqYMYxygOXB79+RlEsaM7B5HbLbhZmUsZ62f 4d4yuRcfRDuNKFHgp5qUQzLj6gM3u83AijuLjnnZvEjGwLzkSxFOwg7KDjRtZGLLBf IiyMGiuxlsp/A== From: Mike Rapoport To: Andrew Morton Cc: David Hildenbrand , Matthew Wilcox , Mel Gorman , Michal Hocko , Mike Rapoport , Thomas Bogendoerfer , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/15] mm: handle hashdist initialization in mm/mm_init.c Date: Sun, 19 Mar 2023 23:59:58 +0200 Message-Id: <20230319220008.2138576-6-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230319220008.2138576-1-rppt@kernel.org> References: <20230319220008.2138576-1-rppt@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760836934535735639?= X-GMAIL-MSGID: =?utf-8?q?1760836934535735639?= From: "Mike Rapoport (IBM)" The hashdist variable must be initialized before the first call to alloc_large_system_hash() and free_area_init() looks like a better place for it than page_alloc_init(). Move hashdist handling to mm/mm_init.c Signed-off-by: Mike Rapoport (IBM) Acked-by: David Hildenbrand --- mm/mm_init.c | 22 ++++++++++++++++++++++ mm/page_alloc.c | 18 ------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 63aa7b6b2880..8aaaddd13a20 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -607,6 +607,25 @@ int __meminit early_pfn_to_nid(unsigned long pfn) return nid; } + +int hashdist = HASHDIST_DEFAULT; + +static int __init set_hashdist(char *str) +{ + if (!str) + return 0; + hashdist = simple_strtoul(str, &str, 0); + return 1; +} +__setup("hashdist=", set_hashdist); + +static inline void fixup_hashdist(void) +{ + if (num_node_state(N_MEMORY) == 1) + hashdist = 0; +} +#else +static inline void fixup_hashdist(void) {} #endif /* CONFIG_NUMA */ #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT @@ -1855,6 +1874,9 @@ void __init free_area_init(unsigned long *max_zone_pfn) } memmap_init(); + + /* disable hash distribution for systems with a single node */ + fixup_hashdist(); } /** diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c56c147bdf27..ff6a2fff2880 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6383,28 +6383,10 @@ static int page_alloc_cpu_online(unsigned int cpu) return 0; } -#ifdef CONFIG_NUMA -int hashdist = HASHDIST_DEFAULT; - -static int __init set_hashdist(char *str) -{ - if (!str) - return 0; - hashdist = simple_strtoul(str, &str, 0); - return 1; -} -__setup("hashdist=", set_hashdist); -#endif - void __init page_alloc_init(void) { int ret; -#ifdef CONFIG_NUMA - if (num_node_state(N_MEMORY) == 1) - hashdist = 0; -#endif - ret = cpuhp_setup_state_nocalls(CPUHP_PAGE_ALLOC, "mm/page_alloc:pcp", page_alloc_cpu_online,