Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3119511imw; Mon, 11 Jul 2022 02:09:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tO5lPCeQlISPqbZ3FM3eW09Ih9xWmkKNaKw5yASs/hmXZKDpUcFpWAIT3f01j0lHFd/I1s X-Received: by 2002:a17:907:1c8f:b0:6e8:f898:63bb with SMTP id nb15-20020a1709071c8f00b006e8f89863bbmr17924867ejc.721.1657530556102; Mon, 11 Jul 2022 02:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657530556; cv=none; d=google.com; s=arc-20160816; b=A75ePo3JwTD3oOVL5qFQlrMsSFMRHKphbKMnI1jFWpZKGMuIbE45WTBDWrkXgtKPYy KCdc6O0X1F6gqCt/ERPR0zcN339/hnZIz5rqCZUbRFKDdIa0NuJ6+QYpL64Eb7UMRoRo jGgHL+sVzCsuwsejZTizT9rSDuVgiUr443eq0EzzRqtqR9oybUphDqBPe21inHR+FrQ4 PKcXiaSyhI2MK+NDOinCVhPAYWuVrn7W0sMedWf/YwGOHu+gZllrZBeK7yHwL6tXV/oD Ez197fTSg3T71sDstq2K8NrfDS6yx7sePM6SX4wjen5snwkGFax/mLf+b+dJm0TCqmoq Y9+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uDNhiNVaova0EQaX6/hQMRj+3qJNe2j96GTWAnJLGnI=; b=hIeP5prjJdaRUrqWXZTCaoCVCDbfzrRYKsvKTysVSlrmWmim/zQXEKwoLWUrtQt9vD fuGNX6VuFABXIU1rOp1dfnfpHuMLIQIhROw7k7J8urN6Xuwhw/cNt5M3re/HJY71W7/n 3hj8Yx3KDxoKWrbpTVwHaK8GGGwIdJ08EA63GBmNksLj38omiCtC1h7Mr88G/juMs/TP vkyJKdOIzCBcLaRA0c9d2+EIUGqv9R+/8kSwYLfYaUtx9K8aZTwk9vIrH+yPe4PgxPTc XRbgRg/W4KofRmBef1yZCcVrI1AYr6eYoi+EpnRAzmlWZovRM27RkVmyXgh1sKYU67Kt JedQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ux06BiEH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a056402164e00b0043a991c182fsi8749987edx.129.2022.07.11.02.08.51; Mon, 11 Jul 2022 02:09: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; dkim=pass header.i=@intel.com header.s=Intel header.b=Ux06BiEH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbiGKIus (ORCPT + 99 others); Mon, 11 Jul 2022 04:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230307AbiGKIuZ (ORCPT ); Mon, 11 Jul 2022 04:50:25 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 204E31EEE1 for ; Mon, 11 Jul 2022 01:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529414; x=1689065414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tbVtvIK8XMk4xb1SU8xCdADdmx3jSPLB5EdXqTq3PBc=; b=Ux06BiEHYrjtywykn3AJ+imdmz96I/Fzz+OFXLy2lBUrgxb9ZJdYJNG5 ycxkXrQZzU3psGcKJb4vZ1qCUeQrHTgH5jdvloIgVRxVSJye2cYm3QuIl Imc0zhGPnr9W7iCp3qio2BbYAd+C8dCIK/s8wX/Uv6dGCWBWq6TaWiQzj oNKHfMFlPCvo6NJkF9E67eH9ublDSvLz+RrM7VFkRL3awfwJL3brxH+45 wy/kAWMogLdZKMb3+jSZCkphjf7IpLB79cCm/+yvp4kKpflQA1jtwUglA hOBOSG69/cRtfQHAKOIycth1uYp642LZ8aBdBfO9tgEvXQsKFWOwwdgtU g==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="284637852" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="284637852" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:13 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374162" Received: from yhuang6-mobl1.sh.intel.com ([10.238.5.168]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:11 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Baolin Wang , Zi Yan , Yang Shi Subject: [PATCH -V2 5/7] migrate_pages(): fix failure counting for THP on -ENOSYS Date: Mon, 11 Jul 2022 16:49:46 +0800 Message-Id: <20220711084948.274787-6-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220711084948.274787-1-ying.huang@intel.com> References: <20220711084948.274787-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 If THP or hugetlbfs page migration isn't supported, unmap_and_move() or unmap_and_move_huge_page() will return -ENOSYS. For THP, splitting will be tried, but if splitting doesn't succeed, the THP will be left in "from" list wrongly. If some other pages are retried, the THP migration failure will counted again. This is fixed via moving the failure THP from "from" to "ret_pages". Another issue of the original code is that the unsupported failure processing isn't consistent between THP and hugetlbfs page. Make them consistent in this patch to make the code easier to be understood too. Signed-off-by: "Huang, Ying" Fixes: 5984fabb6e82 ("mm: move_pages: report the number of non-attempted pages") Reviewed-by: Baolin Wang Cc: Zi Yan Cc: Yang Shi --- mm/migrate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 4bceba143db0..8cce73b7c046 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1192,10 +1192,8 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, * tables or check whether the hugepage is pmd-based or not before * kicking migration. */ - if (!hugepage_migration_supported(page_hstate(hpage))) { - list_move_tail(&hpage->lru, ret); + if (!hugepage_migration_supported(page_hstate(hpage))) return -ENOSYS; - } if (page_count(hpage) == 1) { /* page was freed from under us. So we are done. */ @@ -1392,6 +1390,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, * page will be put back * -EAGAIN: stay on the from list * -ENOMEM: stay on the from list + * -ENOSYS: stay on the from list * Other errno: put on ret_pages list then splice to * from list */ @@ -1421,6 +1420,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, } nr_failed_pages += nr_subpages; + list_move_tail(&page->lru, &ret_pages); break; case -ENOMEM: /* -- 2.30.2