Project

General

Profile

Actions

Bug #789

closed

unaligned memory access on ARM

Added by Stanislav Vovk about 10 years ago. Updated about 4 years ago.

Status:
Invalid
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
04/28/2014
Due date:
% Done:

0%

Estimated time:

Description

Commit id:
--------------------
babeltrace: 87353f23d5107c8cc09719d46cc8ccee5da989f7

Problem:
---------------------
Babeltrace performs unaligned memory access on ARM when converting CTF to text. This slows down conversion and floods syslog with warnings (if warnings are activated). For more info see below,
https://www.kernel.org/doc/Documentation/arm/mem_alignment

Anyhow, to rely on the kernels alignment trap seems to be a bad idea.


Files

snapshot-1-20140506-124353-0.tgz (4.86 KB) snapshot-1-20140506-124353-0.tgz Stanislav Vovk, 05/06/2014 08:52 AM
syslog (58.4 KB) syslog Stanislav Vovk, 05/06/2014 08:52 AM
snapshot.tgz (4.73 KB) snapshot.tgz Stanislav Vovk, 05/12/2014 10:18 AM
syslog (48.1 KB) syslog Stanislav Vovk, 05/12/2014 10:18 AM
fix-unaligned-babeltrace.patch (7.5 KB) fix-unaligned-babeltrace.patch Mathieu Desnoyers, 07/16/2014 11:02 AM
Actions #1

Updated by Jérémie Galarneau almost 10 years ago

Are you reading a trace produced on x86 on ARM, or is this trace read on the architecture that produced it?

Thanks!

Actions #2

Updated by Stanislav Vovk almost 10 years ago

Trace is produced and read on ARM.

Actions #3

Updated by Jérémie Galarneau almost 10 years ago

That's interesting... Any chance you can share a sample trace that exhibits the problem? This (probably) means the tracer is performing unaligned accesses while producing the trace and may be indicative of a more serious problem.

This doesn't change the fact that this is a valid bug against Babeltrace, but I'd like to make sure the tracer works as intended.

Updated by Stanislav Vovk almost 10 years ago

Attaching snapshot and syslog output after reading same snapshot.

Actions #5

Updated by Mathieu Desnoyers almost 10 years ago

Can you tell us on which architecture the trace is generated, and on which architecture is babeltrace running ?
[ edit: sorry, I see it's already been answered ]

Actions #6

Updated by Mathieu Desnoyers almost 10 years ago

The metadata files show that the alignment of integer types is OK for ARM (alignment on the type size).

We'd need to see which field (fields) is being read when the unaligned trap is triggered.

Updated by Stanislav Vovk almost 10 years ago

more detailed architechture:
ARMv7 Processor rev 2 (v7l), cortex A15

Reading a snapshot containing one event produced attached syslog.

root@du1:~# babeltrace /trace/telog/
[13:13:21.492996545] (+?.?????????) du1 com_ericsson_plf_lttng_test:myevent: { cpu_id = 5 }, { }

'-Wcast-align' should give some hints when build with Arm compiler, right?

Actions #8

Updated by Jérémie Galarneau almost 10 years ago

  • Status changed from New to In Progress

A patch related to this issue has been contributed recently. I doubt it fixes the problem completely as the objstack is only used when parsing the trace metadata and you seem to make it further than that by reading actual events.

Still, including this for reference.

ID    cae67efbd9ddf2cee6bbefec076dc8933ababc43
Parent     62f11f74

Added by Fredrik Markström about 3 hours ago

Fix: Align buffers from objstack_alloc on sizeof(void *)

The buffers from objstack_alloc will store pointers, so they must
be aligned on a pointer's size, or else it will cause issues on the
CPUs which do not support unaligned addresses access.

Signed-off-by: Fredrik Markstrom <fredrik.markstrom@gmail.com>
Signed-off-by: Roy Li <rongqing.li@windriver.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Actions #9

Updated by Mathieu Desnoyers almost 10 years ago

Can you check if this patch fixes the issue ?

Actions #10

Updated by Mathieu Desnoyers almost 10 years ago

FWIW, the patch I proposed is not ideal for architectures that support efficient unaligned accesses, especially for the bt bitfield read/writes. It uses unsigned char rather than unsigned long for the accesses. We should therefore detect in configure whether unaligned accesses are efficient for the architecture (like we do in lttng-ust), and use this to decide the type we use for the bitfield accesses (unsigned char or unsigned long).

Actions #11

Updated by Mathieu Desnoyers over 9 years ago

Fix committed as:

commit 6a0b6cd5133db9e3c72914d4e5dd7fc792360934
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date:   Wed Jul 16 10:58:48 2014 -0400

    Fix: don't perform unaligned integer read/writes

    Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Need confirmation that it fixes the issue.

Actions #12

Updated by Jonathan Rajotte Julien about 4 years ago

  • Status changed from Feedback to Invalid

State of babeltrace moved a lot since.

Closing this ticket. Reopen it if it stills apply to Babeltrace 2.

Actions

Also available in: Atom PDF