From patchwork Mon Jul 11 08:49:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12913160 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 CCB00C43334 for ; Mon, 11 Jul 2022 08:50:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 675936B00B0; Mon, 11 Jul 2022 04:50:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 623E56B00B1; Mon, 11 Jul 2022 04:50:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 477DA6B00B2; Mon, 11 Jul 2022 04:50:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 20C386B00B0 for ; Mon, 11 Jul 2022 04:50:17 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E67E72049F for ; Mon, 11 Jul 2022 08:50:16 +0000 (UTC) X-FDA: 79674197232.09.CAF191B Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP id 34322180060 for ; Mon, 11 Jul 2022 08:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657529417; x=1689065417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bnF/J3cdzcNa2nvmNTqNXDVKtTT8seBOtgR5lAaUQZU=; b=nsqddFg0Sfd/KT/7f5ENo3Ztq30ISYFcicYrRE24C1LP5nY4QiS2S0tN jop1s+A0AyC0xBkpUdqgwYZXEWu0zOTmtHgulZApelBOys8U+1acN7BCG eVbfUKsG9KZzVdheP0i/RGyHwrOi7RnIxGNI8y+kPiIbzFEE/OOTHqn7N eVzvWiQDExRirGn9qXo73kxs64z7GFZFa48Rj2/cFN6mv6su8fUgvQV/F WHIxqSTt9t8PVZGi9g2vnMzIHpbaHZBQpcQVMYVtI5PVsfesls6+NhuP2 wtPXa9SksEO6mSeeSSvyoKRsiMc2LcBFh3VY/4JSjCGXLfglMws7RJOnn A==; X-IronPort-AV: E=McAfee;i="6400,9594,10404"; a="346296604" X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="346296604" 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:16 -0700 X-IronPort-AV: E=Sophos;i="5.92,262,1650956400"; d="scan'208";a="652374174" 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:13 -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 6/7] migrate_pages(): fix failure counting for THP splitting Date: Mon, 11 Jul 2022 16:49:47 +0800 Message-Id: <20220711084948.274787-7-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=nsqddFg0; 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=1657529416; 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=+h5CYeMM4q8D1gWVaLUvW4VrJXXibkXozsNUEdEqf3A=; b=2kqMsnGcP/OT75W0ThMA9ygC0hmD+bFEjkqSHnpYyngEDE03jg43ZAXl7N5Itjcuhm7Nks oofv4tNsVmkAqCsfqzIMK311Q477dzgiT2wt4hPu9N44Aw88reQe1z+hi5l1Y+8tb160D7 0ggEOTIb1hVSXw4QNl1qd/z01vszVbk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657529416; a=rsa-sha256; cv=none; b=RXInHBPaf/Qh0Ww4gaxNBz4XHDXDYaD3B2spYEP5+lMgtLW1MbxyTBDy0jUBsWowdFKCTz eXL+gPHj6dkkLl5sprj6+9i2S2hb3cQ5b214LpPnE3T9y9MRakdf1Oh1HXWZyFiOlmMVpM nnw/MAALpNp7+QaQpmyNfJZvS8rB1I8= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=nsqddFg0; 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: dwrmyu3rnhokj7hmzxx16cngdgdjzbkw X-Rspamd-Queue-Id: 34322180060 X-HE-Tag: 1657529416-78460 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 is failed to be migrated, it may be split and retry. But after splitting, the head page will be left in "from" list, although THP migration failure has been counted already. If the head page is failed to be migrated too, the failure will be counted twice incorrectly. So this is fixed in this patch via moving the head page of THP after splitting to "thp_split_pages" 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 Reviewed-by: Oscar Salvador --- mm/migrate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 8cce73b7c046..557708ce13a1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1306,6 +1306,8 @@ static inline int try_split_thp(struct page *page, struct list_head *split_pages lock_page(page); rc = split_huge_page_to_list(page, split_pages); unlock_page(page); + if (!rc) + list_move_tail(&page->lru, split_pages); return rc; } @@ -1365,7 +1367,6 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, thp_retry = 0; list_for_each_entry_safe(page, page2, from, lru) { -retry: /* * THP statistics is based on the source huge page. * Capture required information that might get lost @@ -1412,7 +1413,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, nr_thp_failed++; if (!try_split_thp(page, &thp_split_pages)) { nr_thp_split++; - goto retry; + break; } /* Hugetlb migration is unsupported */ } else if (!no_subpage_counting) { @@ -1432,7 +1433,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, /* THP NUMA faulting doesn't split THP to retry. */ if (!nosplit && !try_split_thp(page, &thp_split_pages)) { nr_thp_split++; - goto retry; + break; } } else if (!no_subpage_counting) { nr_failed++;