Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, avtikhon@tarantool.org,
	kyukhin@tarantool.org
Subject: [Tarantool-patches] [PATCH small 1/1] test: don't use not aligned size for mempool
Date: Sat, 20 Jun 2020 20:01:27 +0200	[thread overview]
Message-ID: <c48b47986bc9594d499f0480c0deb0925cd52bf2.1592676044.git.v.shpilevoy@tarantool.org> (raw)

Mempool expects aligned object size. Because it uses the free
blocks to store metadata in them, in a struct mslab. Which needs
alignment.

Part of https://github.com/tarantool/tarantool/issues/5063
---
Branch: http://github.com/tarantool/small/tree/gerold103/tarantool/gh-5063-not-aligned-test
Issue: https://github.com/tarantool/tarantool/issues/5063

 test/mempool.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/mempool.c b/test/mempool.c
index 298ba17..65eabaf 100644
--- a/test/mempool.c
+++ b/test/mempool.c
@@ -1,3 +1,4 @@
+#include "trivia/util.h"
 #include <small/mempool.h>
 #include <small/quota.h>
 #include <stdio.h>
@@ -121,6 +122,12 @@ int main()
 	objsize = rand() % OBJSIZE_MAX;
 	if (objsize < OBJSIZE_MIN)
 		objsize = OBJSIZE_MIN;
+	/*
+	 * Mempool does not work with not aligned sizes. Because
+	 * it utilizes the unused blocks for storing internal
+	 * info, which needs alignment.
+	 */
+	objsize = small_align(objsize, alignof(uint64_t));
 
 	quota_init(&quota, UINT_MAX);
 
-- 
2.21.1 (Apple Git-122.3)

             reply	other threads:[~2020-06-20 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20 18:01 Vladislav Shpilevoy [this message]
2020-06-21 10:06 ` Sergey Ostanevich
2020-06-21 15:35   ` 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=c48b47986bc9594d499f0480c0deb0925cd52bf2.1592676044.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=avtikhon@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH small 1/1] test: don'\''t use not aligned size for mempool' \
    /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