From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id B2D3D383D028 for ; Fri, 16 Jul 2021 19:58:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B2D3D383D028 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-591-e9Fm4N8ZPPaTvpOLgH2jwQ-1; Fri, 16 Jul 2021 15:58:48 -0400 X-MC-Unique: e9Fm4N8ZPPaTvpOLgH2jwQ-1 Received: by mail-wr1-f72.google.com with SMTP id j6-20020adff5460000b029013c7749ad05so5291765wrp.8 for ; Fri, 16 Jul 2021 12:58:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m5ZOrgAbAd8yr6kRQXk3/ovEhSVYqZpEqUlG3RZuLa8=; b=tZrVMUUS+uKdFSIukc0ONbQOG1hd7GbovX5gTc4pwq22wBKbbYqRnu2j8SkEFkYy3e 1+MDircOHlVX8H9ucqjNxpYG6OksEFkc6r8AIWNqkti2KRPTKWrCkESR2bT8bmbCtYY6 XGwkEwggfKbQjvJP16pGYaYTlPqkrvdA0JEjXHDIsXgtfeHD1u5TciumRwvP694HfP6N erXnOQOiQUvxi3ZcPZC4gfjfX8twux6UqlVz3D4wZJqROc/0byyzJM4YLmPFvAuEtmPU Bbr9ssi3pEOP/umm/szBQrO/zh1k7BdRjgtSRAllB/uW9oR5xHkqCQE3VTO/VnBq5c0n 9JfA== X-Gm-Message-State: AOAM531UXoEWdA0bgdN0TXLFaUOA1F/pLd38pkqiFSejzEJW9bVod3y2 n7SJcaJQbdNycVDjRCLzSxeCW3FCGS6q5daQQHv2XbH4KcDxol626GozZZWfKCCKyOkIT6riraz J19wPQX+VpW+ptV/dhya1fqygKyV55PYeZA== X-Received: by 2002:a7b:c10b:: with SMTP id w11mr13005859wmi.185.1626465527381; Fri, 16 Jul 2021 12:58:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0MBwI/IFmjcg19peUfz5Ei2CcxUSOWlfqKJgmFlQx1rGUz61fY0+0hvE3YBAOA5/6pOa2jVih02h6r04U3j0= X-Received: by 2002:a7b:c10b:: with SMTP id w11mr13005842wmi.185.1626465527192; Fri, 16 Jul 2021 12:58:47 -0700 (PDT) MIME-Version: 1.0 References: <20210716023656.670004-1-jason@redhat.com> <2948804.xd1mhZDcFd@excalibur> In-Reply-To: <2948804.xd1mhZDcFd@excalibur> From: Jonathan Wakely Date: Fri, 16 Jul 2021 20:58:36 +0100 Message-ID: Subject: Re: [PATCH] c++: implement C++17 hardware interference size To: Matthias Kretz Cc: Jason Merrill , "Richard Earnshaw (lists)" , "libstdc++" , gcc-patches List , GNU C Library X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2021 19:58:54 -0000 On Fri, 16 Jul 2021 at 20:26, Matthias Kretz wrote: > > On Friday, 16 July 2021 18:54:30 CEST Jonathan Wakely wrote: > > On Fri, 16 Jul 2021 at 16:33, Jason Merrill wrote: > > > Adjusting them based on tuning would certainly simplify a significant use > > > case, perhaps the only reasonable use. Cases more concerned with ABI > > > stability probably shouldn't use them at all. And that would mean not > > > needing to worry about the impossible task of finding the right values for > > > an entire architecture. > > > > But it would be quite a significant change in behaviour if -mtune > > started affecting ABI, wouldn't it? > > For existing code -mtune still doesn't affect ABI. True, because existing code isn't using the constants. >The users who write > > struct keep_apart { > alignas(std::hardware_destructive_interference_size) std::atomic cat; > alignas(std::hardware_destructive_interference_size) std::atomic dog; > }; > > *want* to have different sizeof(keep_apart) depending on the CPU the code is > compiled for. I.e. they *ask* for getting their ABI broken. Right, but the person who wants that and the person who chooses the -mtune option might be different people. A distro might add -mtune=core2 to all package builds by default, not expecting it to cause ABI changes. Some header in a package in the distro might start using the constants. Now everybody who includes that header needs to use the same -mtune option as the distro default. That change in the behaviour and expected use of an existing option seems scary to me. Even with a warning about using the constants (because somebody's just going to use #pragma around their use of the constants to disable the warning, and now the ABI impact of -mtune is much less obvious). It's much less scary in a world where the code is written and used by the same group of people, but for something like a linux distro it worries me.