From patchwork Fri Mar 4 06:07:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinzhou Su X-Patchwork-Id: 548444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EF8CC433F5 for ; Fri, 4 Mar 2022 06:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238252AbiCDGKS (ORCPT ); Fri, 4 Mar 2022 01:10:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238276AbiCDGKR (ORCPT ); Fri, 4 Mar 2022 01:10:17 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2047.outbound.protection.outlook.com [40.107.100.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C92EF45ACF; Thu, 3 Mar 2022 22:09:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sy8g511V63Up9oHsM/3XSPWjPZWRUQzWYDadkAEavv6faz8Kix/PDLp63zICDOY//uosprpGBaQjBXFeYuKoF6Dh/Xru1yD709zTONbU0SLgol7q836E2J35S8y4zoKxsFXgRsJJ5uaLccvNJSHHL9ck+4zd1vmva5/yKb32jyyBu8IZCbhqOvyWMb68bm4KJvpgLx2XJ2M0MWx3LRgfIgjAWqlXbaro65C0j88+eC6KtzdvxJzEICSEblrWRWg/boE22iXFGNDLto8LNpE6fOGmySJ152J/Xd1/xZ+ksEZF2aJte6BY4rW5OeMHKHqtegw2kvTVPbtWZq6Ikz5eOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vBlX5wVO9ovhQ6dNKrl9JGe6dARvGKz/HIvt+uXaxE4=; b=ktkSDNNJ8LbHZVbHTo0lM6+B/cPCJr3cKQt/R93DHeGopdAXDNyHKVGP48cwujvsSXfbqCZO99Mn5ToiVbQj7IeUi1v//3nbsWOb5pU3OQoB0QkFAY4iSLn1/0T0zMedZG0dZHjNaREk3IibQdSCJB5hQMDYZBvVDkwjor5Myy1ZJq6gM7KxVITksbUQgRcT7SB8RBK5TrSKlb4o/vDL2SY9W4atokaJdSkHBVmEqAJigOQsc9e8m/hJDoUiRRen//UeOngU0BKeX6QyLdi5OEUCw5bf+EnAKlc2YI6K7XE8PLdM+jaLsJY580luSh8RDLhGo5Z0MaPfaKpAKgLpVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=rjwysocki.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vBlX5wVO9ovhQ6dNKrl9JGe6dARvGKz/HIvt+uXaxE4=; b=0L0PaePHhrL71jzOMyxBiqcn7E12ceDCxGZ5BVCOPkww19g3ld8q68Zs8qf1lhun6vRtvsckcG8pTTlqE994FiUP7ZT7lh6G7EDxGsFE0gYkNVu/lw96FfFDUM7WGbBchvx4Y7TNri5QWChK58tudWJrJJrvx1cycviXwoNT7uw= Received: from BN6PR2001CA0039.namprd20.prod.outlook.com (2603:10b6:405:16::25) by BL0PR12MB2548.namprd12.prod.outlook.com (2603:10b6:207:41::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.13; Fri, 4 Mar 2022 06:09:27 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:405:16:cafe::50) by BN6PR2001CA0039.outlook.office365.com (2603:10b6:405:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Fri, 4 Mar 2022 06:09:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Fri, 4 Mar 2022 06:09:27 +0000 Received: from jinzhosu-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Fri, 4 Mar 2022 00:09:22 -0600 From: Jinzhou Su To: , , , CC: , , , , , , , , , , Jinzhou Su Subject: [PATCH V2 2/4] tools/power/x86/intel_pstate_tracer: make tracer as a module Date: Fri, 4 Mar 2022 14:07:22 +0800 Message-ID: <20220304060724.314582-3-Jinzhou.Su@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220304060724.314582-1-Jinzhou.Su@amd.com> References: <20220304060724.314582-1-Jinzhou.Su@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd3888ce-7e06-4b7c-3223-08d9fda589c8 X-MS-TrafficTypeDiagnostic: BL0PR12MB2548:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MfL5jd+ZDb50++T7fk6PQ+HYex56X5g6aG4ZYr//5lI6bc27g2w3PXCUrU6rXU7KhzM9UUoywSbpYHzNp4LjZ4KZNctqiMDbvJOVMRd5flBoKRhtG4JkLg8AFL/htMsNZPcDscwtahSrl70c93EIxWxUU8tgZiLAP5nN09+lLs06E/rwoAW7vVSZneoGbaWt3Ex3npNWZiwHIu04c5jdwaAJvDv3x5CQlzC/K4wT+1WJnwafsR/6Y1UA/Mkzpc6ntw1UeaolgVnJZnAUV+DlOEnj+dATEleZ90lNLePiIXpgRsBoOKuZ46ZjAziDqLNjlLQb/6OgyFKm4+uOMh3+XRnznAa8wWzjNUu7dNvygBuQ3TTRvTbbIfNlvmNMoxnzf5LlT12oJkH4zVxNzCQcIqUFaS/RbbPjC8CcLEElmfQ43jq9KGopQl3z9mo7C8+i7bt4Q9lJpkb2hUBYDX+Ul6XQFWyGefILmgcID5rXkjjqpIG3lUpviQNRX6YoI27ZuBF7r7E3613jENXuec1KzC8yFqckTVuDTttPPcoFojsnPoYCPtlSjELBL4JwaeUeZo4saQayWJkeh7wqzx8Zol0J6mvKUmgVt4UE7kTvNtiDEi74YX2XOMnP0hHiDWv8VkWyPMiN0nwI5Q3Dn5K+nBSn1t54HAGnaMvAnuFicZThA/lyXf5xyfSTl1V3rEE8EMDMIDOGgicTwmDWfHkq2Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(36860700001)(508600001)(47076005)(70586007)(86362001)(83380400001)(40460700003)(16526019)(2906002)(36756003)(26005)(426003)(336012)(1076003)(186003)(7696005)(81166007)(316002)(30864003)(2616005)(5660300002)(4326008)(8936002)(82310400004)(110136005)(8676002)(70206006)(356005)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2022 06:09:27.1884 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd3888ce-7e06-4b7c-3223-08d9fda589c8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2548 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Make intel_pstate_tracer as a module. Other trace event can import this module to analyze their trace data. Signed-off-by: Jinzhou Su Acked-by: Doug Smythies --- .../intel_pstate_tracer.py | 260 +++++++++--------- 1 file changed, 129 insertions(+), 131 deletions(-) diff --git a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py index e15e20696d17..b46e9eb8f5aa 100755 --- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py +++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py @@ -63,7 +63,7 @@ C_USEC = 3 C_SEC = 2 C_CPU = 1 -global sample_num, last_sec_cpu, last_usec_cpu, start_time, testname +global sample_num, last_sec_cpu, last_usec_cpu, start_time, testname, trace_file # 11 digits covers uptime to 115 days getcontext().prec = 11 @@ -72,17 +72,17 @@ sample_num =0 last_sec_cpu = [0] * MAX_CPUS last_usec_cpu = [0] * MAX_CPUS -def print_help(): - print('intel_pstate_tracer.py:') +def print_help(driver_name): + print('%s_tracer.py:'%driver_name) print(' Usage:') print(' If the trace file is available, then to simply parse and plot, use (sudo not required):') - print(' ./intel_pstate_tracer.py [-c cpus] -t -n ') + print(' ./%s_tracer.py [-c cpus] -t -n '%driver_name) print(' Or') - print(' ./intel_pstate_tracer.py [--cpu cpus] ---trace_file --name ') + print(' ./%s_tracer.py [--cpu cpus] ---trace_file --name '%driver_name) print(' To generate trace file, parse and plot, use (sudo required):') - print(' sudo ./intel_pstate_tracer.py [-c cpus] -i -n -m ') + print(' sudo ./%s_tracer.py [-c cpus] -i -n -m '%driver_name) print(' Or') - print(' sudo ./intel_pstate_tracer.py [--cpu cpus] --interval --name --memory ') + print(' sudo ./%s_tracer.py [--cpu cpus] --interval --name --memory '%driver_name) print(' Optional argument:') print(' cpus: comma separated list of CPUs') print(' kbytes: Kilo bytes of memory per CPU to allocate to the trace buffer. Default: 10240') @@ -323,7 +323,7 @@ def set_4_plot_linestyles(g_plot): g_plot('set style line 3 linetype 1 linecolor rgb "purple" pointtype -1') g_plot('set style line 4 linetype 1 linecolor rgb "blue" pointtype -1') -def store_csv(cpu_int, time_pre_dec, time_post_dec, core_busy, scaled, _from, _to, mperf, aperf, tsc, freq_ghz, io_boost, common_comm, load, duration_ms, sample_num, elapsed_time, tsc_ghz): +def store_csv(cpu_int, time_pre_dec, time_post_dec, core_busy, scaled, _from, _to, mperf, aperf, tsc, freq_ghz, io_boost, common_comm, load, duration_ms, sample_num, elapsed_time, tsc_ghz, cpu_mask): """ Store master csv file information """ global graph_data_present @@ -342,11 +342,9 @@ def store_csv(cpu_int, time_pre_dec, time_post_dec, core_busy, scaled, _from, _t graph_data_present = True; -def split_csv(): +def split_csv(current_max_cpu, cpu_mask): """ seperate the all csv file into per CPU csv files. """ - global current_max_cpu - if os.path.exists('cpu.csv'): for index in range(0, current_max_cpu + 1): if cpu_mask[int(index)] != 0: @@ -381,27 +379,25 @@ def clear_trace_file(): print('IO error clearing trace file ') sys.exit(2) -def enable_trace(): +def enable_trace(trace_file): """ Enable trace """ try: - open('/sys/kernel/debug/tracing/events/power/pstate_sample/enable' - , 'w').write("1") + open(trace_file,'w').write("1") except: print('IO error enabling trace ') sys.exit(2) -def disable_trace(): +def disable_trace(trace_file): """ Disable trace """ try: - open('/sys/kernel/debug/tracing/events/power/pstate_sample/enable' - , 'w').write("0") + open(trace_file, 'w').write("0") except: print('IO error disabling trace ') sys.exit(2) -def set_trace_buffer_size(): +def set_trace_buffer_size(memory): """ Set trace buffer size """ try: @@ -421,7 +417,7 @@ def free_trace_buffer(): print('IO error freeing trace buffer ') sys.exit(2) -def read_trace_data(filename): +def read_trace_data(filename, cpu_mask): """ Read and parse trace data """ global current_max_cpu @@ -481,135 +477,137 @@ def read_trace_data(filename): tsc_ghz = Decimal(0) if duration_ms != Decimal(0) : tsc_ghz = Decimal(tsc)/duration_ms/Decimal(1000000) - store_csv(cpu_int, time_pre_dec, time_post_dec, core_busy, scaled, _from, _to, mperf, aperf, tsc, freq_ghz, io_boost, common_comm, load, duration_ms, sample_num, elapsed_time, tsc_ghz) + store_csv(cpu_int, time_pre_dec, time_post_dec, core_busy, scaled, _from, _to, mperf, aperf, tsc, freq_ghz, io_boost, common_comm, load, duration_ms, sample_num, elapsed_time, tsc_ghz, cpu_mask) if cpu_int > current_max_cpu: current_max_cpu = cpu_int # End of for each trace line loop # Now seperate the main overall csv file into per CPU csv files. - split_csv() + split_csv(current_max_cpu, cpu_mask) def signal_handler(signal, frame): print(' SIGINT: Forcing cleanup before exit.') if interval: - disable_trace() + disable_trace(trace_file) clear_trace_file() # Free the memory free_trace_buffer() sys.exit(0) -signal.signal(signal.SIGINT, signal_handler) +if __name__ == "__main__": + trace_file = "/sys/kernel/debug/tracing/events/power/pstate_sample/enable" + signal.signal(signal.SIGINT, signal_handler) -interval = "" -filename = "" -cpu_list = "" -testname = "" -memory = "10240" -graph_data_present = False; + interval = "" + filename = "" + cpu_list = "" + testname = "" + memory = "10240" + graph_data_present = False; -valid1 = False -valid2 = False + valid1 = False + valid2 = False -cpu_mask = zeros((MAX_CPUS,), dtype=int) + cpu_mask = zeros((MAX_CPUS,), dtype=int) -try: - opts, args = getopt.getopt(sys.argv[1:],"ht:i:c:n:m:",["help","trace_file=","interval=","cpu=","name=","memory="]) -except getopt.GetoptError: - print_help() - sys.exit(2) -for opt, arg in opts: - if opt == '-h': - print() + try: + opts, args = getopt.getopt(sys.argv[1:],"ht:i:c:n:m:",["help","trace_file=","interval=","cpu=","name=","memory="]) + except getopt.GetoptError: + print_help('intel_pstate') + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print_help('intel_pstate') + sys.exit() + elif opt in ("-t", "--trace_file"): + valid1 = True + location = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) + filename = os.path.join(location, arg) + elif opt in ("-i", "--interval"): + valid1 = True + interval = arg + elif opt in ("-c", "--cpu"): + cpu_list = arg + elif opt in ("-n", "--name"): + valid2 = True + testname = arg + elif opt in ("-m", "--memory"): + memory = arg + + if not (valid1 and valid2): + print_help('intel_pstate') sys.exit() - elif opt in ("-t", "--trace_file"): - valid1 = True - location = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) - filename = os.path.join(location, arg) - elif opt in ("-i", "--interval"): - valid1 = True - interval = arg - elif opt in ("-c", "--cpu"): - cpu_list = arg - elif opt in ("-n", "--name"): - valid2 = True - testname = arg - elif opt in ("-m", "--memory"): - memory = arg - -if not (valid1 and valid2): - print_help() - sys.exit() - -if cpu_list: - for p in re.split("[,]", cpu_list): - if int(p) < MAX_CPUS : - cpu_mask[int(p)] = 1 -else: - for i in range (0, MAX_CPUS): - cpu_mask[i] = 1 - -if not os.path.exists('results'): - os.mkdir('results') + + if cpu_list: + for p in re.split("[,]", cpu_list): + if int(p) < MAX_CPUS : + cpu_mask[int(p)] = 1 + else: + for i in range (0, MAX_CPUS): + cpu_mask[i] = 1 + + if not os.path.exists('results'): + os.mkdir('results') + # The regular user needs to own the directory, not root. + fix_ownership('results') + + os.chdir('results') + if os.path.exists(testname): + print('The test name directory already exists. Please provide a unique test name. Test re-run not supported, yet.') + sys.exit() + os.mkdir(testname) # The regular user needs to own the directory, not root. - fix_ownership('results') - -os.chdir('results') -if os.path.exists(testname): - print('The test name directory already exists. Please provide a unique test name. Test re-run not supported, yet.') - sys.exit() -os.mkdir(testname) -# The regular user needs to own the directory, not root. -fix_ownership(testname) -os.chdir(testname) - -# Temporary (or perhaps not) -cur_version = sys.version_info -print('python version (should be >= 2.7):') -print(cur_version) - -# Left as "cleanup" for potential future re-run ability. -cleanup_data_files() - -if interval: - filename = "/sys/kernel/debug/tracing/trace" - clear_trace_file() - set_trace_buffer_size() - enable_trace() - print('Sleeping for ', interval, 'seconds') - time.sleep(int(interval)) - disable_trace() - -current_max_cpu = 0 - -read_trace_data(filename) - -if interval: - clear_trace_file() - # Free the memory - free_trace_buffer() - -if graph_data_present == False: - print('No valid data to plot') - sys.exit(2) - -for cpu_no in range(0, current_max_cpu + 1): - plot_perf_busy_with_sample(cpu_no) - plot_perf_busy(cpu_no) - plot_durations(cpu_no) - plot_loads(cpu_no) - -plot_pstate_cpu_with_sample() -plot_pstate_cpu() -plot_load_cpu() -plot_frequency_cpu() -plot_duration_cpu() -plot_scaled_cpu() -plot_boost_cpu() -plot_ghz_cpu() - -# It is preferrable, but not necessary, that the regular user owns the files, not root. -for root, dirs, files in os.walk('.'): - for f in files: - fix_ownership(f) - -os.chdir('../../') + fix_ownership(testname) + os.chdir(testname) + + # Temporary (or perhaps not) + cur_version = sys.version_info + print('python version (should be >= 2.7):') + print(cur_version) + + # Left as "cleanup" for potential future re-run ability. + cleanup_data_files() + + if interval: + filename = "/sys/kernel/debug/tracing/trace" + clear_trace_file() + set_trace_buffer_size(memory) + enable_trace(trace_file) + print('Sleeping for ', interval, 'seconds') + time.sleep(int(interval)) + disable_trace(trace_file) + + current_max_cpu = 0 + + read_trace_data(filename, cpu_mask) + + if interval: + clear_trace_file() + # Free the memory + free_trace_buffer() + + if graph_data_present == False: + print('No valid data to plot') + sys.exit(2) + + for cpu_no in range(0, current_max_cpu + 1): + plot_perf_busy_with_sample(cpu_no) + plot_perf_busy(cpu_no) + plot_durations(cpu_no) + plot_loads(cpu_no) + + plot_pstate_cpu_with_sample() + plot_pstate_cpu() + plot_load_cpu() + plot_frequency_cpu() + plot_duration_cpu() + plot_scaled_cpu() + plot_boost_cpu() + plot_ghz_cpu() + + # It is preferrable, but not necessary, that the regular user owns the files, not root. + for root, dirs, files in os.walk('.'): + for f in files: + fix_ownership(f) + + os.chdir('../../') From patchwork Fri Mar 4 06:07:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinzhou Su X-Patchwork-Id: 548443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 982DFC4332F for ; Fri, 4 Mar 2022 06:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238299AbiCDGKi (ORCPT ); Fri, 4 Mar 2022 01:10:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238290AbiCDGKe (ORCPT ); Fri, 4 Mar 2022 01:10:34 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2049.outbound.protection.outlook.com [40.107.100.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 450C547AFE; Thu, 3 Mar 2022 22:09:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3aRqQW3dwj7w1kLOks0dNf1HIOtrBY8t+tec/Mc00yn26NlTPEPjCVwDADPJVg6cbHrxp5jtM+ef1UPmfljzW+07HKsTiCiQHU2jD2wIfyASow9Xi+AwdoG+wkl+Ho8/WEVN3wsYgypfb+brN6wDR03D4asUdXRj2TGSgqBipmzXZ5zAtA4mgBKKz7XHhPgYn9D0+xLIH2F0Sx7xoIkk87pMq/hz2Z3s/WQXxUI9Zaf9vYC7pf8dzfY4vuutJGBCSEIWzqH7JuG5yjK+pKL2POnAVf/1k40JG9/hUFDSuqcMqWFRS3IOehArm5vVRv5nSPj4tHY1MZAi0NYXamXBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rQSb8aXFwzJmaujcSCOmzQP9FuKfdMzEyXLIAc7XpV0=; b=be1SbxMfUYwGRLs7Y8nrzMz70t1ja3LGKKRtojR3SB49gZUlJLoIsGSdNhDfJ1M+OOTcUcZwZs0wTZJOt0tEXqjT4HoFlRBQHZhwks4wdIKWx86k1ZoT7dWf/ZxyHwxxXZaSQD7evws8Bv0ctJt6cNQ+KgRlunackMykd5D5plXUlOIvXBPRTVpMjnVz6+9TtyaT6LzrfFpIO6g0FstZVzwoH5ywz26nKIHZ8TEzENP96TKaOvnPJ3DnYQKzZfqwtH08mmPmNBaSxb/x3xyn3IVpn9YLqB8fqP5JRtzuEvMAxyct+0lrQ0vqCnVY6AmY7MoBsjWV0+6EOha+Z0ebkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=rjwysocki.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rQSb8aXFwzJmaujcSCOmzQP9FuKfdMzEyXLIAc7XpV0=; b=BQAdBX/2CX1BT3h2pGfhgJRfYyMkAzdl9qSzrtj/9KyO3p4zWN/g+duLDU3gGiBCteQfCE2utDU9FkAqFbUbaeyQv0T5vi5WxtBQtgaFOp+yHhYVGY2QQVfqlJFgkg0fakXrYStkGRLzDo+bVvxOIKnq92iClfXydRy3MKz1GC8= Received: from BN9PR03CA0937.namprd03.prod.outlook.com (2603:10b6:408:108::12) by DM4PR12MB5326.namprd12.prod.outlook.com (2603:10b6:5:39f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Fri, 4 Mar 2022 06:09:43 +0000 Received: from BN8NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:408:108:cafe::31) by BN9PR03CA0937.outlook.office365.com (2603:10b6:408:108::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Fri, 4 Mar 2022 06:09:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT057.mail.protection.outlook.com (10.13.177.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Fri, 4 Mar 2022 06:09:42 +0000 Received: from jinzhosu-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Fri, 4 Mar 2022 00:09:36 -0600 From: Jinzhou Su To: , , , CC: , , , , , , , , , , Jinzhou Su Subject: [PATCH V2 4/4] Documentation: amd-pstate: add tracer tool introduction Date: Fri, 4 Mar 2022 14:07:24 +0800 Message-ID: <20220304060724.314582-5-Jinzhou.Su@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220304060724.314582-1-Jinzhou.Su@amd.com> References: <20220304060724.314582-1-Jinzhou.Su@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2fb6b7e3-b999-48dd-139f-08d9fda592c5 X-MS-TrafficTypeDiagnostic: DM4PR12MB5326:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6GxDl/LJ/yFzWT1+TY7cwUht9DF90jLkNuLemqy8kVoRVAa8oz81bNatTvTI5YKmUookYDuqctTJ1OACfMY38Z8WdDh8a50/4d2QSy2nt9DYmzTGP14ZPAsCOwAOJ4vHoiy2lgbLHxdj206td8L3TSne9M/N1eyk0kpiZslZp6Btv2ShI0ggr9I3KMi+oJQgc7YH+qqyMNO4nzMvW73AyDPYiZmBpvNDc/1Wk3/IM2FBiN1OUKcfzsrtqYLlgPerm5pwr8YUCw6lkFWHGqvsC1I6r+v1S1tnjZqnx5BqTBaOcTpZcLRvvp9OVb4Qw3bOQ8Dx0QhFJV8g9qGxlrymtcW+HYzk1x+442ZNF2cYjkn/5Tl0kv6ydIK/IcKefj1f4CmDHNsRTGQU5UUBEVpdqp+Gxh3W35kPzG2jCrmYllCB9g5xAspD7U2phALVmpdIx2lA3Z6I7h8JDwthRrguefDWddmMSTrdccnC/69fcR3TLGYysXQSNO0iZKKePitUsansHTZE2PnqiCUmG6N65sqc4BRwLhm8c2h0uxikkod0vAygRaKXap08GYyNTjOxr1Hvut/leUJdKKOf+nhFeM/VO4ddZxusIcHZl/v+WroVV6n1jyAV0pccrFC093r7YSDZNAzYeFwVrZC25rOnSFdIRJB9nXl/CEy4Gtfu+i6cdwIDjz7LMIaLvtjoJX2ky59SjgbBM8AExHXgZN7rxw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(316002)(82310400004)(8676002)(4326008)(2616005)(70206006)(508600001)(70586007)(86362001)(110136005)(6666004)(54906003)(36860700001)(47076005)(40460700003)(26005)(81166007)(186003)(1076003)(16526019)(426003)(356005)(336012)(83380400001)(7696005)(2906002)(8936002)(5660300002)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2022 06:09:42.2674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fb6b7e3-b999-48dd-139f-08d9fda592c5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5326 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add amd pstate tracer tool introduction Signed-off-by: Jinzhou Su --- Documentation/admin-guide/pm/amd-pstate.rst | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 2f066df4ee9c..17dd7396e8fc 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -369,6 +369,32 @@ governor (for the policies it is attached to), or by the ``CPUFreq`` core (for t policies with other scaling governors). +Tracer Tool +------------- + +``amd_pstate_tracer.py`` can record and parse amd-pstate trace log, then +generate performance plots. This utility can be used to debug and tune the +performance of the amd-pstate driver. The tracer tool needs to import intel +pstate tracer. + +Tracer tool located in linux/tools/power/x86/amd_pstate_tracer. It can be +used in two ways. If trace file is available, then directly parse the file +with command :: + + ./amd_pstate_trace.py [-c cpus] -t -n + +Or generate trace file with root privilege, then parse and plot with command :: + + sudo ./amd_pstate_trace.py [-c cpus] -n -i [-m kbytes] + +The test result can be found in ``results/test_name``. Following is the example +about part of the output. :: + + common_cpu common_secs common_usecs min_perf des_perf max_perf freq mperf apef tsc load duration_ms sample_num elapsed_time common_comm + CPU_005 712 116384 39 49 166 0.7565 9645075 2214891 38431470 25.1 11.646 469 2.496 kworker/5:0-40 + CPU_006 712 116408 39 49 166 0.6769 8950227 1839034 37192089 24.06 11.272 470 2.496 kworker/6:0-1264 + + Reference ===========