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
193eec77
Commit
193eec77
authored
5 years ago
by
Georges Da Costa
Browse files
Options
Downloads
Patches
Plain Diff
Adds system load with -u
parent
854b0ce1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
load.c
+37
-0
37 additions, 0 deletions
load.c
load.h
+21
-0
21 additions, 0 deletions
load.h
makefile
+7
-4
7 additions, 4 deletions
makefile
mojitos.c
+27
-3
27 additions, 3 deletions
mojitos.c
with
92 additions
and
7 deletions
load.c
0 → 100644
+
37
−
0
View file @
193eec77
/*******************************************************
Copyright (C) 2019-2020 Georges Da Costa <georges.da-costa@irit.fr>
This file is part of Mojitos.
Mojitos is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Mojitos is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MojitO/S. If not, see <https://www.gnu.org/licenses/>.
*******************************************************/
#include
<stdio.h>
#include
<stdlib.h>
#define LOAD_BUFFER_SIZE 1024
char
buffer
[
LOAD_BUFFER_SIZE
];
void
get_load
(
long
long
*
results
)
{
FILE
*
f
=
fopen
(
"/proc/stat"
,
"rb"
);
fgets
(
buffer
,
LOAD_BUFFER_SIZE
,
f
);
fclose
(
f
);
int
pos
=
0
;
while
(
buffer
[
pos
]
>
'9'
||
buffer
[
pos
]
<
'0'
)
pos
++
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
results
[
i
]
=
atoll
(
buffer
+
pos
);
while
(
buffer
[
pos
]
<=
'9'
&&
buffer
[
pos
]
>=
'0'
)
pos
++
;
pos
++
;
}
}
This diff is collapsed.
Click to expand it.
load.h
0 → 100644
+
21
−
0
View file @
193eec77
/*******************************************************
Copyright (C) 2018-2019 Georges Da Costa <georges.da-costa@irit.fr>
This file is part of Mojitos.
Mojitos is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Mojitos is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MojitO/S. If not, see <https://www.gnu.org/licenses/>.
*******************************************************/
void
get_load
(
long
long
*
results
);
This diff is collapsed.
Click to expand it.
makefile
+
7
−
4
View file @
193eec77
all
:
mojitos
all
:
mojitos
mojitos_group
:
mojitos.c counters_group.o counters.h rapl.o rapl.h network.h network.o counters_option.h
mojitos_group
:
mojitos.c counters_group.o counters.h rapl.o rapl.h network.h network.o counters_option.h
load.o
gcc
$(
DEBUG
)
-O3
-Wall
-o
mojitos_group mojitos.c counters_group.o rapl.o network.o
-lpowercap
gcc
$(
DEBUG
)
-O3
-Wall
-o
mojitos_group mojitos.c counters_group.o rapl.o network.o
load.o
-lpowercap
mojitos
:
mojitos.c counters_individual.o counters.h rapl.o rapl.h network.h network.o counters_option.h
mojitos
:
mojitos.c counters_individual.o counters.h rapl.o rapl.h network.h network.o counters_option.h
load.o
gcc
$(
DEBUG
)
-O3
-Wall
-o
mojitos mojitos.c counters_individual.o rapl.o network.o
-lpowercap
gcc
$(
DEBUG
)
-O3
-Wall
-o
mojitos mojitos.c counters_individual.o rapl.o network.o
load.o
-lpowercap
counters_option.h
:
counters_option.py
counters_option.h
:
counters_option.py
./counters_option.py
>
counters_option.h
./counters_option.py
>
counters_option.h
...
@@ -13,6 +13,9 @@ debug: DEBUG = -DDEBUG
...
@@ -13,6 +13,9 @@ debug: DEBUG = -DDEBUG
debug
:
all
debug
:
all
load.o
:
load.c load.h
gcc
-O3
-Wall
-c
load.c
rapl.o
:
rapl.c rapl.h
rapl.o
:
rapl.c rapl.h
gcc
-O3
-Wall
-c
rapl.c
gcc
-O3
-Wall
-c
rapl.c
...
...
This diff is collapsed.
Click to expand it.
mojitos.c
+
27
−
3
View file @
193eec77
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include
"counters.h"
#include
"counters.h"
#include
"rapl.h"
#include
"rapl.h"
#include
"network.h"
#include
"network.h"
#include
"load.h"
int
rapl_mode
=-
1
;
int
rapl_mode
=-
1
;
const
int
nbzones
=
3
;
const
int
nbzones
=
3
;
...
@@ -84,8 +85,10 @@ void perf_event_list(char *perf_string, int *nb_perf, int **perf_indexes) {
...
@@ -84,8 +85,10 @@ void perf_event_list(char *perf_string, int *nb_perf, int **perf_indexes) {
}
}
}
}
int
load_mode
=
-
1
;
void
usage
(
char
**
argv
)
{
void
usage
(
char
**
argv
)
{
printf
(
"Usage : %s [-t time] [-f freq] [-r] [-p perf_list] [-l] [-d network_device] [-o logfile] [-e command arguments...]
\n
"
,
argv
[
0
]);
printf
(
"Usage : %s [-t time] [-f freq] [-r] [-p perf_list] [-l]
[-u]
[-d network_device] [-o logfile] [-e command arguments...]
\n
"
,
argv
[
0
]);
printf
(
"if time==0 then loops infinitively
\n
"
);
printf
(
"if time==0 then loops infinitively
\n
"
);
printf
(
"if -e is present, time and freq are not used
\n
"
);
printf
(
"if -e is present, time and freq are not used
\n
"
);
printf
(
"-r activates RAPL
\n
"
);
printf
(
"-r activates RAPL
\n
"
);
...
@@ -94,6 +97,7 @@ void usage(char** argv) {
...
@@ -94,6 +97,7 @@ void usage(char** argv) {
printf
(
"-l lists the possible performance counters and quits
\n
"
);
printf
(
"-l lists the possible performance counters and quits
\n
"
);
printf
(
"-d activates network monitoring
\n
"
);
printf
(
"-d activates network monitoring
\n
"
);
printf
(
"-s activates statistics of overhead in nanoseconds
\n
"
);
printf
(
"-s activates statistics of overhead in nanoseconds
\n
"
);
printf
(
"-u activates report of system load
\n
"
);
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
...
@@ -130,7 +134,7 @@ int main(int argc, char **argv) {
...
@@ -130,7 +134,7 @@ int main(int argc, char **argv) {
signal
(
15
,
flush
);
signal
(
15
,
flush
);
int
c
;
int
c
;
while
((
c
=
getopt
(
argc
,
argv
,
"lhftdeoprs"
))
!=
-
1
&&
application
==
NULL
)
while
((
c
=
getopt
(
argc
,
argv
,
"lhftdeoprs
u
"
))
!=
-
1
&&
application
==
NULL
)
switch
(
c
)
{
switch
(
c
)
{
case
'f'
:
case
'f'
:
frequency
=
atoi
(
argv
[
optind
]);
frequency
=
atoi
(
argv
[
optind
]);
...
@@ -160,6 +164,9 @@ int main(int argc, char **argv) {
...
@@ -160,6 +164,9 @@ int main(int argc, char **argv) {
case
'r'
:
case
'r'
:
rapl_mode
=
0
;
rapl_mode
=
0
;
break
;
break
;
case
'u'
:
load_mode
=
0
;
break
;
case
's'
:
case
's'
:
stat_mode
=
0
;
stat_mode
=
0
;
break
;
break
;
...
@@ -181,6 +188,12 @@ int main(int argc, char **argv) {
...
@@ -181,6 +188,12 @@ int main(int argc, char **argv) {
long
long
tmp_network_values
[
4
]
=
{
0
,
0
,
0
,
0
};
long
long
tmp_network_values
[
4
]
=
{
0
,
0
,
0
,
0
};
get_network
(
network_values
,
network_sources
);
get_network
(
network_values
,
network_sources
);
// Load initialization
long
long
load_values
[
10
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
long
long
tmp_load_values
[
10
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
if
(
load_mode
==
0
)
get_load
(
load_values
);
// RAPL initialization
// RAPL initialization
rapl_t
rapl
=
NULL
;
rapl_t
rapl
=
NULL
;
size_t
rapl_size
=
0
;
size_t
rapl_size
=
0
;
...
@@ -221,6 +234,9 @@ int main(int argc, char **argv) {
...
@@ -221,6 +234,9 @@ int main(int argc, char **argv) {
for
(
int
r
=
0
;
r
<
rapl
->
nbpackages
*
rapl
->
nbzones
;
r
++
)
for
(
int
r
=
0
;
r
<
rapl
->
nbpackages
*
rapl
->
nbzones
;
r
++
)
fprintf
(
output
,
"%s%u "
,
rapl
->
names
[
r
],
(
unsigned
int
)
r
/
rapl
->
nbzones
);
fprintf
(
output
,
"%s%u "
,
rapl
->
names
[
r
],
(
unsigned
int
)
r
/
rapl
->
nbzones
);
if
(
load_mode
==
0
)
fprintf
(
output
,
"user nice system idle iowait irq softirq steal guest and guest_nice "
);
if
(
stat_mode
==
0
)
if
(
stat_mode
==
0
)
fprintf
(
output
,
"overhead "
);
fprintf
(
output
,
"overhead "
);
fprintf
(
output
,
"
\n
"
);
fprintf
(
output
,
"
\n
"
);
...
@@ -240,7 +256,9 @@ int main(int argc, char **argv) {
...
@@ -240,7 +256,9 @@ int main(int argc, char **argv) {
get_network
(
tmp_network_values
,
network_sources
);
get_network
(
tmp_network_values
,
network_sources
);
if
(
rapl_mode
==
0
)
if
(
rapl_mode
==
0
)
get_rapl
(
tmp_rapl_values
,
rapl
);
get_rapl
(
tmp_rapl_values
,
rapl
);
if
(
load_mode
==
0
)
get_load
(
tmp_load_values
);
if
(
application
!=
NULL
)
{
if
(
application
!=
NULL
)
{
if
(
fork
()
==
0
){
if
(
fork
()
==
0
){
...
@@ -281,6 +299,10 @@ int main(int argc, char **argv) {
...
@@ -281,6 +299,10 @@ int main(int argc, char **argv) {
if
(
rapl_mode
==
0
)
if
(
rapl_mode
==
0
)
for
(
int
r
=
0
;
r
<
rapl
->
nbpackages
*
rapl
->
nbzones
;
r
++
)
for
(
int
r
=
0
;
r
<
rapl
->
nbpackages
*
rapl
->
nbzones
;
r
++
)
fprintf
(
output
,
"%ld "
,
tmp_rapl_values
[
r
]
-
rapl_values
[
r
]);
fprintf
(
output
,
"%ld "
,
tmp_rapl_values
[
r
]
-
rapl_values
[
r
]);
if
(
load_mode
==
0
)
for
(
int
i
=
0
;
i
<
10
;
i
++
)
fprintf
(
output
,
"%lld "
,
tmp_load_values
[
i
]
-
load_values
[
i
]);
if
(
stat_mode
==
0
)
if
(
stat_mode
==
0
)
fprintf
(
output
,
"%ld "
,
stat_data
);
fprintf
(
output
,
"%ld "
,
stat_data
);
...
@@ -290,6 +312,8 @@ int main(int argc, char **argv) {
...
@@ -290,6 +312,8 @@ int main(int argc, char **argv) {
break
;
break
;
if
(
rapl_mode
==
0
)
if
(
rapl_mode
==
0
)
memcpy
(
rapl_values
,
tmp_rapl_values
,
rapl_size
);
memcpy
(
rapl_values
,
tmp_rapl_values
,
rapl_size
);
if
(
load_mode
==
0
)
memcpy
(
load_values
,
tmp_load_values
,
sizeof
(
load_values
));
if
(
dev
!=
NULL
)
if
(
dev
!=
NULL
)
memcpy
(
network_values
,
tmp_network_values
,
sizeof
(
network_values
));
memcpy
(
network_values
,
tmp_network_values
,
sizeof
(
network_values
));
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
...
...
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