Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2952804ybk; Tue, 12 May 2020 12:10:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLt8w8ldymfgjVb/XdDEVubEcf8qcJJxbnNcs4gPhkzejMsKy56rsfg50Bagc9nZ6DWFVkU X-Received: by 2002:a50:dac4:: with SMTP id s4mr18435655edj.277.1589310612177; Tue, 12 May 2020 12:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589310612; cv=none; d=google.com; s=arc-20160816; b=MGwuEdGYipYiIiO3XWvvfX91vCiRDavllP00WUO+wHloZuQ3+LVBqBpP0ckkjupfYC TpW2SB+nTLjFVWkg5t8FRCVcwipVlFAa9E6Gvb5VYVcSv83UBsOsmon1eJoqDyWm4fM6 I9L1ptkoh5FH60HKdqNG4Et5j2frNGgjfuzeULtvgMBCo2UJ6bE2Tz/E8f/dgF4k35mc gks0JXy0r+6mdEeTPrZDR0SuVNWSzTtx751/ld3vULbGGw2Ht761EedCLaL0l9QNdzBH PGBSdLUZdpRyhd03X1N4QzmAEpgyItPJ8AbaNbKTt6+Nd+61rn8jVO95mHuvkzW8gzII bMMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RVdj44/VzSen6iR6rQOWCntv4FGd6/Yn4+ie5a9/Rko=; b=KdLOIo1mxuuRphWR4YBAvDoenEnaBCn4LR0opTw7o7LU0EYla38sDkLUkk5QbhiEeA +9DKa5Kjacf/ZO2bLKBc3jZL4MV6I2ZNro17oyRbwRXtBNQJKsmDLYlkD3A8LbWQixta gwnyE2rK+1tStzkC/i8TBWkSTfaNvnt2khqF+98PDkCaxafdmyr8ABFzD3xx0QZdWQgx Z3Vz1KuAAICEJy+zoCGDVjOvbu3FxfitCL4Fks4PIoaHPLhWjTOlBLPu8HvdhCNi77Ah SM5aB0L9AY1vFc+iN1QCt5Mtz2qPRUVtgwVVr7TApD2jJgozFQDKlXJaYJc7+6ZOW0v8 e5ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qKZiXMSg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si8645234eds.361.2020.05.12.12.09.47; Tue, 12 May 2020 12:10:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qKZiXMSg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727825AbgELTIE (ORCPT + 99 others); Tue, 12 May 2020 15:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbgELTID (ORCPT ); Tue, 12 May 2020 15:08:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C91C061A0C for ; Tue, 12 May 2020 12:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RVdj44/VzSen6iR6rQOWCntv4FGd6/Yn4+ie5a9/Rko=; b=qKZiXMSgcjdtQ6CmvZLKE2h6sw HHpe7Vgsdlq9c+mtnM9CFRMqxVnqgdOeWNVOwPVnF503dAs5Nag1VCtPV9NKrgnWlC0/3GoEXcdOd WnDUmVQrHJ+01SxntoNQBTRcY26ZbJWiKcLFCP2v8+najyvWAzjUeEkisNB1QpBnUtcyq5OgQH+HA nd7sY86AuC2JcsxzEANyGeJKmZHogaWD8kcu1hNHjX/uB7Gv30BUKfqTtZhm8FfMYlV3uLacmkXoR 7kDJI2LMLrq9sI8nvfHXBk58E0wnnnVHfsaRxLyk+zCxlsBOT1kOUzaBPLMUhCxrUwNm2B5exkFnO 9tnLKakg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYaFx-00013o-Pq; Tue, 12 May 2020 19:07:57 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4EFD8305EEF; Tue, 12 May 2020 21:07:55 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3A13628B27272; Tue, 12 May 2020 21:07:55 +0200 (CEST) Date: Tue, 12 May 2020 21:07:55 +0200 From: Peter Zijlstra To: Marco Elver Cc: Will Deacon , LKML , Thomas Gleixner , "Paul E. McKenney" , Ingo Molnar Subject: Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen Message-ID: <20200512190755.GL2957@hirez.programming.kicks-ass.net> References: <20200511204150.27858-1-will@kernel.org> <20200512081826.GE2978@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2020 at 07:53:00PM +0200, Marco Elver wrote: > I just ran a bunch of KCSAN tests. While this series alone would have > passed the tests, there appears to be a problem with > __READ_ONCE/__WRITE_ONCE. I think they should already be using > 'data_race()', as otherwise we will get lots of false positives in > future. > > I noticed this when testing -tip/locking/kcsan, which breaks > unfortunately, because I see a bunch of spurious data races with > arch_atomic_{read,set} because "locking/atomics: Flip fallbacks and > instrumentation" changed them to use __READ_ONCE()/__WRITE_ONCE(). > From what I see, the intent was to not double-instrument, > unfortunately they are still double-instrumented because > __READ_ONCE/__WRITE_ONCE doesn't hide the access from KCSAN (nor KASAN > actually). I don't think we can use __no_sanitize_or_inline for the > arch_ functions, because we really want them to be __always_inline > (also to avoid calls to these functions in uaccess regions, which > objtool would notice). > > I think the easiest way to resolve this is to wrap the accesses in > __*_ONCE with data_race(). But we can't... because I need arch_atomic_*() and __READ_ONCE() to not call out to _ANYTHING_. Sadly, because the compilers are 'broken' that whole __no_sanitize thing didn't work, but I'll be moving a whole bunch of code into .c files with all the sanitizers killed dead. And we'll be validating it'll not be calling out to anything. data_race() will include active calls to kcsan_{dis,en}able_current(), and this must not happen.