Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4365239imu; Fri, 30 Nov 2018 16:04:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/USql/f2NwfVcBvDxBnA4oaxFiFy3uX6jpiwBkVKs/ZdVLIfYkjYJM4AGV7fTETDJ/Z9GNu X-Received: by 2002:a62:7dcb:: with SMTP id y194mr7596417pfc.113.1543622647460; Fri, 30 Nov 2018 16:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543622647; cv=none; d=google.com; s=arc-20160816; b=wI7BQlhU+d1COdQoB8CJ+H2gIQCOmJ/SYji2H7fMNWJGVs0euPe/4BilE9ckXNsY6R kphsyRJcdKNEoKRJ0mfhefPnzP6Xne6EWhpPpksF9mJqr9d53m6sip1hIvZBGjF1jhPJ kbvtW0stA5nMdvnIKbXiMOTAOt9oaAQlTGiYWGXUZzyrIzLnq3Gue8TM3dNZRyAHf0Xz CbBYvc37vQiUoE62PsVykl+S9GxvIce9RfjPOwnsWJsURo0kOdvEgMNpvBB4NOkuuw8/ xOFYv74wpzTSefFbS/vqwxaDHb9IsTBFV6M6W5Oj7LKOMS1euGZirGOy1t60tA41EzXB YseQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=OLSeUXZWPiLpVNgtUryyQYdNnf4Rl6/UQHX0BL1gdBE=; b=mmSdUAH6+HmFB3fE81uQeIWNgnEFMWiQ9Pf0HcG9gjHS7ZW/a1+loqroLZOBTt7ZhU bU3G9iT8nsrSeG1d6qBftoLimOUUtVpj8oveZNxdF+9UTfiMWMl4Ud41ZJsHy446CCXf T8LsbpTJUo5dA1ppjhkFgrNOIL5/03uTcv3vPoAN+hHywYkdgbkh153WsDUGraiglALK B5Zp1qiFi4laXKg9qHhl8XkjjrKSnzPPzZOPlBl2czIYihLpLRMvWtq3biJV0LFq9fiS l9VQY/A1Dvprns9N8wl+7hmPd5YL60+KRYOottiUwg1D2NjZCD6OPbsipYgqcKQbxosg MIMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=qex5YzYa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si7071478plc.320.2018.11.30.16.03.53; Fri, 30 Nov 2018 16:04:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=qex5YzYa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbeLALNS (ORCPT + 99 others); Sat, 1 Dec 2018 06:13:18 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39542 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725749AbeLALNS (ORCPT ); Sat, 1 Dec 2018 06:13:18 -0500 Received: by mail-ed1-f67.google.com with SMTP id b14so6200051edt.6 for ; Fri, 30 Nov 2018 16:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id; bh=OLSeUXZWPiLpVNgtUryyQYdNnf4Rl6/UQHX0BL1gdBE=; b=qex5YzYaGMRrHTasV9FB5+MkLHaiBmJsFpacltp2AgyaGW7Ji1RnsyPTOcOy6EdjOm F2YCayAOE8NTRxvDSSpPe5cAAjwwjWEuG1oyKEBnnNstDUb1iltDGiTVl9svElLeBRh/ xGonPs4lfNOD8cJumUXNnSlaeJEJ95/jWYbkE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OLSeUXZWPiLpVNgtUryyQYdNnf4Rl6/UQHX0BL1gdBE=; b=LidEjAiChWXYr+IbV9I6Hv6HuOPW+W3i4okp+FPngENCyLrDjJZJ3Z6BEFKPlK9HLc sBFhpzMuZiyTQ7tq4eyUhMvjouKc+xMvi3Mp83nekD6SQkWYRLhNUlZ01Oe9oXq4Ey80 LvMA0hGAsZ/Ndiau5NhnK65MStMNTQpBRTfto7cHkSfedzFYUGiokkz4bh1qqit0BVaZ FbUbLzkZcxVL5XQubSQq7cPl9Yba0Lb1fl7K8o/JjEiyZXGpi7QqKAj5z4l+ou0MNZEb zwYP7FS5vUIe0lKAL/01SdijNhNq4r/Y84iqdZWTZPm19ClyBn7JTQjY6eqlrR88w5Yx dyPA== X-Gm-Message-State: AA+aEWa/bzLLQ7BnCbcuJ+9x4TgZ1CJEqwt4qcB5a2/nYNye2h/3XK2b WP4JIar9dBpqkqCYiQFeedEfFji83RMOKw== X-Received: by 2002:a50:b2e1:: with SMTP id p88mr6719797edd.254.1543622532505; Fri, 30 Nov 2018 16:02:12 -0800 (PST) Received: from localhost.localdomain (dynamic-2a00-1028-8386-da8a-eacb-c188-78b9-634c.ipv6.broadband.iol.cz. [2a00:1028:8386:da8a:eacb:c188:78b9:634c]) by smtp.gmail.com with ESMTPSA id k32sm1764304edb.42.2018.11.30.16.02.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 16:02:11 -0800 (PST) From: Andrea Parri To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Andrea Parri , Palmer Dabbelt , Albert Ou , Will Deacon , Peter Zijlstra , Boqun Feng Subject: [PATCH] riscv, atomic: Add #define's for the atomic_{cmp,}xchg_*() variants Date: Sat, 1 Dec 2018 01:01:56 +0100 Message-Id: <20181201000156.5366-1-andrea.parri@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an architecture does not define the atomic_{cmp,}xchg_*() variants, the generic implementation defaults them to the fully-ordered version. riscv's had its own variants since "the beginning", but it never told (#define-d these for) the generic implementation: it is time to do so. Signed-off-by: Andrea Parri Cc: Palmer Dabbelt Cc: Albert Ou Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng --- TBH, the delay was not intentional: I've just become aware of it while working on moving riscv over to queued rwlocks. There's currently one callsite for the non-fully-ordered variants mentioned above for riscv: for atomic_cmpxchg_acquire() in kernel/sched/rt.c:rto_start_trylock(), [before] 51a: 100726af lr.w a3,(a4) 51e: 00069763 bnez a3,52c <.L17> 522: 1af7262f sc.w.rl a2,a5,(a4) 526: fa75 bnez a2,51a <.L1> 528: 0330000f fence rw,rw [after] 51a: 100726af lr.w a3,(a4) 51e: 00069763 bnez a3,52c <.L17> 522: 18f7262f sc.w a2,a5,(a4) 526: fa75 bnez a2,51a <.L1> 528: 0230000f fence r,rw --- arch/riscv/include/asm/atomic.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/riscv/include/asm/atomic.h b/arch/riscv/include/asm/atomic.h index c452359c9cb8a..93826771b616a 100644 --- a/arch/riscv/include/asm/atomic.h +++ b/arch/riscv/include/asm/atomic.h @@ -303,6 +303,15 @@ c_t atomic##prefix##_cmpxchg(atomic##prefix##_t *v, c_t o, c_t n) \ ATOMIC_OPS() +#define atomic_xchg_relaxed atomic_xchg_relaxed +#define atomic_xchg_acquire atomic_xchg_acquire +#define atomic_xchg_release atomic_xchg_release +#define atomic_xchg atomic_xchg +#define atomic_cmpxchg_relaxed atomic_cmpxchg_relaxed +#define atomic_cmpxchg_acquire atomic_cmpxchg_acquire +#define atomic_cmpxchg_release atomic_cmpxchg_release +#define atomic_cmpxchg atomic_cmpxchg + #undef ATOMIC_OPS #undef ATOMIC_OP -- 2.17.1