linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: David Laight <David.Laight@ACULAB.COM>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net v3] net: Force inlining of checksum functions in net/checksum.h
Date: Thu, 17 Feb 2022 14:50:17 +0000	[thread overview]
Message-ID: <d38e5e1c-29b6-8cc6-7409-d0bdd5772f23@csgroup.eu> (raw)
In-Reply-To: <35bcd5df0fb546008ff4043dbea68836@AcuMS.aculab.com>

Adding Ingo, Andrew and Nick as they were involved in the subjet,

Le 17/02/2022 à 14:36, David Laight a écrit :
> From: Christophe Leroy
>> Sent: 17 February 2022 12:19
>>
>> All functions defined as static inline in net/checksum.h are
>> meant to be inlined for performance reason.
>>
>> But since commit ac7c3e4ff401 ("compiler: enable
>> CONFIG_OPTIMIZE_INLINING forcibly") the compiler is allowed to
>> uninline functions when it wants.
>>
>> Fair enough in the general case, but for tiny performance critical
>> checksum helpers that's counter-productive.
> 
> There isn't a real justification for allowing the compiler
> to 'not inline' functions in that commit.

Do you mean that the two following commits should be reverted:

- 889b3c1245de ("compiler: remove CONFIG_OPTIMIZE_INLINING entirely")
- 4c4e276f6491 ("net: Force inlining of checksum functions in 
net/checksum.h")

> 
> It rather seems backwards.
> The kernel sources don't really have anything marked 'inline'
> that shouldn't always be inlined.
> If there are any such functions they are few and far between.
> 
> I've had enough trouble (elsewhere) getting gcc to inline
> static functions that are only called once.
> I ended up using 'always_inline'.
> (That is 4k of embedded object code that will be too slow
> if it ever spills a register to stack.)
> 

I agree with you that that change is a nightmare with many small 
functions that we really want inlined, and when we force inlining we 
most of the time get a smaller binary.

And it becomes even more problematic when we start adding 
instrumentation like stack protector.

According to the original commits however this was supposed to provide 
real benefit:

- 60a3cdd06394 ("x86: add optimized inlining")
- 9012d011660e ("compiler: allow all arches to enable 
CONFIG_OPTIMIZE_INLINING")

But when I build ppc64le_defconfig + CONFIG_CC_OPTIMISE_FOR_SIZE I get:
     112 times  queued_spin_unlock()
     122 times  mmiowb_spin_unlock()
     151 times  cpu_online()
     225 times  __raw_spin_unlock()


So I was wondering, would we have a way to force inlining of functions 
marked inline in header files while leaving GCC handling the ones in C 
files the way it wants ?

Christophe

  reply	other threads:[~2022-02-17 14:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 12:19 [PATCH net v3] net: Force inlining of checksum functions in net/checksum.h Christophe Leroy
2022-02-17 13:36 ` David Laight
2022-02-17 14:50   ` Christophe Leroy [this message]
2022-02-17 14:55     ` Christophe Leroy
2022-02-17 15:15       ` David Laight
2022-02-17 16:17         ` Masahiro Yamada
2022-02-17 16:49           ` David Laight
2022-02-17 17:27             ` Masahiro Yamada
2022-02-17 18:07               ` Segher Boessenkool
2022-02-18  1:35                 ` Masahiro Yamada
2022-02-18 12:12                   ` Segher Boessenkool
2022-02-18 16:29                     ` Stephen Hemminger
2022-02-18 16:44                       ` Segher Boessenkool
2022-02-18  8:41               ` David Laight
2022-02-17 15:42 ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d38e5e1c-29b6-8cc6-7409-d0bdd5772f23@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=David.Laight@ACULAB.COM \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).