Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3001704ybx; Fri, 8 Nov 2019 12:31:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxRyDsc/tiAzC50R4jGBZHAJIhTigUDPrhTcOxWzBuw1XHZ9ZKZ9gx+MnMb+Cy8qyxRNk2k X-Received: by 2002:aa7:cc95:: with SMTP id p21mr12495791edt.189.1573245112463; Fri, 08 Nov 2019 12:31:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573245112; cv=none; d=google.com; s=arc-20160816; b=trXPvTPnvRD+5edtHKgQ60FBWHFSo29pHS1RNao1LPD96u8N/Kvt7Xr3+VQvc/SKK7 KFB8/MAvHSZGmWZjpGRA4T+FmeUuOvhPcakDDPayzpDwMBCy39dMZ3J8/gmAxQ+E2X9v Vn2lIEYSnYWUK/lXPv4ePOZwbYslLt1FxdJ8AbcIHNRt3zqlX3YZm31/tRptRUb4L6ur surish8I7JSGgAzn8NQ7Ybk8/JcGqwQTG6lOw0qmrujvbvbZWw0tmENcHPtapk43p19T oAn12einM511taPIBS5zdq/TLazPFU+czXRmPvU443B0DU1OLO4pBQwqwtjjscAHeFv9 dhxw== 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=4G9LhNu511cUTzzUCbonTskDej2Ys9dbnlHdssKk4WQ=; b=QJWgoS504bFFJCPZUQVNJagkQsAGMs3CotjpzhDtUFgVtZJa7Cno8HRAuXnhwuC4iJ f6JOzMEwASKkVQ86xVr9CmzjWBFnIXIiM0gypPoNUUYxtNvlxEG3AfM8QbndVa20+2mp iM3Ll8hpf6FzOIzOK4hjOi0dkT9Xv3tsJa0FiPfPWR+4Mz+NZuUBwoURkM8jjoOVq5yd +Ak9KEOPKZXu43k/KJuKRaXbH2isDd1sWNaYqvf7BGRIN1vHrOGlMHQYsL4O4hIJRVSv mR9UJzE5tpoApvA9fQwsNOHv2zdd4BS6JxCAHIJQnXF7lzg5AaU3jwaDl2HI6PE6sTZh ZpMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HHey9ElQ; 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 gw3si4255566ejb.385.2019.11.08.12.31.28; Fri, 08 Nov 2019 12:31:52 -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=HHey9ElQ; 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 S1728646AbfKHUa4 (ORCPT + 99 others); Fri, 8 Nov 2019 15:30:56 -0500 Received: from mail-lf1-f48.google.com ([209.85.167.48]:37688 "EHLO mail-lf1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbfKHUa4 (ORCPT ); Fri, 8 Nov 2019 15:30:56 -0500 Received: by mail-lf1-f48.google.com with SMTP id b20so5435632lfp.4 for ; Fri, 08 Nov 2019 12:30:54 -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=4G9LhNu511cUTzzUCbonTskDej2Ys9dbnlHdssKk4WQ=; b=HHey9ElQaNeZFkqKeSFK/EfPMq6vbK2Lm2dr3sIzCNHajSxBJDn4nfeJC674ARMqAO R5Ops4OPDogoeOgHpHESom8BR5x8/Q+cM6RqG6iYH0DFbaImijW3x06QX7os2TCHiDT2 MGulyXH2fLc6SW6VRGS2Cy1Xz3yb2hE39NIfI= 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=4G9LhNu511cUTzzUCbonTskDej2Ys9dbnlHdssKk4WQ=; b=eXOi/QzxZFyY0PuNkV+vlg0sDS48+YI6eF1EXkMXELq9Si0EHSLtcEGD6I8mKe73PM ZSwQiBya8Xlbi8F1dqX3c9mpB0Eekh7OpDVGNEWPBmw7Hpu0h83Fe27KU9FlUiO7hUXU MTrbuaR8ghMjzpUYY0SNraTPeJvqnIgna6AoHh/q4+4uvxPIMIWtiKFCMW/VCNCFT1Qz RXYjIv9IyuRxrCd3phlvv9Vwc+Na8ESiq882XRhmHin/mgFsUtA/xVCvt3ofIvJrRzsV /TjO2w5sqkgU98yjO+K77iJLdri+4OuNWgUnIXcFoH4YIYESUFE/Z8U5ASsPl0HhCp1L gnHA== X-Gm-Message-State: APjAAAUi3eVGOIcX7e5q3kuP6bHNZW1Es4L/YuzP1sPU/W0TxRKL/FEQ Uw7HZX8faponm2ffB7VBex6XfDOMjcc= X-Received: by 2002:ac2:4822:: with SMTP id 2mr7958691lft.115.1573245052803; Fri, 08 Nov 2019 12:30:52 -0800 (PST) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com. [209.85.208.175]) by smtp.gmail.com with ESMTPSA id g25sm3411019ljk.36.2019.11.08.12.30.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Nov 2019 12:30:51 -0800 (PST) Received: by mail-lj1-f175.google.com with SMTP id g3so7524409ljl.11 for ; Fri, 08 Nov 2019 12:30:51 -0800 (PST) X-Received: by 2002:a05:651c:331:: with SMTP id b17mr8195764ljp.133.1573245051344; Fri, 08 Nov 2019 12:30:51 -0800 (PST) MIME-Version: 1.0 References: <000000000000c422a80596d595ee@google.com> <6bddae34-93df-6820-0390-ac18dcbf0927@gmail.com> In-Reply-To: From: Linus Torvalds Date: Fri, 8 Nov 2019 12:30:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Eric Dumazet Cc: Eric Dumazet , syzbot , Marco Elver , linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Al Viro 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 9:56 AM Eric Dumazet wrote: > > BTW, I would love an efficient ADD_ONCE(variable, value) > > Using WRITE_ONCE(variable, variable + value) is not good, since it can > not use the optimized instructions operating directly on memory. So I'm having a hard time seeing how this could possibly ever be valid. Is this a "writer is locked, readers are unlocked" case or something? Because we don't really have any sane way to do that any more efficiently, unless we'd have to add new architecture-specific functions for it (like we do have fo the percpu ops). Anyway, if you have a really hot case you care about, maybe you could convince the gcc people to just add it as a peephole optimization? Right now, gcc ends up doing some strange things with volatiles, and basically disables a lot of stuff over them. But with a test-case, maybe you can convince somebody that certain optimizations are still fine. A "read+add+write" really does the exact same accesses as an add-to-memory instruction, but gcc has some logic to disable that instruction fusion. Linus