From mboxrd@z Thu Jan 1 00:00:00 1970 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 27ADACA0ECA for ; Tue, 12 Sep 2023 13:19:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99A206B00E6; Tue, 12 Sep 2023 09:19:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94A316B00E7; Tue, 12 Sep 2023 09:19:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8119C6B00E8; Tue, 12 Sep 2023 09:19:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6CD696B00E6 for ; Tue, 12 Sep 2023 09:19:22 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 44300B3429 for ; Tue, 12 Sep 2023 13:19:22 +0000 (UTC) X-FDA: 81228001764.28.D4B8154 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 5F0C4C0023 for ; Tue, 12 Sep 2023 13:19:20 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XUjGmrd0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694524760; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=45vYBZ3G2jZIqFieNjtpHSeDEfoCcr3MhetjZ/eAgmE=; b=sKdc/eV0P9rF2v//iavVf3jX9OkNogufmWGqoxvwu7K691/IM+eHkStjbVo3SSxB432fc2 7BKe8BWkJAACPc4GvBVuHEMGdf1QgtXwGpTQTEGXPhcH62Ym7a4/Ogm3aTYQbH4b3WF4md A0a3b+CvXi6vDGADIs2ihRaM8Dq40TQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XUjGmrd0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694524760; a=rsa-sha256; cv=none; b=T6Ee10wbhf/oQe9tgMoLuFn/W6aRQ1U6i3HvJNR68eIfdxW7XYLC4HW9Hqi410mmb4sby4 0p4UBUZ3nHOhkGZJuNDib5nq6VNbJGDJB9hPYNWxiHye7VCsZgN8zTQA/AZOZX9bp2NOmW vTw+ahI1M3A4MY1UUhdKIsfgqwXnGbg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694524759; 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=XUjGmrd0SQRJuBJuR6KBEmPB/ywE3p7I3+4f1OWHDz43thUEM4XYVBLM/b8M68hUQ+TDrk TN7S2robFQRIO2fdB8iD0KZQFZ6xY0/fS4ih9EBcz+KEIt2WpM6hj2x7X0dB0MzOsa5Hqc 1EBZiinAN5iBviYXFWeGNMrqYJBjcZQ= 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 X-Rspam-User: X-Stat-Signature: 7td5p1x58666cdo44iyp1iru57jhj9mu X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5F0C4C0023 X-HE-Tag: 1694524760-940505 X-HE-Meta: U2FsdGVkX1/K7qbSw3gNYQRrGsLrEUQiDNckoNiRjX7iQ8VYAZjU7iQbyPKFdZGLN8SEZBjrF1FinbwUt7nYGlM/SjhSwus5LNJuQu8U+LJpzbGITcfsosbO5+dwqo5Gs9UvlKM5gK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TI3I3/BM4rDEK3VjP/+kdz+4kvOzHBdg63MpICvOp4JonaF0lvvjbUXHY33g== 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: 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.