From 73884e62ce6f013a48769fadd3512b33b347bb77 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Tue, 29 Dec 2020 11:56:37 +0100 Subject: [PATCH] test/scheduler: Add simple tool for utilizing msr driver This tool simply returns contents of EAX|ECX registers for a specific MSR. Targeted use is to compare DPDK's governor results while working under intel_pstate driver. Change-Id: I40b3f3601d41e45ba65c96b99ebd1b6949b5af20 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5737 Reviewed-by: Tomasz Zawadzki Reviewed-by: Maciej Szwed Reviewed-by: Jim Harris Reviewed-by: Karol Latecki Tested-by: SPDK CI Jenkins --- test/scheduler/rdmsr.pl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 test/scheduler/rdmsr.pl diff --git a/test/scheduler/rdmsr.pl b/test/scheduler/rdmsr.pl new file mode 100755 index 000000000..b4628116a --- /dev/null +++ b/test/scheduler/rdmsr.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use constant SEEK_CUR => 1; + +( @ARGV == 2 ) || exit(1); + +my $cpu_path = sprintf( "/dev/cpu/%u/msr", shift() ); +my $msr = hex( shift() ); +my $reg_size = 8; +my ( @msr, $msr_buf, $reg ); + +unless ( -e $cpu_path ) { + printf STDERR "$cpu_path doesn't exist\n"; + exit(1); +} + +open( MSR, "<", $cpu_path ); +sysseek( MSR, $msr, SEEK_CUR ); +sysread( MSR, $msr_buf, $reg_size ); +@msr = unpack( "C*", $msr_buf ); + +unless ( @msr == $reg_size ) { + printf STDERR "Failed to read $cpu_path\n"; + exit(1); +} + +for ( my $byte = @msr - 1 ; $byte >= 0 ; $byte-- ) { + $reg |= $msr[$byte] << ( $byte * 8 ); +} + +printf( "0x%x\n", $reg );