From nobody Tue Apr 7 14:56:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9F84ECAAA3 for ; Fri, 26 Aug 2022 20:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245014AbiHZUDk (ORCPT ); Fri, 26 Aug 2022 16:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236637AbiHZUDh (ORCPT ); Fri, 26 Aug 2022 16:03:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66118E97F1 for ; Fri, 26 Aug 2022 13:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661544213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGiL/wFCui2ekwiPy88y1EJnxLA/VbwmHPhh3BhqAuQ=; b=QArAvcFykrTmz0cxb2VKRjzhBaNbKASljr4jvaMm/eTeCzlgnJyutjIkzT26bFPvjKtDir wBoluhPXAbETqIuOAxqHQQQBsJLV+1FMIvoWXelgbCw3j9N8ql807u4zJsB6NhIHMvu9wq z8aeaTrcVBE+0ak7A2qWpFltaQVA1b0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-370-ZPeGTIVKOLmpXAjMEkzZzA-1; Fri, 26 Aug 2022 16:03:30 -0400 X-MC-Unique: ZPeGTIVKOLmpXAjMEkzZzA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 169A3280EA3B; Fri, 26 Aug 2022 20:03:30 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E717C2166B26; Fri, 26 Aug 2022 20:03:29 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 27QK3TsN007661; Fri, 26 Aug 2022 16:03:29 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 27QK3SCr007657; Fri, 26 Aug 2022 16:03:28 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Fri, 26 Aug 2022 16:03:28 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Geert Uytterhoeven , Brian Cain , linux-hexagon@vger.kernel.org cc: Linus Torvalds , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Linux Kernel Mailing List , Linux-Arch Subject: [PATCH] provide arch_test_bit_acquire for architectures that define test_bit In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: TEXT/PLAIN; charset="utf-8" On Fri, 26 Aug 2022, Geert Uytterhoeven wrote: > Hi Mikulas, >=20 > noreply@ellerman.id.au reports lots of build failures on m68k: >=20 > include/asm-generic/bitops/non-instrumented-non-atomic.h:15:33: > error: implicit declaration of function 'arch_test_bit_acquire'; did > you mean '_test_bit_acquire'? [-Werror=3Dimplicit-function-declaration] >=20 > which I've bisected to this commit. >=20 > http://kisskb.ellerman.id.au/kisskb/head/3e5c673f0d75bc22b3c26eade87e4db4= f374cd34 Does this patch fix it? It is untested. I'm not sure about the hexagon architecture, it is presumably in-order so=20 that test_bit and test_bit_acquire are equivalent, but I am not sure about=20 that - I'm adding hexagon maintainer to the recipient field. Mikulas provide arch_test_bit_acquire for architectures that define test_bit Some architectures define their own arch_test_bit and they also need arch_test_bit_acquire, otherwise they won't compile. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org Fixes: 8238b4579866 ("wait_on_bit: add an acquire memory barrier") --- arch/alpha/include/asm/bitops.h | 7 +++++++ arch/hexagon/include/asm/bitops.h | 15 +++++++++++++++ arch/ia64/include/asm/bitops.h | 7 +++++++ arch/m68k/include/asm/bitops.h | 7 +++++++ arch/s390/include/asm/bitops.h | 7 +++++++ 5 files changed, 43 insertions(+) Index: linux-2.6/arch/m68k/include/asm/bitops.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/arch/m68k/include/asm/bitops.h +++ linux-2.6/arch/m68k/include/asm/bitops.h @@ -163,6 +163,13 @@ arch_test_bit(unsigned long nr, const vo return (addr[nr >> 5] & (1UL << (nr & 31))) !=3D 0; } =20 +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p =3D ((unsigned long *)addr) + BIT_WORD(nr); + return 1UL & (smp_load_acquire(p) >> (nr & (BITS_PER_LONG-1))); +} + static inline int bset_reg_test_and_set_bit(int nr, volatile unsigned long *vaddr) { Index: linux-2.6/arch/alpha/include/asm/bitops.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/arch/alpha/include/asm/bitops.h +++ linux-2.6/arch/alpha/include/asm/bitops.h @@ -289,6 +289,13 @@ arch_test_bit(unsigned long nr, const vo return (1UL & (((const int *) addr)[nr >> 5] >> (nr & 31))) !=3D 0UL; } =20 +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p =3D ((unsigned long *)addr) + BIT_WORD(nr); + return 1UL & (smp_load_acquire(p) >> (nr & (BITS_PER_LONG-1))); +} + /* * ffz =3D Find First Zero in word. Undefined if no zero exists, * so code should check against ~0UL first.. Index: linux-2.6/arch/hexagon/include/asm/bitops.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/arch/hexagon/include/asm/bitops.h +++ linux-2.6/arch/hexagon/include/asm/bitops.h @@ -179,6 +179,21 @@ arch_test_bit(unsigned long nr, const vo return retval; } =20 +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + int retval; + + asm volatile( + "{P0 =3D tstbit(%1,%2); if (P0.new) %0 =3D #1; if (!P0.new) %0 =3D #0;}\n" + : "=3D&r" (retval) + : "r" (addr[BIT_WORD(nr)]), "r" (nr % BITS_PER_LONG) + : "p0", "memory" + ); + + return retval; +} + /* * ffz - find first zero in word. * @word: The word to search Index: linux-2.6/arch/ia64/include/asm/bitops.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/arch/ia64/include/asm/bitops.h +++ linux-2.6/arch/ia64/include/asm/bitops.h @@ -337,6 +337,13 @@ arch_test_bit(unsigned long nr, const vo return 1 & (((const volatile __u32 *) addr)[nr >> 5] >> (nr & 31)); } =20 +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p =3D ((unsigned long *)addr) + BIT_WORD(nr); + return 1UL & (smp_load_acquire(p) >> (nr & (BITS_PER_LONG-1))); +} + /** * ffz - find the first zero bit in a long word * @x: The long word to find the bit in Index: linux-2.6/arch/s390/include/asm/bitops.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/arch/s390/include/asm/bitops.h +++ linux-2.6/arch/s390/include/asm/bitops.h @@ -185,6 +185,13 @@ arch_test_bit(unsigned long nr, const vo return *p & mask; } =20 +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p =3D ((unsigned long *)addr) + BIT_WORD(nr); + return 1UL & (smp_load_acquire(p) >> (nr & (BITS_PER_LONG-1))); +} + static inline bool arch_test_and_set_bit_lock(unsigned long nr, volatile unsigned long *ptr) {