Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1894026lqa; Tue, 30 Apr 2024 02:21:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6LWUgijxYvPmE4U+oPX82zXM/VQVPBnUkpwmJtS3BqwPhHOY1Ufb54gOjbq2UmPsYBMfllOLgBT6duR8kAkiHjI+MgDJdAxWu13u9CA== X-Google-Smtp-Source: AGHT+IGzT7OSRw9pFUp/1ltlQuUNLDWatqR4YvMZN4Zm8o6Dv83RSw3+dmsRKrN+9HOVOjL0PX7I X-Received: by 2002:a17:902:dac4:b0:1ea:482f:f41e with SMTP id q4-20020a170902dac400b001ea482ff41emr3421621plx.15.1714468906070; Tue, 30 Apr 2024 02:21:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714468906; cv=pass; d=google.com; s=arc-20160816; b=aBF148H+b6W44Mud2bxkWaJt8ZjgtR6fEoACTYFyDl5CiRcgZCgX04kZEqT2qs4khg 4j/zDGIO3ru01tuRVRORoJ1x1vRHsKMdheFhcxxEYWuhflanzjnhNMZeo01h7cU6ovUI pKiNr4tNR7BR/BJkBr6Ien1G4CvYldkgB5tfqovv3Wc4ucESMcuyRFqkcB8iHfcVy8fr kYnDnKtTrxoIKFm8G0MlaaCIv9bc0cgKkM3mxz1Y/NsDp1TPEtvef6mAX73SJt5yc3Zt sxtQg6+f2YEZiJ+YxkqF/hzFs/bNojXHz6fKXHpD16NC2SQfO5Spk6sxCP23PPTFFHli Huqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FLIOsVy4cce4j8541l0tytwI1rGz4XmyB8qtCnnEfYc=; fh=6p6RvilH9GFLHKt/j4QscDGzDHssFfuE08NlVF+QDXM=; b=MJ9qF3SrZZsR8bNt82+Ao1mzX9DZ+Mkay9seOR4tzy04OPgjs6FrzOVN2ug1iDv2gF DEzEjdUkn26ZC7HEK2YJW5AwnqGzRnbTwdua54BcCmD5BDW3ApH6JakVGqDdncZoMN5f uK3oWQc96dHSJzwG42eFdB7Ry8BwwAGdEd5XaH6qTgxIBQrb8dQNVrqmIFGYYA7JoD9B 2vT4HVHTYSnePhTc0kRdsLu4cdiswa6wccVQiZE28jaaDv5egh4AxokY9gZ9Iewtzo+l m9kFYNBCtIU6909RqHDujw7c8sDDmaXhySNLH427T+ARcpo8HQIjwCUXxF/barrXPiNd Jeow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gt6Xx7Zd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163653-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bj11-20020a170902850b00b001e6764cd77bsi21436666plb.350.2024.04.30.02.21.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 02:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163653-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gt6Xx7Zd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163653-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 82898282C5A for ; Tue, 30 Apr 2024 09:21:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B448C1A38E0; Tue, 30 Apr 2024 09:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gt6Xx7Zd" Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A90C19DF53 for ; Tue, 30 Apr 2024 09:18:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714468731; cv=none; b=qZq4wavJAUEmcVeFCTr+Yx5J4Ikq8C8jmvq3HKggVNxm1CbarRoWPesmkCdu0i1jRVoBJ5SHQoUqgzswp6cyKbW31aFVurKYXmXJ0I5ShrhU6UIZaY84nlguPes4np3nZYAu4G9prHaG+b7RXeWy/pHAwUQ7ibEBI3MFWOxx3MI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714468731; c=relaxed/simple; bh=vtOoDYl1aOUNmIEBJBr5nX9rVdVflOoQ11HE29qUj9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VgdQmtWDUNTwNmsbq8+2Qm56/qT/xpYqogl4q4rKIet8eKAdLCkwg3BVBVT7gok242YAuKuMQllzZlfwoBtP1SMV5pGiP05Yl1tY92S+Vl8e5FPDf6RqHSZkJjuMeRjWHHxy4uhsdfJQeVUsVE5QSeIL69OT1i70l6qYczmk0bI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gt6Xx7Zd; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2e0a0cc5e83so19042071fa.1 for ; Tue, 30 Apr 2024 02:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714468728; x=1715073528; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FLIOsVy4cce4j8541l0tytwI1rGz4XmyB8qtCnnEfYc=; b=gt6Xx7Zd/3+mcC6pnPPVwuF/w2zMVdase0cUTmO2E9viJjRp3kLa/S44FZFVpSZ2/V qOPCZpP7HEz6r67wpWhMFsb+dndgxr69WXbWd56Frl8ZXWUYa4pZG7EqL9iyiJ1tE2fG c3PCN/2w4I12RjMVA81rIuivRHsT3nSkGODbI5qPy+A4oSGHOL5Kl1ygP+nwTSzhon2g kWy/p83WkfSQrVSXbrI7Ex0v5GOY6QPSDugWnX8HGfUQcAnS2V0yEcog6/Tzzbb35ABK J6A+djmfwiDtIJozZ5WgXvqbE7x6mU9RXXikM8QiOKn8APv291p1x41ogBp0jtqwAO+e XIJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714468728; x=1715073528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FLIOsVy4cce4j8541l0tytwI1rGz4XmyB8qtCnnEfYc=; b=WXzF9qWPQiv+j9xI/kdepQ9ZBQwN6TGwMYvjHqcschOS+UyhMohjETWQnhu7EATDwq x1y48+Wcy/C45wIlLlIL90FZR8ip999BdjM664nxnmm6KuZvzPqEJmS8tW5n+PFFd+ov ZGysnuWwyfmlcb9dnDWBSq/8hyEdYFbZ1prM8l7GzR+fUh5g1GmPj6G0yF9pWFTGRfSe W8+CiY4289rcoaPYlFi2VC5US6eKtm6tVqdxRxJnLa/EJ7M9O7Di0cFRoLEzFBTmT603 W/NqlEXxSeCZOQbXSmphFqf98e9DJQVn5/4ymwQvJC+Dn8rqejhHcrF4Fl2hcoqfxKVe I8pw== X-Forwarded-Encrypted: i=1; AJvYcCXUGK3eNmIZ61+/ZX9wj8J0yc3ms0HM/ccAnJANaVT79XMrsLr3F5pBgH0TgYcocpRGZURPFcqRswL4VUtDOiSuYyOd2MDfB3+35BvP X-Gm-Message-State: AOJu0YwKq6DaxuIquCvrOfPpHiza01Z7X+JYFbk4Gajz8j+jmAykaeUN 7TxHDmTQOalyNBlX6/u7/pJpwUmx5ZzzSacE0yAH4ur2OUE1sgQ5 X-Received: by 2002:a2e:be8d:0:b0:2e0:eb96:7b53 with SMTP id a13-20020a2ebe8d000000b002e0eb967b53mr1314561ljr.44.1714468727617; Tue, 30 Apr 2024 02:18:47 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id h3-20020a05600c314300b0041abdaf8c6asm26324458wmo.13.2024.04.30.02.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 02:18:47 -0700 (PDT) From: Uros Bizjak To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH -tip 3/5] x86/percpu: Unify percpu read-write accessors Date: Tue, 30 Apr 2024 11:17:22 +0200 Message-ID: <20240430091833.196482-3-ubizjak@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430091833.196482-1-ubizjak@gmail.com> References: <20240430091833.196482-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Redefine percpu_from_op() and percpu_to_op() as __raw_cpu_read() and __raw_cpu_write(). Unify __raw_cpu_{read,write}() macros between configs w/ and w/o USE_X86_SEG_SUPPORT in order to unify {raw,this}_cpu{read_write}_N() accessors between configs. No functional change intended. Signed-off-by: Uros Bizjak Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" --- arch/x86/include/asm/percpu.h | 72 ++++++++++++----------------------- 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 08113a2e5377..f360ac5fccde 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -146,28 +146,28 @@ #ifdef CONFIG_USE_X86_SEG_SUPPORT -#define __raw_cpu_read(qual, pcp) \ +#define __raw_cpu_read(size, qual, pcp) \ ({ \ *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)); \ }) -#define __raw_cpu_write(qual, pcp, val) \ +#define __raw_cpu_write(size, qual, pcp, val) \ do { \ *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val); \ } while (0) #else /* CONFIG_USE_X86_SEG_SUPPORT */ -#define percpu_from_op(size, qual, op, _var) \ +#define __raw_cpu_read(size, qual, _var) \ ({ \ __pcpu_type_##size pfo_val__; \ - asm qual (__pcpu_op2_##size(op, __percpu_arg([var]), "%[val]") \ + asm qual (__pcpu_op2_##size("mov", __percpu_arg([var]), "%[val]") \ : [val] __pcpu_reg_##size("=", pfo_val__) \ : [var] "m" (__my_cpu_var(_var))); \ (typeof(_var))(unsigned long) pfo_val__; \ }) -#define percpu_to_op(size, qual, op, _var, _val) \ +#define __raw_cpu_write(size, qual, _var, _val) \ do { \ __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val); \ if (0) { \ @@ -175,7 +175,7 @@ do { \ pto_tmp__ = (_val); \ (void)pto_tmp__; \ } \ - asm qual(__pcpu_op2_##size(op, "%[val]", __percpu_arg([var])) \ + asm qual(__pcpu_op2_##size("mov", "%[val]", __percpu_arg([var])) \ : [var] "+m" (__my_cpu_var(_var)) \ : [val] __pcpu_reg_imm_##size(pto_val__)); \ } while (0) @@ -448,54 +448,32 @@ do { \ */ #define this_cpu_read_stable(pcp) __pcpu_size_call_return(this_cpu_read_stable_, pcp) -#ifdef CONFIG_USE_X86_SEG_SUPPORT -#define raw_cpu_read_1(pcp) __raw_cpu_read(, pcp) -#define raw_cpu_read_2(pcp) __raw_cpu_read(, pcp) -#define raw_cpu_read_4(pcp) __raw_cpu_read(, pcp) -#define raw_cpu_write_1(pcp, val) __raw_cpu_write(, pcp, val) -#define raw_cpu_write_2(pcp, val) __raw_cpu_write(, pcp, val) -#define raw_cpu_write_4(pcp, val) __raw_cpu_write(, pcp, val) - -#define this_cpu_read_1(pcp) __raw_cpu_read(volatile, pcp) -#define this_cpu_read_2(pcp) __raw_cpu_read(volatile, pcp) -#define this_cpu_read_4(pcp) __raw_cpu_read(volatile, pcp) -#define this_cpu_write_1(pcp, val) __raw_cpu_write(volatile, pcp, val) -#define this_cpu_write_2(pcp, val) __raw_cpu_write(volatile, pcp, val) -#define this_cpu_write_4(pcp, val) __raw_cpu_write(volatile, pcp, val) +#define raw_cpu_read_1(pcp) __raw_cpu_read(1, , pcp) +#define raw_cpu_read_2(pcp) __raw_cpu_read(2, , pcp) +#define raw_cpu_read_4(pcp) __raw_cpu_read(4, , pcp) +#define raw_cpu_write_1(pcp, val) __raw_cpu_write(1, , pcp, val) +#define raw_cpu_write_2(pcp, val) __raw_cpu_write(2, , pcp, val) +#define raw_cpu_write_4(pcp, val) __raw_cpu_write(4, , pcp, val) + +#define this_cpu_read_1(pcp) __raw_cpu_read(1, volatile, pcp) +#define this_cpu_read_2(pcp) __raw_cpu_read(2, volatile, pcp) +#define this_cpu_read_4(pcp) __raw_cpu_read(4, volatile, pcp) +#define this_cpu_write_1(pcp, val) __raw_cpu_write(1, volatile, pcp, val) +#define this_cpu_write_2(pcp, val) __raw_cpu_write(2, volatile, pcp, val) +#define this_cpu_write_4(pcp, val) __raw_cpu_write(4, volatile, pcp, val) #ifdef CONFIG_X86_64 -#define raw_cpu_read_8(pcp) __raw_cpu_read(, pcp) -#define raw_cpu_write_8(pcp, val) __raw_cpu_write(, pcp, val) +#define raw_cpu_read_8(pcp) __raw_cpu_read(8, , pcp) +#define raw_cpu_write_8(pcp, val) __raw_cpu_write(8, , pcp, val) -#define this_cpu_read_8(pcp) __raw_cpu_read(volatile, pcp) -#define this_cpu_write_8(pcp, val) __raw_cpu_write(volatile, pcp, val) +#define this_cpu_read_8(pcp) __raw_cpu_read(8, volatile, pcp) +#define this_cpu_write_8(pcp, val) __raw_cpu_write(8, volatile, pcp, val) #endif -#define this_cpu_read_const(pcp) __raw_cpu_read(, pcp) +#ifdef CONFIG_USE_X86_SEG_SUPPORT +#define this_cpu_read_const(pcp) __raw_cpu_read(, , pcp) #else /* CONFIG_USE_X86_SEG_SUPPORT */ -#define raw_cpu_read_1(pcp) percpu_from_op(1, , "mov", pcp) -#define raw_cpu_read_2(pcp) percpu_from_op(2, , "mov", pcp) -#define raw_cpu_read_4(pcp) percpu_from_op(4, , "mov", pcp) -#define raw_cpu_write_1(pcp, val) percpu_to_op(1, , "mov", (pcp), val) -#define raw_cpu_write_2(pcp, val) percpu_to_op(2, , "mov", (pcp), val) -#define raw_cpu_write_4(pcp, val) percpu_to_op(4, , "mov", (pcp), val) - -#define this_cpu_read_1(pcp) percpu_from_op(1, volatile, "mov", pcp) -#define this_cpu_read_2(pcp) percpu_from_op(2, volatile, "mov", pcp) -#define this_cpu_read_4(pcp) percpu_from_op(4, volatile, "mov", pcp) -#define this_cpu_write_1(pcp, val) percpu_to_op(1, volatile, "mov", (pcp), val) -#define this_cpu_write_2(pcp, val) percpu_to_op(2, volatile, "mov", (pcp), val) -#define this_cpu_write_4(pcp, val) percpu_to_op(4, volatile, "mov", (pcp), val) - -#ifdef CONFIG_X86_64 -#define raw_cpu_read_8(pcp) percpu_from_op(8, , "mov", pcp) -#define raw_cpu_write_8(pcp, val) percpu_to_op(8, , "mov", (pcp), val) - -#define this_cpu_read_8(pcp) percpu_from_op(8, volatile, "mov", pcp) -#define this_cpu_write_8(pcp, val) percpu_to_op(8, volatile, "mov", (pcp), val) -#endif - /* * The generic per-cpu infrastrucutre is not suitable for * reading const-qualified variables. -- 2.44.0