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 BFC61C433EF for ; Thu, 21 Jul 2022 12:02:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18B1D8E0001; Thu, 21 Jul 2022 08:02:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13C186B0073; Thu, 21 Jul 2022 08:02:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1CD08E0001; Thu, 21 Jul 2022 08:02:02 -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 DF0336B0072 for ; Thu, 21 Jul 2022 08:02:02 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 31372A083C for ; Thu, 21 Jul 2022 08:26:39 +0000 (UTC) X-FDA: 79710425718.31.E3530F7 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf21.hostedemail.com (Postfix) with ESMTP id 7AD151C009A for ; Thu, 21 Jul 2022 08:26:38 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-209-auZpXflvPsSN020UXNPu1Q-1; Thu, 21 Jul 2022 09:26:35 +0100 X-MC-Unique: auZpXflvPsSN020UXNPu1Q-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Thu, 21 Jul 2022 09:26:35 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.036; Thu, 21 Jul 2022 09:26:35 +0100 From: David Laight To: 'Liam Howlett' , "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Hugh Dickins CC: Yu Zhao Subject: RE: [PATCH] maple_tree: Do not inline write slow path Thread-Topic: [PATCH] maple_tree: Do not inline write slow path Thread-Index: AQHYnJw6aOsbtqNHaEaswARV7Qt6zq2IfbZw Date: Thu, 21 Jul 2022 08:26:34 +0000 Message-ID: <040322fa455941ff9b82ebb0f53a576a@AcuMS.aculab.com> References: <20220721005237.377987-1-Liam.Howlett@oracle.com> In-Reply-To: <20220721005237.377987-1-Liam.Howlett@oracle.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658391998; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f0U4IbTtfnVcYuUuKj3JB1JPy3hsGLtQiTxCGdG2440=; b=Wy1VMGsKTo4aBRi70QiY/zvDoWVGTQShxnnif+H3oi5qOlIQPb8NZ3T6snWT8zK3dXGtkw xifCvlxL/ZuHwFYpTHp1IoxCY9C7RZ8PDTiDFzEWskqHo1UXRUcO8tCuwzbOf8OmbBcl5w C60iBQkGlEHl6djpAYf/Rn72apTG9+k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658391998; a=rsa-sha256; cv=none; b=GUVdTPblF3mq3myxbeCeIceDkC9/nA57dY/S7UMXadAZUFXVTYUO6k/3S+tQg+FWkwnoLc Cd7wMUK8gOn9a4aipngLdfcBXxmJrDEtcSpuspn5PlAYUjtt842HzvluifVq66f7cBEClc V5NmEkI/IbayH7CptMEgdKRYvk6h3rI= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf21.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com X-Rspamd-Queue-Id: 7AD151C009A Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf21.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: o76jkr51swypegsomaxmr4nmqcp5js8u X-HE-Tag: 1658391998-851386 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: From: Liam Howlett > Sent: 21 July 2022 01:53 >=20 > Having the slow path inlined causes too much stack usage. Create new > function mas_wr_bnode() to write a big node into the tree Unless you mark the function 'noinline' the compiler is likely to inline it anyway. =09David >=20 > Signed-off-by: Liam R. Howlett > --- > lib/maple_tree.c | 22 +++++++++++++++++----- > 1 file changed, 17 insertions(+), 5 deletions(-) >=20 > diff --git a/lib/maple_tree.c b/lib/maple_tree.c > index 95d8659c5a99..4c383c780162 100644 > --- a/lib/maple_tree.c > +++ b/lib/maple_tree.c > @@ -4297,12 +4297,27 @@ static inline bool mas_wr_append(struct ma_wr_sta= te *wr_mas) > =09return false; > } >=20 > +/* > + * mas_wr_bnode() - Slow path for a modification. > + * @wr_mas: The write maple state > + * > + * This is where split, rebalance end up. > + */ > +static void mas_wr_bnode(struct ma_wr_state *wr_mas) > +{ > +=09struct maple_big_node b_node; > + > +=09trace_ma_write(__func__, wr_mas->mas, 0, wr_mas->entry); > +=09memset(&b_node, 0, sizeof(struct maple_big_node)); > +=09mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end); > +=09mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end); > +} > + > static inline void mas_wr_modify(struct ma_wr_state *wr_mas) > { > =09unsigned char node_slots; > =09unsigned char node_size; > =09struct ma_state *mas =3D wr_mas->mas; > -=09struct maple_big_node b_node; >=20 > =09/* Direct replacement */ > =09if (wr_mas->r_min =3D=3D mas->index && wr_mas->r_max =3D=3D mas->last= ) { > @@ -4338,10 +4353,7 @@ static inline void mas_wr_modify(struct ma_wr_stat= e *wr_mas) > =09=09return; >=20 > slow_path: > -=09memset(&b_node, 0, sizeof(struct maple_big_node)); > -=09mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end); > -=09trace_ma_write(__func__, mas, 0, wr_mas->entry); > -=09mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end); > +=09mas_wr_bnode(wr_mas); > } >=20 > /* > -- > 2.35.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)