From patchwork Thu Dec 19 04:03:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13914456 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 4D480E7718B for ; Thu, 19 Dec 2024 04:04:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55D896B00A2; Wed, 18 Dec 2024 23:03:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E9796B00A3; Wed, 18 Dec 2024 23:03:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383066B00A4; Wed, 18 Dec 2024 23:03:59 -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 1970D6B00A2 for ; Wed, 18 Dec 2024 23:03:59 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C1320C13E3 for ; Thu, 19 Dec 2024 04:03:58 +0000 (UTC) X-FDA: 82910364726.11.2471022 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id D5DCE140008 for ; Thu, 19 Dec 2024 04:03:34 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YaWwkoMs; spf=pass (imf09.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=1734581012; 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=Uu32OW92SpNhL0I1vCbmQCnujB2lWgg4AoSWm3t9hqg=; b=kMm3muNfXub8yrJF+4P6lnGHvfEBb8MOyE2cBfcavsLF4+9FEkdFuY/+tJtD0/depYvZq2 jGGArsF/c3TPCKl5FAMfT8FJsKLMh8mdqvUzjTsHcJt281LGofGFyvU4vpBrHheJRShUrr 38G/WS31xJ1C4dvt/+j/eqBRDd2u/3U= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YaWwkoMs; spf=pass (imf09.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=1734581012; a=rsa-sha256; cv=none; b=I8wDHWvlwGtGrwpr44NZaMTw3vEegizwnccF+FwsY7hQByeYPYfXAnI8ET8/jjpx3incYG ELvA0IQ7C6GVmr5V9/cmAy1wV6v+diOdAkFBZnNH/bcNRIXGy8Zt7zW678fVmXrb/Y0OEo P2RhPGlIsqjPPo+7fDVenqLQ3Uwgxps= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5E13F5C65D0; Thu, 19 Dec 2024 04:03:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E18E7C4CED4; Thu, 19 Dec 2024 04:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734581036; bh=xGeZNDXz9ovPiTqa907jHI/cUugPY9TuP39+tm2J3DI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YaWwkoMsUq3M/9y90r30+fdbMg5W+Jtn+IphmKPouGNrvQno6svhKYfNY3O1U7Ziq mNLcPEeBaJaRmMhQ7P0n3pYFyDzFAB73gPOufPWOX9UDzeyWcKaICVL7iUmEWSATe7 u4uhvb0Xa28UgL/G5fN94kmI5VZiaUP5dwaljPbJA2IDw9maXLrBc9vYve1lraJTFe hXVB4X8EYz3EhThDwTJKR+DnvOfYdl9IRscCLTVQTEJp4AXzQ5bfEuYAZhu7TNbotZ BXfCCDArHgTD+uNgbG4FaASYkOCjh5j3mXe0ia+BNc8RxmM4OHlZ4jaEgLN5l2S3S0 G9yqOBRNkt8Vw== 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 15/18] mm/damon/sysfs-schemes: expose per-region filter-passed bytes Date: Wed, 18 Dec 2024 20:03:24 -0800 Message-Id: <20241219040327.61902-16-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: D5DCE140008 X-Rspamd-Server: rspam12 X-Stat-Signature: 1g4joau3gjj6wqxu8rhx86ohue3yw7qo X-Rspam-User: X-HE-Tag: 1734581014-934601 X-HE-Meta: U2FsdGVkX1+L/U9k6llvhSejzk52oXSs1XJPurgYc6WpMTDy8e2r3uA7scjDrvFW6lZWXDX3LcJj4nTDaLBAOWAzBXLv43Y12wui2PBfNf3oIwnsqMf48wrxM4IyfLRj+OxNtlBZptG064cGXSaNBWcxqoqNE1XmQ9d53Wx2F0SWR7xWJ1jFm8L/U9/OFR7ymKetT6HCp5m/o8DdxWjJ0phVuvPjV3yhyV0QNzFD6+ZIRV8LLjG8E/CAGuajS+Xyg30eVF6JS7iOTEFTwxy2On9wImb5r+rvIvpOmpol0guufL7e7zkmfLs4q8E688J+JbNvt3ur2ijGvikxDULQT2wchNEJkJMVK+jzpPIIkGChVeG0W4s7bun0cRpC/aF+NN8nEVi6mElpo2Lkp8qdwqv++l57CiwAcb3shnWdqHD18iLcpmNoAY9PAVvB+Sgxejg0FuKekvCDMrN9TBl3IhH5OxQngsPKt1rWQjlh7+9Y+becS/q8rs8qQANECA1CUxPs8swGiL2Hucvqrp6PXi2b4xyzGrsO2Cen6Q7Sw/9IXMU2Iv8pifGu7DXDbTuXWwG9p7iCpLjdZo1e6NrEuK2UwhM16hPfOWqj/Ql/T1Tb3uHTp2a7AFgZ1adfTZ0u1eu7jgP1XFTdvJPl7oK+juISRgFDtesGSgSJ/z72czEvzMpvkVzow4LrKlHUciVBfLy+ivZqUfd68BebdAZWI1zC4UL9TXOiP6IfiLeQmU2JOvit/vNYifGNMRZQ2R7LNO+CtLTkDe+VdactL8a0CqpNHPNETFg04fjL6Z/yNrBoNH104w61HIMKPNCtp++eDmmy+u+w4REFObuLlMHfVQnW2RlOiOVTayMhBoL/rPupbHhYiiSmE5U5gMO4rzDha9lkHeLEeCJPGTXybgsY8/O4gxW+Fy5hE/GrXeDcFH2QVlegUuRtLHE9jfosw4KYlKXYGXq9ADD0bPcsbkp uD76hGKh 3bavwGuEoryWt5F4KRWk5Jen2+dOI+Gm1LB475xM9QGHiayCj9hST6SX1iI/e1UVpwTMtgKPkZrl0dyHFcGNzkNgPhl7RdFTqWVs5bDaA2L9z7SmsjOXF/FoKPxO3VZyiK6nSaCB+ihfd5vCRVXE4VvwgkP9VidbsUsnJz1VW77EuijGKkdlt7JuyAkWJOyXK6GjmYxfn+AUeIPNu7BOJnIbBOYuK6fX9T1k0OsGsAt0IqzQ= 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 | 18 +++++++++++++++++- mm/damon/sysfs.c | 3 ++- 3 files changed, 20 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..1da0594dde55 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); @@ -2110,7 +2124,8 @@ 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) + 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 +2150,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(