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,URIBL_BLOCKED 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 5906AC43331 for ; Tue, 12 Nov 2019 21:14:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F59C21D7F for ; Tue, 12 Nov 2019 21:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573593244; bh=otp6BH91f1j1iYKXCkCEPVuG0Yq2lJz8IEkdivgWJPM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=VqFHbq9sdYhNT8oxLj2klD6SSo2MfaHtjp2TJBfKMIEqA1IvGtEwvaIqa2Fo6uPZm RwFn7Z1EhmkLSnpZqWLTr/wTzO92m788ojS+IqcoZkb086W3Q4//14YeE4hCBwQ9p1 Yn3mU6NdmhsN8qp1MRzdhVpggYEcyCNCuO6n6m7I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbfKLVOD (ORCPT ); Tue, 12 Nov 2019 16:14:03 -0500 Received: from mail-lf1-f46.google.com ([209.85.167.46]:45996 "EHLO mail-lf1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727543AbfKLVN6 (ORCPT ); Tue, 12 Nov 2019 16:13:58 -0500 Received: by mail-lf1-f46.google.com with SMTP id v8so11374lfa.12 for ; Tue, 12 Nov 2019 13:13:57 -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=P9XIZS7SU3RS49LRENl5SM7lOZ7kZM4P3ixT/QNzhdE=; b=UwY9cZA3V5T0vyNv2V661JB/VTL10yx6gFYc1xtgKQgONfocJfi8ojlq33WVjM/r+L cwAON8sR7dBpJMPq9/fq/cuIi8qLzAUszVs0iJ7LDN8D1o4e199T+fOpPSZOiTetQnuj Y+nhBGmk1z4MO+7U+QjWjCyy2lbljWp+V5Ag8= 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=P9XIZS7SU3RS49LRENl5SM7lOZ7kZM4P3ixT/QNzhdE=; b=IV2jpod26RcccFRNDWNbCpglpQ0I/+CBLisDj72CMbPvsk4RhvsnQsX5EYDmcydL0n mLp2Zr9FiA/l3sosglaqeU348/8ZUYgkxsAWtvEa8iWYKB2YG6Iyg+otCYUROMmZm5eP TfzMWAy/La+SjTtz2Pd258mI+2GYNdBbyWrVL/87buuTjFzxqrR7LPzubmlAJvhUskw/ dxBPF4i5vcijrKSrnSND9nbJlvM62QBDXx4LRl42Yl87st39jAOUEFjiu9gix4elJB0L 9QhabQ1waVEYvDxktWWHFuxZqpHlKpeuH6w3araYHbTSWjrDqRQDm/jTfBVVzjHexaef hs0g== X-Gm-Message-State: APjAAAUyJOjxN0lZQkocp7HoG4EhhUNRn7cL75a5xOYwlkhQxwU06axl frVhdlr9ze3JadlUNHrz3Gs2iR1qrzI= X-Google-Smtp-Source: APXvYqwU4FTF1mj+niXbX3V3VqkpIbjUOU32X9XwlKKG76z/VwexbS7g1oPjnP//iunlKIWkXc/qcg== X-Received: by 2002:ac2:53ae:: with SMTP id j14mr11696079lfh.3.1573593235846; Tue, 12 Nov 2019 13:13:55 -0800 (PST) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id b28sm10915649ljp.9.2019.11.12.13.13.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Nov 2019 13:13:52 -0800 (PST) Received: by mail-lj1-f172.google.com with SMTP id d22so32322lji.8 for ; Tue, 12 Nov 2019 13:13:52 -0800 (PST) X-Received: by 2002:a2e:22c1:: with SMTP id i184mr21906891lji.1.1573593232214; Tue, 12 Nov 2019 13:13:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Tue, 12 Nov 2019 13:13:35 -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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Archived-At: List-Archive: List-Post: On Tue, Nov 12, 2019 at 12:58 PM Linus Torvalds wrote: > > 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. Hmm. Looking at the practicality of this, it actually doesn't look *too* horrible. I note that at least clang already has a "--blacklist" ability. I didn't find a list of complete syntax for that, and it looks like it might be just "whole functions" or "whole source files", but maybe the clang people would be willing to add "file and line ranges" to the blacklists? Then you could generate the blacklist with that trivial grep before you start the build, and -fsanitize=thread would automatically simply not look at those lines. For a simple first case, maybe the rule could be that the comment has to be on the line. A bit less legible for humans, but it could be - tsk->min_flt++; + // Benign race min_flt - statistics only + tsk->min_flt++; // data-race instead. Wouldn't that be a much better annotation than having to add code? Linus