From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 7A406361DA9; Tue, 16 Jun 2026 01:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781574413; cv=none; b=obse+ClpPsUtjmZyW69jTr7CYuSX0Uj1P/jzbVBdguS+gQiEYIgWYAUb8ptNPugB+e8bXOvHxhYIMTgs2xpEtzOn2lMmbxF4gHVGh5/rtK6d8H2Dr6f+BitYVK4RJ00CNwqNxWlFuUI71D/I6/5cfJzvUT2BPL4GhrnbuzNNawo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781574413; c=relaxed/simple; bh=Vh3qr68/iKT2PEMExBYqrPSm2NJqt8zwh4MLjWDwv5k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ekr2s/2U4ZC8msO0kDxjFgQ3UtTzSays3Eqz16LZRL4ZCoy2pbP4jSQi+WBzrk9HmkD8+zTC5FcC6MyewXS984juTdcAHP7+BOxq/PjofyPV9B13Q74Pu5ZWJ7lwP6q5dOhC1XNqN3x/cu34XKbBLVMGPd94foWzB4+Xkq8i9cg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hr69Wejh; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hr69Wejh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781574411; x=1813110411; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Vh3qr68/iKT2PEMExBYqrPSm2NJqt8zwh4MLjWDwv5k=; b=hr69WejhOLJH/oB+bAPOP6XieCnE641GDfqHD9/ApUHlvzfxswYS9HG6 JQF84HRK6i8dIZgHGxmb0+gsY290fLXon3GpPKtUmdC4feBMyZl0l0gfU zIhAbYSHOI/WK/5HLmMENqBrbgkXHnOaSQkLhN3uoUIfV5+fYPA2MhhLH G+Z5dmR8fp6E+GpfM07w/DffJTNTVZUt0bGTZP/3y5/NynGXgzR1WRCNc BGX8GGu/SeRiANFubKf8r8BMVGoZwMeNvsvrtwoB2qKvlHwcq+/7YotzX qVZGp+STjPZUJMem8XzmTcaISK9i9TFn0ujiGkTp9+Tyi+CvCM2yUSfPz w==; X-CSE-ConnectionGUID: ir4MJu4USp2t2HPIE5ImGg== X-CSE-MsgGUID: pRgZGPPDRYCa93nMnFR34g== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93000788" X-IronPort-AV: E=Sophos;i="6.24,207,1774335600"; d="scan'208";a="93000788" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 18:46:50 -0700 X-CSE-ConnectionGUID: zdmC6ac6Rw2XQL0mSRy7eA== X-CSE-MsgGUID: xFW/PJU2SZSCASocpnw3TA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,207,1774335600"; d="scan'208";a="245230881" Received: from dapengmi-mobl1.ccr.corp.intel.com (HELO [10.124.241.147]) ([10.124.241.147]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 18:46:47 -0700 Message-ID: <9eed6d07-7258-4d74-bff7-76fa24170aba@linux.intel.com> Date: Tue, 16 Jun 2026 09:46:44 +0800 Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Patch v3] perf tests: Add auto counter reload (ACR) sampling test To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Adrian Hunter , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zide Chen , Falcon Thomas , Dapeng Mi , Xudong Hao References: <20260421045511.2401316-1-dapeng1.mi@linux.intel.com> Content-Language: en-US From: "Mi, Dapeng" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 6/16/2026 2:37 AM, Ian Rogers wrote: > On Mon, Apr 20, 2026 at 9:59 PM Dapeng Mi wrote: >> Add auto counter reload sampling test to verify that the intended event >> records can be captured and the self-reloaded events won't generate any >> records. >> >> Additionally, enhance ratio_to_prev test to verify ACR sampling as well >> if ACR is supported. >> >> Signed-off-by: Dapeng Mi >> --- >> >> V3: Move ratio-to-prev ACR sampling test into ratio_to_prev test. >> V2: https://lore.kernel.org/all/20260420025501.2133495-1-dapeng1.mi@linux.intel.com/ >> v1: https://lore.kernel.org/all/20260413010920.546501-1-dapeng1.mi@linux.intel.com/ >> >> tools/perf/tests/shell/record.sh | 92 +++++++++++++++++++++++++++++++- >> 1 file changed, 91 insertions(+), 1 deletion(-) >> >> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh >> index 7cb81cf3444a..091d8b0a998b 100755 >> --- a/tools/perf/tests/shell/record.sh >> +++ b/tools/perf/tests/shell/record.sh >> @@ -402,7 +402,52 @@ test_callgraph() { >> echo "Callgraph test [Success]" >> } >> >> +test_acr_sampling() { >> + events="{instructions/period=40000,acr_mask=0x2/u,cycles/period=20000,acr_mask=0x3/u}" >> + pebs_events="{instructions/period=40000,acr_mask=0x2/pu,cycles/period=20000,acr_mask=0x3/u}" >> + echo "Auto counter reload (ACR) sampling test" >> + if ! perf record -o "${perfdata}" -e "${events}" ${testprog} 2> /dev/null >> + then >> + echo "Auto counter reload sampling [Skipped not supported]" >> + return >> + fi >> + if ! perf script -i "${perfdata}" -F event | grep -q "instructions" >> + then >> + echo "Auto counter reload sampling [Failed missing instructions event]" >> + err=1 >> + return >> + fi >> + if perf script -i "${perfdata}" -F event | grep -q "cycles" >> + then >> + echo "Auto counter reload sampling [Failed cycles event shouldn't be sampled]" >> + err=1 >> + return >> + fi >> + if ! perf record -o "${perfdata}" -e "${pebs_events}" ${testprog} 2> /dev/null >> + then >> + echo "Auto counter reload PEBS sampling [Skipped not supported]" >> + echo "Auto counter reload sampling [Success]" >> + return >> + fi >> + if ! perf script -i "${perfdata}" -F event | grep -q "instructions" >> + then >> + echo "Auto counter reload PEBS sampling [Failed missing instructions event]" >> + err=1 >> + return >> + fi >> + if perf script -i "${perfdata}" -F event | grep -q "cycles" >> + then >> + echo "Auto counter reload PEBS sampling [Failed cycles event shouldn't be sampled]" >> + err=1 >> + return >> + fi >> + echo "Auto counter reload sampling [Success]" >> +} >> + >> test_ratio_to_prev() { >> + ratio_events="{instructions:u,cycles/period=20000,ratio-to-prev=0.5/u}" >> + p_core_ratio_events="{cpu_core/instructions/u,cpu_core/cycles,period=20000,ratio-to-prev=0.5/u}" >> + e_core_ratio_events="{cpu_atom/instructions/u,cpu_atom/cycles,period=20000,ratio-to-prev=0.5/u}" > Could there also be cpu_lowpower coverage? What about e-core or p-core > only devices? I suspect if the lowpower e-core really supporta ACR. There should be only one device ARL-H has the lowpower e-core with different uarch. But anyway, I can add cpu_lowpower for the full coverage.  The e-core or p-core only devices would be covered by the basic "ratio_events". Thanks. > > Thanks, > Ian > >> echo "ratio-to-prev test" >> if ! perf record -o /dev/null -e "{instructions, cycles/period=100000,ratio-to-prev=0.5/}" \ >> true 2> /dev/null >> @@ -438,7 +483,51 @@ test_ratio_to_prev() { >> err=1 >> return >> fi >> - echo "Basic ratio-to-prev record test [Success]" >> + >> + ratio_err=0 >> + do_ratio_to_prev_test() { >> + local events=$1 >> + local cpu=$2 >> + if ! perf record -o "${perfdata}" -e "${events}" ${testprog} 2> /dev/null >> + then >> + echo "Auto counter reload ${cpu} ratio-to-prev sampling [Failed sampling]" >> + ratio_err=1 >> + return >> + fi >> + if ! perf script -i "${perfdata}" -F event | grep -q "instructions" >> + then >> + echo "Auto counter reload ${cpu} ratio-to-prev sampling [Failed missing instructions event]" >> + ratio_err=1 >> + return >> + fi >> + if perf script -i "${perfdata}" -F event | grep -q "cycles" >> + then >> + echo "Auto counter reload ${cpu} ratio-to-prev sampling [Failed cycles event shouldn't be sampled]" >> + ratio_err=1 >> + return >> + fi >> + } >> + >> + # ratio-to-prev sampling would fallback to normal sampling if ACR sampling >> + # is not supported, so acr_mask must be checked before testing ratio-to-prev sampling. >> + if [ -e /sys/bus/event_source/devices/cpu/format/acr_mask ] >> + then >> + do_ratio_to_prev_test "${ratio_events}" "" >> + fi >> + if [ -e /sys/bus/event_source/devices/cpu_core/format/acr_mask ] >> + then >> + do_ratio_to_prev_test "${p_core_ratio_events}" "P-core" >> + fi >> + if [ -e /sys/bus/event_source/devices/cpu_atom/format/acr_mask ] >> + then >> + do_ratio_to_prev_test "${e_core_ratio_events}" "E-core" >> + fi >> + if test "$ratio_err" -eq 0 >> + then >> + echo "Basic ratio-to-prev record test [Success]" >> + else >> + err="${ratio_err}" >> + fi >> } >> >> # raise the limit of file descriptors to minimum >> @@ -457,6 +546,7 @@ test_leader_sampling >> test_topdown_leader_sampling >> test_precise_max >> test_callgraph >> +test_acr_sampling >> test_ratio_to_prev >> >> # restore the default value >> -- >> 2.34.1 >>