From patchwork Mon Jan 6 19:33:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13927794 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 02959E77188 for ; Mon, 6 Jan 2025 19:34:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD67E6B00AE; Mon, 6 Jan 2025 14:34:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A86BA6B00AF; Mon, 6 Jan 2025 14:34:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 900606B00B0; Mon, 6 Jan 2025 14:34:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7001A6B00AE for ; Mon, 6 Jan 2025 14:34:27 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 23B45A0215 for ; Mon, 6 Jan 2025 19:34:27 +0000 (UTC) X-FDA: 82978028574.29.269556F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 89D93A0005 for ; Mon, 6 Jan 2025 19:34:25 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="mC/FZfn4"; spf=pass (imf15.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=1736192065; 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=6jrX9SAvLd7mLPZdcXDFI5AEiDmV+N2KOlUXoI8djAw=; b=jA9fckhyaFRffjkrq41lXu4O5mXqsR133CnRBZJk6y/K4gN6W4+DMlbxWK/3AhDWMX8Su4 mIYOPaqibwjHAAVo/lU5JBNF/0XMDzwE/57MZNtKICR2BPBNdqKNf6LCawdnkfmbuFMN2i YidHLn+jslEDxKYGpZbewlW0GZaSQwg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736192065; a=rsa-sha256; cv=none; b=f5lfiT34bC3al3Jfsg7uYtoLrVK4SAjp45G03lf7aOfQsiIx774JSm01mKjxeT1OSuRhKa 7Ay423B1ti5WvTn/w+vYH88J0EG99VqYywei6fWLMzgPfFxqg1Tm52wRVOg/vBhD2dSTs1 xpoF2boiXlLVlhXwp4haN9HsEpWHGuI= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="mC/FZfn4"; spf=pass (imf15.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B9DCE5C401D; Mon, 6 Jan 2025 19:33:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BC58C4CEDF; Mon, 6 Jan 2025 19:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736192064; bh=+UnPb4bwnUVNPuDwxrpYf9x2zFG7e9vQ76jJhD49ioc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mC/FZfn4gnh9kGmSK6sjIH4jQ+kDiy0+R/V2rDZn+xwanzRwkdrnAeucKOZd1ufy+ h5+EjyLMVEdHz9KxNqreWlOB+2Zqiu53nN+pdSRacNHAZWZ+WdJYsWY7/3VP6A4NLe ooiY/3Qdfqc7Os+3HMWzWcXi4pADb61s/DN1tU7Ks0DJ5DcJs+I4LwdNwP0ZP7tPqB 4QdMm2jrGAkD9GFSNYWhwKZjaEmi0FpUpbJRDwgsbLtLpygprb5+iJL2+baV3JmqgX q/jIRQ0hwKVsuAwvI/Lhm6cJDVqESD1ra/fE6jBaolwGzQrhMjHm2ZjVwq7mv7tDCQ YIHG1bbNWD1UA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/16] mm/damon/sysfs-schemes: expose per-region filter-passed bytes Date: Mon, 6 Jan 2025 11:33:58 -0800 Message-Id: <20250106193401.109161-14-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-Server: rspam10 X-Rspamd-Queue-Id: 89D93A0005 X-Stat-Signature: w48t66xs14niob558wrm1n9fuhefdyzn X-Rspam-User: X-HE-Tag: 1736192065-424560 X-HE-Meta: U2FsdGVkX1/V2fmiz2QCsjB0jj3wHMLtMaRFnfPJJPDaggI3J4LI2b1dPoYKGT2pUi8+j9XGqp6WAGSL3eyWIst00qMKsOT7kd1PQgc31R+FPuj9dkS1+bzrGbfo2lSl+7BLPAPV/G14PITRLelNtQA3uMPFjBqXs0hxXfVxSkenmCLZDIAt03HYxgTiDz17LwbWlPLE/SZIEYHQ9NKY88/KMVhj87VHT6y60T2MmMHN9nPTT2F6DvGA9wgdjOqxhMN55EFc6xUstwhcMPjRVLXzyw7GoI+PRlDbaF8+C2PHAe+aiAjYxHb7/YwBXYA+o4uxNFn6ClvAJyaCow5NcJ2Eo/qW5FWWj72e2QeJG5ccALUbSyLGYEWhJoSiAtBLV21FQ+1MK3bTAPO6Xk75Q+5GwxpYCmmYnBFcSqXPF4VZpTJ6RRu5kq56leX7tB+ZTSHnOAQZJwGz5OPcJa9NZbD+qkLiYrhEb3YY4uK/LrR4o7QBV5iFWp8UgPnbp3kVVCcjmw1mG9uTHAt3aZDFqeKcd3QOc7qQmBzCT49BuVr7vgL3Ey3hPXLKKJmNBIhk4iDDojwdR809mWZyYckewS99WFbI/dIuUxa2fVsnmDthVqDw39Q0aBytOhLCeKbN7AsOLFmj0szj+A9ZfvUBL8jBGpKtzVk2Yv6JKJkINSn4qixVYfn4Z7ihQe+Gsyu77CxYqm3rpo9fy+D71QVTBxU6IRoTcjNSepfbmmluUKxyxaIGUYTE7rZzAERHRhhBdVO0hm04NvVPF+9fY7C2pT6dDl9FvRH81+Xzyjvr8rX3v+dtIZNKz6MTPqpSTV589lgs/902fXusHEz8cNHxXJmDe7kD6U/uvsFeNrDI7IFPAQ5K796CAvcwx7qsGBhHMKGKXiqnqjwXLlv6Rik7g1Cp1A/UnRU1cAQhQQiIa8KEB/BRRHhnbTWAODbCs93VDC1au5ORpNKb41XK0/4 S7KYiYKk dPZ2XTuUfnqKpaDpmE8+kvtPDLkxdEUqnPbTvWWgv0+jYu/+k8DkugYtWtySTemgNcb7pHQQsWr2mbg5rwdAmSR6FyqUYce/TtvxuhaE07+EwUmr1cpi3FqTxrQcxLUh9t4l0riyH+eVZqvfScG3gvzooaSSYtWvHB3+ork9s+mGm0Uv2VV8uRjnBiAiXEOMEVHICmKdiLMOS62xZZcD46LZm0hJ4n/UN/XNoUzRo4UHmgtc= 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: Per-region operations set-handled DAMOS filters passed memory size information is provided to only DAMON core API users. Further expose it to the user space by adding a new DAMON sysfs interface file under each scheme tried region directory. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 2 +- mm/damon/sysfs-schemes.c | 19 ++++++++++++++++++- mm/damon/sysfs.c | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index b3f63bc658b7..70d84bdc9f5f 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -48,7 +48,7 @@ void damon_sysfs_schemes_update_stats( void damos_sysfs_populate_region_dir(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, struct damos *s, - bool total_bytes_only); + bool total_bytes_only, unsigned long sz_filter_passed); int damon_sysfs_schemes_clear_regions( struct damon_sysfs_schemes *sysfs_schemes); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index b447c412b02c..deeaf23c1fcf 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -19,6 +19,7 @@ struct damon_sysfs_scheme_region { struct damon_addr_range ar; unsigned int nr_accesses; unsigned int age; + unsigned long sz_filter_passed; struct list_head list; }; @@ -74,6 +75,15 @@ static ssize_t age_show(struct kobject *kobj, struct kobj_attribute *attr, return sysfs_emit(buf, "%u\n", region->age); } +static ssize_t sz_filter_passed_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_region *region = container_of(kobj, + struct damon_sysfs_scheme_region, kobj); + + return sysfs_emit(buf, "%lu\n", region->sz_filter_passed); +} + static void damon_sysfs_scheme_region_release(struct kobject *kobj) { struct damon_sysfs_scheme_region *region = container_of(kobj, @@ -95,11 +105,15 @@ static struct kobj_attribute damon_sysfs_scheme_region_nr_accesses_attr = static struct kobj_attribute damon_sysfs_scheme_region_age_attr = __ATTR_RO_MODE(age, 0400); +static struct kobj_attribute damon_sysfs_scheme_region_sz_filter_passed_attr = + __ATTR_RO_MODE(sz_filter_passed, 0400); + static struct attribute *damon_sysfs_scheme_region_attrs[] = { &damon_sysfs_scheme_region_start_attr.attr, &damon_sysfs_scheme_region_end_attr.attr, &damon_sysfs_scheme_region_nr_accesses_attr.attr, &damon_sysfs_scheme_region_age_attr.attr, + &damon_sysfs_scheme_region_sz_filter_passed_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_scheme_region); @@ -2105,12 +2119,14 @@ void damon_sysfs_schemes_update_stats( * @r: DAMON region to populate the directory for. * @s: Corresponding scheme. * @total_bytes_only: Whether the request is for bytes update only. + * @sz_filter_passed: Bytes of @r that passed filters of @s. * * Called from DAMOS walk callback while holding damon_sysfs_lock. */ void damos_sysfs_populate_region_dir(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx, struct damon_target *t, - struct damon_region *r, struct damos *s, bool total_bytes_only) + struct damon_region *r, struct damos *s, bool total_bytes_only, + unsigned long sz_filter_passed) { struct damos *scheme; struct damon_sysfs_scheme_regions *sysfs_regions; @@ -2135,6 +2151,7 @@ void damos_sysfs_populate_region_dir(struct damon_sysfs_schemes *sysfs_schemes, region = damon_sysfs_scheme_region_alloc(r); if (!region) return; + region->sz_filter_passed = sz_filter_passed; list_add_tail(®ion->list, &sysfs_regions->regions_list); sysfs_regions->nr_regions++; if (kobject_init_and_add(®ion->kobj, diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 224873ca8aa6..deeab04d3b46 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1461,7 +1461,8 @@ static void damon_sysfs_schemes_tried_regions_upd_one(void *data, struct damon_c damos_sysfs_populate_region_dir( sysfs_kdamond->contexts->contexts_arr[0]->schemes, - ctx, t, r, s, walk_data->total_bytes_only); + ctx, t, r, s, walk_data->total_bytes_only, + sz_filter_passed); } static int damon_sysfs_update_schemes_tried_regions(