From patchwork Fri Jun 24 02:53:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12893408 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 D4B6ACCA47C for ; Fri, 24 Jun 2022 02:53:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 269F28E01C3; Thu, 23 Jun 2022 22:53:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21C738E01BF; Thu, 23 Jun 2022 22:53:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 093D88E01C3; Thu, 23 Jun 2022 22:53:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EA1A78E01BF for ; Thu, 23 Jun 2022 22:53:42 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B515635A2E for ; Fri, 24 Jun 2022 02:53:42 +0000 (UTC) X-FDA: 79611609084.14.34904A2 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf21.hostedemail.com (Postfix) with ESMTP id 2938F1C0009 for ; Fri, 24 Jun 2022 02:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656039222; x=1687575222; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B27oFNEx1h03uzrh6vOGjjj8DzLgj+BCfNPDGu9pWbA=; b=bLL3yb+vEPaotJ9tyQ5z4piWPlXb1L3WYFtLraifsB0Car3DdAwdaACz hdixpHfr4fILRIbn59NqIuUYKXakpXoxK2/vWUKKc+N0w2UW99i5pNSo8 XUjplRnaOkIyeap5k6Q2+mlGnZQAFdjZzB4wJiI1DGhtbMi8RgcD1Cy+L PI/eMfs07mGs5PmuNtVXJZDQomCsX0WNcCJ0Zr1wNzk1mQVE4wW2CKr8T bEjP/6ZlQkP1YckNORLABZ5CDlBEwgarnBIAZzmyMldDuYJRM1zKIP86e aRA6biJGJ4kAqbgrZUG+i+GogPoV034mPeqAcVlV6A4+YOvenCuDI98iO g==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="279672740" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="279672740" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:41 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="593018097" Received: from yxia2-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.214.143]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:53:39 -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 5/7] migrate_pages(): fix failure counting for THP on -ENOSYS Date: Fri, 24 Jun 2022 10:53:07 +0800 Message-Id: <20220624025309.1033400-6-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220624025309.1033400-1-ying.huang@intel.com> References: <20220624025309.1033400-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656039222; a=rsa-sha256; cv=none; b=M4Psdrx7PeaifIPr4rkSUmY1iDVh8/m6iYVm7bEyzF6FHGzO8bWJeZRShuI248aSLOtiGF fZUUTaP/iO25kGhbfBswaTwn6uK1ci5s2vYcV48do9NRsfjkERXk+7AXaPqYWdZJK3+KGM +F4KsV8+VVoOKdaHQXNaC0rpnLCnCAw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=bLL3yb+v; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656039222; 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=8ZPXrIGcPs3eaaGXvVHrE0URvqPwlHQYUCLf0kkewac=; b=f0xbW2tRcnbm6uCgP/zwpk+RLCmBldyxsbtZJne0NM+nfHujmJ6W55deHKt7w80t5xK48J DUJ3aB0/XQkCk8UDk4WoI1etmCFBifY768ps8A5QPRcSI7SwppcJPsnbMBD2tVUsoH36pJ WAGfhablosOj9Yj8pZEP33gz0sZeBo0= X-Stat-Signature: ooyfhqpprq78cg1b3xg8xjaf3f5i69fk X-Rspamd-Queue-Id: 2938F1C0009 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=bLL3yb+v; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf21.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656039221-347098 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") Cc: Baolin Wang Cc: Zi Yan Cc: Yang Shi Reviewed-by: Baolin Wang --- mm/migrate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 61dab3025a1d..9d1883d5927f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1191,10 +1191,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. */ @@ -1391,6 +1389,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 */ @@ -1420,6 +1419,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: /*