Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2126458ybc; Wed, 13 Nov 2019 09:21:19 -0800 (PST) X-Google-Smtp-Source: APXvYqz8fLa/Co9Cr4gqoSvI5PSPOQKQwVsA9ehPXZSdH6vwXNXxTnbD0ImcMcH9ilCqyZuYw/b8 X-Received: by 2002:a17:906:cb2:: with SMTP id k18mr3844914ejh.49.1573665679569; Wed, 13 Nov 2019 09:21:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573665679; cv=none; d=google.com; s=arc-20160816; b=x8kvnQ3a731YrUhQ6fF/sY67wDHS2rD1ubkM5eu3vTzFqFD6gdCXMf3l2647q/qNzb Evz+CmUVdn+EHQMW4Ku8H1LfEmWa11KEfK8CV+er8qtg3hLAHSX6lAoFd9FQ7U6Q7RzX 3rV4y3oHnQYc6iPLkXkqG0cJLdGaGYTDQ2tMkkh8ozkAxeXs913ftJK63mLTgph300jt fukN+YfAxucdeC4FSljHKC0Y2DUiX6eu7wEI6DNxkFhH1vy8P5pYIxzN10q5pw+9QrZk 4+AAZaJYbG0ONc7UpG1r9qpkMswGmCGAhpbSAl7TIuyiC91OvMAsuqrWV842OdPywsN1 t/Kg== 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=6ZYEg/h4QSDcgUnlMwh4w5+X6tHq85c+NTIUoiTVyRk=; b=kBH2xQXVVL4kyYc482QfXystnD8KT02vMEtJCt5KehQWW55Ys/Q1+d8wADyziZbS7I O0Nd7+TDYFcXz0yB8OKawrEHjX9f4O86tSB5k0HBHxoF7xBxclnPtgKTMBrOjaS3Awen Y6W5TN5hsuIrPDHBkMhMq0x57W3frNRr7BBy+8OFiff7ld2pc6P5tWQ48ee0QjBLJ4Tf Wk385r/T5cG5p5cMrzryWcgtyQyuUmpo8JIfNznopV1gg/kZgXk0tyIsJ/67H5xX6OoF 1AJNjGQOdskT2sFtuUwNyeoGqFpHqCT8ssT5XwLgDZ2yQ7PHXSQ+pIWQbsatWkuHe15d ncjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=U7ravdDy; 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 14si1557649eja.294.2019.11.13.09.20.54; Wed, 13 Nov 2019 09:21:19 -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=U7ravdDy; 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 S1728145AbfKMQ6K (ORCPT + 99 others); Wed, 13 Nov 2019 11:58:10 -0500 Received: from mail-lf1-f54.google.com ([209.85.167.54]:46847 "EHLO mail-lf1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbfKMQ6K (ORCPT ); Wed, 13 Nov 2019 11:58:10 -0500 Received: by mail-lf1-f54.google.com with SMTP id o65so2516902lff.13 for ; Wed, 13 Nov 2019 08:58:08 -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=pakgHHV0v8neE5Lrdi4uadCmJWWTBv73LTKJ+J6Jzjl/YEodWEBLdhSOjutjT19AOa vTWZkFkHM4o8hTk4v2hUiJhtXlyklwEAC+84nyh3Wvs8s/+IZAAOCsDp0nvAxaNlFNpg u5U3hTyNUJEVYH4UdD9t3IxHO4ScIb/196UHb5Vzhv29GHQ5H0pcSrJt2Ka2MgDZ8w95 rzHQP4ynnZjtWDgDtanxto3IWrtH4Uf+WoDRK4gcTVC6GY/7RRTGi2kQr2k+oTaMV6Nf mmwvmx+bHnrDeJM4rHVytdiLWPhj0qFWs8awtfLXnZosAwEeHd6HwvvQxpPSN5Dowcu0 Olmw== X-Gm-Message-State: APjAAAXc05jYiAsuHim/wsVsBLU8PQxY6ncyP754cF8VMAifaATcKhd0 cqN+zjy7FaIf2mpkYM+0Yr92XIn5uGk= X-Received: by 2002:ac2:5236:: with SMTP id i22mr3479770lfl.19.1573664287433; Wed, 13 Nov 2019 08:58:07 -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 z19sm1153773ljk.66.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 r7so3411753ljg.2 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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