History

Merge tag 'trace-v4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt: "Three minor updates - Use the new GFP_RETRY_MAYFAIL to be more aggressive in allocating memory for the ring buffer without causing OOMs - Fix a memory leak in adding and removing instances - Add __rcu annotation to be able to debug RCU usage of function tracing a bit better" * tag 'trace-v4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: trace: fix the errors caused by incompatible type of RCU variables tracing: Fix kmemleak in instance_rmdir tracing/ring_buffer: Try harder to allocate

Linus Torvalds committed 9 years ago

Commit f79ec882 parents b0a7528 f86f4186 files · +40 −26Browse files

Unified · Split

6 files
  1. include/linux/ftrace.h +3 −3
  2. include/linux/trace_events.h +1 −1
  3. kernel/trace/ftrace.c +27 −14
  4. kernel/trace/ring_buffer.c +5 −5
  5. kernel/trace/trace.c +1 −0
  6. kernel/trace/trace.h +3 −3
include/linux/ftrace.h+3−3
@@ -145,8 +145,8 @@ enum { · 144 unmodified lines
145#ifdef CONFIG_DYNAMIC_FTRACE145#ifdef CONFIG_DYNAMIC_FTRACE
146/* The hash used to know what functions callbacks trace */146/* The hash used to know what functions callbacks trace */
147struct ftrace_ops_hash {147struct ftrace_ops_hash {
148 struct ftrace_hash *notrace_hash;148 struct ftrace_hash __rcu *notrace_hash;
149 struct ftrace_hash *filter_hash;149 struct ftrace_hash __rcu *filter_hash;
150 struct mutex regex_lock;150 struct mutex regex_lock;
151};151};
152 152
@@ -168,7 +168,7 @@ static inline void ftrace_free_init_mem(void) { } · 15 unmodified lines
168 */168 */
169struct ftrace_ops {169struct ftrace_ops {
170 ftrace_func_t func;170 ftrace_func_t func;
171 struct ftrace_ops *next;171 struct ftrace_ops __rcu *next;
172 unsigned long flags;172 unsigned long flags;
173 void *private;173 void *private;
174 ftrace_func_t saved_func;174 ftrace_func_t saved_func;
include/linux/trace_events.h+1−1
@@ -338,7 +338,7 @@ enum { · 337 unmodified lines
338struct trace_event_file {338struct trace_event_file {
339 struct list_head list;339 struct list_head list;
340 struct trace_event_call *event_call;340 struct trace_event_call *event_call;
341 struct event_filter *filter;341 struct event_filter __rcu *filter;
342 struct dentry *dir;342 struct dentry *dir;
343 struct trace_array *tr;343 struct trace_array *tr;
344 struct trace_subsystem_dir *system;344 struct trace_subsystem_dir *system;
kernel/trace/ftrace.c+27−14
@@ -113,7 +113,7 @@ static int ftrace_disabled __read_mostly; · 112 unmodified lines
113 113
114static DEFINE_MUTEX(ftrace_lock);114static DEFINE_MUTEX(ftrace_lock);
115 115
116static struct ftrace_ops *ftrace_ops_list __read_mostly = &ftrace_list_end;116static struct ftrace_ops __rcu *ftrace_ops_list __read_mostly = &ftrace_list_end;
117ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;117ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
118static struct ftrace_ops global_ops;118static struct ftrace_ops global_ops;
119 119
@@ -169,8 +169,11 @@ int ftrace_nr_registered_ops(void) · 49 unmodified lines
169 169
170 mutex_lock(&ftrace_lock);170 mutex_lock(&ftrace_lock);
171 171
172 for (ops = ftrace_ops_list;172 for (ops = rcu_dereference_protected(ftrace_ops_list,
173 ops != &ftrace_list_end; ops = ops->next)173 lockdep_is_held(&ftrace_lock));
174 ops != &ftrace_list_end;
175 ops = rcu_dereference_protected(ops->next,
176 lockdep_is_held(&ftrace_lock)))
174 cnt++;177 cnt++;
175 178
176 mutex_unlock(&ftrace_lock);179 mutex_unlock(&ftrace_lock);
@@ -275,10 +278,11 @@ static void update_ftrace_function(void) · 98 unmodified lines
275 * If there's only one ftrace_ops registered, the ftrace_ops_list278 * If there's only one ftrace_ops registered, the ftrace_ops_list
276 * will point to the ops we want.279 * will point to the ops we want.
277 */280 */
278 set_function_trace_op = ftrace_ops_list;281 set_function_trace_op = rcu_dereference_protected(ftrace_ops_list,
282 lockdep_is_held(&ftrace_lock));
279 283
280 /* If there's no ftrace_ops registered, just call the stub function */284 /* If there's no ftrace_ops registered, just call the stub function */
281 if (ftrace_ops_list == &ftrace_list_end) {285 if (set_function_trace_op == &ftrace_list_end) {
282 func = ftrace_stub;286 func = ftrace_stub;
283 287
284 /*288 /*
@@ -286,7 +290,8 @@ static void update_ftrace_function(void) · 1 unmodified line
286 * recursion safe and not dynamic and the arch supports passing ops,290 * recursion safe and not dynamic and the arch supports passing ops,
287 * then have the mcount trampoline call the function directly.291 * then have the mcount trampoline call the function directly.
288 */292 */
289 } else if (ftrace_ops_list->next == &ftrace_list_end) {293 } else if (rcu_dereference_protected(ftrace_ops_list->next,
294 lockdep_is_held(&ftrace_lock)) == &ftrace_list_end) {
290 func = ftrace_ops_get_list_func(ftrace_ops_list);295 func = ftrace_ops_get_list_func(ftrace_ops_list);
291 296
292 } else {297 } else {
@@ -348,9 +353,11 @@ int using_ftrace_ops_list_func(void) · 55 unmodified lines
348 return ftrace_trace_function == ftrace_ops_list_func;353 return ftrace_trace_function == ftrace_ops_list_func;
349}354}
350 355
351static void add_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops)356static void add_ftrace_ops(struct ftrace_ops __rcu **list,
357 struct ftrace_ops *ops)
352{358{
353 ops->next = *list;359 rcu_assign_pointer(ops->next, *list);
360
354 /*361 /*
355 * We are entering ops into the list but another362 * We are entering ops into the list but another
356 * CPU might be walking that list. We need to make sure363 * CPU might be walking that list. We need to make sure
@@ -360,7 +367,8 @@ static void add_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops) · 3 unmodified lines
360 rcu_assign_pointer(*list, ops);367 rcu_assign_pointer(*list, ops);
361}368}
362 369
363static int remove_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops)370static int remove_ftrace_ops(struct ftrace_ops __rcu **list,
371 struct ftrace_ops *ops)
364{372{
365 struct ftrace_ops **p;373 struct ftrace_ops **p;
366 374
@@ -368,7 +376,10 @@ static int remove_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops) · 1 unmodified line
368 * If we are removing the last function, then simply point376 * If we are removing the last function, then simply point
369 * to the ftrace_stub.377 * to the ftrace_stub.
370 */378 */
371 if (*list == ops && ops->next == &ftrace_list_end) {379 if (rcu_dereference_protected(*list,
380 lockdep_is_held(&ftrace_lock)) == ops &&
381 rcu_dereference_protected(ops->next,
382 lockdep_is_held(&ftrace_lock)) == &ftrace_list_end) {
372 *list = &ftrace_list_end;383 *list = &ftrace_list_end;
373 return 0;384 return 0;
374 }385 }
@@ -1569,8 +1580,8 @@ ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs) · 1194 unmodified lines
1569 return 0;1580 return 0;
1570#endif1581#endif
1571 1582
1572 hash.filter_hash = rcu_dereference_raw_notrace(ops->func_hash->filter_hash);1583 rcu_assign_pointer(hash.filter_hash, ops->func_hash->filter_hash);
1573 hash.notrace_hash = rcu_dereference_raw_notrace(ops->func_hash->notrace_hash);1584 rcu_assign_pointer(hash.notrace_hash, ops->func_hash->notrace_hash);
1574 1585
1575 if (hash_contains_ip(ip, &hash))1586 if (hash_contains_ip(ip, &hash))
1576 ret = 1;1587 ret = 1;
@@ -2840,7 +2851,8 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command) · 1263 unmodified lines
2840 * If there's no more ops registered with ftrace, run a2851 * If there's no more ops registered with ftrace, run a
2841 * sanity check to make sure all rec flags are cleared.2852 * sanity check to make sure all rec flags are cleared.
2842 */2853 */
2843 if (ftrace_ops_list == &ftrace_list_end) {2854 if (rcu_dereference_protected(ftrace_ops_list,
2855 lockdep_is_held(&ftrace_lock)) == &ftrace_list_end) {
2844 struct ftrace_page *pg;2856 struct ftrace_page *pg;
2845 struct dyn_ftrace *rec;2857 struct dyn_ftrace *rec;
2846 2858
@@ -6453,7 +6465,8 @@ ftrace_enable_sysctl(struct ctl_table *table, int write, · 3606 unmodified lines
6453 if (ftrace_enabled) {6465 if (ftrace_enabled) {
6454 6466
6455 /* we are starting ftrace again */6467 /* we are starting ftrace again */
6456 if (ftrace_ops_list != &ftrace_list_end)6468 if (rcu_dereference_protected(ftrace_ops_list,
6469 lockdep_is_held(&ftrace_lock)) != &ftrace_list_end)
6457 update_ftrace_function();6470 update_ftrace_function();
6458 6471
6459 ftrace_startup_sysctl();6472 ftrace_startup_sysctl();
kernel/trace/ring_buffer.c+5−5
@@ -1136,12 +1136,12 @@ static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu) · 1135 unmodified lines
1136 for (i = 0; i < nr_pages; i++) {1136 for (i = 0; i < nr_pages; i++) {
1137 struct page *page;1137 struct page *page;
1138 /*1138 /*
1139 * __GFP_NORETRY flag makes sure that the allocation fails1139 * __GFP_RETRY_MAYFAIL flag makes sure that the allocation fails
1140 * gracefully without invoking oom-killer and the system is1140 * gracefully without invoking oom-killer and the system is not
1141 * not destabilized.1141 * destabilized.
1142 */1142 */
1143 bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()),1143 bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()),
1144 GFP_KERNEL | __GFP_NORETRY,1144 GFP_KERNEL | __GFP_RETRY_MAYFAIL,
1145 cpu_to_node(cpu));1145 cpu_to_node(cpu));
1146 if (!bpage)1146 if (!bpage)
1147 goto free_pages;1147 goto free_pages;
@@ -1149,7 +1149,7 @@ static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu) · 1 unmodified line
1149 list_add(&bpage->list, pages);1149 list_add(&bpage->list, pages);
1150 1150
1151 page = alloc_pages_node(cpu_to_node(cpu),1151 page = alloc_pages_node(cpu_to_node(cpu),
1152 GFP_KERNEL | __GFP_NORETRY, 0);1152 GFP_KERNEL | __GFP_RETRY_MAYFAIL, 0);
1153 if (!page)1153 if (!page)
1154 goto free_pages;1154 goto free_pages;
1155 bpage->page = page_address(page);1155 bpage->page = page_address(page);
kernel/trace/trace.c+1−0
@@ -7774,6 +7774,7 @@ static int instance_rmdir(const char *name) · 7773 unmodified lines
7774 }7774 }
7775 kfree(tr->topts);7775 kfree(tr->topts);
7776 7776
7777 free_cpumask_var(tr->tracing_cpumask);
7777 kfree(tr->name);7778 kfree(tr->name);
7778 kfree(tr);7779 kfree(tr);
7779 7780
kernel/trace/trace.h+3−3
@@ -1210,9 +1210,9 @@ struct ftrace_event_field { · 1209 unmodified lines
1210struct event_filter {1210struct event_filter {
1211 int n_preds; /* Number assigned */1211 int n_preds; /* Number assigned */
1212 int a_preds; /* allocated */1212 int a_preds; /* allocated */
1213 struct filter_pred *preds;1213 struct filter_pred __rcu *preds;
1214 struct filter_pred *root;1214 struct filter_pred __rcu *root;
1215 char *filter_string;1215 char *filter_string;
1216};1216};
1217 1217
1218struct event_subsystem {1218struct event_subsystem {