Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp184590ybh; Mon, 20 Jul 2020 13:50:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7vaeJkoqc4uEJHiU98QLQW8yzn4/Xz4LUErBURONQFadXVBsXivR44CI+zfH/CVkZv7BC X-Received: by 2002:a17:906:48d3:: with SMTP id d19mr21908267ejt.180.1595278230317; Mon, 20 Jul 2020 13:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595278230; cv=none; d=google.com; s=arc-20160816; b=EXJmAE1UTmS3OJcHZAeN8hwWgDztwsIeSwT+JebTlomgo8SwRd1qDDfYZ3CYUF4WCu A0iFcESA1oemVWUSy9cUZFYmD9tilYHZO0pAPuuCUU7v2vM3OzzlzDTn172123W4C13h Fuspr00f91ZblXZ8RfH0P6y9I9QwjJvPFEZB9oMDv492rfDeyEjdCpYZgVmc7cNp+wce 9cXI18ICBXGvm+VB789XZvaOW/sCiD0AuncSxwYaugRp5fpxMbf2nKjFrOeYeLeshcBn 0XCZP4uNDPOOnRqQ7VibdyRGD4mDYbSjuUz0MisfKCgRvS+q/gDyTckOknG3VLOUNT9f qsow== 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=ac83xydEfYdvLnMrJP/6mCcgSl/ZzWMIDDapcG1OTQM=; b=TDQNlz8CXMSzclkHm8Pw6P4iF2wpIxYh4EsrSKHoqqVjH6+2g42b2Is656j+BUCykN e41rjlBvWx6f47KU0U2Oz4PfmerZ0q+Tn6+uUUl+TICs/fHC7M1IacGaC8UL2siDGGRg tIVG0arevEjDmcoOnofgEzdXg576joWBtNuDpe3bt7wC8IK2cDg8sdgC5SLqsxD1EC6r 50aD5avQDpVQmBbnknl3TajT2tJvDFpW1l4ITLgCxc7n7T3ggnzlDThFgyu0HIxS7Czy 61Nrc75umKJytw3MZoymCTd/2rg/h8iNxFLMvJTSO8Eotj511Lc89U+GprHCTVz/1SkB 9eNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JYYPB8p5; 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 w6si11963380edl.341.2020.07.20.13.50.07; Mon, 20 Jul 2020 13:50:30 -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=JYYPB8p5; 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 S1729236AbgGTUts (ORCPT + 99 others); Mon, 20 Jul 2020 16:49:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726012AbgGTUts (ORCPT ); Mon, 20 Jul 2020 16:49:48 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0ACBC0619D2 for ; Mon, 20 Jul 2020 13:49:47 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id b69so13489947pfb.14 for ; Mon, 20 Jul 2020 13:49:47 -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=ac83xydEfYdvLnMrJP/6mCcgSl/ZzWMIDDapcG1OTQM=; b=JYYPB8p5iFY3MWf4GNM8ckYki4GjyRtkNH0mEHHR6DuTXDz7v7vhNYqSLMKWEpIxpk 67SB7uVG5diSpuJU9VIA+1E7xEiXuw4VQd/KY2svSaTM2z9wPWEkKmWmCJyXmRqdXmF7 trgYDOyoqDppd4svcJADvNjOmp6UbmHw2OPek+BF0bAro4xX5Z4j4CgUg0LFFEKPQeGt Yl1oAy6z985PPupmzxMiHAzp98NNo3TH8DRKPJZ07XY7n0W2TVbpLo5WQoGoby8h9Lqd Tl+mXCah0XlpzwdBdghBPcpk0QCgZqmp+6UVpFb3ikPBSRDHA7l03Vv3hgoQbiWPaZmo cEEA== 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=ac83xydEfYdvLnMrJP/6mCcgSl/ZzWMIDDapcG1OTQM=; b=cyQ29MKF3F5f/IoIH3Uuv77OQZilScilRzNmBjMDebQOI3Mg0qNiJJBIDeDCZtThkI X+16+PKu4tPzba8J4/kQ89pCWXPY3JYt8Lso+eGROdtfrwyzI+04NE40GP++8Gi3FEeD U0uHNE6mkehczmdj9kaPz4jxIc+OabVG6M3msMqswA8fLFAoW4iRWLQ1imsznQyaWwCt E8AVFOewuy/jNZK8VmOOPJIfqfJHrYQ1RuWbndLtUHvfww7S0FDIHmmh/Vy0Q9NMbDxr TmIL8OlGxM4gZt+oxF1c3f9eiPRFSVeZ6FXYhtzLm+jxR8P5Oc7NfzwWYhJuYa8ycxRd rxoQ== X-Gm-Message-State: AOAM533EtoqfTzBXhRGcx/Rx4OExYEc1KdzKbPGcE9DcopzL8DOhypWU TWISlU1pHo8Kb8/EfAtqZ0s+QLtlEUDDxdn87ek= X-Received: by 2002:a17:90a:d48a:: with SMTP id s10mr1102818pju.116.1595278187193; Mon, 20 Jul 2020 13:49:47 -0700 (PDT) Date: Mon, 20 Jul 2020 13:49:15 -0700 In-Reply-To: <20200720204925.3654302-1-ndesaulniers@google.com> Message-Id: <20200720204925.3654302-2-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 01/11] x86/percpu: Introduce size abstraction macros 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 In preparation for cleaning up the percpu operations, define macros for abstraction based on the width of the operation. 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 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 2278797c769d..19838e4f7a8f 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -87,6 +87,36 @@ * don't give an lvalue though). */ extern void __bad_percpu_size(void); +#define __pcpu_type_1 u8 +#define __pcpu_type_2 u16 +#define __pcpu_type_4 u32 +#define __pcpu_type_8 u64 + +#define __pcpu_cast_1(val) ((u8)(((unsigned long) val) & 0xff)) +#define __pcpu_cast_2(val) ((u16)(((unsigned long) val) & 0xffff)) +#define __pcpu_cast_4(val) ((u32)(((unsigned long) val) & 0xffffffff)) +#define __pcpu_cast_8(val) ((u64)(val)) + +#define __pcpu_op1_1(op, dst) op "b " dst +#define __pcpu_op1_2(op, dst) op "w " dst +#define __pcpu_op1_4(op, dst) op "l " dst +#define __pcpu_op1_8(op, dst) op "q " dst + +#define __pcpu_op2_1(op, src, dst) op "b " src ", " dst +#define __pcpu_op2_2(op, src, dst) op "w " src ", " dst +#define __pcpu_op2_4(op, src, dst) op "l " src ", " dst +#define __pcpu_op2_8(op, src, dst) op "q " src ", " dst + +#define __pcpu_reg_1(mod, x) mod "q" (x) +#define __pcpu_reg_2(mod, x) mod "r" (x) +#define __pcpu_reg_4(mod, x) mod "r" (x) +#define __pcpu_reg_8(mod, x) mod "r" (x) + +#define __pcpu_reg_imm_1(x) "qi" (x) +#define __pcpu_reg_imm_2(x) "ri" (x) +#define __pcpu_reg_imm_4(x) "ri" (x) +#define __pcpu_reg_imm_8(x) "re" (x) + #define percpu_to_op(qual, op, var, val) \ do { \ typedef typeof(var) pto_T__; \ -- 2.28.0.rc0.105.gf9edc3c819-goog