Software Archive
Read-only legacy content
17061 Discussions

Hang when trying to read RAPL MSRs on KNL

akshay_v_
Beginner
456 Views

Hi,

I'm attempting to read /dev/cpu/XYZ/msr using pread64() but I encounter a hang. I'm reusing code available with PAPI for this purpose and am wondering if the following macros I'm using need to be redefined for it to work on KNL. Lmk when possible. Thanks

#define MSR_RAPL_POWER_UNIT             0x606

/*                                                                                                                                        
 * Platform specific RAPL Domains.                                                                                                        
 * Note that PP1 RAPL Domain is supported on 062A only                                                                                    
 * And DRAM RAPL Domain is supported on 062D only                                                                                         
 */
/* Package RAPL Domain */
#define MSR_PKG_RAPL_POWER_LIMIT        0x610
#define MSR_PKG_ENERGY_STATUS           0x611
#define MSR_PKG_PERF_STATUS             0x613
#define MSR_PKG_POWER_INFO              0x614

/* PP0 RAPL Domain */
#define MSR_PP0_POWER_LIMIT             0x638
#define MSR_PP0_ENERGY_STATUS           0x639
#define MSR_PP0_POLICY                  0x63A
#define MSR_PP0_PERF_STATUS             0x63B

/* PP1 RAPL Domain, may reflect to uncore devices */
#define MSR_PP1_POWER_LIMIT             0x640
#define MSR_PP1_ENERGY_STATUS           0x641
#define MSR_PP1_POLICY                  0x642

/* DRAM RAPL Domain */
#define MSR_DRAM_POWER_LIMIT            0x618
#define MSR_DRAM_ENERGY_STATUS          0x619
#define MSR_DRAM_PERF_STATUS            0x61B
#define MSR_DRAM_POWER_INFO             0x61C

/* PP1 RAPL Domain, may reflect to uncore devices */
#define MSR_PP1_POWER_LIMIT             0x640
#define MSR_PP1_ENERGY_STATUS           0x641
#define MSR_PP1_POLICY                  0x642

/* DRAM RAPL Domain */
#define MSR_DRAM_POWER_LIMIT            0x618
#define MSR_DRAM_ENERGY_STATUS          0x619
#define MSR_DRAM_PERF_STATUS            0x61B
#define MSR_DRAM_POWER_INFO             0x61C

/* RAPL UNIT BITMASK */
#define POWER_UNIT_OFFSET       0
#define POWER_UNIT_MASK         0x0F

#define ENERGY_UNIT_OFFSET      0x08
#define ENERGY_UNIT_MASK        0x1F00

#define TIME_UNIT_OFFSET        0x10
#define TIME_UNIT_MASK          0xF000

...

fd = open(filename, O_RDONLY);

uint64_t data;

 if ( pread(fd, &data, sizeof data, MSR_RAPL_POWER_UNIT) != sizeof data ) { ---> hangs here
        perror("rdmsr:pread");
        exit(127);
    }

...

0 Kudos
1 Solution
McCalpinJohn
Honored Contributor III
456 Views

The RAPL infrastructures works fine on my systems.   Only PACKAGE and DRAM domains are supported.

Are you sure that the file open succeeded?  The /dev/cpu/*/msr devices are normally only readable by root.

View solution in original post

0 Kudos
2 Replies
McCalpinJohn
Honored Contributor III
457 Views

The RAPL infrastructures works fine on my systems.   Only PACKAGE and DRAM domains are supported.

Are you sure that the file open succeeded?  The /dev/cpu/*/msr devices are normally only readable by root.

0 Kudos
akshay_v_
Beginner
456 Views

Thanks, John.  Not reading PP0 domain helped circumvent the hang. I'm able to read PKG and DRAM domains with root permissions now.

0 Kudos
Reply