Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2488454imn; Tue, 2 Aug 2022 04:59:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR4BIEwt3MDm3tDhitlCdRsNf4svXnNv8Z/bir/5kNZZW7hjCd6mIoAkQAJt/OT3NytCIbNN X-Received: by 2002:a17:907:2714:b0:730:851d:66b1 with SMTP id w20-20020a170907271400b00730851d66b1mr7130369ejk.184.1659441567903; Tue, 02 Aug 2022 04:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659441567; cv=none; d=google.com; s=arc-20160816; b=v/CypQopu6jAox93gQsEyAJrazy7o+DpzV8rl9JjhOFv+rHqxSsI1CbPSA74w7/FF9 kazsu+Q9IJBEYdGmPV5p6J3FBDynuABAREb/49iOua1y1Mkwt64/CKhAB8kICGDz11hB Z+oHBf6/ixYHFsCDQ84Z4qXiGo2Gflhz8ghg+RGV7e8waMLXDXE1OrFFIiIRR+rhE2JG Fk3hJHkbYeZQ+iY9cpxThHiS7rRpeCXZIUJZSdpVAzIrKXeW/K38UvvFA8c1bOMfJURn KAY2iaBpFkktdTYdvf2louGb5cBECcEC8vo01fMCiBgy+nKRxcsDSQPWw4A85X89mhkW 8Scg== 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=aZR8bP/6vfFe2ZtFsHhxNrpc5QQ5iUzaeMIrD3s/QxI=; b=vgl7es0U6M9ea4hmUS2HXb+DcnDa5mdGCKx0ZkWIiPLuVYLO3PRc5bAehioLHHTsbV 3Q90B+/3FnN6aR8y1UVJ1XDW45TMk6dhC0vnZZusT/9RsADZUlM2Lyh3G242ZYD8tNiY HLWDjdVM6F+PzEq8zfIKeF7+JShDsBHqyoKiTGkJgu0FdmakaqhGJFWBeZcjNW7wF74J 5SuxSK24cXtOllctRNDxw3WkK1K3oYuhxMwnnwT4fiD5AJ1QzJ4xw7W+Bz+UcIdYN1ct oEUIHTYm44He1Tf731UB5xCvanA3hVDJkp+owbgkYhIDoQYtTjFfNjsj93Nvp2eXSy8r tx7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QJaryW1h; 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 he11-20020a1709073d8b00b0072ee57126e9si15496198ejc.166.2022.08.02.04.59.02; Tue, 02 Aug 2022 04:59:27 -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=QJaryW1h; 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 S236526AbiHBLi1 (ORCPT + 99 others); Tue, 2 Aug 2022 07:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236537AbiHBLi0 (ORCPT ); Tue, 2 Aug 2022 07:38:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A515459B3 for ; Tue, 2 Aug 2022 04:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659440302; 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=aZR8bP/6vfFe2ZtFsHhxNrpc5QQ5iUzaeMIrD3s/QxI=; b=QJaryW1hYusdqQVJDKC8V5f9lcgW/uTK1jUmvl+/QmSR+MD3H9b6AYreOI+OLR6b4P2tVz DmSDiApgkeuaTtZx1zWxyaujMDQnrELSxXX6VFWFXtnx6oYgl0M1R8la0IRS/d4/KW6Fk7 iaiKfC2YHfkYkUT0gfExeud935hPEmU= 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-43-KVXa-6jDOh-4-IuGat-U4A-1; Tue, 02 Aug 2022 07:38:19 -0400 X-MC-Unique: KVXa-6jDOh-4-IuGat-U4A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A08283C01DFF; Tue, 2 Aug 2022 11:38:18 +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 7870818EA8; Tue, 2 Aug 2022 11:38:18 +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 272BcI3l009514; Tue, 2 Aug 2022 07:38:18 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 272BcHWP009510; Tue, 2 Aug 2022 07:38:17 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 2 Aug 2022 07:38:17 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Will Deacon cc: Linus Torvalds , "Paul E. McKenney" , Ard Biesheuvel , Alexander Viro , Alan Stern , Andrea Parri , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Linux Kernel Mailing List , linux-arch , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v4 1/2] introduce test_bit_acquire and use it in wait_on_bit In-Reply-To: <20220802084015.GB26962@willie-the-truck> Message-ID: References: <20220801155421.GB26280@willie-the-truck> <20220802084015.GB26962@willie-the-truck> 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.79 on 10.11.54.5 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 Tue, 2 Aug 2022, Will Deacon wrote: > On Mon, Aug 01, 2022 at 12:12:47PM -0400, Mikulas Patocka wrote: > > On Mon, 1 Aug 2022, Will Deacon wrote: > > > On Mon, Aug 01, 2022 at 06:42:15AM -0400, Mikulas Patocka wrote: > > > > > > > Index: linux-2.6/arch/x86/include/asm/bitops.h > > > > =================================================================== > > > > --- linux-2.6.orig/arch/x86/include/asm/bitops.h 2022-08-01 12:27:43.000000000 +0200 > > > > +++ linux-2.6/arch/x86/include/asm/bitops.h 2022-08-01 12:27:43.000000000 +0200 > > > > @@ -203,8 +203,10 @@ arch_test_and_change_bit(long nr, volati > > > > > > > > static __always_inline bool constant_test_bit(long nr, const volatile unsigned long *addr) > > > > { > > > > - return ((1UL << (nr & (BITS_PER_LONG-1))) & > > > > + bool r = ((1UL << (nr & (BITS_PER_LONG-1))) & > > > > (addr[nr >> _BITOPS_LONG_SHIFT])) != 0; > > > > + barrier(); > > > > + return r; > > > > > > Hmm, I find it a bit weird to have a barrier() here given that 'addr' is > > > volatile and we don't need a barrier() like this in the definition of > > > READ_ONCE(), for example. > > > > gcc doesn't reorder two volatile accesses, but it can reorder non-volatile > > accesses around volatile accesses. > > > > The purpose of the compiler barrier is to make sure that the non-volatile > > accesses that follow test_bit are not reordered by the compiler before the > > volatile access to addr. > > If we need these accesses to be ordered reliably, then we need a CPU barrier > and that will additionally prevent the compiler reordering. So I still don't > think we need the barrier() here. This is x86-specific code. x86 has strong memory ordering, so we only care about compiler reordering. We could use smp_rmb() (or smp_load_acquire()) instead of barrier() here, but smp_rmb() and smp_load_acquire() on x86 is identical to barrier() anyway. Mikulas