libmsr
0.3.0
A friendlier interface to accessing MSRs on Intel platforms
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Macros
Pages
include
msr_core.h
Go to the documentation of this file.
1
/* msr_core.h
2
*
3
* Copyright (c) 2011-2016, Lawrence Livermore National Security, LLC.
4
* LLNL-CODE-645430
5
*
6
* Produced at Lawrence Livermore National Laboratory
7
* Written by Barry Rountree, rountree@llnl.gov
8
* Scott Walker, walker91@llnl.gov
9
* Kathleen Shoga, shoga1@llnl.gov
10
*
11
* All rights reserved.
12
*
13
* This file is part of libmsr.
14
*
15
* libmsr is free software: you can redistribute it and/or modify it under the
16
* terms of the GNU Lesser General Public License as published by the Free
17
* Software Foundation, either version 3 of the License, or (at your option)
18
* any later version.
19
*
20
* libmsr is distributed in the hope that it will be useful, but WITHOUT ANY
21
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
23
* details.
24
*
25
* You should have received a copy of the GNU Lesser General Public License
26
* along with libmsr. If not, see <http://www.gnu.org/licenses/>.
27
*
28
* This material is based upon work supported by the U.S. Department of
29
* Energy's Lawrence Livermore National Laboratory. Office of Science, under
30
* Award number DE-AC52-07NA27344.
31
*
32
*/
33
34
#ifndef MSR_CORE_H_INCLUDE
35
#define MSR_CORE_H_INCLUDE
36
37
#include <linux/types.h>
38
#include <stdint.h>
39
#include <sys/types.h>
40
41
#ifdef __cplusplus
42
extern
"C"
{
43
#endif
44
45
#define NUM_DEVS (sockets * coresPerSocket * threadsPerCore)
46
#define X86_IOC_MSR_BATCH _IOWR('c', 0xA2, struct msr_batch_array)
47
#define MSR_BATCH_DIR "/dev/cpu/msr_batch"
48
#define FILENAME_SIZE 1024
49
//#define USE_NO_BATCH 1
50
52
enum
libmsr_data_type_e
{
55
RAPL_DATA
,
57
RAPL_UNIT
,
60
FIXED_COUNTERS_DATA
,
63
FIXED_COUNTERS_CTR_DATA
,
65
COUNTERS_DATA
,
68
COUNTERS_CTRL
,
71
CLOCKS_DATA
,
73
PERF_DATA
,
75
THERM_STAT
,
78
THERM_INTERR
,
80
PKG_THERM_STAT
,
83
PKG_THERM_INTERR
,
85
TEMP_TARGET
,
87
PERF_CTL
,
89
PKG_CRES
,
91
CORE_CRES
,
93
UNCORE_EVTSEL
,
95
UNCORE_COUNT
,
97
USR_BATCH0
,
99
USR_BATCH1
,
101
USR_BATCH2
,
103
USR_BATCH3
,
105
USR_BATCH4
,
107
USR_BATCH5
,
109
USR_BATCH6
,
111
USR_BATCH7
,
113
USR_BATCH8
,
115
USR_BATCH9
,
117
USR_BATCH10
,
118
};
119
121
enum
libmsr_batch_op_type_e
{
123
BATCH_LOAD
,
125
BATCH_WRITE
,
127
BATCH_READ
,
128
};
129
130
// Depending on their scope, MSRs can be written to or read from at either the
131
// socket (aka package/cpu) or core level, and possibly the hardware thread
132
// level.
133
//
134
// read/write_msr reads from core 0.
135
// read/write_msr_all_cores_v uses a vector of values.
136
// write_msr_all_cores writes all cores with a single value.
137
// read/write_msr_single_core contains all of the low-level logic.
138
// The rest of the functions are wrappers that call these two functions.
139
142
struct
msr_batch_op
{
144
__u16
cpu
;
146
__u16
isrdmsr
;
148
__s32
err
;
150
__u32
msr
;
152
__u64
msrdata
;
154
__u64
wmask
;
155
};
156
158
struct
msr_batch_array
{
160
__u32
numops
;
162
struct
msr_batch_op
*
ops
;
163
};
164
168
uint64_t
num_cores
(
void
);
169
173
uint64_t
num_sockets
(
void
);
174
178
uint64_t
num_devs
(
void
);
179
183
uint64_t
cores_per_socket
(
void
);
184
192
int
allocate_batch
(
int
batchnum,
193
size_t
bsize);
194
200
int
free_batch
(
int
batchnum);
201
214
int
create_batch_op
(off_t
msr
,
215
uint64_t
cpu
,
216
uint64_t **dest,
217
const
int
batchnum);
218
228
void
core_config
(uint64_t *coresPerSocket,
229
uint64_t *threadsPerCore,
230
uint64_t *sockets,
231
int
*HTenabled);
232
245
int
sockets_assert
(
const
unsigned
*socket,
246
const
int
location,
247
const
char
*file);
248
261
int
threads_assert
(
const
unsigned
*thread,
262
const
int
location,
263
const
char
*file);
264
277
int
cores_assert
(
const
unsigned
*core,
278
const
int
location,
279
const
char
*file);
280
291
int
stat_module
(
char
*filename,
292
int
*kerneltype,
293
int
*dev_idx);
294
299
int
init_msr
(
void
);
300
306
int
finalize_msr
(
void
);
307
329
int
write_msr_by_coord
(
unsigned
socket,
330
unsigned
core,
331
unsigned
thread,
332
off_t
msr
,
333
uint64_t val);
334
356
int
read_msr_by_coord
(
unsigned
socket,
357
unsigned
core,
358
unsigned
thread,
359
off_t
msr
,
360
uint64_t *val);
361
380
int
read_msr_by_coord_batch
(
unsigned
socket,
381
unsigned
core,
382
unsigned
thread,
383
off_t
msr
,
384
uint64_t **val,
385
int
batchnum);
386
390
int
read_batch
(
const
int
batchnum);
391
395
int
write_batch
(
const
int
batchnum);
396
406
int
load_socket_batch
(off_t
msr
,
407
uint64_t **val,
408
const
int
batchnum);
409
419
int
load_core_batch
(off_t
msr
,
420
uint64_t **val,
421
const
int
batchnum);
422
432
int
load_thread_batch
(off_t
msr
,
433
uint64_t **val,
434
const
int
batchnum);
435
451
int
read_msr_by_idx
(
int
dev_idx,
452
off_t
msr
,
453
uint64_t *val);
454
469
int
write_msr_by_idx
(
int
dev_idx,
470
off_t
msr
,
471
uint64_t val);
472
475
//
485
int
write_msr_by_idx_and_verify
(
int
dev_idx,
486
off_t
msr
,
487
uint64_t val);
488
489
#ifdef __cplusplus
490
}
491
#endif
492
#endif
Generated by
1.8.2