Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp135727rdb; Mon, 18 Sep 2023 10:12:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzVTQqBxtfP45shsiDMvl/3V/zXKzBVX5uNPSEd27gV9HlvHTndib+HS2pIml4Xu/GBJs+ X-Received: by 2002:a05:6a20:428a:b0:13e:7439:1449 with SMTP id o10-20020a056a20428a00b0013e74391449mr14070151pzj.0.1695057157470; Mon, 18 Sep 2023 10:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695057157; cv=none; d=google.com; s=arc-20160816; b=jigYtSXxj/G4ZuR2LDoxAzlrcl+dV6Isf6d9IPWKwruaWivUkeqMuJ5LXghbdFx77x vwsc/BNa3zLRfBJP7A+khfjzAhTm856gUtg1WxawlIxCmqBZO4Nrcf+fAwP7Ygx9CUP6 SJ2wxp5zyB4lOi4++QhN8jRgzhtlPMqlQu2REPDoofuNrY5qDd2yI+wm0PxV+Bh5VHuF ChxAqi50WBDyPLP34wxlN8m4pf4SrxUwiLFvE6VpWloRrf5zQAct+mpgKvuCTpwuHgmE q3tg4+0UvjJMaxACspLz1OaghnB8JRjEIseBrHIX5k2t+0wplQIzIEzIDXrF1v/GQgMq Yelg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:from:content-language:references:cc :to:subject:user-agent:mime-version:date:message-id:dkim-signature :dkim-signature; bh=rhkr9x6k9BtEOlKlD/P8R8AriyQWvcoR190nrM7N960=; fh=LNtG58IjrPvm/sQKnpj/k7BeP9w0+ynU2+Mz4nDlzKA=; b=SDpdXnd3nOYNCuV0NG4/r1dCBHe6QFYoun+p/aFDpRh5N1I8vAuuP/wDKE/MIbaCdy sy4Z/9eEWgoVJ/Cf1FjoxLkFQ9/lqWeUY0/VMmRvAgG1/c56lu0BP1NCb5WQSwtCsA2a AQJOCYCNd+rzLRhf1frAffEotMNabj3qCpZfCAuKIYM0y5H30cKenxx+FnNAia8qeiZp MIQfQ88N9rR3jULLqysuMarJN8B3g+22JjPBR7CIhe3k18YHQcyT12qhN//G/B/jktoG QZ2qmTR/tWmIhEGQUtSyFvR1Al/xcpv/NtpjoVZwrWQRzzraiVR+5WIN7J77h6YHR97V NC1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=A6eDIFqG; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=Oppd2VHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i3-20020a63e903000000b00543c84bf588si8320682pgh.473.2023.09.18.10.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 10:12:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=A6eDIFqG; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=Oppd2VHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B816F81BECAE; Mon, 18 Sep 2023 09:31:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230024AbjIRQbH (ORCPT + 99 others); Mon, 18 Sep 2023 12:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjIRQa4 (ORCPT ); Mon, 18 Sep 2023 12:30:56 -0400 Received: from domac.alu.hr (domac.alu.unizg.hr [IPv6:2001:b68:2:2800::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8006321EBA; Mon, 18 Sep 2023 09:28:16 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 15E2B60186; Mon, 18 Sep 2023 18:28:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1695054495; bh=Sm0N3ynWqQ46F7faVkeKStgJuGy+OLIzp7da6H/9Zos=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=A6eDIFqGD/RANk157jMrthoNd5Vyl1ivTmeXy2HshUKuSUypams93vvaAjNzLV/D8 G0UaEjKoGFKpoPAGmQx3d8Rnpxe6lalMA0csme6TOS9vSEsVz3pnZS4G9eB1qgkq6/ oxjN4brhFuJsUPdeLksEqGBftC5Ja+jWnirPx10NCiTNprGar4Ltj6nLSmQ8IpVxtj MtYkUfOswHm8lR70M3cH6K6oKFJmzXZD+2YFzrV90hNPBY0WyFsWHImcrt30mM1udn 7RUSJwVo7lKLVmiu1tN2vxR/ji4JnXiSnW51fbowwn2Kjh/QxHIChin76ToGcIQgc2 BkWPz3MhPM4Nw== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cjdwUePntF3d; Mon, 18 Sep 2023 18:28:12 +0200 (CEST) Received: from [192.168.1.6] (78-1-184-14.adsl.net.t-com.hr [78.1.184.14]) by domac.alu.hr (Postfix) with ESMTPSA id 1A08560174; Mon, 18 Sep 2023 18:28:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1695054492; bh=Sm0N3ynWqQ46F7faVkeKStgJuGy+OLIzp7da6H/9Zos=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Oppd2VHMDc56Z1aRno3gGAY6Uj+TdGlzVDwspfD2eUTe1IYkC3WB9WSfETVTLs/vG urr5C1KB4sDSPj6xlulLU6Eb/v3eXCfN0a8KgpQyLxy2ZRpMWStAGS4ynNnU7ln3Y/ tG4c0NMOciPYs0nuf9DKUkWIyi6WP7mGW27JGNXxIB3evxBWbWC/9LI9T8oAOcYWgw uYH1yIm/M2l9QR1blJK+df8dBO1jiTj22PJhxaXX9udYMgM8u5BEpnf6A/PeyDSUbZ WWQ1owYvnDIJxMT3MXHA/QRcP+X7I/V0Al36lESp861x4KasuUHqmFUDS9DewUp1Gh 0kJRUomDL13/Q== Content-Type: multipart/mixed; boundary="------------SdM57NH5CFmGTcDmkBlkGKQN" Message-ID: Date: Mon, 18 Sep 2023 18:28:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v1 1/1] xarray: fix the data-race in xas_find_chunk() by using READ_ONCE() To: Jan Kara , Yury Norov Cc: Philipp Stanner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Matthew Wilcox , Chris Mason , Andrew Morton , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-mm@kvack.org References: <20230918044739.29782-1-mirsad.todorovac@alu.unizg.hr> <20230918094116.2mgquyxhnxcawxfu@quack3> <22ca3ad4-42ef-43bc-51d0-78aaf274977b@alu.unizg.hr> <20230918113840.h3mmnuyer44e5bc5@quack3> <20230918155403.ylhfdbscgw6yek6p@quack3> Content-Language: en-US From: Mirsad Todorovac In-Reply-To: <20230918155403.ylhfdbscgw6yek6p@quack3> X-Spam-Status: No, score=-2.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:31:28 -0700 (PDT) This is a multi-part message in MIME format. --------------SdM57NH5CFmGTcDmkBlkGKQN Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 9/18/23 17:54, Jan Kara wrote: > On Mon 18-09-23 07:59:03, Yury Norov wrote: >> On Mon, Sep 18, 2023 at 02:46:02PM +0200, Mirsad Todorovac wrote: >>> -------------------------------------------------------- >>> lib/find_bit.c | 33 +++++++++++++++++---------------- >>> 1 file changed, 17 insertions(+), 16 deletions(-) >>> >>> diff --git a/lib/find_bit.c b/lib/find_bit.c >>> index 32f99e9a670e..56244e4f744e 100644 >>> --- a/lib/find_bit.c >>> +++ b/lib/find_bit.c >>> @@ -18,6 +18,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> /* >>> * Common helper for find_bit() function family >>> @@ -98,7 +99,7 @@ out: \ >>> */ >>> unsigned long _find_first_bit(const unsigned long *addr, unsigned long size) >>> { >>> - return FIND_FIRST_BIT(addr[idx], /* nop */, size); >>> + return FIND_FIRST_BIT(READ_ONCE(addr[idx]), /* nop */, size); >>> } >>> EXPORT_SYMBOL(_find_first_bit); >>> #endif >> >> ... >> >> That doesn't look correct. READ_ONCE() implies that there's another >> thread modifying the bitmap concurrently. This is not the true for >> vast majority of bitmap API users, and I expect that forcing >> READ_ONCE() would affect performance for them. >> >> Bitmap functions, with a few rare exceptions like set_bit(), are not >> thread-safe and require users to perform locking/synchronization where >> needed. > > Well, for xarray the write side is synchronized with a spinlock but the read > side is not (only RCU protected). > >> If you really need READ_ONCE, I think it's better to implement a new >> flavor of the function(s) separately, like: >> find_first_bit_read_once() > > So yes, xarray really needs READ_ONCE(). And I don't think READ_ONCE() > imposes any real perfomance overhead in this particular case because for > any sane compiler the generated assembly with & without READ_ONCE() will be > exactly the same. For example I've checked disassembly of _find_next_bit() > using READ_ONCE(). The main loop is: > > 0xffffffff815a2b6d <+77>: inc %r8 > 0xffffffff815a2b70 <+80>: add $0x8,%rdx > 0xffffffff815a2b74 <+84>: mov %r8,%rcx > 0xffffffff815a2b77 <+87>: shl $0x6,%rcx > 0xffffffff815a2b7b <+91>: cmp %rcx,%rax > 0xffffffff815a2b7e <+94>: jbe 0xffffffff815a2b9b <_find_next_bit+123> > 0xffffffff815a2b80 <+96>: mov (%rdx),%rcx > 0xffffffff815a2b83 <+99>: test %rcx,%rcx > 0xffffffff815a2b86 <+102>: je 0xffffffff815a2b6d <_find_next_bit+77> > 0xffffffff815a2b88 <+104>: shl $0x6,%r8 > 0xffffffff815a2b8c <+108>: tzcnt %rcx,%rcx > > So you can see the value we work with is copied from the address (rdx) into > a register (rcx) and the test and __ffs() happens on a register value and > thus READ_ONCE() has no practical effect. It just prevents the compiler > from doing some stupid de-optimization. > > Honza If I may also add, centralised READ_ONCE() version had fixed a couple of hundred of the instances of KCSAN data-races in dmesg. _find_*_bit() functions and/or macros cause quite a number of KCSAN BUG warnings: 95 _find_first_and_bit (lib/find_bit.c:114 (discriminator 10)) 31 _find_first_zero_bit (lib/find_bit.c:125 (discriminator 10)) 173 _find_next_and_bit (lib/find_bit.c:171 (discriminator 2)) 655 _find_next_bit (lib/find_bit.c:133 (discriminator 2)) 5 _find_next_zero_bit Finding each one find_bit_*() function and replacing it with find_bit_*_read_once() could be time-consuming and challenging. However, I will do both versions so you could compare, if you'd like. Note, in the PoC version I have only implemented find_next_bit_read_once() ATM to see if this works. Regards, Mirsad --------------SdM57NH5CFmGTcDmkBlkGKQN Content-Type: text/x-patch; charset=UTF-8; name="find_bit_read_once.diff" Content-Disposition: attachment; filename="find_bit_read_once.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2luY2x1ZGUvbGludXgvZmluZC5oIGIvaW5jbHVkZS9saW51eC9maW5k LmgKaW5kZXggNWU0ZjM5ZWYyZTcyLi4yYjdmOWYyNGNmZmIgMTAwNjQ0Ci0tLSBhL2luY2x1 ZGUvbGludXgvZmluZC5oCisrKyBiL2luY2x1ZGUvbGludXgvZmluZC5oCkBAIC00MCw2ICs0 MCwzOCBAQCB1bnNpZ25lZCBsb25nIF9maW5kX25leHRfYml0X2xlKGNvbnN0IHVuc2lnbmVk IGxvbmcgKmFkZHIsIHVuc2lnbmVkCiAJCQkJbG9uZyBzaXplLCB1bnNpZ25lZCBsb25nIG9m ZnNldCk7CiAjZW5kaWYKIAordW5zaWduZWQgbG9uZyBfZmluZF9uZXh0X2JpdF9yZWFkX29u Y2UoY29uc3QgdW5zaWduZWQgbG9uZyAqYWRkcjEsIHVuc2lnbmVkIGxvbmcgbmJpdHMsCisJ CQkJdW5zaWduZWQgbG9uZyBzdGFydCk7Cit1bnNpZ25lZCBsb25nIF9maW5kX25leHRfYW5k X2JpdF9yZWFkX29uY2UoY29uc3QgdW5zaWduZWQgbG9uZyAqYWRkcjEsIGNvbnN0IHVuc2ln bmVkIGxvbmcgKmFkZHIyLAorCQkJCQl1bnNpZ25lZCBsb25nIG5iaXRzLCB1bnNpZ25lZCBs b25nIHN0YXJ0KTsKK3Vuc2lnbmVkIGxvbmcgX2ZpbmRfbmV4dF9hbmRub3RfYml0X3JlYWRf b25jZShjb25zdCB1bnNpZ25lZCBsb25nICphZGRyMSwgY29uc3QgdW5zaWduZWQgbG9uZyAq YWRkcjIsCisJCQkJCXVuc2lnbmVkIGxvbmcgbmJpdHMsIHVuc2lnbmVkIGxvbmcgc3RhcnQp OwordW5zaWduZWQgbG9uZyBfZmluZF9uZXh0X29yX2JpdF9yZWFkX29uY2UoY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l6ZSkKK3sKKwlyZXR1cm4gRklORF9GSVJTVF9CSVQoflJFQURfT05DRShhZGRyW2lkeF0p LCBzd2FiLCBzaXplKTsKK30KK0VYUE9SVF9TWU1CT0woX2ZpbmRfZmlyc3RfemVyb19iaXRf bGVfcmVhZF9vbmNlKTsKKworI2VuZGlmCisKKyNpZm5kZWYgZmluZF9uZXh0X3plcm9fYml0 X2xlX3JlYWRfb25jZQordW5zaWduZWQgbG9uZyBfZmluZF9uZXh0X3plcm9fYml0X2xlX3Jl YWRfb25jZShjb25zdCB1bnNpZ25lZCBsb25nICphZGRyLAorCQkJCQkgICAgICAgdW5zaWdu ZWQgbG9uZyBzaXplLCB1bnNpZ25lZCBsb25nIG9mZnNldCkKK3sKKwlyZXR1cm4gRklORF9O RVhUX0JJVCh+UkVBRF9PTkNFKGFkZHJbaWR4XSksIHN3YWIsIHNpemUsIG9mZnNldCk7Cit9 CitFWFBPUlRfU1lNQk9MKF9maW5kX25leHRfemVyb19iaXRfbGVfcmVhZF9vbmNlKTsKKyNl bmRpZgorCisjaWZuZGVmIGZpbmRfbmV4dF9iaXRfbGVfcmVhZF9vbmNlCit1bnNpZ25lZCBs b25nIF9maW5kX25leHRfYml0X2xlX3JlYWRfb25jZShjb25zdCB1bnNpZ25lZCBsb25nICph ZGRyLAorCQkJCQkgIHVuc2lnbmVkIGxvbmcgc2l6ZSwgdW5zaWduZWQgbG9uZyBvZmZzZXQp Cit7CisJcmV0dXJuIEZJTkRfTkVYVF9CSVQoUkVBRF9PTkNFKGFkZHJbaWR4XSksIHN3YWIs IHNpemUsIG9mZnNldCk7Cit9CitFWFBPUlRfU1lNQk9MKF9maW5kX25leHRfYml0X2xlX3Jl YWRfb25jZSk7CisKKyNlbmRpZgorCisjZW5kaWYgLyogX19CSUdfRU5ESUFOICovCg== --------------SdM57NH5CFmGTcDmkBlkGKQN--