Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1787093lqp; Mon, 15 Apr 2024 18:36:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9Q8xQxaOcmbRk+H9GywcbPuIYTdjSDyTR6Ian8Ll8UGaXZlNGLhNXw8Gusx8Ek3CwhWD1+NHpj3MIwz1TYqXINOS7lPoMFFvxWGKLpw== X-Google-Smtp-Source: AGHT+IEz9d52Cg/ek2KRyJyakXZQQr8HfS6qjcsXdkoodgt4eZmoYkoe22r83kJ5TZ348T5jxfvm X-Received: by 2002:a17:90a:701:b0:2a5:259c:3af8 with SMTP id l1-20020a17090a070100b002a5259c3af8mr7668694pjl.47.1713231401915; Mon, 15 Apr 2024 18:36:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713231401; cv=pass; d=google.com; s=arc-20160816; b=i4WtLrhGn3QYo2DNj+iaXbAzIdIQzRQEJjaueK2ayse+wJWDQy5mnOFaXvVzREWTNu 1caD97EXT5caevdkAxdR8ZO1e2w+vdAW6gq0cL0J66LNrNYFpVS7qswnDVDQ2o1+FL/+ wN3UMuEjW5+WgBpfefqk+Vr6uTkW80JmC8nJg2AIpm2EcJQmdDnkmzIlULaOeW9PX0f2 L8WElfpcVhXSN5AywDqbxqA95TQjMF1ZSAUZ++GJn8QEJG5amKCa3LpzqGm3LTgK23Sb K4vL4IdeKb2fexW+TbrCMnVH9BjAU02LPE7MwDfrMcP1d0s+CQ0cC1H9Wh2thxNumBdX zqMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=k+nUXRy8R0raMCXQXhjsuRi7TTAoTF36elLRCcyhRJA=; fh=G0dlidKvvnvHPRYKkMKMoUVhM9oJDNtXoPSRl2vZrbk=; b=NIreSCWpn/gz+4uza/ulg/boTS5aPafzen5srH90kQHX8toe2TPrQla9nWVT01qAtG Tl4fs9st/O6O8t2KgrMA2zHRWWJ7jPANaiNugi/l3LiPC2SYYo6oka7e7EJo6jBXs0Vs 0zEwfCmExlV+B+VpAydKDEgM0oqI6W0Qw7HxStT3udoM4K0zHPYppo/PcFAeSv/m8ZOA SoHrqTKSWItCbGOiYbiCjO6jrupETChchMGfxNmBCMKJO0K4prwvg9/Eul90wV/w5TTI 8bPvxqy9KPe9lfIYUD9Q0Zn6pBGSb2nMbneHJX9od6uwXh1G6tffdIVzZnmbsiysL4rO IXZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-146088-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146088-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i18-20020a63cd12000000b005dcbb9ab5b7si8509355pgg.277.2024.04.15.18.36.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 18:36:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146088-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-146088-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146088-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CDE50B21DC8 for ; Tue, 16 Apr 2024 01:34:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0CBB79C4; Tue, 16 Apr 2024 01:34:48 +0000 (UTC) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 125487464; Tue, 16 Apr 2024 01:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713231288; cv=none; b=DH1w5mCBmGVlWiY7qkCS5ogKLAxfVvSFAz/OvOs7piJNI5o1oTULkuIBLKJqU/QUS5Omj4v9KGUVhT0aFbkNgJkshIkSna1mArin4FTO1kXd5LILLN6QnJh3MlqCrlFeZdlj+/GlM7ZO+tXb1w5fnXD3sq7IyF/lruS7hWyIr8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713231288; c=relaxed/simple; bh=mJem2Ufbl9Ew2/f7xgNNLsKEvT9e4WkGZGTdtTMWaTk=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XODnLMxgmGM7K6ZPj838D+DoSbZjK66zHagpPxmZwwcj3Hh+BaGaKORCr5jcO4wkP/r7y9yQEdV29qC77+lr3qLCCh2ysSqtqKXxPiJln1zL/r/jXXgLbgFVPfUkP7zA65Ms87NVdIQaeS8eyJ14D5xXOlqm8xpkdMmViYGOuaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VJRQJ1YQ9z1ws14; Tue, 16 Apr 2024 09:33:44 +0800 (CST) Received: from kwepemi500009.china.huawei.com (unknown [7.221.188.199]) by mail.maildlp.com (Postfix) with ESMTPS id 2049E1400D5; Tue, 16 Apr 2024 09:34:42 +0800 (CST) Received: from localhost (10.175.127.227) by kwepemi500009.china.huawei.com (7.221.188.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 16 Apr 2024 09:34:41 +0800 Date: Tue, 16 Apr 2024 09:35:20 +0800 From: Long Li To: Andrew Morton CC: , , , , , Subject: Re: [PATCH] xarray: inline xas_descend to improve performance Message-ID: <20240416013520.GA506789@ceph-admin> References: <20240415012136.3636671-1-leo.lilong@huawei.com> <20240415131053.051e60135eacf281df6921f6@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20240415131053.051e60135eacf281df6921f6@linux-foundation.org> X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500009.china.huawei.com (7.221.188.199) On Mon, Apr 15, 2024 at 01:10:53PM -0700, Andrew Morton wrote: > On Mon, 15 Apr 2024 09:21:36 +0800 Long Li wrote: > > > The commit 63b1898fffcd ("XArray: Disallow sibling entries of nodes") > > modified the xas_descend function in such a way that it was no longer > > being compiled as an inline function, because it increased the size of > > xas_descend(), and the compiler no longer optimizes it as inline. This > > had a negative impact on performance, xas_descend is called frequently > > to traverse downwards in the xarray tree, making it a hot function. > > > > Inlining xas_descend has been shown to significantly improve performance > > by approximately 4.95% in the iozone write test. > > > > Machine: Intel(R) Xeon(R) Gold 6240 CPU @ 2.60GHz > > #iozone i 0 -i 1 -s 64g -r 16m -f /test/tmptest > > > > Before this patch: > > > > kB reclen write rewrite read reread > > 67108864 16384 2230080 3637689 6 315197 5496027 > > > > After this patch: > > > > kB reclen write rewrite read reread > > 67108864 16384 2340360 3666175 6272401 5460782 > > > > Percentage change: > > 4.95% 0.78% -0.68% -0.64% > > > > This patch introduces inlining to the xas_descend function. While this > > change increases the size of lib/xarray.o, the performance gains in > > critical workloads make this an acceptable trade-off. > > > > Size comparison before and after patch: > > .text .data .bss file > > 0x3502 0 0 lib/xarray.o.before > > 0x3602 0 0 lib/xarray.o.after > > > > ... > > > > --- a/lib/xarray.c > > +++ b/lib/xarray.c > > @@ -200,7 +200,7 @@ static void *xas_start(struct xa_state *xas) > > return entry; > > } > > > > -static void *xas_descend(struct xa_state *xas, struct xa_node *node) > > +static inline void *xas_descend(struct xa_state *xas, struct xa_node *node) > > { > > unsigned int offset = get_offset(xas->xa_index, node); > > void *entry = xa_entry(xas->xa, node, offset); > > I thought gcc nowadays treats `inline' as avisory and still makes up > its own mind? > > Perhaps we should use __always_inline here? Yes, I agree with you, I will send a new version. thanks!