Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup

Pull cgroup updates from Tejun Heo:
"Just one commit from Steven to take out spin lock from trace event
handlers"

* 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
cgroup/tracing: Move taking of spin lock out of trace event handlers

+58 -31
+23 -24
include/trace/events/cgroup.h
··· 53 53 54 54 DECLARE_EVENT_CLASS(cgroup, 55 55 56 - TP_PROTO(struct cgroup *cgrp), 56 + TP_PROTO(struct cgroup *cgrp, const char *path), 57 57 58 - TP_ARGS(cgrp), 58 + TP_ARGS(cgrp, path), 59 59 60 60 TP_STRUCT__entry( 61 61 __field( int, root ) 62 62 __field( int, id ) 63 63 __field( int, level ) 64 - __dynamic_array(char, path, 65 - cgroup_path(cgrp, NULL, 0) + 1) 64 + __string( path, path ) 66 65 ), 67 66 68 67 TP_fast_assign( 69 68 __entry->root = cgrp->root->hierarchy_id; 70 69 __entry->id = cgrp->id; 71 70 __entry->level = cgrp->level; 72 - cgroup_path(cgrp, __get_dynamic_array(path), 73 - __get_dynamic_array_len(path)); 71 + __assign_str(path, path); 74 72 ), 75 73 76 74 TP_printk("root=%d id=%d level=%d path=%s", ··· 77 79 78 80 DEFINE_EVENT(cgroup, cgroup_mkdir, 79 81 80 - TP_PROTO(struct cgroup *cgroup), 82 + TP_PROTO(struct cgroup *cgrp, const char *path), 81 83 82 - TP_ARGS(cgroup) 84 + TP_ARGS(cgrp, path) 83 85 ); 84 86 85 87 DEFINE_EVENT(cgroup, cgroup_rmdir, 86 88 87 - TP_PROTO(struct cgroup *cgroup), 89 + TP_PROTO(struct cgroup *cgrp, const char *path), 88 90 89 - TP_ARGS(cgroup) 91 + TP_ARGS(cgrp, path) 90 92 ); 91 93 92 94 DEFINE_EVENT(cgroup, cgroup_release, 93 95 94 - TP_PROTO(struct cgroup *cgroup), 96 + TP_PROTO(struct cgroup *cgrp, const char *path), 95 97 96 - TP_ARGS(cgroup) 98 + TP_ARGS(cgrp, path) 97 99 ); 98 100 99 101 DEFINE_EVENT(cgroup, cgroup_rename, 100 102 101 - TP_PROTO(struct cgroup *cgroup), 103 + TP_PROTO(struct cgroup *cgrp, const char *path), 102 104 103 - TP_ARGS(cgroup) 105 + TP_ARGS(cgrp, path) 104 106 ); 105 107 106 108 DECLARE_EVENT_CLASS(cgroup_migrate, 107 109 108 - TP_PROTO(struct cgroup *dst_cgrp, struct task_struct *task, bool threadgroup), 110 + TP_PROTO(struct cgroup *dst_cgrp, const char *path, 111 + struct task_struct *task, bool threadgroup), 109 112 110 - TP_ARGS(dst_cgrp, task, threadgroup), 113 + TP_ARGS(dst_cgrp, path, task, threadgroup), 111 114 112 115 TP_STRUCT__entry( 113 116 __field( int, dst_root ) 114 117 __field( int, dst_id ) 115 118 __field( int, dst_level ) 116 - __dynamic_array(char, dst_path, 117 - cgroup_path(dst_cgrp, NULL, 0) + 1) 118 119 __field( int, pid ) 120 + __string( dst_path, path ) 119 121 __string( comm, task->comm ) 120 122 ), 121 123 ··· 123 125 __entry->dst_root = dst_cgrp->root->hierarchy_id; 124 126 __entry->dst_id = dst_cgrp->id; 125 127 __entry->dst_level = dst_cgrp->level; 126 - cgroup_path(dst_cgrp, __get_dynamic_array(dst_path), 127 - __get_dynamic_array_len(dst_path)); 128 + __assign_str(dst_path, path); 128 129 __entry->pid = task->pid; 129 130 __assign_str(comm, task->comm); 130 131 ), ··· 135 138 136 139 DEFINE_EVENT(cgroup_migrate, cgroup_attach_task, 137 140 138 - TP_PROTO(struct cgroup *dst_cgrp, struct task_struct *task, bool threadgroup), 141 + TP_PROTO(struct cgroup *dst_cgrp, const char *path, 142 + struct task_struct *task, bool threadgroup), 139 143 140 - TP_ARGS(dst_cgrp, task, threadgroup) 144 + TP_ARGS(dst_cgrp, path, task, threadgroup) 141 145 ); 142 146 143 147 DEFINE_EVENT(cgroup_migrate, cgroup_transfer_tasks, 144 148 145 - TP_PROTO(struct cgroup *dst_cgrp, struct task_struct *task, bool threadgroup), 149 + TP_PROTO(struct cgroup *dst_cgrp, const char *path, 150 + struct task_struct *task, bool threadgroup), 146 151 147 - TP_ARGS(dst_cgrp, task, threadgroup) 152 + TP_ARGS(dst_cgrp, path, task, threadgroup) 148 153 ); 149 154 150 155 #endif /* _TRACE_CGROUP_H */
+26
kernel/cgroup/cgroup-internal.h
··· 8 8 #include <linux/list.h> 9 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 38 * A cgroup can be associated with multiple css_sets as different tasks may 13 39 * belong to different cgroups on different hierarchies. In the other
+2 -2
kernel/cgroup/cgroup-v1.c
··· 135 135 if (task) { 136 136 ret = cgroup_migrate(task, false, &mgctx); 137 137 if (!ret) 138 - trace_cgroup_transfer_tasks(to, task, false); 138 + TRACE_CGROUP_PATH(transfer_tasks, to, task, false); 139 139 put_task_struct(task); 140 140 } 141 141 } while (task && !ret); ··· 865 865 866 866 ret = kernfs_rename(kn, new_parent, new_name_str); 867 867 if (!ret) 868 - trace_cgroup_rename(cgrp); 868 + TRACE_CGROUP_PATH(rename, cgrp); 869 869 870 870 mutex_unlock(&cgroup_mutex); 871 871
+7 -5
kernel/cgroup/cgroup.c
··· 83 83 EXPORT_SYMBOL_GPL(css_set_lock); 84 84 #endif 85 85 86 + DEFINE_SPINLOCK(trace_cgroup_path_lock); 87 + char trace_cgroup_path[TRACE_CGROUP_PATH_LEN]; 88 + 86 89 /* 87 90 * Protects cgroup_idr and css_idr so that IDs can be released without 88 91 * grabbing cgroup_mutex. ··· 2641 2638 cgroup_migrate_finish(&mgctx); 2642 2639 2643 2640 if (!ret) 2644 - trace_cgroup_attach_task(dst_cgrp, leader, threadgroup); 2641 + TRACE_CGROUP_PATH(attach_task, dst_cgrp, leader, threadgroup); 2645 2642 2646 2643 return ret; 2647 2644 } ··· 4639 4636 struct cgroup *tcgrp; 4640 4637 4641 4638 /* cgroup release path */ 4642 - trace_cgroup_release(cgrp); 4639 + TRACE_CGROUP_PATH(release, cgrp); 4643 4640 4644 4641 if (cgroup_on_dfl(cgrp)) 4645 4642 cgroup_rstat_flush(cgrp); ··· 4982 4979 if (ret) 4983 4980 goto out_destroy; 4984 4981 4985 - trace_cgroup_mkdir(cgrp); 4982 + TRACE_CGROUP_PATH(mkdir, cgrp); 4986 4983 4987 4984 /* let's create and online css's */ 4988 4985 kernfs_activate(kn); ··· 5170 5167 return 0; 5171 5168 5172 5169 ret = cgroup_destroy_locked(cgrp); 5173 - 5174 5170 if (!ret) 5175 - trace_cgroup_rmdir(cgrp); 5171 + TRACE_CGROUP_PATH(rmdir, cgrp); 5176 5172 5177 5173 cgroup_kn_unlock(kn); 5178 5174 return ret;