chiark / gitweb /
Prep v228: Add remaining updates from upstream (3/3)
[elogind.git] / src / core / cgroup.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2013 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include <stdbool.h>
25
26 // #include "list.h"
27 // #include "time-util.h"
28 #include "logind.h"
29
30 // UNNEEDED typedef struct CGroupContext CGroupContext;
31 // UNNEEDED Stypedef struct CGroupDeviceAllow CGroupDeviceAllow;
32 // UNNEEDED typedef struct CGroupBlockIODeviceWeight CGroupBlockIODeviceWeight;
33 // UNNEEDED typedef struct CGroupBlockIODeviceBandwidth CGroupBlockIODeviceBandwidth;
34
35 /* Maximum value for fixed (manual) net class ID assignment,
36  * and also the value at which the range of automatic assignments starts
37  */
38 // UNNEEDED #define CGROUP_NETCLASS_FIXED_MAX UINT32_C(65535)
39
40 // UNNEEDED typedef struct CGroupContext CGroupContext;
41 // UNNEEDED typedef struct CGroupDeviceAllow CGroupDeviceAllow;
42 // UNNEEDED typedef struct CGroupBlockIODeviceWeight CGroupBlockIODeviceWeight;
43 // UNNEEDED typedef struct CGroupBlockIODeviceBandwidth CGroupBlockIODeviceBandwidth;
44
45 /// UNNEEDED by elogind
46 #if 0
47 typedef enum CGroupDevicePolicy {
48
49         /* When devices listed, will allow those, plus built-in ones,
50         if none are listed will allow everything. */
51         CGROUP_AUTO,
52
53         /* Everything forbidden, except built-in ones and listed ones. */
54         CGROUP_CLOSED,
55
56         /* Everythings forbidden, except for the listed devices */
57         CGROUP_STRICT,
58
59         _CGROUP_DEVICE_POLICY_MAX,
60         _CGROUP_DEVICE_POLICY_INVALID = -1
61 } CGroupDevicePolicy;
62
63 typedef enum CGroupNetClassType {
64         /* Default - do not assign a net class */
65         CGROUP_NETCLASS_TYPE_NONE,
66
67         /* Automatically assign a net class */
68         CGROUP_NETCLASS_TYPE_AUTO,
69
70         /* Assign the net class that was provided by the user */
71         CGROUP_NETCLASS_TYPE_FIXED,
72 } CGroupNetClassType;
73
74 struct CGroupDeviceAllow {
75         LIST_FIELDS(CGroupDeviceAllow, device_allow);
76         char *path;
77         bool r:1;
78         bool w:1;
79         bool m:1;
80 };
81
82 struct CGroupBlockIODeviceWeight {
83         LIST_FIELDS(CGroupBlockIODeviceWeight, device_weights);
84         char *path;
85         uint64_t weight;
86 };
87
88 struct CGroupBlockIODeviceBandwidth {
89         LIST_FIELDS(CGroupBlockIODeviceBandwidth, device_bandwidths);
90         char *path;
91         uint64_t bandwidth;
92         bool read;
93 };
94
95 struct CGroupContext {
96         bool cpu_accounting;
97         bool blockio_accounting;
98         bool memory_accounting;
99         bool tasks_accounting;
100
101         uint64_t cpu_shares;
102         uint64_t startup_cpu_shares;
103         usec_t cpu_quota_per_sec_usec;
104
105         uint64_t blockio_weight;
106         uint64_t startup_blockio_weight;
107         LIST_HEAD(CGroupBlockIODeviceWeight, blockio_device_weights);
108         LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths);
109
110         uint64_t memory_limit;
111
112         CGroupDevicePolicy device_policy;
113         LIST_HEAD(CGroupDeviceAllow, device_allow);
114
115         CGroupNetClassType netclass_type;
116         uint32_t netclass_id;
117
118         uint64_t tasks_max;
119
120         bool delegate;
121 };
122 #endif // 0
123
124 // #include "unit.h"
125 // #include "cgroup-util.h"
126
127 // UNNNEEDE void cgroup_context_init(CGroupContext *c);
128 // UNNEEDED void cgroup_context_done(CGroupContext *c);
129 // UNNEEDED void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix);
130 // UNNEEDED void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, uint32_t netclass_id, ManagerState state);
131
132 // UNNEEDED CGroupMask cgroup_context_get_mask(CGroupContext *c);
133
134 // UNNEEDED void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a);
135 // UNNEEDED void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w);
136 // UNNEEDED void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b);
137
138 // UNNEEDED CGroupMask unit_get_own_mask(Unit *u);
139 // UNNEEDED CGroupMask unit_get_siblings_mask(Unit *u);
140 // UNNEEDED CGroupMask unit_get_members_mask(Unit *u);
141 // UNNEEDED CGroupMask unit_get_subtree_mask(Unit *u);
142
143 // UNNEEDED vCGroupMask unit_get_target_mask(Unit *u);
144 // UNNEEDED CGroupMask unit_get_enable_mask(Unit *u);
145
146 // UNNEEDED void unit_update_cgroup_members_masks(Unit *u);
147
148 // UNNEEDED har *unit_default_cgroup_path(Unit *u);
149 // UNNEEDED int unit_set_cgroup_path(Unit *u, const char *path);
150
151 // UNNEEDED int unit_realize_cgroup(Unit *u);
152 // UNNEEDED void unit_release_cgroup(Unit *u);
153 // UNNEEDED void unit_prune_cgroup(Unit *u);
154 // UNNEEDED int unit_watch_cgroup(Unit *u);
155
156 // UNNEEDED int unit_attach_pids_to_cgroup(Unit *u);
157
158 // UNNEEDED int unit_add_to_netclass_cgroup(Unit *u);
159 // UNNEEDED int unit_remove_from_netclass_cgroup(Unit *u);
160
161 int manager_setup_cgroup(Manager *m);
162 void manager_shutdown_cgroup(Manager *m, bool delete);
163
164 // UNNEEDED unsigned manager_dispatch_cgroup_queue(Manager *m);
165
166 // UNNEEDED Unit *manager_get_unit_by_cgroup(Manager *m, const char *cgroup);
167 // UNNEEDED Unit *manager_get_unit_by_pid_cgroup(Manager *m, pid_t pid);
168 // UNNEEDED Unit* manager_get_unit_by_pid(Manager *m, pid_t pid);
169
170 // UNNEEDED int unit_search_main_pid(Unit *u, pid_t *ret);
171 // UNNEEDED int unit_watch_all_pids(Unit *u);
172
173 // UNNEEDED int unit_get_memory_current(Unit *u, uint64_t *ret);
174 // UNNEEDED int unit_get_tasks_current(Unit *u, uint64_t *ret);
175 // UNNEEDED int unit_get_cpu_usage(Unit *u, nsec_t *ret);
176 // UNNEEDED int unit_reset_cpu_usage(Unit *u);
177
178 // UNNEEDED bool unit_cgroup_delegate(Unit *u);
179
180 // UNNEEDED int unit_notify_cgroup_empty(Unit *u);
181 // UNNEEDED int manager_notify_cgroup_empty(Manager *m, const char *group);
182
183 // UNNEEDED void unit_invalidate_cgroup(Unit *u, CGroupMask m);
184
185 // UNNEEDED void manager_invalidate_startup_units(Manager *m);
186
187 // UNNEEDED const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
188 // UNNEEDED CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;