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 9F209C67861 for ; Tue, 9 Apr 2024 09:31:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17E096B0092; Tue, 9 Apr 2024 05:31:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12E996B009A; Tue, 9 Apr 2024 05:31:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01E086B00A8; Tue, 9 Apr 2024 05:31:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D8CAD6B0092 for ; Tue, 9 Apr 2024 05:31:18 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E39180322 for ; Tue, 9 Apr 2024 09:31:18 +0000 (UTC) X-FDA: 81989475036.25.9A2D183 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf02.hostedemail.com (Postfix) with ESMTP id 577778000F for ; Tue, 9 Apr 2024 09:31:13 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=FWNcQjA2; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf02.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 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=1712655076; 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:dkim-signature; bh=0LnjQmyzNK4ZE6rezMRyW0SnrJ9XYzbVmvYfi+uWYb0=; b=RevKohN+IOxKo6+7XJqyr4XITZqX2hQSptcFa7/ZKOQCkTNFp31XOOjRTWpqXQW2obxVfS r6I2PGmbDO5C/eXQX1BSSUAtgEkUkxlGYGu+JmHHPqQVe7nx+mN9fQzMqBxNPjj3s81U3X NuuqPY/GkzpVbOHGzLFSunlL7d5VNIc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=FWNcQjA2; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf02.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712655076; a=rsa-sha256; cv=none; b=d35M63cT5tgmCFJ6B1tSdnVvA3h3hgJgopE6pE4shPiOnW5+mIz2Ros+68rGlv5tcTjeKb G1Hb2zmPq+2ay1j3Cp5rN1F4GXVc9zmBR679gX8h6WPoGJdleD+VMQ/PKLZag836DinXU+ 9Xyk0/rk/vS4vs927Ma3iQzCddps+jY= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712655071; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=0LnjQmyzNK4ZE6rezMRyW0SnrJ9XYzbVmvYfi+uWYb0=; b=FWNcQjA2PyCZn8ETN1j6sdYkIK9DiHSHskuxsKY+vLcD/Gcdw2V2wpcChKskuMBIKQzQdKT1TGE1g5brikIS5wS4ts0goDHGex6WBJjqdSNmGo8AXPhtFvfPEYrl8rrtR66OB/LswaS5t/sP2LV6xPJU8n5+7ulHvj+/RjUJmcw= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0W4E3E6q_1712655068; Received: from 30.97.56.63(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W4E3E6q_1712655068) by smtp.aliyun-inc.com; Tue, 09 Apr 2024 17:31:09 +0800 Message-ID: <26cb722f-6e1c-4aaf-9edd-ed10a60e0018@linux.alibaba.com> Date: Tue, 9 Apr 2024 17:31:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 10/10] mm: page_alloc: consolidate free page accounting To: Johannes Weiner , Vlastimil Babka Cc: Andrew Morton , Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240320180429.678181-1-hannes@cmpxchg.org> <20240320180429.678181-11-hannes@cmpxchg.org> <7b3b7f2e-7109-4e72-b1cf-259cb56f3629@linux.alibaba.com> <20240408142340.GA1057805@cmpxchg.org> From: Baolin Wang In-Reply-To: <20240408142340.GA1057805@cmpxchg.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 577778000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ndhmzkgrckhsuqzktgtbbs71p36nkorp X-HE-Tag: 1712655073-487072 X-HE-Meta: U2FsdGVkX19jmyAf6QPtUOWdvVfMLIZaCj1Jt/PK6sY7kKOQWJTPVI3J9MppcOfQMyCGwDga5mApLMnF0pFHlJ0V+c39V+sZJMT95bvoi76uU9tITYSJwbSeyAMiajz29bEpeVBNA5E+BVDV7o8RdgqNhE3TT5wzUOgpdTvjaOq58QtHyyL6a2/IKO/HLEOtW1y59stA9SK1XahLCxrCnBsoJfbfpilrzXirai/hUh4bZRCFrKtrKl4d6Nvp6RSxx27xPmbeqnL0za2l0+5MSuIZ+rzUbLEaDz9ul/1wXnkHalt5XNs6rwEdX++CpZVPv5QVcG/QyQEHaKGSIxGd2fcwkBo80HZqkQ4y7QfaMKOITjAscgAcY+vVnffKI1SsMCZysg8DZMqTjThNArgAhqdKXtdMtzlcHZZ4FXtFMZXegh9OKOX1u5el4ewY5VQtnF0SldDlDdgGBrO/bT3War1+z5JIJn8aXB8094wjqEa/URSdJizPAKGOGH/1KF+PfNTnhRkb5PEHFH9tEUTlny5HffBhOKQwnaNR7+UNe2zSdcsGlG6w8oDe0Dg994ZDUwqmCbZ/3dFWwrpWnTUwErVbK5KXXfCjO7pHYhzkGGbBfM5WgoLmGfqLw8C8dxZyVVmEJTQd1NpuCMkJFRyR8k2Z8tcoCAR9FTqVefeDIYvDVMcoqbmjJ7spO4nN4VO3vb5VrJn/Z5TSBTQZE+XAH/F160Ec2gduCS7ZdOokxLkraZE1DmXfTbGA9Ova6PO5dS5KiO6TlK2dmDTrTLYsTmSxoWn4fopwO5kZfRyORATd6pFD3RCSubgpccX7ninsn9FOYkgucabhwvYH853HKFh2bCFZb3bABzfWrBfl+LNmSGXYdP2Eeo0OLFwlLF63iKm2xFeq+kCbeqDnPsUnifmWFuXp/ojY6SjyZ0MGxqv8LXVMCRGNcMd/4oELMgI96G9xyomqhW8= 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: List-Subscribe: List-Unsubscribe: On 2024/4/8 22:23, Johannes Weiner wrote: > On Mon, Apr 08, 2024 at 09:38:20AM +0200, Vlastimil Babka wrote: >> On 4/7/24 12:19 PM, Baolin Wang wrote: >>> On 2024/3/21 02:02, Johannes Weiner wrote: >>>> >>>> + account_freepages(page, zone, 1 << order, migratetype); >>>> + >>>> while (order < MAX_PAGE_ORDER) { >>>> - if (compaction_capture(capc, page, order, migratetype)) { >>>> - __mod_zone_freepage_state(zone, -(1 << order), >>>> - migratetype); >>>> + int buddy_mt = migratetype; >>>> + >>>> + if (compaction_capture(capc, page, order, migratetype)) >>>> return; >>>> - } >>> >>> IIUC, if the released page is captured by compaction, then the >>> statistics for free pages should be correspondingly decreased, >>> otherwise, there will be a slight regression for my thpcompact benchmark. >>> >>> thpcompact Percentage Faults Huge >>> k6.9-rc2-base base + patch10 + 2 fixes >>> Percentage huge-1 78.18 ( 0.00%) 71.92 ( -8.01%) >>> Percentage huge-3 86.70 ( 0.00%) 86.07 ( -0.73%) >>> Percentage huge-5 90.26 ( 0.00%) 78.02 ( -13.57%) >>> Percentage huge-7 92.34 ( 0.00%) 78.67 ( -14.81%) >>> Percentage huge-12 91.18 ( 0.00%) 81.04 ( -11.12%) >>> Percentage huge-18 89.00 ( 0.00%) 79.57 ( -10.60%) >>> Percentage huge-24 90.52 ( 0.00%) 80.07 ( -11.54%) >>> Percentage huge-30 94.44 ( 0.00%) 96.28 ( 1.95%) >>> Percentage huge-32 93.09 ( 0.00%) 99.39 ( 6.77%) >>> >>> I add below fix based on your fix 2, then the thpcompact Percentage >>> looks good. How do you think for the fix? >> >> Yeah another well spotted, thanks. "slight regression" is an understatement, >> this affects not just a "statistics" but very important counter >> NR_FREE_PAGES which IIUC would eventually become larger than reality, make >> the watermark checks false positive and result in depleted reserves etc etc. >> Actually wondering why we're not seeing -next failures already (or maybe I >> just haven't noticed). > > Good catch indeed. > > Trying to understand why I didn't notice this during testing, and I > think it's because I had order-10 pageblocks in my config. There is > this in compaction_capture(): > > if (order < pageblock_order && migratetype == MIGRATE_MOVABLE) > return false; > > Most compaction is for order-9 THPs on movable blocks, so I didn't get > much capturing in practice in order for that leak to be noticable. This makes me wonder why not use 'cc->migratetype' for migratetype comparison, so that low-order (like mTHP) compaction can directly get the released pages, which could avoid some compaction scans without mixing the migratetype? diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2facf844ef84..7a64020f8222 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -622,7 +622,7 @@ compaction_capture(struct capture_control *capc, struct page *page, * and vice-versa but no more than normal fallback logic which can * have trouble finding a high-order free page. */ - if (order < pageblock_order && migratetype == MIGRATE_MOVABLE) + if (order < pageblock_order && capc->cc->migratetype != migratetype) return false; capc->page = page;