Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1687355pxj; Wed, 19 May 2021 11:28:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy56A3MnY11SyRbIaqxg2dSuDPceasfGzYZOGkIPx/5tSrKCJbOq8lhzuIWcy2d3sGQFOGK X-Received: by 2002:a05:6638:13c4:: with SMTP id i4mr323043jaj.37.1621448929720; Wed, 19 May 2021 11:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448929; cv=none; d=google.com; s=arc-20160816; b=dMPM6uAPbKH52FAlNbehuvmhkzbl1DTIKvj2mJpzvk7Y9pUWRAlf7iQ90eFON3xijX age/OMaqE86Ir+uz78OyFyL5nEIz4SB+80lXpqn8sZJl6p8RmCwAfV/pDKhyh/8c260V LcufG2ckt2vC/+LqmcIuxgpp7xgs8fNtzuhbpW/mLFu2JntU8NRrF2wz7XxFeguS+pDx 1UrZjxC5kV0mOS1UfMLvZWwSgh4Ol3o1AX0V6N410XYqjDNO1YV++7rLM3lsxRHMqF83 87YJrwWixYFn3muJHtwNDe4fAEhpYzt6wjQQ14v8gMuMtaREqGA5LL/nFCKPIXwz6/LW GzUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8rS8izsTLYXgTg5EMvpq46Wwtz/UgRyB75Drw18GbEc=; b=TvTDKiHZEd5XKtnFJRfYzEO5y2R4zOY40pjQ+/zNAjMUY5cT8TMWjlsAvIOQdkNqNr wpYsg+A96HsSnFLwFQSHg7DZgs9AyMmyIegrzh3dTtzvSeeNkmdjgXxjKq+BJyOuxYOJ 2A3OWIJ3qP8pj3t/gjoQ1Fnj4eWs+MLIIn1eCrLRMZSpkaLqYd+s6OIlwVTL/xZdmhhs JznAzOb1VU7PliUVZZ+YxHI85RuIo36WLKI37AsBNpS/Y0VTtJmNhV9QseBwM8ps2Mhd q3fbMFSWF7uCd4CRU1w/69v8B9ulvGnNi0Zb1yYeVeoKfhKZVxw8v8+w1U9EAb8zN337 erCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=ordstdKx; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si36499jap.32.2021.05.19.11.28.36; Wed, 19 May 2021 11:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=ordstdKx; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234187AbhERSRn (ORCPT + 99 others); Tue, 18 May 2021 14:17:43 -0400 Received: from mail.zx2c4.com ([104.131.123.232]:58458 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbhERSRl (ORCPT ); Tue, 18 May 2021 14:17:41 -0400 X-Greylist: delayed 397 seconds by postgrey-1.27 at vger.kernel.org; Tue, 18 May 2021 14:17:40 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1621361380; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8rS8izsTLYXgTg5EMvpq46Wwtz/UgRyB75Drw18GbEc=; b=ordstdKxuroSvOenGkA5+S0n5Eaelw4XVAjEk8UkZ+3isrXKa/wmD2IPj5r0Kfvq1zfUvP CY+6i6WC3N7rlrm8aZt38e2edfNAMTLd+AO8SdHBhlEwi2KfGNHs1D7pQQWn5EZk5/Ft6s 3IM/CNVZLwMM7ldWaZFwTTdsthAFBJk= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id dd3e8623 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Tue, 18 May 2021 18:09:40 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id g38so14466582ybi.12; Tue, 18 May 2021 11:09:40 -0700 (PDT) X-Gm-Message-State: AOAM533Fu+hAseTLmikalDAeO39oFaAUX/oBSRZs40DjskHEVMYuQuNd E+jEl+sU9jL/f36vhSipVszbjC+cFV2t6fZ0QrM= X-Received: by 2002:a25:be09:: with SMTP id h9mr9533216ybk.239.1621361379012; Tue, 18 May 2021 11:09:39 -0700 (PDT) MIME-Version: 1.0 References: <20210514100106.3404011-1-arnd@kernel.org> <20210514100106.3404011-8-arnd@kernel.org> In-Reply-To: From: "Jason A. Donenfeld" Date: Tue, 18 May 2021 20:09:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 07/13] asm-generic: unaligned always use struct helpers 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:HARDWARE RANDOM NUMBER GENERATOR CORE" , "open list:BROADCOM NVRAM DRIVER" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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. Jason