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.8 required=3.0 tests=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 9D9DDC17441 for ; Tue, 12 Nov 2019 21:48:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7223820818 for ; Tue, 12 Nov 2019 21:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbfKLVsj (ORCPT ); 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