From patchwork Mon Dec 5 23:08:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065160 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 ADE1CC63704 for ; Mon, 5 Dec 2022 23:08:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 903288E0003; Mon, 5 Dec 2022 18:08:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 863978E0001; Mon, 5 Dec 2022 18:08:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DD438E0003; Mon, 5 Dec 2022 18:08:38 -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 5CC198E0001 for ; Mon, 5 Dec 2022 18:08:38 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 152AFA0BB3 for ; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) X-FDA: 80209793916.30.61E634A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 9C610100007 for ; Mon, 5 Dec 2022 23:08:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LhojvW68; spf=pass (imf14.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281717; a=rsa-sha256; cv=none; b=0xAxXE6p/QilVuDPckGk3ISTyH/a9xZKs7zM7kXzQYQy08bYpyzU5k8GSTxgmUX8pQ6kZ4 T3sOqwrMLSw8Pd24YI0h49T/fA6+zlZgptVW3KeWfdoBB6/lVy4VxDvevNa+Pmt6ytTaSE 0J8PWFRIlCOeE7cgPAk28wrerarhrR0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LhojvW68; spf=pass (imf14.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281717; 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=JFDni24s97g4FVNUvLRr5WSpQRnQvRVE2KEbE4cdgMw=; b=qrsmISRWmQ9eraGNnbDC+NwawEkx0f9iPy9SIdyhC5NzKA7rhydTUoAlWgPV+hhq8aayx1 CTEm5f8u6YzKMpS71cm1OObimeu1a4JbsOfvcGx2mkTfoifW9JdCwYVZgS/CmxKr3f0OAn 2tPHkxqmPq/NAR0Rvl2oowd2ETwqGVc= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D37FD614B6; Mon, 5 Dec 2022 23:08:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D65BC4347C; Mon, 5 Dec 2022 23:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281716; bh=vSamPC5rWY7nml963lA73M1wBydbQNBybO8ofr/YpTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LhojvW68fLcwzuWXDN6sV/7hfBpKIgaNH59qlCDuw8NCCROqjDuCBJTRtVo8cHcYV 3kA/wkUQCzsWw8xLv3PKKNvGv/c+L5KdfNQsuPI3Mrd/gvaKMBLWYEDAZpIjxF0eXv o8+PJm5tIy3RxSvD1kMzOa8QwR2VdjGCnkBizAXKP89btwZUyOH1EOEsnZ/vGaG3Xh zmVHA+n23brth9vXqFjWFna5N21VR61+vjT4LBfnfh4QWzQszspH9+U9jDqR6THRQn 4K8XfECPj9mD6GaVc9JWwGri4+T0MI0nU5MammiKvIYz6aFngSoSwArm8TGAE2g5Lh TnvNXGSjcRBFw== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 01/11] mm/damon/core: implement damos filter Date: Mon, 5 Dec 2022 23:08:20 +0000 Message-Id: <20221205230830.144349-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Spamd-Result: default: False [-0.40 / 9.00]; BAYES_HAM(-6.00)[100.00%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9C610100007 X-Stat-Signature: by3o1duroj7uxbfccefc4wy3mu3wik33 X-HE-Tag: 1670281717-96501 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: DAMOS let users do system operation in a data access pattern oriented way. The data access pattern, which is extracted by DAMON, is somewhat accurate more than what user space could know in many cases. However, in some situation, users could know something more than the kernel about the pattern or some special requirements for some types of memory or processes. For example, some users would have slow swap devices and knows latency-ciritical processes and therefore want to use DAMON-based proactive reclamation (DAMON_RECLAIM) for only non-anonymous pages of non-latency-critical processes. For such restriction, users could exclude the memory regions from the initial monitoring regions and use non-dynamic monitoring regions update monitoring operations set including fvaddr and paddr. They could also adjust the DAMOS target access pattern. For dynamically changing memory layout and access pattern, those would be not enough. To help the case, add an interface, namely DAMOS filters, which can be used to avoid the DAMOS actions be applied to specific types of memory, to DAMON kernel API (damon.h). At the moment, it supports filtering anonymous pages and/or specific memory cgroups in or out for each DAMOS scheme. Note that this commit adds only the interface to the DAMON kernel API. The impelmentation should be made in the monitoring operations sets, and following commits will add that. Signed-off-by: SeongJae Park --- include/linux/damon.h | 51 +++++++++++++++++++++++++++++++++++++++++++ mm/damon/core.c | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 35630634d790..42cea3bf7319 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -8,6 +8,7 @@ #ifndef _DAMON_H_ #define _DAMON_H_ +#include #include #include #include @@ -215,6 +216,39 @@ struct damos_stat { unsigned long qt_exceeds; }; +/** + * enum damos_filter_type - Type of memory for &struct damos_filter + * @DAMOS_FILTER_TYPE_ANON: Anonymous pages. + * @DAMOS_FILTER_TYPE_MEMCG: Specific memcg's pages. + * @NR_DAMOS_FILTER_TYPES: Number of filter types. + */ +enum damos_filter_type { + DAMOS_FILTER_TYPE_ANON, + DAMOS_FILTER_TYPE_MEMCG, + NR_DAMOS_FILTER_TYPES, +}; + +/** + * struct damos_filter - DAMOS action target memory filter. + * @type: Type of the page. + * @matching: If the matching page should filtered out or in. + * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. + * @list: List head for siblings. + * + * Before applying the &damos->action to a memory region, DAMOS checks if each + * page of the region matches to this and avoid applying the action if so. + * Note that the check support is up to &struct damon_operations + * implementation. + */ +struct damos_filter { + enum damos_filter_type type; + bool matching; + union { + unsigned short memcg_id; + }; + struct list_head list; +}; + /** * struct damos_access_pattern - Target access pattern of the given scheme. * @min_sz_region: Minimum size of target regions. @@ -239,6 +273,7 @@ struct damos_access_pattern { * @action: &damo_action to be applied to the target regions. * @quota: Control the aggressiveness of this scheme. * @wmarks: Watermarks for automated (in)activation of this scheme. + * @filters: Additional set of &struct damos_filter for &action. * @stat: Statistics of this scheme. * @list: List head for siblings. * @@ -254,6 +289,10 @@ struct damos_access_pattern { * If all schemes that registered to a &struct damon_ctx are inactive, DAMON * stops monitoring and just repeatedly checks the watermarks. * + * Before applying the &action to a memory region, &struct damon_operations + * implementation could check pages of the region and skip &action to respect + * &filters + * * After applying the &action to each region, &stat_count and &stat_sz is * updated to reflect the number of regions and total size of regions that the * &action is applied. @@ -263,6 +302,7 @@ struct damos { enum damos_action action; struct damos_quota quota; struct damos_watermarks wmarks; + struct list_head filters; struct damos_stat stat; struct list_head list; }; @@ -516,6 +556,12 @@ static inline unsigned long damon_sz_region(struct damon_region *r) #define damon_for_each_scheme_safe(s, next, ctx) \ list_for_each_entry_safe(s, next, &(ctx)->schemes, list) +#define damos_for_each_filter(f, scheme) \ + list_for_each_entry(f, &(scheme)->filters, list) + +#define damos_for_each_filter_safe(f, next, scheme) \ + list_for_each_entry_safe(f, next, &(scheme)->filters, list) + #ifdef CONFIG_DAMON struct damon_region *damon_new_region(unsigned long start, unsigned long end); @@ -536,6 +582,11 @@ void damon_destroy_region(struct damon_region *r, struct damon_target *t); int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, unsigned int nr_ranges); +struct damos_filter *damos_new_filter(enum damos_filter_type type, + bool matching); +void damos_add_filter(struct damos *s, struct damos_filter *f); +void damos_destroy_filter(struct damos_filter *f); + struct damos *damon_new_scheme(struct damos_access_pattern *pattern, enum damos_action action, struct damos_quota *quota, struct damos_watermarks *wmarks); diff --git a/mm/damon/core.c b/mm/damon/core.c index ceec75b88ef9..1bf0654ae189 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -263,6 +263,40 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, return 0; } +struct damos_filter *damos_new_filter(enum damos_filter_type type, + bool matching) +{ + struct damos_filter *filter; + + filter = kmalloc(sizeof(*filter), GFP_KERNEL); + if (!filter) + return NULL; + filter->type = type; + filter->matching = matching; + return filter; +} + +void damos_add_filter(struct damos *s, struct damos_filter *f) +{ + list_add_tail(&f->list, &s->filters); +} + +static void damos_del_filter(struct damos_filter *f) +{ + list_del(&f->list); +} + +static void damos_free_filter(struct damos_filter *f) +{ + kfree(f); +} + +void damos_destroy_filter(struct damos_filter *f) +{ + damos_del_filter(f); + damos_free_filter(f); +} + /* initialize private fields of damos_quota and return the pointer */ static struct damos_quota *damos_quota_init_priv(struct damos_quota *quota) { @@ -287,6 +321,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, return NULL; scheme->pattern = *pattern; scheme->action = action; + INIT_LIST_HEAD(&scheme->filters); scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); @@ -315,6 +350,10 @@ static void damon_free_scheme(struct damos *s) void damon_destroy_scheme(struct damos *s) { + struct damos_filter *f, *next; + + damos_for_each_filter_safe(f, next, s) + damos_destroy_filter(f); damon_del_scheme(s); damon_free_scheme(s); } From patchwork Mon Dec 5 23:08:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065162 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 DDA09C63705 for ; Mon, 5 Dec 2022 23:08:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8401F8E0005; Mon, 5 Dec 2022 18:08:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A0C78E0001; Mon, 5 Dec 2022 18:08:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CC2D8E0005; Mon, 5 Dec 2022 18:08:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 41D3D8E0001 for ; Mon, 5 Dec 2022 18:08:39 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 150FC1C64D5 for ; Mon, 5 Dec 2022 23:08:39 +0000 (UTC) X-FDA: 80209793958.23.274CCE9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id AE7E2C0003 for ; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OZtT+uKK; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281718; a=rsa-sha256; cv=none; b=SfFjfXT7DZpzesTTndIXevkhrhtB7Dai74YVvAh1sfipWUgLi68+0bzmspUGf75Lgi0r7l bedLxYUp4IFxRMFKNEk/9Vk+azKCwDLULTsM1K3aGVkmVZBJ9uDRxWKMy6A2Nw9Y3Nu1em 7k4AYiP7p0P0W1Nv+AhUGENLYPbZM54= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OZtT+uKK; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281718; 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=CDD01R5AGR0VCKXOUvbXwSINuJd3g9aT00R1KPyCMrI=; b=eZ4SkYmlhpzwRahSqpZKPSHiCZY9DVzHVP2mY7CUVb9klTI2R8WvvaCEj/obLtwq9LvJi4 R44aTVKDwOp6hnKFrGsQUmCtaNxBGxSlYnt3Oyet2BwE+wYOUlpt+YytYWEFq5cp16xIyA sMy29C+4eST1JaaHh0243gef5B9ivkg= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D67E6614C1; Mon, 5 Dec 2022 23:08:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D62FDC433D6; Mon, 5 Dec 2022 23:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281717; bh=A+37s6JJXYN+1C0NX4ExPJftU7PAKfFK4zc/BA9nVsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZtT+uKK4/4lwOI6eMAjYSBULmKtBrpMkQl2IHAUITb7EXo98LhCroIQJT8y9r+hV RjErPSimYQk6wI+oQHnJ2W8q1HKG7VsvuN3Z+CN8V9E9/92jWWK9WujY4iRGqptbr9 dZ1X1kwT3xUlFezXuwH46XHCKBojafP0YCqEFGFR1vZNAWcV05AY87wJz86mrDFUu8 7AT3dCObaN7p4ljYZ0j2i9jOwjEn4aYoNgDh58H+HC36IVp3cySUm5RJG8jNb1gCrq Qpf8bWCAA+bJNi9KZjsPhX+0mk7H/hdAO4opS9KDOUtLyh6k3SSBP+kytCHh8F6y1J YJYBKx0ps72Uw== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 02/11] mm/damon/paddr: support DAMOS filters Date: Mon, 5 Dec 2022 23:08:21 +0000 Message-Id: <20221205230830.144349-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Spamd-Result: default: False [-0.40 / 9.00]; BAYES_HAM(-6.00)[99.99%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: AE7E2C0003 X-Rspamd-Server: rspam01 X-Stat-Signature: gy4xjya7xuha3hiaemcdzh3e3eudnu89 X-HE-Tag: 1670281718-302425 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: Implement support of the DAMOS filters in the physical address space monitoring operations set, for all DAMOS actions that it supports including 'pageout', 'lru_prio', and 'lru_deprio'. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 71 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index e1a4315c4be6..ebd1905eed6f 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -202,7 +202,47 @@ static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) return max_nr_accesses; } -static unsigned long damon_pa_pageout(struct damon_region *r) +static bool __damos_pa_filter_out(struct damos_filter *filter, + struct page *page) +{ + bool matched = false; + struct mem_cgroup *memcg; + + switch (filter->type) { + case DAMOS_FILTER_TYPE_ANON: + matched = PageAnon(page); + break; + case DAMOS_FILTER_TYPE_MEMCG: + rcu_read_lock(); + memcg = page_memcg_check(page); + if (!memcg) + matched = false; + else + matched = filter->memcg_id == mem_cgroup_id(memcg); + rcu_read_unlock(); + break; + default: + break; + } + + return matched == filter->matching; +} + +/* + * damos_pa_filter_out - Return true if the page should be filtered out. + */ +static bool damos_pa_filter_out(struct damos *scheme, struct page *page) +{ + struct damos_filter *filter; + + damos_for_each_filter(filter, scheme) { + if (__damos_pa_filter_out(filter, page)) + return true; + } + return false; +} + +static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) { unsigned long addr, applied; LIST_HEAD(page_list); @@ -213,6 +253,11 @@ static unsigned long damon_pa_pageout(struct damon_region *r) if (!page) continue; + if (damos_pa_filter_out(s, page)) { + put_page(page); + continue; + } + ClearPageReferenced(page); test_and_clear_page_young(page); if (isolate_lru_page(page)) { @@ -232,7 +277,7 @@ static unsigned long damon_pa_pageout(struct damon_region *r) } static inline unsigned long damon_pa_mark_accessed_or_deactivate( - struct damon_region *r, bool mark_accessed) + struct damon_region *r, struct damos *s, bool mark_accessed) { unsigned long addr, applied = 0; @@ -241,6 +286,12 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( if (!page) continue; + + if (damos_pa_filter_out(s, page)) { + put_page(page); + continue; + } + if (mark_accessed) mark_page_accessed(page); else @@ -251,14 +302,16 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( return applied * PAGE_SIZE; } -static unsigned long damon_pa_mark_accessed(struct damon_region *r) +static unsigned long damon_pa_mark_accessed(struct damon_region *r, + struct damos *s) { - return damon_pa_mark_accessed_or_deactivate(r, true); + return damon_pa_mark_accessed_or_deactivate(r, s, true); } -static unsigned long damon_pa_deactivate_pages(struct damon_region *r) +static unsigned long damon_pa_deactivate_pages(struct damon_region *r, + struct damos *s) { - return damon_pa_mark_accessed_or_deactivate(r, false); + return damon_pa_mark_accessed_or_deactivate(r, s, false); } static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, @@ -267,11 +320,11 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, { switch (scheme->action) { case DAMOS_PAGEOUT: - return damon_pa_pageout(r); + return damon_pa_pageout(r, scheme); case DAMOS_LRU_PRIO: - return damon_pa_mark_accessed(r); + return damon_pa_mark_accessed(r, scheme); case DAMOS_LRU_DEPRIO: - return damon_pa_deactivate_pages(r); + return damon_pa_deactivate_pages(r, scheme); case DAMOS_STAT: break; default: From patchwork Mon Dec 5 23:08:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065161 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 6BD87C636F9 for ; Mon, 5 Dec 2022 23:08:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09E5A8E0006; Mon, 5 Dec 2022 18:08:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1CBA8E0001; Mon, 5 Dec 2022 18:08:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF7DD8E0006; Mon, 5 Dec 2022 18:08:39 -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 BDEEB8E0001 for ; Mon, 5 Dec 2022 18:08:39 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8D0CE1C6481 for ; Mon, 5 Dec 2022 23:08:39 +0000 (UTC) X-FDA: 80209793958.17.8095E1A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 307E418000F for ; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Gkd9ZtOB; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281719; 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=r3xyNreIJtEHO9foiiQtvJVmPt1q36n0JQLVr8U6gzI=; b=3T8Ko4wo0Swx8abPY01/g4TAhRLiUB9OMtP5Oc7RC3XDSCN3/OaYo0kDbiuQcgx4sBzfEg ibiKAbzDwIqiYv5I/b9rFaZsfP/LKEpL7DkmjhhYA7KpjIQa9ZIveK7R2fSiXK49L3tj+i fryOUp1U/nI6A+INvbIIPCqS8GJABmo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Gkd9ZtOB; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281719; a=rsa-sha256; cv=none; b=rRjesNHiFRys18UjK3+M3ui/imnMj26yM1bD32QUj6Bprt1wbnm9XU9yWg3Hjt9H3yGaQs otZsgqJhBNTXnWO3du8t3VEb1Y1FOSuW/kxZiADqldOg8ArsUST/lqHacmRGsfEEf/0+PL v6eIHYRTsRH5UvQcS7LC2uQnaJ9PttQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 80075614C0; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A9C9C43146; Mon, 5 Dec 2022 23:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281717; bh=grt8f69Dz6AwyetZSMeMbFhewde1iaVMzadAT1LoRZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gkd9ZtOBsrsbXnQFw9/sbyQbOH93AK/MO5lZXVdWN9g0ZWQ8gEIX08NSzEl2o7mnd lEZcmZgk03/Bb1cA8Se81GMDzpz1rpO4pSs3dXeVGR3586qFm0ua28x7yTZUsiP1Jw XohFGfEmlDPWRNb7mRez4As0YcnWL2GTA6oEzH0/r13j4H0S6fl286ORTXbb9xxln0 BylJ/JsgTIFq56cYSPF0JSx3FT2kNU+ZCefodS0dcW3vGVzIo0UWtL/hj1a6NmFXhH jxei4CFDcvbTrIf+gco38m0sYnHgXATXdCmuX5WZyuV+UuBXuFRzw1X90uFhiu8G6H jlVIbQEwM991A== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 03/11] mm/damon/reclaim: add a parameter called skip_anon for avoiding anonymous pages reclamation Date: Mon, 5 Dec 2022 23:08:22 +0000 Message-Id: <20221205230830.144349-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 307E418000F X-Rspam-User: X-Stat-Signature: on3ptejoii484gtmqtcrrm8od9eg73qo X-Spamd-Result: default: False [2.90 / 9.00]; BAYES_HAM(-3.70)[94.14%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; SUBJECT_HAS_UNDERSCORES(1.00)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[kernel.org:+]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; ARC_NA(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; RCVD_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-HE-Tag: 1670281718-243410 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: In some cases, for example if users have confidence at anonymous pages management or the swap device is too slow, users would want to avoid DAMON_RECLAIM swapping the anonymous pages out. For such case, add yet another DAMON_RECLAIM parameter, namely 'skip_anon'. When it is set as 'Y', DAMON_RECLAIM will avoid reclaiming anonymous pages using a DAMOS filter. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index e82631f39481..648d2a85523a 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -98,6 +98,15 @@ module_param(monitor_region_start, ulong, 0600); static unsigned long monitor_region_end __read_mostly; module_param(monitor_region_end, ulong, 0600); +/* + * Skip anonymous pages reclamation. + * + * If this parameter is set as ``Y``, DAMON_RECLAIM does not reclaim anonymous + * pages. By default, ``N``. + */ +static bool skip_anon __read_mostly; +module_param(skip_anon, bool, 0600); + /* * PID of the DAMON thread * @@ -142,6 +151,7 @@ static struct damos *damon_reclaim_new_scheme(void) static int damon_reclaim_apply_parameters(void) { struct damos *scheme; + struct damos_filter *filter; int err = 0; err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); @@ -152,6 +162,15 @@ static int damon_reclaim_apply_parameters(void) scheme = damon_reclaim_new_scheme(); if (!scheme) return -ENOMEM; + if (skip_anon) { + filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); + if (!filter) { + /* Will be freed by next 'damon_set_schemes()' below */ + damon_destroy_scheme(scheme); + return -ENOMEM; + } + damos_add_filter(scheme, filter); + } damon_set_schemes(ctx, &scheme, 1); return damon_set_region_biggest_system_ram_default(target, From patchwork Mon Dec 5 23:08:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065169 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 873C2C63706 for ; Mon, 5 Dec 2022 23:08:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA80F8E000E; Mon, 5 Dec 2022 18:08:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E32248E000C; Mon, 5 Dec 2022 18:08:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC1628E000E; Mon, 5 Dec 2022 18:08:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A9D558E000C for ; Mon, 5 Dec 2022 18:08:45 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8171D160AB3 for ; Mon, 5 Dec 2022 23:08:45 +0000 (UTC) X-FDA: 80209794210.25.A466166 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf12.hostedemail.com (Postfix) with ESMTP id CAC5840014 for ; Mon, 5 Dec 2022 23:08:44 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="W8qG/90j"; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281725; 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=vvd7VIY3E2fb0b6B1lCyCZF6kEVIsBEC2F3qsYkpFaU=; b=T7O7w8LetK+Gwpt0Zx4w24k3llEYbTO+sDGwPew0q5lgxeBzqMbOGjSMHuh/ronK8esvk2 4A3tgen/Se6fCtYV7bUAP8dN+ehVu/Hu1GVnCvM76tR4XPKf2c0vrg7iZGbdPOGiVFroPd fkYbaYZNMoGXfowDE4vzavqPILm9iI8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="W8qG/90j"; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281725; a=rsa-sha256; cv=none; b=7HFhXBi2WG2QfMBZnYC5kzO92ij1+HbXmVbM0j+t1hVSPGbh/N6c0Pj0lh3+uwrteb4QSS z+8Dl3UxnBFhxzcdxk9TX6Nngeu/FSzt++ewXuYXa1WrlPhl7G0dnrLAQTlzXgzClgyyMI uGSYUBOM4Qx4bTWgDpbmO7KmBIet1uc= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 59ACFCE1318; Mon, 5 Dec 2022 23:08:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1305AC433B5; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281718; bh=ew0j918CPCZ3BCkCfl4ilV0ZC0sdlaLXkkNEQyNFiwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8qG/90jufBB/qjSVpiIuoor4XnhnFVzjtYHepc2rpNDuU7yo7naKqYbm+xUemT+p qIttT3rUj6KqPG8THzAwmC5df/LY0OlN9RZ0cAdXuYxrbHF2EQ9HU6Cb8XcOYdQcZ1 QQBc5DPFKjaAX3t0XTQ6D1HhaNWGA2Z+ZXyttXmz+77vKn0Vg2BxQHkOHWmFplAXzc /Cvnc01ns3hEKs/Oni+zs1nc1xnb1fLJa/63pUGo0MYGcW83Da8UJdc2xuwCIec8QL sj4CwRnbiNZ0pcCt7pWD+OzHOuqxbfF24jjEWG4kzF7RNn0ryU/e0lOmoMAfTVjeXo R8sA1F0+fiwCA== From: SeongJae Park To: Andrew Morton Cc: Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 04/11] Docs/admin-guide/damon/reclaim: document 'skip_anon' parameter Date: Mon, 5 Dec 2022 23:08:23 +0000 Message-Id: <20221205230830.144349-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Spamd-Result: default: False [5.39 / 9.00]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; BAYES_HAM(-1.21)[81.87%]; MID_CONTAINS_FROM(1.00)[]; SUBJECT_HAS_UNDERSCORES(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:sin.source.kernel.org]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; DKIM_TRACE(0.00)[kernel.org:+]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CAC5840014 X-Stat-Signature: 6zf4yk89xeppout8n7hb4qmc6en54ua1 X-HE-Tag: 1670281724-118237 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: Document the newly added 'skip_anon' parameter of DAMON_RECLAIM, which can be used to avoid anonymous pages reclamation. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/reclaim.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst index 4f1479a11e63..ff335e96e0d8 100644 --- a/Documentation/admin-guide/mm/damon/reclaim.rst +++ b/Documentation/admin-guide/mm/damon/reclaim.rst @@ -205,6 +205,15 @@ The end physical address of memory region that DAMON_RECLAIM will do work against. That is, DAMON_RECLAIM will find cold memory regions in this region and reclaims. By default, biggest System RAM is used as the region. +skip_anon +--------- + +Skip anonymous pages reclamation. + +If this parameter is set as ``Y``, DAMON_RECLAIM does not reclaim anonymous +pages. By default, ``N``. + + kdamond_pid ----------- From patchwork Mon Dec 5 23:08:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065164 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 7C937C63704 for ; Mon, 5 Dec 2022 23:08:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFCD08E0008; Mon, 5 Dec 2022 18:08:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C5E2C8E0001; Mon, 5 Dec 2022 18:08:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C5208E0008; Mon, 5 Dec 2022 18:08:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8A97A8E0001 for ; Mon, 5 Dec 2022 18:08:41 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1435F1A0BF4 for ; Mon, 5 Dec 2022 23:08:41 +0000 (UTC) X-FDA: 80209794042.06.FBBD379 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 7EA391C0010 for ; Mon, 5 Dec 2022 23:08:40 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jrOqtFOc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281720; 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=oAWeLdbec29o/pQUTk4KG0iaCmNJO1bxhOKX71KFHjw=; b=EXN/If7VEKiOxfnP8yJEDYrgps3euWkxNXFds0XAHlYNEx86b66qun0Cg51cbyhUrgwvp9 updcTBmf7KnQDDxeol+SU83qsIJmJxXhGIHD8TBa7zVQbnUeiBXjiyDKsiZocPxHSIhM+K p1lp4dQnfSX7sk7mbbXVDv3Dn+UOs9w= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jrOqtFOc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281720; a=rsa-sha256; cv=none; b=tO2NT9KQfOWmDmzgEqOwTAK6+NOnWwWDt5UwOgq93+F6xZhEGpzvfzdgU4esHnTdeb7gj3 W78ow+6BElqdvgtmRY1bylkbUQGMHVkVSobhWxD2LdUcpVDGjOC0dEDKXPi+QABFHtw/x3 H4I0ovXzW97dfZlQXaGM/oGdyMa7+xk= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C03C6614A7; Mon, 5 Dec 2022 23:08:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB87EC43150; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281719; bh=MpYV+KbY79xvzeBIqlzmkGgEI6XBAJRwIre/bGlDx34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jrOqtFOcq71qCPzhO6p9V19nT7ndK/ktf8pemOkO/ds3ceglbgw4pBdBGHJXcYuXK B5QxEtOWIvy6mMrfh6WyoGlKsDuZwEUmhs/XJ2EObhf2BzERcjLkvKKuIukv/+mW92 AQSLy7+iW7woDEQkwyqcr5skQlZR9Rrg2M39/yEBfsqKhd1js1Ene52VNP0IQc9LoL 3PTokR6wVqfGVqaEtMBF79FLVdzhBUd8YMVAMU9BlrfdlRbXmF/y2pRo+j8qlYVIo/ Yp/uOGXc0yGOHUKlzPhO3KcQN7fITY8+fyorFvu2Md/9H0phPBnu0F3wlc0kSQhh4X i/nnOsljXmZ7A== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 05/11] mm/damon/sysfs-schemes: implement filters directory Date: Mon, 5 Dec 2022 23:08:24 +0000 Message-Id: <20221205230830.144349-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Spamd-Result: default: False [0.26 / 9.00]; BAYES_HAM(-5.34)[98.55%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 7EA391C0010 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 9wgq3qs6j8t7k3617axph638bc7ctnzs X-HE-Tag: 1670281720-796566 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: DAMOS filters is currently supported by only DAMON kernel API. To expose the feature to user space, implement a DAMON sysfs directory named 'filters' under each scheme directory. Please note that this is implementing only the directory. Following commits will implement more files and directories, and finally connect the DAMOS filters feature. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 85 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 81fc4d27f4e4..50c8148cb474 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -258,6 +258,63 @@ static struct kobj_type damon_sysfs_stats_ktype = { .default_groups = damon_sysfs_stats_groups, }; +/* + * filters directory + */ + +struct damon_sysfs_scheme_filters { + struct kobject kobj; + int nr; +}; + +static struct damon_sysfs_scheme_filters * +damon_sysfs_scheme_filters_alloc(void) +{ + return kzalloc(sizeof(struct damon_sysfs_scheme_filters), GFP_KERNEL); +} + +static ssize_t nr_filters_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_filters *filters = container_of(kobj, + struct damon_sysfs_scheme_filters, kobj); + + return sysfs_emit(buf, "%d\n", filters->nr); +} + +static ssize_t nr_filters_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + int nr, err = kstrtoint(buf, 0, &nr); + + if (err) + return err; + if (nr < 0) + return -EINVAL; + + return count; +} + +static void damon_sysfs_scheme_filters_release(struct kobject *kobj) +{ + kfree(container_of(kobj, struct damon_sysfs_scheme_filters, kobj)); +} + +static struct kobj_attribute damon_sysfs_scheme_filters_nr_attr = + __ATTR_RW_MODE(nr_filters, 0600); + +static struct attribute *damon_sysfs_scheme_filters_attrs[] = { + &damon_sysfs_scheme_filters_nr_attr.attr, + NULL, +}; +ATTRIBUTE_GROUPS(damon_sysfs_scheme_filters); + +static struct kobj_type damon_sysfs_scheme_filters_ktype = { + .release = damon_sysfs_scheme_filters_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_scheme_filters_groups, +}; + /* * watermarks directory */ @@ -784,6 +841,7 @@ struct damon_sysfs_scheme { struct damon_sysfs_access_pattern *access_pattern; struct damon_sysfs_quotas *quotas; struct damon_sysfs_watermarks *watermarks; + struct damon_sysfs_scheme_filters *filters; struct damon_sysfs_stats *stats; struct damon_sysfs_scheme_regions *tried_regions; }; @@ -878,6 +936,24 @@ static int damon_sysfs_scheme_set_watermarks(struct damon_sysfs_scheme *scheme) return err; } +static int damon_sysfs_scheme_set_filters(struct damon_sysfs_scheme *scheme) +{ + struct damon_sysfs_scheme_filters *filters = + damon_sysfs_scheme_filters_alloc(); + int err; + + if (!filters) + return -ENOMEM; + err = kobject_init_and_add(&filters->kobj, + &damon_sysfs_scheme_filters_ktype, &scheme->kobj, + "filters"); + if (err) + kobject_put(&filters->kobj); + else + scheme->filters = filters; + return err; +} + static int damon_sysfs_scheme_set_stats(struct damon_sysfs_scheme *scheme) { struct damon_sysfs_stats *stats = damon_sysfs_stats_alloc(); @@ -926,9 +1002,12 @@ static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme) err = damon_sysfs_scheme_set_watermarks(scheme); if (err) goto put_quotas_access_pattern_out; - err = damon_sysfs_scheme_set_stats(scheme); + err = damon_sysfs_scheme_set_filters(scheme); if (err) goto put_watermarks_quotas_access_pattern_out; + err = damon_sysfs_scheme_set_stats(scheme); + if (err) + goto put_filters_watermarks_quotas_access_pattern_out; err = damon_sysfs_scheme_set_tried_regions(scheme); if (err) goto put_tried_regions_out; @@ -937,6 +1016,9 @@ static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme) put_tried_regions_out: kobject_put(&scheme->tried_regions->kobj); scheme->tried_regions = NULL; +put_filters_watermarks_quotas_access_pattern_out: + kobject_put(&scheme->filters->kobj); + scheme->filters = NULL; put_watermarks_quotas_access_pattern_out: kobject_put(&scheme->watermarks->kobj); scheme->watermarks = NULL; @@ -956,6 +1038,7 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme) damon_sysfs_quotas_rm_dirs(scheme->quotas); kobject_put(&scheme->quotas->kobj); kobject_put(&scheme->watermarks->kobj); + kobject_put(&scheme->filters->kobj); kobject_put(&scheme->stats->kobj); damon_sysfs_scheme_regions_rm_dirs(scheme->tried_regions); kobject_put(&scheme->tried_regions->kobj); From patchwork Mon Dec 5 23:08:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065163 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 BCA0CC4708C for ; Mon, 5 Dec 2022 23:08:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50ED98E0007; Mon, 5 Dec 2022 18:08:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 46EBA8E0001; Mon, 5 Dec 2022 18:08:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2726D8E0007; Mon, 5 Dec 2022 18:08:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 137398E0001 for ; Mon, 5 Dec 2022 18:08:41 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E0CA740C55 for ; Mon, 5 Dec 2022 23:08:40 +0000 (UTC) X-FDA: 80209794000.07.847D2E5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 979092000B for ; Mon, 5 Dec 2022 23:08:40 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YUkqaVKS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281720; 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=6SIrU+qHgmD/alHJaDLXicupWPCEB92hw5xZgg3ikzQ=; b=mFrw/aZHKQqkMqwBb9nLH22Z2DcgNY/X/T7cAMWooWI/XP7HtLBFz/ni3Mzlti9wmmyxTq PACauT5UpEe0MBWCXZ/j42OKzLRXdjY/VWTjt9rq+qjm05nGLZJsUdntjbzb/KC6wbemoT H5pxZxavXkixnLn4bKuhIQlajI5VCXI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YUkqaVKS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281720; a=rsa-sha256; cv=none; b=DFE13eNfFk7bEfloccQ6lkuJB0VTxbr/SCjYwZP98QUE+WCxxAl1Jy134K0daVd3roc0rO J24CsQBOtFi9TbZQeJKrQ6d6BqPphmwIfgqH1atcmtWAWRH8b5PcdarfPV2cNjBfmKX4Ln HBnlvolenlvnZAyKhqKfhD4BiF/2J4Y= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA434614CA; Mon, 5 Dec 2022 23:08:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F026C433D6; Mon, 5 Dec 2022 23:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281719; bh=KP45fkenUtVNkuekA5wpVSKSKg+M620wUBu7fatA2gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YUkqaVKSH3C/skAJJU1XZFSGjNvz+JOJJWRnZ5XtjszTIzwOpUh4pjUCZTrrOwXAT bFSmtLVDGZER/Az8C7PjezIHAT4JlOqfi9TAGN/0mcz3WDm8cmNVc4yBn4zNi3RAZ/ DmhCB1GIVkVEXGMHS/kH6CRjtTSn+1CatzHn8g/uKFjDRGEKMf9YqjFTpp2PT/qbDb WlXPLxuGxYUXKKs59TePia0AkcOTAyJ2ZzOQSTjszfS0uAvBYQvkBM9m3rcuYZRrBc AmkFiri3/8jsmiAzeSUpNskE/fX3fHK0/Ia3Uk2ZWJvdSMTsUclzavi9uMo8iK8GqP L/IIAH/E655uQ== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 06/11] mm/damon/sysfs-schemes: implement filter directory Date: Mon, 5 Dec 2022 23:08:25 +0000 Message-Id: <20221205230830.144349-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Spamd-Result: default: False [-0.20 / 9.00]; BAYES_HAM(-5.80)[99.57%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org:c]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 979092000B X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 6ig9qriosxchbs5sa69d84mximwqh6qs X-HE-Tag: 1670281720-805272 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: Implement DAMOS filter directory which will be located under the filters directory. The directory provides three files, namely type, matching, and memcg_path. 'type' and 'matching' will be directly connected to the fields of 'struct damos_filter' having same name. 'memcg_path' will receive the path of the memory cgroup of the interest and later converted to memcg id when it's committed. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 128 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 50c8148cb474..afbfc55a8e84 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -258,6 +258,134 @@ static struct kobj_type damon_sysfs_stats_ktype = { .default_groups = damon_sysfs_stats_groups, }; +/* + * filter directory + */ + +struct damon_sysfs_scheme_filter { + struct kobject kobj; + enum damos_filter_type type; + bool matching; + char *memcg_path; +}; + +/* Should match with enum damos_filter_type */ +static const char * const damon_sysfs_scheme_filter_type_strs[] = { + "anon", + "memcg", +}; + +static ssize_t type_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + + return sysfs_emit(buf, "%s\n", + damon_sysfs_scheme_filter_type_strs[filter->type]); +} + +static ssize_t type_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + enum damos_filter_type type; + ssize_t ret = -EINVAL; + + for (type = 0; type < NR_DAMOS_FILTER_TYPES; type++) { + if (sysfs_streq(buf, damon_sysfs_scheme_filter_type_strs[ + type])) { + filter->type = type; + ret = count; + break; + } + } + return ret; +} + +static ssize_t matching_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + + return sysfs_emit(buf, "%c\n", filter->matching ? 'Y' : 'N'); +} + +static ssize_t matching_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + bool matching; + int err = kstrtobool(buf, &matching); + + if (err) + return err; + + filter->matching = matching; + return count; +} + +static ssize_t memcg_path_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + + return sysfs_emit(buf, "%s\n", + filter->memcg_path ? filter->memcg_path : ""); +} + +static ssize_t memcg_path_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + char *path = kmalloc(sizeof(*path) * (count + 1), GFP_KERNEL); + + if (!path) + return -ENOMEM; + + strncpy(path, buf, count); + path[count] = '\0'; + filter->memcg_path = path; + return count; +} + +static void damon_sysfs_scheme_filter_release(struct kobject *kobj) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + + kfree(filter->memcg_path); + kfree(filter); +} + +static struct kobj_attribute damon_sysfs_scheme_filter_type_attr = + __ATTR_RW_MODE(type, 0600); + +static struct kobj_attribute damon_sysfs_scheme_filter_matching_attr = + __ATTR_RW_MODE(matching, 0600); + +static struct kobj_attribute damon_sysfs_scheme_filter_memcg_path_attr = + __ATTR_RW_MODE(memcg_path, 0600); + +static struct attribute *damon_sysfs_scheme_filter_attrs[] = { + &damon_sysfs_scheme_filter_type_attr.attr, + &damon_sysfs_scheme_filter_matching_attr.attr, + &damon_sysfs_scheme_filter_memcg_path_attr.attr, + NULL, +}; +ATTRIBUTE_GROUPS(damon_sysfs_scheme_filter); + +static struct kobj_type damon_sysfs_scheme_filter_ktype = { + .release = damon_sysfs_scheme_filter_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_scheme_filter_groups, +}; + /* * filters directory */ From patchwork Mon Dec 5 23:08:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065165 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 7F8FEC63705 for ; Mon, 5 Dec 2022 23:08:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E03A8E000A; Mon, 5 Dec 2022 18:08:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 642438E0001; Mon, 5 Dec 2022 18:08:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383C88E0009; Mon, 5 Dec 2022 18:08:42 -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 29B598E0001 for ; Mon, 5 Dec 2022 18:08:42 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EFCCC1C64A6 for ; Mon, 5 Dec 2022 23:08:41 +0000 (UTC) X-FDA: 80209794042.26.CA825EB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 8E1692000D for ; Mon, 5 Dec 2022 23:08:41 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LiP2vcVc; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281721; a=rsa-sha256; cv=none; b=lV80VYQN7Ma1c4Eerh+8ZzCfMrwxOd0+lSxtprW5MPqncHqRTNpRSgYcnukBqzsRnakp39 s76LNoRr5n5KYdPx8emizJ1av6HkEZx53Z3P/7JT7yVs0GwG5wDdETJDeDZZLfu5eTnslQ 3rspNPgMBFgtDufSG+RI8pY++7WEMQs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LiP2vcVc; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281721; 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=Pp1yUJLa+MIK3wToikS/B21yRm2JhREhRKEMfqbq6ds=; b=s6jw8kjWq6cvZmTT+xEe23tqPqsvn/U+Wi/qj6sgWp6VNtkUr1z555647KFS5XG59JJmrx yZnQ2OvzRR5PRBRY3hwcB4D/1QXy34g0L/YZmJR0gcLTjIDDubpPvYopF0fZUSDdz1AS5P Xql2i8Qn2xNFVKooyHwlq/Es42xtRQo= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 853A2614BF; Mon, 5 Dec 2022 23:08:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F09CDC43141; Mon, 5 Dec 2022 23:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281720; bh=5gMO8cLybx9rIEkN5/YUfJzDl3RNG0bek/qaVakfGfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LiP2vcVcBH/ViJzcxFOdvs7s/0ZOLtF88q4fj24PDoJGfxkBZjEF8SXWCNKmTEl2v doSq1h0O0yLwR6AujiHFTLkm2uTaqqpxul11peFqTmBfzkwYqAsM7opXy4CKcP2GZU V0XivkIlN1gRGQk0CakM7U7GSLsyXBq93UQMdhNJ4AsHvYcWhZHuz6ZP6sxGe6AsDG bVhzMIt+5pNU04+9c80VMWLkZ3mfZ+t/ic3yCqjXHIIn0skiSH9EfmNJPrwFvlh0vv D3qPnFwH05tjEQeJo3ZNrv58MvU65bCrn3ha3yrT1Wve2Tk3NOvnin9kCr+R+m8eN6 csTQbzfoWVcuQ== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 07/11] mm/damon/sysfs-schemes: connect filter directory and filters directory Date: Mon, 5 Dec 2022 23:08:26 +0000 Message-Id: <20221205230830.144349-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Spamd-Result: default: False [0.74 / 9.00]; BAYES_HAM(-4.86)[97.39%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org:c]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 8E1692000D X-Rspamd-Server: rspam01 X-Stat-Signature: akty9ixe3nzqyxrr6yqgjrnrtesnyzu9 X-HE-Tag: 1670281721-501866 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: Implement 'nr_filters' file under 'filters' directory, which will be used to populate specific number of 'filter' directory under the directory, similar to other 'nr_*' files in DAMON sysfs interface. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index afbfc55a8e84..e79c678a69d5 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -269,6 +269,11 @@ struct damon_sysfs_scheme_filter { char *memcg_path; }; +static struct damon_sysfs_scheme_filter *damon_sysfs_scheme_filter_alloc(void) +{ + return kzalloc(sizeof(struct damon_sysfs_scheme_filter), GFP_KERNEL); +} + /* Should match with enum damos_filter_type */ static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", @@ -392,6 +397,7 @@ static struct kobj_type damon_sysfs_scheme_filter_ktype = { struct damon_sysfs_scheme_filters { struct kobject kobj; + struct damon_sysfs_scheme_filter **filters_arr; int nr; }; @@ -401,6 +407,57 @@ damon_sysfs_scheme_filters_alloc(void) return kzalloc(sizeof(struct damon_sysfs_scheme_filters), GFP_KERNEL); } +static void damon_sysfs_scheme_filters_rm_dirs( + struct damon_sysfs_scheme_filters *filters) +{ + struct damon_sysfs_scheme_filter **filters_arr = filters->filters_arr; + int i; + + for (i = 0; i < filters->nr; i++) + kobject_put(&filters_arr[i]->kobj); + filters->nr = 0; + kfree(filters_arr); + filters->filters_arr = NULL; +} + +static int damon_sysfs_scheme_filters_add_dirs( + struct damon_sysfs_scheme_filters *filters, int nr_filters) +{ + struct damon_sysfs_scheme_filter **filters_arr, *filter; + int err, i; + + damon_sysfs_scheme_filters_rm_dirs(filters); + if (!nr_filters) + return 0; + + filters_arr = kmalloc_array(nr_filters, sizeof(*filters_arr), + GFP_KERNEL | __GFP_NOWARN); + if (!filters_arr) + return -ENOMEM; + filters->filters_arr = filters_arr; + + for (i = 0; i < nr_filters; i++) { + filter = damon_sysfs_scheme_filter_alloc(); + if (!filter) { + damon_sysfs_scheme_filters_rm_dirs(filters); + return -ENOMEM; + } + + err = kobject_init_and_add(&filter->kobj, + &damon_sysfs_scheme_filter_ktype, + &filters->kobj, "%d", i); + if (err) { + kobject_put(&filter->kobj); + damon_sysfs_scheme_filters_rm_dirs(filters); + return err; + } + + filters_arr[i] = filter; + filters->nr++; + } + return 0; +} + static ssize_t nr_filters_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -413,6 +470,7 @@ static ssize_t nr_filters_show(struct kobject *kobj, static ssize_t nr_filters_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { + struct damon_sysfs_scheme_filters *filters; int nr, err = kstrtoint(buf, 0, &nr); if (err) @@ -420,6 +478,15 @@ static ssize_t nr_filters_store(struct kobject *kobj, if (nr < 0) return -EINVAL; + filters = container_of(kobj, struct damon_sysfs_scheme_filters, kobj); + + if (!mutex_trylock(&damon_sysfs_lock)) + return -EBUSY; + err = damon_sysfs_scheme_filters_add_dirs(filters, nr); + mutex_unlock(&damon_sysfs_lock); + if (err) + return err; + return count; } @@ -1166,6 +1233,7 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme) damon_sysfs_quotas_rm_dirs(scheme->quotas); kobject_put(&scheme->quotas->kobj); kobject_put(&scheme->watermarks->kobj); + damon_sysfs_scheme_filters_rm_dirs(scheme->filters); kobject_put(&scheme->filters->kobj); kobject_put(&scheme->stats->kobj); damon_sysfs_scheme_regions_rm_dirs(scheme->tried_regions); From patchwork Mon Dec 5 23:08:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065166 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 9520BC47089 for ; Mon, 5 Dec 2022 23:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAD948E0001; Mon, 5 Dec 2022 18:08:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC1AE8E0009; Mon, 5 Dec 2022 18:08:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3AFC8E0001; Mon, 5 Dec 2022 18:08:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6A7D18E0009 for ; Mon, 5 Dec 2022 18:08:42 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 42C781406FD for ; Mon, 5 Dec 2022 23:08:42 +0000 (UTC) X-FDA: 80209794084.23.77D9554 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id D19BB40013 for ; Mon, 5 Dec 2022 23:08:41 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DP0dV1am; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281722; 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=n5cK+e8f/OeVSbjmEapDXFxy7TvX9zLQMLpRsluJV5U=; b=l3PkiX/Yyulk/U21aNLwnHIJ+OqK1GKOf8J3/sU88BjQq4Hmr8jthQJ7Ck8DVXqyfS58Ce Zmh/jMacErrLACc0C7fnEdAkc0hIlgMGwV8wimQJs3UPiGc04GsSql6NX17Q1JU5NJZfwR hXYc7d1YiR3GLhhbfmVCefzUU97ksc8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DP0dV1am; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281722; a=rsa-sha256; cv=none; b=ryizR4DWD+E0czG862ahBT9YFym+dWgXFH6Fhn5LdODG5p3t7G/t3S02CUq79vZxXC8Wsi hBBCob2CkDuMFrnO5CV2GulwwmqTWlSNVSFAWjuk+2sRHCKbpQfuf5421T17N/JOJIUHDX CtHKqbaen88SOz8ng6nVRGnBNtIEveo= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 205C1614C1; Mon, 5 Dec 2022 23:08:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BC9BC43470; Mon, 5 Dec 2022 23:08:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281720; bh=np2Yu8Q2x8gtS0MXr5n11c7mRGrlDAkmbbQ8z9YhO6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DP0dV1am6uTMREEzJ9WKKgke+T/riNJL/iI1dDL41RwlOuTyssvVKlRN5qDlJgFwr /N/4QwwW3Ptpb7mmbY6xxlU/g8GUDB3eEs3A5mBxM73fb3VBGYkg94yS2jeBUqmpKu eBOIZS4vKsEhEAqmWEHbPdw3I1HCnbRenBxa5EmjrX6zqG87OsYkQrzP3SIbBuoltz lQvthVZQOyEF7pQMtw/RtE3C7ECAJ7W0zah2+xIH+wEPUfIrA/qeaGjEw/54LeIihb Y0406Rr0xFGm+Nh5fALz77fQ/m/QN7L0mUcBFYdxZvLu0pb2Ay+0WKTwoYR/GrA/Fk kaqY9U/q8wOJw== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 08/11] mm/damon/sysfs-schemes: implement scheme filters Date: Mon, 5 Dec 2022 23:08:27 +0000 Message-Id: <20221205230830.144349-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D19BB40013 X-Stat-Signature: sdozdcfr14duks6dpk3y41k5kfe1qq5g X-Spamd-Result: default: False [-0.38 / 9.00]; BAYES_HAM(-5.98)[99.96%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-HE-Tag: 1670281721-77583 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: Implement scheme filters functionality of DAMON sysfs interface by making the code reads the values of files under the filter directories and pass that to DAMON using DAMON kernel API. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 89 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index e79c678a69d5..0501862534f2 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1403,6 +1403,75 @@ struct kobj_type damon_sysfs_schemes_ktype = { .default_groups = damon_sysfs_schemes_groups, }; +static bool damon_sysfs_memcg_path_eq(struct mem_cgroup *memcg, + char *memcg_path_buf, char *path) +{ +#ifdef CONFIG_MEMCG + cgroup_path(memcg->css.cgroup, memcg_path_buf, PATH_MAX); + if (sysfs_streq(memcg_path_buf, path)) + return true; +#endif /* CONFIG_MEMCG */ + return false; +} + +static int damon_sysfs_memcg_path_to_id(char *memcg_path, unsigned short *id) +{ + struct mem_cgroup *memcg; + char *path; + + if (!memcg_path) + return -EINVAL; + + path = kmalloc(sizeof(*path) * PATH_MAX, GFP_KERNEL); + if (!path) + return -ENOMEM; + + for (memcg = mem_cgroup_iter(NULL, NULL, NULL); memcg; + memcg = mem_cgroup_iter(NULL, memcg, NULL)) { + /* skip removed memcg */ + if (!mem_cgroup_id(memcg)) + continue; + if (damon_sysfs_memcg_path_eq(memcg, path, memcg_path)) { + *id = mem_cgroup_id(memcg); + break; + } + } + + kfree(path); + return 0; +} + +static int damon_sysfs_set_scheme_filters(struct damos *scheme, + struct damon_sysfs_scheme_filters *sysfs_filters) +{ + int i; + struct damos_filter *filter, *next; + + damos_for_each_filter_safe(filter, next, scheme) + damos_destroy_filter(filter); + + for (i = 0; i < sysfs_filters->nr; i++) { + struct damon_sysfs_scheme_filter *sysfs_filter = + sysfs_filters->filters_arr[i]; + struct damos_filter *filter = + damos_new_filter(sysfs_filter->type, + sysfs_filter->matching); + int err; + + if (!filter) + return -ENOMEM; + if (filter->type == DAMOS_FILTER_TYPE_MEMCG) { + err = damon_sysfs_memcg_path_to_id( + sysfs_filter->memcg_path, + &filter->memcg_id); + if (err) + return err; + } + damos_add_filter(scheme, filter); + } + return 0; +} + static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_scheme *sysfs_scheme) { @@ -1411,6 +1480,10 @@ static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_quotas *sysfs_quotas = sysfs_scheme->quotas; struct damon_sysfs_weights *sysfs_weights = sysfs_quotas->weights; struct damon_sysfs_watermarks *sysfs_wmarks = sysfs_scheme->watermarks; + struct damon_sysfs_scheme_filters *sysfs_filters = + sysfs_scheme->filters; + struct damos *scheme; + int err; struct damos_access_pattern pattern = { .min_sz_region = access_pattern->sz->min, @@ -1436,8 +1509,17 @@ static struct damos *damon_sysfs_mk_scheme( .low = sysfs_wmarks->low, }; - return damon_new_scheme(&pattern, sysfs_scheme->action, "a, + scheme = damon_new_scheme(&pattern, sysfs_scheme->action, "a, &wmarks); + if (!scheme) + return NULL; + + err = damon_sysfs_set_scheme_filters(scheme, sysfs_filters); + if (err) { + damon_destroy_scheme(scheme); + return NULL; + } + return scheme; } static void damon_sysfs_update_scheme(struct damos *scheme, @@ -1448,6 +1530,7 @@ static void damon_sysfs_update_scheme(struct damos *scheme, struct damon_sysfs_quotas *sysfs_quotas = sysfs_scheme->quotas; struct damon_sysfs_weights *sysfs_weights = sysfs_quotas->weights; struct damon_sysfs_watermarks *sysfs_wmarks = sysfs_scheme->watermarks; + int err; scheme->pattern.min_sz_region = access_pattern->sz->min; scheme->pattern.max_sz_region = access_pattern->sz->max; @@ -1470,6 +1553,10 @@ static void damon_sysfs_update_scheme(struct damos *scheme, scheme->wmarks.high = sysfs_wmarks->high; scheme->wmarks.mid = sysfs_wmarks->mid; scheme->wmarks.low = sysfs_wmarks->low; + + err = damon_sysfs_set_scheme_filters(scheme, sysfs_scheme->filters); + if (err) + damon_destroy_scheme(scheme); } int damon_sysfs_set_schemes(struct damon_ctx *ctx, From patchwork Mon Dec 5 23:08:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065167 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 D93B1C63704 for ; Mon, 5 Dec 2022 23:08:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B26A88E000B; Mon, 5 Dec 2022 18:08:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A62228E0009; Mon, 5 Dec 2022 18:08:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 818978E000B; Mon, 5 Dec 2022 18:08:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6AC768E0009 for ; Mon, 5 Dec 2022 18:08:43 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3A762AB205 for ; Mon, 5 Dec 2022 23:08:43 +0000 (UTC) X-FDA: 80209794126.14.D59AF4C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id E07201A000D for ; Mon, 5 Dec 2022 23:08:42 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=k78k7YEx; spf=pass (imf19.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281722; a=rsa-sha256; cv=none; b=l+GMmyUETJIYuLO2nmeeGNMOgURuIf/ItdlBxLMB/XEMK2VdP3XPmYpN8+XXsKLZMQBwX/ psLIJz3Y3ULRZcTlcKVceNlyY3rxrZfPJ6z21qQyndQtyqX8NRaWp8vNHBUWr8Y4dk1+PO qrsa5bOkZSxSCOF8/CHqB4pQxwhArhQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=k78k7YEx; spf=pass (imf19.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281722; 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=+OTj21n3Wg9gwrrIBxAx4NidZtXBp6SPjJpmtwVGK9A=; b=xgnWRUpWCrHEU+7N13DbaeF3BXgnrKDnUJl/D+W8zoSNdZQMl45dvOecWci7NvPYRbB8x4 R1Qs6cukuTc5khm1r4f0yrP00+KFvShlFkIwmuEm28JWRvfQeAGfs5nMuJo1LK8nVV7oVa qkmYoSJd2iTtjERoyahrkCXu64a7vt0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3DB57614C1; Mon, 5 Dec 2022 23:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28A3AC433D6; Mon, 5 Dec 2022 23:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281721; bh=qgpIYxCoLxiSbmookPCEJSX95mijzZoDksXEWue5IhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k78k7YExuF6/YEEvcLQCrdPFVM8+qZ66Sw1wGSQt1vOP6nrkfOevcW9LvmA+peVW5 aDGsFBfIOyR+pD6XRfeyIyNJq6d6quIA1qUV451ks6L5wwqGhGcaPKXvj6Pg0kIFn8 BATF7tCEg6mGkduLufzPqMOvR3R8PoZDrrnIHcIW9nNoWcaXgzH/V7/0z03ujbr1AS Azx5pHsw1fGteX+pc6NdS8LbE1lyO4RXhdINeyGAhRwyiQMBg+5EleKrTIgEnfU5Nk zfHofzo5dszklOcY3XDH/svZ9cz0X2+TqTsRq03hk8zd9m38KcvvTi3p0Bke4T1KDM bGdKopAY9JjLQ== From: SeongJae Park To: Andrew Morton Cc: Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 09/11] selftests/damon/sysfs: test filters directory Date: Mon, 5 Dec 2022 23:08:28 +0000 Message-Id: <20221205230830.144349-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Spamd-Result: default: False [-0.09 / 9.00]; BAYES_HAM(-5.69)[99.33%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; RCPT_COUNT_SEVEN(0.00)[7]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org:c]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: E07201A000D X-Rspamd-Server: rspam01 X-Stat-Signature: 6d6aybeh9ssnxdz5nqe6856yfy7s4f9n X-HE-Tag: 1670281722-708946 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: Add simple test cases for scheme filters of DAMON sysfs interface. The test cases check if the files are populated as expected, receives some valid inputs, and refuses some invalid inputs. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/sysfs.sh | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh index db4942383a50..a00336ffdcad 100644 --- a/tools/testing/selftests/damon/sysfs.sh +++ b/tools/testing/selftests/damon/sysfs.sh @@ -96,6 +96,34 @@ test_stats() done } +test_filter() +{ + filter_dir=$1 + ensure_file "$filter_dir/type" "exist" "600" + ensure_write_succ "$filter_dir/type" "anon" "valid input" + ensure_write_succ "$filter_dir/type" "memcg" "valid input" + ensure_write_fail "$filter_dir/type" "foo" "invalid input" + ensure_file "$filter_dir/matching" "exist" "600" + ensure_file "$filter_dir/memcg_path" "exist" "600" +} + +test_filters() +{ + filters_dir=$1 + ensure_dir "$filters_dir" "exist" + ensure_file "$filters_dir/nr_filters" "exist" "600" + ensure_write_succ "$filters_dir/nr_filters" "1" "valid input" + test_filter "$filters_dir/0" + + ensure_write_succ "$filters_dir/nr_filters" "2" "valid input" + test_filter "$filters_dir/0" + test_filter "$filters_dir/1" + + ensure_write_succ "$filters_dir/nr_filters" "0" "valid input" + ensure_dir "$filters_dir/0" "not_exist" + ensure_dir "$filters_dir/1" "not_exist" +} + test_watermarks() { watermarks_dir=$1 @@ -143,6 +171,7 @@ test_scheme() test_access_pattern "$scheme_dir/access_pattern" test_quotas "$scheme_dir/quotas" test_watermarks "$scheme_dir/watermarks" + test_filters "$scheme_dir/filters" test_stats "$scheme_dir/stats" test_tried_regions "$scheme_dir/tried_regions" } From patchwork Mon Dec 5 23:08:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065168 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 0CA3DC4708E for ; Mon, 5 Dec 2022 23:08:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FC958E000D; Mon, 5 Dec 2022 18:08:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BF7F8E000C; Mon, 5 Dec 2022 18:08:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 052108E000D; Mon, 5 Dec 2022 18:08:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D906C8E0009 for ; Mon, 5 Dec 2022 18:08:43 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9DA20AB21B for ; Mon, 5 Dec 2022 23:08:43 +0000 (UTC) X-FDA: 80209794126.14.54689ED Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 4E221A0006 for ; Mon, 5 Dec 2022 23:08:43 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="TpC/jo3F"; 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=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281723; a=rsa-sha256; cv=none; b=kzNSoZ91gBGTQweKi1KbCEhIcqn4OiHZB2mxTfiQkVCXMFV5QiFYoyK0B2q+R0kmj1Z4te sTB3rz+V1jor4gcdm32ByZPTcIqh6BAw36bhna+QVoW76GO6BKFzYWWxYDOP/HinAHdL/D 3IEpN8mBJn+CweEndsW16OKcKkk73Cc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="TpC/jo3F"; 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=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281723; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gpmeBORiZpRF2beWDn7dZTCiE/JqtbjFsMCpo3MlrhI=; b=xyxSdnFIeUETdSyO9ygFNuBmaPiRrKyKloazlmprZ0Yhh7qXfUSrWZpc3Ar5mxgDJITOmi WI4ylzZy+aTRmtG9vN+kuywn4ys9S+Zr0O0rd1YbKt0duhrW1BA2Pk6lM3/ue2aGJAFy/6 ItUMVIr1sddMMDgqhSaT6iWVO5FMKaU= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 86A83614C7; Mon, 5 Dec 2022 23:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D54E3C433B5; Mon, 5 Dec 2022 23:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281722; bh=r1rD9KyNMBqJg8aGe8o3Z8JXG+myDQ882BtgLSHPqNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TpC/jo3FRVmu71R9MEs5kfN81AQUSgkCo1RtoY8sR8M5AhiTlSFop6eidAkEL500R 3WWeMUWcyVAticHGeqK/2aoP8zJ2gfXDWFu0DRK+hzXV2/39r+iQZYfw63lsFkytSN wOQZ5WYoYuankdXi/+EmB2YQYxAiySX71ZEFP5fi870/7LjhHr9MA18flwOrJ3jfAU deKq/xJ+DW/jCprrJLiuNPeBq/OuVw/y5UTtOZ6Q2bVccJDKKRGeXg5n55Rl2VfBSN 6Vb0MObMeDp4t09OaVDRWiRflX+wMpfxXXb6pqRqdmoXfABnsVMwFcPmCptnviYamo +bBIg9JrEMXgQ== From: SeongJae Park To: Andrew Morton , Jonathan Corbet Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 10/11] Docs/admin-guide/mm/damon/usage: document DAMOS filters of sysfs Date: Mon, 5 Dec 2022 23:08:29 +0000 Message-Id: <20221205230830.144349-11-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.90 / 9.00]; BAYES_HAM(-6.00)[100.00%]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; RCPT_COUNT_SEVEN(0.00)[7]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4E221A0006 X-Stat-Signature: 9amayx71mt18671w5fb365q57gbo9rdg X-HE-Tag: 1670281723-125047 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: Document about the newly added files for DAMOS filters on the DAMON usage document. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 48 +++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 1a5b6b71efa1..3d82ca6a17ff 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -87,6 +87,8 @@ comma (","). :: │ │ │ │ │ │ │ quotas/ms,bytes,reset_interval_ms │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil │ │ │ │ │ │ │ watermarks/metric,interval_us,high,mid,low + │ │ │ │ │ │ │ filters/nr_filters + │ │ │ │ │ │ │ │ 0/type,matching,memcg_id │ │ │ │ │ │ │ stats/nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds │ │ │ │ │ │ │ tried_regions/ │ │ │ │ │ │ │ │ 0/start,end,nr_accesses,age @@ -151,6 +153,8 @@ number (``N``) to the file creates the number of child directories named as moment, only one context per kdamond is supported, so only ``0`` or ``1`` can be written to the file. +.. _sysfs_contexts: + contexts// ------------- @@ -268,8 +272,8 @@ schemes// ------------ In each scheme directory, five directories (``access_pattern``, ``quotas``, -``watermarks``, ``stats``, and ``tried_regions``) and one file (``action``) -exist. +``watermarks``, ``filters``, ``stats``, and ``tried_regions``) and one file +(``action``) exist. The ``action`` file is for setting and getting what action you want to apply to memory regions having specific access pattern of the interest. The keywords @@ -347,6 +351,46 @@ as below. The ``interval`` should written in microseconds unit. +schemes//filters/ +-------------------- + +Users could know something more than the kernel for specific types of memory. +In the case, users could do their own management for the memory and hence +doesn't want DAMOS bothers that. Users could limit DAMOS by setting the access +pattern of the scheme and/or the monitoring regions for the purpose, but that +can be inefficient in some cases. In such cases, users could set non-access +pattern driven filters using files in this directory. + +In the beginning, this directory has only one file, ``nr_filters``. Writing a +number (``N``) to the file creates the number of child directories named ``0`` +to ``N-1``. Each directory represents each filter. The filters are evaluated +in the numeric order. + +Each filter directory contains three files, namely ``type``, ``matcing``, and +``memcg_path``. You can write one of two special keywords, ``anon`` for +anonymous pages, or ``memcg`` for specific memory cgroup filtering. In case of +the memory cgroup filtering, you can specify the memory cgroup of the interest +by writing the path of the memory cgroup from the cgroups mount point to +``memcg_path`` file. You can write ``Y`` or ``N`` to ``matching`` file to +filter out pages that does or does not match to the type, respectively. Then, +the scheme's action will not be applied to the pages that specified to be +filtered out. + +For example, below restricts a DAMOS action to be applied to only non-anonymous +pages of all memory cgroups except ``/having_care_already``.:: + + # echo 2 > nr_filters + # # filter out anonymous pages + echo anon > 0/type + echo Y > 0/matching + # # further filter out all cgroups except one at '/having_care_already' + echo memcg > 1/type + echo /having_care_already > 1/memcg_path + echo N > 1/matching + +Note that filters could be ignored depend on the running DAMON operations set +`implementation `. + .. _sysfs_schemes_stats: schemes//stats/ From patchwork Mon Dec 5 23:08:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065170 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 3FBDAC47089 for ; Mon, 5 Dec 2022 23:08:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 732B18E0009; Mon, 5 Dec 2022 18:08:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 620108E000E; Mon, 5 Dec 2022 18:08:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 114B98E0009; Mon, 5 Dec 2022 18:08:44 -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 EC8AB8E000C for ; Mon, 5 Dec 2022 18:08:43 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C0338AB22A for ; Mon, 5 Dec 2022 23:08:43 +0000 (UTC) X-FDA: 80209794126.10.A4481E3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 6695940015 for ; Mon, 5 Dec 2022 23:08:43 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YxuueYy6; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281723; 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=TLb5XnMDpgcYHy4frIqgmGqxPwmmsgK8DLbiJhJicSI=; b=4P2BGOHs9hBut9kMAG5aMzfQOlslcyTn2anlmNp5m8Xznlx279WpQadefUwcDj7HvL7e2o hg7w5QgVWUfJMHnywoE741o7Pw9GVHR7jGrYJdWMNHlsRvPhWRCew4WnVeedYD32eYAaNu hrGGF3St+wMLBzTekcRktPeAXFBfnNI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YxuueYy6; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281723; a=rsa-sha256; cv=none; b=Otlg05QIdTzK2/A15CPCGnFL89UMh3gI4RmvYtgXE/pG8cSbbLwrq0lj2Kyv3bdZtaVWvR SGaJiStSxNmr1eYi0Y/ZJMHbjzUPbHkP0HvkpnKLI2fg5wDhRudzeaOnJAPiLwqwJegXtw HfVUqlaRyNXCN45K3dMTxW7I+rzY2fU= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1DB13614B6; Mon, 5 Dec 2022 23:08:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DF90C4347C; Mon, 5 Dec 2022 23:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281722; bh=wsgdvbT/35uxHZu2m3onVtLPaAGvmOTx9y/8CzTLOOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxuueYy6qYjuBFiqjlcV+iqd+nixVioCIjejoFvrmzrck0sfJmflNmEaibMAmS2cK saItIFUp+3KFIBvFbvXO4X8DAPx0A0haX9DFhplRRGpPVLocjF4JtbjhTiJfSzc5n4 KC1AWOFwDyT8pNFPPVXWgdQltdhDCdQDIMAQ0ItUrQJ3WeN97A/G/7xjUJBYC0ICV8 C/RsAqjJmmbNvecUyMc3T5YA6zt4xMvYGDdAhb8g/FhdBcgTB26jeXdXCSFNBao4++ CMNsro6B6M1cmI2DeQVZyu4oEdlepLiwuFz1f/NVBj5ideR96UWuwDJTUQPaD/+9y8 H+hLjnRCAI1Kw== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 11/11] Docs/ABI/damon: document scheme filters files Date: Mon, 5 Dec 2022 23:08:30 +0000 Message-Id: <20221205230830.144349-12-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6695940015 X-Stat-Signature: ek6fifdhujc557oc5ebpty9tmywtszic X-Spamd-Result: default: False [5.45 / 9.00]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; BAYES_HAM(-0.15)[62.96%]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; BAD_REP_POLICIES(0.10)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-HE-Tag: 1670281723-148185 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: Document newly added DAMON sysfs interface files for DAMOS filtering on the DAMON ABI document. Signed-off-by: SeongJae Park --- .../ABI/testing/sysfs-kernel-mm-damon | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index 13397b853692..2744f21b5a6b 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -258,6 +258,35 @@ Contact: SeongJae Park Description: Writing to and reading from this file sets and gets the low watermark of the scheme in permil. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters/nr_filters +Date: Dec 2022 +Contact: SeongJae Park +Description: Writing a number 'N' to this file creates the number of + directories for setting filters of the scheme named '0' to + 'N-1' under the filters/ directory. + +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//type +Date: Dec 2022 +Contact: SeongJae Park +Description: Writing to and reading from this file sets and gets the type of + the memory of the interest. 'anon' for anonymous pages, or + 'memcg' for specific memory cgroup can be written and read. + +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//memcg_path +Date: Dec 2022 +Contact: SeongJae Park +Description: If 'memcg' is written to the 'type' file, writing to and + reading from this file sets and gets the path to the memory + cgroup of the interest. + +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//matching +Date: Dec 2022 +Contact: SeongJae Park +Description: Writing 'Y' or 'N' to this file sets whether to filter out + pages that do or do not match to the 'type' and 'memcg_path', + respectively. Filter out means the action of the scheme will + not be applied to. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//stats/nr_tried Date: Mar 2022 Contact: SeongJae Park