Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1849723imm; Thu, 11 Oct 2018 00:25:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV63i8BKY+Jrvl+A+sKTj8RcFGBGUI/LfGrcCDtPDdTklyjJvuGpLrmH3mTn2skbG7n08MBEe X-Received: by 2002:a17:902:848f:: with SMTP id c15-v6mr408617plo.119.1539242701865; Thu, 11 Oct 2018 00:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539242701; cv=none; d=google.com; s=arc-20160816; b=nGITjfBXhPOEQdTT+LUgMdL6Huwnkp+k4byaK5uaCz80pNq1pqqoUiHCcVYRE12HcK SSi9umBw9Lf1wCCDmL2C/vCS+xQr+H1K2Nw2AF23/y71lzY0gI9GVXkNAwvoHsnBIGFV H76fprc2VmZ6bQuuyLTu1FiYs9myAgqiqPE92lGV+t/m3o/zSRUDY07W6AEzSSpeLFu+ 282InF/4RM3c0a6USZ6fLFHjwLqBvs4geoRCwwUhx5di3/bY9k0raNJEkBqHd/jrnT0l zQWcVWYHIQRy9oVQt6Mew4KSkNSsZ4rPfJiXpo2pl7eezqy5LDwTG4w6zw1isWCbscXC aVeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=MGQdSvurek/eb859XHRPToWneflbfKWnWw4mQitSat8=; b=zZbOW5e3uGueHHdgQXbj6IZS34CFXiO3ujgTLkrciiPMeBBjrAQ9eSyGyGb35zDaVV jK1+jOcteIGj6KBblWGP2lOXIQnMAjeaxkz8JacFAZwW4PxyzJ9A1lJmFKHtfCzDwv1H 4GrPXK8plNg0K85ew0gYT2PYWPsXBiKQfEn8wtwPELPcpHeTknBGCdkYa+En/fREZNX7 ML4JYKUyRLXrXVRtt4U0UbqJY23g6RzwBz/W3a0B2m2qKjJhlwoOs8uf/FoQL9r4iigJ whzyQyhS2pNPrS05LuSQyYQdTg6AToTTGH9WA9gC1uN1K6UUtf9F2VuaiDEusilfLwGd JSSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay10-v6si1989297plb.5.2018.10.11.00.24.46; Thu, 11 Oct 2018 00:25:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbeJKOa7 (ORCPT + 99 others); Thu, 11 Oct 2018 10:30:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:47644 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725995AbeJKOa7 (ORCPT ); Thu, 11 Oct 2018 10:30:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C1190B10D; Thu, 11 Oct 2018 07:05:01 +0000 (UTC) Date: Thu, 11 Oct 2018 09:04:58 +0200 (CEST) From: Richard Biener To: Nadav Amit cc: Segher Boessenkool , Michael Matz , Borislav Petkov , "gcc@gcc.gnu.org" , Ingo Molnar , LKML , X86 ML , Masahiro Yamada , Sam Ravnborg , Alok Kataria , Christopher Li , Greg Kroah-Hartman , "H. Peter Anvin" , Jan Beulich , Josh Poimboeuf , Juergen Gross , Kate Stewart , Kees Cook , "linux-sparse@vger.kernel.org" , Peter Zijlstra , Philippe Ombredanne , Thomas Gleixner , "virtualization@lists.linux-foundation.org" , Linus Torvalds , Chris Zankel , Max Filippov , "linux-xtensa@linux-xtensa.org" Subject: Re: PROPOSAL: Extend inline asm syntax with size spec In-Reply-To: <5ACDEDEA-0E42-45F2-BC80-B96EC2ABC01D@vmware.com> Message-ID: References: <20181003213100.189959-1-namit@vmware.com> <20181007091805.GA30687@zn.tnic> <20181007132228.GJ29268@gate.crashing.org> <20181008073128.GL29268@gate.crashing.org> <20181009145330.GT29268@gate.crashing.org> <5ACDEDEA-0E42-45F2-BC80-B96EC2ABC01D@vmware.com> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="-1609908220-1536231581-1539241501=:16707" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1609908220-1536231581-1539241501=:16707 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 10 Oct 2018, Nadav Amit wrote: > at 7:53 AM, Segher Boessenkool wrote: > > > On Mon, Oct 08, 2018 at 11:07:46AM +0200, Richard Biener wrote: > >> On Mon, 8 Oct 2018, Segher Boessenkool wrote: > >>> On Sun, Oct 07, 2018 at 03:53:26PM +0000, Michael Matz wrote: > >>>> On Sun, 7 Oct 2018, Segher Boessenkool wrote: > >>>>> On Sun, Oct 07, 2018 at 11:18:06AM +0200, Borislav Petkov wrote: > >>>>>> Now, Richard suggested doing something like: > >>>>>> > >>>>>> 1) inline asm ("...") > >>>>> > >>>>> What would the semantics of this be? > >>>> > >>>> The size of the inline asm wouldn't be counted towards the inliner size > >>>> limits (or be counted as "1"). > >>> > >>> That sounds like a good option. > >> > >> Yes, I also like it for simplicity. It also avoids the requirement > >> of translating the number (in bytes?) given by the user to > >> "number of GIMPLE instructions" as needed by the inliner. > > > > This patch implements this, for C only so far. And the syntax is > > "asm inline", which is more in line with other syntax. > > > > How does this look? > > It looks good to me in general. I have a couple of reservations, but I > suspect you will not want to address them: > > 1. It is not backward compatible, requiring a C macro to wrap it, as the > kernel might be built with different compilers. > > 2. It is specific to asm. I do not have in mind another use case (excluding > the __builtin_constant_p), but it would be nicer IMHO to have a builtin > saying “ignore the cost of this statement” for the matter of optimizations. The only easy possibility that comes to my mid is sth like __attribute__((always_inline, zero_cost)) foo () { ... your stmts ... } and us, upon inlining, marking the inlined stmts properly. That would also work for the asm() case and it would be backwards compatible (well, you'd get a diagnostic for the unknown zero_cost attribute). There's the slight complication that if you have, say _1 = _2 * 3; // zero-cost _4 = _1 * 2; and optimization ends up combining those to _4 = _2 * 6; then is this stmt supposed to be zero-cost or not? Compare that to _1 = _2 * 3; _4 = _1 * 2; // zero-cost So outside of asm() there are new issues that come up with respect to expected (cost) semantics. Richard. ---1609908220-1536231581-1539241501=:16707--