linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@intel.com>,
	Hugh Dickins <hughd@google.com>, Shaohua Li <shli@kernel.org>,
	Minchan Kim <minchan@kernel.org>, Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure
Date: Thu, 6 Apr 2017 06:40:24 -0700	[thread overview]
Message-ID: <20170406134024.GD31725@bombadil.infradead.org> (raw)
In-Reply-To: <20170405071058.25223-1-ying.huang@intel.com>

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.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-04-06 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05  7:10 [PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure Huang, Ying
2017-04-06 13:40 ` Matthew Wilcox [this message]
2017-04-07  1:24   ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170406134024.GD31725@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=riel@redhat.com \
    --cc=shli@kernel.org \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).