Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp538930lqo; Fri, 10 May 2024 07:29:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/zWNPYursVENaieG1jSaWt0LNLeMVDsE/1HbtOKBM6aTsDBHnmWFLKkFb4cpK+h4HF3BX7seh9xHSDu70Ryl9T6iDYjg/hu7Ju5wGxA== X-Google-Smtp-Source: AGHT+IFg8jPtGykdmBxI6jCRVgABJAvKYi7KvYLm9Vy+vhmH9oRGlTJd+rb5YRXDWHgCMdZ+POf4 X-Received: by 2002:a05:622a:412:b0:437:ba24:2dd0 with SMTP id d75a77b69052e-43dfdb4e928mr25852881cf.31.1715351346618; Fri, 10 May 2024 07:29:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715351346; cv=pass; d=google.com; s=arc-20160816; b=YI8NDQPimtad7lWsNnJThNRLXGKwkVDn1uK2rz6LV8yj7ZHrgmEB1IsEVbiqOVFvUW LPEetgy8mRYeGobv08SPOMPX2QWby5+axj8hCtFtBXnXTbX9bpglzrQCXmG+sx7B5XDo mupseRDGCiRBzMoKaoHdEqqVMHWl/h3glRHtQ8ro1Jfh1cbVQFU1RFjCrk+dPDnaWxcn BEQwSayFKR1HRx2yWUHp3jEy8cc1iKXaj77b/uQ5Ja8bAuBn/f1dHA5UWInevExuDwp8 xaWP+JU3Su+EjFgymDAZ0Kl05uPec3OYqUJza5Y6b2Y7MRCKUUlakWcE8P3Yy7ngq5kz 9YFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=38xXDqKoToM9frMHkxcYxnC8M11PgrzwbYFH289Fa7w=; fh=GogPIzQq2xRp3qtuOGRSGCnDvaMXc3MIb2yBWL8CHBs=; b=KusR9TM16cAkNgV83jCUE6VTcJaASqvBYmP22B9DB6RF5AdYUFelIkUn+uMQYbW8I9 IDs2ER3FgkyBJjV67A4+xp0fiGUNFfvWKr8nUSLQeBfHgzReKwgi+hWU9IqADFyoYaeo SlSViN9vBz7H6mXaxBNATfEOsscb7L+25YI//LB4PakV66q366sep/DdF5YrTxK0yks0 qAEIcOR8jQqbcgNvtq23UDfWp/okwtPCIxQEz67U/3HEwT4lgqmnPHARu18rdxsCb6Pg XHsAMD24W4mLXbaN14eXis9WHL0VFHDSfM9EcaB3IooWVkQk4Yn6FyuCdOgZBJhASb/z V95g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@acm.org header.s=mr01 header.b=0kQPzbPd; arc=pass (i=1 spf=pass spfdomain=acm.org dkim=pass dkdomain=acm.org dmarc=pass fromdomain=acm.org); spf=pass (google.com: domain of linux-kernel+bounces-175902-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=acm.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df54b4871si36520451cf.191.2024.05.10.07.29.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 07:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175902-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@acm.org header.s=mr01 header.b=0kQPzbPd; arc=pass (i=1 spf=pass spfdomain=acm.org dkim=pass dkdomain=acm.org dmarc=pass fromdomain=acm.org); spf=pass (google.com: domain of linux-kernel+bounces-175902-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=acm.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 571C91C225FF for ; Fri, 10 May 2024 14:29:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4A2917082E; Fri, 10 May 2024 14:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="0kQPzbPd" Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EEB9168BE; Fri, 10 May 2024 14:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715351328; cv=none; b=CNo/stBi57ItRdLLmX+xOe77+3cNSPXy97FmdskImZ7Mj0Cuz0cN+LibRzpT78gk77V53hRdPfSf8iodcNiv/72a6vj1b/sA3e95Pqk491TiCkQ0tzUhMl3iwwqMNzDlipop9S8jzfUXI8l8uo5z6r9VaQtK6hfU2eBwCbj29Bg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715351328; c=relaxed/simple; bh=BFrpAMtQ6hOgNZP36CFmr/GFU+yNvcmCFe8r40i8/6U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EwuRD8uzURJMTJa4YpjD3qxy0x5gJd1BTK9fIBTDeG/KOhadDqDfKLnTwNixQmSJmTwDA8ZwbSdIc5KmsjvFF6HNnXfONICA3InAbt/VSUkHci67joFpKveXCb4iQpmrDZrq1U3xMP9hPQF3PDewO87clE9g8BxRO9kNjaicNwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=0kQPzbPd; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4VbWTT6PHrz6Cnk8y; Fri, 10 May 2024 14:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:content-language:references:subject:subject :user-agent:mime-version:date:date:message-id:received:received; s=mr01; t=1715351324; x=1717943325; bh=38xXDqKoToM9frMHkxcYxnC8 M11PgrzwbYFH289Fa7w=; b=0kQPzbPdtgdB6+UuGEQxlXjVWB6JY7mHizLjuAdj l48EeEF17HPQLYWXnLzcIkbZs/gOZEFzoDgdfERoa+HcV8+6UMENa5UXW+BhOq0i V17ULYPyOoUe28K/CrjDRVvvY8kN/Hi811GhPX77H/drR1Reb29LkkutfIhiSK+1 5Ll0dupCiUe7M4Cfk7jjQyUIHsoFIaT+9w6HuCwYnns9tGJ9o6RhbphLNYr3IQ2M ThY7xzgNOOITsjYhD1jiEYBYTEI9CiaUXPoBKv6OQGLBDHKRe+9jHbjoLGw0a4Kw DiwzBnFZMyq6PmRSVApMKlVf/hN+bpjh2WaW5SdY/ixiWQ== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id UJMy_NOPQQXI; Fri, 10 May 2024 14:28:44 +0000 (UTC) Received: from [192.168.51.14] (c-73-231-117-72.hsd1.ca.comcast.net [73.231.117.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4VbWTR1F1Rz6Cnk8t; Fri, 10 May 2024 14:28:43 +0000 (UTC) Message-ID: Date: Fri, 10 May 2024 07:28:41 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] block: Annotate a racy read in blk_do_io_stat() To: Breno Leitao , Jens Axboe Cc: paulmck@kernel.org, "open list:BLOCK LAYER" , open list References: <20240510141921.883231-1-leitao@debian.org> Content-Language: en-US From: Bart Van Assche In-Reply-To: <20240510141921.883231-1-leitao@debian.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 5/10/24 07:19, Breno Leitao wrote: > diff --git a/block/blk.h b/block/blk.h > index d9f584984bc4..57a1d73a0718 100644 > --- a/block/blk.h > +++ b/block/blk.h > @@ -353,7 +353,8 @@ int blk_dev_init(void); > */ > static inline bool blk_do_io_stat(struct request *rq) > { > - return (rq->rq_flags & RQF_IO_STAT) && !blk_rq_is_passthrough(rq); > + /* Disk stats reading isn=E2=80=99t critical, let it race */ > + return (data_race(rq->rq_flags) & RQF_IO_STAT) && !blk_rq_is_passthro= ugh(rq); > } > =20 > void update_io_ticks(struct block_device *part, unsigned long now, bo= ol end); Why to annotate this race with data_race() instead of READ_ONCE()? Are there any cases in which it is better to use data_race() than READ_ONCE()? Thanks, Bart.