Skip to contentSkip to conversation

overlay: parse tracepoints from sysfs to figure out fields' location

PATCH Superseded Lionel Landwerlin 3 participants 4 messages Dec 19, 2017 Arm/Amlogic Meson SoC support

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 overlay: parse tracepoints from sysfs to figure out fields' location

With changes going to drm-tip, the tracepoints field locations are going to change. This change introduces a tracepoint parser (using a peg parser) which lets us figure out field positions on the fly.

v2: Fix automake build (Lionel)

v3: Make overlay build conditional on peg (Petri)
Make wait_end callback more readable (Chris)
Drop tracepoint_id(), instead parsing from format file (Lionel)

v4: Fix existing configure.ac issue with overlay build (Petri)

v5: Silence unused function (Lionel)

For the build system changes:

---
 configure.ac                  |   9 ++-
 overlay/Makefile.am           |   5 ++
 overlay/gpu-perf.c            | 164 ++++++++++++++++++++++++++++++++----------
 overlay/meson.build           |  13 +++-
 overlay/tracepoint_format.leg |  35 +++++++++
 5 files changed, 186 insertions(+), 40 deletions(-)
 create mode 100644 overlay/tracepoint_format.leg
configure.ac +8 -1
index 8740f7a4..50c1a024 100644
@@ -146,6 +146,13 @@ if test x"$build_x86" = xyes; then
 	AS_IF([test x"$LEX" != "x:" -a x"$YACC" != xyacc],
 		[enable_assembler=yes],
 		[enable_assembler=no])
+
+	AC_CHECK_TOOL([LEG], [leg])
+	if test "x$LEG" != "xleg"; then
+		AC_MSG_NOTICE([leg command missing, disabling overlay; try : apt-get install peg])
+		enable_overlay_xvlib="no"
+		enable_overlay_xlib="no"
+	fi
 else
 	enable_overlay_xvlib="no"
 	enable_overlay_xlib="no"
@@ -158,7 +165,7 @@ AM_CONDITIONAL(BUILD_ASSEMBLER, [test "x$enable_assembler" = xyes])
 
 AM_CONDITIONAL(BUILD_OVERLAY_XVLIB, [test "x$enable_overlay_xvlib" = xyes])
 AM_CONDITIONAL(BUILD_OVERLAY_XLIB, [test "x$enable_overlay_xlib" = xyes])
-AM_CONDITIONAL(BUILD_OVERLAY, [test "x$enable_overlay_xlib" = xyes -o "x$enable_overlay_xvlib"])
+AM_CONDITIONAL(BUILD_OVERLAY, [test "x$enable_overlay_xlib" = xyes -o "x$enable_overlay_xvlib" = "xyes])
 if test x$enable_overlay_xvlib = xyes; then
 	AC_DEFINE(HAVE_OVERLAY_XVLIB, 1, [Enable XV backend])
 fi
overlay/Makefile.am +5 -0
index fca04cae..0f553b7c 100644
@@ -1,7 +1,12 @@
 if BUILD_OVERLAY
 bin_PROGRAMS = intel-gpu-overlay
+
+BUILT_SOURCES = tracepoint_format.h
 endif
 
+tracepoint_format.h: tracepoint_format.leg
+	$(LEG) -o $@ $<
+
 AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi
 AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
 	$(CAIRO_CFLAGS) $(OVERLAY_CFLAGS) $(WERROR_CFLAGS) -I$(srcdir)/../lib
overlay/gpu-perf.c +126 -38

226 lines not on this page · raw message

overlay/meson.build +12 -1
index afacff5e..8b5c52b4 100644
@@ -51,7 +51,18 @@ gpu_overlay_src += both_x11_src
 
 gpu_overlay_src += 'kms/kms-overlay.c'
 
-if xrandr.found() and cairo.found()
+leg = find_program('leg', required : false)
+if leg.found()
+	leg_file = custom_target('tracepoint_format',
+		output: 'tracepoint_format.h',
+		input: 'tracepoint_format.leg',
+		command: [leg, '-P', '-o', '@OUTPUT@', '@INPUT@'])
+	gpu_overlay_src += leg_file
+else
+	warning('leg command not found, disabling overlay; try : apt-get install peg')
+endif
+
+if leg.found() and xrandr.found() and cairo.found()
 	executable('intel-gpu-overlay', gpu_overlay_src,
 			include_directories : inc,
 			c_args : gpu_overlay_cflags,
overlay/tracepoint_format.leg new file +35 -0
new file mode 100644
index 00000000..7a09149d
@@ -0,0 +1,35 @@
+TracepointFmt =
+    'name' ':' Space n:PropertyName EndLine
+        { free(v.string); }
+    'ID:' Space v:Number EndLine
+        { yy->ctx.tp->event_id = v.integer; }
+    'format:' EndLine
+    Field+
+    'print fmt:' [^.]* !.
+
+Field         = Space (Property ';' Space)+ EndLine
+        { yy->ctx.tp->n_fields++; }
+              | EndLine
+
+Property      = 'offset' ':' v:Number
+        { yy->ctx.tp->fields[yy->ctx.tp->n_fields].offset = v.integer; }
+              | 'size' ':' v:Number
+        { yy->ctx.tp->fields[yy->ctx.tp->n_fields].size = v.integer; }
+              | 'signed' ':' v:Number
+        { yy->ctx.tp->fields[yy->ctx.tp->n_fields].is_signed = v.integer != 0; }
+              | 'field' ':' v:PropertyValue
+        { snprintf(yy->ctx.tp->fields[yy->ctx.tp->n_fields].name,
+                   sizeof(yy->ctx.tp->fields[yy->ctx.tp->n_fields].name),
+                   "%s", strrchr(v.string, ' ') + 1); free(v.string); }
+              | n:PropertyName ':' v:PropertyValue
+        { free(n.string); free(v.string); }
+
+PropertyName  = < [A-Za-z0-9_]+ >
+        { $$.string = strdup(yytext); }
+PropertyValue = < [^;]+ >
+        { $$.string = strdup(yytext); }
+Number        = < [0-9]+ >
+        { $$.integer = atoi(yytext); }
+
+EndLine       = [\n]
+Space         = [ \t]*
Signature · 6 lines
2.15.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Acked-by on v5 1/1
#1 lore raw

Quoting Lionel Landwerlin (2017-12-19 14:26:11)

Quoted 10 lines

With changes going to drm-tip, the tracepoints field locations are going to change. This change introduces a tracepoint parser (using a peg parser) which lets us figure out field positions on the fly.

v2: Fix automake build (Lionel)

v3: Make overlay build conditional on peg (Petri)
Make wait_end callback more readable (Chris)
Drop tracepoint_id(), instead parsing from format file (Lionel)

Quoted 8 lines

v4: Fix existing configure.ac issue with overlay build (Petri)

v5: Silence unused function (Lionel)

For the build system changes:

If it works, it works.

One of the next steps would be failing if the tracepoint doesn't contain the desired data.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
Quoted 17 lines · Chris Wilson

Quoting Lionel Landwerlin (2017-12-19 14:26:11)

Quoted 16 lines

With changes going to drm-tip, the tracepoints field locations are going to change. This change introduces a tracepoint parser (using a peg parser) which lets us figure out field positions on the fly.

v2: Fix automake build (Lionel)

v3: Make overlay build conditional on peg (Petri)
Make wait_end callback more readable (Chris)
Drop tracepoint_id(), instead parsing from format file (Lionel)

v4: Fix existing configure.ac issue with overlay build (Petri)

v5: Silence unused function (Lionel)

Quoted 9 lines
Quoted 2 lines

For the build system changes:

If it works, it works.

One of the next steps would be failing if the tracepoint doesn't contain the desired data.
-Chris

It will fail if the parsing fails. Now if someone removes a field from the kernel, yeah, we're a bit screwed...

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✗ Fi.CI.BAT: failure for overlay: parse tracepoints from sysfs to figure out fields' location (rev5)

In reply to Lionel Landwerlin
== Series Details ==

== Series Details ==

Series: overlay: parse tracepoints from sysfs to figure out fields' location (rev5)
URL : https://patchwork.freedesktop.org/series/35545/
State : failure

== Summary ==

IGT patchset build failed on latest successful build
da0889bfacff106fb3ecb7049a7a21f78b4b301b igt/kms_frontbuffer_tracking: Access via GGTT is not guaranteed to be tracked

checking if gcc supports -Werror=write-strings... yes
checking if gcc supports -Werror=address... yes
checking if gcc supports -Werror=int-to-pointer-cast... yes checking if gcc supports -Werror=pointer-to-int-cast... yes checking if gcc supports -pedantic... yes
checking if gcc supports -Werror... yes
checking if gcc supports -Werror=attributes... yes
checking whether make supports nested variables... (cached) yes checking for DRM... yes
checking for PCIACCESS... yes
checking for KMOD... yes
checking for PROCPS... yes
checking for LIBUNWIND... yes
checking for VALGRIND... no
checking for OVERLAY_XVLIB... yes
checking for OVERLAY_XLIB... yes
checking for leg... no
configure: leg command missing, disabling overlay; try : apt-get install peg ./configure: line 21894: syntax error near unexpected token `('
./configure: line 21894: ` as_fn_error $? "Package requirements (cairo >= 1.12.0) were not met:'

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx