From patchwork Thu Dec 19 04:03:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13914447 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 48EB2E77184 for ; Thu, 19 Dec 2024 04:03:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97A3F6B0093; Wed, 18 Dec 2024 23:03:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92C1C6B0095; Wed, 18 Dec 2024 23:03:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C97D6B0096; Wed, 18 Dec 2024 23:03:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 585226B0093 for ; Wed, 18 Dec 2024 23:03:48 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 17843161336 for ; Thu, 19 Dec 2024 04:03:48 +0000 (UTC) X-FDA: 82910363886.30.84AB18F Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf06.hostedemail.com (Postfix) with ESMTP id 8A26D180007 for ; Thu, 19 Dec 2024 04:03:23 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iUXxuYoz; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1734581011; 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=5vXnVKoBMuwVbRB+3GJtFdOGoFpfINLIRjd2IAlWcPRckeNudGuAEmHVXScnD0i5kG5cYS 6OWCjdCNlVbjidlHsC2+hC0JEgfbqAlIsAJgyOR1ooIgdsVvp1YbibP/nYoCPwDkAH/Tv9 8d2UA52gtclNoTaiUNYzPBGTWcJoZMg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iUXxuYoz; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1734581011; a=rsa-sha256; cv=none; b=8P9vJv7KCysU0H1Px3RiW+YGKEXqpL69ZzmOgI7sF9PByOlXrJSJ0yf9J33+EswiGAFP8E X2eDXKLzXj1uMnw8CU6VZmmtbnSEkmpE0pntCVG6bCte10z6IjRxtLZZSQfTFZk9uO5ZUY C83PqxRh3C6J7m5hDIcF7kHV40TIQdA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 49617A41C12; Thu, 19 Dec 2024 04:01:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 841BEC4CED4; Thu, 19 Dec 2024 04:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734581025; bh=qRmiCMizOQQeo+/I858Y/f5o5hnl0HiSgoRowr7L2/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUXxuYoz0GNi9lf9CHZM18zuewqVRNsYobwBykPHSYrMV9AgbT2ibgoGTL7yCHIs4 viP8pP4alQGmgJSLHf/I5LsPUACsFYRzpQicIDxhcro7F8wUnWsW0QJrKrCo8NgoEk HUscxtnN3hWLtn3zVIU4krkMQI0vt2dDIKyl6z1/+gNxTaVQamtpETRyvHw3MeDDUQ JG0qHKEokMfFer8zvAjHZZ7iuDhZgllJPQNKHeJp47L2I30y/9tFFNYIYx6/XbXuCJ 5+Szxy6CAkRdObErvHvP4QfbdqQHcpOeXfMxFVtN3yJgfhJubzqYydJoFvAg7koQuU F7bPo+Gki1G/w== From: SeongJae Park To: Cc: kernel-team@meta.com, SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 06/18] mm/damon/paddr: report filter-passed bytes back for normal actions Date: Wed, 18 Dec 2024 20:03:15 -0800 Message-Id: <20241219040327.61902-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241219040327.61902-1-sj@kernel.org> References: <20241219040327.61902-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8A26D180007 X-Stat-Signature: r68r3h5335jbik4ibzqh4rc8fnexn1ex X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734581003-951849 X-HE-Meta: U2FsdGVkX1/3Hhxf14/ROnWvpwKSJE2f+QksFFauLqnEI6/YW3W3GP5gdzptJlNcpPu1gGeQS3XmjZSZlUxbU6r+oyDBNdCvp/PIukMc4xL81P8mgXazV190B2zHaA/P7mrBdDHuXummqQwdnoSW2Hh4qNaM4/kOIwX6sM0gDNrFK1lSD3dpYE/cOnDzzf9qic32Toh0Xn1U9kbiB7zZ0wrkRPBvpqDrEnl+1q8Zhyqkg+5DECY/kpESrwng6X4fswGAW5WVD3RolCPwg416LWAiccBXe+L9ztMVMb7GGWmAvJ5OAdkq9gTsQ7+7n/J92hBeMb5PqMYalwkm1cZjZkh3D+lf//DuH7kj0Kbu+9LPDCcXgUJQ7oZl4jPlEIlBCZV56cF93PsJROGel6racA+s+xog8ZEQape7FazsYsfKIQh06mrc7RpktKDJp3fN9NjKRewvpwwYwodduu1gKXnv6tt/ejnqVeE7DEKq90B2vvfKJY4woMJARz7ib+IcJR8n2Vp8c35AGJW2y2DvjZzEHrRriMBfVARHllW1BXyd4c5qxTCAMSNyOjyU8uF9VAEz07urYlTuJ9rzw1eLBXb8iLk5DNz17FCoD2W8n8jCdKse1pep0LAa1fHauC0qIuc26fdQ6/wKlrq851KCdHVUaqw1oeB8t026mf29qKApHBZegAew1MaWHojaLxOaDiGn59vzqht+/vC5+QK8JMa8+WTLHy89URE1CtuRsPwr7AB6Xgs9GlrW8XxyK9+rFU3+qVhOy4nXGIEcd/f/L9jLio1zo1VuFYHj+EffnEFOqYZsO0gPmbx1vFA93Rb9hvOuBUV49PrgUyt2MTDPaPVKeIjDdkrQSe3tCIcWCjZSGg1SKO0qgxqdN32FxAohYdk0/ldZIT76CFQPBcWO7I9maeNw2qGOeoe73QiBuM8r7RQe48vt6G2SZRu8sPGckJtuP5L1RJoZqHzA8OS q80l2hop 4Tbu6zEn5JNf3085jVHZxC5LGaul6A54F7WWyJiX4xExEY9B99xNzVrt6wiT9DN1MtgqIHE57Q5lOb+esie0C1f03+LcXAUf3aS0h3Pu6QCQ9BimC0pz9pI1QYP7x89DaPxq7ux9qqyZDZ3X9wQOQNB6fyjdzQ6rIDe8eYzmL9ly+rZvpnscP62gn8Y0tvkW4eKWlnyvTynwRhSG/zhD20rDYgu9oA4e1lJZRQ9bJVTvBor8= 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: