Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1331598pxj; Fri, 4 Jun 2021 11:31:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/LbU+UrKEJ/7EDSIqRZaoKXGIJwLs5P3XiPhdK3c1axr30x45wFAI+ldTb8RDR1sIbwGx X-Received: by 2002:aa7:c547:: with SMTP id s7mr6059044edr.239.1622831496709; Fri, 04 Jun 2021 11:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622831496; cv=none; d=google.com; s=arc-20160816; b=eUQS9ftPBduy3sjvXnLxRc1CYkX00JsvLYOR320VDMsy7dD7hYtMU3iDSuAJiFmxWE 4HiNIYWDVGlF9MN+7CNPMS3ga5wkM+v1TlHMmazVvnDXMjk8Oh7WMbX1NbIQ9RpoHwWC tXufMiPu4fYYYPqmIrUydQWgPshryoUcAJD//cVwkDFUYO2k6EcFLbzRCkC/+9T5kAg9 WTNJuFtnT02pWiPJ7tw4r39Av9UDULrMXGjKR4hNShPm6JEzoWq5sG6iG4fazxKdNHV4 lJ47dNr1lKoOYJrItfWRCj+fWv+LjNqGDoc1zc6cqQPSlJ+esvjZBg13riV0x6K91kOu nYYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Xr/SuKTQ/ZZX+TloAb5ls4YGnnYEZyFnzFpVGdH5EA8=; b=j8Y7t4EWwYl/OWjBKiwOCMwzlLRNKbId3a7+C/nqStW/XQLiNPRvmcIfIrFnATz76z cDllRfi03ZA2k8xQQXsxbBPgcrc9qVXrrNmOeTQSnT2DdDNJrKhyQinotDuNwoZc/Kit 9FJJaWbe02s8SzThpL6N+DExbuXLUCoI/2sA9PtZxJRZiem6ucrXKwCu1xQt1dTBWtjf GKBVzqb6nYkCfeDFZCJc8FUrKrE3cIw6ZjslEqKDt7h38Q1gPilIjqOq7Ad3tz9eJXC0 c9W2sCddyquE5xaK7jELlHoudEYIc2DEVGECAUNuKoTSWrhv+AzLRMTnCgOT6xX4OzBI B6Nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si5414208eji.380.2021.06.04.11.31.13; Fri, 04 Jun 2021 11:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbhFDSby (ORCPT + 99 others); Fri, 4 Jun 2021 14:31:54 -0400 Received: from gate.crashing.org ([63.228.1.57]:39809 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbhFDSby (ORCPT ); Fri, 4 Jun 2021 14:31:54 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 154IPkRL003330; Fri, 4 Jun 2021 13:25:46 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 154IPjK0003329; Fri, 4 Jun 2021 13:25:45 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 4 Jun 2021 13:25:44 -0500 From: Segher Boessenkool To: Linus Torvalds Cc: Peter Zijlstra , Will Deacon , "Paul E. McKenney" , Alan Stern , Andrea Parri , Boqun Feng , Nick Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Linux Kernel Mailing List , linux-toolchains@vger.kernel.org, linux-arch Subject: Re: [RFC] LKMM: Add volatile_if() Message-ID: <20210604182544.GK18427@gate.crashing.org> References: <20210604172407.GJ18427@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On Fri, Jun 04, 2021 at 10:38:43AM -0700, Linus Torvalds wrote: > On Fri, Jun 4, 2021 at 10:27 AM Segher Boessenkool > wrote: > > > Of course, we might want to make sure that the compiler doesn't go > > > "oh, empty asm, I can ignore it", > > > > It isn't allowed to do that. GCC has this arguable misfeature where it > > doesn't show empty asm in the assembler output, but that has no bearing > > on anything but how human-readable the output is. > > That sounds about right, but we have had people talking about the > compiler looking inside the asm string before. > > So it worries me that some compiler person might at some point go all > breathy-voice on us and say "I am altering the deal. Pray I don't > alter it any further". GCC will never do that. And neither will any other compiler that claims to implement the GCC asm extensions, if they are true to their word. GCC *does* look inside the assembler template to estimate what code size this asm will generate, and it tries to be pessimistic about its estimate so that this will always work, but it always is possible to mislead the compiler here, precisely because it does not actually pretend it understands assembler code (think .irp or anything with assembler macros for example). In very rare cases this leads to (assembler) errors ("jump target out of range", that kind of thing). The most effective workaround is to write less silly code ;-) And of course this is documented, see > Side note: when grepping for what "barrier()" does on different > architectures and different compilers, I note that yes, it really is > just an empty asm volatile with a "memory" barrier. That should in all > way sbe sufficient. > > BUT. > > There's this really odd comment in that talks > about some "ECC" compiler: > > /* Intel ECC compiler doesn't support gcc specific asm stmts. > * It uses intrinsics to do the equivalent things. > */ > > and it defines it as "__memory_barrier()". This seems to be an ia64 thing, but: "ecc" apparently was "icc" but for Itanium. It ceased to exist some time in the 2.4 era apparently. It was still used in 2003. Searching for "ecpc" (the C++ compiler driver) will find a bit more. > - I cannot get google to find me any documentation on such an intrinsic > > - it seems to be bogus anyway, since we have "asm volatile" usage in > at least arch/ia64/mm/tlb.c > > So I do note that "barrier()" has an odd definition in one odd ia64 > case, and I can't find the semantics for it. > > Admittedly I also cannot find it in myself to care. Yeah, I love code archaeology, but I have work to do as well :-) > I don't think that > "Intel ECC" compiler case actually exists, and even if it does I don't > think itanium is relevant any more. But it was an odd detail on what > "barrier()" actually might mean to the compiler. :-) Segher