From: Mathieu Desnoyers via lttng-dev <lttng-dev@lists.lttng.org> To: Dmitry Antipov <dmantipov@yandex.ru> Cc: lttng-dev <lttng-dev@lists.lttng.org> Subject: Re: Userspace RCU data alignment Date: Fri, 5 Jun 2020 12:09:08 -0400 (EDT) [thread overview] Message-ID: <168357390.56518.1591373348015.JavaMail.zimbra@efficios.com> (raw) In-Reply-To: <5352eebd-dbb7-70f9-a354-91522170efdf@yandex.ru> ----- On Jun 3, 2020, at 8:36 AM, lttng-dev lttng-dev@lists.lttng.org wrote: > I've compiled userspace-rcu with: > > CC=gcc CFLAGS='-O0 -g3 -fsanitize=undefined' LIBS='-lubsan' ./configure [xxx] > > and see a lot of 'misaligned address' runtime errors like: > > ./doc/examples/urcu-flavors/bp ==> > > ../include/urcu/static/urcu-bp.h:185:6: runtime error: member access within > misaligned address 0x7fcac376a020 for type 'struct urcu_bp_reader', which > requires 128 byte alignment > 0x7fcac376a020: note: pointer points here > ca 7f 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 00 00 00 00 00 00 > ^ > #0 0x7fcac372a880 in _urcu_bp_read_unlock ../include/urcu/static/urcu-bp.h:185 > #1 0x7fcac372b0d9 in urcu_bp_read_unlock > /home/antipov/userspace-rcu/src/urcu-bp.c:363 > #2 0x4017d5 in main > /home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp.c:92 > #3 0x7fcac2bc2041 in __libc_start_main ../csu/libc-start.c:308 > #4 0x40111d in _start > (/home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp+0x40111d) > > ../include/urcu/static/urcu-bp.h:189:2: runtime error: member access within > misaligned address 0x7fcac376a020 for type 'struct urcu_bp_reader', which > requires 128 byte alignment > 0x7fcac376a020: note: pointer points here > ca 7f 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 00 00 00 00 00 00 > ^ > #0 0x7fcac372a8c1 in _urcu_bp_read_unlock ../include/urcu/static/urcu-bp.h:189 > #1 0x7fcac372b0d9 in urcu_bp_read_unlock > /home/antipov/userspace-rcu/src/urcu-bp.c:363 > #2 0x4017d5 in main > /home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp.c:92 > #3 0x7fcac2bc2041 in __libc_start_main ../csu/libc-start.c:308 > #4 0x40111d in _start > (/home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp+0x40111d) > > Is it critical for correctness, or speed, or whatever else? As I remember this is mainly for speed, so it's not a show-stopper. > To whom it may be interesting, some of (probably not all) alignment issues may > be fixed > with attached patch. I agree on fixing this, but I recommend a different approach: Change: struct registry_chunk { size_t data_len; /* data length */ size_t used; /* amount of data used */ struct cds_list_head node; /* chunk_list node */ char data[]; }; for: struct registry_chunk { size_t nr_readers; /* number of readers */ size_t used; /* amount of data used */ struct cds_list_head node; /* chunk_list node */ struct urcu_bp_reader readers[]; }; And adapt all the readers allocation scheme within urcu-bp to work on "readers" elements rather than bytes. By doing so, struct registry_chunk will adapt to have the proper alignment. Thanks, Mathieu > > Dmitry > > _______________________________________________ > lttng-dev mailing list > lttng-dev@lists.lttng.org > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
WARNING: multiple messages have this Message-ID (diff)
From: Mathieu Desnoyers via lttng-dev <lttng-dev@lists.lttng.org> To: Dmitry Antipov <dmantipov@yandex.ru> Cc: lttng-dev <lttng-dev@lists.lttng.org> Subject: Re: [lttng-dev] Userspace RCU data alignment Date: Fri, 5 Jun 2020 12:09:08 -0400 (EDT) [thread overview] Message-ID: <168357390.56518.1591373348015.JavaMail.zimbra@efficios.com> (raw) Message-ID: <20200605160908.SiID8Q859QAiVLCdF_5bEZmgxFvXCBieLwYgO1HmZcQ@z> (raw) In-Reply-To: <5352eebd-dbb7-70f9-a354-91522170efdf@yandex.ru> ----- On Jun 3, 2020, at 8:36 AM, lttng-dev lttng-dev@lists.lttng.org wrote: > I've compiled userspace-rcu with: > > CC=gcc CFLAGS='-O0 -g3 -fsanitize=undefined' LIBS='-lubsan' ./configure [xxx] > > and see a lot of 'misaligned address' runtime errors like: > > ./doc/examples/urcu-flavors/bp ==> > > ../include/urcu/static/urcu-bp.h:185:6: runtime error: member access within > misaligned address 0x7fcac376a020 for type 'struct urcu_bp_reader', which > requires 128 byte alignment > 0x7fcac376a020: note: pointer points here > ca 7f 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 00 00 00 00 00 00 > ^ > #0 0x7fcac372a880 in _urcu_bp_read_unlock ../include/urcu/static/urcu-bp.h:185 > #1 0x7fcac372b0d9 in urcu_bp_read_unlock > /home/antipov/userspace-rcu/src/urcu-bp.c:363 > #2 0x4017d5 in main > /home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp.c:92 > #3 0x7fcac2bc2041 in __libc_start_main ../csu/libc-start.c:308 > #4 0x40111d in _start > (/home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp+0x40111d) > > ../include/urcu/static/urcu-bp.h:189:2: runtime error: member access within > misaligned address 0x7fcac376a020 for type 'struct urcu_bp_reader', which > requires 128 byte alignment > 0x7fcac376a020: note: pointer points here > ca 7f 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 00 00 00 00 00 00 > ^ > #0 0x7fcac372a8c1 in _urcu_bp_read_unlock ../include/urcu/static/urcu-bp.h:189 > #1 0x7fcac372b0d9 in urcu_bp_read_unlock > /home/antipov/userspace-rcu/src/urcu-bp.c:363 > #2 0x4017d5 in main > /home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp.c:92 > #3 0x7fcac2bc2041 in __libc_start_main ../csu/libc-start.c:308 > #4 0x40111d in _start > (/home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp+0x40111d) > > Is it critical for correctness, or speed, or whatever else? As I remember this is mainly for speed, so it's not a show-stopper. > To whom it may be interesting, some of (probably not all) alignment issues may > be fixed > with attached patch. I agree on fixing this, but I recommend a different approach: Change: struct registry_chunk { size_t data_len; /* data length */ size_t used; /* amount of data used */ struct cds_list_head node; /* chunk_list node */ char data[]; }; for: struct registry_chunk { size_t nr_readers; /* number of readers */ size_t used; /* amount of data used */ struct cds_list_head node; /* chunk_list node */ struct urcu_bp_reader readers[]; }; And adapt all the readers allocation scheme within urcu-bp to work on "readers" elements rather than bytes. By doing so, struct registry_chunk will adapt to have the proper alignment. Thanks, Mathieu > > Dmitry > > _______________________________________________ > lttng-dev mailing list > lttng-dev@lists.lttng.org > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list lttng-dev@lists.lttng.org https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
next prev parent reply other threads:[~2020-06-05 16:09 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-03 12:36 Userspace RCU data alignment Dmitry Antipov via lttng-dev 2020-06-03 12:36 ` [lttng-dev] " Dmitry Antipov via lttng-dev 2020-06-05 16:09 ` Mathieu Desnoyers via lttng-dev [this message] 2020-06-05 16:09 ` 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=168357390.56518.1591373348015.JavaMail.zimbra@efficios.com \ --to=lttng-dev@lists.lttng.org \ --cc=dmantipov@yandex.ru \ --cc=mathieu.desnoyers@efficios.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: linkBe 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 NNTP newsgroup(s).