Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
966d4401
Commit
966d4401
authored
Feb 28, 2019
by
lu43jih
Browse files
Fixing msr bugs
parent
a6818d68
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/sensors/msr/MSRConfigurator.cpp
View file @
966d4401
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*/
*/
#include
"MSRConfigurator.h"
#include
"MSRConfigurator.h"
#include
<iomanip>
MSRConfigurator
::
MSRConfigurator
()
{
MSRConfigurator
::
MSRConfigurator
()
{
_groupName
=
"group"
;
_groupName
=
"group"
;
...
@@ -17,7 +18,9 @@ MSRConfigurator::~MSRConfigurator() {}
...
@@ -17,7 +18,9 @@ MSRConfigurator::~MSRConfigurator() {}
void
MSRConfigurator
::
sensorBase
(
MSRSensorBase
&
s
,
CFG_VAL
config
)
{
void
MSRConfigurator
::
sensorBase
(
MSRSensorBase
&
s
,
CFG_VAL
config
)
{
ADD
{
ADD
{
if
(
boost
::
iequals
(
val
.
first
,
"metric"
)){
if
(
boost
::
iequals
(
val
.
first
,
"metric"
)){
s
.
setMetric
(
std
::
stoull
(
val
.
second
.
data
(),
nullptr
,
16
));
//TODO try catch...
uint64_t
metric
=
std
::
stoull
(
val
.
second
.
data
(),
nullptr
,
16
);
s
.
setMetric
(
metric
);
}
}
}
}
}
}
...
@@ -184,7 +187,11 @@ void MSRConfigurator::customizeAndStore(SG_Ptr g) {
...
@@ -184,7 +187,11 @@ void MSRConfigurator::customizeAndStore(SG_Ptr g) {
}
else
{
}
else
{
for
(
auto
s
:
original
)
{
for
(
auto
s
:
original
)
{
auto
s_otherCPUs
=
std
::
make_shared
<
MSRSensorBase
>
(
s
->
getName
());
auto
s_otherCPUs
=
std
::
make_shared
<
MSRSensorBase
>
(
s
->
getName
());
s_otherCPUs
->
setName
(
s
->
getName
(),
cpu
);
std
::
size_t
found
=
s
->
getName
().
find_first_of
(
"."
);
if
(
found
!=
std
::
string
::
npos
){
found
++
;
//to skip the point
s_otherCPUs
->
setName
(
s
->
getName
().
substr
(
found
),
cpu
);
}
s_otherCPUs
->
setCpu
(
cpu
);
s_otherCPUs
->
setCpu
(
cpu
);
s_otherCPUs
->
setMetric
(
s
->
getMetric
());
s_otherCPUs
->
setMetric
(
s
->
getMetric
());
auto
size
=
s
->
getMqtt
().
size
();
auto
size
=
s
->
getMqtt
().
size
();
...
...
src/sensors/msr/MSRSensorBase.h
View file @
966d4401
...
@@ -42,9 +42,9 @@ public:
...
@@ -42,9 +42,9 @@ public:
}
}
void
printConfig
(
LOG_LEVEL
ll
,
LOGGER
&
lg
)
{
void
printConfig
(
LOG_LEVEL
ll
,
LOGGER
&
lg
)
{
LOG_VAR
(
ll
)
<<
" CPU: "
<<
_cpu
;
LOG_VAR
(
ll
)
<<
" CPU: "
<<
_cpu
;
LOG_VAR
(
ll
)
<<
" Metric: "
<<
_metric
;
LOG_VAR
(
ll
)
<<
" Metric: "
<<
_metric
;
}
}
protected:
protected:
unsigned
int
_cpu
;
unsigned
int
_cpu
;
...
...
src/sensors/msr/MSRSensorGroup.cpp
View file @
966d4401
...
@@ -42,8 +42,6 @@ void MSRSensorGroup::start() {
...
@@ -42,8 +42,6 @@ void MSRSensorGroup::start() {
return
;
return
;
}
}
program_fixed
();
for
(
auto
&
kv
:
cpuToFd
)
{
for
(
auto
&
kv
:
cpuToFd
)
{
int
cpu
=
kv
.
first
;
int
cpu
=
kv
.
first
;
char
*
path
=
new
char
[
200
];
char
*
path
=
new
char
[
200
];
...
@@ -62,6 +60,8 @@ void MSRSensorGroup::start() {
...
@@ -62,6 +60,8 @@ void MSRSensorGroup::start() {
cpuToFd
[
cpu
]
=
handle
;
cpuToFd
[
cpu
]
=
handle
;
}
}
program_fixed
();
_keepRunning
=
1
;
_keepRunning
=
1
;
_pendingTasks
++
;
_pendingTasks
++
;
_timer
->
async_wait
(
std
::
bind
(
&
MSRSensorGroup
::
readAsync
,
this
));
_timer
->
async_wait
(
std
::
bind
(
&
MSRSensorGroup
::
readAsync
,
this
));
...
@@ -85,11 +85,13 @@ void MSRSensorGroup::read() {
...
@@ -85,11 +85,13 @@ void MSRSensorGroup::read() {
try
{
try
{
for
(
auto
s
:
_sensors
)
{
for
(
auto
s
:
_sensors
)
{
msr_read
(
s
->
getMetric
(),
&
reading
.
value
,
s
->
getCpu
());
auto
ret_val
=
msr_read
(
s
->
getMetric
(),
&
reading
.
value
,
s
->
getCpu
());
s
->
storeReading
(
reading
);
if
(
ret_val
!=
-
1
){
s
->
storeReading
(
reading
);
#ifdef DEBUG
#ifdef DEBUG
LOG
(
debug
)
<<
_groupName
<<
"::"
<<
s
->
getName
()
<<
" raw reading:
\"
"
<<
reading
.
value
<<
"
\"
"
;
LOG
(
debug
)
<<
_groupName
<<
"::"
<<
s
->
getName
()
<<
" raw reading:
\"
"
<<
reading
.
value
<<
"
\"
"
;
#endif
#endif
}
}
}
}
catch
(
const
std
::
exception
&
e
)
{
}
catch
(
const
std
::
exception
&
e
)
{
LOG
(
error
)
<<
"Sensorgroup"
<<
_groupName
<<
" could not read value: "
<<
e
.
what
();
LOG
(
error
)
<<
"Sensorgroup"
<<
_groupName
<<
" could not read value: "
<<
e
.
what
();
...
@@ -136,6 +138,7 @@ void MSRSensorGroup::program_fixed(){
...
@@ -136,6 +138,7 @@ void MSRSensorGroup::program_fixed(){
&&
ctrl_reg
.
fields
.
usr1
&&
ctrl_reg
.
fields
.
os2
&&
ctrl_reg
.
fields
.
usr1
&&
ctrl_reg
.
fields
.
os2
&&
ctrl_reg
.
fields
.
usr2
)
{
&&
ctrl_reg
.
fields
.
usr2
)
{
//yes! Free running counters were set by someone else => we don't need to program them, just read them.
//yes! Free running counters were set by someone else => we don't need to program them, just read them.
LOG
(
debug
)
<<
"CPU"
<<
kv
.
first
<<
" has free running counter, so there will be no fixed counter programming"
;
continue
;
continue
;
}
}
//not all of them (or none) are enabled => we program them again
//not all of them (or none) are enabled => we program them again
...
...
src/sensors/msr/MSRSensorGroup.h
View file @
966d4401
...
@@ -37,7 +37,7 @@ private:
...
@@ -37,7 +37,7 @@ private:
void
program_fixed
();
void
program_fixed
();
std
::
map
<
unsigned
int
,
int
>
cpuToFd
;
std
::
map
<
unsigned
int
,
int
>
cpuToFd
;
int32_t
msr_read
(
uint64_t
msr_number
,
uint64_t
*
value
,
unsigned
int
cpu
);
int32_t
msr_read
(
uint64_t
msr_number
,
uint64_t
*
value
,
unsigned
int
cpu
);
int32_t
msr_write
(
uint64_t
msr_number
,
uint64_t
value
,
unsigned
int
cpu
);
int32_t
msr_write
(
uint64_t
msr_number
,
uint64_t
value
,
unsigned
int
cpu
);
};
};
...
...
src/sensors/msr/appendToMakefile.txt
deleted
100644 → 0
View file @
a6818d68
Append to PLUGINS variable: msr
Append at end of Makefile:
libdcdbplugin_msr.$(LIBEXT): src/sensors/msr/MSRSensorGroup.o src/sensors/msr/MSRConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system
NOTE: Probably you will have to append further libraries to the linker for your plugin to compile
src/sensors/msr/msr.conf
deleted
100644 → 0
View file @
a6818d68
;
comments
in
config
files
are
indicated
by
a
semicolon
global
{
mqttPrefix
/
FF112233445566778899AABB
;
add
here
other
global
attributes
for
your
plugin
}
template_group
def1
{
;
define
template
groups
by
appending
"template_"
interval
1000
minValues
3
groupAtt
1234
;
add
other
attributes
your
plugin
requires
for
a
sensor
group
;
define
sensors
belonging
to
the
group
below
sensor
temp1
{
sensorAtt
5678
;
add
other
attributes
your
plugin
requires
for
a
sensor
}
}
single_sensor
sens1
{
;
if
you
want
a
group
with
only
one
sensor
you
can
use
a
single_sensor
default
temp1
mqttsuffix
0001
;
add
other
attributes
your
plugin
requires
for
a
sensor
}
group
g1
{
interval
1000
mqttprefix
01
default
def1
;
sensor
temp1
is
taken
from
def1
and
does
not
need
to
be
redefined
sensor
gSens
{
mqttsuffix
00
}
}
src/sensors/msr/msr2.conf
deleted
100644 → 0
View file @
a6818d68
global
{
mqttPrefix
/
FF112233445566778899AABBFFFF
;
add
here
other
global
attributes
for
your
plugin
}
group
g1
{
interval
1000
mqttprefix
01
cpus
0
-
95
sensor
Instructions
{
mqttsuffix
00
metric
0
x309
}
sensor
Cycles
{
mqttsuffix
01
metric
0
x30A
}
sensor
RefCycles
{
mqttsuffix
02
metric
0
x30B
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment