Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2992075pxb; Tue, 12 Jan 2021 03:48:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxxgqAGuDgzL8x7hBngbLWqqt772nIaxDT95puT+KeXGNCe065/CKz7LbZ3Bh5UFaMj+jR X-Received: by 2002:aa7:c919:: with SMTP id b25mr2953060edt.108.1610452109763; Tue, 12 Jan 2021 03:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610452109; cv=none; d=google.com; s=arc-20160816; b=pdTnJPoRI83gDAoRKsaL3qTn1PnHWnAlR8MfOrKgWtSMdqPuGcK6GF35NWXU3kwTyL zlQHi3gy6q3x1SelN+IM8V/YMv07yEIoGA6TmQ/6H+Cd/zzeU9U9JGWk5ygb63BeTIQn EnSZDrnUmqVJridE072ApvG4LNsRJfloAXPl6U7dPwrfhFD6NG8F7znG4+xQ34T/KsoN TmNur5tgyMW/VUprFm/3wB8KfvV6Z+tJiJlrNKJQQZoXCUji4/xILdMROoP2gIA5409Y o8H6KMGTIOPBKRop8NE67PrcemcIRLi4mr1ifBaE52ie6kP6EmITXxOblH+bg2uQ5MoM hhSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2O4oVCcY5rd2IeP/z10VBhkIJpOFPjzFWez+q+L4HJw=; b=enl/SFpqO9XsDZG7IccN1ghcz3QhcLDfkQLFtHSz0xB5AF2jC55iMcQ04EcP+P4PTx MA5AO3xm8eyAm+X+Tve+rS6T+AUy8rJda4qNkYIwYMDKAafKxiJBegSoR7mIAakPZFqf 7gVf131/SOeDjJSMo8NinMGu4WLfE9f6oa3J6WN/On988O0TAKb163eNDBldYcKuNwkN Ya+krEoMpdu2B04SgcujqPW7opiyfV8hfBNAqL5WLayfaoy1w4nDW+lhyIPhzmpK2kY9 pOmE3G4V65QQozAhkwX+R6s7lupEnTeuUQJ6CwluCUJZRLoZGlJQrZ8fx02rg8Cs/QNr xnXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vUtmN33h; 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 n22si1180845edb.427.2021.01.12.03.48.06; Tue, 12 Jan 2021 03:48:29 -0800 (PST) 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=vUtmN33h; 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 S2392282AbhALITT (ORCPT + 99 others); Tue, 12 Jan 2021 03:19:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392247AbhALITS (ORCPT ); Tue, 12 Jan 2021 03:19:18 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44205C061794 for ; Tue, 12 Jan 2021 00:18:36 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id z20so1069482qtq.3 for ; Tue, 12 Jan 2021 00:18:36 -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=2O4oVCcY5rd2IeP/z10VBhkIJpOFPjzFWez+q+L4HJw=; b=vUtmN33he1absWSIk8T5Hy/Rn2xKLJBbD3vu62LbyvKvQrutrL+COtZNriH2/oqwKb +1T4Ds7sEblVyoTZRJvoYXkCy/bCMZbotiya2xYYphm6bW96Ok1+MInaL/093FxWbdu1 DJmP+uPuvS/rGfZ21DJEdwRMPjbBxGRMUtXY0d/xX+GqqYSZ7SpsFf9/VIyUEB5zNY2N yfcZFwZeGPWz6hUDq/VV+3qnU9AdllYux0Cy/9h8WS6gxk8gPKRzU4P02Zop1h3PprjH viczQ1ojLSDC6A5Fhdbfxezk9ovpaFTADg/6fMoKRhTl08ThOFOL1S3IdBmVWijZLH4x kdcA== 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=2O4oVCcY5rd2IeP/z10VBhkIJpOFPjzFWez+q+L4HJw=; b=gBStDHquZOrLPYQwep+xmphVUS8BiOVBePzIX+I7o7/XLTUNw44LTr4zjptJQGAtqL 4yQieREtoNKuc8Qu1Vv8zOdBLmHKPDo/dg2kPkIae7EkD1RrtwG4QKPVlG2I2tn2RkwP USSE+Cs990JIxKU/w4x1eV+cH0/0mJa6kCska+ReYCQ0ebWzYooNt3mKSdAoWHIevPX+ aKKsowf9Up4tYepcfn91EogTcLsjlSizjtmZZ6WiAiqFyhMttcpH4i1O8dYReBOJwT4d I1/bJPDu0RnT1bfR0I9jnG2ir/ng9XiUrYz9myk8OhpMvvREGVRaHYggPYO/qauWWf2Y eK5Q== X-Gm-Message-State: AOAM531opo4hQvvA6aDzgD/Ft1EjWxXNWfV5YSQETCN8KGTK2H/Agj22 zXEG8O0CX5bDH8IujJasgWIrBwhlLeY08TzNG9H79g== X-Received: by 2002:ac8:7512:: with SMTP id u18mr3452445qtq.300.1610439515331; Tue, 12 Jan 2021 00:18:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Alexander Potapenko Date: Tue, 12 Jan 2021 09:18:24 +0100 Message-ID: Subject: Re: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL To: Andrey Konovalov Cc: Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Marco Elver , Andrew Morton , Will Deacon , Andrey Ryabinin , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov wrote: > > It might not be obvious to the compiler that the expression must be > executed between writing and reading to fail_data. In this case, the > compiler might reorder or optimize away some of the accesses, and > the tests will fail. Have you seen this happen in practice? Are these accesses to fail_data that are optimized (in which case we could make it volatile), or some part of the expression? Note that compiler barriers won't probably help against removing memory accesses, they only prevent reordering. > + barrier(); \ > expression; \ > + barrier(); \ The need for barriers is not obvious to the reader, so a comment in the code clarifying that would be nice.