Commit a043e3b2c63445512c5592cbe3c8694f3c655e81
Committed by
Linus Torvalds
1 parent
d19e058330
Exists in
master
and in
4 other branches
cgroup: fix comments
fix: - comments about need_forkexit_callback - comments about release agent - typo and comment style, etc. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 80 additions and 64 deletions Side-by-side Diff
include/linux/cgroup.h
... | ... | @@ -175,7 +175,7 @@ |
175 | 175 | * |
176 | 176 | * |
177 | 177 | * When reading/writing to a file: |
178 | - * - the cgroup to use in file->f_dentry->d_parent->d_fsdata | |
178 | + * - the cgroup to use is file->f_dentry->d_parent->d_fsdata | |
179 | 179 | * - the 'cftype' of the file is file->f_dentry->d_fsdata |
180 | 180 | */ |
181 | 181 |
kernel/cgroup.c
... | ... | @@ -113,9 +113,9 @@ |
113 | 113 | #define dummytop (&rootnode.top_cgroup) |
114 | 114 | |
115 | 115 | /* This flag indicates whether tasks in the fork and exit paths should |
116 | - * take callback_mutex and check for fork/exit handlers to call. This | |
117 | - * avoids us having to do extra work in the fork/exit path if none of the | |
118 | - * subsystems need to be called. | |
116 | + * check for fork/exit handlers to call. This avoids us having to do | |
117 | + * extra work in the fork/exit path if none of the subsystems need to | |
118 | + * be called. | |
119 | 119 | */ |
120 | 120 | static int need_forkexit_callback; |
121 | 121 | |
... | ... | @@ -307,7 +307,6 @@ |
307 | 307 | * template: location in which to build the desired set of subsystem |
308 | 308 | * state objects for the new cgroup group |
309 | 309 | */ |
310 | - | |
311 | 310 | static struct css_set *find_existing_css_set( |
312 | 311 | struct css_set *oldcg, |
313 | 312 | struct cgroup *cgrp, |
... | ... | @@ -354,7 +353,6 @@ |
354 | 353 | * and chains them on tmp through their cgrp_link_list fields. Returns 0 on |
355 | 354 | * success or a negative error |
356 | 355 | */ |
357 | - | |
358 | 356 | static int allocate_cg_links(int count, struct list_head *tmp) |
359 | 357 | { |
360 | 358 | struct cg_cgroup_link *link; |
... | ... | @@ -396,7 +394,6 @@ |
396 | 394 | * substituted into the appropriate hierarchy. Must be called with |
397 | 395 | * cgroup_mutex held |
398 | 396 | */ |
399 | - | |
400 | 397 | static struct css_set *find_css_set( |
401 | 398 | struct css_set *oldcg, struct cgroup *cgrp) |
402 | 399 | { |
... | ... | @@ -507,8 +504,8 @@ |
507 | 504 | * critical pieces of code here. The exception occurs on cgroup_exit(), |
508 | 505 | * when a task in a notify_on_release cgroup exits. Then cgroup_mutex |
509 | 506 | * is taken, and if the cgroup count is zero, a usermode call made |
510 | - * to /sbin/cgroup_release_agent with the name of the cgroup (path | |
511 | - * relative to the root of cgroup file system) as the argument. | |
507 | + * to the release agent with the name of the cgroup (path relative to | |
508 | + * the root of cgroup file system) as the argument. | |
512 | 509 | * |
513 | 510 | * A cgroup can only be deleted if both its 'count' of using tasks |
514 | 511 | * is zero, and its list of 'children' cgroups is empty. Since all |
... | ... | @@ -521,7 +518,7 @@ |
521 | 518 | * |
522 | 519 | * The need for this exception arises from the action of |
523 | 520 | * cgroup_attach_task(), which overwrites one tasks cgroup pointer with |
524 | - * another. It does so using cgroup_mutexe, however there are | |
521 | + * another. It does so using cgroup_mutex, however there are | |
525 | 522 | * several performance critical places that need to reference |
526 | 523 | * task->cgroup without the expense of grabbing a system global |
527 | 524 | * mutex. Therefore except as noted below, when dereferencing or, as |
... | ... | @@ -537,7 +534,6 @@ |
537 | 534 | * cgroup_lock - lock out any changes to cgroup structures |
538 | 535 | * |
539 | 536 | */ |
540 | - | |
541 | 537 | void cgroup_lock(void) |
542 | 538 | { |
543 | 539 | mutex_lock(&cgroup_mutex); |
... | ... | @@ -548,7 +544,6 @@ |
548 | 544 | * |
549 | 545 | * Undo the lock taken in a previous cgroup_lock() call. |
550 | 546 | */ |
551 | - | |
552 | 547 | void cgroup_unlock(void) |
553 | 548 | { |
554 | 549 | mutex_unlock(&cgroup_mutex); |
... | ... | @@ -590,7 +585,6 @@ |
590 | 585 | * Call subsys's pre_destroy handler. |
591 | 586 | * This is called before css refcnt check. |
592 | 587 | */ |
593 | - | |
594 | 588 | static void cgroup_call_pre_destroy(struct cgroup *cgrp) |
595 | 589 | { |
596 | 590 | struct cgroup_subsys *ss; |
... | ... | @@ -600,7 +594,6 @@ |
600 | 594 | return; |
601 | 595 | } |
602 | 596 | |
603 | - | |
604 | 597 | static void cgroup_diput(struct dentry *dentry, struct inode *inode) |
605 | 598 | { |
606 | 599 | /* is dentry a directory ? if so, kfree() associated cgroup */ |
... | ... | @@ -1129,8 +1122,13 @@ |
1129 | 1122 | return dentry->d_fsdata; |
1130 | 1123 | } |
1131 | 1124 | |
1132 | -/* | |
1133 | - * Called with cgroup_mutex held. Writes path of cgroup into buf. | |
1125 | +/** | |
1126 | + * cgroup_path - generate the path of a cgroup | |
1127 | + * @cgrp: the cgroup in question | |
1128 | + * @buf: the buffer to write the path into | |
1129 | + * @buflen: the length of the buffer | |
1130 | + * | |
1131 | + * Called with cgroup_mutex held. Writes path of cgroup into buf. | |
1134 | 1132 | * Returns 0 on success, -errno on error. |
1135 | 1133 | */ |
1136 | 1134 | int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) |
1137 | 1135 | |
... | ... | @@ -1188,11 +1186,13 @@ |
1188 | 1186 | *subsys_id = test_ss->subsys_id; |
1189 | 1187 | } |
1190 | 1188 | |
1191 | -/* | |
1192 | - * Attach task 'tsk' to cgroup 'cgrp' | |
1189 | +/** | |
1190 | + * cgroup_attach_task - attach task 'tsk' to cgroup 'cgrp' | |
1191 | + * @cgrp: the cgroup the task is attaching to | |
1192 | + * @tsk: the task to be attached | |
1193 | 1193 | * |
1194 | - * Call holding cgroup_mutex. May take task_lock of | |
1195 | - * the task 'pid' during call. | |
1194 | + * Call holding cgroup_mutex. May take task_lock of | |
1195 | + * the task 'tsk' during call. | |
1196 | 1196 | */ |
1197 | 1197 | int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk) |
1198 | 1198 | { |
... | ... | @@ -1293,7 +1293,6 @@ |
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | /* The various types of files and directories in a cgroup file system */ |
1296 | - | |
1297 | 1296 | enum cgroup_filetype { |
1298 | 1297 | FILE_ROOT, |
1299 | 1298 | FILE_DIR, |
... | ... | @@ -1584,12 +1583,11 @@ |
1584 | 1583 | } |
1585 | 1584 | |
1586 | 1585 | /* |
1587 | - * cgroup_create_dir - create a directory for an object. | |
1588 | - * cgrp: the cgroup we create the directory for. | |
1589 | - * It must have a valid ->parent field | |
1590 | - * And we are going to fill its ->dentry field. | |
1591 | - * dentry: dentry of the new cgroup | |
1592 | - * mode: mode to set on new directory. | |
1586 | + * cgroup_create_dir - create a directory for an object. | |
1587 | + * @cgrp: the cgroup we create the directory for. It must have a valid | |
1588 | + * ->parent field. And we are going to fill its ->dentry field. | |
1589 | + * @dentry: dentry of the new cgroup | |
1590 | + * @mode: mode to set on new directory. | |
1593 | 1591 | */ |
1594 | 1592 | static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry, |
1595 | 1593 | int mode) |
... | ... | @@ -1651,8 +1649,12 @@ |
1651 | 1649 | return 0; |
1652 | 1650 | } |
1653 | 1651 | |
1654 | -/* Count the number of tasks in a cgroup. */ | |
1655 | - | |
1652 | +/** | |
1653 | + * cgroup_task_count - count the number of tasks in a cgroup. | |
1654 | + * @cgrp: the cgroup in question | |
1655 | + * | |
1656 | + * Return the number of tasks in the cgroup. | |
1657 | + */ | |
1656 | 1658 | int cgroup_task_count(const struct cgroup *cgrp) |
1657 | 1659 | { |
1658 | 1660 | int count = 0; |
1659 | 1661 | |
... | ... | @@ -1962,12 +1964,13 @@ |
1962 | 1964 | } |
1963 | 1965 | |
1964 | 1966 | /** |
1965 | - * Build and fill cgroupstats so that taskstats can export it to user | |
1966 | - * space. | |
1967 | - * | |
1967 | + * cgroupstats_build - build and fill cgroupstats | |
1968 | 1968 | * @stats: cgroupstats to fill information into |
1969 | 1969 | * @dentry: A dentry entry belonging to the cgroup for which stats have |
1970 | 1970 | * been requested. |
1971 | + * | |
1972 | + * Build and fill cgroupstats so that taskstats can export it to user | |
1973 | + * space. | |
1971 | 1974 | */ |
1972 | 1975 | int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) |
1973 | 1976 | { |
1974 | 1977 | |
1975 | 1978 | |
... | ... | @@ -2199,14 +2202,13 @@ |
2199 | 2202 | } |
2200 | 2203 | |
2201 | 2204 | /* |
2202 | - * cgroup_create - create a cgroup | |
2203 | - * parent: cgroup that will be parent of the new cgroup. | |
2204 | - * name: name of the new cgroup. Will be strcpy'ed. | |
2205 | - * mode: mode to set on new inode | |
2205 | + * cgroup_create - create a cgroup | |
2206 | + * @parent: cgroup that will be parent of the new cgroup | |
2207 | + * @dentry: dentry of the new cgroup | |
2208 | + * @mode: mode to set on new inode | |
2206 | 2209 | * |
2207 | - * Must be called with the mutex on the parent inode held | |
2210 | + * Must be called with the mutex on the parent inode held | |
2208 | 2211 | */ |
2209 | - | |
2210 | 2212 | static long cgroup_create(struct cgroup *parent, struct dentry *dentry, |
2211 | 2213 | int mode) |
2212 | 2214 | { |
2213 | 2215 | |
2214 | 2216 | |
... | ... | @@ -2349,13 +2351,12 @@ |
2349 | 2351 | parent = cgrp->parent; |
2350 | 2352 | root = cgrp->root; |
2351 | 2353 | sb = root->sb; |
2354 | + | |
2352 | 2355 | /* |
2353 | - * Call pre_destroy handlers of subsys | |
2356 | + * Call pre_destroy handlers of subsys. Notify subsystems | |
2357 | + * that rmdir() request comes. | |
2354 | 2358 | */ |
2355 | 2359 | cgroup_call_pre_destroy(cgrp); |
2356 | - /* | |
2357 | - * Notify subsyses that rmdir() request comes. | |
2358 | - */ | |
2359 | 2360 | |
2360 | 2361 | if (cgroup_has_css_refs(cgrp)) { |
2361 | 2362 | mutex_unlock(&cgroup_mutex); |
... | ... | @@ -2431,8 +2432,10 @@ |
2431 | 2432 | } |
2432 | 2433 | |
2433 | 2434 | /** |
2434 | - * cgroup_init_early - initialize cgroups at system boot, and | |
2435 | - * initialize any subsystems that request early init. | |
2435 | + * cgroup_init_early - cgroup initialization at system boot | |
2436 | + * | |
2437 | + * Initialize cgroups at system boot, and initialize any | |
2438 | + * subsystems that request early init. | |
2436 | 2439 | */ |
2437 | 2440 | int __init cgroup_init_early(void) |
2438 | 2441 | { |
... | ... | @@ -2474,8 +2477,10 @@ |
2474 | 2477 | } |
2475 | 2478 | |
2476 | 2479 | /** |
2477 | - * cgroup_init - register cgroup filesystem and /proc file, and | |
2478 | - * initialize any subsystems that didn't request early init. | |
2480 | + * cgroup_init - cgroup initialization | |
2481 | + * | |
2482 | + * Register cgroup filesystem and /proc file, and initialize | |
2483 | + * any subsystems that didn't request early init. | |
2479 | 2484 | */ |
2480 | 2485 | int __init cgroup_init(void) |
2481 | 2486 | { |
... | ... | @@ -2618,7 +2623,7 @@ |
2618 | 2623 | |
2619 | 2624 | /** |
2620 | 2625 | * cgroup_fork - attach newly forked task to its parents cgroup. |
2621 | - * @tsk: pointer to task_struct of forking parent process. | |
2626 | + * @child: pointer to task_struct of forking parent process. | |
2622 | 2627 | * |
2623 | 2628 | * Description: A task inherits its parent's cgroup at fork(). |
2624 | 2629 | * |
... | ... | @@ -2642,9 +2647,12 @@ |
2642 | 2647 | } |
2643 | 2648 | |
2644 | 2649 | /** |
2645 | - * cgroup_fork_callbacks - called on a new task very soon before | |
2646 | - * adding it to the tasklist. No need to take any locks since no-one | |
2647 | - * can be operating on this task | |
2650 | + * cgroup_fork_callbacks - run fork callbacks | |
2651 | + * @child: the new task | |
2652 | + * | |
2653 | + * Called on a new task very soon before adding it to the | |
2654 | + * tasklist. No need to take any locks since no-one can | |
2655 | + * be operating on this task. | |
2648 | 2656 | */ |
2649 | 2657 | void cgroup_fork_callbacks(struct task_struct *child) |
2650 | 2658 | { |
... | ... | @@ -2659,11 +2667,14 @@ |
2659 | 2667 | } |
2660 | 2668 | |
2661 | 2669 | /** |
2662 | - * cgroup_post_fork - called on a new task after adding it to the | |
2663 | - * task list. Adds the task to the list running through its css_set | |
2664 | - * if necessary. Has to be after the task is visible on the task list | |
2665 | - * in case we race with the first call to cgroup_iter_start() - to | |
2666 | - * guarantee that the new task ends up on its list. */ | |
2670 | + * cgroup_post_fork - called on a new task after adding it to the task list | |
2671 | + * @child: the task in question | |
2672 | + * | |
2673 | + * Adds the task to the list running through its css_set if necessary. | |
2674 | + * Has to be after the task is visible on the task list in case we race | |
2675 | + * with the first call to cgroup_iter_start() - to guarantee that the | |
2676 | + * new task ends up on its list. | |
2677 | + */ | |
2667 | 2678 | void cgroup_post_fork(struct task_struct *child) |
2668 | 2679 | { |
2669 | 2680 | if (use_task_css_set_links) { |
... | ... | @@ -2676,6 +2687,7 @@ |
2676 | 2687 | /** |
2677 | 2688 | * cgroup_exit - detach cgroup from exiting task |
2678 | 2689 | * @tsk: pointer to task_struct of exiting process |
2690 | + * @run_callback: run exit callbacks? | |
2679 | 2691 | * |
2680 | 2692 | * Description: Detach cgroup from @tsk and release it. |
2681 | 2693 | * |
... | ... | @@ -2706,7 +2718,6 @@ |
2706 | 2718 | * top_cgroup isn't going away, and either task has PF_EXITING set, |
2707 | 2719 | * which wards off any cgroup_attach_task() attempts, or task is a failed |
2708 | 2720 | * fork, never visible to cgroup_attach_task. |
2709 | - * | |
2710 | 2721 | */ |
2711 | 2722 | void cgroup_exit(struct task_struct *tsk, int run_callbacks) |
2712 | 2723 | { |
... | ... | @@ -2743,9 +2754,13 @@ |
2743 | 2754 | } |
2744 | 2755 | |
2745 | 2756 | /** |
2746 | - * cgroup_clone - duplicate the current cgroup in the hierarchy | |
2747 | - * that the given subsystem is attached to, and move this task into | |
2748 | - * the new child | |
2757 | + * cgroup_clone - clone the cgroup the given subsystem is attached to | |
2758 | + * @tsk: the task to be moved | |
2759 | + * @subsys: the given subsystem | |
2760 | + * | |
2761 | + * Duplicate the current cgroup in the hierarchy that the given | |
2762 | + * subsystem is attached to, and move this task into the new | |
2763 | + * child. | |
2749 | 2764 | */ |
2750 | 2765 | int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys) |
2751 | 2766 | { |
2752 | 2767 | |
... | ... | @@ -2858,10 +2873,13 @@ |
2858 | 2873 | return ret; |
2859 | 2874 | } |
2860 | 2875 | |
2861 | -/* | |
2862 | - * See if "cgrp" is a descendant of the current task's cgroup in | |
2863 | - * the appropriate hierarchy | |
2876 | +/** | |
2877 | + * cgroup_is_descendant - see if @cgrp is a descendant of current task's cgrp | |
2878 | + * @cgrp: the cgroup in question | |
2864 | 2879 | * |
2880 | + * See if @cgrp is a descendant of the current task's cgroup in | |
2881 | + * the appropriate hierarchy. | |
2882 | + * | |
2865 | 2883 | * If we are sending in dummytop, then presumably we are creating |
2866 | 2884 | * the top cgroup in the subsystem. |
2867 | 2885 | * |
2868 | 2886 | |
... | ... | @@ -2939,9 +2957,7 @@ |
2939 | 2957 | * release agent task. We don't bother to wait because the caller of |
2940 | 2958 | * this routine has no use for the exit status of the release agent |
2941 | 2959 | * task, so no sense holding our caller up for that. |
2942 | - * | |
2943 | 2960 | */ |
2944 | - | |
2945 | 2961 | static void cgroup_release_agent(struct work_struct *work) |
2946 | 2962 | { |
2947 | 2963 | BUG_ON(work != &release_agent_work); |