aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r--include/linux/cgroup.h112
1 files changed, 44 insertions, 68 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 39c1d9469677..5c097596104b 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -21,6 +21,7 @@
21#include <linux/xattr.h> 21#include <linux/xattr.h>
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/percpu-refcount.h> 23#include <linux/percpu-refcount.h>
24#include <linux/seq_file.h>
24 25
25#ifdef CONFIG_CGROUPS 26#ifdef CONFIG_CGROUPS
26 27
@@ -28,8 +29,6 @@ struct cgroupfs_root;
28struct cgroup_subsys; 29struct cgroup_subsys;
29struct inode; 30struct inode;
30struct cgroup; 31struct cgroup;
31struct css_id;
32struct eventfd_ctx;
33 32
34extern int cgroup_init_early(void); 33extern int cgroup_init_early(void);
35extern int cgroup_init(void); 34extern int cgroup_init(void);
@@ -79,8 +78,6 @@ struct cgroup_subsys_state {
79 struct cgroup_subsys_state *parent; 78 struct cgroup_subsys_state *parent;
80 79
81 unsigned long flags; 80 unsigned long flags;
82 /* ID for this css, if possible */
83 struct css_id __rcu *id;
84 81
85 /* percpu_ref killing and RCU release */ 82 /* percpu_ref killing and RCU release */
86 struct rcu_head rcu_head; 83 struct rcu_head rcu_head;
@@ -239,10 +236,6 @@ struct cgroup {
239 struct rcu_head rcu_head; 236 struct rcu_head rcu_head;
240 struct work_struct destroy_work; 237 struct work_struct destroy_work;
241 238
242 /* List of events which userspace want to receive */
243 struct list_head event_list;
244 spinlock_t event_list_lock;
245
246 /* directory xattrs */ 239 /* directory xattrs */
247 struct simple_xattrs xattrs; 240 struct simple_xattrs xattrs;
248}; 241};
@@ -280,6 +273,9 @@ enum {
280 * - "tasks" is removed. Everything should be at process 273 * - "tasks" is removed. Everything should be at process
281 * granularity. Use "cgroup.procs" instead. 274 * granularity. Use "cgroup.procs" instead.
282 * 275 *
276 * - "cgroup.procs" is not sorted. pids will be unique unless they
277 * got recycled inbetween reads.
278 *
283 * - "release_agent" and "notify_on_release" are removed. 279 * - "release_agent" and "notify_on_release" are removed.
284 * Replacement notification mechanism will be implemented. 280 * Replacement notification mechanism will be implemented.
285 * 281 *
@@ -320,9 +316,6 @@ struct cgroupfs_root {
320 /* Unique id for this hierarchy. */ 316 /* Unique id for this hierarchy. */
321 int hierarchy_id; 317 int hierarchy_id;
322 318
323 /* A list running through the attached subsystems */
324 struct list_head subsys_list;
325
326 /* The root cgroup for this hierarchy */ 319 /* The root cgroup for this hierarchy */
327 struct cgroup top_cgroup; 320 struct cgroup top_cgroup;
328 321
@@ -389,16 +382,6 @@ struct css_set {
389}; 382};
390 383
391/* 384/*
392 * cgroup_map_cb is an abstract callback API for reporting map-valued
393 * control files
394 */
395
396struct cgroup_map_cb {
397 int (*fill)(struct cgroup_map_cb *cb, const char *key, u64 value);
398 void *state;
399};
400
401/*
402 * struct cftype: handler definitions for cgroup control files 385 * struct cftype: handler definitions for cgroup control files
403 * 386 *
404 * When reading/writing to a file: 387 * When reading/writing to a file:
@@ -445,10 +428,6 @@ struct cftype {
445 */ 428 */
446 struct cgroup_subsys *ss; 429 struct cgroup_subsys *ss;
447 430
448 int (*open)(struct inode *inode, struct file *file);
449 ssize_t (*read)(struct cgroup_subsys_state *css, struct cftype *cft,
450 struct file *file,
451 char __user *buf, size_t nbytes, loff_t *ppos);
452 /* 431 /*
453 * read_u64() is a shortcut for the common case of returning a 432 * read_u64() is a shortcut for the common case of returning a
454 * single integer. Use it in place of read() 433 * single integer. Use it in place of read()
@@ -458,24 +437,14 @@ struct cftype {
458 * read_s64() is a signed version of read_u64() 437 * read_s64() is a signed version of read_u64()
459 */ 438 */
460 s64 (*read_s64)(struct cgroup_subsys_state *css, struct cftype *cft); 439 s64 (*read_s64)(struct cgroup_subsys_state *css, struct cftype *cft);
461 /*
462 * read_map() is used for defining a map of key/value
463 * pairs. It should call cb->fill(cb, key, value) for each
464 * entry. The key/value pairs (and their ordering) should not
465 * change between reboots.
466 */
467 int (*read_map)(struct cgroup_subsys_state *css, struct cftype *cft,
468 struct cgroup_map_cb *cb);
469 /*
470 * read_seq_string() is used for outputting a simple sequence
471 * using seqfile.
472 */
473 int (*read_seq_string)(struct cgroup_subsys_state *css,
474 struct cftype *cft, struct seq_file *m);
475 440
476 ssize_t (*write)(struct cgroup_subsys_state *css, struct cftype *cft, 441 /* generic seq_file read interface */
477 struct file *file, 442 int (*seq_show)(struct seq_file *sf, void *v);
478 const char __user *buf, size_t nbytes, loff_t *ppos); 443
444 /* optional ops, implement all or none */
445 void *(*seq_start)(struct seq_file *sf, loff_t *ppos);
446 void *(*seq_next)(struct seq_file *sf, void *v, loff_t *ppos);
447 void (*seq_stop)(struct seq_file *sf, void *v);
479 448
480 /* 449 /*
481 * write_u64() is a shortcut for the common case of accepting 450 * write_u64() is a shortcut for the common case of accepting
@@ -504,27 +473,6 @@ struct cftype {
504 * kick type for multiplexing. 473 * kick type for multiplexing.
505 */ 474 */
506 int (*trigger)(struct cgroup_subsys_state *css, unsigned int event); 475 int (*trigger)(struct cgroup_subsys_state *css, unsigned int event);
507
508 int (*release)(struct inode *inode, struct file *file);
509
510 /*
511 * register_event() callback will be used to add new userspace
512 * waiter for changes related to the cftype. Implement it if
513 * you want to provide this functionality. Use eventfd_signal()
514 * on eventfd to send notification to userspace.
515 */
516 int (*register_event)(struct cgroup_subsys_state *css,
517 struct cftype *cft, struct eventfd_ctx *eventfd,
518 const char *args);
519 /*
520 * unregister_event() callback will be called when userspace
521 * closes the eventfd or on cgroup removing.
522 * This callback must be implemented, if you want provide
523 * notification functionality.
524 */
525 void (*unregister_event)(struct cgroup_subsys_state *css,
526 struct cftype *cft,
527 struct eventfd_ctx *eventfd);
528}; 476};
529 477
530/* 478/*
@@ -538,6 +486,26 @@ struct cftype_set {
538}; 486};
539 487
540/* 488/*
489 * cgroupfs file entry, pointed to from leaf dentry->d_fsdata. Don't
490 * access directly.
491 */
492struct cfent {
493 struct list_head node;
494 struct dentry *dentry;
495 struct cftype *type;
496 struct cgroup_subsys_state *css;
497
498 /* file xattrs */
499 struct simple_xattrs xattrs;
500};
501
502/* seq_file->private points to the following, only ->priv is public */
503struct cgroup_open_file {
504 struct cfent *cfe;
505 void *priv;
506};
507
508/*
541 * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details. This 509 * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details. This
542 * function can be called as long as @cgrp is accessible. 510 * function can be called as long as @cgrp is accessible.
543 */ 511 */
@@ -552,6 +520,18 @@ static inline const char *cgroup_name(const struct cgroup *cgrp)
552 return rcu_dereference(cgrp->name)->name; 520 return rcu_dereference(cgrp->name)->name;
553} 521}
554 522
523static inline struct cgroup_subsys_state *seq_css(struct seq_file *seq)
524{
525 struct cgroup_open_file *of = seq->private;
526 return of->cfe->css;
527}
528
529static inline struct cftype *seq_cft(struct seq_file *seq)
530{
531 struct cgroup_open_file *of = seq->private;
532 return of->cfe->type;
533}
534
555int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 535int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
556int cgroup_rm_cftypes(struct cftype *cfts); 536int cgroup_rm_cftypes(struct cftype *cfts);
557 537
@@ -631,12 +611,8 @@ struct cgroup_subsys {
631#define MAX_CGROUP_TYPE_NAMELEN 32 611#define MAX_CGROUP_TYPE_NAMELEN 32
632 const char *name; 612 const char *name;
633 613
634 /* 614 /* link to parent, protected by cgroup_lock() */
635 * Link to parent, and list entry in parent's children.
636 * Protected by cgroup_lock()
637 */
638 struct cgroupfs_root *root; 615 struct cgroupfs_root *root;
639 struct list_head sibling;
640 616
641 /* list of cftype_sets */ 617 /* list of cftype_sets */
642 struct list_head cftsets; 618 struct list_head cftsets;