Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1714384rdb; Thu, 7 Dec 2023 07:03:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBy7TtYgRJruhjAhnk/MvEcmYeF0MGZQLJAwflZO5WNGyQs9tFtCt3I/YCCbGbSr19eVJI X-Received: by 2002:a05:6a20:da8f:b0:190:230:8e91 with SMTP id iy15-20020a056a20da8f00b0019002308e91mr1286857pzb.109.1701961419613; Thu, 07 Dec 2023 07:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701961419; cv=none; d=google.com; s=arc-20160816; b=RA/xytsOCWth404AR8tiFcLRbmgbap96I8NDhNl5WVtWWieeVHfdx0cBJquRdXfTZx VjtX0JH4WYf5jyBQzo1rGGZAPo85+Lz+haDwXu2X8E1JGDsppzGvPrNy+C/d7a+WeqS9 tJAkxlP84DBRoFdP910W6WLWvEmaxMgkpwiPZGdjqvxEKTaFnCQEI8s/DtsMK+Mv6mr3 FxFW7HZ2DD3F+bPR9ZTDVQtUexeYrAtNDPvSLXqRBmHFEsnTiMiGkUlJHBvX9/K2eVxz Gkt1dlEwIQbuqI4OqwrVpWrbAYsH3B7Bj/2Pk9wYw85bEyLzDW1/KkCUX3+FZckQUs8M pbVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=HHpJ84J22Q00U7BLS6EU+OE4WXCpc9+H+1qcnXVn080=; fh=XHJC3rNtFqy9NBdwfesynq0dG98cBzq8Qrv2Usg7GS0=; b=AQ/EW08qndFCW0grzs5bK/v4VolD+I89a1J+YTlmYA51a2v05Y41S9R9lNoxxpOIpL TI7A1rGscTyDhl+CfOWvsvGFyV7OVlPCLCbba/KTAnZ3ERGUFWtU1ZY17Hniz2AuauLP SpgIJ86af+JDzgNNo8AWK3tVsKxARByoenSJr6nFF6YxzzMFOLkjJ3vl5RDLVeh2oUQx gm18Zu5YO43wmoTM+rZBzeLkt2b3Um8N9lQ5GoLSnoQ1EXp5++ALnljpO2ln1Lpkb9k4 RKAS4UCWqBH87L2ocfffVTNxXN2o58ayu4k3le96h1wFIjtQhIckPcNnkDglW6Ej4tnB 22ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nGxEQcGi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n6-20020a056a0007c600b006ce060dba6esi1316756pfu.240.2023.12.07.07.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 07:03:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nGxEQcGi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7FD9D803D02F; Thu, 7 Dec 2023 07:03:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232940AbjLGPDL (ORCPT + 99 others); Thu, 7 Dec 2023 10:03:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232768AbjLGPDK (ORCPT ); Thu, 7 Dec 2023 10:03:10 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B49019A; Thu, 7 Dec 2023 07:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701961396; x=1733497396; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=oAuqsn7L4saZbJC5M9zu9VGIEPm+2LWdN9ym+6Wxgrc=; b=nGxEQcGiV01rG9dvpQZMwh/p7GTkF+o28ipmUr9GhzY1b4E4WBfmjkEy TWEWH5SyxWS+ghI6kZrzhgGyv8P5uPZZYUb+Ev+wcyqasX1L2RqfUSAB2 oYYl4bmrPAej+DJB4j9xnkqfV5E+19DDHTfUyb5gFOvi+rHezn4HjOMXG a3YP7WXutNLO/LqZbMLmeqnBXC9wM7QSvoGnwHHulrOFBT8++BkbF5mHJ sI7Hci9a38XLD7Ts5NnPa4nf2/BZDXT9I6mAvnLbkI1AUAjVZGelko830 BN8+36ph4CwV4KcZwV7L2An4tghnkuDjZ2WDwdpxnA2ierCiFhk/NAv9/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="374408758" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="374408758" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 07:03:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="915609992" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="915609992" Received: from dkrupnov-mobl3.ger.corp.intel.com ([10.249.34.6]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 07:03:14 -0800 Date: Thu, 7 Dec 2023 17:03:11 +0200 (EET) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Reinette Chatre cc: linux-kselftest@vger.kernel.org, Shuah Khan , Shaopeng Tan , =?ISO-8859-15?Q?Maciej_Wiecz=F3r-Retman?= , Fenghua Yu , LKML Subject: Re: [PATCH v2 17/26] selftests/resctrl: Replace file write with volatile variable In-Reply-To: <6358c720-66a9-4727-a74d-b56100f01ac4@intel.com> Message-ID: <7e373b7a-3d62-5eb1-c11f-70dd62293b97@linux.intel.com> References: <20231120111340.7805-1-ilpo.jarvinen@linux.intel.com> <20231120111340.7805-18-ilpo.jarvinen@linux.intel.com> <6358c720-66a9-4727-a74d-b56100f01ac4@intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1637657272-1701961395=:1765" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 07 Dec 2023 07:03:25 -0800 (PST) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1637657272-1701961395=:1765 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Tue, 28 Nov 2023, Reinette Chatre wrote: > On 11/20/2023 3:13 AM, Ilpo Järvinen wrote: > > The fill_buf code prevents compiler optimizating the entire read loop > > away by writing the final value of the variable into a file. While it > > achieves the goal, writing into a file requires significant amount of > > work within the innermost test loop and also error handling. > > > > A simpler approach is to take advantage of volatile. Writing to a > > variable through a volatile pointer is enough to prevent compiler from > > optimizing the write away, and therefore compiler cannot remove the > > read loop either. > > > > Add a volatile 'value_sink' into resctrl_tests.c and make fill_buf to > > write into it. As a result, the error handling in fill_buf.c can be > > simplified. > > > > The subject and changelog describes the need for a volatile variable. > The patch introduces two volatile variables. Could you please elaborate > why two volatile variables are needed? Well, the other "volatile variable" is a pointer to a volatile variable. I've seen gcc to kill a static volatile int so I prefer to not take change with its optimizer. Thus, I placed the sink into different compilation unit and just present a pointer to the actual "volatile" variable. I guess the sink could be marked as plain int instead but this being trickery to begin with I don't see much value either way. It's still a trick. I'll alter the changelog's wording though, "a volatile variable" is not accurate as it's "a pointer to a volatile variable". -- i. --8323329-1637657272-1701961395=:1765--