Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4278032imm; Fri, 18 May 2018 02:20:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrp+m1zctpVhS+1nVw3MtxbEz5BtsQ77UgcocAjhHGGIIIEEIpac4R9rdymP5sz96S0xMbY X-Received: by 2002:a63:b443:: with SMTP id n3-v6mr6704493pgu.81.1526635231845; Fri, 18 May 2018 02:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526635231; cv=none; d=google.com; s=arc-20160816; b=h4XuYFiVuFOX7IXz5tKT7oNs6IkM0jZL601hAHZeAy9Jf6ifLCo9ZF6iNBHqx5uQ/y Jc24Ig9HFLy43hV2ezDv6D8q7IkrrgbEtO6Ch8uLsukCpcYsntqBD0vMT+WKfjBsT6HF O12g3dtNCeYrNsaZ7+ThYJOCjE6h7WFx/M2bw7oWmAYI8Be+PFFlINtO8/OS5oLoPA48 Pf4SmZwDO4gs+gwtACa+yRhMEkPcfjUsCPvBHECYa5UONSHfcaFGCSf/1+QxxwOHHTEp qj6OnWEjqe8xOwdOJ63ZPnDM0oww8KyVAcZZo5Aa2Ah+07e2G3XD1xl4hxrvT4fGQEzR GD5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=t2OxMAqPg4Nj+hKlFg0+6J2t153c+6abizR89r+XDPA=; b=G8UzQdsqXEbNwRajmF3aTxGBt8M4P4yo2NBS/X+oR915+iFRcECDwOhV8nCNwiwFVQ A2rumB11851qbf7AmX18/oF6jRQadd4YWMq0wDUu60uzQ0+gFNZziJKQMET4MStKF4tK dPwJ4JNTv6JFt6zgpPwCv7CbsTWqgm6aDWcVzI2X7fBEouuZhAQaKz1ezp/4EWrXY6vZ dOG4YIExjqGZL8pT03Dr6/qMdfU6jGtmwXQ2vrxpunjNkHW9AaKK48OeR4iQ9+G3Fg0g geJx8K1+N1LswVhBQq0Vtoit7vlccPWqEv9nkQ7DsgCxE3ziPls9X5pWp+IXA4UnNWSL y0cw== 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 a7-v6si5750084pgd.338.2018.05.18.02.20.17; Fri, 18 May 2018 02:20:31 -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 S1753070AbeERJT4 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 18 May 2018 05:19:56 -0400 Received: from smtp-out6.electric.net ([192.162.217.189]:51807 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbeERJTt (ORCPT ); Fri, 18 May 2018 05:19:49 -0400 Received: from 1fJbXx-0006vk-UH by out6a.electric.net with emc1-ok (Exim 4.90_1) (envelope-from ) id 1fJbY5-0007mk-UI; Fri, 18 May 2018 02:19:41 -0700 Received: by emcmailer; Fri, 18 May 2018 02:19:41 -0700 Received: from [156.67.243.126] (helo=AcuMS.aculab.com) by out6a.electric.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fJbXx-0006vk-UH; Fri, 18 May 2018 02:19:33 -0700 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b::d117) by AcuMS.aculab.com (fd9f:af1c:a25b::d117) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 18 May 2018 10:20:40 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Fri, 18 May 2018 10:20:40 +0100 From: David Laight To: 'Nadav Amit' , "linux-kernel@vger.kernel.org" , "x86@kernel.org" CC: "nadav.amit@gmail.com" , Alok Kataria , Christopher Li , "H. Peter Anvin" , Ingo Molnar , Jan Beulich , Jonathan Corbet , Josh Poimboeuf , Juergen Gross , Kees Cook , "linux-sparse@vger.kernel.org" , Peter Zijlstra , "Randy Dunlap" , Thomas Gleixner , "virtualization@lists.linux-foundation.org" Subject: RE: [PATCH 0/6] Macrofying inline assembly for better compilation Thread-Topic: [PATCH 0/6] Macrofying inline assembly for better compilation Thread-Index: AQHT7jb3bgwHyh+4Jkuhj2LenJssC6Q1Njbg Date: Fri, 18 May 2018 09:20:40 +0000 Message-ID: <8737d8d4c7e84c47938e9b1aaeae16b9@AcuMS.aculab.com> References: <20180517161402.78089-1-namit@vmware.com> In-Reply-To: <20180517161402.78089-1-namit@vmware.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuMS.aculab.com X-TLS: TLSv1.2:ECDHE-RSA-AES256-SHA384:256 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 X-Virus-Status: Scanned by VirusSMART (c) X-Virus-Status: Scanned by VirusSMART (s) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadav Amit > Sent: 17 May 2018 17:14 > This patch-set deals with an interesting yet stupid problem: kernel code > that does not get inlined despite its simplicity. There are several > causes for this behavior: "cold" attribute on __init, different function > optimization levels; conditional constant computations based on > __builtin_constant_p(); and finally large inline assembly blocks. > > This patch-set deals with the inline assembly problem. I separated these > patches from the others (that were sent in the RFC) for easier > inclusion. > > The problem with inline assembly is that inline assembly is often used > by the kernel for things that are other than code - for example, > assembly directives and data. GCC however is oblivious to the content of > the blocks and assumes their cost in space and time is proportional to > the number of the perceived assembly "instruction", according to the > number of newlines and semicolons. Alternatives, paravirt and other > mechanisms are affected, causing code not to be inlined, and degrading > compilation quality in general. > > The solution that this patch-set carries for this problem is to create > an assembly macro, and then call it from the inline assembly block. As > a result, the compiler sees a single "instruction" and assigns the more > appropriate cost to the code. In addition, this patch-set removes > unneeded new-lines from common x86 inline asm's, which "confuse" GCC > heuristics. Can't you get the same effect by using always_inline ? David