Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1618018
| From | Matthew Wilcox <willy@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure |
| Date | 2017-04-06 15:50 +0200 |
| Message-ID | <ttfXs-HN-5@gated-at.bofh.it> (permalink) |
| References | <tsNou-7Zm-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Apr 05, 2017 at 03:10:58PM +0800, Huang, Ying wrote: > In general, kmalloc() will have less memory fragmentation than > vmalloc(). From Dave Hansen: For example, 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. Wait, what? How does kmalloc() manage to allocate two pages that cross a 2MB boundary? AFAIK if you ask kmalloc to allocate N pages, it asks the page allocator for an order-log(N) page allocation. Being a buddy allocator, that comes back with an aligned set of pages. There's no way it can get the last page from a 2MB region and the first page from the next 2MB region.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure "Huang, Ying" <ying.huang@intel.com> - 2017-04-05 09:20 +0200
Re: [PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure Matthew Wilcox <willy@infradead.org> - 2017-04-06 15:50 +0200
Re: [PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure "Huang\, Ying" <ying.huang@intel.com> - 2017-04-07 03:30 +0200
csiph-web