Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp556341lqo; Fri, 10 May 2024 07:57:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVDZlMPFGGIh+iKYisoqYhg9klGPUVj82CyMgms07QYog701tf9BE+LnGl3WFfKOdey+e9DRXxJpC30gCd51eL1ZwSCH/nW259tbkOXw== X-Google-Smtp-Source: AGHT+IEGR1A7ms8P1yVXFVBpWB2AxZ0oFFvmKs/4LrrH1aQ3wc0JzkkO8TYyVu69Z7jppR9vlhan X-Received: by 2002:a05:6808:4194:b0:3c9:6c0a:7a12 with SMTP id 5614622812f47-3c99706caf2mr2856155b6e.35.1715353059437; Fri, 10 May 2024 07:57:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715353059; cv=pass; d=google.com; s=arc-20160816; b=Z33CFU/jDiW/t9JJn/oNQmnaXh67t8h3aJdMCQwo+e3BoaHD1mAewqphH+PxU80GUG T6NgvC44KZO5H1+xOiS77fs1y2EbP3GS1xNOd9FDwWOp/ALvesB8TmsJO1A1NmMmv63a BG6R9oJlIX85QizhsIZx+XVtHt1/Dqc6eaN4eecRtbG5yvWu9JiPHxSE0BtMoFRsZJF6 RP+TcToUaeGOGwYGDnqAccuJo+AD500l4U9aAPSBYK6PujB3ixh77XQl1IzZhRtSFxxh J0MR3QEGMISAJ5/B1v4RSk3McPkn55GY0gmtoGXia+rqmQXHpulH8TCL+o26tbJ42ZjI znSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=rmPX0pe9l4LhCeCJ9RFzXwq04vOIoS39dg64tvVpZjk=; fh=TmLrT9t2nn3l4SeVyHpeNDNMXDDGYkr5tBonaMNs1ro=; b=kpctN7btg+R+BQD6+ddh91/oSZ3OxjgNBOjWHV9gtZX4t2saWQES1Tkgrl7BBODarL TcY+IpabCiFvwQMFT1PQhQgS2rXMFsxDb+O/qOhEoK/t8K2e8n15TgmQACtkzKYB8fWW NShwsAfCULaAGTsfEwYEHs/85OTku9wWd6wmDnveL1R9mkw2sQdId/5sEG6iLhjUzVpV sFLUcpvucMo6FTKyLM2J785ZhHDFw7nbtA04/5b3Fj2m+YMHhOFDROOmQa9bAo86E3om hd89BWo1NcyqxPI1uXfOq/8GEnxpainUSwqBqTtwHodNOCTenzBaBNIytLGCXpTkexcV Ws4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-175925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175925-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f29a8cdsi39060516d6.191.2024.05.10.07.57.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 07:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-175925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175925-linux.lists.archive=gmail.com@vger.kernel.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 276041C23000 for ; Fri, 10 May 2024 14:57:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10FD517109A; Fri, 10 May 2024 14:57:32 +0000 (UTC) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CCBCEAC0; Fri, 10 May 2024 14:57:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715353051; cv=none; b=n2zm3+PKevpMhh/F5A0Yt0wBivSgLeebY36l+i3Yv88N5MnAzXPKE7/uZcVTqU7P59ntH7HJnGs128nWtZfxKin6um2lGfGZFId4ca7nauavk1jyFJxqGiwLeQMk5dH/ASV/xZYCUf9+LqmhXDKKKPsG6bI4vYQEo3N/rfdriTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715353051; c=relaxed/simple; bh=U7C++UZ8Ckt4orfC7xx+jCKetrNe3QBnPE/FhNdCFiE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XQJmQu7UJrDD//2Y9EfyCbcGvnFF2mq9Vwe+rAJOSQ5FDoknGlCcuy8GFV4cCvFJjubLJbynZj10YMICdIgrGhlheXJui2uKeDwz6l7hlOOOWE27KC4rJFKyUH08fUeZ0E8Fvf13jcCO8OQbzZdKRmlINQJZPLyDY5ctD4wDI1M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a59cdf7cd78so551865966b.0; Fri, 10 May 2024 07:57:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715353048; x=1715957848; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rmPX0pe9l4LhCeCJ9RFzXwq04vOIoS39dg64tvVpZjk=; b=NNn6SLB8JpuEkJfvo3cUVp7nc1mh2qpZQ9cTcefa/IBahy5RWwkib6LwQkDr1Sf3TG 0Ddr+ztQl+juI+UDkLRK7SbpHqTE+hDZhcBh0WOmq9CeUfCPD6l9yowIOiKnZJJ1rZ/V IDr1Zm1LbpOeEpl7G6ifWHa9AUIw289QY6YoCWG2cz3EaC9Q/bOjOFRAWiGslTZX2RHZ MwVezosBcY32KzhL/ChUS0uw5qRSfS9N8BQYDl83p2ubBllJmHVQLXuBHWtl5Gbfedee ievWMEVvK/NIFWhFrx2yHlb9ScM52He+qDh1HebY5p6Y+YZQUqn6DoWItFepFZzY37LS 3lvQ== X-Forwarded-Encrypted: i=1; AJvYcCUyQREAEx5LVER8fiLon0DjtuTCitcuDEfUbZUaLSxqHo6RwrABxIzz6IDpAdk7Hl+zrLSxSBfglNGElPQRQpjLkCh2hKxJlbh//S9XnLCPjJPrrgk2V6ptlG5vIfdWpc3MKEy2AV59H+Q= X-Gm-Message-State: AOJu0Yxh8M4TN1WVL73ik6ZAJHCPZSDM/46H2PmJnkt8f4X6YDkYT1KB EXPdmNaMCPnFY6g75p4aqPpyixQGfKC0p+ae19R4Yzj6n9lKkUvItZ5IsQ== X-Received: by 2002:a50:f699:0:b0:570:369:3e06 with SMTP id 4fb4d7f45d1cf-5734d5de84emr2201724a12.19.1715353048169; Fri, 10 May 2024 07:57:28 -0700 (PDT) Received: from gmail.com (fwdproxy-lla-120.fbsv.net. [2a03:2880:30ff:78::face:b00c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5733becfcc1sm1838512a12.45.2024.05.10.07.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 07:57:27 -0700 (PDT) Date: Fri, 10 May 2024 07:57:25 -0700 From: Breno Leitao To: Bart Van Assche Cc: Jens Axboe , paulmck@kernel.org, "open list:BLOCK LAYER" , open list Subject: Re: [PATCH] block: Annotate a racy read in blk_do_io_stat() Message-ID: References: <20240510141921.883231-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, May 10, 2024 at 07:28:41AM -0700, Bart Van Assche wrote: > 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’t critical, let it race */ > > + return (data_race(rq->rq_flags) & RQF_IO_STAT) && !blk_rq_is_passthrough(rq); > > } > > void update_io_ticks(struct block_device *part, unsigned long now, bool 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()? data_race() doesn't not emit any code, but, keep KCSAN silent. READ_ONCE()/WRITE_ONCE() emits code. So, if you do not want to change the current behaviour, but, keep KCSAN away, data_race() is preferred.