From mboxrd@z Thu Jan 1 00:00:00 1970 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 38E75C77B7F for ; Tue, 9 May 2023 02:20:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37B97280006; Mon, 8 May 2023 22:20:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 32B3B280001; Mon, 8 May 2023 22:20:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F2D2280006; Mon, 8 May 2023 22:20:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0C98C280001 for ; Mon, 8 May 2023 22:20:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D047D1C6DDD for ; Tue, 9 May 2023 02:20:27 +0000 (UTC) X-FDA: 80769112494.01.4B1F353 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf12.hostedemail.com (Postfix) with ESMTP id 630A440009 for ; Tue, 9 May 2023 02:20:25 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=VhXG5HYY; spf=pass (imf12.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683598826; 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:references:dkim-signature; bh=+WdzJwxvekpZiCdmFrPivA731vNoIk8+hwlrPBM62LA=; b=rC2a8JnVvzycQBhyLJ0zoUvqUx0Mjizzn4zflrSdlRZA4kTM1w0r5gHZRhPz94Tcu6fu9Z 9LcBlV0O9CnemMPkF12jbYluWW6PjnXBUVvRi77VwD9jRsrgYpxwbj7nqIweddAYKLcBc/ elaoyAyUwR0CSarlr4p1VXxc42vM7wM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683598826; a=rsa-sha256; cv=none; b=2GLJAEXNWzoo435l6NkaqaoGtyX2oDvcSFwS5RftKXzQY+ewdZpdJVMypd4ctHk2pjdyjb w7t86QvZVh367Oe/lT7PTJszFHrpj7E6oS0wmrBNt4YXtdJcNAzxFcBJ//Xr0a4mc1k+tU DX+siirpBBEH/gEOS0NC+AOb2hYBU2g= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=VhXG5HYY; spf=pass (imf12.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683598825; x=1715134825; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Nmn1IPrYCW89+aGyZUryWtE01T7K4enWfajjIDcQAnk=; b=VhXG5HYYWdTaBzJdsFLrFRMyqj95IMjlxPFEtceJIwfao8h8ovLv4/D6 KrqQQ9JEPIzYMm7k7ozOOqdEanV7bWnat3JUksjUskKjEN5cKKMePg4wX s4v6X3+fqW/GWROmHJvHgqGyp8Gi0Nx7/gpfKrQM0F+rTm9XRwy5hRZAo ZPxfTq2sg89LSfXHvkWaah8+ux/CxjOMKEBX5UfK8MDWr+ZaE6CH5Y0fc 8LcBhw7smPTKey6srRTcOE+uekwtjzJWvZEXk6Q2gRZTXm4WpQHHy/Kqa sbNKFK1PF0CzYbnMFnQwEQp1wM/uALckg7Bdx5q/PTRJVD4ShM90HucSU w==; X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="330155068" X-IronPort-AV: E=Sophos;i="5.99,259,1677571200"; d="scan'208";a="330155068" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 19:20:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="731515706" X-IronPort-AV: E=Sophos;i="5.99,259,1677571200"; d="scan'208";a="731515706" Received: from jiudongl-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.30.15]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 19:20:19 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Xin Hao , Zi Yan , Yang Shi , Baolin Wang , Oscar Salvador , Alistair Popple Subject: [PATCH 1/2] migrate_pages_batch: simplify retrying and failure counting of large folios Date: Tue, 9 May 2023 10:20:13 +0800 Message-Id: <20230509022014.380493-1-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 630A440009 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: sajt97w1zi8zewzecgukarae4n6tpntf X-HE-Tag: 1683598825-930386 X-HE-Meta: U2FsdGVkX18XTftj29UdyoslTJ8SXyrCe8IoghGlchO/0Y7d2qTgEFG7Iwh8Un9gpHXAMg5myIKkMdugnf6zKJaEBon5XKDsFTjFEe8/eMKJ77SMWlMssxzrz6v4xvgC0MnPK8ck1s9NpKZJK2Azo6zbUH471oOdpV6PAWrPYIzkJ+ycA3Wa0bVETAfsKIksfrr5ER459e50BqEsSf+/fdqhj/vFp3wisp3p9F24If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1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: After recent changes to the retrying and failure counting in migrate_pages_batch(), it was found that it's unnecessary to count retrying and failure for normal, large, and THP folios separately. Because we don't use retrying and failure number of large folios directly. So, in this patch, we simplified retrying and failure counting of large folios via counting retrying and failure of normal and large folios together. This results in the reduced line number. This is just code cleanup, no functionality changes are expected. Signed-off-by: "Huang, Ying" Cc: Xin Hao Cc: Zi Yan Cc: Yang Shi Cc: Baolin Wang Cc: Oscar Salvador Cc: Alistair Popple --- mm/migrate.c | 103 +++++++++++++++++---------------------------------- 1 file changed, 35 insertions(+), 68 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 01cac26a3127..10709aed76d3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1614,11 +1614,9 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, int nr_pass) { int retry = 1; - int large_retry = 1; int thp_retry = 1; int nr_failed = 0; int nr_retry_pages = 0; - int nr_large_failed = 0; int pass = 0; bool is_large = false; bool is_thp = false; @@ -1631,9 +1629,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, VM_WARN_ON_ONCE(mode != MIGRATE_ASYNC && !list_empty(from) && !list_is_singular(from)); - for (pass = 0; pass < nr_pass && (retry || large_retry); pass++) { + for (pass = 0; pass < nr_pass && retry; pass++) { retry = 0; - large_retry = 0; thp_retry = 0; nr_retry_pages = 0; @@ -1660,7 +1657,7 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, * list is processed. */ if (!thp_migration_supported() && is_thp) { - nr_large_failed++; + nr_failed++; stats->nr_thp_failed++; if (!try_split_folio(folio, split_folios)) { stats->nr_thp_split++; @@ -1688,38 +1685,33 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, * When memory is low, don't bother to try to migrate * other folios, move unmapped folios, then exit. */ - if (is_large) { - nr_large_failed++; - stats->nr_thp_failed += is_thp; - /* Large folio NUMA faulting doesn't split to retry. */ - if (!nosplit) { - int ret = try_split_folio(folio, split_folios); - - if (!ret) { - stats->nr_thp_split += is_thp; - break; - } else if (reason == MR_LONGTERM_PIN && - ret == -EAGAIN) { - /* - * Try again to split large folio to - * mitigate the failure of longterm pinning. - */ - large_retry++; - thp_retry += is_thp; - nr_retry_pages += nr_pages; - /* Undo duplicated failure counting. */ - nr_large_failed--; - stats->nr_thp_failed -= is_thp; - break; - } + nr_failed++; + stats->nr_thp_failed += is_thp; + /* Large folio NUMA faulting doesn't split to retry. */ + if (is_large && !nosplit) { + int ret = try_split_folio(folio, split_folios); + + if (!ret) { + stats->nr_thp_split += is_thp; + break; + } else if (reason == MR_LONGTERM_PIN && + ret == -EAGAIN) { + /* + * Try again to split large folio to + * mitigate the failure of longterm pinning. + */ + retry++; + thp_retry += is_thp; + nr_retry_pages += nr_pages; + /* Undo duplicated failure counting. */ + nr_failed--; + stats->nr_thp_failed -= is_thp; + break; } - } else { - nr_failed++; } stats->nr_failed_pages += nr_pages + nr_retry_pages; /* nr_failed isn't updated for not used */ - nr_large_failed += large_retry; stats->nr_thp_failed += thp_retry; rc_saved = rc; if (list_empty(&unmap_folios)) @@ -1727,12 +1719,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, else goto move; case -EAGAIN: - if (is_large) { - large_retry++; - thp_retry += is_thp; - } else { - retry++; - } + retry++; + thp_retry += is_thp; nr_retry_pages += nr_pages; break; case MIGRATEPAGE_SUCCESS: @@ -1750,20 +1738,14 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, * removed from migration folio list and not * retried in the next outer loop. */ - if (is_large) { - nr_large_failed++; - stats->nr_thp_failed += is_thp; - } else { - nr_failed++; - } - + nr_failed++; + stats->nr_thp_failed += is_thp; stats->nr_failed_pages += nr_pages; break; } } } nr_failed += retry; - nr_large_failed += large_retry; stats->nr_thp_failed += thp_retry; stats->nr_failed_pages += nr_retry_pages; move: @@ -1771,17 +1753,15 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, try_to_unmap_flush(); retry = 1; - for (pass = 0; pass < nr_pass && (retry || large_retry); pass++) { + for (pass = 0; pass < nr_pass && retry; pass++) { retry = 0; - large_retry = 0; thp_retry = 0; nr_retry_pages = 0; dst = list_first_entry(&dst_folios, struct folio, lru); dst2 = list_next_entry(dst, lru); list_for_each_entry_safe(folio, folio2, &unmap_folios, lru) { - is_large = folio_test_large(folio); - is_thp = is_large && folio_test_pmd_mappable(folio); + is_thp = folio_test_large(folio) && folio_test_pmd_mappable(folio); nr_pages = folio_nr_pages(folio); cond_resched(); @@ -1797,12 +1777,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, */ switch(rc) { case -EAGAIN: - if (is_large) { - large_retry++; - thp_retry += is_thp; - } else { - retry++; - } + retry++; + thp_retry += is_thp; nr_retry_pages += nr_pages; break; case MIGRATEPAGE_SUCCESS: @@ -1810,13 +1786,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, stats->nr_thp_succeeded += is_thp; break; default: - if (is_large) { - nr_large_failed++; - stats->nr_thp_failed += is_thp; - } else { - nr_failed++; - } - + nr_failed++; + stats->nr_thp_failed += is_thp; stats->nr_failed_pages += nr_pages; break; } @@ -1825,14 +1796,10 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, } } nr_failed += retry; - nr_large_failed += large_retry; stats->nr_thp_failed += thp_retry; stats->nr_failed_pages += nr_retry_pages; - if (rc_saved) - rc = rc_saved; - else - rc = nr_failed + nr_large_failed; + rc = rc_saved ? : nr_failed; out: /* Cleanup remaining folios */ dst = list_first_entry(&dst_folios, struct folio, lru); -- 2.39.2