From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756105AbbCCN36 (ORCPT ); Tue, 3 Mar 2015 08:29:58 -0500 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:54733 "EHLO e28smtp08.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751441AbbCCN35 (ORCPT ); Tue, 3 Mar 2015 08:29:57 -0500 From: "Aneesh Kumar K.V" To: Rik van Riel , "Kirill A. Shutemov" , Andrew Morton , Andrea Arcangeli , Hugh Dickins Cc: Dave Hansen , Mel Gorman , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , Johannes Weiner , Michal Hocko , Jerome Marchand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv3 03/24] mm: avoid PG_locked on tail pages In-Reply-To: <54DD08BC.2020008@redhat.com> References: <1423757918-197669-1-git-send-email-kirill.shutemov@linux.intel.com> <1423757918-197669-4-git-send-email-kirill.shutemov@linux.intel.com> <54DD054E.7000605@redhat.com> <54DD08BC.2020008@redhat.com> User-Agent: Notmuch/0.19+30~gd241a48 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Tue, 03 Mar 2015 18:51:11 +0530 Message-ID: <87egp69pyw.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: 15030313-0029-0000-0000-000004B1F53C Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rik van Riel writes: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 02/12/2015 02:55 PM, Rik van Riel wrote: >> On 02/12/2015 11:18 AM, Kirill A. Shutemov wrote: > >>> @@ -490,6 +493,7 @@ extern int >>> wait_on_page_bit_killable_timeout(struct page *page, >> >>> static inline int wait_on_page_locked_killable(struct page *page) >>> { + page = compound_head(page); if (PageLocked(page)) return >>> wait_on_page_bit_killable(page, PG_locked); return 0; @@ -510,6 >>> +514,7 @@ static inline void wake_up_page(struct page *page, int >>> bit) */ static inline void wait_on_page_locked(struct page *page) >>> { + page = compound_head(page); if (PageLocked(page)) >>> wait_on_page_bit(page, PG_locked); } >> >> These are all atomic operations. >> >> This may be a stupid question with the answer lurking somewhere in >> the other patches, but how do you ensure you operate on the right >> page lock during a THP collapse or split? > > Kirill answered that question on IRC. > > The VM takes a refcount on a page before attempting to take a page > lock, which prevents the THP code from doing anything with the > page. In other words, while we have a refcount on the page, we > will dereference the same page lock. Can we explain this more ? Don't we allow a thp split to happen even if we have page refcount ?. -aneesh