From patchwork Mon Jan 6 19:33:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13927786 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 28396E77188 for ; Mon, 6 Jan 2025 19:34:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CCEC6B00A2; Mon, 6 Jan 2025 14:34:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 554F76B00A3; Mon, 6 Jan 2025 14:34:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F5A46B00A4; Mon, 6 Jan 2025 14:34:16 -0500 (EST) 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 1DFFB6B00A2 for ; Mon, 6 Jan 2025 14:34:16 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CCEB81A02A7 for ; Mon, 6 Jan 2025 19:34:15 +0000 (UTC) X-FDA: 82978028070.23.345290C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 302FFA000D for ; Mon, 6 Jan 2025 19:34:14 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qA9EK67v; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736192054; 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=HhVcQEGzGH+TRle20lu2J+FrSlhsgAp2yCmZVzwMIRk=; b=w7jU39zFXwRNmB7r5tLbq0d65wMG9NUl2xMMERwEnUG+oMlX6sIlmW53OKT9RRFwdYL4QQ L+QvJvhMyRoLGkwms5DPmK7qsOPscOG2fl1iJfvFCaFq6q430HpkEJV0Cke/8Zf22Mv9H0 5dRUs6Y+3eEnCbdWiA1gd7mvLWPLfbI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qA9EK67v; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736192054; a=rsa-sha256; cv=none; b=2KXRz/RUFdErMu4KTlR20g6DEu4T2TQ4X9d1K+Kfbd+JaKBW6BIOB5ypmgI+Ylm7Z2strF pvhnfxpkgfdY6xq407P0OrwKgWiJ1lkOAShdQtxImpdAC0zb+VtpunBjwzRaAbdphAmKRS 9aw9ssqvzz2Av8F7t8gZUmVfdRV97h4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 59F615C495B; Mon, 6 Jan 2025 19:33:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2255AC4CEE1; Mon, 6 Jan 2025 19:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736192053; bh=qRmiCMizOQQeo+/I858Y/f5o5hnl0HiSgoRowr7L2/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qA9EK67v2YtDPIKvr5mAQaNXyERVAGH9DAeSw7HlU3+SnipZEqPU6LZF6KliRbYOP I79h9ZLxSPiSD/EB3IHMigjvY1Ov1yW+6CVCj0WlsvwGagWkH4uzAlOd4+S8Pm39cZ Br7cJp0yzFpV41sTA9sg5yw5SwwIXdQIJF2ZNoiDNX5tssjc6dZbuAlPlmxbkwkH4Q HAXF8OjZH7oLTDiQ2Kxe6AwKMbYLl/gVPUkIXQecu55SwRPUvIEmGpaTop9G2/inlU x8yBSdjdkYaHJcd8ICqtI777erM3yFwCWORnnwEPc0Cf87i1oRAMPD+MQxqBX8iUFg VeH8Scq0iQ/Yg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/16] mm/damon/paddr: report filter-passed bytes back for normal actions Date: Mon, 6 Jan 2025 11:33:50 -0800 Message-Id: <20250106193401.109161-6-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250106193401.109161-1-sj@kernel.org> References: <20250106193401.109161-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 302FFA000D X-Rspamd-Server: rspam12 X-Stat-Signature: 7g9abz4yc7pkt6zewxktxzci3c7896zz X-Rspam-User: X-HE-Tag: 1736192054-642162 X-HE-Meta: U2FsdGVkX1/g5lGgUIiBe63eab1/P9zc60Jx80rL367ek0Un/aw3L+R/tm8Cmr0XoQuDFRHPosOPs9+rIzwEpZdZoKpJVDsUGEOrkMRcHuZeK7ltNtsHzjDrr+gW2nuLtVvmcbo93Pz+/kRoNSXwXRDPdj+Q0AjXrxQZFvvmS47mSRiQRO6GseM1YcBVvZNdCUdsFwiAGKJWiZpYWs97UxSwzZn7Z91F9wxwPkWgxrLJVnlKMNB6xdfixB/02jjXg0RhF1wIbG6ryjs3JMFzKMQNPjF3VlnDUwt9ZaZZsDSt7vQG60mUGaqfYbG7WsacYQdsIhkfZ8ZroYuE+/64zkAcRPH+ssIvKsr60DwouhVIpSRofM9LgTor9bNh1+z2+mHJJmDPimm1Cy89kjPB5Y4f540PeLN+c0/UQ3m6jJ1kfZup1X4MrwDJmOWAX2kensBjTTLAkXzUpoNBlkG9rj6ScuowHV+CWOoQAOq0UX3WiTOvYA84hTxwFYwXGMk5uclELn+t4iZqIGJVOHg8qmkFSLAWpDZJVp80Bq8GsBw0cUC5CGu+rHH+YJjgC06h9eQcLBn+wnWrShKxizEpDr1qNShvBKgmoPtkZWVW3wc4gzq9c2p358mfCVKZVgTAtUlUYq35pmkHnPy7F/VAmz3E0TBbM9jQ8GHwW6PiDKEMkV4libT/kN++8B6VBjJNIZFBsrzgpDS21DpfNP+OgMVU2Wg0GwMsWoaDULQiSfobv57qt+1+jnr3KNxMdDvi0OW4IYyXtVPK8PvTT/awCEF9kV8cg98oBAA2jLc/ZavjgDZfrPDbfcYQUPek3Werq8zcrAw2MOwim7A+qpz+aPXuew8UCt8vGWuM0+sOD1FsBr7Xo9vm/hzezcDvM1/zgrROe7LQbazIfhigWyXxSIgzttuBhPNe28zlfY017cSzu78wnr3W80Xj6iWg77zHWyCFAIqv8zE3hOY+Et+ mD/4aWiv RJWCFBkWAr4YfeljHclNSahP6ZktYpQJSwCQ6fNycXJ7xEaAaXRrEcx1latCFNHCEB1RB4SGh1Jph75ytqX7xWvTxBN6Qp6VOT3k4Kb6i1lCNxDS1Ovtskzx7Yc+IFOZq5t69hE9UU9xaaU8xxYIN36grwLi2rzJlawaQQOTZKqGD6pQCOal35TTWcAwDimpckxPTJ5EZPIP6Xpz4+KJuAJaVndRykXYDyHgVliE3/OTXatQ= 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: damon_operations->apply_scheme() implementations are requested to report back how many bytes of the given region has passed DAMOS filter. 'paddr' operations set implementation supports some of region-internal DAMOS filter handling for normal DAMOS actions except DAMOS_STAT action. But, those are not respecting the request. Report the region-internal DAMOS filter-passed bytes back for the actions. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 3530ef9c80bd..5944316a0b4c 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -243,7 +243,8 @@ static bool damos_pa_filter_out(struct damos *scheme, struct folio *folio) return false; } -static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) +static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s, + unsigned long *sz_filter_passed) { unsigned long addr, applied; LIST_HEAD(folio_list); @@ -272,6 +273,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) if (damos_pa_filter_out(s, folio)) goto put_folio; + else + *sz_filter_passed += folio_size(folio); folio_clear_referenced(folio); folio_test_clear_young(folio); @@ -292,7 +295,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) } static inline unsigned long damon_pa_mark_accessed_or_deactivate( - struct damon_region *r, struct damos *s, bool mark_accessed) + struct damon_region *r, struct damos *s, bool mark_accessed, + unsigned long *sz_filter_passed) { unsigned long addr, applied = 0; @@ -304,6 +308,8 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( if (damos_pa_filter_out(s, folio)) goto put_folio; + else + *sz_filter_passed += folio_size(folio); if (mark_accessed) folio_mark_accessed(folio); @@ -317,15 +323,17 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( } static unsigned long damon_pa_mark_accessed(struct damon_region *r, - struct damos *s) + struct damos *s, unsigned long *sz_filter_passed) { - return damon_pa_mark_accessed_or_deactivate(r, s, true); + return damon_pa_mark_accessed_or_deactivate(r, s, true, + sz_filter_passed); } static unsigned long damon_pa_deactivate_pages(struct damon_region *r, - struct damos *s) + struct damos *s, unsigned long *sz_filter_passed) { - return damon_pa_mark_accessed_or_deactivate(r, s, false); + return damon_pa_mark_accessed_or_deactivate(r, s, false, + sz_filter_passed); } static unsigned int __damon_pa_migrate_folio_list( @@ -449,7 +457,8 @@ static unsigned long damon_pa_migrate_pages(struct list_head *folio_list, return nr_migrated; } -static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s) +static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s, + unsigned long *sz_filter_passed) { unsigned long addr, applied; LIST_HEAD(folio_list); @@ -462,6 +471,8 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s) if (damos_pa_filter_out(s, folio)) goto put_folio; + else + *sz_filter_passed += folio_size(folio); if (!folio_isolate_lru(folio)) goto put_folio; @@ -481,14 +492,14 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, { switch (scheme->action) { case DAMOS_PAGEOUT: - return damon_pa_pageout(r, scheme); + return damon_pa_pageout(r, scheme, sz_filter_passed); case DAMOS_LRU_PRIO: - return damon_pa_mark_accessed(r, scheme); + return damon_pa_mark_accessed(r, scheme, sz_filter_passed); case DAMOS_LRU_DEPRIO: - return damon_pa_deactivate_pages(r, scheme); + return damon_pa_deactivate_pages(r, scheme, sz_filter_passed); case DAMOS_MIGRATE_HOT: case DAMOS_MIGRATE_COLD: - return damon_pa_migrate(r, scheme); + return damon_pa_migrate(r, scheme, sz_filter_passed); case DAMOS_STAT: break; default: