Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1329981ybl; Fri, 30 Aug 2019 16:17:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBR2zDD8V72/WmDpeks+f1V0qRPsxzXZZVam0in5DlZir6DND5cJjkFOHbXYSfXGcb9Vo7 X-Received: by 2002:a63:5945:: with SMTP id j5mr14788759pgm.452.1567207035118; Fri, 30 Aug 2019 16:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567207035; cv=none; d=google.com; s=arc-20160816; b=NGL7WrK3GLuaQ054+RRghLSdEuQiTxzHmTDjOXtk1MXeldjXOyLT6HQT0HA4U9pgn8 15pz5WfTrFP0WDRqdcjINFwEmGhSjxrconObj/ch0Vm4/Rt+HYSoNEtGDDlueypZd+EN sqbYYbYlKE9WMsFugG/BxdMUGeEDztHuG/EtR5+yGuvQ9dnWCheznp036JTN0m5bQoYU Nb62KtHptAB2eIgOQLxE7G3cqwj7hEkatCVmjHZt+46J2Yd0Y/i4WXpy7OdNnP6E3Qgg mJHr+zxS78OJmHiPOuFRuA60x/F36ZllXYhCH+aCYwSLDFNJSeLxGGUs5/sESUEtOpxg +WlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6P0N9+OtzBQ/+pWxgapquiOAPv3FZmW3I9CzZ8KtwA0=; b=E0txf4gucDobY1z09HODyU5IrtOR5liF/u3CwNKoZdWpSBcgfXC4c9U5w3263h5AiV 5Z9US8MECIQWN06URz+Dl7l+rxs+PkwdLg+xDF/qZ4JOPJjasR4t7cWlaAmeFT0i9zgI yOJFkDQH0U4DkW+M46xizgv5FsIL6F2Bindjp1VeebZG1giNdUCogW4xh20duAPDqGIJ MCol3EGV7ilCXzC58RebArYPE6dEfR3zVSPXaBdvvtwdYgVz+YC+dZ7LGFc0F70Xossu Fc3eXSYno1WSe0yyRUqfPThIJwKPBthvJaQWEyUeakouvE6MfkCEy6g/4P1WU5EdpRWR pS5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=boJouUw7; 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 cj2si5983846plb.190.2019.08.30.16.17.00; Fri, 30 Aug 2019 16:17:15 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=boJouUw7; 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 S1728540AbfH3XPw (ORCPT + 99 others); Fri, 30 Aug 2019 19:15:52 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:44846 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728468AbfH3XPk (ORCPT ); Fri, 30 Aug 2019 19:15:40 -0400 Received: by mail-ed1-f66.google.com with SMTP id a21so9695880edt.11 for ; Fri, 30 Aug 2019 16:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6P0N9+OtzBQ/+pWxgapquiOAPv3FZmW3I9CzZ8KtwA0=; b=boJouUw78n75bFxQRuRR8zbkuteRj6NjF5ukCY3vk1vAP3W5UUvRAzwPJ7M4qRF0b1 VhaNF6RFkQm01KXbbHye45S5UxAtRndhVKlvQI6um+I2GuQ4yAYDuGEytSKxDbBA9bPf r8Ack5+2qynx6L1DM68lp3PCdFRZ7Nv04qnQA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6P0N9+OtzBQ/+pWxgapquiOAPv3FZmW3I9CzZ8KtwA0=; b=c+Yr4lXks06oRozEv89kMql98kL3Jonj5M6xssaOsNlYOiaSq13CP/xXZr8sEaT9h5 Q7G4mVyL7ovhPRxKqo2lmrhD54xbnAgb8tZK4c//OZ+TmevPA/hXFLPpNZdZTnxIF+5w A2Hf6YOI6lmdcTQ2PcbMhZcgLVSWrpxFDbRPY3S7IVI1K3hBtsWz+ta4VczDc7HcB3RU DJ2z9q+7e7YCyOClOPcta80bhj/L6DwIAFpudaniF9U3hZTdFtU+AOh7YhnkNOcnprK7 qZCQg8UT2oDJlEhRfHhCB3hVUdfYAHlBFtbc1KULDWfqwpph3VVoixOII2eF7ZWii7Au ht3Q== X-Gm-Message-State: APjAAAX6WGM+L9DVtLAyuPUGs5hWOXoevFbNd6EdpQwAtlPofQqU5Slu 0k/5CMJHWmwUZMsfML+dP5bPbg== X-Received: by 2002:a50:ba81:: with SMTP id x1mr17958640ede.257.1567206938426; Fri, 30 Aug 2019 16:15:38 -0700 (PDT) Received: from prevas-ravi.prevas.se (ip-5-186-115-35.cgn.fibianet.dk. [5.186.115.35]) by smtp.gmail.com with ESMTPSA id s4sm875457ejx.33.2019.08.30.16.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 16:15:37 -0700 (PDT) From: Rasmus Villemoes To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Nadav Amit , Linus Torvalds , Miguel Ojeda , ndesaulniers@google.com, Rasmus Villemoes Subject: [PATCH v2 5/6] x86: alternative.h: use asm_inline for all alternative variants Date: Sat, 31 Aug 2019 01:15:26 +0200 Message-Id: <20190830231527.22304-6-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190830231527.22304-1-linux@rasmusvillemoes.dk> References: <20190829083233.24162-1-linux@rasmusvillemoes.dk> <20190830231527.22304-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Most, if not all, uses of the alternative* family just provide one or two instructions in .text, but the string literal can be quite large, causing gcc to overestimate the size of the generated code. That in turn affects its decisions about inlining of the function containing the alternative() asm statement. gcc >= 9.1 allows one to overrule the estimated size by using "asm inline" instead of just "asm". So replace asm by the helper asm_inline, which for older gccs just expands to asm. Signed-off-by: Rasmus Villemoes --- arch/x86/include/asm/alternative.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 094fbc9c0b1c..13adca37c99a 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -201,10 +201,10 @@ static inline int alternatives_text_reserved(void *start, void *end) * without volatile and memory clobber. */ #define alternative(oldinstr, newinstr, feature) \ - asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) : : : "memory") + asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) : : : "memory") #define alternative_2(oldinstr, newinstr1, feature1, newinstr2, feature2) \ - asm volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2) ::: "memory") + asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2) ::: "memory") /* * Alternative inline assembly with input. @@ -218,7 +218,7 @@ static inline int alternatives_text_reserved(void *start, void *end) * Leaving an unused argument 0 to keep API compatibility. */ #define alternative_input(oldinstr, newinstr, feature, input...) \ - asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ + asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ : : "i" (0), ## input) /* @@ -231,18 +231,18 @@ static inline int alternatives_text_reserved(void *start, void *end) */ #define alternative_input_2(oldinstr, newinstr1, feature1, newinstr2, \ feature2, input...) \ - asm volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, \ + asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, \ newinstr2, feature2) \ : : "i" (0), ## input) /* Like alternative_input, but with a single output argument */ #define alternative_io(oldinstr, newinstr, feature, output, input...) \ - asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ + asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ : output : "i" (0), ## input) /* Like alternative_io, but for replacing a direct call with another one. */ #define alternative_call(oldfunc, newfunc, feature, output, input...) \ - asm volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \ + asm_inline volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \ : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input) /* @@ -253,7 +253,7 @@ static inline int alternatives_text_reserved(void *start, void *end) */ #define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2, \ output, input...) \ - asm volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\ + asm_inline volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\ "call %P[new2]", feature2) \ : output, ASM_CALL_CONSTRAINT \ : [old] "i" (oldfunc), [new1] "i" (newfunc1), \ -- 2.20.1