struct trace_array_cpu *data;
        unsigned int trace_ctx;
        int bit;
-       int cpu;
 
        if (unlikely(!tr->function_enabled))
                return;
 
        trace_ctx = tracing_gen_ctx();
 
-       cpu = smp_processor_id();
-       data = per_cpu_ptr(tr->array_buffer.data, cpu);
+       data = this_cpu_ptr(tr->array_buffer.data);
        if (!atomic_read(&data->disabled))
                trace_function(tr, ip, parent_ip, trace_ctx);
 
        unsigned int trace_ctx;
        unsigned long flags;
        int bit;
-       int cpu;
 
        if (unlikely(!tr->function_enabled))
                return;
        if (bit < 0)
                return;
 
-       cpu = smp_processor_id();
-       data = per_cpu_ptr(tr->array_buffer.data, cpu);
+       data = this_cpu_ptr(tr->array_buffer.data);
        if (atomic_read(&data->disabled))
                goto out;
 
         * TODO: think about a solution that is better than just hoping to be
         * lucky.
         */
-       last_info = per_cpu_ptr(tr->last_func_repeats, cpu);
+       last_info = this_cpu_ptr(tr->last_func_repeats);
        if (is_repeat_check(tr, last_info, ip, parent_ip))
                goto out;