From patchwork Tue Mar 21 17:05:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13182965 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 BC555C6FD1D for ; Tue, 21 Mar 2023 17:05:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58F646B0081; Tue, 21 Mar 2023 13:05:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51825900002; Tue, 21 Mar 2023 13:05:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 409C36B0083; Tue, 21 Mar 2023 13:05:48 -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 335466B0081 for ; Tue, 21 Mar 2023 13:05:48 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 01AB280224 for ; Tue, 21 Mar 2023 17:05:47 +0000 (UTC) X-FDA: 80593532376.18.60C6121 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id 5DC0A4001C for ; Tue, 21 Mar 2023 17:05:46 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ki4HDy3h; spf=pass (imf27.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679418346; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=x3MfkibJ4adH3NfdLHIJ+Y/HBqs8dwjVDFl43aXPj98=; b=wcmJTAeSSG5NW2Cc0GoOsQe1v4gvGoaaM6C3GPtWqQe1gApR8QNVHCBR1JoqLm1FaHQDFS GFuxczH6e/pO4PkVHn8wPACA54Gma0m4bTjrTI0WOujBDXc3/1IjR2bD/Zfz4HuJgf9El7 M8/JgoPJ4E1PV8wEhdTsHKEeMZZttWY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ki4HDy3h; spf=pass (imf27.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679418346; a=rsa-sha256; cv=none; b=BXEHsg2IJXDC61u28u0dLdyl3GCLL8pJrRaI77auPWbxDmwlSaqyk4ULL2qW7z1VPA5Oaj Z+lhDycFqiToP/Nt6PBg/7z+r4ByTB+gAAd05FZFJmBKWK5E5Glz/T9DX4713MnLA7zDhm j5bmZobvYtZcaZgxNbaXi/wWVHX0EqA= 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 dfw.source.kernel.org (Postfix) with ESMTPS id B002561D4F; Tue, 21 Mar 2023 17:05:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4D45C433EF; Tue, 21 Mar 2023 17:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679418344; bh=MPWRuoot5VH9l7RTC3NQyqOuQ7W1sTgroDlLaej4jgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ki4HDy3h8Gte0ZZEiRROBgIVBKFw/KuBSOBtijYBxEVe/p0aoS4vQdaXkNPzwqJiy jm62Y7wVswZ217UB4t9S6RFrE+xX2Aao48V72Jt+lJScMIs2rLYjzI38K++ZlzsIkN i/L8Zo/nLOb/yunaZ65ZbQOSUL5sKCjfTgEaxzzfUa94sKcDTnLlLzB5lPAVdkSyyy F8EUSzfSGiOVR8MHUlvJfsNjsn63XilQL/5NFHyCYEiYete/89jyWdOkUmMYvIpQ5N we3BPRxPxI0VZoDmzEjWBv4KLNuxG9TJ5NQq7Hxa4nTmiROIigUvgn7nULl7rQz+Jr MhE9LOk0eZosw== From: Mike Rapoport To: Andrew Morton Cc: David Hildenbrand , Doug Berger , 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 v2 04/14] mm: handle hashdist initialization in mm/mm_init.c Date: Tue, 21 Mar 2023 19:05:03 +0200 Message-Id: <20230321170513.2401534-5-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230321170513.2401534-1-rppt@kernel.org> References: <20230321170513.2401534-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5DC0A4001C X-Rspam-User: X-Stat-Signature: argk56hdc5o6k1ngw9nzie3kjzup6hda X-HE-Tag: 1679418346-965266 X-HE-Meta: U2FsdGVkX1+02pM+zfQSwXKByKU8KIztZqXnTAUTtGfvSuKo4Fz2g4ahAVpkuqJqnjKwC0gPnXMy36EQlF+g+kLdkbWzi26GECiCaaEQguSoCQHUF39MW3THjOvHQY3ubEp3DOn5z14kK9/IOaxaXj2eO7D3p9ZKIintH/PZ6ot78zyMe9tR1CnnPxiV6Zz0Q5dfwjeGvmwMbiDLJHmHoGfqjk6SOGH+OqTSDEJFzCA9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xZkPU4AaYESpFW+4z+0aPBP8ZyhXWTXtFfl7IBypkAhSBHBoFnPMuZCrZ3OdnaaiC8JF3wb83fiFuWo0M20TMVU= 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: 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 Reviewed-by: Vlastimil Babka --- 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 68d0187c7886..2e60c7186132 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,