From: Aleksandr Lyapunov <alyapunov@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
tarantool-patches@dev.tarantool.org, korablev@tarantool.org,
tsafin@tarantool.org, gorcunov@gmail.com
Subject: Re: [Tarantool-patches] [PATCH small 2/2] lsregion: provide aligned version of alloc
Date: Fri, 15 May 2020 16:03:48 +0300 [thread overview]
Message-ID: <e2ba34fa-76e3-9776-b553-4b175da7d6fb@tarantool.org> (raw)
In-Reply-To: <90f1c60ad69d7e577467ad0d1664bbfee3816df7.1589498880.git.v.shpilevoy@tarantool.org>
[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]
On 5/15/20 2:31 AM, Vladislav Shpilevoy wrote:
> +static inline void *
> +lsregion_aligned_alloc(struct lsregion *lsregion, size_t size, size_t alignment,
> + int64_t id)
> +{
> + void *unaligned = lsregion_reserve(lsregion, size + alignment - 1);
I do not like this change. It will work, but it's not optimal.
We don't need to reserve more than size if lslab_pos(slab) is already
aligned.
It could lead to new slab allocation in cases we actually have enough
aligned space in current.
If we really need aligned alloc, I'm sure we should implement it more
carefully.
I think it should start with something like:
static inline size_t
-lslab_unused(const struct lslab *slab)
+lslab_unused(const struct lslab *slab, size_t align)
{
- assert(slab->slab_size >= slab->slab_used);
- return slab->slab_size - slab->slab_used;
+ assert(slab->slab_size >= small_align(slab->slab_used, align));
+ return slab->slab_size - small_align(slab->slab_used, align);
}
Note also we should remove small_align call from lslab_sizeof method.
[-- Attachment #2: Type: text/html, Size: 1738 bytes --]
next prev parent reply other threads:[~2020-05-15 13:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 23:31 [Tarantool-patches] [PATCH small 0/2] Aligned lsregion Vladislav Shpilevoy
2020-05-14 23:31 ` [Tarantool-patches] [PATCH small 1/2] lsregion: introduce lsregion_reserve() Vladislav Shpilevoy
2020-05-15 12:35 ` Aleksandr Lyapunov
2020-05-14 23:31 ` [Tarantool-patches] [PATCH small 2/2] lsregion: provide aligned version of alloc Vladislav Shpilevoy
2020-05-15 13:03 ` Aleksandr Lyapunov [this message]
2020-05-15 23:24 ` Vladislav Shpilevoy
2020-05-15 12:26 ` [Tarantool-patches] [PATCH small 0/2] Aligned lsregion Aleksandr Lyapunov
2020-05-15 23:22 ` Vladislav Shpilevoy
2020-05-16 19:09 ` Aleksandr Lyapunov
2020-05-17 13:56 ` 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=e2ba34fa-76e3-9776-b553-4b175da7d6fb@tarantool.org \
--to=alyapunov@tarantool.org \
--cc=gorcunov@gmail.com \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=tsafin@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH small 2/2] lsregion: provide aligned version of alloc' \
/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