Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp758940rwe; Fri, 26 Aug 2022 14:01:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR74ai4mDmnwtZtqRUbX6ZlvfqO06OXHwLuaPUo0J2wBhlKj6tdvaafFe/g4sWGeiI3v19kk X-Received: by 2002:a17:90a:2b0f:b0:1fa:d73f:ce92 with SMTP id x15-20020a17090a2b0f00b001fad73fce92mr6205086pjc.60.1661547681533; Fri, 26 Aug 2022 14:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661547681; cv=none; d=google.com; s=arc-20160816; b=Cav4Hgy2QQjHgIsByq5VkLYB90tKNts3rsJlsEZW+x+z2gP7mI3p9xSk3lA9OsmuMT ZFcrRHNbg6cUr1HBJC3WuY+i2vRYycclkHcLYLsbl30PNamr9/xq0Ux1PIbgSp2oVXeF wbKuJ5rN4twNJYKGyrBqPYyynvKlRgio1i9GAthjW+3k+GNBu7UClwhKSAcmZ6Ek3kwy qonCT2HrDEUZZm4aLpPuWMkJ4nsudPJ+yukfjcKpFTTZwNn6QAl5dPuXXHpAry7dI/YX Tu4kruzoKhtChoSyx6Zl4hOZLxoS9Ojy9jn8Dq29+g/kmY6j9oKmnpenKIKlAnk1R4lK zMZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=pGiL/wFCui2ekwiPy88y1EJnxLA/VbwmHPhh3BhqAuQ=; b=KSwyaKdxyoGAU2dF6nZKQrcoO3/3JrfPTyT5ekLV8w7FlpsVEv6z02u5rmW4ZgPgVY DN84nwCP9UYNh4TO6XaKGA2FcTomSLlHKrMqkH12K8kU4eEGzuk3MNhNnDP2k4kGSxjC KvUdGbpXAkVQHXQXBjDBbqawm/roVwQWhrYupjnmAAcA+iYmkugSN31mxw6zsFyQZfh4 TRaeQfewERnicANdEbbec09m9xkT7MTObfvAhX1p8O/Na5owiPSrGQ7muKucyFt8aCCC YJRY50PYtFPOnZJjd3eknxH/uLkXAPZhbJg5O1MAy5GV/onJlfnEBrjpd1YNCW+FjxeF DNpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QArAvcFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a635209000000b0041c335d3761si2455439pgb.363.2022.08.26.14.01.08; Fri, 26 Aug 2022 14:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QArAvcFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244134AbiHZUDj (ORCPT + 99 others); Fri, 26 Aug 2022 16:03:39 -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 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Aug 2022, Geert Uytterhoeven wrote: > Hi Mikulas, > > noreply@ellerman.id.au reports lots of build failures on m68k: > > 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=implicit-function-declaration] > > which I've bisected to this commit. > > http://kisskb.ellerman.id.au/kisskb/head/3e5c673f0d75bc22b3c26eade87e4db4f374cd34 Does this patch fix it? It is untested. I'm not sure about the hexagon architecture, it is presumably in-order so that test_bit and test_bit_acquire are equivalent, but I am not sure about 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 =================================================================== --- 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))) != 0; } +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p = ((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 =================================================================== --- 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))) != 0UL; } +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + return 1UL & (smp_load_acquire(p) >> (nr & (BITS_PER_LONG-1))); +} + /* * ffz = 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 =================================================================== --- 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; } +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + int retval; + + asm volatile( + "{P0 = tstbit(%1,%2); if (P0.new) %0 = #1; if (!P0.new) %0 = #0;}\n" + : "=&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 =================================================================== --- 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)); } +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p = ((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 =================================================================== --- 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; } +static __always_inline bool +arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) +{ + unsigned long *p = ((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) {