Merge tag 'v3.10.103' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / kernel / trace / trace_printk.c
index 7be4d67cecbd9c8ce3ed28ea89eae011ba1139db..9008103db583ed354a2e44136489a78ce92c2769 100644 (file)
@@ -249,12 +249,31 @@ static const char **find_next(void *v, loff_t *pos)
 {
        const char **fmt = v;
        int start_index;
+       int last_index;
 
        start_index = __stop___trace_bprintk_fmt - __start___trace_bprintk_fmt;
 
        if (*pos < start_index)
                return __start___trace_bprintk_fmt + *pos;
 
+       /*
+        * The __tracepoint_str section is treated the same as the
+        * __trace_printk_fmt section. The difference is that the
+        * __trace_printk_fmt section should only be used by trace_printk()
+        * in a debugging environment, as if anything exists in that section
+        * the trace_prink() helper buffers are allocated, which would just
+        * waste space in a production environment.
+        *
+        * The __tracepoint_str sections on the other hand are used by
+        * tracepoints which need to map pointers to their strings to
+        * the ASCII text for userspace.
+        */
+       last_index = start_index;
+       start_index = __stop___tracepoint_str - __start___tracepoint_str;
+
+       if (*pos < last_index + start_index)
+               return __start___tracepoint_str + (*pos - last_index);
+
        return find_next_mod_format(start_index, v, fmt, pos);
 }