archive mirror
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <>
To: Linus Torvalds <>
Cc: Arnd Bergmann <>,
	Eric Biggers <>,
	 linux-arch <>,
	Vineet Gupta <>,
	 Russell King <>,
	Herbert Xu <>,
	"David S. Miller" <>,
	Thomas Bogendoerfer <>,
	 Linux ARM <>,
	 Linux Kernel Mailing List <>,
	 "open list:BROADCOM NVRAM DRIVER" <>
Subject: Re: [PATCH v2 07/13] asm-generic: unaligned always use struct helpers
Date: Tue, 18 May 2021 20:09:27 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Hi Linus,

On Tue, May 18, 2021 at 6:12 PM Linus Torvalds
<> wrote:
> I'm actually surprised wireguard would use -O3. Yes, performance is
> important. But for wireguard, correctness is certainly important too.
> Maybe Jason isn't aware of just how bad gcc -O3 has historically been?
> Jason? How big of a deal is that -O3 for wireguard wrt the normal -O2?
> There are known buggy gcc versions that aren't ancient.

My impression has always been that O3 might sometimes generate slower
code, but not that it generates buggy code so commonly. Thanks for
letting me know.

I have a habit of compulsively run IDA Pro after making changes (brain
damage from too many years as a "security person" or something), to
see what the compiler did, and I've just been doing that with O3 since
the beginning of the project, so that's what I wound up optimizing
for. Or sometimes I'll work little things out in Godbolt's compiler
explorer. It's not like it matters much most of the time, but
sometimes I enjoy the golf. Anyway, I've never noticed it producing
any clearly wrong code compared to O2. But I'm obviously not testing
on all compilers or on all architectures. So if you think there's
danger lurking somewhere, it seems reasonable to change that to O2.

Comparing gcc 11's output between O2 and O3, it looks like the primary
difference is that the constant propagation is much less aggressive
with O2, and less inlining in general also means that some stores and
loads to local variables across static function calls aren't being
coalesced. A few null checks are removed too, where the compiler can
prove them away.

So while I've never seen issues with that code under O3, I don't see a
super compelling speed up anywhere either, but rather a bunch of
places that may or may not be theoretically faster or slower on some
system, maybe. I can queue up a patch for the next wireguard series I
send to Dave.


linux-arm-kernel mailing list

  reply	other threads:[~2021-05-18 18:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 10:00 [PATCH v2 00/13] Unify asm/unaligned.h around struct helper Arnd Bergmann
2021-05-14 10:00 ` [PATCH v2 06/13] asm-generic: unaligned: remove byteshift helpers Arnd Bergmann
2021-05-14 10:00 ` [PATCH v2 07/13] asm-generic: unaligned always use struct helpers Arnd Bergmann
2021-05-17 21:53   ` Eric Biggers
2021-05-18  7:25     ` Arnd Bergmann
2021-05-18 14:56       ` Linus Torvalds
2021-05-18 15:41         ` Arnd Bergmann
2021-05-18 16:12           ` Linus Torvalds
2021-05-18 18:09             ` Jason A. Donenfeld [this message]
2021-05-18 20:51             ` Arnd Bergmann
2021-05-18 21:31               ` Eric Biggers
2021-05-18 21:14         ` David Laight
2021-05-14 17:32 ` [PATCH v2 00/13] Unify asm/unaligned.h around struct helper Linus Torvalds
2021-05-14 18:51   ` Vineet Gupta
2021-05-14 19:22     ` Linus Torvalds
2021-05-14 19:45       ` Vineet Gupta
2021-05-14 20:19         ` Linus Torvalds
2021-05-14 19:31   ` Arnd Bergmann

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* 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).