Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp605042ybv; Fri, 7 Feb 2020 05:20:41 -0800 (PST) X-Google-Smtp-Source: APXvYqx1Y6+MGNcSkHRVnOq6wqN/ER9PbkFQ7XdM6AVRJAOSTQt3NEfmYwBoziwprRddQhaccA4K X-Received: by 2002:a05:6808:4cc:: with SMTP id a12mr2105425oie.115.1581081641509; Fri, 07 Feb 2020 05:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581081641; cv=none; d=google.com; s=arc-20160816; b=t+IOGnrDUwkuYkjLDl6rxolqGzNybtYAkHwop2+l2GxwJm4Stbh7Uow+9E5bKi0O6X SbvV6MYTY2ktiBaiK4kNWqG5JdfseItd1r5c3C+EubDRQLcsNBTk+v6xELVJs0d00znT cy7Dg96gReYzL00D3Sk4GJA3fw1BpwwivQr0PUVu+wBg5+9Wsd2qwj3RgV1jNFavjK6I k4944sd21R1PwrBxkIUtOc52OeSGdxoVDC15tItR1ouClWfvoZ8gyHdzrVTxtXKH17n5 vWghQmHop+w4Kh7U1tuBUMuBwIBuCldCev0RfV8Ryprt4PnMdie/KKGO02wfrCXBBGPN gRwQ== 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=AppHa1mPfAaiV/SFjOWJnS9mSSWNJs8o2NmtKzYnLIM=; b=OKssfyTYBSHJsSHr9kbxmqbPphS6cHeaPN4fs3fFef9wnXT/JopgmmhtrnNuoBa11c ACbakbuvr/oZXGuCygsxg1g3J8ykCMmAnz2xP8q2wLWEtcSo/7/Du0kFIiABBcFqsLDM ZcI6y0demIIQmHfCU5n24fKycqsO7eAlO1iXrqLmDSoku8zCk7Sa0zAn3RWTjqYGlVph ZYoYY4tWODhlhGYAGebDfTAxuxuuHMXOd5OjQgteCMU/6MRl0YHvPJ2g9AwywobejKQ2 Jk0IMVbXpgakQuQ2JLnhEMR0O58JtBHoUaufFe/+pD68dvRB0ouFhMlyMvmxIsVkasi6 6mcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Bv7+O0Gj; 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 x20si1636038otq.222.2020.02.07.05.20.28; Fri, 07 Feb 2020 05:20:41 -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=Bv7+O0Gj; 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 S1727372AbgBGNST (ORCPT + 99 others); Fri, 7 Feb 2020 08:18:19 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:42432 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726874AbgBGNST (ORCPT ); Fri, 7 Feb 2020 08:18:19 -0500 Received: by mail-ot1-f68.google.com with SMTP id 66so2079662otd.9 for ; Fri, 07 Feb 2020 05:18:18 -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=AppHa1mPfAaiV/SFjOWJnS9mSSWNJs8o2NmtKzYnLIM=; b=Bv7+O0Gj9xzAxmxTKrE64kVHWDzLjK/48wyrFk5pv+zPmbR8MwZx8Mq9HSymH0TL+F gBqs2In+xlRc+Bc4Y3A2710Y+mDoCmsm5Phl1ZyDdMonr92CewoH05FNxI7b4vSIuyxp 01lpriTCHmxoLgRRDZdAmRB+ZZ8RtnEgjuAQNztgMRWCX+hr/TL8mYBbbU5FXaN+TYJi KpzEQnEJ/41S/hjd77bv20LD4OrgAjU8T22ThyKEIhiFLJ57CKdXyqWOkUyzlhxaqZpY TSsDfTZeYUgJwDsJJDso9uDZ2kKP4XcI+ZUVnBB9mu0z6TAaTBIr+a3oOsrAlpGO/A6m HokA== 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=AppHa1mPfAaiV/SFjOWJnS9mSSWNJs8o2NmtKzYnLIM=; b=svI8KfJoJtNQfEPukb5yq6rQVG2NoKLDPHJN9RXugvx8or71ZL6HoNccrUnkKbK3nH CF6urptb9q151nPI6fhWVnTb82tMqaKwWPdigHwHsyVJ+2gkEwLsfMpSBmz9dRn6Aftn OtqWUSc9dLxclLJ6VxuWr8YKbcwH/GFOgZVhnWhHe9Mlu1heIlRjSm2ekiAQ0xLOxL5n 9avoaWuEyj1ms+V5QQQLQ+jB8EVWboExedGuBUAjC9Sv/SSa/Pm6x2vu9BY67zhiTaJ1 Rcwl0kvzAm3kmq2dybsPM3lHaNz6kSDZ1U9O/4o775zF+al3iabrt4wZNnRvK+DCcMoi C1xg== X-Gm-Message-State: APjAAAX/zGYkAoqhaxDl1bsaxWN3u1aO8tJo1vPVkZgbeGQebi4Isd+C xcvMVMM3mx1qOWtcyDjkYSxLQ5rWCJbMyvbg0AHVYQ== X-Received: by 2002:a9d:7410:: with SMTP id n16mr2746790otk.23.1581081497948; Fri, 07 Feb 2020 05:18:17 -0800 (PST) MIME-Version: 1.0 References: <20200206035235.2537-1-cai@lca.pw> <480a7dde-f678-c07b-2231-4da8e0a38753@nvidia.com> <1580997681.7365.14.camel@lca.pw> <423eb3c6-6db2-87d2-e0b7-a32600ee1cd4@nvidia.com> In-Reply-To: <423eb3c6-6db2-87d2-e0b7-a32600ee1cd4@nvidia.com> From: Marco Elver Date: Fri, 7 Feb 2020 14:18:06 +0100 Message-ID: Subject: Re: [PATCH -next] mm: mark a intentional data race in page_zonenum() To: John Hubbard Cc: Qian Cai , Andrew Morton , ira.weiny@intel.com, dan.j.williams@intel.com, jack@suse.cz, Linux Memory Management List , LKML 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 Fri, 7 Feb 2020 at 00:18, John Hubbard wrote: > > On 2/6/20 6:35 AM, Marco Elver wrote: > ... > >>>> diff --git a/include/linux/mm.h b/include/linux/mm.h > >>>> index 52269e56c514..cafccad584c2 100644 > >>>> --- a/include/linux/mm.h > >>>> +++ b/include/linux/mm.h > >>>> @@ -920,7 +920,7 @@ vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf); > >>>> > >>>> static inline enum zone_type page_zonenum(const struct page *page) > >>>> { > >>>> - return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK; > >>>> + return data_race((page->flags >> ZONES_PGSHIFT) & ZONES_MASK); > >>> > >>> > >>> I don't know about this. Lots of the kernel is written to do this sort > >>> of thing, and adding a load of "data_race()" everywhere is...well, I'm not > >>> sure if it's really the best way. I wonder: could we maybe teach this > >>> kcsan thing to understand a few of the key idioms, particularly about page > >>> flags, instead of annotating all over the place? > >> > >> My understanding is that it is rather difficult to change the compilers, but it > >> is a good question and I Cc Marco who is the maintainer for KCSAN that might > >> give you a definite answer. > > > > The problem is that there is no general idiom where we could say with > > confidence that a data race is safe across the whole kernel. Here it > > Yes. I'm grasping at straws now, but...what about the idiom that page_zonenum() > uses: a set of bits that are "always" (after a certain early point) read-only? > What are your thoughts on that? I have replied to the other thread. Thanks, -- Marco > > might not matter, but somewhere else it might matter a lot. > > > > If you think that it turns out the entire file may be littered with > > 'data_race()', and you do not want to use annotations, you can > > blacklist the file. I already had to do this for other files in mm/, > > because concurrent flag modification/checking is pervasive and a lot > > of them seem 'benign'. We decided to revisit those files later. > > > > Feel free to add 'KCSAN_SANITIZE_memory.o := n' or whatever other > > files you think are full of these to mm/Makefile. > > > > The only problem I see with that is that it's not obvious what is > > concurrently modified and what isn't. The annotations would have > > helped document what is happening. > > > > Thanks, > > -- Marco > > > > > thanks, > -- > John Hubbard > NVIDIA