From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0757C433E0 for ; Tue, 12 Jan 2021 08:18:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0870022D58 for ; Tue, 12 Jan 2021 08:18:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0870022D58 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 374C18D0072; Tue, 12 Jan 2021 03:18:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 324C18D0051; Tue, 12 Jan 2021 03:18:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 213808D0072; Tue, 12 Jan 2021 03:18:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 07F068D0051 for ; Tue, 12 Jan 2021 03:18:37 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B0F373622 for ; Tue, 12 Jan 2021 08:18:36 +0000 (UTC) X-FDA: 77696421432.16.test25_020ab2327513 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 8D866100E6903 for ; Tue, 12 Jan 2021 08:18:36 +0000 (UTC) X-HE-Tag: test25_020ab2327513 X-Filterd-Recvd-Size: 4159 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 08:18:36 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id z20so1069484qtq.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=iybQsVHDDFwriAB6FSNLgm6Bh8tB0kdnfAcUfVPIq9ty3F30CuGUrIiC1xiPlGiS50 rnOl24LsaFn7JwLk/FuNXZO7r/dOF1WCTiZWwhNvlBiVKSCPRyGZUbhO38d6BJFH5I0n aH9lH0pXtWsC0YlZrHYBjRTDqJnr9oGK/MAmyxx3IpPcgZFxV/BRno0O1xSQdI7ATVXK k3YBsPvVNs1oyhQgBkIzN7ys0RKgSwGticgohNSHRvgQkJMeaVmXt06nCK+fDI0TV9hE kCcJWl4Z4AzYeEDv6WuTJ7Qg/TdXHEo2BVmCPIR6/KSdplAgsfJJjcjd9lfkqqNtZZbs KS8A== X-Gm-Message-State: AOAM533RqjbdulEPZPUUTRKwNft5bkNlHj6WBZWLYOo+O4CBVpFehvDR +YkV1Lu07G6Hdoscc9XG+wfSJYQh66XQOco+L9fQOw== X-Google-Smtp-Source: ABdhPJwDvS6XK8nVNZVXoR6ZYl97fk9N3dt0lEOcbwDGnr9y6hCPY5xR/Akfv7n+oIdi7Btxwd7tfnhfavX3rRpl01g= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.