Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1024750ybc; Tue, 12 Nov 2019 13:00:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwFcRGdNNZxgxpiM4GSkGS7S9htLfVLdg+LKMvMDsrUfpFps9/pHabt7t0xRWeLDF5zqLf9 X-Received: by 2002:aa7:db09:: with SMTP id t9mr35982899eds.171.1573592456566; Tue, 12 Nov 2019 13:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573592456; cv=none; d=google.com; s=arc-20160816; b=R30mZrab4x02LE+1+HFSxX+vyALZR8QEpW7tWY7RAEcGwDC5ytbPloMWXywPaKFtgG +Vk7B57eZKtiiC7ed1ybfnypRVpLXpAT/QkWG/OBOFlabgW6Cxt0LtY7yk6lSRznKzyE czJg+61ppYP6SmZITZfKxpT3oogn5VNN9nUWmAQMX+yfkLXTpBwvFB5I5YDoZoZCOC8O Cj1wiF3d8xC2LeFIcGZQM6aG9C5n/89SEDgLOCVw7vTb35TyFZdYlcJ4bkcT1q1kXgCf tCRqFlw5vsek0Fa4iXSvlLXTV6VmmfWGqMQf+HFMnDc1u7mOVJwv7S2h+Y5PXaJyng7P /TAw== 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=wnvOYwfa6qDRGH1va7JtPEY4MALggxuc4YXJOwSoKVY=; b=ZXwIs3Sz/06lU6TaX92dIK0Tai0hkYEntFkUWJV540HMB6gD3M2xHweEibHQMIhpyg wBWDW9vCU2bESc5JlDLOUEZ1kgrGGVVJk0P+US8pzbGTrhFLP7KpGrldurzPuPwgoJJw TCZBbNW3rlvKipqWbk/lGBuA7o0DgB8hmNCDLAisZitPid6NpCfIfpqFYdHiKSHfRpWY wUIYR9daxz2b6yU7GYycEEiTywSYEloMCinRGUYE+IZ+zmAevhFbZ9ojhztpf7SEWdVF Nw4yAcRTlFYWOoizOgc8nSrx/fy7Iv+gZSruMk1TmpFLl1lT+N6ORIqCRwj3TDn3hjF/ fkUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=bIPT90I+; 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 mh1si816608ejb.221.2019.11.12.13.00.29; Tue, 12 Nov 2019 13:00:56 -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=bIPT90I+; 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 S1727137AbfKLU7R (ORCPT + 99 others); Tue, 12 Nov 2019 15:59:17 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44705 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbfKLU7R (ORCPT ); Tue, 12 Nov 2019 15:59:17 -0500 Received: by mail-lj1-f195.google.com with SMTP id g3so19375509ljl.11 for ; Tue, 12 Nov 2019 12:59:16 -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=wnvOYwfa6qDRGH1va7JtPEY4MALggxuc4YXJOwSoKVY=; b=bIPT90I+28Y1aSlcbzKemY/unFev3VpktnoJsw2rog25WeOeiXV2YOJCa+ttkBwlSO ZR69063yp6U5gZ2TTJIVI23n0ZboiBREakXYprN90R8ijIWb1A+8wIOx1iFnvuHiZoSD h/KA9xiVfnbLgjycX8QDmV+3dLXhmJg195C1I= 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=wnvOYwfa6qDRGH1va7JtPEY4MALggxuc4YXJOwSoKVY=; b=O+gVYlSgfnpad1bvSSYeheOd/Y7mLn82YOQ7MWEFdNZReBS6NRBN2Y1s3t9upvKxFg h/dZ/EA01E+RZ41uJecc4eSrDkmPmFnsq2DtwTPr1YU9G3SeUtYOu4YCyA92LybINJQ4 oA58oqy2QGdQRUjAf1sRvQwbvcjuRxqfJboWwYjsHR/jpzwL22CIys75QkprLj1jCdLf p3o+NLju1J8om53W9uOFYWN+Bny07Qfituqix+vJWdKT9j3n7lxcBQI5q4Madu+hV3eY +GnB08cXIcA8XWjGfYo/MR4XnJuRJ1BtWXrEsT42x5blgvnPq8gJrB11ZFQPKU7v1AJC m2oQ== X-Gm-Message-State: APjAAAW1hezXffnzG81OXmX3YyDYGRZb2j6Vn2+4PuK9MCLJqDEKNnqj wLT5cjA7Ns5I+43NJJz7i9aSdJKReDk= X-Received: by 2002:a2e:b5a2:: with SMTP id f2mr21180715ljn.108.1573592354236; Tue, 12 Nov 2019 12:59:14 -0800 (PST) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com. [209.85.167.46]) by smtp.gmail.com with ESMTPSA id m18sm4754494ljg.3.2019.11.12.12.59.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Nov 2019 12:59:13 -0800 (PST) Received: by mail-lf1-f46.google.com with SMTP id q28so9346lfa.5 for ; Tue, 12 Nov 2019 12:59:12 -0800 (PST) X-Received: by 2002:a19:c790:: with SMTP id x138mr21291173lff.61.1573592352459; Tue, 12 Nov 2019 12:59:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Tue, 12 Nov 2019 12:58:55 -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 Tue, Nov 12, 2019 at 12:29 PM Alan Stern wrote: > > I'm trying to solve a real problem: How to tell KCSAN and the compiler > that we don't care about certain access patterns which result in > hardware-level races, and how to guarantee that the object code will > still work correctly when those races occur. Not telling the compiler > anything is a head-in-the-sand approach that will be dangerous in the > long run. I don't actually know how KCSAN ends up reading the annotations, but since it's apparently not using the 'volatile' as a marker. [ Goes off and fetches the thing ] Ugh, that's just nasty. Honestly, my preferred model would have been to just add a comment, and have the reporting tool know to then just ignore it. So something like + // Benign data-race on min_flt tsk->min_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); for the case that Eric mentioned - the tool would trigger on "data-race", and the rest of the comment could/should be for humans. Without making the code uglier, but giving the potential for a nice leghibl.e explanation instead of a completely illegible "let's randomly use WRITE_ONCE() here" or something like that. Could the KCSAN code be taught to do something like that by simply not instrumenting it? Or, as mentioned, just have the reporting logic maybe have a list of those comments (easily generated with some variation of "git grep -in data-race" or something) and logic to just ignore any report that comes from a line below that kind of comment? Because I do not see a pretty way to annotate random things like this that actually makes the code more legible. The READ_ONCE/WRITE_ONCE annotations have not imho improved the code quality. Linus