Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966349AbcKKDSj (ORCPT ); Thu, 10 Nov 2016 22:18:39 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56646 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965962AbcKKDSi (ORCPT ); Thu, 10 Nov 2016 22:18:38 -0500 Subject: Re: [PATCH v2 03/12] mm: thp: introduce separate TTU flag for thp freezing To: Naoya Horiguchi References: <1478561517-4317-1-git-send-email-n-horiguchi@ah.jp.nec.com> <1478561517-4317-4-git-send-email-n-horiguchi@ah.jp.nec.com> <5824307C.7070105@linux.vnet.ibm.com> <20161110090904.GA9173@hori1.linux.bs1.fc.nec.co.jp> Cc: "linux-mm@kvack.org" , "Kirill A. Shutemov" , Hugh Dickins , Andrew Morton , Dave Hansen , Andrea Arcangeli , Mel Gorman , Michal Hocko , Vlastimil Babka , Pavel Emelyanov , Zi Yan , Balbir Singh , "linux-kernel@vger.kernel.org" , Naoya Horiguchi From: Anshuman Khandual Date: Fri, 11 Nov 2016 08:48:19 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20161110090904.GA9173@hori1.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16111103-0004-0000-0000-0000036AD85B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16111103-0005-0000-0000-0000106DFF65 Message-Id: <5825387B.2060606@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-11_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611110057 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2142 Lines: 59 On 11/10/2016 02:39 PM, Naoya Horiguchi wrote: > On Thu, Nov 10, 2016 at 02:01:56PM +0530, Anshuman Khandual wrote: >> > On 11/08/2016 05:01 AM, Naoya Horiguchi wrote: >>> > > TTU_MIGRATION is used to convert pte into migration entry until thp split >>> > > completes. This behavior conflicts with thp migration added later patches, >> > >> > Hmm, could you please explain why it conflicts with the PMD based >> > migration without split ? Why TTU_MIGRATION cannot be used to >> > freeze/hold on the PMD while it's being migrated ? > try_to_unmap() is used both for thp split (via freeze_page()) and page > migration (via __unmap_and_move()). In freeze_page(), ttu_flag given for > head page is like below (assuming anonymous thp): > > (TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS | TTU_RMAP_LOCKED | \ > TTU_MIGRATION | TTU_SPLIT_HUGE_PMD) Right. > > and ttu_flag given for tail pages is: > > (TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS | TTU_RMAP_LOCKED | \ > TTU_MIGRATION) Right. > > __unmap_and_move() calls try_to_unmap() with ttu_flag: > > (TTU_MIGRATION | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS) > > Now I'm trying to insert a branch for thp migration at the top of > try_to_unmap_one() like below > > > static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, > unsigned long address, void *arg) > { > ... > if (flags & TTU_MIGRATION) { > if (!PageHuge(page) && PageTransCompound(page)) { > set_pmd_migration_entry(page, vma, address); > goto out; > } > } > > , so try_to_unmap() for tail pages called by thp split can go into thp > migration code path (which converts *pmd* into migration entry), while > the expectation is to freeze thp (which converts *pte* into migration entry.) Got it. > > I detected this failure as a "bad page state" error in a testcase where > split_huge_page() is called from queue_pages_pte_range(). > > Anyway, I'll add this explanation into the patch description in the next post. Sure, thanks for the explanation.