Skip to contentSkip to conversation

libtracefs: Have labels in selections be synthetic fields

PATCH In review Steven Rostedt 2 participants 2 messages Jun 1, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracefs: Have labels in selections be synthetic fields

From: "Steven Rostedt (Google)" <[email protected]>

The labels in the selection case are suppose to be the fields for the created synthetic events. But for some reason they were ignored.

For example:

sqlhist -n wakeup_lat 'select end.next_pid as pid, end.next_comm as comm, (end.TIMESTAMP - start.TIMESTAMP) as lat
from sched_waking as start join sched_switch as end on start.pid = end.next_pid'

Produces the synthetic event of:

echo 'wakeup_lat pid_t next_pid; char next_comm[16]; u64 lat;' >> /sys/kernel/tracing/synthetic_events

Where it should have used 'pid' instead of 'next_pid' and 'comm' instead of 'next_comm'

Fixes 25446407 ("libtracefs: Added new API tracefs_sql()")
---
 src/tracefs-sqlhist.c | 1 +
 1 file changed, 1 insertion(+)
src/tracefs-sqlhist.c +1 -0
index 9811362..8d71800 100644
@@ -253,6 +253,7 @@ __hidden int add_selection(struct sqlhist_bison *sb, void *select,
 
 	switch (expr->type) {
 	case EXPR_FIELD:
+		expr->field.label = name;
 		break;
 	case EXPR_COMPARE:
 		expr->compare.name = name;
Signature · 1 line
2.35.1
Tested-by on v1 1/1
#1 lore raw
Quoted 12 lines · Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

The labels in the selection case are suppose to be the fields for the created synthetic events. But for some reason they were ignored.

For example:

  sqlhist -n wakeup_lat 'select end.next_pid as pid, end.next_comm as comm, (end.TIMESTAMP - start.TIMESTAMP) as lat from sched_waking as start join sched_switch as end on start.pid = end.next_pid'

Produces the synthetic event of:

Quoted 7 lines

  echo 'wakeup_lat pid_t next_pid; char next_comm[16]; u64 lat;' >> /sys/kernel/tracing/synthetic_events

Where it should have used 'pid' instead of 'next_pid' and 'comm' instead of 'next_comm'

Fixes 25446407 ("libtracefs: Added new API tracefs_sql()")
Quoted 16 lines

---
 src/tracefs-sqlhist.c | 1 +

 1 file changed, 1 insertion(+)
src/tracefs-sqlhist.c +0 -0
index 9811362..8d71800 100644
@@ -253,6 +253,7 @@ __hidden int add_selection(struct sqlhist_bison *sb, void *select,


        switch (expr->type) {
        case EXPR_FIELD:
+               expr->field.label = name;
                break;
        case EXPR_COMPARE:
                expr->compare.name = name;