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.