From patchwork Mon Jul 11 08:49:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913159 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 A5706C43334 for ; Mon, 11 Jul 2022 08:50:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 319D36B00AD; Mon, 11 Jul 2022 04:50:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C7FD6B00AE; Mon, 11 Jul 2022 04:50:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 168906B00AF; Mon, 11 Jul 2022 04:50:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F0BD56B00AD for ; Mon, 11 Jul 2022 04:50:14 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BF21233513 for ; Mon, 11 Jul 2022 08:50:14 +0000 (UTC) X-FDA: 79674197148.21.E077020 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id 1727C180052 for ; Mon, 11 Jul 2022 08:50:13 +0000 (UTC) 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="346296593" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296593" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 01:50:14 -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 ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ux06BiEH; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657529414; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uDNhiNVaova0EQaX6/hQMRj+3qJNe2j96GTWAnJLGnI=; b=IBsh5Ll84DeOg9RPffLi1s/qPOnSaKIB2qzctGBZGO0YbxvwwbFn1jaoiLCA9SyfwAl+bQ GbWccBBTOQw3KXNE8TGFFqyp9Doq1GIw/3BSLqH5Pr6uolBL2fSC/ml7erbUA+n62fdpiL BTbXzQ1t8EQnJwwqcrEXqCn+eOnQtFw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529414; a=rsa-sha256; cv=none; b=RVzQvIpe4pykkCCVg6g/NlsrR/Y5ITIVQJMIpb7byaMjCjl7ANt0U+e8IglvPxsibuVw+v NuYCMCcH6is1I69H9tYitnXO7w3AiEGdd8+KjGeHQ5g2S9wMXDpQziZG4Qet5XNTNeIpiU FuCfLvweCwxxiXkO8JpPf/VJQG2gBBo= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ux06BiEH; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: qdiec8uz9zk37n9dw1yoopoyw3jtyto8 X-Rspamd-Queue-Id: 1727C180052 X-HE-Tag: 1657529413-238157 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: 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: /*