From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rik van Riel Subject: Re: [PATCH] mm: hugetlb: initialize PG_reserved for tail pages of gigantig compound pages Date: Thu, 10 Oct 2013 13:51:45 -0400 Message-ID: <5256E931.5010403@redhat.com> References: <1381421561-10203-1-git-send-email-aarcange@redhat.com> <1381421561-10203-2-git-send-email-aarcange@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Andrew Morton , qemu-devel@nongnu.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gleb Natapov , Mel Gorman , Hugh Dickins To: Andrea Arcangeli Return-path: In-Reply-To: <1381421561-10203-2-git-send-email-aarcange@redhat.com> Sender: owner-linux-mm@kvack.org List-Id: kvm.vger.kernel.org On 10/10/2013 12:12 PM, Andrea Arcangeli wrote: > 11feeb498086a3a5907b8148bdf1786a9b18fc55 introduced a memory leak when > KVM is run on gigantic compound pages. > > 11feeb498086a3a5907b8148bdf1786a9b18fc55 depends on the assumption > that PG_reserved is identical for all head and tail pages of a > compound page. So that if get_user_pages returns a tail page, we don't > need to check the head page in order to know if we deal with a > reserved page that requires different refcounting. > > The assumption that PG_reserved is the same for head and tail pages is > certainly correct for THP and regular hugepages, but gigantic > hugepages allocated through bootmem don't clear the PG_reserved on the > tail pages (the clearing of PG_reserved is done later only if the > gigantic hugepage is freed). > > This patch corrects the gigantic compound page initialization so that > we can retain the optimization in > 11feeb498086a3a5907b8148bdf1786a9b18fc55. The cacheline was already > modified in order to set PG_tail so this won't affect the boot time of > large memory systems. > > Reported-by: andy123 > Signed-off-by: Andrea Arcangeli Acked-by: Rik van Riel -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755990Ab3JJRwz (ORCPT ); Thu, 10 Oct 2013 13:52:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40139 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753479Ab3JJRwx (ORCPT ); Thu, 10 Oct 2013 13:52:53 -0400 Message-ID: <5256E931.5010403@redhat.com> Date: Thu, 10 Oct 2013 13:51:45 -0400 From: Rik van Riel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Andrea Arcangeli CC: Andrew Morton , qemu-devel@nongnu.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gleb Natapov , Mel Gorman , Hugh Dickins Subject: Re: [PATCH] mm: hugetlb: initialize PG_reserved for tail pages of gigantig compound pages References: <1381421561-10203-1-git-send-email-aarcange@redhat.com> <1381421561-10203-2-git-send-email-aarcange@redhat.com> In-Reply-To: <1381421561-10203-2-git-send-email-aarcange@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/10/2013 12:12 PM, Andrea Arcangeli wrote: > 11feeb498086a3a5907b8148bdf1786a9b18fc55 introduced a memory leak when > KVM is run on gigantic compound pages. > > 11feeb498086a3a5907b8148bdf1786a9b18fc55 depends on the assumption > that PG_reserved is identical for all head and tail pages of a > compound page. So that if get_user_pages returns a tail page, we don't > need to check the head page in order to know if we deal with a > reserved page that requires different refcounting. > > The assumption that PG_reserved is the same for head and tail pages is > certainly correct for THP and regular hugepages, but gigantic > hugepages allocated through bootmem don't clear the PG_reserved on the > tail pages (the clearing of PG_reserved is done later only if the > gigantic hugepage is freed). > > This patch corrects the gigantic compound page initialization so that > we can retain the optimization in > 11feeb498086a3a5907b8148bdf1786a9b18fc55. The cacheline was already > modified in order to set PG_tail so this won't affect the boot time of > large memory systems. > > Reported-by: andy123 > Signed-off-by: Andrea Arcangeli Acked-by: Rik van Riel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUKPy-0002GJ-J4 for qemu-devel@nongnu.org; Thu, 10 Oct 2013 13:53:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUKPs-0006lb-FP for qemu-devel@nongnu.org; Thu, 10 Oct 2013 13:52:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUKPs-0006lJ-6x for qemu-devel@nongnu.org; Thu, 10 Oct 2013 13:52:52 -0400 Message-ID: <5256E931.5010403@redhat.com> Date: Thu, 10 Oct 2013 13:51:45 -0400 From: Rik van Riel MIME-Version: 1.0 References: <1381421561-10203-1-git-send-email-aarcange@redhat.com> <1381421561-10203-2-git-send-email-aarcange@redhat.com> In-Reply-To: <1381421561-10203-2-git-send-email-aarcange@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] mm: hugetlb: initialize PG_reserved for tail pages of gigantig compound pages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrea Arcangeli Cc: kvm@vger.kernel.org, Gleb Natapov , Hugh Dickins , qemu-devel@nongnu.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mel Gorman , Andrew Morton On 10/10/2013 12:12 PM, Andrea Arcangeli wrote: > 11feeb498086a3a5907b8148bdf1786a9b18fc55 introduced a memory leak when > KVM is run on gigantic compound pages. > > 11feeb498086a3a5907b8148bdf1786a9b18fc55 depends on the assumption > that PG_reserved is identical for all head and tail pages of a > compound page. So that if get_user_pages returns a tail page, we don't > need to check the head page in order to know if we deal with a > reserved page that requires different refcounting. > > The assumption that PG_reserved is the same for head and tail pages is > certainly correct for THP and regular hugepages, but gigantic > hugepages allocated through bootmem don't clear the PG_reserved on the > tail pages (the clearing of PG_reserved is done later only if the > gigantic hugepage is freed). > > This patch corrects the gigantic compound page initialization so that > we can retain the optimization in > 11feeb498086a3a5907b8148bdf1786a9b18fc55. The cacheline was already > modified in order to set PG_tail so this won't affect the boot time of > large memory systems. > > Reported-by: andy123 > Signed-off-by: Andrea Arcangeli Acked-by: Rik van Riel