From patchwork Fri Oct 21 10:16:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 6620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp610801wrr; Fri, 21 Oct 2022 03:18:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hEgqqv/1itfOq8ZWs79JCnkn3wGpm9vuy2AIOpWbenra2UWWnTiqU6mQQhXrFjxhEfwan X-Received: by 2002:a17:907:6d9b:b0:78d:f24b:e358 with SMTP id sb27-20020a1709076d9b00b0078df24be358mr14703228ejc.714.1666347496627; Fri, 21 Oct 2022 03:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666347496; cv=none; d=google.com; s=arc-20160816; b=mbbxLSVp/9H2AmQzKSIjVO+PuxsR6TPJFYkZRPsDnOVBZ+eAtelbJ1Ukb3x6nxUjtE 3SzASFsu81m3R8CcCZrq2FQrKwHHD30iYW3Eokf3YUYfODmoscCKxIZLm9lCLzMErrsu iZ1Ww32+2WwjsW3NfgI/xWyy5mDi/9Xn3cdMSBbuZ0icfvBoYGtKI8/VtnasbR+hH4kD GPNw6jTtvgp1CWuk9wPRktt3AIIvTQBwOa0UqByjE1Lh9ltgOzcO6LV11af+GSdlyRH1 kFc4qnT/fnnfh1VFAcubz1zQYf0KTL8uptXTW1m/EcaORMZ7xcgps+EsWbHIGQVF/Xio M12g== 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=VgX9H1qAS+UbCF4uoAVvy1TMCj1OGBBNsSmsDI0cBG4=; b=Xsv8xIbmPTvlMddQiLPdFRnhUisatDdYpAs3PExVLmo1z8a2bttkEJloIeFYapDH9F uaF+PXdMagJYnikOoKLevltH5qHXhQelAt6rZl6SLwQAStyMooh3P5jx0CFZMeODWXr2 h4QvpClBCrH3VVDZUal72vZEXeM3sfiWisNhPqCJq3bmq/lcumtP0bEpE8QMmQ+iNSVg Fjhlw/oCP4ZIbVEBnFecRIQ6U+NLS9n3wLNQL5u243PfnkpuLpSO2PjxVk6tZ+rAxZ+Y 82Ry4n+uw9AzOtccfor1PjO3z/yloemUT9yGcwrLuwGuYp13Xo4Xml5tm9Wm18b+fsjy cVOw== 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 du6-20020a17090772c600b0078c0c866a18si20818898ejc.19.2022.10.21.03.17.51; Fri, 21 Oct 2022 03:18:16 -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 S230446AbiJUKQl (ORCPT + 99 others); Fri, 21 Oct 2022 06:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbiJUKQi (ORCPT ); Fri, 21 Oct 2022 06:16:38 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30B401AD680 for ; Fri, 21 Oct 2022 03:16:36 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VSjF-ZZ_1666347392; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VSjF-ZZ_1666347392) by smtp.aliyun-inc.com; Fri, 21 Oct 2022 18:16:33 +0800 From: Baolin Wang 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 v2 1/2] mm: migrate: Fix return value if all subpages of THPs are migrated successfully Date: Fri, 21 Oct 2022 18:16:23 +0800 Message-Id: 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,RCVD_IN_MSPIKE_H2, 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747291992492526484?= X-GMAIL-MSGID: =?utf-8?q?1747291992492526484?= When THP migration, if THPs are split and all subpages are migrated successfully , the migrate_pages() will still return the number of THP that were not migrated. That will confuse the callers of migrate_pages(), for example, which will make the longterm pinning failed though all pages are migrated successfully. Thus we should return 0 to indicate all pages are migrated in this case. Signed-off-by: Baolin Wang Reviewed-by: Alistair Popple --- 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..1da0dbc 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 (nr_thp_split && 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);