mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 14:55:37 +03:00
core: add new call unit_reset_accounting()
It's a simple wrapper for resetting both IP and CPU accounting in one go. This will become particularly useful when we also needs this to reset IO accounting (to be added in a later commit).
This commit is contained in:
parent
cc6625212f
commit
9b2559a13e
@ -3210,6 +3210,17 @@ int unit_reset_ip_accounting(Unit *u) {
|
|||||||
return r < 0 ? r : q;
|
return r < 0 ? r : q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int unit_reset_accounting(Unit *u) {
|
||||||
|
int r, q;
|
||||||
|
|
||||||
|
assert(u);
|
||||||
|
|
||||||
|
r = unit_reset_cpu_accounting(u);
|
||||||
|
q = unit_reset_ip_accounting(u);
|
||||||
|
|
||||||
|
return r < 0 ? r : q;
|
||||||
|
}
|
||||||
|
|
||||||
void unit_invalidate_cgroup(Unit *u, CGroupMask m) {
|
void unit_invalidate_cgroup(Unit *u, CGroupMask m) {
|
||||||
assert(u);
|
assert(u);
|
||||||
|
|
||||||
|
@ -204,6 +204,7 @@ int unit_get_ip_accounting(Unit *u, CGroupIPAccountingMetric metric, uint64_t *r
|
|||||||
|
|
||||||
int unit_reset_cpu_accounting(Unit *u);
|
int unit_reset_cpu_accounting(Unit *u);
|
||||||
int unit_reset_ip_accounting(Unit *u);
|
int unit_reset_ip_accounting(Unit *u);
|
||||||
|
int unit_reset_accounting(Unit *u);
|
||||||
|
|
||||||
#define UNIT_CGROUP_BOOL(u, name) \
|
#define UNIT_CGROUP_BOOL(u, name) \
|
||||||
({ \
|
({ \
|
||||||
|
@ -330,8 +330,7 @@ static int scope_start(Unit *u) {
|
|||||||
return r;
|
return r;
|
||||||
|
|
||||||
(void) unit_realize_cgroup(u);
|
(void) unit_realize_cgroup(u);
|
||||||
(void) unit_reset_cpu_accounting(u);
|
(void) unit_reset_accounting(u);
|
||||||
(void) unit_reset_ip_accounting(u);
|
|
||||||
|
|
||||||
unit_export_state_files(u);
|
unit_export_state_files(u);
|
||||||
|
|
||||||
|
@ -230,8 +230,7 @@ static int slice_start(Unit *u) {
|
|||||||
return r;
|
return r;
|
||||||
|
|
||||||
(void) unit_realize_cgroup(u);
|
(void) unit_realize_cgroup(u);
|
||||||
(void) unit_reset_cpu_accounting(u);
|
(void) unit_reset_accounting(u);
|
||||||
(void) unit_reset_ip_accounting(u);
|
|
||||||
|
|
||||||
slice_set_state(t, SLICE_ACTIVE);
|
slice_set_state(t, SLICE_ACTIVE);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -5393,8 +5393,7 @@ int unit_prepare_exec(Unit *u) {
|
|||||||
(void) unit_realize_cgroup(u);
|
(void) unit_realize_cgroup(u);
|
||||||
|
|
||||||
if (u->reset_accounting) {
|
if (u->reset_accounting) {
|
||||||
(void) unit_reset_cpu_accounting(u);
|
(void) unit_reset_accounting(u);
|
||||||
(void) unit_reset_ip_accounting(u);
|
|
||||||
u->reset_accounting = false;
|
u->reset_accounting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user