Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1875207lqe; Tue, 9 Apr 2024 03:07:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbfKNYIIrGr3tURHIA8tL3h4qoROay/M7uedMhIE6uh+1zXMQj5sBnqgfn3pWB4rJgeSLGVQS6Pr2wnUOIR38MiPbgQ/zbVHYpivFvyw== X-Google-Smtp-Source: AGHT+IEwB52hP2yf7xNMSHYhPIwF+0h4kXRZaZ+ue2wI9nWGcIdAX15rzJ5Y9lSeloEDtBrQsrQq X-Received: by 2002:a05:6a20:96ce:b0:1a7:1b6e:4d4 with SMTP id hq14-20020a056a2096ce00b001a71b6e04d4mr8925544pzc.23.1712657260410; Tue, 09 Apr 2024 03:07:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712657260; cv=pass; d=google.com; s=arc-20160816; b=WVenR8+z7LBgNFY5VmBLPE9D06+NPKfoLbUhlaX90kKKxj/BhC8JefGzQL0weOjPEI dFqLW3QNdUdFYwaNL+QxznvK5HITT/1qztofcMA2NMrWeSzOkvM208T/oPzXeDymUW81 IUPvMG5IOvvqzW3ZfMH4x4WhcxZmXLg/LRiOpXU7ofF0gT981HtGals04q7u5GOjAoL2 wJHd54UmxU5/en3IG0GmqQ2q9D+WZVaYswRSTo4znxRfViVqmQb3Df7IEFmdNJ1Llu0e aNTTP4x2k8uA6/ucYtxoZtiWySWT88UZbkSj8p6CKxoX4Fg5QR7iGPDr4Q7bo+rZifxM VYIg== 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=lyHz56u/iO9/FgsI4q0cP6V/rorpyyesh7+7+zlmKI8=; fh=HnMNcscVuqsZTpv9GJBSwWooHp89h+kfMxYoKWjiJWk=; b=gy7jdP0gSXLQz6CN6azbNwGienSMXIz3FhpZk37ZA5AUTH6hHlmdfG0dkC4FB9Q4lc WVARsaUhGPrcQcAmEayR+AXf0s90jE8eb5w5eWbFHrJHcmoDNlsBbmEOalFYjBUNHINz y43U/ON/byVU0r06xtM2E38kl/6N8/3jT3iaQJgVoEQXEHe8MuFa6zvguChGWuC69RQH WX+dgokkhe8ypLMrGXtNMOWh8ZkcZvKRAe1F5kPuRmHTHSb9mG0SXNfQziH7PIuOwG48 jWFhAxImfeYAG3MJc8KrivU6Fi1DDS58RaBGK82BF3vBnyWVZTKUgyfp3CsPD++0eqBV jCyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bC6p1iHW; 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-136628-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136628-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. [139.178.88.99]) by mx.google.com with ESMTPS id x22-20020a1709027c1600b001e43ce0be9fsi3240372pll.359.2024.04.09.03.07.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 03:07:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136628-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bC6p1iHW; 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-136628-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136628-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 EC7752869A8 for ; Tue, 9 Apr 2024 10:06:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0805084A56; Tue, 9 Apr 2024 10:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bC6p1iHW" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 6D578129A7B for ; Tue, 9 Apr 2024 10:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712657120; cv=none; b=o9I+C0NJg37FDxDIrdqJvkoIlfeO/wh7JLI47si4IF2Ewt70WUYi9ezUudc5HUNjmdOTvrTdPkgY+tAB/lzcI4Oel7y/OEUFBoeennmk+fAduH5/7IqC9/twx/71mWDL5YH33Pvl9CPSD0b++2IKLEwVeo2b5XZLeNQaAxo6Y9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712657120; c=relaxed/simple; bh=+IJA9+/LkDO3Qh/z4ZzTDQ69ze3J+3wDzxu13Sj1clQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QykGzBAqdV6cYzvbgGolW358DBpdUjVzGLCj7HgpMuVSbfBXYLd4+TqdhAH4kAtcwSFF6OKa1eQoHHAtbbWB04GU8akjycUZe29D5MwcJgtrKGYK1CuSbr9waf+DA9Yqhw0bWysOBQEJRAFgmNdtNkN2Z1zCF0CK6dzoRM67UX8= 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=bC6p1iHW; arc=none smtp.client-ip=209.85.218.43 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-ej1-f43.google.com with SMTP id a640c23a62f3a-a5200202c1bso26184666b.0 for ; Tue, 09 Apr 2024 03:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712657117; x=1713261917; 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=lyHz56u/iO9/FgsI4q0cP6V/rorpyyesh7+7+zlmKI8=; b=bC6p1iHW8rZgqBzJSrEDMfsBA8aTO0wbFgbYcGVyKUpUB4JNc/tKHr2S8OdXpgabDz 2DMYFlMzl25nixcs6I64S795bRhd5dhCO2cuYQVQXKHuGN6ZDSNrdez3VQf+PXqcTzpI r2iF9EzOAMSHbUB61JpiLH48+Fn/ee0pp34JuSEp8NipWxg7YS/N60ZWLSvvFQVu+vVE GUYszspOjp9Ar/f0j4pQV9gQdOtcFhX7zLWuDdUljn/fQA3VdkgghI6lwKsIIn6phpiG 8PijcE2aRcLEjmxGl4wA2l5LtSlMrEPBHDY0Wk5WcLKVkoajljBHjb87Qwt4NNLHx0Ep 5x0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712657117; x=1713261917; 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=lyHz56u/iO9/FgsI4q0cP6V/rorpyyesh7+7+zlmKI8=; b=qAxiTrTRMziYMLl4vF6x9+3ftV7pTJ5FP/pqSNPX6Cpj5RQgLMPbwXHr49tf4UMQWD WCpB+NUOrh3FcSXZtR+SYx4dXeBljV9TRoTcLqfYGRkp0etzto/2+GlRSVLbGyqKiqbs xGKJn1biRgHedCUzWW7+0jvtKi28NbAoLQhREyHVwoiXBnUMcFY+3XM+q4OMgVBZ2ayx VrdfJBEA31KMh+jOooArfUUCsn17shSNfw6/T+avI+UsE31ZSDZRviZWG49udNL9OabD 3VhHdK8kglUfjwzAAMa9vjqoCfin7J+RuhCjMat5fbD28M8FG3tv9FPXt5mxA/3Tf9Km Z/9w== X-Forwarded-Encrypted: i=1; AJvYcCWefhON1LfgyPf+vo98S3HXbwUUo45X0BK99CIL4LcBolKAIeE/YqgLI9wGkWcVVsj06HEB1dlEmEub51WG+ZKWqpdKYcHreK12SoKc X-Gm-Message-State: AOJu0YwGJ6efaJq3NQ0f+qaO4uXrdL6WdlOvyKnyl1xtWeZk8jh+4LVI KR7uxmJo6rQshTxz7SGLTVwOGG9yRioD8PLWtLrh/V9yOJNH9iq4 X-Received: by 2002:a17:907:7ea4:b0:a4e:5676:417d with SMTP id qb36-20020a1709077ea400b00a4e5676417dmr12020143ejc.58.1712657116669; Tue, 09 Apr 2024 03:05:16 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id qs1-20020a170906458100b00a4e6626ae21sm5496681ejc.0.2024.04.09.03.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 03:05:15 -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" , Peter Zijlstra Subject: [PATCH 6/6] locking/atomic/x86: Reorder a couple of arch_atomic64 functions Date: Tue, 9 Apr 2024 12:03:57 +0200 Message-ID: <20240409100503.274629-7-ubizjak@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409100503.274629-1-ubizjak@gmail.com> References: <20240409100503.274629-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 Reorder a couple of arch_atomic64 functions in arch/x86/include/asm/atomic64_32.h to better match their sequence of declarations between x86_32 and x86_64. No functional changes intended. Signed-off-by: Uros Bizjak Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Peter Zijlstra --- arch/x86/include/asm/atomic64_32.h | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h index 862448db1207..3864d82a9339 100644 --- a/arch/x86/include/asm/atomic64_32.h +++ b/arch/x86/include/asm/atomic64_32.h @@ -12,7 +12,7 @@ typedef struct { s64 __aligned(8) counter; } atomic64_t; -#define ATOMIC64_INIT(val) { (val) } +#define ATOMIC64_INIT(i) { (i) } #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...) #ifndef ATOMIC64_EXPORT @@ -61,17 +61,21 @@ ATOMIC64_DECL(add_unless); #undef __ATOMIC64_DECL #undef ATOMIC64_EXPORT -static __always_inline s64 arch_atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new) +static __always_inline s64 arch_atomic64_read(const atomic64_t *v) { - return arch_cmpxchg64(&v->counter, old, new); + s64 r; + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory"); + return r; } -#define arch_atomic64_cmpxchg arch_atomic64_cmpxchg -static __always_inline bool arch_atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new) +static __always_inline void arch_atomic64_set(atomic64_t *v, s64 i) { - return arch_try_cmpxchg64(&v->counter, old, new); + unsigned high = (unsigned)(i >> 32); + unsigned low = (unsigned)i; + alternative_atomic64(set, /* no output */, + "S" (v), "b" (low), "c" (high) + : "eax", "edx", "memory"); } -#define arch_atomic64_try_cmpxchg arch_atomic64_try_cmpxchg static __always_inline s64 arch_atomic64_xchg(atomic64_t *v, s64 n) { @@ -85,22 +89,6 @@ static __always_inline s64 arch_atomic64_xchg(atomic64_t *v, s64 n) } #define arch_atomic64_xchg arch_atomic64_xchg -static __always_inline void arch_atomic64_set(atomic64_t *v, s64 i) -{ - unsigned high = (unsigned)(i >> 32); - unsigned low = (unsigned)i; - alternative_atomic64(set, /* no output */, - "S" (v), "b" (low), "c" (high) - : "eax", "edx", "memory"); -} - -static __always_inline s64 arch_atomic64_read(const atomic64_t *v) -{ - s64 r; - alternative_atomic64(read, "=&A" (r), "c" (v) : "memory"); - return r; -} - static __always_inline s64 arch_atomic64_add_return(s64 i, atomic64_t *v) { alternative_atomic64(add_return, @@ -199,6 +187,18 @@ static __always_inline s64 arch_atomic64_dec_if_positive(atomic64_t *v) #undef alternative_atomic64 #undef __alternative_atomic64 +static __always_inline s64 arch_atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new) +{ + return arch_cmpxchg64(&v->counter, old, new); +} +#define arch_atomic64_cmpxchg arch_atomic64_cmpxchg + +static __always_inline bool arch_atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new) +{ + return arch_try_cmpxchg64(&v->counter, old, new); +} +#define arch_atomic64_try_cmpxchg arch_atomic64_try_cmpxchg + static __always_inline s64 arch_atomic64_fetch_add(s64 i, atomic64_t *v) { s64 val = __READ_ONCE(v->counter); -- 2.44.0