From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932949AbdDGBZE (ORCPT ); Thu, 6 Apr 2017 21:25:04 -0400 Received: from mga02.intel.com ([134.134.136.20]:1091 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932701AbdDGBYw (ORCPT ); Thu, 6 Apr 2017 21:24:52 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,162,1488873600"; d="scan'208";a="953133171" From: "Huang\, Ying" To: Matthew Wilcox Cc: "Huang\, Ying" , Andrew Morton , , , Dave Hansen , "Hugh Dickins" , Shaohua Li , Minchan Kim , Rik van Riel Subject: Re: [PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure References: <20170405071058.25223-1-ying.huang@intel.com> <20170406134024.GD31725@bombadil.infradead.org> Date: Fri, 07 Apr 2017 09:24:49 +0800 In-Reply-To: <20170406134024.GD31725@bombadil.infradead.org> (Matthew Wilcox's message of "Thu, 6 Apr 2017 06:40:24 -0700") Message-ID: <87a87tau1q.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Matthew, Matthew Wilcox writes: > 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. OK. I will change the comments in the next version. Best Regards, Huang, Ying