From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: Re: [PATCHv4 14/39] thp, mm: rewrite delete_from_page_cache() to support huge pages Date: Fri, 07 Jun 2013 08:56:10 -0700 Message-ID: <51B2029A.8050504@sr71.net> References: <1368321816-17719-1-git-send-email-kirill.shutemov@linux.intel.com> <1368321816-17719-15-git-send-email-kirill.shutemov@linux.intel.com> <519BD595.5040405@sr71.net> <20130528122812.0D624E0090@blue.fi.intel.com> <20130607151025.241EFE0090@blue.fi.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Andrea Arcangeli , Andrew Morton , Al Viro , Hugh Dickins , Wu Fengguang , Jan Kara , Mel Gorman , linux-mm@kvack.org, Andi Kleen , Matthew Wilcox , "Kirill A. Shutemov" , Hillf Danton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: "Kirill A. Shutemov" Return-path: In-Reply-To: <20130607151025.241EFE0090@blue.fi.intel.com> Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org On 06/07/2013 08:10 AM, Kirill A. Shutemov wrote: > + /* > + * When we add a huge page to page cache we take only reference to head > + * page, but on split we need to take addition reference to all tail > + * pages since they are still in page cache after splitting. > + */ > + init_tail_refcount = PageAnon(page) ? 0 : 1; What's the "init" for in the name? In add_to_page_cache_locked() in patch 12/39, you do > + spin_lock_irq(&mapping->tree_lock); > + for (i = 0; i < nr; i++) { > + page_cache_get(page + i); That looks to me to be taking references to the tail pages. What gives? :) > for (i = HPAGE_PMD_NR - 1; i >= 1; i--) { > struct page *page_tail = page + i; > > @@ -1587,8 +1595,9 @@ static void __split_huge_page_refcount(struct page *page, > * atomic_set() here would be safe on all archs (and > * not only on x86), it's safer to use atomic_add(). > */ > - atomic_add(page_mapcount(page) + page_mapcount(page_tail) + 1, > - &page_tail->_count); > + atomic_add(init_tail_refcount + page_mapcount(page) + > + page_mapcount(page_tail) + 1, > + &page_tail->_count); > > /* after clearing PageTail the gup refcount can be released */ > smp_mb(); This does look much better in general, though. -- 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 S1754010Ab3FJPiH (ORCPT ); Mon, 10 Jun 2013 11:38:07 -0400 Received: from www.sr71.net ([198.145.64.142]:35184 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753918Ab3FJPiF (ORCPT ); Mon, 10 Jun 2013 11:38:05 -0400 Message-ID: <51B2029A.8050504@sr71.net> Date: Fri, 07 Jun 2013 08:56:10 -0700 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: "Kirill A. Shutemov" CC: Andrea Arcangeli , Andrew Morton , Al Viro , Hugh Dickins , Wu Fengguang , Jan Kara , Mel Gorman , linux-mm@kvack.org, Andi Kleen , Matthew Wilcox , "Kirill A. Shutemov" , Hillf Danton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv4 14/39] thp, mm: rewrite delete_from_page_cache() to support huge pages References: <1368321816-17719-1-git-send-email-kirill.shutemov@linux.intel.com> <1368321816-17719-15-git-send-email-kirill.shutemov@linux.intel.com> <519BD595.5040405@sr71.net> <20130528122812.0D624E0090@blue.fi.intel.com> <20130607151025.241EFE0090@blue.fi.intel.com> In-Reply-To: <20130607151025.241EFE0090@blue.fi.intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/07/2013 08:10 AM, Kirill A. Shutemov wrote: > + /* > + * When we add a huge page to page cache we take only reference to head > + * page, but on split we need to take addition reference to all tail > + * pages since they are still in page cache after splitting. > + */ > + init_tail_refcount = PageAnon(page) ? 0 : 1; What's the "init" for in the name? In add_to_page_cache_locked() in patch 12/39, you do > + spin_lock_irq(&mapping->tree_lock); > + for (i = 0; i < nr; i++) { > + page_cache_get(page + i); That looks to me to be taking references to the tail pages. What gives? :) > for (i = HPAGE_PMD_NR - 1; i >= 1; i--) { > struct page *page_tail = page + i; > > @@ -1587,8 +1595,9 @@ static void __split_huge_page_refcount(struct page *page, > * atomic_set() here would be safe on all archs (and > * not only on x86), it's safer to use atomic_add(). > */ > - atomic_add(page_mapcount(page) + page_mapcount(page_tail) + 1, > - &page_tail->_count); > + atomic_add(init_tail_refcount + page_mapcount(page) + > + page_mapcount(page_tail) + 1, > + &page_tail->_count); > > /* after clearing PageTail the gup refcount can be released */ > smp_mb(); This does look much better in general, though.