Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1070457ybc; Tue, 12 Nov 2019 13:49:38 -0800 (PST) X-Google-Smtp-Source: APXvYqzNFCt5RJS9nWWI/QoLoSiD5ZZkPlr6Rcl3krT5dmctgCZpkApKxkHRp2iz/94Ks1r/VwwO X-Received: by 2002:a17:906:b74c:: with SMTP id fx12mr28825221ejb.324.1573595377896; Tue, 12 Nov 2019 13:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573595377; cv=none; d=google.com; s=arc-20160816; b=G9syLx2DYFnsdlaJgWsZTeEfzVt5+kTPjBqD7TD0XRmokI6OqtxjcAxCi/FQkOFb5A +RJU+uQwXPlkqppgh91RfTOt/n25zDh9QMTdqvPra0Rcl81nj08+4LEXIEeToO4Tp/sp 2meI2n0RKv1fDZR4qEf9zkxKnsHMLfn9xNFXURXq/ZX37rCMKIrUPnZYJrOPt4jeSPpx erJJyIZypJC/L0uaiCfSSymSxcuLaI6JwEyqDJ/yZ4L5Jn4sDho7qvo0diKSN4PfUCeP 2FZLet151bA9ATlD2LSV0RhSs0G/T/6ospaiWSf5Vz1KDxBvUE+3Fey0IunGMLLe+KiF bW3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=TyPL9pMEK2rLB1p0nnHp8r5KWabFxpssfd8AlwNjhv8=; b=hSRqjiVvqQco+PpYXEeUK39DLzL/+VmzVFkiRItEE7oMKXaB5c8FyWfYWQAtzwjvmu Zq50rgGD0iRo/S2BTAUFUDWvGD3m+8IUU64Ike8MGrhqWfECDVo5fQ0UZ6K0rtSBG+nP gfCC719DmhJTkxzazmh2+nRfrnjanzjcsWpzm5OManAEm0P8dYtjX7aRrdULP9Au0UgU SPP7GiCmUt53SzG1j5d9y7yzhYbtUKKibLXZIKKriQNU68Hv3suoIm/fKWDsaW8xYpvx vLYIYm0+RW061kDhdw3LTMepHaRxJSFmiXE2bS3XXolLgns29/pbdVVQQITlwpEQjMqR TkwA== ARC-Authentication-Results: i=1; mx.google.com; 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 d13si9733200edv.97.2019.11.12.13.49.11; Tue, 12 Nov 2019 13:49:37 -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; 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 S1726954AbfKLVsj (ORCPT + 99 others); Tue, 12 Nov 2019 16:48:39 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:35284 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726910AbfKLVsj (ORCPT ); Tue, 12 Nov 2019 16:48:39 -0500 Received: (qmail 6266 invoked by uid 2102); 12 Nov 2019 16:48:38 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 12 Nov 2019 16:48:38 -0500 Date: Tue, 12 Nov 2019 16:48:38 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Linus Torvalds 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 Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Nov 2019, 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. Just to be perfectly clear, then: Your feeling is that we don't need to tell the compiler anything at all about these races, because if a compiler generates code that is non-robust against such things then you don't want to use it for the kernel. And as a corollary, the only changes you want to make to the source code are things that tell KCSAN not to worry about these races when they occur. Right? > + // Benign data-race on min_flt > tsk->min_flt++; > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); I suggest grouping the accesses into classes somehow, and telling KCSAN that races between accesses in the same class are okay but racing accesses in different classes should trigger a warning. That would give the tool a better chance of finding genuine races. Alan Stern