Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp186306ybh; Mon, 20 Jul 2020 13:54:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmJXosZTEIzPMcuAEjKfQlp/gMkX+CBywgvdEUERoF2kPDD6VhfM+KHVyQfSgRorIZNe+9 X-Received: by 2002:a17:906:53d4:: with SMTP id p20mr22113136ejo.472.1595278472976; Mon, 20 Jul 2020 13:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595278472; cv=none; d=google.com; s=arc-20160816; b=OXNziSSrR0PX2sN6ebEdZjBVWIXz3/0JNw9y9rzmKYf71DBF3/4taL6ZyOEXcZy//V CBkNRWIa3syZtZRPxpDYv3BoktoCKV2i6gNDrt5vr5TMv9fIAlMGW2Tz+TluUUGQlujd mSMwnmPnQ/0YGMfLgvCFSpkMBrhGqPbWYuAK8N1Z7uwB4quhVpXE0kxsGiuakgZHI5Ql SJEqZo/EWlPQRbhfBvDua56SulkF6JPTVkX+sf2xNnVuez4Rkfh740B0pUn4z7TpTgMa IBJPt/rdGv8pKwsseO/pFYMHmy1bpyh4DevVwkJi/g4qO0kJQnMqC+bxAHkbSvnFLIym Yg6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=t/rXoQERR5pj1vBkNrq0HXWlaSRuz2vmMuIwif9Ddok=; b=cHVOSJZebCO6sMG4kxtoPGJiU6Wqbo5wyr9mRVlnIcxNVZfDwRS9W8kqc9CZj0R904 lu3ZsbPQALfeBUorerbHnBVXa5hfyMnSv+38Cz+9eNPiX5CJZnp+e/oYfnE3qXSw+Ls5 ut/2aYnfNcmO38fy1Qmlfnppv8FvqfasZ672S3MD8JzLM4xxYIjGeY/rvb89m9LySk3+ uE9PNhqmnsZPakv9AmXLCe5+8Q61r4aJDll/Ive1EThZ39qizWIAYwo9fkagK9w7uBBE mgKM7vlDYLOAR4Gjx+UTKB6FMhr9FaiFI1p3G2d3rirOYNK6ymsQsvELL/kZWP8Vymfu 2Veg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=G0oYaHUj; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si11739394edt.252.2020.07.20.13.54.09; Mon, 20 Jul 2020 13:54:32 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=G0oYaHUj; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729583AbgGTUuc (ORCPT + 99 others); Mon, 20 Jul 2020 16:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728604AbgGTUub (ORCPT ); Mon, 20 Jul 2020 16:50:31 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EC83C061794 for ; Mon, 20 Jul 2020 13:50:31 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i62so22972012ybc.15 for ; Mon, 20 Jul 2020 13:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=t/rXoQERR5pj1vBkNrq0HXWlaSRuz2vmMuIwif9Ddok=; b=G0oYaHUjQaYCEQsiULb1FkHUyf6Ws6k2kL/ZT6PlMtUwX2Htgrnc2dmV4ry+IG9WtR DTJ9LMsvw1uMntGHswGJOjFW97ZaEZ5Kue3RlHDxUkNJAnS1lsSBJXHJKrNlXtCnOOSo rc8X75FCQDv3dJaMIwWpbT531Ph3eE/zDV5SBWthR6U9kQ5bwyk5K4gTgNpsZh3sqJq3 7ZJ+zB61Si36MBVE8pB2UpqisJUQ2Ru+cuJyezkpM/efy7RJtXkfDRZfUEXIQYuzTt8L yUqq78Di6USyGVhLGeHOkXTdrvpJz/TDBIzTUC+Ghf2aA0KTkWQZvYEKOfuSb8Df0hPq hiWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=t/rXoQERR5pj1vBkNrq0HXWlaSRuz2vmMuIwif9Ddok=; b=lT5F4gGFoXZlDqWpjfD+Vj8egf8ckCOfBWjfIccW5qcAPPMBofQqUnYguFuNiz484F kM8AFvK4ydy9GxH42sq2R2xY/Ingk6Ko6xrSKSEJOVOB8SD6Os3p42ptsGOgiLckRL15 17L5u7dBT0GkQp6yP3jNH6LFvI4snXITboZ2f7oea4BaOYfSSsIg5tF54KnofE2aX8VF 70sS9zAvWLaRcp6h2U7vEDXmr+eyodrFHShI7UXKYg667TPtg1ZH+s7qBr77K+W7JLn1 ejSy72iy+aKBvBX6UH6cPFPvudXpamN5yYYrwqCTuRNc95qm0gEfys3jWieysXb07ne/ o0ag== X-Gm-Message-State: AOAM5304CJJWI5+NVp1aarHaorzysCvy3AypCvggqUMcf61cyJAPfIC+ i0amsSGZRn/+l+5xe7DQzQYEW/wJvP/pzy5bSUA= X-Received: by 2002:a25:dc84:: with SMTP id y126mr37614831ybe.350.1595278230622; Mon, 20 Jul 2020 13:50:30 -0700 (PDT) Date: Mon, 20 Jul 2020 13:49:23 -0700 In-Reply-To: <20200720204925.3654302-1-ndesaulniers@google.com> Message-Id: <20200720204925.3654302-10-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200720204925.3654302-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog Subject: [PATCH v3 09/11] x86/percpu: Clean up percpu_stable_op() From: Nick Desaulniers To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , x86@kernel.org, "H. Peter Anvin" , Al Viro , Andrew Morton , Peter Zijlstra , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Brian Gerst , Nick Desaulniers , Linus Torvalds Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian Gerst Use __pcpu_size_call_return() to simplify this_cpu_read_stable(). Also remove __bad_percpu_size() which is now unused. Tested-by: Nick Desaulniers Reviewed-by: Nick Desaulniers Acked-by: Linus Torvalds Acked-by: Peter Zijlstra (Intel) Signed-off-by: Brian Gerst Signed-off-by: Nick Desaulniers --- arch/x86/include/asm/percpu.h | 41 ++++++++++------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 7efc0b5c4ff0..cf2b9c2a241e 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -85,7 +85,6 @@ /* For arch-specific code, we can use direct single-insn ops (they * don't give an lvalue though). */ -extern void __bad_percpu_size(void); #define __pcpu_type_1 u8 #define __pcpu_type_2 u16 @@ -167,33 +166,13 @@ do { \ (typeof(_var))(unsigned long) pfo_val__; \ }) -#define percpu_stable_op(op, var) \ -({ \ - typeof(var) pfo_ret__; \ - switch (sizeof(var)) { \ - case 1: \ - asm(op "b "__percpu_arg(P1)",%0" \ - : "=q" (pfo_ret__) \ - : "p" (&(var))); \ - break; \ - case 2: \ - asm(op "w "__percpu_arg(P1)",%0" \ - : "=r" (pfo_ret__) \ - : "p" (&(var))); \ - break; \ - case 4: \ - asm(op "l "__percpu_arg(P1)",%0" \ - : "=r" (pfo_ret__) \ - : "p" (&(var))); \ - break; \ - case 8: \ - asm(op "q "__percpu_arg(P1)",%0" \ - : "=r" (pfo_ret__) \ - : "p" (&(var))); \ - break; \ - default: __bad_percpu_size(); \ - } \ - pfo_ret__; \ +#define percpu_stable_op(size, op, _var) \ +({ \ + __pcpu_type_##size pfo_val__; \ + asm(__pcpu_op2_##size(op, __percpu_arg(P[var]), "%[val]") \ + : [val] __pcpu_reg_##size("=", pfo_val__) \ + : [var] "p" (&(_var))); \ + (typeof(_var))(unsigned long) pfo_val__; \ }) /* @@ -258,7 +237,11 @@ do { \ * per-thread variables implemented as per-cpu variables and thus * stable for the duration of the respective task. */ -#define this_cpu_read_stable(var) percpu_stable_op("mov", var) +#define this_cpu_read_stable_1(pcp) percpu_stable_op(1, "mov", pcp) +#define this_cpu_read_stable_2(pcp) percpu_stable_op(2, "mov", pcp) +#define this_cpu_read_stable_4(pcp) percpu_stable_op(4, "mov", pcp) +#define this_cpu_read_stable_8(pcp) percpu_stable_op(8, "mov", pcp) +#define this_cpu_read_stable(pcp) __pcpu_size_call_return(this_cpu_read_stable_, pcp) #define raw_cpu_read_1(pcp) percpu_from_op(1, , "mov", pcp) #define raw_cpu_read_2(pcp) percpu_from_op(2, , "mov", pcp) -- 2.28.0.rc0.105.gf9edc3c819-goog