From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48F01C43331 for ; Mon, 11 Nov 2019 21:53:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D5DC2184C for ; Mon, 11 Nov 2019 21:53:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Qy7hsN4r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbfKKVxV (ORCPT ); Mon, 11 Nov 2019 16:53:21 -0500 Received: from mail-il1-f178.google.com ([209.85.166.178]:40583 "EHLO mail-il1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfKKVxV (ORCPT ); Mon, 11 Nov 2019 16:53:21 -0500 Received: by mail-il1-f178.google.com with SMTP id d83so13521321ilk.7 for ; Mon, 11 Nov 2019 13:53:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x5dR2X2FPjc0R4vKaFMq42of1ocjgN73FFpV0IAy3Es=; b=Qy7hsN4rNqDIsADEty2zFKc9T419wkbTgjhkrGwsJBb0mS8oAXBvZmLuLbksEbS967 AS7SumZJtySJk+Uo7BlorvhZJ/5b9I8wZEi62BArK7PTRkStJ7lOmT7lWRpD/TaXyk5T l6oBe+cBgOHBhzLF0fHedCG3gbw2w7v8poM7XnJ2Wn09xLoLqO1YnMHVB6a1ePNU/BV1 lnf39TjhLmTLV75aN6SI7p8VuObJkzj5PtJamPDhv3MorHUDsDjxbKsoeHQDmWdX35/+ dxJpPyl8uSV6uOrQzRkX654Dtdl5cZVmvYrKkMIcy8V2OMcGBQiHwjzO8KfKmXXoHsZ1 IFcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x5dR2X2FPjc0R4vKaFMq42of1ocjgN73FFpV0IAy3Es=; b=s3fduTY6UcV9VdtoVdajtsMIwHGXLY7xpWHwpAwSrLv1q3hcCS1vO0O9gPXYpoKTf3 LEcSVmQMzIxuSM0gzDLC7J8iKKBAV2A7uPpCPBqbIbAOoX5vQ7hov5YpGmXNcg8Rf8It qPO1ypNV7siytBA6gdU/jVs/sXz8kGtCyIdfPhIzgE0zlAYlAGTXN6asYQVtZQn0D2BR RNOMSmk+rLoHGeNv7kXJgtJNoQHgcBB94PhJ0XldZlBia5uIt0N86ovj8Y0wjbzEDIA7 xAtWQWB06lNq3RHDRIL/Jxehy6taYtLGWkeX9+vl+AgGaCmCXqFIZUPM4xwmm2i3emij ftGw== X-Gm-Message-State: APjAAAWfxa+liIYQ7ZU64SSXg8A8gyEPtmT9NqFlOj74aQzEPdUq98hS X2S0FwCq/ig+DjHfjdww/RZZ8WhjBQSoLm27ZpxN+A== X-Google-Smtp-Source: APXvYqyEKArgN/a9P0jAoaKNekFY1H9Ikjs3X+yMpFLujCjs7WSeV2O3zE/DTUMb+bgZ6AKrEPGh8EwSxNFXUbMagqA= X-Received: by 2002:a92:99cb:: with SMTP id t72mr29681319ilk.218.1573509199768; Mon, 11 Nov 2019 13:53:19 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Eric Dumazet Date: Mon, 11 Nov 2019 13:53:07 -0800 Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Linus Torvalds Cc: Alan Stern , Marco Elver , Eric Dumazet , syzbot , linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Al Viro , Andrea Parri , "Paul E. McKenney" , LKMM Maintainers -- Akira Yokosawa Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Nov 11, 2019 at 12:47 PM Linus Torvalds wrote: > > On Mon, Nov 11, 2019 at 12:43 PM Linus Torvalds > wrote: > > > > Yeah, maybe we could have some model for marking "this is statistics, > > doesn't need to be exact". > > Side note: that marking MUST NOT be "READ_ONCE + WRITE_ONCE", because > that makes gcc create horrible code, and only makes the race worse. > > At least with a regular add, it might stay as a single r-m-w > instruction on architectures that have that, and makes the quality of > the statistics slightly better (no preemption etc). > > So that's an excellent example of where changing code to use > WRITE_ONCE actually makes the code objectively worse in practice - > even if it might be the same in theory. Yes, I believe that was the rationale of the ADD_ONCE() thing I mentioned earlier. I do not believe we have a solution right now ? We have similar non atomic increments in some virtual network drivers doing "dev->stats.tx_errors++;" in their error path.