Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2302918lqo; Mon, 20 May 2024 01:10:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfl6atMSHLiPioqZe5zlrpDRi2fiEE/alh/5CdPn7kiOVCYzHZD8h7m33XepmWkuhu8Lnns49wkkJ7+Gdd44iBWOPLktX+1o5gdK+zIA== X-Google-Smtp-Source: AGHT+IFyQQ04pT9V8TwfdBDHpbH04LKNuzRyicjpfQxBsKuXJLTP9oUKeD0EdX/2fTJKiEKpjR6/ X-Received: by 2002:a05:620a:4905:b0:792:c243:3270 with SMTP id af79cd13be357-792c7577b4dmr3137915285a.7.1716192610616; Mon, 20 May 2024 01:10:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716192610; cv=pass; d=google.com; s=arc-20160816; b=nUae/YtuBl/S3/iDJSE3p9kkbftwDBDVoRnWlAj3T9Is48pIqD+feUWFH2D1PXRx9r UHaXdvkVuhkhfo7O9xHurs0Idoa4qYjmzWqe0UImqOg8JEjfIYDIZDYg4AwYRWi21782 GuHow3xBpJgPyUoHCCpxd+xs0MBCeJ5rCFZgrh7YGmUSAoOR3CWrrt/gqEUVnb6XPIyG pX5Lkjv9ZZjmB13HIX/27Xrj738/KTu1ZGNICbgECTsoc55TTuxG2z/aDGzzX4jgSbfW RO/VkiFRO9nsGstJO3Je6JJQzqJtrUc7RDox5ayuOkt89rggigvR3px+9+vp17/Zg+gZ 6oqQ== 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=gsL9bQ0y9pX/2lyTMYaTOUIKY6XWDRYJxwuWOVCpsyw=; fh=VaZeVgaFcx8SErmQ+YqQVGFejd+RdeFdtBRNX8S3TDk=; b=EHb73wKjJAUN5kTi/MDy5i2U11TFBfbNPRq1NzKrjEGLOoZQetMrZcxD74q/apKDZR 3zJvIkTeRQa0rOwaL/X+DSW5ckbpNjUhj1WiVcKveOVFWDLcynwrUNaiTPPgngUvEdUO hs41iB+T1h5xz7iCiYuVPPKmpUZosdhyFZll2FC5RCuZTOLtVcohdF5j4aZXCVRacGHl AZ+hyE2hUfZlfwuZX5zv/7e6A76sl2F6aqYsNhsQet45fALMv7oq4FXRN9E6mW0ozx2O 15wVocPFr6j6unhfz3GbVPHo2a67khff1rmHEdxyXm8MAUOqhexb3tGpc9IZ1czLlIfm S0qg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RiHK+ZQQ; 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-183479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183479-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf364ff1si2437950485a.614.2024.05.20.01.10.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 01:10:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RiHK+ZQQ; 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-183479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183479-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 49EDF1C20FA4 for ; Mon, 20 May 2024 08:10:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1640F1C2A5; Mon, 20 May 2024 08:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RiHK+ZQQ" Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 99C241BC3F for ; Mon, 20 May 2024 08:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716192598; cv=none; b=uVi4TM8jyNBCq3qjNpQe3CA0tQx2sNC93pRH6Xf9XJL05XbboUvRHPPUr9EtZje9qRcZhy414PBCgpKnTg7NAUPR3z9FVXNmSG6IEfnXqgvohVIR9eh2fPvsEZFtfAtCENjulKCgsvqdmWpAQAsCa6I8VNwsbFU2DIFWTYuiwU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716192598; c=relaxed/simple; bh=z8NthXkMFgdIbl0krCEF+Y+L/RbyZV7sLRHmjvGb+Zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tL94qQW7hZfhnsACs2B7PhLFtU4mPqIGNoSit+gOLRDJ533jGaXsVt719LoPclEUWlX/xxynth+XwQVxzOted3lldGGsrL4QboJF+No7Wu2+YQDlycsjf1IKieEFASsCpK3Y8zQXon/F5/yhOp2PWiwXcKaufQftTJh4dA1oPc0= 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=RiHK+ZQQ; arc=none smtp.client-ip=209.85.221.45 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-wr1-f45.google.com with SMTP id ffacd0b85a97d-354c5b7fafaso812946f8f.3 for ; Mon, 20 May 2024 01:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716192594; x=1716797394; 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=gsL9bQ0y9pX/2lyTMYaTOUIKY6XWDRYJxwuWOVCpsyw=; b=RiHK+ZQQiygHT9xW9FGf+q90GHAb1qdiO/fYScSWskCPIRSrdelpaXijnZFQC0oE7g 8e9HB352o6jFDMkcGyMr/+XtepLixlJ002GyltiLwhbARWu4wrgtMpTyQ2SC4pSAgcLt r45OT9tLzE+r71w/nq9WKC3bOv2KehfF0VINxevepu/Oktq2092/VSQZeSDDPPqUZ0zz 28mH/QmL3tc9k69RRRfaqb5gK9aeaKKQiD0E7MmyyzJwHUv4I4rq9664/ZcUtGjRyRJ6 k/Vlq5CclgKkcZrLhQBKlFr3qiwL5fBjxBRhCYJ/mo72DNpOSPE51gXajkbwcpCeuTPd AjTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716192594; x=1716797394; 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=gsL9bQ0y9pX/2lyTMYaTOUIKY6XWDRYJxwuWOVCpsyw=; b=giw3av/U6PbZxPGh71SdBEziITf17XQfxsSdE4gtgwKbXreKI0P3q2QyMwciioUSyO GAJeGjWOdUF65eRDDuv3UsK7BOEfwiFTQtXwECxHtKSgxecuSZ3lY3TcDEYHqkh8CDCi lwBkuHb8O+wKXeCBDj5OPAW4HoaYVx8eyT1wNI4nNgvlL1hJbNyXfiqGrejby2954c7r 8pgpgq5UvJfDiwtNdrEtql2uOn3W5s+ct91DXT/wxwvp7rVKm3no3bNaIRHfFVEjYTJ+ AmCT2ehGppFhSJCBvpCQuohFszGaQK1fnhlaaeIpUmQMxRhOwsPDXCZxPmA2SPskrlYr +78A== X-Gm-Message-State: AOJu0YwlOz1GUSSbPElOB6PvkqfVNleqtOqz1J3LmfR/jM8e1cUqQlXK jsumwrMjlXYDca+KZ17UedM9x6/OOlHY2VvmFUij1gu0mv0j3qIDEyzwA265 X-Received: by 2002:a05:6000:114c:b0:34d:b549:9465 with SMTP id ffacd0b85a97d-3504a737635mr20536526f8f.32.1716192594289; Mon, 20 May 2024 01:09:54 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3518d817ee2sm24784776f8f.2.2024.05.20.01.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 01:09:53 -0700 (PDT) From: Uros Bizjak To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Uros Bizjak , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH 2/2] x86/percpu: Move some percpu accessors around to reduce ifdeffery Date: Mon, 20 May 2024 10:09:25 +0200 Message-ID: <20240520080951.121049-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240520080951.121049-1-ubizjak@gmail.com> References: <20240520080951.121049-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 Move some percpu accessors around, mainly to reduce ifdeffery and improve readabilty by following dependencies between accessors. 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 | 40 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 39762fcfe328..0f0d8973f8df 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -445,17 +445,6 @@ do { \ #define this_cpu_try_cmpxchg128(pcp, ovalp, nval) percpu_try_cmpxchg128_op(16, volatile, pcp, ovalp, nval) #endif -/* - * this_cpu_read() makes gcc load the percpu variable every time it is - * accessed while this_cpu_read_stable() allows the value to be cached. - * this_cpu_read_stable() is more efficient and can be used if its value - * is guaranteed to be valid across cpus. The current users include - * pcpu_hot.current_task and pcpu_hot.top_of_stack, both of which are - * actually per-thread variables implemented as per-CPU variables and - * thus stable for the duration of the respective task. - */ -#define this_cpu_read_stable(pcp) __pcpu_size_call_return(this_cpu_read_stable_, pcp) - #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) @@ -470,16 +459,6 @@ do { \ #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(8, , pcp) -#define raw_cpu_write_8(pcp, val) __raw_cpu_write(8, , 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_const(pcp) - #define this_cpu_read_stable_1(pcp) __raw_cpu_read_stable(1, pcp) #define this_cpu_read_stable_2(pcp) __raw_cpu_read_stable(2, pcp) #define this_cpu_read_stable_4(pcp) __raw_cpu_read_stable(4, pcp) @@ -535,6 +514,12 @@ do { \ * 32 bit must fall back to generic operations. */ #ifdef CONFIG_X86_64 +#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(8, volatile, pcp) +#define this_cpu_write_8(pcp, val) __raw_cpu_write(8, volatile, pcp, val) + #define this_cpu_read_stable_8(pcp) __raw_cpu_read_stable(8, pcp) #define raw_cpu_add_8(pcp, val) percpu_add_op(8, , (pcp), val) @@ -561,6 +546,19 @@ do { \ #define raw_cpu_read_long(pcp) raw_cpu_read_4(pcp) #endif +#define this_cpu_read_const(pcp) __raw_cpu_read_const(pcp) + +/* + * this_cpu_read() makes gcc load the percpu variable every time it is + * accessed while this_cpu_read_stable() allows the value to be cached. + * this_cpu_read_stable() is more efficient and can be used if its value + * is guaranteed to be valid across cpus. The current users include + * pcpu_hot.current_task and pcpu_hot.top_of_stack, both of which are + * actually per-thread variables implemented as per-CPU variables and + * thus stable for the duration of the respective task. + */ +#define this_cpu_read_stable(pcp) __pcpu_size_call_return(this_cpu_read_stable_, pcp) + #define x86_this_cpu_constant_test_bit(_nr, _var) \ ({ \ unsigned long __percpu *addr__ = \ -- 2.45.1