diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-21 20:51:34 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-21 20:51:34 -0500 |
| commit | f075e0f6993f41c72dbb1d3e7a2d7740f14e89e2 (patch) | |
| tree | a25b464a67fffc6f43940e0e85e2735a48bb1ad7 /include/linux | |
| parent | 5cb7398caf69e3943df78435a19a8a77fe8b9463 (diff) | |
| parent | dd4b0a4676907481256d16d5de0851b315a6f22c (diff) | |
Merge branch 'for-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo:
"The bulk of changes are cleanups and preparations for the upcoming
kernfs conversion.
- cgroup_event mechanism which is and will be used only by memcg is
moved to memcg.
- pidlist handling is updated so that it can be served by seq_file.
Also, the list is not sorted if sane_behavior. cgroup
documentation explicitly states that the file is not sorted but it
has been for quite some time.
- All cgroup file handling now happens on top of seq_file. This is
to prepare for kernfs conversion. In addition, all operations are
restructured so that they map 1-1 to kernfs operations.
- Other cleanups and low-pri fixes"
* 'for-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: (40 commits)
cgroup: trivial style updates
cgroup: remove stray references to css_id
doc: cgroups: Fix typo in doc/cgroups
cgroup: fix fail path in cgroup_load_subsys()
cgroup: fix missing unlock on error in cgroup_load_subsys()
cgroup: remove for_each_root_subsys()
cgroup: implement for_each_css()
cgroup: factor out cgroup_subsys_state creation into create_css()
cgroup: combine css handling loops in cgroup_create()
cgroup: reorder operations in cgroup_create()
cgroup: make for_each_subsys() useable under cgroup_root_mutex
cgroup: css iterations and css_from_dir() are safe under cgroup_mutex
cgroup: unify pidlist and other file handling
cgroup: replace cftype->read_seq_string() with cftype->seq_show()
cgroup: attach cgroup_open_file to all cgroup files
cgroup: generalize cgroup_pidlist_open_file
cgroup: unify read path so that seq_file is always used
cgroup: unify cgroup_write_X64() and cgroup_write_string()
cgroup: remove cftype->read(), ->read_map() and ->write()
hugetlb_cgroup: convert away from cftype->read()
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/cgroup.h | 112 | ||||
| -rw-r--r-- | include/linux/vmpressure.h | 8 |
2 files changed, 47 insertions, 73 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; | |||
| 28 | struct cgroup_subsys; | 29 | struct cgroup_subsys; |
| 29 | struct inode; | 30 | struct inode; |
| 30 | struct cgroup; | 31 | struct cgroup; |
| 31 | struct css_id; | ||
| 32 | struct eventfd_ctx; | ||
| 33 | 32 | ||
| 34 | extern int cgroup_init_early(void); | 33 | extern int cgroup_init_early(void); |
| 35 | extern int cgroup_init(void); | 34 | extern 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 | |||
| 396 | struct 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 | */ | ||
| 492 | struct 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 */ | ||
| 503 | struct 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 | ||
| 523 | static 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 | |||
| 529 | static 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 | |||
| 555 | int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); | 535 | int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); |
| 556 | int cgroup_rm_cftypes(struct cftype *cfts); | 536 | int 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; |
diff --git a/include/linux/vmpressure.h b/include/linux/vmpressure.h index 3f3788d49362..3e4535876d37 100644 --- a/include/linux/vmpressure.h +++ b/include/linux/vmpressure.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <linux/gfp.h> | 7 | #include <linux/gfp.h> |
| 8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
| 9 | #include <linux/cgroup.h> | 9 | #include <linux/cgroup.h> |
| 10 | #include <linux/eventfd.h> | ||
| 10 | 11 | ||
| 11 | struct vmpressure { | 12 | struct vmpressure { |
| 12 | unsigned long scanned; | 13 | unsigned long scanned; |
| @@ -33,13 +34,10 @@ extern void vmpressure_init(struct vmpressure *vmpr); | |||
| 33 | extern void vmpressure_cleanup(struct vmpressure *vmpr); | 34 | extern void vmpressure_cleanup(struct vmpressure *vmpr); |
| 34 | extern struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg); | 35 | extern struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg); |
| 35 | extern struct cgroup_subsys_state *vmpressure_to_css(struct vmpressure *vmpr); | 36 | extern struct cgroup_subsys_state *vmpressure_to_css(struct vmpressure *vmpr); |
| 36 | extern struct vmpressure *css_to_vmpressure(struct cgroup_subsys_state *css); | 37 | extern int vmpressure_register_event(struct mem_cgroup *memcg, |
| 37 | extern int vmpressure_register_event(struct cgroup_subsys_state *css, | ||
| 38 | struct cftype *cft, | ||
| 39 | struct eventfd_ctx *eventfd, | 38 | struct eventfd_ctx *eventfd, |
| 40 | const char *args); | 39 | const char *args); |
| 41 | extern void vmpressure_unregister_event(struct cgroup_subsys_state *css, | 40 | extern void vmpressure_unregister_event(struct mem_cgroup *memcg, |
| 42 | struct cftype *cft, | ||
| 43 | struct eventfd_ctx *eventfd); | 41 | struct eventfd_ctx *eventfd); |
| 44 | #else | 42 | #else |
| 45 | static inline void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, | 43 | static inline void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, |
