From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161366AbbKENr3 (ORCPT ); Thu, 5 Nov 2015 08:47:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:36975 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756159AbbKENr1 (ORCPT ); Thu, 5 Nov 2015 08:47:27 -0500 Subject: Re: [PATCH] mm, hugetlb: use memory policy when available To: Dave Hansen References: <20151020195317.ADA052D8@viggo.jf.intel.com> Cc: akpm@linux-foundation.org, n-horiguchi@ah.jp.nec.com, mike.kravetz@oracle.com, hillf.zj@alibaba-inc.com, rientjes@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com From: Vlastimil Babka Message-ID: <563B5DE9.70803@suse.cz> Date: Thu, 5 Nov 2015 14:47:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151020195317.ADA052D8@viggo.jf.intel.com> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/20/2015 09:53 PM, Dave Hansen wrote: > From: Dave Hansen > > I have a hugetlbfs user which is never explicitly allocating huge pages > with 'nr_hugepages'. They only set 'nr_overcommit_hugepages' and then let > the pages be allocated from the buddy allocator at fault time. > > This works, but they noticed that mbind() was not doing them any good and > the pages were being allocated without respect for the policy they > specified. > > The code in question is this: > >> struct page *alloc_huge_page(struct vm_area_struct *vma, > ... >> page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, gbl_chg); >> if (!page) { >> page = alloc_buddy_huge_page(h, NUMA_NO_NODE); > > dequeue_huge_page_vma() is smart and will respect the VMA's memory policy. > But, it only grabs _existing_ huge pages from the huge page pool. If the > pool is empty, we fall back to alloc_buddy_huge_page() which obviously > can't do anything with the VMA's policy because it isn't even passed the > VMA. > > Almost everybody preallocates huge pages. That's probably why nobody has > ever noticed this. Looking back at the git history, I don't think this > _ever_ worked from when alloc_buddy_huge_page() was introduced in 7893d1d5, > 8 years ago. > > The fix is to pass vma/addr down in to the places where we actually call in > to the buddy allocator. It's fairly straightforward plumbing. This has > been lightly tested. > > Cc: Andrew Morton > Cc: Naoya Horiguchi > Cc: Mike Kravetz > Cc: Hillf Danton > Cc: David Rientjes > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Dave Hansen Together with the fix and NUMA=n cleanup Acked=by: Vlastimil Babka