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 413EDC433DB for ; Tue, 12 Jan 2021 19:51:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DAD12206C3 for ; Tue, 12 Jan 2021 19:51:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DAD12206C3 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 458A36B00B5; Tue, 12 Jan 2021 14:51:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 408D96B00B6; Tue, 12 Jan 2021 14:51:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F6A76B00B7; Tue, 12 Jan 2021 14:51:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 191296B00B5 for ; Tue, 12 Jan 2021 14:51:07 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D872C824556B for ; Tue, 12 Jan 2021 19:51:06 +0000 (UTC) X-FDA: 77698166532.08.shame79_2200e9927518 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id AD2EF1819E769 for ; Tue, 12 Jan 2021 19:51:06 +0000 (UTC) X-HE-Tag: shame79_2200e9927518 X-Filterd-Recvd-Size: 4484 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 19:51:06 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id v3so1962346plz.13 for ; Tue, 12 Jan 2021 11:51:06 -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=DCxpZYyPI/Y3trjmBrRTDlsX92cIUAx7GVVWW0wsbxI=; b=dl6ZgRi9ij44HXmd2XU7K74XFPFFHQ6YbWi5O5gtBlRtrWztUCSGWdyWd+3qeguTVs 8tn/vz/z3VLBofexzZYp03t4+c0mFqWJoc0csBZYoKkLJ3JGts4ME74sNY123M7y2rC+ 5B4ek1KX33mZIajq+a7cjKFHJd4QVo2yEg0f6RDZxHLTiYe2d0i0qEQwm2+MkKzDQVi3 4gLqtT6hY2OeQVnKtwrz+8qv72YHCa9sO7tFhF11ef3YJ6+kevbzCYJLr4SCNt35f7T0 E0+A2t6syBvdnbQ0mT+VmtGInIGpgWRN+TMo8tve8ta7kbdgSbDLPB+X6Aqee2oDqNAj T7qQ== 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=DCxpZYyPI/Y3trjmBrRTDlsX92cIUAx7GVVWW0wsbxI=; b=epSv1B/e6iSD8nyuuzQPEuCUfamGNDPPzfNjfLfbkbOvaLG2/HqabGugH+yXIcBpQ6 LsQxjJLNElvsxxhyk4OzwI9mkou/w+VZyDsQcgMIYlAAGCB69lmNOP07s0Vc56hhjM0F 2VBVSqLYo86oxPcg/MMGxv1ExL7PGjvETswryOOa4msb7p8rgBWS0/0b0/7uuftua2l2 2iPaXSmq3z2rl1RdRFeW3iWQ4kfMxXhmRy1R5BYCcexKPkTLJR1AzIC4nks6iGIb0eYB mtiZp6CtheHtJlvMIheRtkN2P4XX8W68hudYUR7aqN5pyPK1cdQMVHvlIGs50Vcx32Sq JJCQ== X-Gm-Message-State: AOAM530OCaefji+9wVqLWXRFMF19wE/psVKnHATUxt59yPPUisroF89R 5IyoIZHKHPtUDForMuCJoDENafPY+wqJsws48PCpXQ== X-Google-Smtp-Source: ABdhPJxGJE1yS/s9s+ksrWctiL27QxvN6soZWFglHG4SDVeKOCR+wRpE5ZKzd/h5wic0rNwapIWBKsY2pZ4didhM1DU= X-Received: by 2002:a17:90a:f683:: with SMTP id cl3mr792157pjb.136.1610481065204; Tue, 12 Jan 2021 11:51:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Tue, 12 Jan 2021 20:50:54 +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 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. > 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. Will add a comment in v2, thanks!