Re: the memory align about return value of kmalloc?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Refer: Understanding the Linux®  Virtual Memory Manager by Mel Gorman.
Ch 8- Slab allocator.



Shailesh Jain

On Sun, Jul 25, 2010 at 9:52 AM, Hiren Panchasara
<hiren.panchasara@xxxxxxxxx> wrote:
> Hi Sailesh,
>
> Can you point me to some good basic documentation where I can learn about memory, it's alignment, coloring and all ?
>
> Thanks much and regards.
> Hiren
>
>
>
> On Jul 25, 2010, at 12:26 AM, shailesh jain <coolworldofshail@xxxxxxxxx> wrote:
>
>> Slabs are generally allocated in range from 2^5 to 2^17 or something.
>> So even if you ask for 10 bytes you will get object from 2^5 slab i.e
>> 32 bytes. Objects allocated from slab are actually L1 CPU cache
>> aligned for optimal hardware use (other space is used to coloring.)
>>
>> I am pretty sure that it has be to 4 or 8 bytes aligned because
>> unaligned accesses are expensive and linux won't do that.
>>
>>
>>
>>
>> Shailesh Jain
>>
>>
>>
>>
>>
>> On Sun, Jul 25, 2010 at 12:15 AM, vichy <vichy.kuo@xxxxxxxxx> wrote:
>>> hi:
>>>
>>> 2010/7/25 shailesh jain <coolworldofshail@xxxxxxxxx>:
>>>> Nope. kmalloc uses slab allocator underneath it. So, No addresses will
>>>> not be 4k aligned.
>>>>
>>>> If you care about 4k aligned addresses you should use
>>>> __get_free_page() rather than kmalloc().
>>>> kmalloc's are used for small allocations - think about wastage of
>>>> memory if we try to place 4k alignment
>>>> requirements.
>>> thanks for your reply.
>>> so you mean we will have no idea what the alignment of memory address
>>> returned by kmalloc?
>>> thank you,
>>> vichy
>>>
>>
>>
>>
>> --
>> Shailesh Jain
>>
>> --
>> To unsubscribe from this list: send an email with
>> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>
>



-- 
Shailesh Jain

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux