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 <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5737
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Michal Berger 2020-12-29 11:56:37 +01:00 committed by Tomasz Zawadzki
parent 453b15d62d
commit 73884e62ce

34
test/scheduler/rdmsr.pl Executable file
View File

@ -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 );