From patchwork Tue Apr 9 07:48:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13621926 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 C216BC67861 for ; Tue, 9 Apr 2024 07:48:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57B0E6B0089; Tue, 9 Apr 2024 03:48:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52B926B008C; Tue, 9 Apr 2024 03:48:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419596B0092; Tue, 9 Apr 2024 03:48:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 248FF6B0089 for ; Tue, 9 Apr 2024 03:48:30 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9D9B1A08DB for ; Tue, 9 Apr 2024 07:48:29 +0000 (UTC) X-FDA: 81989215938.21.0670FC2 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by imf20.hostedemail.com (Postfix) with ESMTP id 1CC791C0004 for ; Tue, 9 Apr 2024 07:48:25 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=tzpKAX4u; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.111 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712648907; a=rsa-sha256; cv=none; b=Mv75F3CBIPCqyW2tHF/o6M3v2vxJLwweO8d9ysnYDOxoX/0M2vk7vhdkakmEwaTcPs8uR8 WuFchDyMiSIOXVMUXhnFp8VMSdjnk5uknOXATnr6XebMYOpU6a25CKWtqJJlEbZFFPDUCa jtXNc9qIEqLQN1pKIPFsbRXJMw+yVgs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=tzpKAX4u; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.111 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=1712648907; 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=rVa0w4iPrfKIGVgN82R9JMd4RGG8BOD6XDG3/b9ksDA=; b=C73hY+z6VqdUn2UozBMkG+T+v6fzlTZoHMLmcA6GZ0ZbHGVOBernaiD3clxEIHvYG12T0i UUq8TqHWHBshHf11wWS24oF7SKykhUDqS8Qxa7Ar2ofCk+viP0TTOyupj9Md6jbFRkDVL1 YvaoCVZrZXLnPKOEMHv/XXPfRhWTvBY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712648903; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=rVa0w4iPrfKIGVgN82R9JMd4RGG8BOD6XDG3/b9ksDA=; b=tzpKAX4ufCm6QWwvUwWkwBanYrGIWIzi4Tr15SWZMXMdsKr980B27d33+cWgvtQ3Fi2eYCbwUxrFxvmmItAzjnJslo69BTR3pa50+jnrSCquZZJZA9BufvdtrwXlYNHuSxKBsufzNjGjTZ6fZoWEbxseg3HBiEKcBFKEV7hFEm4= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0W4DkG4Q_1712648900; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W4DkG4Q_1712648900) by smtp.aliyun-inc.com; Tue, 09 Apr 2024 15:48:21 +0800 From: Baolin Wang To: vbabka@suse.cz Cc: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, david@redhat.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mgorman@techsingularity.net, ying.huang@intel.com, ziy@nvidia.com Subject: [PATCH] mm: page_alloc: consolidate free page accounting fix 3 Date: Tue, 9 Apr 2024 15:48:04 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: <1cc1e3d1-4646-436c-92cb-f8584406bf88@suse.cz> References: <1cc1e3d1-4646-436c-92cb-f8584406bf88@suse.cz> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1CC791C0004 X-Stat-Signature: 4m98yoii6dwjc1wzhxkdjyobxgexdfrx X-HE-Tag: 1712648905-795550 X-HE-Meta: U2FsdGVkX19C2zsrKIqfLUaeHn/NADQkWGHR7VMgTGZ1hOhsHfrM2zc7wzR0Iaoiyh+ooRSbGVfsAqYfjJLvgziP+cW1KUlZBNzVR2b7WO85n166Er2o/3XuohMI/aUC6Vy3gy1EDfXcNFI4dJhph2D7vKXiR3SeW0dRDn0itxebINIyHpWKlySeR0ND5Fl1FAQ46P7AVujaTmOJrRWOnIgu94S5TtSIjmEfSYAccVrbE4kDc7henAEY7DJ85ug2PhvfRAcK4RZ5p4p1QATRBYmc1vPiZLu/U3y9npwloyQ0ndjsTAuMQOsXeqbuKT4zVYYyk+0fBafzr4Uhz3PvMlKED43yqnfABcXttH9CtkDcjsvDukCaN+zObJQH2YHo4badp+pP3C/5ER+6fd1ek0ybOof+sjshZpHi3XS5q/EbOWPWK39Y+8OEu1z2OQHXIQocMwJCesRPi3NuMLkYCo0cO9lzmEAoxQGnyuKAGYw0tzw6ytd2DFF1rflUsJ6NV9fR3kjl9d8l5S7712QWz2JFqEupoNtcSuxIoYvB5or34oKBO+ZbBhg0+dOxAx5swKtEuwoSFFa+pIHhulXf9GWi7jXK/N6cvBn/Et092m5SeoIqqlcH4WNi6bzaj7zFcy5MdZWlf+9Z3V+lKvKiUfp76HiJItdQoZ7FVcxhe9HUZ1d/IIyXpZZlj6X1bX2Ap3upKY9FNzumqQMNMP3uxshS7K4mIMXxJStyOJCtv/KiN6GnN4QuIh0mDB8VFkuQwUp8hQIN60t0/6B8WXCaaWQXx/ThxrNKZPyEsi/qXojLlj4wUa70x9K1xkMcGpYc9+UkPQ4nfw/Hj2TLr69FN9f+6Rk7QPjgHAYrQZ1s2TyA8gSQKNIhLyAo+XyuTABwAhTCerZaQXXNZIv/aozPpcIfXHx2cUsWzsCH/XdO8DffND8oJq4RHz9n6+3DeO9U/LvlqMi/3Ek= 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: If the released page is captured by compaction, now the free page accounting is not correspondingly decreased, which can make the watermark checks false positive and result in depleted reserves etc. And I can see the false positive watermark checks in thpcompact benchmark, that led to a slight regression: 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%) After the fix, the regression is gone. Signed-off-by: Baolin Wang Acked-by: Johannes Weiner Acked-by: Vlastimil Babka --- mm/page_alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8330c5c2de6b..2facf844ef84 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -805,8 +805,10 @@ static inline void __free_one_page(struct page *page, while (order < MAX_PAGE_ORDER) { int buddy_mt = migratetype; - if (compaction_capture(capc, page, order, migratetype)) + if (compaction_capture(capc, page, order, migratetype)) { + account_freepages(zone, -(1 << order), migratetype); return; + } buddy = find_buddy_page_pfn(page, pfn, order, &buddy_pfn); if (!buddy)