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 DA50DC46CD2 for ; Tue, 30 Jan 2024 18:44:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F6446B0081; Tue, 30 Jan 2024 13:44:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A61E6B0099; Tue, 30 Jan 2024 13:44:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 495806B009A; Tue, 30 Jan 2024 13:44:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3AE836B0081 for ; Tue, 30 Jan 2024 13:44:50 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 02FD112028B for ; Tue, 30 Jan 2024 18:44:49 +0000 (UTC) X-FDA: 81736853940.22.BEBC77A Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf11.hostedemail.com (Postfix) with ESMTP id 1FBD24000A for ; Tue, 30 Jan 2024 18:44:47 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dxaVrCjo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706640288; a=rsa-sha256; cv=none; b=SiWW9UkFbmh13IBN0ffxfHmWGIrI7OD9Vp0U0TEanAfg9J2/QjmltTHGXvXp5wcvJd0Ivk 6mVZ4wJNXQ/uLcrhZJuVreDAknbM6F5risuSLRuqXX4CQ3HcpZ8iLh9E79TLRanSXX8Oly wypqn/9E4OYcX7ooLWDpPBkt5Xznb0U= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dxaVrCjo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706640288; 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=z23OMEfQd2Zd5DlteZNRvp4RWaGbggWiP82btYQ5h+0=; b=GIbhDhkDHW5LNLysgvD+u/ReXgMhKpV7DYLDOt7uEsW0TGFZWsTWGlSa6FK7svlQrVfl6X 8JJvdU69Ztcc4iB9L3BhqAdzAnaxEn4gWaaNZsGwo+2bAJiQLER1uV8jXci1qISbSd6AGy 2P3KAsicXqw8BGvAVXBhGFOeFjeQdk8= Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5111e5e4e2bso1156459e87.3 for ; Tue, 30 Jan 2024 10:44:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706640286; x=1707245086; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=z23OMEfQd2Zd5DlteZNRvp4RWaGbggWiP82btYQ5h+0=; b=dxaVrCjo2Vxzu3/66PQXZA+YNyMA4QMoc/JIBkPsWKXJPzq2JF+u5vRKnRzJVmnUbp rIPKi1zBCgZ3o+83kEbmY+tVYgsrRdDQymRAh+DcY/QP0kTpTMcBmuLOOXFESlauMGib Ddsy8T+RwnDht2XKd0Gw8krP1Uu2N7JISQcdb9lxbxeyg6pY6OFqMxrSCh9kPD+CPA6p +cNiPP1E291spd70QVzUeSOUeRKZAh9y5Tg9rCXyV7wuAMFqPoGEQ8++wD/mO8LnPdM4 YKenO6cfPI0XYmoXzRcwrvzEF/AcZW/avAvV+e+Wf5dr7EIY1UtIUBQ0jMtmY9IfBMUJ uEbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706640286; x=1707245086; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z23OMEfQd2Zd5DlteZNRvp4RWaGbggWiP82btYQ5h+0=; b=kQPDqiXT7lxKH18+WioFy70Hvq0kX2Lz0bxyKfXzbdMG/DOmSaBY3Fi8ypfSvy1yuJ yZHXg7i8cGKaJ7M75YEcAG4qc5D5vBthdO9LbPBiaQV7DsPNyIqmlP98dL+8gdbJ0Yv2 clmIMsARpYuuJAG1p+ys+SPZIvVJz7c19B9qaNtzF3CTS3YxnJNQkryZssZowjVTcfPM 1ASrtlCqX7ZbghDZUXqAHtBIMVf2algYgeXM8Yn5NHPiwQ2X90iq4TU4xRS68rMh0e+d 5BchOQK13cse2VsRAu8AV0jNzpSR5FdjGmX7OMqmS0BscoBRkIOjHOHlMzow7PBCydLZ MXfw== X-Gm-Message-State: AOJu0Yw5Yld/iX3OL3e7Mfu2etC3GkazhxcuN+4HcKvATGeUTfOi4LKp OinE2cKAlO0NglwPDU8eWhww1VEF+7MCHxrlck1pc2sfpwoRvbjQ X-Google-Smtp-Source: AGHT+IFsFS9OlQA2eeVPaXbz2RO+arsZ/guxCPFD1BkQX+5M8YBVxvWI8aH7kUmWAG3PJ6cmvJ+vKQ== X-Received: by 2002:a05:6512:2247:b0:511:b42:1711 with SMTP id i7-20020a056512224700b005110b421711mr6396693lfu.29.1706640285904; Tue, 30 Jan 2024 10:44:45 -0800 (PST) Received: from localhost ([2a00:23cc:d20f:ba01:bb66:f8b2:a0e8:6447]) by smtp.gmail.com with ESMTPSA id bi19-20020a05600c3d9300b0040ee51f1025sm12843362wmb.43.2024.01.30.10.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:44:44 -0800 (PST) Date: Tue, 30 Jan 2024 18:44:43 +0000 From: Lorenzo Stoakes To: "Uladzislau Rezki (Sony)" Cc: linux-mm@kvack.org, Andrew Morton , LKML , Baoquan He , Christoph Hellwig , Matthew Wilcox , Dave Chinner , Oleksiy Avramchenko Subject: Re: [PATCH 1/2] mm: vmalloc: Improve description of vmap node layer Message-ID: <97342c5a-3d16-477d-9e75-25d54b3bc082@lucifer.local> References: <20240124180920.50725-1-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240124180920.50725-1-urezki@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1FBD24000A X-Stat-Signature: c49i13kn8prcprtie3tq4hs4fr6woos4 X-HE-Tag: 1706640287-46529 X-HE-Meta: U2FsdGVkX1+YxbuTNmLZOp4tPukMihOVZn8YNCpbWlwINa4y+uIL1WYTrN0YPozVN2hpBUi7haa5q5auTIfiTF6Gf1rLSTrhjPGSoHlpIZZ7OraeOxl67rVdpNONBM+rLcEE3htB2m3ZhkxicuaQnX4pUmvI+jQ5frY344FGDdLpHee9qnBNnjrvkdsBakcfB76XATNB7RahEgEj1ySBOumfi4if4x3DtfD3pCmMsUaUllpoJd7JvMmc74BWRkq4Z7jQnFP/GxVT23P2sIcunigxbxBep5FSeTw7o6rOsaqlmONFMQevH5pKPRQSCdkp1ur0J9rv227RlwSgbivf8+JQKrz4iwgUYPd06s5+Yn174uQzsyIIX+Qgj2zeCtlozZQJ5FeR5jfA4HNDD76r/+h2VL0aTmEP7xuqPJF72LBibPJGl8IgGqbI9HGqDkM+8r3pmfIiZ4d/UtwdpdgH/JR1FWjF0/dVKKbMHN0HP3eZxnPZ9WcAGZrEeFdGAA726FPHcGeHpPHq7gRtF4NXg8lT7ZlmnRqCoGXpeNtZiSaf/zgAzBlMDiIKNCNNX20HbTviI0jTCl5l2gq+gkRW8/6yaXRtZEXpA7gTbaVIc+Aht3c2jLJjLWAD2Ndhgkq3Bg8rB3uJdsTve8hJGcluRdeoQfswue2p/+pnAREHWdGTKRrY9MxsyMJ/W6bdUBIXj4iu5F2Acc0qLFrc30uMOJI+mjxn8ECCY0qcj0CoRNhE6vC1bB0xcmwX94jBNAaN/IuKYGCaC9Wt1GRB8QqqWcCi+Wo1ZV5TFMl8LT2bNTT99fQ7LL5+t9jXfJyBSKq7WhPexIeklsD3A1Qjf3ZaOjyOyf12fbuO26F4RZFfIz/pE/0ctJeSCqm//bTPZU8ddB6Sjr+E0x97SuaclmlK0o8zHoBDekZTULmFalK6jPst2CEcsGCJntrZzMSnW2vOR4doXede+nzycLeSHOS /QZs+S2L n7DMoB7S1gR17uXiIcp5xY+fS+vzTn8J7K7zU 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: List-Subscribe: List-Unsubscribe: On Wed, Jan 24, 2024 at 07:09:19PM +0100, Uladzislau Rezki (Sony) wrote: > This patch adds extra explanation of recently added vmap > node layer based on community feedback. No functional change. > > Signed-off-by: Uladzislau Rezki (Sony) > --- > mm/vmalloc.c | 60 ++++++++++++++++++++++++++++++++++++++++------------ > 1 file changed, 46 insertions(+), 14 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 257981e37936..b8be601b056d 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -765,9 +765,10 @@ 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. > + * This structure defines a single, solid model where a list and > + * rb-tree are part of one entity protected by the lock. Nodes are > + * sorted in ascending order, thus for O(1) access to left/right > + * neighbors a list is used as well as for sequential traversal. > */ > struct rb_list { > struct rb_root root; > @@ -775,16 +776,23 @@ struct rb_list { > spinlock_t lock; > }; > > +/* > + * A fast size storage contains VAs up to 1M size. A pool consists > + * of linked between each other ready to go VAs of certain sizes. > + * An index in the pool-array corresponds to number of pages + 1. > + */ > +#define MAX_VA_SIZE_PAGES 256 > + > struct vmap_pool { > struct list_head head; > unsigned long len; > }; > > /* > - * A fast size storage contains VAs up to 1M size. > + * An effective vmap-node logic. Users make use of nodes instead > + * of a global heap. It allows to balance an access and mitigate > + * contention. > */ > -#define MAX_VA_SIZE_PAGES 256 > - > static struct vmap_node { > /* Simple size segregated storage. */ > struct vmap_pool pool[MAX_VA_SIZE_PAGES]; > @@ -803,6 +811,11 @@ static struct vmap_node { > unsigned long nr_purged; > } single; > > +/* > + * Initial setup consists of one single node, i.e. a balancing > + * is fully disabled. Later on, after vmap is initialized these > + * parameters are updated based on a system capacity. > + */ > static struct vmap_node *vmap_nodes = &single; > static __read_mostly unsigned int nr_vmap_nodes = 1; > static __read_mostly unsigned int vmap_zone_size = 1; > @@ -2048,7 +2061,12 @@ decay_va_pool_node(struct vmap_node *vn, bool full_decay) > } > } > > - /* Attach the pool back if it has been partly decayed. */ > + /* > + * Attach the pool back if it has been partly decayed. > + * Please note, it is supposed that nobody(other contexts) > + * can populate the pool therefore a simple list replace > + * operation takes place here. > + */ > if (!full_decay && !list_empty(&tmp_list)) { > spin_lock(&vn->pool_lock); > list_replace_init(&tmp_list, &vn->pool[i].head); > @@ -2257,16 +2275,14 @@ struct vmap_area *find_vmap_area(unsigned long addr) > * An addr_to_node_id(addr) converts an address to a node index > * where a VA is located. If VA spans several zones and passed > * addr is not the same as va->va_start, what is not common, we > - * may need to scan an extra nodes. See an example: > + * may need to scan extra nodes. See an example: > * > - * <--va--> > + * <----va----> > * -|-----|-----|-----|-----|- > * 1 2 0 1 > * > - * VA resides in node 1 whereas it spans 1 and 2. If passed > - * addr is within a second node we should do extra work. We > - * should mention that it is rare and is a corner case from > - * the other hand it has to be covered. > + * VA resides in node 1 whereas it spans 1, 2 an 0. If passed > + * addr is within 2 or 0 nodes we should do extra work. > */ > i = j = addr_to_node_id(addr); > do { > @@ -2289,6 +2305,9 @@ static struct vmap_area *find_unlink_vmap_area(unsigned long addr) > struct vmap_area *va; > int i, j; > > + /* > + * Check the comment in the find_vmap_area() about the loop. > + */ > i = j = addr_to_node_id(addr); > do { > vn = &vmap_nodes[i]; > @@ -4882,7 +4901,20 @@ static void vmap_init_nodes(void) > int i, n; > > #if BITS_PER_LONG == 64 > - /* A high threshold of max nodes is fixed and bound to 128. */ > + /* > + * A high threshold of max nodes is fixed and bound to 128, > + * thus a scale factor is 1 for systems where number of cores > + * are less or equal to specified threshold. > + * > + * As for NUMA-aware notes. For bigger systems, for example > + * NUMA with multi-sockets, where we can end-up with thousands > + * of cores in total, a "sub-numa-clustering" should be added. > + * > + * In this case a NUMA domain is considered as a single entity > + * with dedicated sub-nodes in it which describe one group or > + * set of cores. Therefore a per-domain purging is supposed to > + * be added as well as a per-domain balancing. > + */ > n = clamp_t(unsigned int, num_possible_cpus(), 1, 128); > > if (n > 1) { > -- > 2.39.2 > Looks good to me (sorry for delay, busy with many things in life :)! Feel free to add: Reviewed-by: Lorenzo Stoakes