Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2294516rdb; Sun, 11 Feb 2024 22:43:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXxWRVNyzmw5RgLjPijDMDpctE/IO5/0KpUhdgGm1NDbJIotQT6Me792ZVDPpDo1rfX1lh X-Received: by 2002:a67:f787:0:b0:46d:277e:48ea with SMTP id j7-20020a67f787000000b0046d277e48eamr4052285vso.4.1707720209355; Sun, 11 Feb 2024 22:43:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707720209; cv=pass; d=google.com; s=arc-20160816; b=psko5TxhrnWWGfKzlJjeuRFRz9yo3Ren4QJ7O0cQG0ZvZHj/Hwwrf8jRAbMNkAlpyj P4IMgu/VhpK14Or5WMSk33rBZsfzIXG3J5QYtvFhAJkBEi0STrcqjZ3+YIg8FGrz6Soh g09HHsV7jcp50scV6I46h+BW7LMkoFKLiGrFqzU0rvKFulhNxLbR0oTkV1jgMVdhF/K/ idPGUhM/c3UOIsEwUOtkFmv0N6Z2w8KEHrvOGl6O67jBOtXpv6W+ljL/LPB16Y4D1ZZD eYuysm0jS3Q+VLy5kpiYH2SD1OJc+R/YprE3+x1p0WubPiVaVCTYeHWlNbBbITCWS70J cV0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=pE8hgq1vhBtNg7caeXjy9NDkcEtYDM5NDGWtnD1mkLs=; fh=OSSTDgHhsjmryYKP9o0qebScbW9dOkgJmTXUxv403eA=; b=bjZev50EcbUqKFvvJalsRa4omj6Bq7Qz66+u30mduSbAD7wUxo83SyT2t1f+TC0NO4 kJkx6uiXpkLWzqrtBYX7S2RkTfjvss6keeY1yc0mZiPDXal+OJCHfRs5qDueuT7ymobK VjBFngVf5zvXOjt5sMway9ON2QxLHVP2jCLckeiT2QYqNFumzADc8GeCo0VzSdkY2vH1 +l7GvRb5qhKZViqMzG6g42XrRYDB9kkep2sWH3MshKLSgmo9PO9+30n32NovfDfNDF5G KjDXc1Fkocm1sM5xRFVHqrkqWprdJxS9xr0KhEtp7Br8Ob+YvaWIzbD13B/S0FXMLEom Oe9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UcKcjJ2f; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUi8s/Opf61DCXCX0fMrliaNoepgNiO1vG8dqwtp3MCYnl4IO0XyYYqoyjbPVrsbmxFujE4Bz1Q8DT4HbRPT6MnSyzoB78GKHv7OhKLQA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f7-20020ac84987000000b0042c69db0261si3960525qtq.275.2024.02.11.22.43.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 22:43:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UcKcjJ2f; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2178B1C222AF for ; Mon, 12 Feb 2024 06:43:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BCF8747F; Mon, 12 Feb 2024 06:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UcKcjJ2f" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44FC36FBE; Mon, 12 Feb 2024 06:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707720202; cv=none; b=N6YrHNMgzyr3oVWqduI+bE7dcFybKyQq5KFbem/slGsRIDiK/wl53XODUULk1W4W4ErKy4FC0BcUvEtSQps/BS4E7iGSB3LUHdCBf/XAD9j6pszGoG1pkDmEkT5J/57p/SEnyp8MCGlKCSSXWlZG2XcRG/gpsoihjyli7U7IVdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707720202; c=relaxed/simple; bh=JEaLXdeo6fNthLC6iDS4VCiLgLO+VSbXbp2Vu7m6SIc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gH9+ePchbsQzWi1iFLpsYudyVwUIxbhw/jl45lBJVmLGCYD9zS5VvptrjCwqEQKU9mxPNVztUdPu024u0jPpEZtZffyMPH3KJ188pkq60o6SIOJQwLhL3YGLGq2kIsiVgSnlvKk4rNOhcSQFwZqUU5WA3U26JBPaQyp1bZtqN1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UcKcjJ2f; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707720201; x=1739256201; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=JEaLXdeo6fNthLC6iDS4VCiLgLO+VSbXbp2Vu7m6SIc=; b=UcKcjJ2f/wix+61VRNgZFff2bSc4e9D1qWPoeIvGxS0A2te969f8iu8y 7uW0YKStJXIjiuUTPmOsw7ZHE43qDwgnAWbjhfzVKL5T5nv0mIEVDOi+1 ZpRhPPqrEWSwBNCPSL6BckfMj03A7gMK3z8mFfAbw532e33ZXEOOrxbxt dW5s3/x7mF6jSaiIqdItEkV1WRtlyJHsmeesc3L/Vn4Akw/3USlAlRv8M GWJiceSaWE+0gyzfE/i5u/4IdhfrCJnCIJkc+OF9ckNeBf/pCbcCwU0Yq cQj4w+gCbA5V0s4GuhpJgv5WtSUbNfBWb5L0h6X59dROdTxtMKiFkeK6h Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="1585983" X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="1585983" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2024 22:43:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="33288927" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.43.27]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2024 22:43:14 -0800 Message-ID: <05ac66fc-ddda-46ff-b08d-c15943c16bc1@intel.com> Date: Mon, 12 Feb 2024 08:43:11 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V5 01/12] perf/core: Add aux_pause, aux_resume, aux_start_paused To: Andi Kleen Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Heiko Carstens , Thomas Richter , Hendrik Brueckner , Suzuki K Poulose , Mike Leach , James Clark , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Yicong Yang , Jonathan Cameron , Will Deacon , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20240208113127.22216-1-adrian.hunter@intel.com> <20240208113127.22216-2-adrian.hunter@intel.com> Content-Language: en-US From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 9/02/24 23:10, Andi Kleen wrote: >> The writes to rb->aux_in_pause_resume must be done >> only once. It might be possible to get away without >> WRITE_ONCE(), but really the compiler should be informed >> not to make assumptions. > > What stops the NMI from firing here? That would be fine. > >>>> + if (READ_ONCE(rb->aux_in_pause_resume)) >>>> + /* Guard against NMI, NMI loses here */ >>>> + goto out_restore; > <----------------------- NMI That would be fine. >>>> + WRITE_ONCE(rb->aux_in_pause_resume, 1); From here on, the NMI will see rb->aux_in_pause_resume == 1 and do nothing, up to the point when rb->aux_in_pause_resume == 0 again. This code is about guarding against NMI. Interrupts are disabled, and the rb and event only operate on 1 cpu at a time. > > > Even if it isn't racy it needs a clear comment. It has a comment, but it could be more explanatory. The code paradigm is also used in perf_pmu_snapshot_aux().