From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <453EF4C1.5050102@kolumbus.fi> Date: Wed, 25 Oct 2006 08:23:13 +0300 From: =?ISO-8859-1?Q?Mika_Penttil=E4?= MIME-Version: 1.0 Subject: Re: [PATCH 3/3] hugetlb: fix absurd HugePages_Rsvd References: In-Reply-To: Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Sender: owner-linux-mm@kvack.org Return-Path: To: Hugh Dickins Cc: Andrew Morton , Ken Chen , Bill Irwin , Adam Litke , David Gibson , linux-mm@kvack.org List-ID: Hugh Dickins wrote: > If you truncated an mmap'ed hugetlbfs file, then faulted on the truncated > area, /proc/meminfo's HugePages_Rsvd wrapped hugely "negative". Reinstate > my preliminary i_size check before attempting to allocate the page (though > this only fixes the most obvious case: more work will be needed here). > > Signed-off-by: Hugh Dickins > ___ > > This is not a complete solution (what if hugetlb_no_page is actually > racing with truncate_hugepages?), and there are several other accounting > anomalies in here (private versus shared pages, hugetlbfs quota handling); > but those all need more thought. It'll probably make sense to use i_mutex > instead of hugetlb_instantiation_mutex, so locking out truncation and mmap. > > mm/hugetlb.c | 3 +++ > 1 file changed, 3 insertions(+) > > --- 2.6.19-rc3/mm/hugetlb.c 2006-10-24 04:34:37.000000000 +0100 > +++ linux/mm/hugetlb.c 2006-10-24 16:23:17.000000000 +0100 > @@ -478,6 +478,9 @@ int hugetlb_no_page(struct mm_struct *mm > retry: > page = find_lock_page(mapping, idx); > if (!page) { > + size = i_size_read(mapping->host) >> HPAGE_SHIFT; > + if (idx >= size) > + goto out; > if (hugetlb_get_quota(mapping)) > goto out; > page = alloc_huge_page(vma, address); > > -- > Shouldn't it be something like following ? size = (i_size_read(mapping->host) + HPAGE_SIZE - 1) >> HPAGE_SHIFT; If so this was wrong in the original code also. --Mika -- 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: email@kvack.org