Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Timur Safin" <tsafin@tarantool.org>
To: 'Vladislav Shpilevoy' <v.shpilevoy@tarantool.org>,
	tarantool-patches@dev.tarantool.org, alyapunov@tarantool.org,
	korablev@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 09/10] port: make port_c_entry not PACKED
Date: Thu, 28 May 2020 23:42:52 +0300	[thread overview]
Message-ID: <04a701d63530$8f1b1f30$ad515d90$@tarantool.org> (raw)
In-Reply-To: <926949a835f9c4220502bab40186c4f45798c94b.1590622225.git.v.shpilevoy@tarantool.org>

LGTM!

: -----Original Message-----
: From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
: Sent: Thursday, May 28, 2020 2:32 AM
: To: tarantool-patches@dev.tarantool.org; alyapunov@tarantool.org;
: korablev@tarantool.org; tsafin@tarantool.org
: Subject: [PATCH v2 09/10] port: make port_c_entry not PACKED
: 
: PACKED structures don't have padding between their members and
: after the structure (needed to be able to store them in an array).
: 
: Port_c_entry was PACKED, since it does not have padding between
: its members anyway, and the padding in the end was not needed,
: because these objects are never stored in an array. As a result,
: sizeof(port_c_entry) was not aligned too.
: 
: Appeared, that mempool, used to allocate port_c_entry objects,
: can't work correctly, when object size is not aligned at least by
: 8 bytes. Because mempool does not do any alignment internally, and
: uses the free objects as a temporary storage for some metadata,
: requiring 8 byte alignment.
: 
: The patch removes PACKED attribute from port_c_entry, so now its
: size is aligned by 8 bytes, and mempool works fine.
: 
: Part of #4609
: ---
:  src/box/lua/schema.lua |  2 +-
:  src/box/port.h         | 10 +---------
:  src/lib/core/port.h    |  2 +-
:  3 files changed, 3 insertions(+), 11 deletions(-)
: 
: diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua
: index cdfbb65f7..e6844b45f 100644
: --- a/src/box/lua/schema.lua
: +++ b/src/box/lua/schema.lua
: @@ -79,7 +79,7 @@ ffi.cdef[[
:      box_txn_savepoint_t *
:      box_txn_savepoint();
: 
: -    struct __attribute__((packed)) port_c_entry {
: +    struct port_c_entry {
:          struct port_c_entry *next;
:          union {
:              struct tuple *tuple;
: diff --git a/src/box/port.h b/src/box/port.h
: index 76bb5ed1b..43d0f9deb 100644
: --- a/src/box/port.h
: +++ b/src/box/port.h
: @@ -106,12 +106,7 @@ void
:  port_vdbemem_create(struct port *base, struct sql_value *mem,
:  		    uint32_t mem_count);
: 
: -/**
: - * The struct is PACKED to avoid unnecessary 4 byte padding
: - * after mp_size. These objects are never stored on stack, neither
: - * allocated as an array, so the padding is not needed.
: - */
: -struct PACKED port_c_entry {
: +struct port_c_entry {
:  	struct port_c_entry *next;
:  	union {
:  		/** Valid if mp_size is 0. */
: @@ -126,9 +121,6 @@ struct PACKED port_c_entry {
:  	uint32_t mp_size;
:  };
: 
: -static_assert(sizeof(struct port_c_entry) == 20,
: -	      "port_c_entry is expected to be perfectly aligned and
: packed");
: -
:  /**
:   * C port is used by C functions from the public API. They can
:   * return tuples and arbitrary MessagePack.
: diff --git a/src/lib/core/port.h b/src/lib/core/port.h
: index bb7787679..5c51f76e1 100644
: --- a/src/lib/core/port.h
: +++ b/src/lib/core/port.h
: @@ -122,7 +122,7 @@ struct port {
:  	 * Implementation dependent content. Needed to declare
:  	 * an abstract port instance on stack.
:  	 */
: -	char pad[52];
: +	char pad[60];
:  };
: 
:  /** Is not inlined just to be exported. */
: --
: 2.21.1 (Apple Git-122.3)

  reply	other threads:[~2020-05-28 20:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 23:32 [Tarantool-patches] [PATCH v2 00/10] Sanitize unaligned access Vladislav Shpilevoy
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 01/10] small: sanitized rlist and new region API Vladislav Shpilevoy
2020-05-28 20:41   ` Timur Safin
2020-05-28 22:56     ` Vladislav Shpilevoy
2020-06-08 23:01   ` Vladislav Shpilevoy
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 10/10] xrow: use unaligned store operation in xrow_to_iovec() Vladislav Shpilevoy
2020-05-28 20:20   ` Timur Safin
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 02/10] cmake: ignore warnings on alignof() and offsetof() Vladislav Shpilevoy
2020-05-28 20:18   ` Timur Safin
2020-05-29  6:24   ` Kirill Yukhin
2020-05-29 22:34     ` Vladislav Shpilevoy
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 03/10] cmake: add option ENABLE_UB_SANITIZER Vladislav Shpilevoy
2020-05-28 20:42   ` Timur Safin
2020-05-29  8:53   ` Sergey Bronnikov
2020-05-29 22:36     ` Vladislav Shpilevoy
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 04/10] crc32: align memory access Vladislav Shpilevoy
2020-05-28 20:11   ` Timur Safin
2020-05-28 23:23     ` Vladislav Shpilevoy
2020-05-28 23:32       ` Timur Safin
2020-06-08 22:33       ` Vladislav Shpilevoy
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 05/10] sql: make BtCursor's memory aligned Vladislav Shpilevoy
2020-05-28 20:20   ` Timur Safin
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 06/10] region: use aligned allocations where necessary Vladislav Shpilevoy
2020-05-28 20:35   ` Timur Safin
2020-05-28 23:07     ` Vladislav Shpilevoy
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 07/10] vinyl: align statements and bps tree extents Vladislav Shpilevoy
2020-05-28 20:38   ` Timur Safin
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 08/10] tuple: use unaligned store-load for field map Vladislav Shpilevoy
2020-05-28 20:22   ` Timur Safin
2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 09/10] port: make port_c_entry not PACKED Vladislav Shpilevoy
2020-05-28 20:42   ` Timur Safin [this message]
2020-06-03 21:27 ` [Tarantool-patches] [PATCH v2 00/10] Sanitize unaligned access Vladislav Shpilevoy
2020-06-08 22:33 ` Vladislav Shpilevoy

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='04a701d63530$8f1b1f30$ad515d90$@tarantool.org' \
    --to=tsafin@tarantool.org \
    --cc=alyapunov@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 09/10] port: make port_c_entry not PACKED' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox