lkml.org 
[lkml]   [2017]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -v2 1/2] mm, swap: Use kvzalloc to allocate some swap data structure
From
Date
On 03/24/2017 09:52 AM, Tim Chen wrote:
> On Fri, 2017-03-24 at 06:56 -0700, Dave Hansen wrote:
>> On 03/24/2017 12:33 AM, John Hubbard wrote:
>>>
>>> There might be some additional information you are using to come up with
>>> that conclusion, that is not obvious to me. Any thoughts there? These
>>> calls use the same underlying page allocator (and I thought that both
>>> were subject to the same constraints on defragmentation, as a result of
>>> that). So I am not seeing any way that kmalloc could possibly be a
>>> less-fragmenting call than vmalloc.
>> You guys are having quite a discussion over a very small point.
>>
>> But, Ying is right.
>>
>> Let's say we have a two-page data structure. vmalloc() takes two
>> effectively random order-0 pages, probably from two different 2M pages
>> and pins them. That "kills" two 2M pages.
>>
>> kmalloc(), allocating two *contiguous* pages, is very unlikely to cross
>> a 2M boundary (it theoretically could). That means it will only "kill"
>> the possibility of a single 2M page. More 2M pages == less fragmentation.
>
> In vmalloc, it eventually calls __vmalloc_area_node that allocates the
> page one at a time. There's no attempt there to make the pages contiguous
> if I am reading the code correctly. So that will increase the memory
> fragmentation as we will be piecing together pages from all over the places.
>
> Tim

OK. Thanks everyone for spelling it out for me, before I started doing larger projects, with an
incorrect way of looking at the fragmentation behavior. :)

--
thanks,
john h

\
 
 \ /
  Last update: 2017-03-24 19:17    [W:0.074 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site