@@ -3165,11 +3165,6 @@ static const struct file_operations show_traces_fops = {
31653165 .llseek = seq_lseek ,
31663166};
31673167
3168- /*
3169- * Only trace on a CPU if the bitmask is set:
3170- */
3171- static cpumask_var_t tracing_cpumask ;
3172-
31733168/*
31743169 * The tracer itself will not take this lock, but still we want
31753170 * to provide a consistent cpumask to user-space:
@@ -3186,11 +3181,12 @@ static ssize_t
31863181tracing_cpumask_read (struct file * filp , char __user * ubuf ,
31873182 size_t count , loff_t * ppos )
31883183{
3184+ struct trace_array * tr = file_inode (filp )-> i_private ;
31893185 int len ;
31903186
31913187 mutex_lock (& tracing_cpumask_update_lock );
31923188
3193- len = cpumask_scnprintf (mask_str , count , tracing_cpumask );
3189+ len = cpumask_scnprintf (mask_str , count , tr -> tracing_cpumask );
31943190 if (count - len < 2 ) {
31953191 count = - EINVAL ;
31963192 goto out_err ;
@@ -3208,7 +3204,7 @@ static ssize_t
32083204tracing_cpumask_write (struct file * filp , const char __user * ubuf ,
32093205 size_t count , loff_t * ppos )
32103206{
3211- struct trace_array * tr = filp -> private_data ;
3207+ struct trace_array * tr = file_inode ( filp ) -> i_private ;
32123208 cpumask_var_t tracing_cpumask_new ;
32133209 int err , cpu ;
32143210
@@ -3228,12 +3224,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
32283224 * Increase/decrease the disabled counter if we are
32293225 * about to flip a bit in the cpumask:
32303226 */
3231- if (cpumask_test_cpu (cpu , tracing_cpumask ) &&
3227+ if (cpumask_test_cpu (cpu , tr -> tracing_cpumask ) &&
32323228 !cpumask_test_cpu (cpu , tracing_cpumask_new )) {
32333229 atomic_inc (& per_cpu_ptr (tr -> trace_buffer .data , cpu )-> disabled );
32343230 ring_buffer_record_disable_cpu (tr -> trace_buffer .buffer , cpu );
32353231 }
3236- if (!cpumask_test_cpu (cpu , tracing_cpumask ) &&
3232+ if (!cpumask_test_cpu (cpu , tr -> tracing_cpumask ) &&
32373233 cpumask_test_cpu (cpu , tracing_cpumask_new )) {
32383234 atomic_dec (& per_cpu_ptr (tr -> trace_buffer .data , cpu )-> disabled );
32393235 ring_buffer_record_enable_cpu (tr -> trace_buffer .buffer , cpu );
@@ -3242,7 +3238,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
32423238 arch_spin_unlock (& ftrace_max_lock );
32433239 local_irq_enable ();
32443240
3245- cpumask_copy (tracing_cpumask , tracing_cpumask_new );
3241+ cpumask_copy (tr -> tracing_cpumask , tracing_cpumask_new );
32463242
32473243 mutex_unlock (& tracing_cpumask_update_lock );
32483244 free_cpumask_var (tracing_cpumask_new );
@@ -3256,9 +3252,10 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
32563252}
32573253
32583254static const struct file_operations tracing_cpumask_fops = {
3259- .open = tracing_open_generic ,
3255+ .open = tracing_open_generic_tr ,
32603256 .read = tracing_cpumask_read ,
32613257 .write = tracing_cpumask_write ,
3258+ .release = tracing_release_generic_tr ,
32623259 .llseek = generic_file_llseek ,
32633260};
32643261
@@ -5938,6 +5935,11 @@ static int new_instance_create(const char *name)
59385935 if (!tr -> name )
59395936 goto out_free_tr ;
59405937
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+
59415943 raw_spin_lock_init (& tr -> start_lock );
59425944
59435945 tr -> current_trace = & nop_trace ;
@@ -5969,6 +5971,7 @@ static int new_instance_create(const char *name)
59695971 out_free_tr :
59705972 if (tr -> trace_buffer .buffer )
59715973 ring_buffer_free (tr -> trace_buffer .buffer );
5974+ free_cpumask_var (tr -> tracing_cpumask );
59725975 kfree (tr -> name );
59735976 kfree (tr );
59745977
@@ -6098,6 +6101,9 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
60986101{
60996102 int cpu ;
61006103
6104+ trace_create_file ("tracing_cpumask" , 0644 , d_tracer ,
6105+ tr , & tracing_cpumask_fops );
6106+
61016107 trace_create_file ("trace_options" , 0644 , d_tracer ,
61026108 tr , & tracing_iter_fops );
61036109
@@ -6147,9 +6153,6 @@ static __init int tracer_init_debugfs(void)
61476153
61486154 init_tracer_debugfs (& global_trace , d_tracer );
61496155
6150- trace_create_file ("tracing_cpumask" , 0644 , d_tracer ,
6151- & global_trace , & tracing_cpumask_fops );
6152-
61536156 trace_create_file ("available_tracers" , 0444 , d_tracer ,
61546157 & global_trace , & show_traces_fops );
61556158
@@ -6371,7 +6374,7 @@ __init static int tracer_alloc_buffers(void)
63716374 if (!alloc_cpumask_var (& tracing_buffer_mask , GFP_KERNEL ))
63726375 goto out ;
63736376
6374- if (!alloc_cpumask_var (& tracing_cpumask , GFP_KERNEL ))
6377+ if (!alloc_cpumask_var (& global_trace . tracing_cpumask , GFP_KERNEL ))
63756378 goto out_free_buffer_mask ;
63766379
63776380 /* Only allocate trace_printk buffers if a trace_printk exists */
@@ -6386,7 +6389,7 @@ __init static int tracer_alloc_buffers(void)
63866389 ring_buf_size = 1 ;
63876390
63886391 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 );
63906393
63916394 raw_spin_lock_init (& global_trace .start_lock );
63926395
@@ -6441,7 +6444,7 @@ __init static int tracer_alloc_buffers(void)
64416444#ifdef CONFIG_TRACER_MAX_TRACE
64426445 free_percpu (global_trace .max_buffer .data );
64436446#endif
6444- free_cpumask_var (tracing_cpumask );
6447+ free_cpumask_var (global_trace . tracing_cpumask );
64456448out_free_buffer_mask :
64466449 free_cpumask_var (tracing_buffer_mask );
64476450out :
0 commit comments