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 3B114C433DB for ; Tue, 12 Jan 2021 19:51:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E71522202 for ; Tue, 12 Jan 2021 19:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436654AbhALTvq (ORCPT ); Tue, 12 Jan 2021 14:51:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392194AbhALTvq (ORCPT ); Tue, 12 Jan 2021 14:51:46 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7312C061575 for ; Tue, 12 Jan 2021 11:51:05 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id be12so1990041plb.4 for ; Tue, 12 Jan 2021 11:51:05 -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=o2J1OrP8wvlwkHQyYvSZC1tXGilaMTyDyPNhDzm4YeKaHbavINWcQsub0wiGYBRhBV 1g+DAsawPIqMbp9Z6sg1ah+xS9Dmo6hzyLbbEQPxfvsQZjJ2sua7twc282WsQ+WETlY1 nqT9IIhRBn+y6oBlRu2By5OsjIrgenR6Hf4N2n1gwhrqbbTLapltliLrIIgTUzsuAxMs XGh55OiiEwhFqaPZVeSCYq9RoeYn2PpuzmKaPeyTqglqld4gOYqNf8v0/Qi38RZ1QncX jRnL4PJHcfElJkyZf6no550zINU2rwkZsc6EtmykgxDQES7c08ZWwFGpiNkOvYxqTBkS GUVA== X-Gm-Message-State: AOAM531Gq8BjxKjCQmF6h5bNU4DnClwYWuRWUskADxpQjaz3y5cuPFrf mibW2vHo99dxNOw6aEBNsuLpqVh+18pP7B46QKemHg== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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! 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! 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=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 3DF6AC433E0 for ; Tue, 12 Jan 2021 19:53:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC0A5206C3 for ; Tue, 12 Jan 2021 19:53:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC0A5206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jXbPjH6z6DrC7ynWxMpm6dQ36wDljQceuL0G1ath/DY=; b=GJs6MeRvHoLwe5kPryWHFTebr OpHNhsK30FZQF35cswl5YZSF5tcuiSw+V5NBRUnfmLrb5Zl06AWgZFj+FdyCx1vs48O1yPq/KiTqk rl6qCxt95WWpC1IK+vKAzZAYMeZl1b0iD22E9TD+oYOejHlaQlrTd/HNdX0az9oil2RRSPEGKiz5R UC4+8vrK5uNM+nhkOGbvUgzc7k73nciLoXgFnpPU7nnO4Lo5uH+eCDtlbVVvj3HA/L8lnvfJ7XXM4 8ZNu/+/s+BwMqMR1LJSmmeXeVc3X8CbmEuPc+VEc3fIzV/ofDrP710HKso8Y0Op20hiCz/g0ul61n OU2HNcwBw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzPhE-0004zA-UF; Tue, 12 Jan 2021 19:51:17 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzPh5-0004wR-NR for linux-arm-kernel@lists.infradead.org; Tue, 12 Jan 2021 19:51:08 +0000 Received: by mail-pl1-x633.google.com with SMTP id x12so1967333plr.10 for ; Tue, 12 Jan 2021 11:51:07 -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=aNIdEve+6fzzM5hJixjpBruhlnqa/ttj2pL5lkAMNxsPpqVJx9XYzT1wWdkggPcZ7y vmKi3i4lvLIPRMiozqJAD8a4dQwPak5QN+b4GT/Og9o8zPO+HrsEaq/bSJQE4iGwJiPg XrRMsY9534vxqvvsgg0MKZnqcZctni0YTbUG1V85NkbDyk+T67ZCb86mawZ7TVaGSi1I p56d85nCeYrQfiAzdjTsfzHsFoBJLAyVelHlYvumH9xhneKCjaXTYsGV38QgslD/FTnO nD2sWOmx99w0lIYP23RyugsTDHtusejW8+EyO1Ff5e9rbzGBgUnKAWADg4edvszKxbo0 rWpw== X-Gm-Message-State: AOAM533eXYZ5x2i5KsV9vvEEI0hTFE/anSpJHZLmIeMMLvNGWWvnO/WO XnP1uLj3JmaR7D3HwTZZEXmSaX6My6zl8NlwErBldw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210112_145107_854564_18E5938A X-CRM114-Status: GOOD ( 17.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux ARM , Marco Elver , Catalin Marinas , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev , LKML , Linux Memory Management List , Evgenii Stepanov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Dmitry Vyukov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel