Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5004984rdb; Fri, 15 Sep 2023 21:55:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqNFlfYH90Pff43l+UyAsuHWKLN7W0gm0XC9BycveazBcIiN4HPnrMYnFriXW2i7E4S6Kh X-Received: by 2002:a05:6870:468a:b0:1d6:5133:2f37 with SMTP id a10-20020a056870468a00b001d651332f37mr4005474oap.48.1694840153639; Fri, 15 Sep 2023 21:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694840153; cv=none; d=google.com; s=arc-20160816; b=grTMaGZjG6wM1kLat/UA2ZsOfdqJrikLGy4wsCtTRdvuiUzj4XnAF5WvBweWctOmNw wkODAbeJ7kkPkhHu8GQj3571neOkP5B47VneeypQT7kxkHMLOgG+Rbd3s6DLwxoOchfr eELVJBxP4bgXv6TUq5XXB22sJ7bTRY0sXn/UNRvxGO4JBQoIzN0WU1XhYDXrbw1PGufi vaxmgpZu275Kutbx6aLHmEy3fKyAtyFjxgB6un4fqOlSADWMXiS0S9/q7BwWnpA3lKim waOPFIxXiydukEDox6GI/SdvCI9R91HBUm4TELYJFiQmxWeJgM+bdMFlZkYFoxIyCjzp DBJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZpfbgJ5FdmMlvqcljfZeMWdf6Pp3ie+fbXvpKVgnxSk=; fh=3aD2Iy0URaCxht7bq17LHBic940+47SSfmXQFn0mBFY=; b=0HQqAavfuTC6Kh5Xf6x5VZGg9lVPyOGS03t6PdPqoghtzUvHFNfRCPPVzvHR3zpaZZ 0VjcCRRH/n0MN8laess34++tpD7DIuNajW62d8Sb2ElcgUyYCc9jVolAYsbvZy9ffSRQ Yi/PpUxZMIuIhDc10flR9ztuOqQZTlS9lDWiu0bkwa7WdxLH5BU0sNrmHS/e4bLHSgds +lvkzSxZEw0nT8T3PvklXkKVSg0TCrk7B1fw7djJ6kebCvF1vgchX4TGF5MR4M+afQgV hCHBHYEYXnQ9phhBN5f+3O2xnNY1fMOHUValdptwSsu8IsV4/mOJMPC7tF5A2uvslcNX QE1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z9WftRfM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id fb3-20020a056a002d8300b0069028222ae7si4405934pfb.231.2023.09.15.21.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 21:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z9WftRfM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C9CB481B75E6; Fri, 15 Sep 2023 06:04:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235229AbjIONEc (ORCPT + 99 others); Fri, 15 Sep 2023 09:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235155AbjIONEb (ORCPT ); Fri, 15 Sep 2023 09:04:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7CFE31AC for ; Fri, 15 Sep 2023 06:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694783017; 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: in-reply-to:in-reply-to:references:references; bh=ZpfbgJ5FdmMlvqcljfZeMWdf6Pp3ie+fbXvpKVgnxSk=; b=Z9WftRfMZ6po/DxkkmdQdcU4nxyQ867pY0M5yfywqDkvEJmtmbbb3UpLt6/bpKdpwWNkoC 0K9wBlekPBIDcpKZYZTEYaPm5tJvjU/0G4G9b3VUahRd/Hv5LU2rEI7xQeFLmgYMOPlnBQ W9WB8XPelFINoQ/nGp3y3RwFw9uVOCM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-CFYeF0T8NXStZbVp2ZErcg-1; Fri, 15 Sep 2023 09:03:33 -0400 X-MC-Unique: CFYeF0T8NXStZbVp2ZErcg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB87780A154; Fri, 15 Sep 2023 13:03:32 +0000 (UTC) Received: from localhost (unknown [10.72.113.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16DDF1006B70; Fri, 15 Sep 2023 13:03:31 +0000 (UTC) Date: Fri, 15 Sep 2023 21:03:29 +0800 From: Baoquan He To: "Uladzislau Rezki (Sony)" Cc: linux-mm@kvack.org, Andrew Morton , LKML , Lorenzo Stoakes , Christoph Hellwig , Matthew Wilcox , "Liam R . Howlett" , Dave Chinner , "Paul E . McKenney" , Joel Fernandes , Oleksiy Avramchenko Subject: Re: [PATCH v2 9/9] mm: vmalloc: Set nr_nodes/node_size based on CPU-cores Message-ID: References: <20230829081142.3619-1-urezki@gmail.com> <20230829081142.3619-10-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230829081142.3619-10-urezki@gmail.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:04:30 -0700 (PDT) On 08/29/23 at 10:11am, Uladzislau Rezki (Sony) wrote: ...... > real 1m28.382s > user 0m0.014s > sys 0m0.026s > urezki@pc638:~$ > > Signed-off-by: Uladzislau Rezki (Sony) > --- > mm/vmalloc.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) LGTM, Reviewed-by: Baoquan He > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 9cce012aecdb..08990f630c21 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -796,6 +796,9 @@ struct vmap_node { > atomic_t fill_in_progress; > }; > > +#define MAX_NODES U8_MAX > +#define MAX_NODE_SIZE SZ_4M > + > static struct vmap_node *nodes, snode; > static __read_mostly unsigned int nr_nodes = 1; > static __read_mostly unsigned int node_size = 1; > @@ -4803,11 +4806,24 @@ static void vmap_init_free_space(void) > } > } > > +static unsigned int calculate_nr_nodes(void) > +{ > + unsigned int nr_cpus; > + > + nr_cpus = num_present_cpus(); > + if (nr_cpus <= 1) > + nr_cpus = num_possible_cpus(); > + > + /* Density factor. Two users per a node. */ > + return clamp_t(unsigned int, nr_cpus >> 1, 1, MAX_NODES); > +} > + > static void vmap_init_nodes(void) > { > struct vmap_node *vn; > int i; > > + nr_nodes = calculate_nr_nodes(); > nodes = &snode; > > if (nr_nodes > 1) { > @@ -4830,6 +4846,16 @@ static void vmap_init_nodes(void) > INIT_LIST_HEAD(&vn->free.head); > spin_lock_init(&vn->free.lock); > } > + > + /* > + * Scale a node size to number of CPUs. Each power of two > + * value doubles a node size. A high-threshold limit is set > + * to 4M. > + */ > +#if BITS_PER_LONG == 64 > + if (nr_nodes > 1) > + node_size = min(SZ_64K << fls(num_possible_cpus()), SZ_4M); > +#endif > } > > void __init vmalloc_init(void) > -- > 2.30.2 >