]> Pileus Git - ~andy/linux/blobdiff - kernel/trace/trace.c
tracing: Use current_uid() for critical time tracing
[~andy/linux] / kernel / trace / trace.c
index ae6fa2d1cdf7dd75dd7e9aa4cfb66bcb32192315..1a41023a1f88e03cb6ee79e0b7c46991857e90ab 100644 (file)
@@ -843,7 +843,15 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
 
        memcpy(max_data->comm, tsk->comm, TASK_COMM_LEN);
        max_data->pid = tsk->pid;
-       max_data->uid = task_uid(tsk);
+       /*
+        * If tsk == current, then use current_uid(), as that does not use
+        * RCU. The irq tracer can be called out of RCU scope.
+        */
+       if (tsk == current)
+               max_data->uid = current_uid();
+       else
+               max_data->uid = task_uid(tsk);
+
        max_data->nice = tsk->static_prio - 20 - MAX_RT_PRIO;
        max_data->policy = tsk->policy;
        max_data->rt_priority = tsk->rt_priority;
@@ -6216,10 +6224,15 @@ __init static int tracer_alloc_buffers(void)
 
        trace_init_cmdlines();
 
-       register_tracer(&nop_trace);
-
+       /*
+        * register_tracer() might reference current_trace, so it
+        * needs to be set before we register anything. This is
+        * just a bootstrap of current_trace anyway.
+        */
        global_trace.current_trace = &nop_trace;
 
+       register_tracer(&nop_trace);
+
        /* All seems OK, enable tracing */
        tracing_disabled = 0;