From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FEB2C433E2 for ; Wed, 8 Jul 2020 07:16:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1E3920760 for ; Wed, 8 Jul 2020 07:16:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1E3920760 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8BA778D0024; Wed, 8 Jul 2020 03:16:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86B4C8D000D; Wed, 8 Jul 2020 03:16:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7813E8D0024; Wed, 8 Jul 2020 03:16:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 5D2FF8D000D for ; Wed, 8 Jul 2020 03:16:48 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 19D9D1EE6 for ; Wed, 8 Jul 2020 07:16:48 +0000 (UTC) X-FDA: 77014051296.04.sock65_5a14cee26ebb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id B4FDB800696B for ; Wed, 8 Jul 2020 07:16:44 +0000 (UTC) X-HE-Tag: sock65_5a14cee26ebb X-Filterd-Recvd-Size: 16655 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Wed, 8 Jul 2020 07:16:43 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2A751FB; Wed, 8 Jul 2020 00:16:42 -0700 (PDT) Received: from [192.168.0.129] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E53553F718; Wed, 8 Jul 2020 00:16:38 -0700 (PDT) Subject: Re: [PATCH V3] mm/vmstat: Add events for THP migration without split To: John Hubbard , linux-mm@kvack.org Cc: Daniel Jordan , Hugh Dickins , Matthew Wilcox , Zi Yan , Naoya Horiguchi , Andrew Morton , linux-kernel@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org References: <1594080415-27924-1-git-send-email-anshuman.khandual@arm.com> <18a3af27-7cab-63d3-29b8-e253021622cc@nvidia.com> From: Anshuman Khandual Message-ID: Date: Wed, 8 Jul 2020 12:44:47 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <18a3af27-7cab-63d3-29b8-e253021622cc@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Rspamd-Queue-Id: B4FDB800696B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 07/08/2020 05:31 AM, John Hubbard wrote: > On 2020-07-06 17:06, Anshuman Khandual wrote: >> Add following new vmstat events which will help in validating THP migr= ation >> without split. Statistics reported through these new VM events will he= lp in >> performance debugging. >> >> 1. THP_MIGRATION_SUCCESS >> 2. THP_MIGRATION_FAILURE >> 3. THP_MIGRATION_SPLIT >> >> In addition, these new events also update normal page migration statis= tics >> appropriately via PGMIGRATE_SUCCESS and PGMIGRATE_FAILURE. While here,= this >> updates current trace event 'mm_migrate_pages' to accommodate now avai= lable >> THP statistics. >> >> Cc: Daniel Jordan >> Cc: Hugh Dickins >> Cc: Matthew Wilcox >> Cc: Zi Yan >> Cc: John Hubbard >> Cc: Naoya Horiguchi >> Cc: Andrew Morton >> Cc: linux-mm@kvack.org >> Cc: linux-kernel@vger.kernel.org >> Signed-off-by: Zi Yan >> Signed-off-by: Anshuman Khandual >=20 >=20 > This is missing the Documentation/ Cc's, did you run scripts/get_mainta= iner.pl? I'm > adding linux-doc and Jonathan Corbet, for now at least. And I'll refrai= n from > trimming the reply. I had missed the Documention/ Cc's, thanks for adding them here. Will update the Cc list next time around. >=20 >=20 >> --- >> Changes in V3: >> >> - Formatted new events documentation with 'fmt' tool per Matthew >> - Made events universally available i.e dropped ARCH_ENABLE_THP_MIGRAT= ION >> - Added THP_MIGRATION_SPLIT >> - Updated trace_mm_migrate_pages() with THP events >> - Made THP events update normal page migration events as well >> >> Changes in V2: (https://patchwork.kernel.org/patch/11586893/) >> >> - Dropped PMD reference both from code and commit message per Matthew >> - Added documentation and updated the commit message per Daniel >> >> Changes in V1: (https://patchwork.kernel.org/patch/11564497/) >> >> - Changed function name as thp_pmd_migration_success() per John >> - Folded in a fix (https://patchwork.kernel.org/patch/11563009/) from = Hugh >> >> Changes in RFC V2: (https://patchwork.kernel.org/patch/11554861/) >> >> - Decopupled and renamed VM events from their implementation per Zi an= d John >> - Added THP_PMD_MIGRATION_FAILURE VM event upon allocation failure and= split >> >> Changes in RFC V1: (https://patchwork.kernel.org/patch/11542055/) >> >> =C2=A0 Documentation/vm/page_migration.rst | 19 +++++++++++ >> =C2=A0 include/linux/vm_event_item.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= |=C2=A0 3 ++ >> =C2=A0 include/trace/events/migrate.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | = 17 ++++++++-- >> =C2=A0 mm/migrate.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 | 49 ++++++++++++++++++++++++++--- >> =C2=A0 mm/vmstat.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 |=C2=A0 3 ++ >> =C2=A0 5 files changed, 84 insertions(+), 7 deletions(-) >> >> diff --git a/Documentation/vm/page_migration.rst b/Documentation/vm/pa= ge_migration.rst >> index 1d6cd7db4e43..e65d49f3cf86 100644 >> --- a/Documentation/vm/page_migration.rst >> +++ b/Documentation/vm/page_migration.rst >> @@ -253,5 +253,24 @@ which are function pointers of struct address_spa= ce_operations. >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 PG_isolated is alias with PG_recl= aim flag so driver shouldn't use the flag >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for own purpose. >> =C2=A0 +Quantifying Migration >> +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> +Following events can be used to quantify page migration. >> + >> +1. PGMIGRATE_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Normal pa= ge migration success */ >=20 >=20 > This doesn't explain what's going on with the new combined counter > behavior. See the proposal below. >=20 >=20 >> +2. PGMIGRATE_FAIL=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= /* Normal page migration failure */ >> +3. THP_MIGRATION_SUCCESS=C2=A0=C2=A0 /* Transparent huge page migrati= on success */ >> +4. THP_MIGRATION_FAILURE=C2=A0=C2=A0 /* Transparent huge page migrati= on failure */ >=20 >=20 > Shouldn't that be THP_MIGRATION_FAIL, in order to match the existing na= ming > scheme here? Sure, will change it. >=20 >=20 >> +5. THP_MIGRATION_SPLIT=C2=A0=C2=A0=C2=A0=C2=A0 /* Transparent huge pa= ge got split, retried */ >> + >> +THP_MIGRATION_SUCCESS is when THP is migrated successfully without ge= tting >> +split into it's subpages. THP_MIGRATION_FAILURE is when THP could nei= ther >> +be migrated nor be split. THP_MIGRATION_SPLIT is when THP could not >> +just be migrated as is but instead get split into it's subpages and l= ater >> +retried as normal pages. THP events would also update normal page mig= ration >> +statistics PGMIGRATE_SUCCESS and PGMIGRATE_FAILURE. These events will= help >> +in quantifying and analyzing various THP migration events including b= oth >> +success and failure cases. >> + >=20 >=20 > I would like to propose the following instead of the above. It's rewrit= ten > so as to add explanations for the new behavior, remove the redundancy (= the last > sentence in particular is a justification, and belongs in a commit log = if anywhere, > not in the doc itself), fix a few typos, use the full 80 columns, and c= larify a > bit as well. It uses the new THP_MIGRATION_FAIL name: >=20 >=20 > Monitoring Migration > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > The following events (counters) can be used to monitor page migration. >=20 > 1. PGMIGRATE_SUCCESS: Normal page migration success. Each count means t= hat a > =C2=A0=C2=A0 page was migrated. If the page was a non-THP page, then th= is counter is > =C2=A0=C2=A0 increased by one. If the page was a THP, then this counter= is increased by > =C2=A0=C2=A0 the number of THP subpages. For example, migration of a si= ngle 2MB THP that > =C2=A0=C2=A0 has 4KB-size base pages (subpages) will cause this counter= to increase by > =C2=A0=C2=A0 512. >=20 > 2. PGMIGRATE_FAIL: Normal page migration failure. Same counting rules a= s for > =C2=A0=C2=A0 _SUCCESS, above: this will be increased by the number of s= ubpages, if it was > =C2=A0=C2=A0 a THP. >=20 > 3. THP_MIGRATION_SUCCESS: A THP was migrated without being split. >=20 > 4. THP_MIGRATION_FAIL: A THP could not be migrated at all, even after b= eing > =C2=A0=C2=A0 split. >=20 > 5. THP_MIGRATION_SPLIT: A THP was migrated, but not as such: first, the= THP had > =C2=A0=C2=A0 to be split. After splitting, a migration retry was used f= or the sub-pages, > =C2=A0=C2=A0 and that retry succeeded. The last part might not be true. All that THP_MIGRATION_SPLIT tracks is w= hether the THP was split or not. Whether it's subpages got successfully migrated= later or not, would be hidden in overall PGMIGRATE_SUCCESS and PGMIGRATE_FAIL v= alues. >=20 > THP_MIGRATION_* events also update the appropriate PGMIGRATE_SUCCESS or > PGMIGRATE_FAILURE events. For example, a THP migration failure will cau= se both > THP_MIGRATION_FAIL and PGMIGRATE_FAIL to increase. Above explanation (probably with some changes) looks better, will update.= =20 >=20 >=20 >> =C2=A0 Christoph Lameter, May 8, 2006. >> =C2=A0 Minchan Kim, Mar 28, 2016. >> diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_it= em.h >> index 24fc7c3ae7d6..5e7ffa025589 100644 >> --- a/include/linux/vm_event_item.h >> +++ b/include/linux/vm_event_item.h >> @@ -95,6 +95,9 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOU= T, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 THP_ZERO_PAGE_A= LLOC_FAILED, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 THP_SWPOUT, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 THP_SWPOUT_FALL= BACK, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 THP_MIGRATION_SUCCESS, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 THP_MIGRATION_FAILURE, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 THP_MIGRATION_SPLIT, >> =C2=A0 #endif >> =C2=A0 #ifdef CONFIG_MEMORY_BALLOON >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BALLOON_INFLATE= , >> diff --git a/include/trace/events/migrate.h b/include/trace/events/mig= rate.h >> index 705b33d1e395..4d434398d64d 100644 >> --- a/include/trace/events/migrate.h >> +++ b/include/trace/events/migrate.h >> @@ -46,13 +46,18 @@ MIGRATE_REASON >> =C2=A0 TRACE_EVENT(mm_migrate_pages, >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 TP_PROTO(unsigned long succeeded= , unsigned long failed, >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enum migrate_mode mo= de, int reason), >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long thp_su= cceeded, unsigned long thp_failed, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long thp_sp= lit, enum migrate_mode mode, int reason), >> =C2=A0 -=C2=A0=C2=A0=C2=A0 TP_ARGS(succeeded, failed, mode, reason), >> +=C2=A0=C2=A0=C2=A0 TP_ARGS(succeeded, failed, thp_succeeded, thp_fail= ed, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 thp_split, mode, reason), >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 TP_STRUCT__entry( >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __field(=C2=A0=C2= =A0=C2=A0 unsigned long,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 succee= ded) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __field(=C2=A0=C2= =A0=C2=A0 unsigned long,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 failed= ) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __field(=C2=A0=C2=A0=C2=A0= unsigned long,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 thp_succeeded) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __field(=C2=A0=C2=A0=C2=A0= unsigned long,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 thp_failed) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __field(=C2=A0=C2=A0=C2=A0= unsigned long,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 thp_split) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __field(=C2=A0=C2= =A0=C2=A0 enum migrate_mode,=C2=A0=C2=A0=C2=A0 mode) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __field(=C2=A0=C2= =A0=C2=A0 int,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 reason) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ), >> @@ -60,13 +65,19 @@ TRACE_EVENT(mm_migrate_pages, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 TP_fast_assign( >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->succee= ded=C2=A0=C2=A0=C2=A0 =3D succeeded; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->failed= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D failed; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->thp_succeeded=C2=A0= =C2=A0=C2=A0 =3D thp_succeeded; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->thp_failed=C2=A0=C2= =A0=C2=A0 =3D thp_failed; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->thp_split=C2=A0=C2= =A0=C2=A0 =3D thp_split; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->mode=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D mode; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->reason= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D reason; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ), >> =C2=A0 -=C2=A0=C2=A0=C2=A0 TP_printk("nr_succeeded=3D%lu nr_failed=3D%= lu mode=3D%s reason=3D%s", >> +=C2=A0=C2=A0=C2=A0 TP_printk("nr_succeeded=3D%lu nr_failed=3D%lu nr_t= hp_succeeded=3D%lu nr_thp_failed=3D%lu nr_thp_split=3D%lu mode=3D%s reaso= n=3D%s", >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->succee= ded, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->failed= , >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->thp_succeeded, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->thp_failed, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __entry->thp_split, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __print_symboli= c(__entry->mode, MIGRATE_MODE), >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __print_symboli= c(__entry->reason, MIGRATE_REASON)) >> =C2=A0 ); >> diff --git a/mm/migrate.c b/mm/migrate.c >> index f37729673558..baf3cc477d11 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -1429,22 +1429,35 @@ int migrate_pages(struct list_head *from, new_= page_t get_new_page, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enum migrate_mo= de mode, int reason) >> =C2=A0 { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int retry =3D 1; >> +=C2=A0=C2=A0=C2=A0 int thp_retry =3D 1; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int nr_failed =3D 0; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int nr_succeeded =3D 0; >> +=C2=A0=C2=A0=C2=A0 int nr_thp_succeeded =3D 0; >> +=C2=A0=C2=A0=C2=A0 int nr_thp_failed =3D 0; >> +=C2=A0=C2=A0=C2=A0 int nr_thp_split =3D 0; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int pass =3D 0; >> +=C2=A0=C2=A0=C2=A0 bool is_thp =3D false; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct page *page; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct page *page2; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int swapwrite =3D current->flags & PF_S= WAPWRITE; >> -=C2=A0=C2=A0=C2=A0 int rc; >> +=C2=A0=C2=A0=C2=A0 int rc, thp_nr_pages; >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!swapwrite) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 current->flags = |=3D PF_SWAPWRITE; >> =C2=A0 -=C2=A0=C2=A0=C2=A0 for(pass =3D 0; pass < 10 && retry; pass++)= { >> +=C2=A0=C2=A0=C2=A0 for (pass =3D 0; pass < 10 && (retry || thp_retry)= ; pass++) { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 retry =3D 0; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 thp_retry =3D 0; >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 list_for= _each_entry_safe(page, page2, from, lru) { >> =C2=A0 retry: >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 * THP statistics is based on the source huge page. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 * Capture required information that might get lost >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 * during migration. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 */ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 is= _thp =3D PageTransHuge(page); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 th= p_nr_pages =3D hpage_nr_pages(page); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 cond_resched(); >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 if (PageHuge(page)) >> @@ -1475,15 +1488,30 @@ int migrate_pages(struct list_head *from, new_= page_t get_new_page, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unlock_page(page); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!rc) { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 list_safe_reset_next(page, page2, lru); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nr_= thp_split++; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A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=A0 if (is_thp) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nr_thp_succeeded++; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nr_succeeded +=3D thp_nr_pa= ges; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nr_succeeded++; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 default: >> @@ -1493,19 +1521,32 @@ int migrate_pages(struct list_head *from, new_= page_t get_new_page, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * removed from migration page list a= nd not >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> -=C2=A0=C2=A0=C2=A0 nr_failed +=3D retry; >> +=C2=A0=C2=A0=C2=A0 nr_failed +=3D retry + thp_retry; >> +=C2=A0=C2=A0=C2=A0 nr_thp_failed +=3D thp_retry; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D nr_failed; >> =C2=A0 out: >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nr_succeeded) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 count_vm_events= (PGMIGRATE_SUCCESS, nr_succeeded); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (nr_failed) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 count_vm_events= (PGMIGRATE_FAIL, nr_failed); >> -=C2=A0=C2=A0=C2=A0 trace_mm_migrate_pages(nr_succeeded, nr_failed, mo= de, reason); >> +=C2=A0=C2=A0=C2=A0 if (nr_thp_succeeded) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 count_vm_events(THP_MIGRAT= ION_SUCCESS, nr_thp_succeeded); >> +=C2=A0=C2=A0=C2=A0 if (nr_thp_failed) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 count_vm_events(THP_MIGRAT= ION_FAILURE, nr_thp_failed); >> +=C2=A0=C2=A0=C2=A0 if (nr_thp_split) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 count_vm_events(THP_MIGRAT= ION_SPLIT, nr_thp_split); >=20 > As mentioned in the other thread, those "ifs" should be removed. I thin= k you > can also get away with removing the two pre-existing "ifs" in the same > patch, too, just to keep the whole set consistent and more readable. Makes sense, will do.