Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1090043ybc; Tue, 12 Nov 2019 14:11:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzwYSIHy53br8IhjKdXQKEbBmnsY69H9D4s+Sz6ECkBl7SqYseMGRR767gPQqU2sJQizVE4 X-Received: by 2002:a50:870c:: with SMTP id i12mr43964edb.16.1573596666718; Tue, 12 Nov 2019 14:11:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573596666; cv=none; d=google.com; s=arc-20160816; b=TnmUflDO4wV+B7d5qHp9CRZoxg23ZgTJ6sKWoofnQ8WfJw47dCVXOwIIp7YHvTuneh +MMB2iX+l7eQObhEc85lp6bGYjhlU/K07qxSVQrGRyjkarqR/54tUO71tcQgcC5+5VqT JWtcNhGdfMJV5rwcY1axxUHApUmp1JHi9rnzMrYhb+o2iPINHjg1eXNUSYzV2ZuJUWGc YEFF7zbkLsUctTBrTyP+kbFAEzYVmSPnVySuNUwFI+ciJg2eMpWZWiNMMrEBpqrD2Zsv slXq7pTfJQqayiwHZbX56uJNBwBq9cY3RnA5fJ0Z1s9DeDZMnGEp0izlFqU1BgC/BYr4 /ZYw== 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=6qmNJU/8i/AHYRLowbaJaGkE1pf99MU0Fm8e4I+JI0Y=; b=STrzBxWfaEBJlEg0/BT8+ckCPRn1PGEHkrKQH+PDPsRzqZ8xhyROjDOb5vFBMi8FdH 0carfY1+sV1Zvg3dV4XeoNnRV4nLXC3xf8ImYNQ2Ew/zQFmDXnWRDbrkpCpZgaMA8oYf lDdyHgcHzOas6zvbO2E3hkV/5g9JftX4HYjG8DRCAGDta3dLXEbME0ZqiSaW9DQonwaO YqOULrnn/ryfQBQLLSHtaYIiZ9GZrbk7/vTW6IGJngp4z4L/85vWL6xW8GvWnbFV60v+ H5pOG3oVIkPMImxvm5kfXEBDcuH3VdW7ou602T1y6VuU+KyaTmNL61H8CBPdOCw4xC1j fI6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pPnwnv3Y; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c17si13749437edc.384.2019.11.12.14.10.42; Tue, 12 Nov 2019 14:11:06 -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=@google.com header.s=20161025 header.b=pPnwnv3Y; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbfKLWHR (ORCPT + 99 others); Tue, 12 Nov 2019 17:07:17 -0500 Received: from mail-il1-f177.google.com ([209.85.166.177]:44679 "EHLO mail-il1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbfKLWHR (ORCPT ); Tue, 12 Nov 2019 17:07:17 -0500 Received: by mail-il1-f177.google.com with SMTP id i6so17025843ilr.11 for ; Tue, 12 Nov 2019 14:07:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6qmNJU/8i/AHYRLowbaJaGkE1pf99MU0Fm8e4I+JI0Y=; b=pPnwnv3YVdwiRnyPsDGGxdNvbSgcWNX7wPpXt/1YuUKOFpcsyzF+WY/N6zbmiBuWCE 45mXuAF6aLBdDLTPAn9VLVo5qJ40hrv42lGyfc4U1pGIO2wmfn6VpeJAnY/zcVU4mh+s mVGzvDdnXYJMAN4lyDvpB1ni02yC9OzpwxbNGlWGHtQwZCQxxQzuDJTWnRu4jSj8xpX+ eYqE+nGqB7r0lPY92UjTJylbr4yCBrlvlCMLaeqQ1Bs/sNeYkpRGlSU/L9qjVJRNd1Vl tsctlaHmh3RBbi8470QUu6ain1HAbYJkpMSf0v11tOj4wuXgcPrytSEYSa6w+iLzd+I8 155w== 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=6qmNJU/8i/AHYRLowbaJaGkE1pf99MU0Fm8e4I+JI0Y=; b=kvmNP0Q+P/T1KqAlIWq/SpAH7HHnPb731TGG5o6qY3Cxxg7eZkXF9pt1IZmx1Ns0Rj axv7Eq0EdlZLo8HlU/yWzo7S+kQr7CR+psOeePyOXCPUSGoBE33eV+7T7jV9dGTrRJ/P YxMTdonm+ZPxxIHUIr6FEnbok33tJvnsubfKZN6N9j6cd/l3ZMmkvKUyUecH0WCFLCXV iF6QqnPbD71e9vA2yvLuHvSdhQfqTokjea+SLES361ATJ9en0kT6aoqtgLv/jQGXL2au 2pit10kvFDoUgxTZ1CDv2yoOdGWenXpGPTV4rydzXsbDOs7+OJc9syTRoRD1cigXQHg1 WI4w== X-Gm-Message-State: APjAAAVieL0c0KH6FhRHD8Ck3BPvH4sa+L8m/DfBeFP93VDvadgcbD+7 h1hin49DkmmxVI8Ryj5/1Mc1rnA+fj9CQ1qE86NQcA== X-Received: by 2002:a92:ba1b:: with SMTP id o27mr147642ili.269.1573596435824; Tue, 12 Nov 2019 14:07:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Eric Dumazet Date: Tue, 12 Nov 2019 14:07:03 -0800 Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Alan Stern Cc: Linus Torvalds , Marco Elver , 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 1:48 PM Alan Stern wrote: > > 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. > I would prefer some kind of explicit marking, instead of a comment. Even if we prefer having a sane compiler, having these clearly annotated can help code readability quite a lot. /* * To use when we are ok with minor races... bla bla bla */ static void inline add_relaxed(int *p, int x) { x += __atomic_load_n(p, __ATOMIC_RELAXED); __atomic_store_n(p, x, __ATOMIC_RELAXED); } The actual implementation might depend on the compiler, and revert to something without any constraint for old compilers : *p += x;