Spdk/test/scheduler/rdmsr.pl
Michal Berger 588dfe314b Add SPDX header to various files
They were missed by the initial set of patches which introduced this
header as a mandatory one across different types of files.

Signed-off-by: Michal Berger <michal.berger@intel.com>
Change-Id: I3f9b37d41298c843e1648e72fe8593768ccd37e0
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15423
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2022-11-29 08:27:51 +00:00

39 lines
785 B
Perl
Executable File

#!/usr/bin/env perl
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2020 Intel Corporation.
# All rights reserved.
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 );