Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6219271rwl; Wed, 22 Mar 2023 07:58:14 -0700 (PDT) X-Google-Smtp-Source: AK7set9JXKpXs+uC/GaEus+dewqOOacaFb/32TOsI6Sdnd8QlRC/WQGY/jStqNfNdf6Efic95HnN X-Received: by 2002:a05:6a20:4916:b0:d4:fd7e:c8b0 with SMTP id ft22-20020a056a20491600b000d4fd7ec8b0mr5278683pzb.7.1679497094046; Wed, 22 Mar 2023 07:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679497094; cv=none; d=google.com; s=arc-20160816; b=RTtewt/gbI8DtEOl2tBLS6TMMZMT4aNDNDC8elBo76FOfvNaI0lfA4Mv5xCDq+0GE3 smkOd6nvRgomdpVZ8aPD7nq5dm4YVeTmxDJ8H+eRQ7WNROwbxJWJj2D+Yb3U+5wnoqQ0 4+5kujCY0b9sbIz3cKC2EVUxx1+F4kJQrMPIdF8IwDe8bCLgfjd7THWEi/niS5tHXN02 o+uRS0F7az9W+KZBP/XtyAckZttBgsJ/QIr5vLIdKn/7+fSyp8CWy+wkTfcVlXEQaBmh Nsi35Ar0+XzJkNjFu2heXUKF2Y3oFo0seE0j/mu02p8nfV7WhYnAKifjaaeTaSfDcfCM jPog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=WStsIEd2k7RdaTJPjgss3dQsnOiCKbIVzQh6g0XMjJw=; b=Xn3xqebjdXSJq5wZ/qPGp1NjR5QhNCgytCAZ64PxvimlQFNnbYOYb2EH2y/8ChXi/D 8YVyydwzKATMSvFdcJKi3IiYckazy421oj5n8wEOAMhC+DZzQcM0YIUa0nyt44lZZc8K wneWZ3QpglOZ9ajUJS+JmyeOOcBH39lbOEvDMDQLPOg2oQYQZykm6KiqcAZSxhbGQDlZ d/Xu4dD35WvMk9+TU7T5lxkjdfSt9xq4ORenI95ql+/tNr8QExZvWaj60fztm+IpUXrE BIeMiLhriW4JeGuu2zCuLe/jykMehg9HVzPWIP1xny4PyhkKpuzL3KUc7eqFy5k3sti3 hyTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=keua6vrz; dkim=neutral (no key) header.i=@suse.cz header.b=XDCCaVhw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q25-20020a637519000000b0050f53eec0b2si13284348pgc.665.2023.03.22.07.58.02; Wed, 22 Mar 2023 07:58:14 -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=@suse.cz header.s=susede2_rsa header.b=keua6vrz; dkim=neutral (no key) header.i=@suse.cz header.b=XDCCaVhw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbjCVOvS (ORCPT + 99 others); Wed, 22 Mar 2023 10:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbjCVOvA (ORCPT ); Wed, 22 Mar 2023 10:51:00 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A6F316AD6; Wed, 22 Mar 2023 07:49:26 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B0F8B20EDA; Wed, 22 Mar 2023 14:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1679496564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WStsIEd2k7RdaTJPjgss3dQsnOiCKbIVzQh6g0XMjJw=; b=keua6vrzqFvD9d24VxKeN+P/9uXoYODOqtrErIG/mFeIbZVehzKEskAJmBFCi0Y8xj7WKJ pmcGiXtk38EgR4HUZMpxbVMjRpbT/7Vrs/+Ks0XGUOUlTjb50+aaMtBeacMHGQzY1kN1mf FM6J86xeBjnsaz6TLcApLK3UK5S0+us= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1679496564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WStsIEd2k7RdaTJPjgss3dQsnOiCKbIVzQh6g0XMjJw=; b=XDCCaVhwYzaOWYZn/gP36NSxpReGq7etaOQhGQ5VLmoob+pUe/n+MnmvWWMlCIgQIM3z77 KSRc22i5edVyCsBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 806FB138E9; Wed, 22 Mar 2023 14:49:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OzqNHnQVG2RpNQAAMHmgww (envelope-from ); Wed, 22 Mar 2023 14:49:24 +0000 Message-ID: Date: Wed, 22 Mar 2023 15:49:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v2 04/14] mm: handle hashdist initialization in mm/mm_init.c Content-Language: en-US To: Mike Rapoport , Andrew Morton Cc: David Hildenbrand , Doug Berger , Matthew Wilcox , Mel Gorman , Michal Hocko , Thomas Bogendoerfer , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org References: <20230321170513.2401534-1-rppt@kernel.org> <20230321170513.2401534-5-rppt@kernel.org> From: Vlastimil Babka In-Reply-To: <20230321170513.2401534-5-rppt@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 On 3/21/23 18:05, Mike Rapoport wrote: > 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 Looks like this will move the fixup_hashdist() call earlier, but can't result in seeing less N_MEMORY nodes than before, right? I wonder if the whole thing lacks hotplug support anyway, what if system boots with one node and more are added later? Hmm. > --- > 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,