From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755325AbbCaPve (ORCPT ); Tue, 31 Mar 2015 11:51:34 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:41977 "EHLO e23smtp04.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753534AbbCaPvd (ORCPT ); Tue, 31 Mar 2015 11:51:33 -0400 From: "Aneesh Kumar K.V" To: "Kirill A. Shutemov" , Andrew Morton , Andrea Arcangeli Cc: Dave Hansen , Hugh Dickins , Mel Gorman , Rik van Riel , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , Johannes Weiner , Michal Hocko , Jerome Marchand , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: Re: [PATCHv4 20/24] mm, thp: remove compound_lock In-Reply-To: <1425486792-93161-21-git-send-email-kirill.shutemov@linux.intel.com> References: <1425486792-93161-1-git-send-email-kirill.shutemov@linux.intel.com> <1425486792-93161-21-git-send-email-kirill.shutemov@linux.intel.com> User-Agent: Notmuch/0.19+30~gd241a48 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu) Date: Tue, 31 Mar 2015 21:20:31 +0530 Message-ID: <87r3s5b1yw.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15033115-0013-0000-0000-000001086108 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org .... .... static void put_compound_page(struct page *page) > { > struct page *page_head; > - unsigned long flags; > > if (likely(!PageTail(page))) { > if (put_page_testzero(page)) { > @@ -108,58 +101,33 @@ static void put_compound_page(struct page *page) > /* __split_huge_page_refcount can run under us */ > page_head = compound_head(page); > > - if (!compound_lock_needed(page_head)) { > - /* > - * If "page" is a THP tail, we must read the tail page flags > - * after the head page flags. The split_huge_page side enforces > - * write memory barriers between clearing PageTail and before > - * the head page can be freed and reallocated. > - */ > - smp_rmb(); > - if (likely(PageTail(page))) { > - /* __split_huge_page_refcount cannot race here. */ > - VM_BUG_ON_PAGE(!PageHead(page_head), page_head); > - VM_BUG_ON_PAGE(page_mapcount(page) != 0, page); > - if (put_page_testzero(page_head)) { > - /* > - * If this is the tail of a slab compound page, > - * the tail pin must not be the last reference > - * held on the page, because the PG_slab cannot > - * be cleared before all tail pins (which skips > - * the _mapcount tail refcounting) have been > - * released. For hugetlbfs the tail pin may be > - * the last reference on the page instead, > - * because PageHeadHuge will not go away until > - * the compound page enters the buddy > - * allocator. > - */ > - VM_BUG_ON_PAGE(PageSlab(page_head), page_head); > - __put_compound_page(page_head); > - } > - } else if (put_page_testzero(page)) > - __put_single_page(page); > - return; > - } > - > - flags = compound_lock_irqsave(page_head); > - /* here __split_huge_page_refcount won't run anymore */ > - if (likely(page != page_head && PageTail(page))) { > - bool free; > - > - free = put_page_testzero(page_head); > - compound_unlock_irqrestore(page_head, flags); > - if (free) { > - if (PageHead(page_head)) > - __put_compound_page(page_head); > - else > - __put_single_page(page_head); > + /* > + * If "page" is a THP tail, we must read the tail page flags after the > + * head page flags. The split_huge_page side enforces write memory > + * barriers between clearing PageTail and before the head page can be > + * freed and reallocated. > + */ > + smp_rmb(); > + if (likely(PageTail(page))) { > + /* __split_huge_page_refcount cannot race here. */ > + VM_BUG_ON_PAGE(!PageHead(page_head), page_head); > + if (put_page_testzero(page_head)) { > + /* > + * If this is the tail of a slab compound page, the > + * tail pin must not be the last reference held on the > + * page, because the PG_slab cannot be cleared before > + * all tail pins (which skips the _mapcount tail > + * refcounting) have been released. For hugetlbfs the > + * tail pin may be the last reference on the page > + * instead, because PageHeadHuge will not go away until > + * the compound page enters the buddy allocator. > + */ > + VM_BUG_ON_PAGE(PageSlab(page_head), page_head); > + __put_compound_page(page_head); > } The comment may need an update ? For THP also a tail pin may be the last reference on the page right ? > - } else { > - compound_unlock_irqrestore(page_head, flags); > - VM_BUG_ON_PAGE(PageTail(page), page); > - if (put_page_testzero(page)) > - __put_single_page(page); > - } > + } else if (put_page_testzero(page)) > + __put_single_page(page); > + return; > } > > void put_page(struct page *page) > @@ -178,42 +146,29 @@ EXPORT_SYMBOL(put_page); > void __get_page_tail(struct page *page) > { > struct page *page_head = compound_head(page); ..... .... > + smp_rmb(); > + if (likely(PageTail(page))) { > + /* > + * This is a hugetlbfs page or a slab page. > + * __split_huge_page_refcount cannot race here. > + */ This comment also need an update. This can be a THP tail page right ? > + VM_BUG_ON_PAGE(!PageHead(page_head), page_head); > + VM_BUG_ON(page_head != page->first_page); > + VM_BUG_ON_PAGE(atomic_read(&page_head->_count) <= 0, > + page); > + atomic_inc(&page_head->_count); > + } else { > + /* > + * __split_huge_page_refcount run before us, "page" was > + * a thp tail. the split page_head has been freed and > + * reallocated as slab or hugetlbfs page of smaller > + * order (only possible if reallocated as slab on x86). > + */ > VM_BUG_ON_PAGE(atomic_read(&page->_count) <= 0, page); > atomic_inc(&page->_count); > } > - compound_unlock_irqrestore(page_head, flags); > + return; > } > EXPORT_SYMBOL(__get_page_tail); > > -- > 2.1.4