From patchwork Thu Mar 16 11:06:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13177386 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 5868CC6FD19 for ; Thu, 16 Mar 2023 11:07:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F342900007; Thu, 16 Mar 2023 07:07:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A0DA900002; Thu, 16 Mar 2023 07:07:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56887900007; Thu, 16 Mar 2023 07:07:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4A15F900002 for ; Thu, 16 Mar 2023 07:07:03 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 214D21C6D41 for ; Thu, 16 Mar 2023 11:07:03 +0000 (UTC) X-FDA: 80574484326.11.9C47553 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by imf07.hostedemail.com (Postfix) with ESMTP id 1D6F740025 for ; Thu, 16 Mar 2023 11:06:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678964821; 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; bh=4iEwgEufw1E44AmNlaoOTCnL7OKSRMw6hxynyb6vNaE=; b=VkSMP+9CRZuIpqAFSeknXWwLEDkp5KwjfhhL9cLdx7hycasToWnomRtrP6TfpG35XV5/yz Xjh/gOmhX0Vi86uVymc/p2JUF4RAW5dK11AIOm73sHTGTvVvODoOsfYjYkBBPaqLTXFXKf 5eAHN1kkrngbsvtMI1XCPRTxaY7mfIY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678964821; a=rsa-sha256; cv=none; b=npPjnZyZ439OCEgdYxg9ObzxvwdIIbAPvNF1HmWrgfhGBD+CzwA9opbnebnUxBtbkJvFH7 Nn+M15EfnA5asyavLZ+eMd+YItdUlCmIvrCiie4MGfbW/fHBg4a6obAAYx9GfQdZ27aHTK a4JTYJX/rgle2IZ+A5inCkRL5MWVm+g= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0Ve-NM83_1678964813; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Ve-NM83_1678964813) by smtp.aliyun-inc.com; Thu, 16 Mar 2023 19:06:54 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, osalvador@suse.de, vbabka@suse.cz, william.lam@bytedance.com, mike.kravetz@oracle.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] mm: compaction: consider the number of scanning compound pages in isolate fail path Date: Thu, 16 Mar 2023 19:06:46 +0800 Message-Id: <73d6250a90707649cc010731aedc27f946d722ed.1678962352.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1D6F740025 X-Stat-Signature: aqqnn3wkonjxgdnq1gdn6ypwhw53355n X-HE-Tag: 1678964819-73558 X-HE-Meta: U2FsdGVkX1/xVr0LI0CRlFO5JfVegRbiLjeafJt9gKc6sqCG0TUZnGHd464ALUvVJqZqvZ/20M19r8C+1+JJi5lch2XACl7urtqooA7tN1GYd+H3GA0P0VbfxTs3iasSOLR7o7wHmTA7uptwb/QRTQ6SYrlH/rDGg4Pya0YaaG5NPq5u0gNP0HySw9YLW8mLNLslW7SiAJBubYgrhN1pUf0PpdBz0aZ0PE0v2GXeRL6tjgbT3mt7367hDXb4jZVY7CW4XXV56c7Wcb7Ttd9hpY8S4SXIAwGpV/4SK/Adhz3AsUsu8SRNZFU+xoKUUutvuy8Z10+8Z2HVPa2DSvc0KP34BnKamhL4WTypdgrohgyc7oJfoTEDxJW/qTzzs8yGH2r9HY5BAypmeM9hopDBjHEN+xcFcUyKOetH3W+mUANyXUsmcoUPi6mr+vDh7tUW7LMFJcp10J0FcQrZf3ne+cQYRazuXzGAT9tCd/qiLnRGneqCbeQtxKCorjP/HN0XJtrYuYNu8Jk0pGqNsGcyCYLgUWpJHv8x+RhGDnCkIVKE6AlKe+plrz/07MA/ra/XmVFbO5H94wT1LP1k/LpGB+VOKaP9fbumfuENd2DT7cOI/0vmutaILcabv2pAYVjLAYFuNW8H4Gl0aavrRPaiV9cnR39MkpkR7z4TJDJwgE09DK7CQg5LrsUHwnTpI92fkO/lvBIk6BGX10Bq6on3DoALnI6ODRkZRR8sM5gPRwAS3e6M+JtV8nVHw659DqtzsUbzDWyaSmX+NYmCG34Tujj4/7ZE2DeQ656eJj7cdxC1gq0uWqqxtokQqQkao8CzXEru1fLZX/4mRJ37OJD53xb6WauFmgVNoMDpHjANu3M1dBkwvn7areDb7XDXoazRNzeSaJ9NdVOyQzSZLsoSEr1yDoVzM6Atr+5BJbQBqEuhKSj697wHxQvPklB60BaXNyDl5+eVZfzIZK1knVh MOM4IkMD hfPRM6bVfET1vKOTjqSOIyfWzVQHV7xbsR//tHTVHNrYIbko8LemZs59PLdqJH80Y0MQRni3T05Kd62YqhhxfEG7AhfGkjllfX7lHzVCbW+lFUTA= 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: The commit b717d6b93b54 ("mm: compaction: include compound page count for scanning in pageblock isolation") had added compound page statistics for scanning in pageblock isolation, to make sure the number of scanned pages are always larger than the number of isolated pages when isolating mirgratable or free pageblock. However, when failed to isolate the pages when scanning the mirgratable or free pageblock, the isolation failure path did not consider the scanning statistics of the compound pages, which can show the incorrect number of scanned pages in tracepoints or the vmstats to make people confusing about the page scanning pressure in memory compaction. Thus we should take into account the number of scanning pages when failed to isolate the compound pages to make the statistics accurate. Signed-off-by: Baolin Wang Reviewed-by: Vlastimil Babka Acked-by: Mel Gorman --- Changes from v1: - Move the compound pages statistics after sanity order checking. --- mm/compaction.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 5a9501e0ae01..7e645cdfc2e9 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -586,6 +586,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, if (likely(order < MAX_ORDER)) { blockpfn += (1UL << order) - 1; cursor += (1UL << order) - 1; + nr_scanned += (1UL << order) - 1; } goto isolate_fail; } @@ -904,6 +905,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, if (ret == -EBUSY) ret = 0; low_pfn += compound_nr(page) - 1; + nr_scanned += compound_nr(page) - 1; goto isolate_fail; } @@ -938,8 +940,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, * a valid page order. Consider only values in the * valid order range to prevent low_pfn overflow. */ - if (freepage_order > 0 && freepage_order < MAX_ORDER) + if (freepage_order > 0 && freepage_order < MAX_ORDER) { low_pfn += (1UL << freepage_order) - 1; + nr_scanned += (1UL << freepage_order) - 1; + } continue; } @@ -954,8 +958,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, if (PageCompound(page) && !cc->alloc_contig) { const unsigned int order = compound_order(page); - if (likely(order < MAX_ORDER)) + if (likely(order < MAX_ORDER)) { low_pfn += (1UL << order) - 1; + nr_scanned += (1UL << order) - 1; + } goto isolate_fail; } @@ -1077,6 +1083,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, */ if (unlikely(PageCompound(page) && !cc->alloc_contig)) { low_pfn += compound_nr(page) - 1; + nr_scanned += compound_nr(page) - 1; SetPageLRU(page); goto isolate_fail_put; }