diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cgroup/cgroup-internal.h | 26 | ||||
| -rw-r--r-- | kernel/cgroup/cgroup-v1.c | 4 | ||||
| -rw-r--r-- | kernel/cgroup/cgroup.c | 12 |
3 files changed, 35 insertions, 7 deletions
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h index 77ff1cd6a252..75568fcf2180 100644 --- a/kernel/cgroup/cgroup-internal.h +++ b/kernel/cgroup/cgroup-internal.h | |||
| @@ -8,6 +8,32 @@ | |||
| 8 | #include <linux/list.h> | 8 | #include <linux/list.h> |
| 9 | #include <linux/refcount.h> | 9 | #include <linux/refcount.h> |
| 10 | 10 | ||
| 11 | #define TRACE_CGROUP_PATH_LEN 1024 | ||
| 12 | extern spinlock_t trace_cgroup_path_lock; | ||
| 13 | extern char trace_cgroup_path[TRACE_CGROUP_PATH_LEN]; | ||
| 14 | |||
| 15 | /* | ||
| 16 | * cgroup_path() takes a spin lock. It is good practice not to take | ||
| 17 | * spin locks within trace point handlers, as they are mostly hidden | ||
| 18 | * from normal view. As cgroup_path() can take the kernfs_rename_lock | ||
| 19 | * spin lock, it is best to not call that function from the trace event | ||
| 20 | * handler. | ||
| 21 | * | ||
| 22 | * Note: trace_cgroup_##type##_enabled() is a static branch that will only | ||
| 23 | * be set when the trace event is enabled. | ||
| 24 | */ | ||
| 25 | #define TRACE_CGROUP_PATH(type, cgrp, ...) \ | ||
| 26 | do { \ | ||
| 27 | if (trace_cgroup_##type##_enabled()) { \ | ||
| 28 | spin_lock(&trace_cgroup_path_lock); \ | ||
| 29 | cgroup_path(cgrp, trace_cgroup_path, \ | ||
| 30 | TRACE_CGROUP_PATH_LEN); \ | ||
| 31 | trace_cgroup_##type(cgrp, trace_cgroup_path, \ | ||
| 32 | ##__VA_ARGS__); \ | ||
| 33 | spin_unlock(&trace_cgroup_path_lock); \ | ||
| 34 | } \ | ||
| 35 | } while (0) | ||
| 36 | |||
| 11 | /* | 37 | /* |
| 12 | * A cgroup can be associated with multiple css_sets as different tasks may | 38 | * A cgroup can be associated with multiple css_sets as different tasks may |
| 13 | * belong to different cgroups on different hierarchies. In the other | 39 | * belong to different cgroups on different hierarchies. In the other |
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index 8b4f0768efd6..51063e7a93c2 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c | |||
| @@ -135,7 +135,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from) | |||
| 135 | if (task) { | 135 | if (task) { |
| 136 | ret = cgroup_migrate(task, false, &mgctx); | 136 | ret = cgroup_migrate(task, false, &mgctx); |
| 137 | if (!ret) | 137 | if (!ret) |
| 138 | trace_cgroup_transfer_tasks(to, task, false); | 138 | TRACE_CGROUP_PATH(transfer_tasks, to, task, false); |
| 139 | put_task_struct(task); | 139 | put_task_struct(task); |
| 140 | } | 140 | } |
| 141 | } while (task && !ret); | 141 | } while (task && !ret); |
| @@ -865,7 +865,7 @@ static int cgroup1_rename(struct kernfs_node *kn, struct kernfs_node *new_parent | |||
| 865 | 865 | ||
| 866 | ret = kernfs_rename(kn, new_parent, new_name_str); | 866 | ret = kernfs_rename(kn, new_parent, new_name_str); |
| 867 | if (!ret) | 867 | if (!ret) |
| 868 | trace_cgroup_rename(cgrp); | 868 | TRACE_CGROUP_PATH(rename, cgrp); |
| 869 | 869 | ||
| 870 | mutex_unlock(&cgroup_mutex); | 870 | mutex_unlock(&cgroup_mutex); |
| 871 | 871 | ||
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 35cf3d71f8aa..aae10baf1902 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
| @@ -83,6 +83,9 @@ EXPORT_SYMBOL_GPL(cgroup_mutex); | |||
| 83 | EXPORT_SYMBOL_GPL(css_set_lock); | 83 | EXPORT_SYMBOL_GPL(css_set_lock); |
| 84 | #endif | 84 | #endif |
| 85 | 85 | ||
| 86 | DEFINE_SPINLOCK(trace_cgroup_path_lock); | ||
| 87 | char trace_cgroup_path[TRACE_CGROUP_PATH_LEN]; | ||
| 88 | |||
| 86 | /* | 89 | /* |
| 87 | * Protects cgroup_idr and css_idr so that IDs can be released without | 90 | * Protects cgroup_idr and css_idr so that IDs can be released without |
| 88 | * grabbing cgroup_mutex. | 91 | * grabbing cgroup_mutex. |
| @@ -2638,7 +2641,7 @@ int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader, | |||
| 2638 | cgroup_migrate_finish(&mgctx); | 2641 | cgroup_migrate_finish(&mgctx); |
| 2639 | 2642 | ||
| 2640 | if (!ret) | 2643 | if (!ret) |
| 2641 | trace_cgroup_attach_task(dst_cgrp, leader, threadgroup); | 2644 | TRACE_CGROUP_PATH(attach_task, dst_cgrp, leader, threadgroup); |
| 2642 | 2645 | ||
| 2643 | return ret; | 2646 | return ret; |
| 2644 | } | 2647 | } |
| @@ -4636,7 +4639,7 @@ static void css_release_work_fn(struct work_struct *work) | |||
| 4636 | struct cgroup *tcgrp; | 4639 | struct cgroup *tcgrp; |
| 4637 | 4640 | ||
| 4638 | /* cgroup release path */ | 4641 | /* cgroup release path */ |
| 4639 | trace_cgroup_release(cgrp); | 4642 | TRACE_CGROUP_PATH(release, cgrp); |
| 4640 | 4643 | ||
| 4641 | if (cgroup_on_dfl(cgrp)) | 4644 | if (cgroup_on_dfl(cgrp)) |
| 4642 | cgroup_rstat_flush(cgrp); | 4645 | cgroup_rstat_flush(cgrp); |
| @@ -4979,7 +4982,7 @@ int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, umode_t mode) | |||
| 4979 | if (ret) | 4982 | if (ret) |
| 4980 | goto out_destroy; | 4983 | goto out_destroy; |
| 4981 | 4984 | ||
| 4982 | trace_cgroup_mkdir(cgrp); | 4985 | TRACE_CGROUP_PATH(mkdir, cgrp); |
| 4983 | 4986 | ||
| 4984 | /* let's create and online css's */ | 4987 | /* let's create and online css's */ |
| 4985 | kernfs_activate(kn); | 4988 | kernfs_activate(kn); |
| @@ -5167,9 +5170,8 @@ int cgroup_rmdir(struct kernfs_node *kn) | |||
| 5167 | return 0; | 5170 | return 0; |
| 5168 | 5171 | ||
| 5169 | ret = cgroup_destroy_locked(cgrp); | 5172 | ret = cgroup_destroy_locked(cgrp); |
| 5170 | |||
| 5171 | if (!ret) | 5173 | if (!ret) |
| 5172 | trace_cgroup_rmdir(cgrp); | 5174 | TRACE_CGROUP_PATH(rmdir, cgrp); |
| 5173 | 5175 | ||
| 5174 | cgroup_kn_unlock(kn); | 5176 | cgroup_kn_unlock(kn); |
| 5175 | return ret; | 5177 | return ret; |
