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 X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77217C433E0 for ; Thu, 4 Jun 2020 11:00:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 35E8B2075B for ; Thu, 4 Jun 2020 11:00:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GS1zJyLb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35E8B2075B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BC29280007; Thu, 4 Jun 2020 07:00:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4BFD8E0006; Thu, 4 Jun 2020 07:00:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A14F380007; Thu, 4 Jun 2020 07:00:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 856998E0006 for ; Thu, 4 Jun 2020 07:00:04 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 49B3F824556B for ; Thu, 4 Jun 2020 11:00:03 +0000 (UTC) X-FDA: 76891234686.21.hose71_3a91f2c674c1c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 298CF180442C2 for ; Thu, 4 Jun 2020 11:00:03 +0000 (UTC) X-HE-Tag: hose71_3a91f2c674c1c X-Filterd-Recvd-Size: 6546 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 11:00:02 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 054Agb5B020913; Thu, 4 Jun 2020 10:59:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2020-01-29; bh=NojrugslEXuF32/HkqLjTbTdUS1E6mDsGnjQQWBtRoY=; b=GS1zJyLb1HfTQz3WhYjHe6QDrbeUymz2tWCp3CPsX1fnNRojoa2vIEVWS0J93vRr9KaH ZaaEpxnq+FkPLDkOE3xtgQS0D0v7GT2vx5ulRauf58WCmkQqrpBkZJLHpX/8HhewmWK6 25Ww5xM8Zp4qfneg1QtESFW6GheJJqdghe7cwrnhK232vFIIux1p9TObjioJOU8yJ3ki QoLVw8tpG3LUCaLHmokCY/Cfc8zGKEOtRIeHZBQvo3nJT1sj7ApPlj2QhYi2+czkbYSj xa6sRKaWznvXviJf24uWasG3AJepSeBMWtcdSoxlla/Crb5oNOTwsqamkJN6pELkeTFz aA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 31evap10xg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 04 Jun 2020 10:59:55 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 054Aw42R191541; Thu, 4 Jun 2020 10:59:54 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 31c25uy2cf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Jun 2020 10:59:54 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 054AxsLC031164; Thu, 4 Jun 2020 10:59:54 GMT Received: from [192.168.0.110] (/73.243.10.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 04 Jun 2020 03:59:54 -0700 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] vmalloc: Convert to XArray From: William Kucharski In-Reply-To: <20200604033309.GS19604@bombadil.infradead.org> Date: Thu, 4 Jun 2020 04:59:53 -0600 Cc: Andrew Morton , linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20200603171448.5894-1-willy@infradead.org> <3CE9C10C-2C1E-4363-94A6-BD4724881926@oracle.com> <20200604033309.GS19604@bombadil.infradead.org> To: Matthew Wilcox X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9641 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=2 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006040075 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9641 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=2 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006040074 X-Rspamd-Queue-Id: 298CF180442C2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: Again, nice - for the followup: Reviewed-by: William Kucharski > On Jun 3, 2020, at 9:33 PM, Matthew Wilcox = wrote: >=20 > On Wed, Jun 03, 2020 at 11:35:24AM -0600, William Kucharski wrote: >>> - err =3D radix_tree_preload(gfp_mask); >>> - if (unlikely(err)) { >>> + err =3D xa_insert(&vmap_blocks, vb_idx, vb, gfp_mask); >>> + if (err) { >>=20 >> Should the "(err)" here be "unlikely(err)" as the radix tree version = was? >=20 > That's a good question. In previous years, GCC used to be stupider = and > we had to help it out by annotating which paths were more or less = likely > to be taken. Now it generally makes the right decision (eg = understanding > that an "early exit" which unwinds state from a function is likely to > be an error case and thus the slow path), so we no longer need to mark > nearly as much code with unlikely() as we used to. Similar things are > true for prefetch() calls. >=20 > I took a look at the disassembly of this code with and without the > unlikely() and I also compared if (err) with if (err < 0). In the = end, > it makes no difference to the control flow (all variants jump to the = end > of the function) although it changes the register allocation decisions > a little (!) >=20 > What did make a difference was moving all the error handling to the > end of the function; reduced the size of the function by 48 bytes. > This is with gcc-9.3. I can submit this patch as a follow-up since = it's > basically unrelated to the other change. >=20 > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 375bbb410a94..3d5b5c32c840 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -1569,10 +1569,8 @@ static void *new_vmap_block(unsigned int order, = gfp_t gfp_mask) > va =3D alloc_vmap_area(VMAP_BLOCK_SIZE, VMAP_BLOCK_SIZE, > VMALLOC_START, VMALLOC_END, > node, gfp_mask); > - if (IS_ERR(va)) { > - kfree(vb); > - return ERR_CAST(va); > - } > + if (IS_ERR(va)) > + goto free_vb; >=20 > vaddr =3D vmap_block_vaddr(va->va_start, 0); > spin_lock_init(&vb->lock); > @@ -1587,11 +1585,8 @@ static void *new_vmap_block(unsigned int order, = gfp_t gfp_mask) >=20 > vb_idx =3D addr_to_vb_idx(va->va_start); > err =3D xa_insert(&vmap_blocks, vb_idx, vb, gfp_mask); > - if (err) { > - kfree(vb); > - free_vmap_area(va); > - return ERR_PTR(err); > - } > + if (err < 0) > + goto free_va; >=20 > vbq =3D &get_cpu_var(vmap_block_queue); > spin_lock(&vbq->lock); > @@ -1600,6 +1595,13 @@ static void *new_vmap_block(unsigned int order, = gfp_t gfp_mask) > put_cpu_var(vmap_block_queue); >=20 > return vaddr; > + > +free_va: > + free_vmap_area(va); > + va =3D ERR_PTR(err); > +free_vb: > + kfree(vb); > + return ERR_CAST(va); > } >=20 > static void free_vmap_block(struct vmap_block *vb) >=20 >> Nice change and simplifies the code quite a bit. >>=20 >> Reviewed-by: William Kucharski >=20