[SLOF] [PATCH] Improve SLOF_alloc_mem_aligned()
thuth at redhat.com
Thu Sep 15 17:04:10 AEST 2016
On 15.09.2016 05:49, Alexey Kardashevskiy wrote:
> On 14/09/16 15:39, Alexey Kardashevskiy wrote:
>> On 05/09/16 19:28, Thomas Huth wrote:
>>> When loading a file via the spapr-vlan network interface, SLOF
>>> currently leaks quite a lot of memory, about 12kB each time.
>>> This happens mainly because veth_init() uses for example
>>> SLOF_alloc_mem_aligned(8192, 4096) and similar calls to get
>>> the memory, but the space for the additional alignment is never
>>> returned anymore later. An easy way to ease this situation is to
>>> improve SLOF_alloc_mem_aligned() a little bit. We normally get memory
>>> from SLOF_alloc_mem() which is aligned pretty well already, thanks to
>>> the buddy allocator in SLOF. So we can try to first get a memory
>>> block with the exact size first, and only do the alignment dance
>>> if the first allocation was not aligned yet.
>>> Signed-off-by: Thomas Huth <thuth at redhat.com>
>> I do not like it but since the allocated address does not store the size
>> somewhere nearby, I'll apply this anyway, thanks.
> I asked for advice and we could actually always try allocating
> (size+align-1) here, and then if the address is not aligned - free the
> chunk before aligned address, if aligned - free the chunk after addr+size.
That could work ... but you should also be prepared that you might need
to free chunks on both ends of the allocation, e.g. when somebody asks
for a region with "align" being much bigger than "size"...
More information about the SLOF