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 9D9B0C433DB for ; Tue, 12 Jan 2021 19:57:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A47A22202 for ; Tue, 12 Jan 2021 19:57:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A47A22202 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 94F956B00BC; Tue, 12 Jan 2021 14:57:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 925076B00BD; Tue, 12 Jan 2021 14:57:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 862746B00BE; Tue, 12 Jan 2021 14:57:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id 71E656B00BC for ; Tue, 12 Jan 2021 14:57:16 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 372E0180AD82F for ; Tue, 12 Jan 2021 19:57:16 +0000 (UTC) X-FDA: 77698182072.16.land87_2e1724d27518 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 14B68100E690B for ; Tue, 12 Jan 2021 19:57:16 +0000 (UTC) X-HE-Tag: land87_2e1724d27518 X-Filterd-Recvd-Size: 4545 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 19:57:15 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id v3so1971534plz.13 for ; Tue, 12 Jan 2021 11:57:15 -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=lgOj3ewtZHsgYpuiLe3BFwKHrGEWEDXGYzULDKuvxQQ=; b=j+uYJ02WLo/yAEwfWyCdG4VHNmT3d87J+yhNRugdeCR3VR74kMt+9flAkqaGRXVoSd IWyobA1CBIm8NYdKVJAy0GdW+uGncU041V2g+am/rMSaQ6QKifzmjQsAQ5Mjf+3DfrrB WStfn8/6JqwjOY9DRkVD+q2R9XhTU+rO8sTKIuc0SRhVEHYw6lJrR0l7spq5p11wmk1u /3N8zSXDBgz7i0sT4bvzeFbzD0rZrtexdCIICbt4dImj+EIwDlRryReYNgc61fobKcYk 2P1lW3u+KNrjpV/n5z9uA9GIy11EdctesXfeOdFeG6mZM3u7X9cBqQtphBi1aMt0VEHz Azwg== 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=lgOj3ewtZHsgYpuiLe3BFwKHrGEWEDXGYzULDKuvxQQ=; b=C1o6Q8Cs9vlLOsyaIM3kmhYj1RdpVq7MeRR0navop8s7hILvs0PpNFAWWQYQmO6kkj AiQDqstdAMBPz1gfquzoeai5fAJMEwSvSHIl/afn6/HdMejOaQN71EEhGM0gmJCgP7JI pjMqDLDhFt/Sxy2xwhv7VKwihSI07upBpd9lDFgGBy9Dpj9/9Je5Rc0U2YE8JGa9bK9O d/tGx61IKV0EnXy0DVDWFiNwxYsX/dbWd5Ye+4EaEzzSIEAB4VickdY93kbmMrC83i7/ 1LBlGGfY1uQta/YM0P3VCdRJWf1lKe0gypQ+Qr6vkrLDkyeH0bYD0vsFp5Ckk6iGEHFe zRWQ== X-Gm-Message-State: AOAM532ATdr6KHcBA1uxqwGZjxQ+5qVgZopy2LB4i2z9XDFgqDxKsczl SL/nRq9ha/CM9sVIkZWiYcMJ2fFrpCG0QnkvoTNx/g== X-Google-Smtp-Source: ABdhPJxI0QGOzv5kpWUwTH2+9PK5o9lI0ts3/aC2qseS8/cQtBU9A8LRgrhYiNGzhreGwNSlfT3z+6wp8m/08MXvN2k= X-Received: by 2002:a17:90a:f683:: with SMTP id cl3mr813985pjb.136.1610481434518; Tue, 12 Jan 2021 11:57:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Tue, 12 Jan 2021 20:57:03 +0100 Message-ID: Subject: Re: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL To: Alexander Potapenko 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 12, 2021 at 8:50 PM Andrey Konovalov wrote: > > On Tue, Jan 12, 2021 at 9:18 AM Alexander Potapenko wrote: > > > > 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? > > Yes. > > > Are these accesses to fail_data that are optimized (in which case we > > could make it volatile)? > > Yes. AFAIU compiler doesn't expect expression to change fail_data > fields, no those accesses and checks are optimized away. Ah, actually no, it reorders the expression and puts it after fail_data fields checks. That's why I put the barriers. > > Note that compiler barriers won't probably help against removing > > memory accesses, they only prevent reordering. But using WRITE/READ_ONCE() might also be a good idea, as technically the compiler can optimize away the accesses.