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=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 765B4C432C3 for ; Wed, 13 Nov 2019 16:58:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28A7C206D7 for ; Wed, 13 Nov 2019 16:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573664293; bh=GGY3G0+6mpa4tHVngh8c0Sn1vF+30kVZm15H32Wqrn0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=H5i6zo6wxSr5a7g+jAnITQNTpdIS25mFqnoszQ+28HuPoyEFfuPhYv/KpOPdBnsru VNSesuEtkJS6AknnH0KLXCIklR4hdi1PceG0ANTYSruS3rSL/6TSYTMncQXlLWcCIU 3cPtz1+L2yK+wQAiIxjCZM3tB8mlEgEngpEtlnIc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728627AbfKMQ6N (ORCPT ); Wed, 13 Nov 2019 11:58:13 -0500 Received: from mail-lj1-f182.google.com ([209.85.208.182]:37567 "EHLO mail-lj1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbfKMQ6M (ORCPT ); Wed, 13 Nov 2019 11:58:12 -0500 Received: by mail-lj1-f182.google.com with SMTP id d5so3396344ljl.4 for ; Wed, 13 Nov 2019 08:58:09 -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=6ZYEg/h4QSDcgUnlMwh4w5+X6tHq85c+NTIUoiTVyRk=; b=U7ravdDyiBjUVP8ErfMB91io1YhXvWHGVKa77PMeGvwn8vFpkMlRNnDUtYyuCdHy/V eXLqYfmp5YyTims+8tWu7mnnzxTheo9yQBk18/JI9FYSjBx2+5iIJS2FdZCXQkrg9sy+ PAqMgVt9H/TKePAImEEkVIthOmiQ0+tOoY2sY= 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=6ZYEg/h4QSDcgUnlMwh4w5+X6tHq85c+NTIUoiTVyRk=; b=um22aozmvgjrPf4YmS2kIOkSl2eEgVg1gGQuJj54DiHw9riKU5D6m63wa7dQGHsgwa bCkmY4HrZ7msUvaOPZ4TVL5Jk7W8eZmiJ9CJ66WS7yQHq4GPrMv/W4RP4LHDVbSgHJDr I/CLOT+UhRxHWtP9Ol8A0QIHso/NhJw+1ibxVtrvqDUgUMeagFfAeArNZ8Ov2DmuvMsU jNVQjzsx+0/Y4E/7ihwLm4+KsJRdeguW7+jlZz9UMvpCe99RP14nn4oJiR7OSLM71RGe C8QEJj4Cok7wQ1ZC0p4fdtV9rUcYT+H0GZmXktzlyNdLeB3rvTyC1A4VhtW5b+kqYJ71 9+yg== X-Gm-Message-State: APjAAAUe7SSCDRfabvnqZ4zV3yTGOl8/A1EcmrtxlTBQom2CPq21cNGl Gl6nSwA+i88p0trRs5cA1Pat0V1ZS2c= X-Google-Smtp-Source: APXvYqyzBQRFcZJHiMPZvfxtzODz6JCNqOvRNlhzA99n8aemfW20kQAoC6vGaybikS6aXrxOiAFArA== X-Received: by 2002:a2e:96cc:: with SMTP id d12mr3317666ljj.210.1573664288818; Wed, 13 Nov 2019 08:58:08 -0800 (PST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com. [209.85.208.174]) by smtp.gmail.com with ESMTPSA id i30sm1385572lfp.39.2019.11.13.08.58.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Nov 2019 08:58:06 -0800 (PST) Received: by mail-lj1-f174.google.com with SMTP id y23so3361178ljh.10 for ; Wed, 13 Nov 2019 08:58:05 -0800 (PST) X-Received: by 2002:a2e:8919:: with SMTP id d25mr3368745lji.97.1573664285540; Wed, 13 Nov 2019 08:58:05 -0800 (PST) MIME-Version: 1.0 References: <20191112224441.2kxmt727qy4l4ncb@ast-mbp.dhcp.thefacebook.com> In-Reply-To: From: Linus Torvalds Date: Wed, 13 Nov 2019 08:57:49 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Marco Elver Cc: Eric Dumazet , Alexei Starovoitov , Alan Stern , 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 Wed, Nov 13, 2019 at 7:00 AM Marco Elver wrote: > > Just to summarize the options we've had so far: > 1. Add a comment, and let the tool parse it somehow. > 2. Add attribute to variables. > 3. Add some new macro to use with expressions, which doesn't do > anything if the tool is disabled. E.g. "racy__(counter++)", > "lossy__(counter++);" or any suitable name. I guess I could live with "data_race(x)" or something simple like that, assuming we really can just surround a whole expression with it, and we don't have to make a hundred different versions for the different cases ("racy plain assignment" vs "racy statistics update" vs "racy u64 addition" etc etc). I just want the source code to be very legible, which is one of the problems with the ugly READ_ONCE() conversions. Part of that "legible source code" implies no crazy double underscores. But a plain "data_race(x)" might not look too bad, and would be easy to grep for, and doesn't seem to exist in the current kernel as anything else. One question is if it would be a statement expression or an actual expression. I think the expression would read much better, IOW you could do val = data_race(p->field); instead of having to write it as data_race(val = p->field); to really point out the race. But at the same time, maybe you need to surround several statements, ie // intentionally racy xchg because we don't care and it generates better code data_race(a = p->field; p->field = b); which all would work fine with a non-instrumented macro something like this: #define data_race(x) ({ x; }) which would hopefully give the proper syntax rules. But that might be very very inconvenient for KCSAN, depending on how you annotate the thing. So I _suspect_ that what you actually want is to do it as a statement, not as an expression. What's the actual underlying syntax for "ignore this code for thread safety checking"? Linus