scheduler-tools / rt-app

rt-app emulates typical mobile and real-time systems use cases and gives runtime information
GNU General Public License v2.0
125 stars 102 forks source link

error with ftrace examples #119

Closed amamory closed 3 years ago

amamory commented 3 years ago

When running any example with ftrace enable, it causes the following error:

rt-app examples/tutorial/example1.json

Cannot write mark_fd: Bad file descriptor This error happen when _tracing_on_ is not enabled before writing into _trace_marker_. Looking at the following [line of code](https://github.com/scheduler-tools/rt-app/blob/665eececccea20b6cb55bfed3a2c02a7d3773a2a/src/rt-app.c#L1545): > log_notice("configuring ftrace"); > strcpy(tmp, ft_data.debugfs); > strcat(tmp, "/tracing/tracing_on"); > strcpy(tmp, ft_data.debugfs); > strcat(tmp, "/tracing/trace_marker"); > ft_data.marker_fd = open(tmp, O_WRONLY); As can be seen in this code, nothing is written into tracing_on, before writing into trace_marker. There should be something equivalent to: > echo 1 > /sys/kernel/debug/tracing/tracing_on > echo 'something' > /sys/kernel/debug/tracing/trace_marker > echo 0 > /sys/kernel/debug/tracing/tracing_on Also, it seems that there is no place disabling the tracing.
amamory commented 3 years ago

Pull #121 fix this as it first checks whether tracing is enabled outside the app scope. For example, if the json file enables ftrace, it is expected that the user runs ftrace (i.e., set _tracingon to '1' or trace-cmd record ...) before running rt-app. If the user forget it, the rt-app will issue an error 'tracing is not enabled in file ....tracing/tracing_on'.