X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fcgroup.h;h=6bef26c481ee04e6f4da50c7d6572ec6255acc6a;hp=95f09e00195f69dd700544f36c928cb026d4624a;hb=da4b83e77bc603745cf4a365d7f013301ef7fa89;hpb=ecedd90fcdf647f9a7b56b4934b65e30b2979b04 diff --git a/src/core/cgroup.h b/src/core/cgroup.h index 95f09e001..6bef26c48 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -1,12 +1,11 @@ /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ -#ifndef foocgrouphfoo -#define foocgrouphfoo +#pragma once /*** This file is part of systemd. - Copyright 2010 Lennart Poettering + Copyright 2013 Lennart Poettering systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -22,73 +21,168 @@ along with systemd; If not, see . ***/ -typedef struct CGroupBonding CGroupBonding; +#include -#include "unit.h" +// #include "list.h" +// #include "time-util.h" +#include "logind.h" -/* Binds a cgroup to a name */ -struct CGroupBonding { - char *controller; - char *path; +// UNNEEDED typedef struct CGroupContext CGroupContext; +// UNNEEDED Stypedef struct CGroupDeviceAllow CGroupDeviceAllow; +// UNNEEDED typedef struct CGroupBlockIODeviceWeight CGroupBlockIODeviceWeight; +// UNNEEDED typedef struct CGroupBlockIODeviceBandwidth CGroupBlockIODeviceBandwidth; + +/* Maximum value for fixed (manual) net class ID assignment, + * and also the value at which the range of automatic assignments starts + */ +// UNNEEDED #define CGROUP_NETCLASS_FIXED_MAX UINT32_C(65535) + +// UNNEEDED typedef struct CGroupContext CGroupContext; +// UNNEEDED typedef struct CGroupDeviceAllow CGroupDeviceAllow; +// UNNEEDED typedef struct CGroupBlockIODeviceWeight CGroupBlockIODeviceWeight; +// UNNEEDED typedef struct CGroupBlockIODeviceBandwidth CGroupBlockIODeviceBandwidth; + +/// UNNEEDED by elogind +#if 0 +typedef enum CGroupDevicePolicy { + + /* When devices listed, will allow those, plus built-in ones, + if none are listed will allow everything. */ + CGROUP_AUTO, + + /* Everything forbidden, except built-in ones and listed ones. */ + CGROUP_CLOSED, + + /* Everythings forbidden, except for the listed devices */ + CGROUP_STRICT, - Unit *unit; + _CGROUP_DEVICE_POLICY_MAX, + _CGROUP_DEVICE_POLICY_INVALID = -1 +} CGroupDevicePolicy; - /* For the Unit::cgroup_bondings list */ - LIST_FIELDS(CGroupBonding, by_unit); +typedef enum CGroupNetClassType { + /* Default - do not assign a net class */ + CGROUP_NETCLASS_TYPE_NONE, - /* For the Manager::cgroup_bondings hashmap */ - LIST_FIELDS(CGroupBonding, by_path); + /* Automatically assign a net class */ + CGROUP_NETCLASS_TYPE_AUTO, - /* When shutting down, remove cgroup? Are our own tasks the - * only ones in this group?*/ - bool ours:1; + /* Assign the net class that was provided by the user */ + CGROUP_NETCLASS_TYPE_FIXED, +} CGroupNetClassType; - /* If we cannot create this group, or add a process to it, is this fatal? */ - bool essential:1; +struct CGroupDeviceAllow { + LIST_FIELDS(CGroupDeviceAllow, device_allow); + char *path; + bool r:1; + bool w:1; + bool m:1; +}; - /* This cgroup is realized */ - bool realized:1; +struct CGroupBlockIODeviceWeight { + LIST_FIELDS(CGroupBlockIODeviceWeight, device_weights); + char *path; + uint64_t weight; }; -int cgroup_bonding_realize(CGroupBonding *b); -int cgroup_bonding_realize_list(CGroupBonding *first); +struct CGroupBlockIODeviceBandwidth { + LIST_FIELDS(CGroupBlockIODeviceBandwidth, device_bandwidths); + char *path; + uint64_t bandwidth; + bool read; +}; + +struct CGroupContext { + bool cpu_accounting; + bool blockio_accounting; + bool memory_accounting; + bool tasks_accounting; -void cgroup_bonding_free(CGroupBonding *b, bool trim); -void cgroup_bonding_free_list(CGroupBonding *first, bool trim); + uint64_t cpu_shares; + uint64_t startup_cpu_shares; + usec_t cpu_quota_per_sec_usec; -int cgroup_bonding_install(CGroupBonding *b, pid_t pid, const char *suffix); -int cgroup_bonding_install_list(CGroupBonding *first, pid_t pid, const char *suffix); + uint64_t blockio_weight; + uint64_t startup_blockio_weight; + LIST_HEAD(CGroupBlockIODeviceWeight, blockio_device_weights); + LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths); -int cgroup_bonding_set_group_access(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid); -int cgroup_bonding_set_group_access_list(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid); + uint64_t memory_limit; -int cgroup_bonding_set_task_access(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid, int sticky); -int cgroup_bonding_set_task_access_list(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid, int sticky); + CGroupDevicePolicy device_policy; + LIST_HEAD(CGroupDeviceAllow, device_allow); -int cgroup_bonding_kill(CGroupBonding *b, int sig, bool sigcont, Set *s, const char *suffix); -int cgroup_bonding_kill_list(CGroupBonding *first, int sig, bool sigcont, Set *s, const char *suffix); + CGroupNetClassType netclass_type; + uint32_t netclass_id; -void cgroup_bonding_trim(CGroupBonding *first, bool delete_root); -void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root); + uint64_t tasks_max; -int cgroup_bonding_is_empty(CGroupBonding *b); -int cgroup_bonding_is_empty_list(CGroupBonding *first); + bool delegate; +}; +#endif // 0 -CGroupBonding *cgroup_bonding_find_list(CGroupBonding *first, const char *controller); +// #include "unit.h" +// #include "cgroup-util.h" -char *cgroup_bonding_to_string(CGroupBonding *b); +// UNNNEEDE void cgroup_context_init(CGroupContext *c); +// UNNEEDED void cgroup_context_done(CGroupContext *c); +// UNNEEDED void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix); +// UNNEEDED void cgroup_context_apply(CGroupContext *c, CGroupMask mask, const char *path, uint32_t netclass_id, ManagerState state); -pid_t cgroup_bonding_search_main_pid(CGroupBonding *b); -pid_t cgroup_bonding_search_main_pid_list(CGroupBonding *b); +// UNNEEDED CGroupMask cgroup_context_get_mask(CGroupContext *c); -#include "manager.h" +// UNNEEDED void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a); +// UNNEEDED void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w); +// UNNEEDED void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b); + +// UNNEEDED CGroupMask unit_get_own_mask(Unit *u); +// UNNEEDED CGroupMask unit_get_siblings_mask(Unit *u); +// UNNEEDED CGroupMask unit_get_members_mask(Unit *u); +// UNNEEDED CGroupMask unit_get_subtree_mask(Unit *u); + +// UNNEEDED vCGroupMask unit_get_target_mask(Unit *u); +// UNNEEDED CGroupMask unit_get_enable_mask(Unit *u); + +// UNNEEDED void unit_update_cgroup_members_masks(Unit *u); + +// UNNEEDED har *unit_default_cgroup_path(Unit *u); +// UNNEEDED int unit_set_cgroup_path(Unit *u, const char *path); + +// UNNEEDED int unit_realize_cgroup(Unit *u); +// UNNEEDED void unit_release_cgroup(Unit *u); +// UNNEEDED void unit_prune_cgroup(Unit *u); +// UNNEEDED int unit_watch_cgroup(Unit *u); + +// UNNEEDED int unit_attach_pids_to_cgroup(Unit *u); + +// UNNEEDED int unit_add_to_netclass_cgroup(Unit *u); +// UNNEEDED int unit_remove_from_netclass_cgroup(Unit *u); int manager_setup_cgroup(Manager *m); void manager_shutdown_cgroup(Manager *m, bool delete); -int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding); -int cgroup_notify_empty(Manager *m, const char *group); +// UNNEEDED unsigned manager_dispatch_cgroup_queue(Manager *m); + +// UNNEEDED Unit *manager_get_unit_by_cgroup(Manager *m, const char *cgroup); +// UNNEEDED Unit *manager_get_unit_by_pid_cgroup(Manager *m, pid_t pid); +// UNNEEDED Unit* manager_get_unit_by_pid(Manager *m, pid_t pid); + +// UNNEEDED int unit_search_main_pid(Unit *u, pid_t *ret); +// UNNEEDED int unit_watch_all_pids(Unit *u); + +// UNNEEDED int unit_get_memory_current(Unit *u, uint64_t *ret); +// UNNEEDED int unit_get_tasks_current(Unit *u, uint64_t *ret); +// UNNEEDED int unit_get_cpu_usage(Unit *u, nsec_t *ret); +// UNNEEDED int unit_reset_cpu_usage(Unit *u); + +// UNNEEDED bool unit_cgroup_delegate(Unit *u); + +// UNNEEDED int unit_notify_cgroup_empty(Unit *u); +// UNNEEDED int manager_notify_cgroup_empty(Manager *m, const char *group); + +// UNNEEDED void unit_invalidate_cgroup(Unit *u, CGroupMask m); -Unit* cgroup_unit_by_pid(Manager *m, pid_t pid); +// UNNEEDED void manager_invalidate_startup_units(Manager *m); -#endif +// UNNEEDED const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_; +// UNNEEDED CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;