Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MojitOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
MojitOS
Commits
bdb2908f
Commit
bdb2908f
authored
2 years ago
by
floreal.risso
Browse files
Options
Downloads
Patches
Plain Diff
add: exit information
parent
4ffdcfaf
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!9
fix sensor example (doc)
,
!6
Simple memory sensor
,
!5
Add dev name to labels
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/amd_rapl.c
+19
-5
19 additions, 5 deletions
src/amd_rapl.c
with
19 additions
and
5 deletions
src/amd_rapl.c
+
19
−
5
View file @
bdb2908f
...
@@ -201,17 +201,36 @@ void debug_print_amd_rapl(AmdRapl *rapl)
...
@@ -201,17 +201,36 @@ void debug_print_amd_rapl(AmdRapl *rapl)
unsigned
int
get_nb_cpu
()
unsigned
int
get_nb_cpu
()
{
{
char
filename
[
BUFFER_SIZE
];
char
filename
[
BUFFER_SIZE
];
int
cpy_errno
;
unsigned
int
n_cpu
=
0
;
unsigned
int
n_cpu
=
0
;
for
(;;
n_cpu
++
)
{
for
(;;
n_cpu
++
)
{
snprintf
(
filename
,
BUFFER_SIZE
,
base_str
,
n_cpu
);
snprintf
(
filename
,
BUFFER_SIZE
,
base_str
,
n_cpu
);
int
fd
=
open
(
filename
,
O_RDONLY
);
int
fd
=
open
(
filename
,
O_RDONLY
);
cpy_errno
=
errno
;
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
break
;
break
;
}
}
close
(
fd
);
close
(
fd
);
}
}
if
(
n_cpu
==
0
)
{
perror
(
"open()"
);
fprintf
(
stderr
,
"on %s
\n
"
,
filename
);
switch
(
cpy_errno
)
{
case
ENOENT
:
fprintf
(
stderr
,
"Amd rapl works with msr module, try to run 'sudo modprobe msr', then retry.
\n
"
);
exit
(
99
);
case
EACCES
:
fprintf
(
stderr
,
"Amd rapl must be executed with the administrator privilege, try with 'sudo'.
\n
"
);
exit
(
98
);
default:
fprintf
(
stderr
,
"Unexpected error"
);
exit
(
97
);
}
}
// n_cpu > 0
return
n_cpu
;
return
n_cpu
;
}
}
...
@@ -295,11 +314,6 @@ unsigned int init_amd_rapl(char *none, void **ptr)
...
@@ -295,11 +314,6 @@ unsigned int init_amd_rapl(char *none, void **ptr)
UNUSED
(
none
);
UNUSED
(
none
);
unsigned
int
max_cpus
=
get_nb_cpu
();
unsigned
int
max_cpus
=
get_nb_cpu
();
if
(
max_cpus
==
0
)
{
fprintf
(
stderr
,
base_str
,
0
);
perror
(
":open()"
);
exit
(
127
);
}
CpuSensor
*
cpu_information
=
(
CpuSensor
*
)
calloc
(
max_cpus
,
sizeof
(
CpuSensor
));
CpuSensor
*
cpu_information
=
(
CpuSensor
*
)
calloc
(
max_cpus
,
sizeof
(
CpuSensor
));
if
(
parse_cpuinfo
(
cpu_information
,
max_cpus
))
{
if
(
parse_cpuinfo
(
cpu_information
,
max_cpus
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment