Skip to content

add lttng to kernel build steps#18

Merged
razr merged 9 commits intoros-realtime:masterfrom
flynneva:feature/lttng
Sep 12, 2021
Merged

add lttng to kernel build steps#18
razr merged 9 commits intoros-realtime:masterfrom
flynneva:feature/lttng

Conversation

@flynneva
Copy link
Copy Markdown
Contributor

@flynneva flynneva commented Sep 1, 2021

this PR tries to add lttng tracer to the kernel build process as brought up in #16.

building the kernel now so there might be a few more commits to come to get it fully working.

im not 100% sure if all the CONFIG settings are needed but I've added them all and commented out a few that I dont think are necessary...feel free to chime in here if you think some should be uncommented.

with lttng enabled, the kernel build step (make ARCH=...) prompts the user with some questions, unfortunately I wasnt fast enough this time to copy it down but will try later on. I just stuck with the "default" options (capitol letters) like M, Y or N.

once merged this should close #16

Signed-off-by: Evan Flynn <evanflynn.msu@gmail.com>
Signed-off-by: Evan Flynn <evanflynn.msu@gmail.com>
@LanderU LanderU requested review from LanderU and razr September 2, 2021 11:51
@flynneva flynneva marked this pull request as draft September 2, 2021 16:23
@flynneva
Copy link
Copy Markdown
Contributor Author

flynneva commented Sep 2, 2021

making this a draft as im still unsure if this actually works yet. need to test the generated kernel today

@flynneva
Copy link
Copy Markdown
Contributor Author

flynneva commented Sep 2, 2021

I rebuilt it today and this time copied the prompts here:

LTTng support (LTTNG) [M/n/y/?] (NEW) y
  LTTng experimental bitwise enum support (LTTNG_EXPERIMENTAL_BITWISE_ENUM) [N/y/?] (NEW) N
  Use test plugin as trace clock (LTTNG_CLOCK_PLUGIN_TEST) [M/n/y/?] (NEW) y

these prompts have the same names as the ones I added to the .config-fragment file...which makes me worried that they are not being applied properly.

@LanderU
Copy link
Copy Markdown
Contributor

LanderU commented Sep 3, 2021

@flynneva, you can check if they are active in your .config file

Signed-off-by: Evan Flynn <evan.flynn@apex.ai>
@flynneva
Copy link
Copy Markdown
Contributor Author

flynneva commented Sep 7, 2021

almost there i think. no user input other than following the README commands as already documented.

looks like lttng is being built into the kernel during the make command:

Screenshot from 2021-09-07 10-26-35

Signed-off-by: Evan Flynn <evan.flynn@apex.ai>
@flynneva flynneva marked this pull request as ready for review September 7, 2021 19:45
@flynneva
Copy link
Copy Markdown
Contributor Author

flynneva commented Sep 7, 2021

I've confirmed the output deb files work as expected and integrate the lttng-modules package right in with the kernel.

when following the ros2_tracing installation instructions just leave out the installation of lttng-dkms-modules as it is already built in.

@flynneva
Copy link
Copy Markdown
Contributor Author

flynneva commented Sep 7, 2021

output of the ros2_tracing launch example:

ros2 launch tracetools_launch example.launch.py 
[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2021-09-07-19-47-06-778068-ubuntu-2086
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [tracetools_launch.action]: Writing tracing session to: /home/ubuntu/.ros/tracing/my-tracing-session
[INFO] [test_ping-1]: process started with pid [2113]
[INFO] [test_pong-2]: process started with pid [2115]
[test_pong-2] [INFO] [1631044029.972198136] [test_pong]: [output] some random ping string
[test_ping-1] [INFO] [1631044029.973497659] [test_ping]: [output] some random pong string
[test_ping-1] spinning
[test_pong-2] spinning
[INFO] [test_pong-2]: process has finished cleanly [pid 2115]
[INFO] [test_ping-1]: process has finished cleanly [pid 2113]
`cat metadata` from tracing logs

$ cat metadata 
typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
typealias integer { size = 16; align = 8; signed = false; } := uint16_t;
typealias integer { size = 32; align = 8; signed = false; } := uint32_t;
typealias integer { size = 64; align = 8; signed = false; } := uint64_t;
typealias integer { size = 64; align = 8; signed = false; } := unsigned long;
typealias integer { size = 5; align = 1; signed = false; } := uint5_t;
typealias integer { size = 27; align = 1; signed = false; } := uint27_t;

trace {
	major = 1;
	minor = 8;
	uuid = "76f996dc-d9c7-f144-bb4d-f90ca898cbe7";
	byte_order = le;
	packet.header := struct {
		uint32_t magic;
		uint8_t  uuid[16];
		uint32_t stream_id;
		uint64_t stream_instance_id;
	};
};

env {
	hostname = "ubuntu";
	domain = "kernel";
	sysname = "Linux";
	kernel_release = "5.4.128-rt61";
	kernel_version = "#1 SMP PREEMPT_RT Tue Sep 7 17:24:07 UTC 2021";
	tracer_name = "lttng-modules";
	tracer_major = 2;
	tracer_minor = 12;
	tracer_patchlevel = 5;
	trace_buffering_scheme = "global";
	trace_name = "my-tracing-session";
	trace_creation_datetime = "20210907T194707+0000";
};

clock {
	name = "lttng_test_clock_override";
	uuid = "83c63deb-7aa4-48fb-abda-946f400d76e6";
	description = "Freeze time with 1KHz for regression test";
	freq = 1000; /* Frequency, in Hz */
	/* clock value offset from Epoch is: offset * (1/freq) */
	offset = 1631044028667;
};

typealias integer {
	size = 27; align = 1; signed = false;
	map = clock.lttng_test_clock_override.value;
} := uint27_clock_monotonic_t;

typealias integer {
	size = 32; align = 8; signed = false;
	map = clock.lttng_test_clock_override.value;
} := uint32_clock_monotonic_t;

typealias integer {
	size = 64; align = 8; signed = false;
	map = clock.lttng_test_clock_override.value;
} := uint64_clock_monotonic_t;

struct packet_context {
	uint64_clock_monotonic_t timestamp_begin;
	uint64_clock_monotonic_t timestamp_end;
	uint64_t content_size;
	uint64_t packet_size;
	uint64_t packet_seq_num;
	unsigned long events_discarded;
	uint32_t cpu_id;
};

struct event_header_compact {
	enum : uint5_t { compact = 0 ... 30, extended = 31 } id;
	variant <id> {
		struct {
			uint27_clock_monotonic_t timestamp;
		} compact;
		struct {
			uint32_t id;
			uint64_clock_monotonic_t timestamp;
		} extended;
	} v;
} align(8);

struct event_header_large {
	enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;
	variant <id> {
		struct {
			uint32_clock_monotonic_t timestamp;
		} compact;
		struct {
			uint32_t id;
			uint64_clock_monotonic_t timestamp;
		} extended;
	} v;
} align(8);

stream {
	id = 0;
	event.header := struct event_header_compact;
	packet.context := struct packet_context;
};

event {
	name = "power_cpu_frequency";
	id = 3;
	stream_id = 0;
	fields := struct {
		integer { size = 32; align = 8; signed = 0; encoding = none; base = 10; } _state;
		integer { size = 32; align = 8; signed = 0; encoding = none; base = 10; } _cpu_id;
	};
};

event {
	name = "kmem_mm_page_free";
	id = 2;
	stream_id = 0;
	fields := struct {
		integer { size = 64; align = 8; signed = 0; encoding = none; base = 16; } _page;
		integer { size = 64; align = 8; signed = 0; encoding = none; base = 10; } _pfn;
		integer { size = 32; align = 8; signed = 0; encoding = none; base = 10; } _order;
	};
};

event {
	name = "kmem_mm_page_alloc";
	id = 1;
	stream_id = 0;
	fields := struct {
		integer { size = 64; align = 8; signed = 0; encoding = none; base = 16; } _page;
		integer { size = 64; align = 8; signed = 0; encoding = none; base = 10; } _pfn;
		integer { size = 32; align = 8; signed = 0; encoding = none; base = 10; } _order;
		integer { size = 32; align = 8; signed = 0; encoding = none; base = 10; } _gfp_flags;
		integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _migratetype;
	};
};

event {
	name = "sched_switch";
	id = 0;
	stream_id = 0;
	fields := struct {
		integer { size = 8; align = 8; signed = 0; encoding = UTF8; base = 10; } _prev_comm[16];
		integer { size = 32; align = 8; signed = 1; encoding = none; base = 10W�uv������D�M�
                                                                                                    ������; } _prev_tid;
		integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _prev_prio;
		enum : integer { size = 64; align = 8; signed = 1; encoding = none; base = 10; } {
			"TASK_RUNNING" = 0,
			"TASK_INTERRUPTIBLE" = 1,
			"TASK_UNINTERRUPTIBLE" = 2,
			"TASK_STOPPED" = 4,
			"TASK_TRACED" = 8,
			"EXIT_DEAD" = 16,
			"EXIT_ZOMBIE" = 32,
			"TASK_PARKED" = 64,
			"TASK_DEAD" = 128,
			"TASK_WAKEKILL" = 256,
			"TASK_WAKING" = 512,
			"TASK_NOLOAD" = 1024,
			"TASK_NEW" = 2048,
			"TASK_STATE_MAX" = 4096,
		} _prev_state;
		integer { size = 8; align = 8; signed = 0; encoding = UTF8; base = 10; } _next_comm[16];
		integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_tid;
		integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_prio;
	};
};

Copy link
Copy Markdown
Member

@razr razr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add a few words in the README describing why do we need to add lttng support?

Dockerfile Outdated
# download lttng source for use later
# TODO(flynneva): make script to auto-determine which version to get?
RUN cd $HOME \
&& wget https://lttng.org/files/lttng-modules/lttng-modules-${LTTNG}.tar.bz2 \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not better to get sources from Ubuntu directly, like

$ sudo apt-add-repository ppa:lttng/stable-2.12
$ sudo apt-get update
$ apt-get source lttng-modules-dkms

they are patched afaics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

@christophebedard christophebedard Sep 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it really changes anything in practice, but ROS 2 (well, ros2_tracing) currently targets the versions of LTTng available from the usual Ubuntu packages. So if we want to stick to that, we shouldn't use the PPA here. You can still call apt-get source without the PPA of course.

Signed-off-by: Evan Flynn <evan.flynn@apex.ai>
@flynneva flynneva requested a review from razr September 9, 2021 17:29
@flynneva
Copy link
Copy Markdown
Contributor Author

flynneva commented Sep 9, 2021

@razr i implemented your recommendations and am building the kernel again now just to confirm everything works as expected. ill follow up here once its done building and tested.

@flynneva
Copy link
Copy Markdown
Contributor Author

would probably be good to get @christophebedard input / review here as well

Copy link
Copy Markdown
Member

@razr razr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flynneva thanks much, it looks good

Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
Copy link
Copy Markdown
Contributor

@LanderU LanderU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@razr razr merged commit 4e20866 into ros-realtime:master Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unable to install lttng on rt linux kernel

5 participants