lttng-dev Archive mirror
 help / color / mirror / Atom feed
From: Mathieu Desnoyers via lttng-dev <lttng-dev@lists.lttng.org>
To: "Beckius, Mikael" <mikael.beckius@windriver.com>,
	"lttng-dev@lists.lttng.org" <lttng-dev@lists.lttng.org>
Subject: Re: [lttng-dev] lttng-consumerd crash on aarch64 due to x86 arch specific optimization
Date: Tue, 31 Jan 2023 11:18:11 -0500	[thread overview]
Message-ID: <e525c864-a2ee-ef34-b7fd-1c114e70b081@efficios.com> (raw)
In-Reply-To: <46f36a1a-c748-773b-8f6d-d481c9c8ad1b@efficios.com>

On 2023-01-31 11:08, Mathieu Desnoyers wrote:
> On 2023-01-30 01:50, Beckius, Mikael via lttng-dev wrote:
>> Hello Matthieu!
>>
>> I have looked at this in place of Anders and as far as I can tell this 
>> is not an arm64 issue but an arm issue. And even on arm 
>> __ARM_FEATURE_UNALIGNED is 1 so it seems the problem only occurs if 
>> size equals 8.
> 
> So for ARM, perhaps we should do the following in include/lttng/ust-arch.h:
> 
> #if defined(LTTNG_UST_ARCH_ARM) && defined(__ARM_FEATURE_UNALIGNED)
> #define LTTNG_UST_ARCH_HAS_EFFICIENT_UNALIGNED_ACCESS 1
> #endif
> 
> And refer to 
> https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#ARM-Options
> 
> Based on that documentation, it is possible to build with 
> -mno-unaligned-access,
> and for all pre-ARMv6, all ARMv6-M and for ARMv8-M Baseline architectures,
> unaligned accesses are not enabled.
> 
> I would only push this kind of change into the master branch though, due to
> its impact and the fact that this is only a performance improvement.

But setting LTTNG_UST_ARCH_HAS_EFFICIENT_UNALIGNED_ACCESS 1 for arm32
when __ARM_FEATURE_UNALIGNED is defined would still cause issues for
8-byte lttng_inline_memcpy with my proposed patch right ?

AFAIU 32-bit arm with __ARM_FEATURE_UNALIGNED has unaligned accesses for
2 and 4 bytes accesses, but somehow traps for unaligned 8-bytes
accesses ?

Thanks,

Mathieu

> 
>>
>> In addition I did some performance testing of lttng_inline_memcpy by 
>> extracting it and adding it to a simple test program. It appears that 
>> the general performance increases on arm, arm64, arm on arm64 hardware 
>> and x86-64. But it also appears that on arm if you end up in memcpy 
>> the old code where you call memcpy directly is actually slightly faster.
> 
> Nothing unexpected here. Just make sure that your test program does not 
> call lttng_inline_memcpy
> with constant size values which end up optimizing away branches. In the 
> context where lttng_inline_memcpy
> is used, most of the time its arguments are not constants.
> 
>>
>> Skipping the memcpy fallback on arm for unaligned copies of sizes 2 
>> and 4 further improves the performance
> 
> This would be naturally done on your board if we conditionally
> set LTTNG_UST_ARCH_HAS_EFFICIENT_UNALIGNED_ACCESS 1 for 
> __ARM_FEATURE_UNALIGNED
> right ?
> 
> and setting LTTNG_UST_ARCH_HAS_EFFICIENT_UNALIGNED_ACCESS 1 yields the 
> best performance on arm64.
> 
> This could go into lttng-ust master branch as well, e.g.:
> 
> #if defined(LTTNG_UST_ARCH_AARCH64)
> #define LTTNG_UST_ARCH_HAS_EFFICIENT_UNALIGNED_ACCESS 1
> #endif
> 
> Thanks!
> 
> Mathieu
> 
>>
>> Micke
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev@lists.lttng.org
>> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

  reply	other threads:[~2023-01-31 16:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30  6:50 [lttng-dev] lttng-consumerd crash on aarch64 due to x86 arch specific optimization Beckius, Mikael via lttng-dev
2023-01-31 16:08 ` Mathieu Desnoyers via lttng-dev
2023-01-31 16:18   ` Mathieu Desnoyers via lttng-dev [this message]
2023-01-31 16:32     ` Mathieu Desnoyers via lttng-dev
2023-02-02 16:26       ` Mathieu Desnoyers via lttng-dev
2023-02-06 15:21         ` Beckius, Mikael via lttng-dev
2023-02-06 16:15         ` Beckius, Mikael via lttng-dev
2023-02-06 16:39           ` Mathieu Desnoyers via lttng-dev
     [not found] <CAF2baFfZ+sxAGfxGY_or7=JJMxDngZTtfrzruUC5=RnZFD4tvA@mail.gmail.com>
     [not found] ` <954909194.21985.1511551181212.JavaMail.zimbra@efficios.com>
     [not found]   ` <CAF2baFecVMCenooHSMcNChMEkevz1taF0VWUxWAyxbUq8kVXSg@mail.gmail.com>
2023-01-25 12:25     ` Mathieu Desnoyers via lttng-dev
2023-01-26 19:32       ` Anders Wallin via lttng-dev
2023-01-26 19:47         ` Mathieu Desnoyers via lttng-dev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e525c864-a2ee-ef34-b7fd-1c114e70b081@efficios.com \
    --to=lttng-dev@lists.lttng.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mikael.beckius@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).