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 AB50EC6FD1F for ; Thu, 16 Mar 2023 09:53:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FA17900003; Thu, 16 Mar 2023 05:53:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 181C0900002; Thu, 16 Mar 2023 05:53:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 022DB900003; Thu, 16 Mar 2023 05:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E287F900002 for ; Thu, 16 Mar 2023 05:53:15 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B1B931A0714 for ; Thu, 16 Mar 2023 09:53:15 +0000 (UTC) X-FDA: 80574298350.16.9433379 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by imf19.hostedemail.com (Postfix) with ESMTP id BE5351A0012 for ; Thu, 16 Mar 2023 09:53:12 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678960394; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6U0o6BaBufxejL0Q2FRUSlLmzgmaI/7HBVcUrJid1UM=; b=1cY00wDQ+M3/r8P1HPw+0pfs7hluSrOZqiU2ZSsR+bpYhJj3CGRY2f18uFqqbCHVLN+Rjm oV07ms/CED9cFD4NZ1ipvhmAgaeIkbTZNLbyiic6Nyxx7EM3FJo9RarcCC8+lPaKmdt72T 4DitLnMRD4NHZeT2gpg8u7irn4Q4stA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678960394; a=rsa-sha256; cv=none; b=KhHmm21mGgCv27aujl3Bi+9jPxVqhED5Rb+kV34B7JX2Ge2DBY8IraStgjj+i2TCilEFjx 6UfZ1C6McfavLIy8AN4ALF8nppdLkveU8cm9Y14dVUAKaReG7JRBY1SL+yXbIEzUCZZGaS L9ofUt2mpbD4kWvCkZHmASCtkP+dGyg= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R681e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Ve-ANYQ_1678960387; Received: from 30.97.48.88(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Ve-ANYQ_1678960387) by smtp.aliyun-inc.com; Thu, 16 Mar 2023 17:53:08 +0800 Message-ID: <1435450b-f1fb-17f8-1c35-68f27bafcc23@linux.alibaba.com> Date: Thu, 16 Mar 2023 17:53:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 1/2] mm: compaction: consider the number of scanning compound pages in isolate fail path To: Vlastimil Babka , akpm@linux-foundation.org Cc: mgorman@techsingularity.net, osalvador@suse.de, william.lam@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1bc1c955b03603c4e14f56dfbbef9f637f18dbbd.1678703534.git.baolin.wang@linux.alibaba.com> <258932e0-a2a6-7f17-014c-05676bfad456@suse.cz> From: Baolin Wang In-Reply-To: <258932e0-a2a6-7f17-014c-05676bfad456@suse.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: cpepxpocrddjn63y1pykkrbftwre4uy4 X-Rspam-User: X-Rspamd-Queue-Id: BE5351A0012 X-Rspamd-Server: rspam06 X-HE-Tag: 1678960392-862646 X-HE-Meta: U2FsdGVkX1/D5HSbOdlfx67V4g/i7V63YUz15LxXKPJqUShp2iM5gIUvu9bkndMWOt/ZzoV5jW1nw0s5vYVa5rdJzk4wv3sOq1YUa4rAYVW+VJNcMGHqXXvlaqT0U/Hq8U0h5ml8m2zBV/Os80dkp+0E6t07onsLv+buKLzFKJljYzNsj7kkQR8yrcNrY3j80mLwWO42bAcf3WyMgWuhFzn7dIP+/F872BNBvL1ypBw5BCWXhS4mdsC7NzoA1tOPNDooMH5S45/vnq6Nqw+FSmniEhMJs63/jxl5A9we0p8tWfDDiHXW+q4X+qfyDHfCVApEcUjfb2ik1bA/hQo+zaSqhghYbXH0m/IUy4Q3PbDJxciQ2dH1XHEM4YN+scHAHIdb+kDx7IqC3tc0GK3UdYXVG8p4Pr0Edk7SQeDqdYwZhsMRVxbJuPBUac9A2MxtMUtTfSasG+Urtql0SJ3XUdV8Ef4ADLI7+K0ossIhOQRYab3hVnvG9EXkZEFXZo7esMo6HGVJJDHpGcTArOySVUz7XxvZFz2OJGlouYwvkwnO0fQbETPW+n6xB2pTWpTmWePc2sBAfbcZEz89VMEQal1zmyhlGowiooKuPiUqIsAxDw0Bs2rhWvY3TOI0bTPmqboVy7P0odxTNlrs+PVhHFQhvIT5j1b+nQ8dHsSafLwI4G7u6/clyrFkbs38nIP22XjWIXGoTU2sw7Ph9j7h8w8XKcCQvuGV5NcdMOlBNNAAwLCqZkNKPx3rD6CzTZk7+dEWeE6i7Q2ySvYnFJ+mB9dAwnW7xJAGtULDkShKymceJaE61hXV3QecPYWFdKtwcE4eY5Pg+GCdfrryDgcwMeeYfV8rtWy9bDkVwPzeBVDKkO7qzVLp/OFVCKRZrKhRRoNuJbX7aX0aXTfJpbLtdQg8RGvDBO8szTNdic2vcQNSpjqqBqljzKkkKMNcZCeGY1GzAavpaa7Eyi0ObtP Pe7uJR0S UnA4KHLXil/GmG8iSjg0k76EjjR2XMaISIMAPuR3icCeaX1iVQzz5t4l5w97HvW70VLlnxckyQLqBTlceVmHDZ/6JnL2kNtO4lrsyMGeRIF5HpaUyprPYRWcU63OzhYQSAGzj 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: On 3/15/2023 11:54 PM, Vlastimil Babka wrote: > On 3/13/23 11:37, Baolin Wang wrote: >> 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 >> --- >> mm/compaction.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/mm/compaction.c b/mm/compaction.c >> index 5a9501e0ae01..c9d9ad958e2a 100644 >> --- a/mm/compaction.c >> +++ b/mm/compaction.c >> @@ -587,6 +587,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, >> blockpfn += (1UL << order) - 1; >> cursor += (1UL << order) - 1; >> } >> + nr_scanned += (1UL << order) - 1; > > I'd rather put it in the block above that tests order < MAX_ORDER. Otherwise > as the comments say, the value can be bogus as it's racy. Right, thanks for pointing it out. Will do in next version. > >> goto isolate_fail; >> } >> >> @@ -873,9 +874,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, >> cond_resched(); >> } >> >> - nr_scanned++; >> - >> page = pfn_to_page(low_pfn); >> + nr_scanned += compound_nr(page); > > For the same reason, I'd rather leave the nr_scanned adjustment by order in > the specific code blocks where we know/think we have a compound or huge page > and have sanity checked the order/nr_pages, and not add an unchecked > compound_nr() here. OK. Sound reasonable to me. Thanks for your input. >> /* >> * Check if the pageblock has already been marked skipped. >> @@ -1077,6 +1077,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; >> } >> @@ -1097,7 +1098,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, >> isolate_success_no_list: >> cc->nr_migratepages += compound_nr(page); >> nr_isolated += compound_nr(page); >> - nr_scanned += compound_nr(page) - 1; >> >> /* >> * Avoid isolating too much unless this block is being