Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3159184rdb; Wed, 13 Sep 2023 04:07:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETji8B4I1QzSzxRJxMZkioox1xfuKUIwTLv/SNrNmtHndww7NQNoFrs32j4oR3F5/++6zD X-Received: by 2002:a17:903:245:b0:1bf:cac:13b4 with SMTP id j5-20020a170903024500b001bf0cac13b4mr2637848plh.5.1694603269529; Wed, 13 Sep 2023 04:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694603269; cv=none; d=google.com; s=arc-20160816; b=fRzTx2DWraAGxf2sr/Jxt7rtDKfTi7DuYW7AI8T3Qffw6ualinw7EQY52g0GTYcCbA kFxPhGHxsBl0a2YiHKVxf7CHZ3dOObA16GoFWDyXJvZS3EbXmiI+YkLyntVp6GUiI88o 73O8gDTQkrY/l6V5DxPmHxa2bqgVyBpdE706qcTEOz7tsOpwjnvoh9tBQaBUZKLq6/DR /nLm9KphoSrhTzMPKppzhQsuuLCTFLumBjVngBqt8a2PO6KmiWQn/6hgBCLO6E93OL3e cf+5xzCY+6YZ6/jqQ1dTNDtaXkP3wR7FDqv9GGm4o3XA9M679Dx2atpDhJ/c8Ta4PGyf P07A== 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=45vYBZ3G2jZIqFieNjtpHSeDEfoCcr3MhetjZ/eAgmE=; fh=slJMzQ1RvrZUOlfD2500Kf4ZO6ZGA+3mv2ASwoAyUK4=; b=VgBwZLu17oKZtq29SaLVmqwwKA3j+n/d86yecHAq8zRhy8QIU+fqKuFpSeSGuLwtv7 ZZntl6PQBQtPycv2bprZ9tbZ1oB8F/0PN9fWdSgDalszONS1pf04TLgdnSxTKmSAh60X oS4lT3Sr+OE7N6m3EH2RXUcBC6zKE41zf69pQTckGvq6YMI1JkmLjQCI4Pn/iD9W64gA KY7WzW2wpBYCxgFuY7xBuXDRZt7rGbO3y/ZrFZ3DcZSH/WqmwvMr3/qOB3RisLHjr2hx VmO4P5G17qPjmiq7MLpj2WK2CsOLKN5hQLzAtb1DtQ7Jw0gMRb2a4/41AU2qsm0+C399 Wm5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GScva/nz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id kv12-20020a17090328cc00b001bb8e3f3475si9685174plb.52.2023.09.13.04.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 04:07:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GScva/nz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 587C884EE54D; Tue, 12 Sep 2023 06:20:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235467AbjILNUI (ORCPT + 99 others); Tue, 12 Sep 2023 09:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235320AbjILNUH (ORCPT ); Tue, 12 Sep 2023 09:20:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 668D710CA for ; Tue, 12 Sep 2023 06:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694524757; 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=45vYBZ3G2jZIqFieNjtpHSeDEfoCcr3MhetjZ/eAgmE=; b=GScva/nz7RwAAy/ILU2qlFwZ4nSQvzpTyfrBz46aKPXXNwbIYc3SIvd3/3hFn4Y1SY4jUh RXu+0mIWNe5fwYb1Smai2bYBzIDFzLL2Zdi92CgnVIR/8alwfdWH37QyFQKYOwpcVytibZ F+BsPmMecdtvbY9pPw3+6mbCUffjOtk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-298-VwJ5igqmMbWEkGlt2SHWzA-1; Tue, 12 Sep 2023 09:19:16 -0400 X-MC-Unique: VwJ5igqmMbWEkGlt2SHWzA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 879533C18DD1; Tue, 12 Sep 2023 13:19:15 +0000 (UTC) Received: from localhost (unknown [10.72.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A94172904; Tue, 12 Sep 2023 13:19:14 +0000 (UTC) Date: Tue, 12 Sep 2023 21:19:11 +0800 From: Baoquan He To: Uladzislau Rezki 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 4/9] mm: vmalloc: Remove global vmap_area_root rb-tree Message-ID: References: <20230829081142.3619-1-urezki@gmail.com> <20230829081142.3619-5-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 06:20:08 -0700 (PDT) On 09/11/23 at 06:53pm, Uladzislau Rezki wrote: > On Mon, Sep 11, 2023 at 10:38:29AM +0800, Baoquan He wrote: > > On 08/29/23 at 10:11am, Uladzislau Rezki (Sony) wrote: > > > Store allocated objects in a separate nodes. A va->va_start > > > address is converted into a correct node where it should > > > be placed and resided. An addr_to_node() function is used > > > to do a proper address conversion to determine a node that > > > contains a VA. > > > > > > Such approach balances VAs across nodes as a result an access > > > becomes scalable. Number of nodes in a system depends on number > > > of CPUs divided by two. The density factor in this case is 1/2. > > > > > > Please note: > > > > > > 1. As of now allocated VAs are bound to a node-0. It means the > > > patch does not give any difference comparing with a current > > > behavior; > > > > > > 2. The global vmap_area_lock, vmap_area_root are removed as there > > > is no need in it anymore. The vmap_area_list is still kept and > > > is _empty_. It is exported for a kexec only; > > > > > > 3. The vmallocinfo and vread() have to be reworked to be able to > > > handle multiple nodes. > > > > > > Signed-off-by: Uladzislau Rezki (Sony) > > > --- > > > mm/vmalloc.c | 209 +++++++++++++++++++++++++++++++++++++++------------ > > > 1 file changed, 161 insertions(+), 48 deletions(-) > > > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > > index b7deacca1483..ae0368c314ff 100644 > > > --- a/mm/vmalloc.c > > > +++ b/mm/vmalloc.c > > > @@ -728,11 +728,9 @@ EXPORT_SYMBOL(vmalloc_to_pfn); > > > #define DEBUG_AUGMENT_LOWEST_MATCH_CHECK 0 > > > > > > > > > -static DEFINE_SPINLOCK(vmap_area_lock); > > > static DEFINE_SPINLOCK(free_vmap_area_lock); > > > /* Export for kexec only */ > > > LIST_HEAD(vmap_area_list); > > > -static struct rb_root vmap_area_root = RB_ROOT; > > > static bool vmap_initialized __read_mostly; > > > > > > static struct rb_root purge_vmap_area_root = RB_ROOT; > > > @@ -772,6 +770,38 @@ static struct rb_root free_vmap_area_root = RB_ROOT; > > > */ > > > static DEFINE_PER_CPU(struct vmap_area *, ne_fit_preload_node); > > > > > > +/* > > > + * An effective vmap-node logic. Users make use of nodes instead > > > + * of a global heap. It allows to balance an access and mitigate > > > + * contention. > > > + */ > > > +struct rb_list { > > > + struct rb_root root; > > > + struct list_head head; > > > + spinlock_t lock; > > > +}; > > > + > > > +struct vmap_node { > > > + /* Bookkeeping data of this node. */ > > > + struct rb_list busy; > > > +}; > > > + > > > +static struct vmap_node *nodes, snode; > > > +static __read_mostly unsigned int nr_nodes = 1; > > > +static __read_mostly unsigned int node_size = 1; > > > > It could be better if calling these global variables a meaningful name, > > e.g vmap_nodes, static_vmap_nodes, nr_vmap_nodes. When I use vim+cscope > > to reference them, it gives me a super long list. Aside from that, a > > simple name often makes me mistake it as a local virable. A weak > > opinion. > > > I am OK to add "vmap_" prefix: > > vmap_nodes; > vmap_nr_nodes; ~ nr_vmap_nodes? > vmap_node_size; > .. > > If you are not OK with that, feel free to propose other variants. Other than the nr_nodes one, others look good to me, thanks a lot.