diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 37 | ||||
-rw-r--r-- | kernel/trace/trace.h | 1 |
2 files changed, 21 insertions, 17 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 496f94d57698..7974ba20557d 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3166,11 +3166,6 @@ static const struct file_operations show_traces_fops = { | |||
3166 | }; | 3166 | }; |
3167 | 3167 | ||
3168 | /* | 3168 | /* |
3169 | * Only trace on a CPU if the bitmask is set: | ||
3170 | */ | ||
3171 | static cpumask_var_t tracing_cpumask; | ||
3172 | |||
3173 | /* | ||
3174 | * The tracer itself will not take this lock, but still we want | 3169 | * The tracer itself will not take this lock, but still we want |
3175 | * to provide a consistent cpumask to user-space: | 3170 | * to provide a consistent cpumask to user-space: |
3176 | */ | 3171 | */ |
@@ -3186,11 +3181,12 @@ static ssize_t | |||
3186 | tracing_cpumask_read(struct file *filp, char __user *ubuf, | 3181 | tracing_cpumask_read(struct file *filp, char __user *ubuf, |
3187 | size_t count, loff_t *ppos) | 3182 | size_t count, loff_t *ppos) |
3188 | { | 3183 | { |
3184 | struct trace_array *tr = file_inode(filp)->i_private; | ||
3189 | int len; | 3185 | int len; |
3190 | 3186 | ||
3191 | mutex_lock(&tracing_cpumask_update_lock); | 3187 | mutex_lock(&tracing_cpumask_update_lock); |
3192 | 3188 | ||
3193 | len = cpumask_scnprintf(mask_str, count, tracing_cpumask); | 3189 | len = cpumask_scnprintf(mask_str, count, tr->tracing_cpumask); |
3194 | if (count - len < 2) { | 3190 | if (count - len < 2) { |
3195 | count = -EINVAL; | 3191 | count = -EINVAL; |
3196 | goto out_err; | 3192 | goto out_err; |
@@ -3208,7 +3204,7 @@ static ssize_t | |||
3208 | tracing_cpumask_write(struct file *filp, const char __user *ubuf, | 3204 | tracing_cpumask_write(struct file *filp, const char __user *ubuf, |
3209 | size_t count, loff_t *ppos) | 3205 | size_t count, loff_t *ppos) |
3210 | { | 3206 | { |
3211 | struct trace_array *tr = filp->private_data; | 3207 | struct trace_array *tr = file_inode(filp)->i_private; |
3212 | cpumask_var_t tracing_cpumask_new; | 3208 | cpumask_var_t tracing_cpumask_new; |
3213 | int err, cpu; | 3209 | int err, cpu; |
3214 | 3210 | ||
@@ -3228,12 +3224,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf, | |||
3228 | * Increase/decrease the disabled counter if we are | 3224 | * Increase/decrease the disabled counter if we are |
3229 | * about to flip a bit in the cpumask: | 3225 | * about to flip a bit in the cpumask: |
3230 | */ | 3226 | */ |
3231 | if (cpumask_test_cpu(cpu, tracing_cpumask) && | 3227 | if (cpumask_test_cpu(cpu, tr->tracing_cpumask) && |
3232 | !cpumask_test_cpu(cpu, tracing_cpumask_new)) { | 3228 | !cpumask_test_cpu(cpu, tracing_cpumask_new)) { |
3233 | atomic_inc(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled); | 3229 | atomic_inc(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled); |
3234 | ring_buffer_record_disable_cpu(tr->trace_buffer.buffer, cpu); | 3230 | ring_buffer_record_disable_cpu(tr->trace_buffer.buffer, cpu); |
3235 | } | 3231 | } |
3236 | if (!cpumask_test_cpu(cpu, tracing_cpumask) && | 3232 | if (!cpumask_test_cpu(cpu, tr->tracing_cpumask) && |
3237 | cpumask_test_cpu(cpu, tracing_cpumask_new)) { | 3233 | cpumask_test_cpu(cpu, tracing_cpumask_new)) { |
3238 | atomic_dec(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled); | 3234 | atomic_dec(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled); |
3239 | ring_buffer_record_enable_cpu(tr->trace_buffer.buffer, cpu); | 3235 | ring_buffer_record_enable_cpu(tr->trace_buffer.buffer, cpu); |
@@ -3242,7 +3238,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf, | |||
3242 | arch_spin_unlock(&ftrace_max_lock); | 3238 | arch_spin_unlock(&ftrace_max_lock); |
3243 | local_irq_enable(); | 3239 | local_irq_enable(); |
3244 | 3240 | ||
3245 | cpumask_copy(tracing_cpumask, tracing_cpumask_new); | 3241 | cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new); |
3246 | 3242 | ||
3247 | mutex_unlock(&tracing_cpumask_update_lock); | 3243 | mutex_unlock(&tracing_cpumask_update_lock); |
3248 | free_cpumask_var(tracing_cpumask_new); | 3244 | free_cpumask_var(tracing_cpumask_new); |
@@ -3256,9 +3252,10 @@ err_unlock: | |||
3256 | } | 3252 | } |
3257 | 3253 | ||
3258 | static const struct file_operations tracing_cpumask_fops = { | 3254 | static const struct file_operations tracing_cpumask_fops = { |
3259 | .open = tracing_open_generic, | 3255 | .open = tracing_open_generic_tr, |
3260 | .read = tracing_cpumask_read, | 3256 | .read = tracing_cpumask_read, |
3261 | .write = tracing_cpumask_write, | 3257 | .write = tracing_cpumask_write, |
3258 | .release = tracing_release_generic_tr, | ||
3262 | .llseek = generic_file_llseek, | 3259 | .llseek = generic_file_llseek, |
3263 | }; | 3260 | }; |
3264 | 3261 | ||
@@ -5938,6 +5935,11 @@ static int new_instance_create(const char *name) | |||
5938 | if (!tr->name) | 5935 | if (!tr->name) |
5939 | goto out_free_tr; | 5936 | goto out_free_tr; |
5940 | 5937 | ||
5938 | if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL)) | ||
5939 | goto out_free_tr; | ||
5940 | |||
5941 | cpumask_copy(tr->tracing_cpumask, cpu_all_mask); | ||
5942 | |||
5941 | raw_spin_lock_init(&tr->start_lock); | 5943 | raw_spin_lock_init(&tr->start_lock); |
5942 | 5944 | ||
5943 | tr->current_trace = &nop_trace; | 5945 | tr->current_trace = &nop_trace; |
@@ -5969,6 +5971,7 @@ static int new_instance_create(const char *name) | |||
5969 | out_free_tr: | 5971 | out_free_tr: |
5970 | if (tr->trace_buffer.buffer) | 5972 | if (tr->trace_buffer.buffer) |
5971 | ring_buffer_free(tr->trace_buffer.buffer); | 5973 | ring_buffer_free(tr->trace_buffer.buffer); |
5974 | free_cpumask_var(tr->tracing_cpumask); | ||
5972 | kfree(tr->name); | 5975 | kfree(tr->name); |
5973 | kfree(tr); | 5976 | kfree(tr); |
5974 | 5977 | ||
@@ -6098,6 +6101,9 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer) | |||
6098 | { | 6101 | { |
6099 | int cpu; | 6102 | int cpu; |
6100 | 6103 | ||
6104 | trace_create_file("tracing_cpumask", 0644, d_tracer, | ||
6105 | tr, &tracing_cpumask_fops); | ||
6106 | |||
6101 | trace_create_file("trace_options", 0644, d_tracer, | 6107 | trace_create_file("trace_options", 0644, d_tracer, |
6102 | tr, &tracing_iter_fops); | 6108 | tr, &tracing_iter_fops); |
6103 | 6109 | ||
@@ -6147,9 +6153,6 @@ static __init int tracer_init_debugfs(void) | |||
6147 | 6153 | ||
6148 | init_tracer_debugfs(&global_trace, d_tracer); | 6154 | init_tracer_debugfs(&global_trace, d_tracer); |
6149 | 6155 | ||
6150 | trace_create_file("tracing_cpumask", 0644, d_tracer, | ||
6151 | &global_trace, &tracing_cpumask_fops); | ||
6152 | |||
6153 | trace_create_file("available_tracers", 0444, d_tracer, | 6156 | trace_create_file("available_tracers", 0444, d_tracer, |
6154 | &global_trace, &show_traces_fops); | 6157 | &global_trace, &show_traces_fops); |
6155 | 6158 | ||
@@ -6371,7 +6374,7 @@ __init static int tracer_alloc_buffers(void) | |||
6371 | if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) | 6374 | if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) |
6372 | goto out; | 6375 | goto out; |
6373 | 6376 | ||
6374 | if (!alloc_cpumask_var(&tracing_cpumask, GFP_KERNEL)) | 6377 | if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL)) |
6375 | goto out_free_buffer_mask; | 6378 | goto out_free_buffer_mask; |
6376 | 6379 | ||
6377 | /* Only allocate trace_printk buffers if a trace_printk exists */ | 6380 | /* Only allocate trace_printk buffers if a trace_printk exists */ |
@@ -6386,7 +6389,7 @@ __init static int tracer_alloc_buffers(void) | |||
6386 | ring_buf_size = 1; | 6389 | ring_buf_size = 1; |
6387 | 6390 | ||
6388 | cpumask_copy(tracing_buffer_mask, cpu_possible_mask); | 6391 | cpumask_copy(tracing_buffer_mask, cpu_possible_mask); |
6389 | cpumask_copy(tracing_cpumask, cpu_all_mask); | 6392 | cpumask_copy(global_trace.tracing_cpumask, cpu_all_mask); |
6390 | 6393 | ||
6391 | raw_spin_lock_init(&global_trace.start_lock); | 6394 | raw_spin_lock_init(&global_trace.start_lock); |
6392 | 6395 | ||
@@ -6441,7 +6444,7 @@ out_free_cpumask: | |||
6441 | #ifdef CONFIG_TRACER_MAX_TRACE | 6444 | #ifdef CONFIG_TRACER_MAX_TRACE |
6442 | free_percpu(global_trace.max_buffer.data); | 6445 | free_percpu(global_trace.max_buffer.data); |
6443 | #endif | 6446 | #endif |
6444 | free_cpumask_var(tracing_cpumask); | 6447 | free_cpumask_var(global_trace.tracing_cpumask); |
6445 | out_free_buffer_mask: | 6448 | out_free_buffer_mask: |
6446 | free_cpumask_var(tracing_buffer_mask); | 6449 | free_cpumask_var(tracing_buffer_mask); |
6447 | out: | 6450 | out: |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index afaae41b0a02..502fed770751 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -206,6 +206,7 @@ struct trace_array { | |||
206 | struct dentry *event_dir; | 206 | struct dentry *event_dir; |
207 | struct list_head systems; | 207 | struct list_head systems; |
208 | struct list_head events; | 208 | struct list_head events; |
209 | cpumask_var_t tracing_cpumask; /* only trace on set CPUs */ | ||
209 | int ref; | 210 | int ref; |
210 | }; | 211 | }; |
211 | 212 | ||