blob: d2ec430146be1eea074166fa46438e6eecbac76f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*
* Copyright (c) 2013-2014 Red Hat.
* Copyright (c) 2010 Aconex. All Rights Reserved.
*
* This program 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 2 of the License, or (at your
* option) any later version.
*
* This program 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.
*/
#ifndef _CGROUP_H
#define _CGROUP_H
/*
* Note: cgroup metrics have an "extra" component - the cluster part
* of the PMID (12 bits) is split into two (6 bits each): the bottom
* part contains the regular metric (cluster) ID while the top holds
* the cgroup ID (index - e.g. this is the 3rd cgroup we've seen for
* a particular subsystem).
*/
#define CGROUP_SPLIT 6
#define CGROUP_MASK ((1 << CGROUP_SPLIT) - 1)
static inline pmID
cgroup_pmid_build(unsigned int domain, unsigned int cluster,
unsigned int gid, unsigned int metric)
{
return pmid_build(domain, (gid << CGROUP_SPLIT) | cluster, metric);
}
static inline unsigned int
cgroup_pmid_group(pmID id)
{
return pmid_cluster(id) >> CGROUP_SPLIT;
}
static inline unsigned int
proc_pmid_cluster(pmID id)
{
return pmid_cluster(id) & CGROUP_MASK;
}
static inline unsigned int
cgroup_pmid_metric(pmID id)
{
return pmid_item(id);
}
/*
* General cgroup interfaces
*/
extern void cgroup_init(pmdaMetric *, int);
extern char *cgroup_find_subsys(pmInDom, void *);
extern int cgroup_group_fetch(pmID, unsigned int, pmAtomValue *);
/*
* Metric name and value refresh interfaces
*/
extern int refresh_cgroups(pmdaExt *, __pmnsTree **);
/*
* Indom-specific interfaces
*/
extern void refresh_cgroup_cpus(pmInDom);
extern void refresh_cgroup_devices(pmInDom);
extern void refresh_cgroup_filesys(pmInDom);
extern void refresh_cgroup_subsys(pmInDom);
#endif /* _CGROUP_H */
|