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 D413D398CC26 for ; Fri, 16 Jul 2021 19:58:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D413D398CC26 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-591-akqV3f-hNvWsOJGaJtS5Nw-1; Fri, 16 Jul 2021 15:58:48 -0400 X-MC-Unique: akqV3f-hNvWsOJGaJtS5Nw-1 Received: by mail-wm1-f69.google.com with SMTP id l17-20020a05600c4f11b0290225ef65c35dso2604499wmq.2 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=fgLkwVcSRApmEHdwdjsgaAFmznf6NX8ZpFgOI1zdChzv9u90gWsKamxNbUDtZZs8j+ b76FVsYhVQFL7/9n13V8RVOB2jlE6zQN2Ndt02ckJhtKkUZmi5SdR1ll0WP4ZHBSO+15 wkCXQm8/I8NC5UJFXxSt1oWgJk4MpHZksCSsBJtgO9tggS4co7wEIcIPFS0uTSO3YeMM YIe3wyZFWecY5V7U2DgEJT6WqQkIXR1K2VK7OpRbp/w9Y1ayzMZS8b8RrEQ1QvjZI3yE 0qz8wlPTJ8iCZYO+zzZ/2ALPQRs20AL10NP8vJlMWXatdqUGKUdByPgvptZeoA8dWAdu mgcQ== X-Gm-Message-State: AOAM530Bbu/FWzVj2aYmvIZtb58gTz8mCma8yQEoUIgkcCcHOxdmZXyc Tu0pMaZXgW9hD8Q4UZEVlV7Tz0KF+6CJlD9zlbHACZ975QrCDPvvKaZEQKDi+Sc2w4DJmvxmyFz YLgCyBPeNwv+iXG2KPKsFxDmb11cZdpw= X-Received: by 2002:a7b:c10b:: with SMTP id w11mr13005871wmi.185.1626465527515; 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.8 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=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2021 19:58:53 -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.