Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4533765pxj; Wed, 12 May 2021 07:40:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8kJTGXhNbQzCtFKQIsSSC8C61zXXKTeHaGa/mSl02AIpDloEyoGe0LO9AuDTnrlMohhZ6 X-Received: by 2002:a19:c304:: with SMTP id t4mr24958665lff.86.1620830441128; Wed, 12 May 2021 07:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620830441; cv=none; d=google.com; s=arc-20160816; b=bC7oEaFxCfHqY6LqG2Kh7ZlWDeHaKm6CGVtGn7JZpW4oOjOYxwhQDP410sl4VTGkrD NntQeSiNLwJj1yTiXXEpAPaAmkQ9CHRU9Qh0Boa3cK2cqVbwlrFPgqE/51ktDJVma6wO +6lfonvXkO4a0txfivOVHKgmWi8kAIMDmUCpL9NiUEna3bgLetebk3VpPX4kWYhl7PLz wcEqujU43S//xtXYixksOXI6PyK9/rRZ49SItxN9u9qiFhuwIZndFieAMksffeZSOORR 1dic2/NWfIeAXg5ZAKi2iodQcKKzZ09yzte/Mt5ZXAAaQIm96ts5jOrU+zBXirdUpNyP xqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bXMotG1tPrEhpp948WcmFs0gyeL/okB4Vpx6bCCgWww=; b=fxgBMYS/bmuEDEFH3L2wQHY2FpruXUSvEj+zYLApgTFfDHIrESOxVox2dm4g3BN8rb 2241H9S5Fi43N23bXyCOddhUd61EqTx37mIka8CoLKu5ohq8MaDB8ty4vCLliNnAwGXT k5L85yQAIoHcSEKA99dXHUJKRB/hVDfeQOup6Z+knCG1Se9yfRzTtBSDRa8392gdHdVS FFkjuiqBrxoQgRWof+733Ig1/sFZRRGjpkKE9RdH/DIbvMzXR9qxd646JggG9VMs8+TR F2EzbMF6JI4YWJllKQIvOYW/CduumgChZe2es2way9Tjyj3sz3LMUYwDWRRnc8do9ZvL cwZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si88613lfk.568.2021.05.12.07.40.10; Wed, 12 May 2021 07:40:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230429AbhELOhy (ORCPT + 99 others); Wed, 12 May 2021 10:37:54 -0400 Received: from gate.crashing.org ([63.228.1.57]:48806 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbhELOhy (ORCPT ); Wed, 12 May 2021 10:37:54 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 14CEV6Yp018137; Wed, 12 May 2021 09:31:06 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 14CEV5SC018136; Wed, 12 May 2021 09:31:05 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 12 May 2021 09:31:05 -0500 From: Segher Boessenkool To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc: Force inlining of csum_add() Message-ID: <20210512143105.GW10366@gate.crashing.org> References: <20210511105154.GJ10366@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 02:56:56PM +0200, Christophe Leroy wrote: > Le 11/05/2021 ? 12:51, Segher Boessenkool a ?crit?: > >Something seems to have decided this asm is more expensive than it is. > >That isn't always avoidable -- the compiler cannot look inside asms -- > >but it seems it could be improved here. > > > >Do you have (or can make) a self-contained testcase? > > I have not tried, and I fear it might be difficult, because on a kernel > build with dozens of calls to csum_add(), only ip6_tunnel.o exhibits such > an issue. Yeah. Sometimes you can force some of the decisions, but that usually requires knowing too many GCC internals :-/ > >>And there is even one completely unused instance of csum_add(). > > > >That is strange, that should never happen. > > It seems that several .o include unused versions of csum_add. After the > final link, one remains (in addition to the used one) in vmlinux. But it is a static function, so it should not end up in any object file where it isn't used. > >>In the non-inlined version, the first sum with 0 was performed. > >>Here it is skipped. > > > >That is because of how __builtin_constant_p works, most likely. As we > >discussed elsewhere it is evaluated before all forms of loop unrolling. > > But we are not talking about loop unrolling here, are we ? Oh, right you are, but that doesn't change much. The _builtin_constant_p(len) is evaluated long before the compiler sees len is a constant here. > It seems that the reason here is that __builtin_constant_p() is evaluated > long after GCC decided to not inline that call to csum_add(). Yes, it seems we do not currently do even trivial inlining except very early in the compiler. Thanks, Segher