Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp255720rdb; Mon, 18 Sep 2023 14:12:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEb7vivQMb0oaPVuC/PmaXm7MoOCdLhJEFAMJsMgUADsD6EyouzuAsQloOVVZNYqNpWxXG8 X-Received: by 2002:a05:6e02:1b04:b0:34f:663d:b9fe with SMTP id i4-20020a056e021b0400b0034f663db9femr14714069ilv.19.1695071524674; Mon, 18 Sep 2023 14:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695071524; cv=none; d=google.com; s=arc-20160816; b=KcdGpeGFUFu96hiWPExsaxCjXlxn18zw29vfNaHwYidwdlMrp/fD4yymBy45zDQdJn 305GpZc1OYJm8gS152oq062PumIDZSAq+pgYg29uNqOQrXZARMGycpxoAJFuTfLJCJDM 2yFtUHXO+4qIF8HHj4lzhYktRs8JB5arALskobb5A2mPEFAML09T2PiTbBlKZBwcWBFw 7l3MnaDJoqLjOohdkl2lkAX2bJ7UPRh1MFZ4cjP504tPDjwMiqPLyCfAkTWMzf6ihlyL Yn8waZfSMQA6NFtCb/9afP+1WVSNF5Wyyz/v5DkP07Ch0EzoHsNUMo/vX9I+DM3n2dmq JSxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=4CzilwYZQ4Jc72fuQtoAbSWLiLUf2pcHd4c41aRTXJU=; fh=NA9KulCzYvf+H7SATtmpooOq3KD41pD54UVockOFt1I=; b=l0EZmuqKgRIUvOKNWdPSn53/V4dmGyD8pWgs0djM+f2y0eWLTL17ug0xV/NN6T2Bcv ar3l0Bt1S4se8OBHRzk2ojcEC4eAFWQALLhLNswijmdoXhDRunmtlPdmQZgDkg2SU/bU bx7znsJUSEjkEAJN6A4jgM1o1q2pIvMqEPkbcXWBwm5ckYLZqNtDIJUKaxebZgDgPcGG pNtOHt1au8vkeLvUYO6FyPAEQhhxmgyn/be6rsV/wGVIyoXIupO0MtFcM3sfHST0lJOa S+Jt/lKvRh7Po26vM4l+DXUO5xQga4KwEiv+0yDQZi8XbHXJK8JMmIt/iy6jz3/H6JMY UgKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=gTXIPXVM; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b25-20020a630c19000000b00577549e67c8si8632543pgl.601.2023.09.18.14.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 14:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=gTXIPXVM; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BD1BE8040E8A; Mon, 18 Sep 2023 08:41:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229468AbjIRPlN (ORCPT + 99 others); Mon, 18 Sep 2023 11:41:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjIRPlM (ORCPT ); Mon, 18 Sep 2023 11:41:12 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C24CE9; Mon, 18 Sep 2023 08:37:32 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A4B751FF30; Mon, 18 Sep 2023 14:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1695046643; h=from:from:reply-to: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=4CzilwYZQ4Jc72fuQtoAbSWLiLUf2pcHd4c41aRTXJU=; b=gTXIPXVMhLb/LF0YpGzOEeYsjv3Lr4csi2hL+oimZIQeoP/z/KNsoN4Q+twIQap9MQqtz7 1kIpKIRSQ2uelNAqCffvG59ryNJKmtfUNrqeJ2urH7KUse2lSQm/l2hrtCXPyjMqgLp4/n E0x8wazKcKNGeEbqXV6JA8ZvOsR3fGk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1695046643; h=from:from:reply-to: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=4CzilwYZQ4Jc72fuQtoAbSWLiLUf2pcHd4c41aRTXJU=; b=Uhf3JhdM3e4goIwB0O9dO8JBxhx30tZalcAOWCg446Jw47oyqFKtY/1e0P0ztDVAQFLsL2 nra2CSmQGKJNcDAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8580B13480; Mon, 18 Sep 2023 14:17:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id c2yRIPNbCGUDMgAAMHmgww (envelope-from ); Mon, 18 Sep 2023 14:17:23 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 9362BA0759; Mon, 18 Sep 2023 16:17:22 +0200 (CEST) Date: Mon, 18 Sep 2023 16:17:22 +0200 From: Jan Kara To: Mirsad Todorovac Cc: Jan Kara , 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, Yury Norov Subject: Re: [PATCH v1 1/1] xarray: fix the data-race in xas_find_chunk() by using READ_ONCE() Message-ID: <20230918141722.gasntomhkkp2fwy2@quack3> References: <20230918044739.29782-1-mirsad.todorovac@alu.unizg.hr> <20230918094116.2mgquyxhnxcawxfu@quack3> <22ca3ad4-42ef-43bc-51d0-78aaf274977b@alu.unizg.hr> <20230918113840.h3mmnuyer44e5bc5@quack3> <20230918131815.otjqgu3zhigsst64@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:41:18 -0700 (PDT) On Mon 18-09-23 15:34:46, Mirsad Todorovac wrote: > On 9/18/23 15:18, Jan Kara wrote: > > On Mon 18-09-23 14:46:02, Mirsad Todorovac wrote: > > > Hi, > > > > > > I tried this patch and the > > > > > > > > 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 > > > > > > data-races do not seem to appear any longer. > > > > Yup. You've just missed one case in _find_last_bit() and then all the > > functions in include/linux/find.h need a similar treatment... > > I seem to have this: > > ----------------------------------------------------------------------------------- > #ifndef find_last_bit > unsigned long _find_last_bit(const unsigned long *addr, unsigned long size) > { > if (size) { > unsigned long val = BITMAP_LAST_WORD_MASK(size); > unsigned long idx = (size-1) / BITS_PER_LONG; > > do { > val &= READ_ONCE(addr[idx]); > if (val) > return idx * BITS_PER_LONG + __fls(val); > > val = ~0ul; > } while (idx--); > } > return size; > } > EXPORT_SYMBOL(_find_last_bit); > #endif > ----------------------------------------------------------------------------------- > > Is there something I did not notice? No, this looks correct. I just somehow didn't see this hunk in the diff you've posted. Honza -- Jan Kara SUSE Labs, CR