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: 13014571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F1B2C4332F for ; Fri, 21 Oct 2022 10:16:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41FDA8E0002; Fri, 21 Oct 2022 06:16:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CFEA8E0001; Fri, 21 Oct 2022 06:16:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BF1F8E0002; Fri, 21 Oct 2022 06:16:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1F65E8E0001 for ; Fri, 21 Oct 2022 06:16:38 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DCA70AA9ED for ; Fri, 21 Oct 2022 10:16:37 +0000 (UTC) X-FDA: 80044552434.04.7723955 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf24.hostedemail.com (Postfix) with ESMTP id 9E55B18003D for ; Fri, 21 Oct 2022 10:16:36 +0000 (UTC) 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666347397; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=VgX9H1qAS+UbCF4uoAVvy1TMCj1OGBBNsSmsDI0cBG4=; b=CV4sQjuagNadqHr7ExQf7NN4xlqnQaEllWTwuduQzfonvaWdjrGnW8KYe0dWx274ZbUKTz fkbvMWuEJ/rvxTdxawYAmBaUj9gwBpbZEOyczEPUI2rWlakzFYTmZPrYiwstYETaxvDnhE uoGKF/aVhOqfYkSXO42cvd5yGUDIhCM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf24.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666347397; a=rsa-sha256; cv=none; b=orI9eZMbmZ43mnFxNObrRGNmtaVgprkyRlbR6Zf0BVUPNWg3WUTqWMuASm1k7Z2Ab+lqVz kNI6IG29r1NVHOOamQp/4j/03ZkOFcqWEuAUB54T2tvUygyt0+TafXSxiwftOMWBOHjJFR oFi5wRkDJWMP1+UjT/M+TjVclkyACKM= Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf24.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9E55B18003D X-Stat-Signature: 6sn1r5ndd8ucq58zfj9k41hxyomxyrez X-Rspam-User: X-HE-Tag: 1666347396-348206 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: 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);