Patch "tracing: Have TRACE_DEFINE_ENUM affect trace event types as well" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tracing: Have TRACE_DEFINE_ENUM affect trace event types as well

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tracing-have-trace_define_enum-affect-trace-event-ty.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9913babd3ce945070761e55a0e82bf26a985bb96
Author: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
Date:   Thu Mar 10 23:27:38 2022 -0500

    tracing: Have TRACE_DEFINE_ENUM affect trace event types as well
    
    [ Upstream commit b3bc8547d3be60898818885f5bf22d0a62e2eb48 ]
    
    The macro TRACE_DEFINE_ENUM is used to convert enums in the kernel to
    their actual value when they are exported to user space via the trace
    event format file.
    
    Currently only the enums in the "print fmt" (TP_printk in the TRACE_EVENT
    macro) have the enums converted. But the enums can be used to denote array
    size:
    
            field:unsigned int fc_ineligible_rc[EXT4_FC_REASON_MAX]; offset:12;      size:36;        signed:0;
    
    The EXT4_FC_REASON_MAX has no meaning to userspace but it needs to know
    that information to know how to parse the array.
    
    Have the array indexes also be parsed as well.
    
    Link: https://lore.kernel.org/all/cover.1646922487.git.riteshh@xxxxxxxxxxxxx/
    
    Reported-by: Ritesh Harjani <riteshh@xxxxxxxxxxxxx>
    Tested-by: Ritesh Harjani <riteshh@xxxxxxxxxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index dd17171829d6..b35a66a8e7ce 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2637,6 +2637,33 @@ static void update_event_printk(struct trace_event_call *call,
 	}
 }
 
+static void update_event_fields(struct trace_event_call *call,
+				struct trace_eval_map *map)
+{
+	struct ftrace_event_field *field;
+	struct list_head *head;
+	char *ptr;
+	int len = strlen(map->eval_string);
+
+	head = trace_get_fields(call);
+	list_for_each_entry(field, head, link) {
+		ptr = strchr(field->type, '[');
+		if (!ptr)
+			continue;
+		ptr++;
+
+		if (!isalpha(*ptr) && *ptr != '_')
+			continue;
+
+		if (strncmp(map->eval_string, ptr, len) != 0)
+			continue;
+
+		ptr = eval_replace(ptr, map, len);
+		/* enum/sizeof string smaller than value */
+		WARN_ON_ONCE(!ptr);
+	}
+}
+
 void trace_event_eval_update(struct trace_eval_map **map, int len)
 {
 	struct trace_event_call *call, *p;
@@ -2672,6 +2699,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len)
 					first = false;
 				}
 				update_event_printk(call, map[i]);
+				update_event_fields(call, map[i]);
 			}
 		}
 	}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux