[CRIU] [PATCH] rst-malloc: introduce rst_mem_align

Pavel Emelyanov xemul at virtuozzo.com
Wed Feb 10 09:08:43 PST 2016


On 02/10/2016 07:54 PM, Tycho Andersen wrote:
> On Wed, Feb 10, 2016 at 08:48:47AM -0800, Andrew Vagin wrote:
>> On Wed, Feb 10, 2016 at 09:43:23AM -0700, Tycho Andersen wrote:
>>> On Wed, Feb 10, 2016 at 08:38:24AM -0800, Andrew Vagin wrote:
>>>> On Wed, Feb 10, 2016 at 09:06:36AM -0700, Tycho Andersen wrote:
>>>>> Since we need to align some allocations (but not most of them), let's
>>>>> switch to a helper called rst_mem_align, which aligns the free list pointer
>>>>> for the next allocation.
>>>>
>>>> When should we call rst_mem_align()?
>>>
>>> I'm not sure, actually. I guess whenever there is going to be an
>>> argument that will be passed to futex or atomic?
>>>
>>>> Why do we not call it before each call of rst_mem_cpos()
>>>
>>> I just translated all calls:
>>>
>>> rst_mem_alloc() => rst_mem_align(); rst_mem_alloc()
>>> rst_mem_alloc_cont() => rst_mem_alloc()
>>>
>>> so in principle it should be the same as before (except the cpos is
>>> always reported correctly).
>>
>> It's wrong. I think we need to align a start address of an array too.
>>
>> I mean that rst_mem_alloc() should return alligned address after
>> rst_mem_cpos().
>>
>> Initially I aligned an addess which is returned from rst_mem_cpos(), but
>> then we decided that it isn't required. Now we see that it was a wrong
>> idea.
> 
> rst_mem_cpos() and rst_mem_alloc() should always return the same
> thing, otherwise it's a bug.

Exactly! And in order to make this work we need to have either two pairs --
_alloc() + _cpos() vs _alloc_align() + _cpos_align() , which is easy to
misuse, or have separate _align() call that just moves the pointer and
makes subsequent _alloc() + _cpos() work correctly.

> (leaving the discussion of when to align to the other thread)

-- Pavel


More information about the CRIU mailing list