[v3,1/2] mm: migrate: Fix return value if all subpages of THPs are migrated successfully
Message ID | de386aa864be9158d2f3b344091419ea7c38b2f7.1666599848.git.baolin.wang@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp325753wru; Mon, 24 Oct 2022 01:48:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4F8y4GNDyUHNjjKmXqSdbm4tKyVzYg/9nlDs2mTKyM7plIVtmeE0DcTQexLxIpohobjphc X-Received: by 2002:a17:906:da85:b0:741:40a7:d08d with SMTP id xh5-20020a170906da8500b0074140a7d08dmr27980417ejb.263.1666601319084; Mon, 24 Oct 2022 01:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666601319; cv=none; d=google.com; s=arc-20160816; b=Nkwy3a7UBrzrZ7R0coJeNzvX4+49MHhwTbI/Z5fTDaGhzKivI+cUCXh/Lo9kIk2JMJ P7qPfPFNrkLx93DCAn78KJmD1+TXCMTCBWYRQSPm2KWwx/CfWkLG9MCCAT7iC0vMk9iF UQMZQWpRRX4dCGS5/1r1ymuxSckzE0p3WBKZeaC0ft1BdPRC27zqCJnAwjf/i51qVAMw RsvnUKPhpsT+SUKHONMOuljXADLada8PR09y+t85Vwl10xlWmfBKQWL6r/hkkFjvanUU xQvIvVqb/kTksYd4jEBVRyGganTWema7c/RSP7TOAMN5f/Qk7mk9zVRU9XVtlmz7ay7q 2DFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=KeC00WeoYZ/ViJPn20UQg+IEpDwRzEZ+DxYoDOeVhEM=; b=YxtBeisr0RoS+GZIQ1aItyh+NNQCQ8prHZqQWBMLmhZ2z1gSs32o6UpGOGeKpIOhDK YRN+1vCUZeAQpngd5uGIKrULZZ1oP+6phxq4e+KHCKaSgDm9TQnL/asrvHD8+Tz9OQ7y rHlDXwiXjVtXdsrgVidjQoRIBbSD08gOqtgf+3EG0RohyQ4YkWVsU3zjFH84kGiGr1J9 jC/QTr6+3wl5XMFHBmvEMMAwrlrDNIBCPrsnLu2MuTN4SMm4DCAUvNw7L5nSP2lfxbpm cbeGJ6YzWg13c5G9ste8ncR/G3wHSI+bju0WNmIJ3UNuhha1vVwkXAmVhdj+gzY8Hl2h lLew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn16-20020a17090794d000b00730870cb4b6si22546537ejc.621.2022.10.24.01.48.14; Mon, 24 Oct 2022 01:48:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbiJXIem (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Mon, 24 Oct 2022 04:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbiJXIei (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Oct 2022 04:34:38 -0400 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C5851A229 for <linux-kernel@vger.kernel.org>; Mon, 24 Oct 2022 01:34:34 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R571e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VSvcrBd_1666600470; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VSvcrBd_1666600470) by smtp.aliyun-inc.com; Mon, 24 Oct 2022 16:34:31 +0800 From: Baolin Wang <baolin.wang@linux.alibaba.com> To: akpm@linux-foundation.org Cc: david@redhat.com, ying.huang@intel.com, ziy@nvidia.com, shy828301@gmail.com, apopple@nvidia.com, baolin.wang@linux.alibaba.com, jingshan@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] mm: migrate: Fix return value if all subpages of THPs are migrated successfully Date: Mon, 24 Oct 2022 16:34:21 +0800 Message-Id: <de386aa864be9158d2f3b344091419ea7c38b2f7.1666599848.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747558144931584831?= X-GMAIL-MSGID: =?utf-8?q?1747558144931584831?= |
Series |
[v3,1/2] mm: migrate: Fix return value if all subpages of THPs are migrated successfully
|
|
Commit Message
Baolin Wang
Oct. 24, 2022, 8:34 a.m. UTC
During THP migration, if THPs are not migrated but they are split and all subpages are migrated successfully, migrate_pages() will still return the number of THP pages that were not migrated. This will confuse the callers of migrate_pages(). For example, the longterm pinning will failed though all pages are migrated successfully. Thus we should return 0 to indicate that all pages are migrated in this case Fixes: b5bade978e9b ("mm: migrate: fix the return value of migrate_pages()") Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> Reviewed-by: Alistair Popple <apopple@nvidia.com> Cc: <stable@vger.kernel.org> --- Changes from v2: - Add Fixes tag suggested by Yang Shi and Huang, Ying. - Drop 'nr_thp_split' validation suggested by Alistair. - Add reviewed tag from Alistair. - Update the commit message suggested by Andrew. Changes from v1: - Fix the return value of migrate_pages() instead of fixing the callers' validation. --- mm/migrate.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
On Mon, Oct 24, 2022 at 1:34 AM Baolin Wang <baolin.wang@linux.alibaba.com> wrote: > > During THP migration, if THPs are not migrated but they are split and all > subpages are migrated successfully, migrate_pages() will still return the > number of THP pages that were not migrated. This will confuse the callers > of migrate_pages(). For example, the longterm pinning will failed though > all pages are migrated successfully. > > Thus we should return 0 to indicate that all pages are migrated in this > case > > Fixes: b5bade978e9b ("mm: migrate: fix the return value of migrate_pages()") > Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> > Reviewed-by: Alistair Popple <apopple@nvidia.com> > Cc: <stable@vger.kernel.org> Reviewed-by: Yang Shi <shy828301@gmail.com> > --- > Changes from v2: > - Add Fixes tag suggested by Yang Shi and Huang, Ying. > - Drop 'nr_thp_split' validation suggested by Alistair. > - Add reviewed tag from Alistair. > - Update the commit message suggested by Andrew. > Changes from v1: > - Fix the return value of migrate_pages() instead of fixing the > callers' validation. > --- > mm/migrate.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/migrate.c b/mm/migrate.c > index 8e5eb6e..2eb16f8 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1582,6 +1582,13 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, > */ > list_splice(&ret_pages, from); > > + /* > + * Return 0 in case all subpages of fail-to-migrate THPs are > + * migrated successfully. > + */ > + if (list_empty(from)) > + rc = 0; > + > count_vm_events(PGMIGRATE_SUCCESS, nr_succeeded); > count_vm_events(PGMIGRATE_FAIL, nr_failed_pages); > count_vm_events(THP_MIGRATION_SUCCESS, nr_thp_succeeded); > -- > 1.8.3.1 >
diff --git a/mm/migrate.c b/mm/migrate.c index 8e5eb6e..2eb16f8 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1582,6 +1582,13 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, */ list_splice(&ret_pages, from); + /* + * Return 0 in case all subpages of fail-to-migrate THPs are + * migrated successfully. + */ + if (list_empty(from)) + rc = 0; + count_vm_events(PGMIGRATE_SUCCESS, nr_succeeded); count_vm_events(PGMIGRATE_FAIL, nr_failed_pages); count_vm_events(THP_MIGRATION_SUCCESS, nr_thp_succeeded);