Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2904808ybk; Tue, 12 May 2020 10:57:11 -0700 (PDT) X-Google-Smtp-Source: APiQypJJXAToXTipJfe8/Azrmx96rPLjyjWxvpJbll1g4G9YBQu9bIqXZS9zpKEYFg2YQcusYMPg X-Received: by 2002:a17:907:42fe:: with SMTP id oa22mr18212971ejb.98.1589306231256; Tue, 12 May 2020 10:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589306231; cv=none; d=google.com; s=arc-20160816; b=Bk7cZ+qVHJgfC/2WAtlnHH1mY+p1cDrPCoHCq2y1pJ5UKdfX6pL21drM8WdCACEe0F BWVbNQL9z4qs68BbUCj9N0+sRGryzbNVLf3q6nTM7upqpqhoEfdN8zrMkbrqq3We4vjE YDh1oc5u3t5p0QF7Gu1FkZQMr+7vI+zIuZAx2P/U2VSZv1vjaZv4xdt8KoCQiPpCbg4E T2mWHGUeVulEwde0HkFDyJ3PPrl2tGPahzWAMUi0YlYX+xtXi8YRDYJfO3n0QvoB0zov eQOJq2AMJ0hpi5mzFuoeGLlqEgBtAvF8Fi0Z7FENjQs+8Ezo40jkfVgDs1F3/H9kOzS9 VlLQ== 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=NkOoyxp+KOfXBJgSgsmTbcJqNZ2GGnNdvXTFmavoPqM=; b=Xx8q5WOajKoCqty8nVxZ3AJ825ka88HQ0swkpbXhl7/K2LuHEbzd9AEcUkIZ32069u dL0gMBrLlczvXdB7ZK/USYeXcskIh2xvmNQc5BguHp1gPuHbizVfjV2cyGnfJFooNPzu MGoj04uw+bfGTj4fr5cUEiqMNBjNIX4q93ytOg36J/oVnkmJIQnaXaixMxKIlMPpFMeb EVT3fDBaBw5svAW1vih+ZcY34gp5DA9KTVB/Xa2sJ9yqVMPQ9e4Eent7t+q9kGGrSFrl NoWbLdVw8PQgTfl9HYUc9XVGeut/f/5piDhFb1JnzGj1IXvy3dirsJFugbeOv/O3WEbl iI6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cJXtddWT; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si8302856edj.601.2020.05.12.10.56.47; Tue, 12 May 2020 10:57:11 -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=pass header.i=@google.com header.s=20161025 header.b=cJXtddWT; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730201AbgELRxN (ORCPT + 99 others); Tue, 12 May 2020 13:53:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbgELRxM (ORCPT ); Tue, 12 May 2020 13:53:12 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C6C7C061A0C for ; Tue, 12 May 2020 10:53:12 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id 19so18991812oiy.8 for ; Tue, 12 May 2020 10:53:12 -0700 (PDT) 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=NkOoyxp+KOfXBJgSgsmTbcJqNZ2GGnNdvXTFmavoPqM=; b=cJXtddWTuDJRf+CmWTK1TB/ivAn0sQMUeBhtE5kBCZ5crRtq55EMpkXbCwDrWFdnG2 hw/jaxgXukOHTPwvYFbv5bhgRwrMwTf9T7YxLz/pgY6ngXJcMWcQnRi6fpXVWarUAkf1 T9m1woadtB13mx35loE0yBtMOqsFfGNBmGCXcty1tKKbQ7qxfsAxTIn8H+P0kaqcXCkc Gs7IvOII9jlcgWojPmJmO+89TkRnzHVX+248d3y1wPUNdY3LBWbECFM9TdA+YcUOzIXS QJz7fEBPgG3qmasdKr6psI5Pmw9WTOiPeWGPQyGUiL8b0l8JJWv5jccf5FeWT5jsOpCT lbhA== 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=NkOoyxp+KOfXBJgSgsmTbcJqNZ2GGnNdvXTFmavoPqM=; b=nG3QyHORxLcWusU3ou2YZ51i+R6jLMnshJ4Xkim2vuHOsndYl7edmxzji3OWinseST O7c0/LQkBuOBPV+EPnUXPi0gawrSsHGhh8oTean+K4mV/sLGWgj0daNOMdZIKzN8fcvn HCRCCyguECmaEP+jbu5CeFGqTDm6gdec6uQ/SvqzQ9frWocs9944Zs3BCcXynS7GrJwl oKQzR3K+bfX1ulGir2BwllpiCF1FWUVwFN22uRlcS3oxwvtsxZPmTTZIUFKdJwbwE6E+ 9a399w/IQnFhD5oPl4v5im8F9mvdrkIPMU1H21I3+iU3I4+uSzCRCaAjK+ztUOBo7T0E J+xQ== X-Gm-Message-State: AGi0Pub2yi93mDhW41fWHdMlNNWZ4GtdM+ZFRrBXe3A4T1xeIy4VSN+C xJ7yBolv1bpje4HkWf4Qp9e40dKtt0pNKz3PEo8wFA== X-Received: by 2002:a05:6808:b36:: with SMTP id t22mr24884545oij.121.1589305991490; Tue, 12 May 2020 10:53:11 -0700 (PDT) MIME-Version: 1.0 References: <20200511204150.27858-1-will@kernel.org> <20200512081826.GE2978@hirez.programming.kicks-ass.net> In-Reply-To: <20200512081826.GE2978@hirez.programming.kicks-ass.net> From: Marco Elver Date: Tue, 12 May 2020 19:53:00 +0200 Message-ID: Subject: Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen To: Peter Zijlstra Cc: Will Deacon , LKML , Thomas Gleixner , "Paul E. McKenney" , Ingo Molnar 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, 12 May 2020 at 10:18, Peter Zijlstra wrote: > > On Mon, May 11, 2020 at 09:41:32PM +0100, Will Deacon wrote: > > Hi folks, > > > > (trimmed CC list since v4 since this is largely just a rebase) > > > > This is version five of the READ_ONCE() codegen improvement series that > > I've previously posted here: > > > > RFC: https://lore.kernel.org/lkml/20200110165636.28035-1-will@kernel.org > > v2: https://lore.kernel.org/lkml/20200123153341.19947-1-will@kernel.org > > v3: https://lore.kernel.org/lkml/20200415165218.20251-1-will@kernel.org > > v4: https://lore.kernel.org/lkml/20200421151537.19241-1-will@kernel.org > > > > The main change since v4 is that this is now based on top of the KCSAN > > changes queued in -tip (locking/kcsan) and therefore contains the patches > > necessary to avoid breaking sparc32 as well as some cleanups to > > consolidate {READ,WRITE}_ONCE() and data_race(). > > > > Other changes include: > > > > * Treat 'char' as distinct from 'signed char' and 'unsigned char' for > > __builtin_types_compatible_p() > > > > * Add a compile-time assertion that the argument to READ_ONCE_NOCHECK() > > points at something the same size as 'unsigned long' > > > > I'm happy for all of this to go via -tip, or I can take it via arm64. > > Looks good to me; Thanks! > > Acked-by: Peter Zijlstra (Intel) 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(). Thanks, -- Marco