Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3104032ybx; Fri, 8 Nov 2019 14:08:09 -0800 (PST) X-Google-Smtp-Source: APXvYqxMOhySvQHuxKiPbHicdgGO9wSit1V8lSVB81GQEBlsKpn3EiqWGf6ZZb37lnHq/LFRWQCU X-Received: by 2002:aa7:c303:: with SMTP id l3mr12681934edq.89.1573250889696; Fri, 08 Nov 2019 14:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573250889; cv=none; d=google.com; s=arc-20160816; b=UR3FS1ljo+poSREk3I4A9kn6rG/nG7vQy9K93TKuCRWlKCQDOQpMqITYYxNUbY5sbk ytDVLap6kryW6lY8f+S1igyesXrkgmWmq72jm6b5yvFgSwBWhBWFgHNySFxOwBIydc1A W3KygQVXZ1KeOfCpHz/GcRtNicO0ApECelILNeDYBzWhuKtOeLQUPSnpYqFPCRMk+nwC JngVjp+tsul9iem0HD9+ELS9y2wwwWvMbQ0+GgS3qX5y+hD72rmoAk5gMjdy77xzLvgD wZWbrJrw6htrmSdZJ75zetInthjvJK8FvCdAiqzaH1QuAQaUiYgkRFjIB4XETrdC0t9q fuLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PM7aXIqGlTv4ooyqCBP9d/aFSkST3hpJVxVLXow9peg=; b=QLGc/zu/lDfbkgr6VBQ6MIaKDz7YdEsnHlqf+hcvyMndV2V058gP8zk2+KvVZLRRYs Sk1CQBtbKf15u/wxo/ddwPTX7tUO5yMFpJ3DgRnpU5hr9ssDEkeAKz/qADKoGuxyUXa4 ZDcXF035+cA4MraNqASk1pSO68tTRCXcLZcfZWcvUZRBs3YPk6qs5caHrPZEdrt+VFAE +QJY9hI2xW6ZvKz7CYFULbVCdyjAtIbLHz5S+WQVoEoqub3oFbzgImNV4a8LQY8itT4f 91p8KMiWwCj62OVMld9Tg8FsRwYHeuj9XpicuFVamtyRkFsP0l4CDovmpcLINzE9vWeE T78g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=PS2bjVFa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qh4si4622422ejb.319.2019.11.08.14.07.45; Fri, 08 Nov 2019 14:08:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=PS2bjVFa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729162AbfKHWGr (ORCPT + 99 others); Fri, 8 Nov 2019 17:06:47 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33294 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbfKHWGr (ORCPT ); Fri, 8 Nov 2019 17:06:47 -0500 Received: by mail-lj1-f195.google.com with SMTP id t5so7791731ljk.0 for ; Fri, 08 Nov 2019 14:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PM7aXIqGlTv4ooyqCBP9d/aFSkST3hpJVxVLXow9peg=; b=PS2bjVFaLslkBSK4KUWZW/tIht7XZkmjJaTGU2fPdPRjfl2o/Ml1nSc5Cg3cXbpjrn uVwV0UkzJaP00ag8fp+t0sP9z4xcMjUm8fftb7VXNUC7o8uebivBnfsBFl0/gpgF8qbg C7Lov0mQEbZd2DawPCA8y68rgZ/YLGOFrSlQo= 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=PM7aXIqGlTv4ooyqCBP9d/aFSkST3hpJVxVLXow9peg=; b=qzMFHjopilD18DFg1xFNh8P38SPrQXSHQRw4kZ+Hez/zVDdHDnQcxvBeYNubMpt7GH lV1/4C+B7SxK+b1eF1CWNgNSDgfJfCA2XHo/WU0kwjfO60eY5OkdAEu8WoP6y3Vae7vj eeYaSaYeq/4PPy4aFB7Ej4a199qCdsUDzOdpIfMuzIAbTk11qB/gO9xiiUwhpQCMK8ZP KWLAHW+2ybzh7/xSANbF+tEXIoL6zEY5XE3L5OxRZw6gy/AcPAAWu2XyaW06FP8ImXvS 4hm1RhNpoXYLoJqRT8/q5sPc8RjoqeWVcRaEXqvlTcrd2ITfsGNdYzeCMKlCipdABS8Z IVwA== X-Gm-Message-State: APjAAAWRi1IAj1dbz+czVp86tEUYuCVWANcAiDersxYwK2HocNcRB5lL b4yNTGSULx2xhXJakOx3aKzoZVhoAbk= X-Received: by 2002:a2e:8857:: with SMTP id z23mr5107071ljj.50.1573250802679; Fri, 08 Nov 2019 14:06:42 -0800 (PST) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id d26sm1421593ljo.54.2019.11.08.14.06.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Nov 2019 14:06:41 -0800 (PST) Received: by mail-lj1-f181.google.com with SMTP id v8so7765924ljh.5 for ; Fri, 08 Nov 2019 14:06:41 -0800 (PST) X-Received: by 2002:a2e:9a8f:: with SMTP id p15mr8150237lji.148.1573250801141; Fri, 08 Nov 2019 14:06:41 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Fri, 8 Nov 2019 14:06:25 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Alan Stern Cc: Marco Elver , Eric Dumazet , 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 8, 2019 at 1:57 PM Alan Stern wrote: > > Can we please agree to call these writes something other than > "idempotent"? After all, any write to normal memory is idempotent in > the sense that doing it twice has the same effect as doing it once > (ignoring possible races, of course). No! You're completely missing the point. Two writes to normal memory are *not* idempotent if they write different values. The ordering very much matters, and it's racy and a tool should complain. But the point of WRITE_IDEMPOTENT() is that it *always* writes the same value, so it doesn't matter if two different writers race on it. So it really is about being idempotent. > A better name would be "write-if-different" or "write-if-changed" No. Again, you're totally missing the point. It's not about "write-if-different". It's about idempotent writes. But if you do know that all the possible racing writes are idempotent, then AS A POSSIBLE CACHE OPTIMIZATION, you can then say "only do this write if somebody else didn't already do it". But that's a side effect of being idempotent, not the basic rule! And it's not necessarily obviously an optimization at all, because the cacheline may already be dirty, and checking the old value and having a conditional on it may be much more expensive than just writing the new value./ The point is that certain writes DO NOT CARE ABOUT ORDERING, because they may be setting a sticky flag (or stickily clearing a flag, as in this case). The ordering doesn't matter, because the operation is idempotent. That's what "idempotent" means. You can do it once, or a hundred times, and the end result is the same (but is different from not doing it at all). And no, not all writes are idempotent. That's just crazy talk. Writes have values. Linus