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: 13180633 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 85381C7618A for ; Sun, 19 Mar 2023 22:00:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F229900008; Sun, 19 Mar 2023 18:00:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A12C900002; Sun, 19 Mar 2023 18:00:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48F59900008; Sun, 19 Mar 2023 18:00:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3A5E5900002 for ; Sun, 19 Mar 2023 18:00:44 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 12EAEC0388 for ; Sun, 19 Mar 2023 22:00:44 +0000 (UTC) X-FDA: 80587018008.30.C23FF8A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 562F520012 for ; Sun, 19 Mar 2023 22:00:42 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cKXnkkoH; spf=pass (imf03.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=1679263242; 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=HGST2anScb4FjWhK/kqFOnDwJJopTO7Qtn7SPmlR7lU=; b=fTCXqHxooY6kmszdch3JO8lmaEosJ1kvtvhueWsiNhWzMKcUaYfvSo58Rj1FoA/HCtJ4O0 KT+5c+4AxsWUiCHSoqrh6RTAQ+Koz1E7u3ggI7JQapLRhY5BxA+Ksgk662lACADRmERYps 7tZXOxl0EVEDKqV8+BHLid/V8Le7O6o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cKXnkkoH; spf=pass (imf03.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=1679263242; a=rsa-sha256; cv=none; b=bPgzSg043sJKM5W6613PZdp54bk/ZcCASe/faTq3gM9mAHfwtGf34xdo/wSl+L3U1DTOX3 k4pm3fXJfTzc0ufuD7Ky4BFJXrEC/M8r+q4ZZ+bhHDVeZQV401gAVexOvyXW/dWQjIhGqW Tr0DsYXD/d6pT4idv2x/f9J3C/alpxY= 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 95877611A7; Sun, 19 Mar 2023 22:00:41 +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-Stat-Signature: f3epkic1mn5xj1a8x3wfputn9jnjn8w3 X-Rspam-User: X-Rspamd-Queue-Id: 562F520012 X-Rspamd-Server: rspam06 X-HE-Tag: 1679263242-150808 X-HE-Meta: U2FsdGVkX1+ylKaIaQbttMeSPOE2BBYDiPajtscd/1x/o0/QrFv5H58lVuNyl3K4tV+vvzP/Hj1cIBe6nbWz32HLlhvkDnbGXp2goRagsiay8S6yHIdd8ZxPx+JcSleCxzfsC7TnIC5AKmEqdbuUtvvsHHuThYfVGVOIfs2QNiX9pD7Nv/cENfbeW7k/D/o8LreQNoSE8ZoeT53cSOUyiBa9rHwTolOT08QVLBranMMWuYs4ecF14LSYjjofbhYxRa2n/kmQu3ig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AIxqev7YOzerSMBMqBXUtrFyaALTDrqOigQSzpaAlP8jyqQ38MUQFom7IQ== 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 --- 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,