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: 29997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2519945wrr; Mon, 5 Dec 2022 15:09:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf5q0/M/D2dFEIZ/4KMal73CYPqJZSC91FJh/+rRqzBoGvVcl9R5RhWxKdD8OMIkoF+NJWOt X-Received: by 2002:a17:902:ccca:b0:186:6c10:7260 with SMTP id z10-20020a170902ccca00b001866c107260mr72463285ple.26.1670281783115; Mon, 05 Dec 2022 15:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281783; cv=none; d=google.com; s=arc-20160816; b=fs5+3qImfakYDz5lrNYLUst9xt9aJME9Ft4RyR90BWm9YcONqnVoIep5UPIGRrQXG9 MCxLVl6GGRwbwOTXE1kiU0jehU3LJQThmdaxMwMlXTIuEu9B6XktTz0qsCIb+t141gbL CfXtMoH07Elohb5B85nU6BrTCu4kF90R46r7gY+ky9fhs5a/wY61ZmNb9yIMFV8B6P8R 3rpDmCgWTwPkUKLQEWb+n5OuzTny/SntKzPnfaYhnrlCxsv/nZ6GemlsQCqLpbxon6a5 QY6dhUZen6PfsyWvvVB9k6rCFMr4K1ekULMZBmdpmshB+FchZyeYy3ZDJBt7p0q37tN4 PAUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JFDni24s97g4FVNUvLRr5WSpQRnQvRVE2KEbE4cdgMw=; b=Tby3bgfun0z+KkNb3EW3SvvZvWN+otia+sWPHkkxgXaNrKIOR06SXPfh32XlEBdSNC bLUsvvzsiuso++wBLMPN2RYmFY+bLahtkQ3CP5tc7AWC/tHSs25/61gJgObrOL53PLso oMA3zsQrLEABRI6SNZTHcy7JGxZIVKSmlUC8YCtwnZ0hN2t0jWzDzJPgHXWmarku5G+q aNsvXx8vBskenmia+z0EEx5zy/8smwG9fgksZm6ueOZU/nSLjVRa2TCJClKL55Bw1PsP 1ocA5KIrds7g0PPBwVmwdvpn+2dKoJZla1pQxYl7rdBQf7hDLU4eah6ziq5Yxvyi1PKV uWSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LhojvW68; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020a170903245200b001893689660asi17009523pls.209.2022.12.05.15.09.29; Mon, 05 Dec 2022 15:09:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LhojvW68; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233311AbiLEXJF (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231837AbiLEXIk (ORCPT ); Mon, 5 Dec 2022 18:08:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A2DF1E3D2 for ; Mon, 5 Dec 2022 15:08:39 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 0CF28B8114B for ; Mon, 5 Dec 2022 23:08:38 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417391196054280?= X-GMAIL-MSGID: =?utf-8?q?1751417391196054280?= 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: 29998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520009wrr; Mon, 5 Dec 2022 15:09:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/wS7Ybmrb8XgHhrWkqkSmp5CSnB0zgUCiTUd0WsJ+gCMj9k7BoExLbfNmVUYVThCcNBat X-Received: by 2002:a17:902:74ca:b0:189:c9f7:fac4 with SMTP id f10-20020a17090274ca00b00189c9f7fac4mr11740148plt.151.1670281791511; Mon, 05 Dec 2022 15:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281791; cv=none; d=google.com; s=arc-20160816; b=x8iwFQ94RhtifHQqyjKGupzI1JZh2s/w45oEk3WhjEoCJwM7mjblYGbpQjZJwO1/i6 VUR15fOhfhIDJTv3n/0fd+9j22XmJjRq4qxej5BaNbH+O7OttPap/xHopaUwBlT5eJ+9 FXfYDAdv67nMmzvwgapj2rULlUs8jPzUCV2UIoMwdK1kD4MuOf/sD5d8kOqBLWQs6tg/ BB7I3vXlnHX3zE9L/qRQV66mf6g/BWNDxcLIIh+KDhCp4wyvTR1MEu14nSvqCIrgrrw9 qk8lQUvazE0ReD75mXwug1a7lxTur/uPGKLtXEDGB0wPn7jF4fhydt11N7uqpO5fvv93 tu/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CDD01R5AGR0VCKXOUvbXwSINuJd3g9aT00R1KPyCMrI=; b=vxdLFFwAxMHWBqPuwNhqv9Ky9diqcft2lpXu4mZ+2HpqOM9ppk4bF5C32I1DHAnVnm 9U4cV1UX1RvUq06OKciWvMUiCEGcGge3zyvB99Vebe6YdostOM6Wf21ImvGzeU7untyG +o7wot9GafSd9zuF8JhVVDNZ7gPTXAnYwSuRFog20GHqBHP7W/bm2BC88lSK2r1iR2tB hw0isHUnnXlag6m1W7VvUhBlo2wEXyUzGmor5ndZLdZV6Bz+jIHEGYCa9iNNm6K8fj27 1ctPipign4aB4lGrw4Ve5Vu8Yge043W9f0KhmW2KybqBcSHfGmRVFaPmiy3qlj+MqKkE SGvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OZtT+uKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b77-20020a621b50000000b00576916b7127si7562107pfb.181.2022.12.05.15.09.37; Mon, 05 Dec 2022 15:09:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OZtT+uKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232726AbiLEXJI (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231892AbiLEXIk (ORCPT ); Mon, 5 Dec 2022 18:08:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 030D46544 for ; Mon, 5 Dec 2022 15:08:40 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id A91E1B815A3 for ; Mon, 5 Dec 2022 23:08:38 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417400288602007?= X-GMAIL-MSGID: =?utf-8?q?1751417400288602007?= 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: 29996 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2519792wrr; Mon, 5 Dec 2022 15:09:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zk09HnS1A5iAK9G6TAVEueZGuk+jhZbiE9p08Suc/4prTqbew3uvjurZEuxzrvDJ6fj60 X-Received: by 2002:a63:4861:0:b0:477:4451:d49 with SMTP id x33-20020a634861000000b0047744510d49mr58664270pgk.575.1670281762727; Mon, 05 Dec 2022 15:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281762; cv=none; d=google.com; s=arc-20160816; b=jTzXTh9GrhXLcnGqA+4a8KUMfPz998gY1JX+eoW2eSu5NypG3MqFaGcQbGcPTYi97z C4bKQCl6XFUOq7y1SOVEBaipdnhlnllWDOT//aJs9mcqKBhgIHq2mE9MyPrj1QKxfRmN EAMbb/JxM/0gD1pxKLPYMOvMH83v8aiaAY8LvYcFm55ylszQO5gCPTk1ryWRRKOdNWg4 sFKX6ZeT9sBcnB7O31hfu1zm5aISuOBckQAgnZw5OhMYjvf78hEJeqh/HaS8IHGnQOX7 xktO9k9zsPwoErA3iWd6p88mYS9uiQqT5ZndCYqZWJ59pMjFX18kW5lD852eAF8ok4iZ zKAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r3xyNreIJtEHO9foiiQtvJVmPt1q36n0JQLVr8U6gzI=; b=BxPh+NpHMUN/HmcXLWL1nAWoKwjEuFMlPI1MpSCeI9xPtxD6naBMqGY7E+dVcAo+SE Sz1Uw5ipHS3gzCAMK9zCuoaCX58yD6rPkGDkSfo/NRzdqscq2h9/s4TGvZT5ymUcMsyu SK96+dvuLugsaIVw6epIk4PjlMSi4jlvYLJXjHpOpMNsjUDbt6mCs8g0FeLl8Nsb2kT3 ek9v/CSJ7AzYj2kLFJRsFfIKs6g3Z74gecOmcqYtC5GQC3Uq55l+IgYMFlaDcrkBctQy p52NVzPHctFDd0zbutq4VUykUCd5RfSISbdMMAhqOSSPwYXTPLSjKk57uWOkByA4ArRb avTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gkd9ZtOB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i70-20020a638749000000b00478b771fa18si4592849pge.250.2022.12.05.15.09.09; Mon, 05 Dec 2022 15:09:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gkd9ZtOB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232561AbiLEXIq (ORCPT + 99 others); Mon, 5 Dec 2022 18:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbiLEXIj (ORCPT ); Mon, 5 Dec 2022 18:08:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2BA15592 for ; Mon, 5 Dec 2022 15:08:38 -0800 (PST) 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 6995C614BF for ; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417369536560061?= X-GMAIL-MSGID: =?utf-8?q?1751417369536560061?= 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: 30005 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520296wrr; Mon, 5 Dec 2022 15:10:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf4dlOlEywjVoTT83XlSQT7bD+zxWV7Y14GVCZkAIv3FCzEwY9nX+C8D94/Xst5HE19qMFKi X-Received: by 2002:a17:90a:930f:b0:218:9107:381b with SMTP id p15-20020a17090a930f00b002189107381bmr85370873pjo.75.1670281832065; Mon, 05 Dec 2022 15:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281832; cv=none; d=google.com; s=arc-20160816; b=kd0tn9L2zA3jNgPRopJTD5qrVqclsMG6H7gmBLMSYeIwotwkb1IGjmF9hmYguXXkom 52aO5miaa7wqaCAFfpJEZMDBa8V3k2N0XXhcMZc3m4ArXphXHx5tYmxQsvWq2EAnr8Qr 8EGK+lbaDzVel7bkIh5Qc4N6MPiOeuyDEHWTXxumTmWS+zPgSaBAds8tp0GpAGg5ty7i NefAXPKyMVYmwjiFKN/je6MxGh2/Jd1v0F2NQUKNL5CvwtdJZzGFcATobOWBA8WqIUjr DYuA5kUSrljLThPpA8OS/Uqmjd6/ggX/31xxdsuIx/nHb86bgDk9CEoOzfcrde7KHfJw JClw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vvd7VIY3E2fb0b6B1lCyCZF6kEVIsBEC2F3qsYkpFaU=; b=tjStW8psFOmrZKQ2icq+FVgGllDqzSo9eZisefMyQ0cYuLel+oLZCEc1sW4erbgirK R1w/6sjh9zD/dLU6efMMUyGVOWp/XXdungNluUCPI0W7FxLHZgoUmm0gyqduvd9DOOBK UEJyv/FGCSLBnzNDeihiXIzjh12D/TGYRgimOgtqXE7hgnWOvGW5K9GfqxW5AdeFRqaT YoYgJUFnBlZL/OWSuXCm34jJsnuvJqCK3KAlfTQb6oVXrXqpSkO1y109x/VT2LiIUjVT fGNanCqoT/kRSRl0FTKPMO3wcfI0LDRHYAOhl8zTVQO/D3pfsSNgH/kKYofnJ8+usUOW y65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W8qG/90j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a636b08000000b004768f1cd061si15911546pgc.374.2022.12.05.15.10.18; Mon, 05 Dec 2022 15:10:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W8qG/90j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233041AbiLEXIw (ORCPT + 99 others); Mon, 5 Dec 2022 18:08:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbiLEXIj (ORCPT ); Mon, 5 Dec 2022 18:08:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28103FAC9; Mon, 5 Dec 2022 15:08:39 -0800 (PST) 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 B57B0614C5; Mon, 5 Dec 2022 23:08:38 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417442704988919?= X-GMAIL-MSGID: =?utf-8?q?1751417442704988919?= 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: 30006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520385wrr; Mon, 5 Dec 2022 15:10:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7roIFh399qcKL2MSxHOtfEc2Sq67LZMYit2E7dP6ARAOA+4GgbmZODZdVavJHSkERPXAF0 X-Received: by 2002:a17:90b:4d0b:b0:214:1329:dec7 with SMTP id mw11-20020a17090b4d0b00b002141329dec7mr98180804pjb.91.1670281841959; Mon, 05 Dec 2022 15:10:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281841; cv=none; d=google.com; s=arc-20160816; b=JVUBa2zG7GVLR+TkxabdHwZzejnN3mtq1oEnTHkXKjcTME2xHMASsmDN/ChOlyC1gv b43apEQtE4u3IjmK5b8wPC+1P2p7b3ycvbkCNZr2Cc8VPfn0lnRvP2o78KqwgRMRZYWR 1yaiA4WKpIhVUaD8sQy9JZA3V/fdhMLR0UvIzETgVfDYVY7pc3vBCrJWS3JLm3mJqr06 +xEgyyPUKcBbC4p+wyFfliWTvrixYvcFjworB4eWO9aV0oEaph4nBIhX8rLNvXKroJzB nhnUh9DKjGP6eFjoWf00TcYarJBjrcpltD9pNUCGKH9xaIZYqSfS/AY463L3QxLuVlP6 nxnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oAWeLdbec29o/pQUTk4KG0iaCmNJO1bxhOKX71KFHjw=; b=FoiIEEHPVa+oYME8q1mGzbRHTFDKex9RksoIhU3wWIMvcADQsSV9Qn+etJI4alhO23 nvvuqbnhcHVAbjwGNbnfw0x1s4O/Lr0e1gvcBxAKlYM4rgpWlrGAd7xMQuu0JXpD3Ymd hEZvdBt2APfk0JQpDQZgvd882JvtFJi1Z+TTpUvq7dHoL+ltAGvP7SlOlqFcA03xYP5c Q29j83FFPlHSQdnTqMILzFrpzPDeoIL9AGt4ZqKVb8+9eeXp7Q0ZZL2wj3WFdjaMVzmj ApSkj+OKGagqoRrukA02+vP17zHn7yJFY+krQM1bUbhbClsxheR8a8pmQO87aMbytbeU jAgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jrOqtFOc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a056a001ac800b00565a581ecc0si17348838pfv.11.2022.12.05.15.10.28; Mon, 05 Dec 2022 15:10:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jrOqtFOc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233820AbiLEXJf (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232599AbiLEXIq (ORCPT ); Mon, 5 Dec 2022 18:08:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFE751EEF0 for ; Mon, 5 Dec 2022 15:08:41 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 7A4A3B81158 for ; Mon, 5 Dec 2022 23:08:40 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417452765878095?= X-GMAIL-MSGID: =?utf-8?q?1751417452765878095?= 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: 30000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520040wrr; Mon, 5 Dec 2022 15:09:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf59YjBvq/0sXSxPpwur4ii56SAq/YeMlHspa/5yPP82jq9Oj5VDkHcfPkVl52VA34nO0Phs X-Received: by 2002:a17:90b:1bc3:b0:212:ed58:2825 with SMTP id oa3-20020a17090b1bc300b00212ed582825mr98898834pjb.199.1670281795588; Mon, 05 Dec 2022 15:09:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281795; cv=none; d=google.com; s=arc-20160816; b=LvFsD5RMuBULYnGva8HtFg6CkRwY+RTLUXFI9te+Pm7beI4UIDMi5OGOrcyhhvOOTF muDNv0UjkKiQpT9urXhneEqeK/fIqgO4925NMgILKiE23mbggenzMzSf52/ILjrKFeB5 7RTCI7yAk8Q7zPYFBDyarDJxmmVdRA2Wn/6bMR3EXS+2LXF1UOhDQRfuM3u/BoVsuyRG t6RhJ/mr5QIBSKhkiXwYRLhpjJd3A7sL44V2/Z4lTHCBfvvdSUC8NIS+rga843zO/aOP Oii+b4WqgEUWzWHcAiyp6dfdZPyBAtmYdttZ+YT5LDFf2cLZaB2Kt++OIOasGoGGwSK2 pc+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6SIrU+qHgmD/alHJaDLXicupWPCEB92hw5xZgg3ikzQ=; b=MdA+cRTjNTZzSlprEiLzO2LfCvJWcPlC70IFfQjOxVTbvJi9IZBwNCluqCncHueMA3 KkILhLehJ5bt2jj9eraEsYfwgxPDLcMekSBExVJBhY5X4TFFVK3nrv+9v57vhoNZf66G WU/gopPECdvutdTUZBdWYQjVz7Ne8+y4caV4fRYq9cznGEVCMOiSsaC3NuyE8hFWHo2n 9xOZ3goeSvQJsjcOIHFQqKi3OTAIjYCfnfxEmF0lBTNBtHO4sY5YQmp64yY6DLdo5m+x Oho8B5xhYuhznxabiyrnMxx+QGEgir6dt//6IEj8x2IuAMC3l294uAG451VoQ+JdShuL /Hqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YUkqaVKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a056a001ac600b00573a320155fsi16235592pfv.34.2022.12.05.15.09.42; Mon, 05 Dec 2022 15:09:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YUkqaVKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233593AbiLEXJM (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232384AbiLEXIp (ORCPT ); Mon, 5 Dec 2022 18:08:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D97671EED4 for ; Mon, 5 Dec 2022 15:08:40 -0800 (PST) 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 5D335614C5 for ; Mon, 5 Dec 2022 23:08:40 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417403691614272?= X-GMAIL-MSGID: =?utf-8?q?1751417403691614272?= 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: 30004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520210wrr; Mon, 5 Dec 2022 15:10:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4E7eWPG7tG/jZO3bcYYtnQyzPqAW4QxbLkiNQAMy6l52NkVZEZRKSIX88QbttTVk0csebD X-Received: by 2002:a17:90a:2dc8:b0:219:baef:3ba with SMTP id q8-20020a17090a2dc800b00219baef03bamr11355682pjm.6.1670281821200; Mon, 05 Dec 2022 15:10:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281821; cv=none; d=google.com; s=arc-20160816; b=Zjfkpg3sApCL10Dm10YAE3wsEZlWNFFZMmXMElHkppe8UQZ+d6BT78GF7ugTQUaaOD glcW/O2D+tvClrES56X91fN6gAdHY+HqjoAxpfRGvi5If7mdVtIj+P5+bMCndk6gtEHe TtS4Ae1UxoxoemFPLwmTZmHhMzobxC8wUHvtxGWnVl42BWT12muu6/zNaBRFIE5eFeak rSd8FjA6E076S/9Mj1tWRdnycbKuAh2K3lqb6fy0lRBMOz02qBQ+B263y2bpgVMiZr9+ sl2gxDUT6daJehV/gYzHKERc7FAqGbB7XtqSQCRGygGppxZwsJ+sg1I16sK6LD9g87mO 4qPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Pp1yUJLa+MIK3wToikS/B21yRm2JhREhRKEMfqbq6ds=; b=A0QvtXXrtWqMQMV89jRq3zEp5AVBr+BjFV9QYFhDdGS7jvgplX6YvFY483rqpW4xPk DbAHqqdSNyeyFiYLqJNp1EyXxuf+j4zTo8LfnB35I5JmM7d6d4E9yrgiy8z5dCd1Lzki H9pkgesQzbcqkEuRdwuyRUOTaTKGPRd00txdgZa7rqcGDQxGS10yg1N7MHWPetPSa8QH qffZycqdb7W/2bOx5FzoN5WKrF+YAoWG9OSmdVHgpm99hAv6MiO3lEAN7gAL/qXQYHdf D5bQBzp/HQJmrx9wAoZBPxyxVPZGeh/wZagn7nnCd3pOuCPaOjGJkaZdn/G8USXf8Ap5 zUTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LiP2vcVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631258000000b00478a3959742si6299632pgs.297.2022.12.05.15.10.07; Mon, 05 Dec 2022 15:10:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LiP2vcVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233804AbiLEXJ3 (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232657AbiLEXIq (ORCPT ); Mon, 5 Dec 2022 18:08:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA29A1EEFC for ; Mon, 5 Dec 2022 15:08:42 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 93B90B8111A for ; Mon, 5 Dec 2022 23:08:41 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417430658485793?= X-GMAIL-MSGID: =?utf-8?q?1751417430658485793?= 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: 30001 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520049wrr; Mon, 5 Dec 2022 15:09:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ox4BgYbzhIXCggjCUcjF0jCnh2uYOcjGWdkUSGe2eegVYlKLbzsvxevw1ZcGYsHqeaXJk X-Received: by 2002:a63:f342:0:b0:478:bc15:bf28 with SMTP id t2-20020a63f342000000b00478bc15bf28mr6210341pgj.542.1670281799367; Mon, 05 Dec 2022 15:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281799; cv=none; d=google.com; s=arc-20160816; b=a5jQ3SDq23F2bae2VZE6N5BPEn6WReAXvFRGTIr17J2522JApiEw/4W5Sjj8tVrXC0 qz3zctB4T56KRkVFn60Hi8LxNb3rJDq68bdQGzcN5pAQ7Tj8/JXfpKFvdXSzsOBFHGiI EKouDHVCX2W6AXKoG/GCY3qlTUF4ufcQhkKlKiyBnYodm+qh9EQO9/5tWOjIc6Q2I3WY GvIzaFzOGaEdkyZvkEvUE49h7OVMRSO2AR//ARPrNLzWFqolyc5nXDUHEtmuFvwjvhki E5gvF7DKUf07J/leQq6JBK1zYiQ8HGv0GY4//5mZyj74d3OJfsCw4L/w4JQF8v4but6Q u/2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=n5cK+e8f/OeVSbjmEapDXFxy7TvX9zLQMLpRsluJV5U=; b=F2xHw1jBtOJJJBfZup6jJrKm0Ki9Q0Aq3RK/vN8BcL6pot99GQNNtxzb4WKzM1Oi3P 8AChto1YVv2ZN0/DP1mmp/7vcs3r5lNXXNLoX13hWmWCvttkkNsoWNyviGuDnHeIr1DZ 2Scs/WD5gZbCCyxqDRntOBakqtunivM8vvsYa6IMv7DbpVsc56x4sKEF+LaOo7+Nxryv fEivTjzXbzXDkFutKOOWYePvSER0G6UcSSB3oXZuce07bpf8qdtmzy8taxYQOuJOX0oN 8WzoAisetitDef6tvwRZ8iolGe/aVn/9rLQuAz2KyVhbq+55qCGtQDr+pNZwzBHmCVW2 I+SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DP0dV1am; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c70-20020a621c49000000b005768619bd8esi8434862pfc.177.2022.12.05.15.09.46; Mon, 05 Dec 2022 15:09:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DP0dV1am; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233661AbiLEXJP (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbiLEXIp (ORCPT ); Mon, 5 Dec 2022 18:08:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D741EEF5 for ; Mon, 5 Dec 2022 15:08:41 -0800 (PST) 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 80D22614C0 for ; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417408027851202?= X-GMAIL-MSGID: =?utf-8?q?1751417408027851202?= 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: 30009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520872wrr; Mon, 5 Dec 2022 15:11:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/vDMVAAvAomnxIYKcTqnm9LZPuT6MhwVyLCxV4cm8RQet75mka+tNn/n9N9i9pCexBl9a X-Received: by 2002:a63:e54b:0:b0:46f:8e45:8da1 with SMTP id z11-20020a63e54b000000b0046f8e458da1mr58337242pgj.71.1670281910188; Mon, 05 Dec 2022 15:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281910; cv=none; d=google.com; s=arc-20160816; b=y2IYS9EkOqVjvAKXbiV4VcF0jANm1aVgMhNrtXswZ2C7pnmQmCv7+84APgpwAlTkNE MdMwUbLHhyyTf3V/3fS3e1gQ6X6V0FoyFlYLR4QcXjTY8ronh9HOZezhvW6ryaBnq0Hk C58hRSJkAIkRm0JWFMQFRHBplAbw41KB0Y9BWXXzeaNmSeKKheAc7rmbrKNnEGoXLFH7 37TCOeA8AOU82r4o0jv1+HCbMsLc5nXSeF5NuDZYw6xz5D1Nrd3upw0Q0++kMXM260/E mdohdGXB5Fc2m0EMCT+Pf35tH40nzT0iuBEEqFjXqjepqCU2ib4SH1x2/z3augQN0ELh mRHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+OTj21n3Wg9gwrrIBxAx4NidZtXBp6SPjJpmtwVGK9A=; b=B7ugVzFyzYRvPsmtzEoCyOA/m4KbIhgKjFgg7i2XsRwF/ezImg3V2us0luuSXqWGWN Q5LaFHRxqf0ooDU8oMByV6v8SBrUpmrdBpVITs7BMqNprAsrRHZb29B9XlEN4dxirKBo 3OQzKz0ESUqCpsJaRpVeucce/D8K4TIcQy4ePeBEgkeAh9HUEwYy0PSozx0cwrypKD9t jeq4Q17623ZSxZak404JdKIHh6zbsqXXJ1/zANVnlgYMzeNyg8JE2P+yc2N7Ts46aiOT hwbNWu9emCaXG5wKWllP/ERXptV5a1r6ErnwFADpjvXu9H8Jt9QczBd2nnp5D4kzADGY 57EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k78k7YEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a63fb4c000000b0043941763eadsi15503831pgj.835.2022.12.05.15.11.37; Mon, 05 Dec 2022 15:11:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k78k7YEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233863AbiLEXJk (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232604AbiLEXIq (ORCPT ); Mon, 5 Dec 2022 18:08:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1EEFACE; Mon, 5 Dec 2022 15:08:42 -0800 (PST) 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 CDA5E614C5; Mon, 5 Dec 2022 23:08:41 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417524291164652?= X-GMAIL-MSGID: =?utf-8?q?1751417524291164652?= 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: 30010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520888wrr; Mon, 5 Dec 2022 15:11:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf5GVWxnqc5cEJcrNUsJSOeNoXufW00tEWhzt09Trx46cgGOru9tF2DGkcIMzd454BanG6PB X-Received: by 2002:a17:902:e8d5:b0:186:a636:b135 with SMTP id v21-20020a170902e8d500b00186a636b135mr79160529plg.93.1670281912272; Mon, 05 Dec 2022 15:11:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281912; cv=none; d=google.com; s=arc-20160816; b=Krg/tTMUx3YaWjYlWeNSKp+LFg7Pt7PB0jW32xeqEGuW5vtE4St4i44yYHt18Kqvlz 8UoUbQzpLuaKPx8006jMHQfyCmm5acIjuE39YLakeTXUBL1JtTJsC1lrWtHpbTmPgTVL hb05Lu6CRLKGyFO9JAeIU2W340tWe2cCpl7omKrXaUUXrA5dm1iquC5QfdMSRdvfySBi jj1Oj/bckLpuQRusBHng7gPBrfWS8wGoRUcLv03tvPB/at91ewLPE0wbFMWk3VX7SPSZ xTXDY1fsBp+NGophjY3qSgIRharrSuHiR6z+r3l2aqsWbvwETFlhSjNl2T3h7z0vA0gQ 7trw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gpmeBORiZpRF2beWDn7dZTCiE/JqtbjFsMCpo3MlrhI=; b=0IKwNekYxi17EfVOzY14G93YzN4JA4XaRp5uJFugTmsB4AWZlFKf/ERvDvMEaPVeQ9 6zRNR3m1OZb2U0+7v4VOq7AcHFrae3i6qGd3eLmRmztl7uxFBkkGkqORgGqyXBF3RSzC J8HDBWj/jfs6CH9sqM7MjT6Tl0Uvqf44frchXc6n5Ed/kFqKFFMH1DQGp3Wjj2CrYSBZ NNmmVxV0AnXu0RfhK3iwTd4kir1Jwn33Gp6GPcTVTf5PzM+dK03C0AiOulsv7H1RoJIR +irYsMw078J/BgJ5GN6356ft9gvdDnfRpSLH5ukB3JGsXcd+xmNAAhasObgdKWdEQq3w odaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TpC/jo3F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a056a000ac700b0056bf15d0cbfsi17262040pfl.308.2022.12.05.15.11.38; Mon, 05 Dec 2022 15:11:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TpC/jo3F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233397AbiLEXJy (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233199AbiLEXI7 (ORCPT ); Mon, 5 Dec 2022 18:08:59 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD9A6544; Mon, 5 Dec 2022 15:08:45 -0800 (PST) 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 2DBBCCE1347; Mon, 5 Dec 2022 23:08:44 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417526326894434?= X-GMAIL-MSGID: =?utf-8?q?1751417526326894434?= 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: 30008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2520794wrr; Mon, 5 Dec 2022 15:11:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MnRHuRKUGGGBo1FTW6uAZXZlnIWC0BXsqg5199i1VOhVqSO2teASwsJ1NdpseIvjEA4Hw X-Received: by 2002:a17:902:aa06:b0:183:7f67:25d7 with SMTP id be6-20020a170902aa0600b001837f6725d7mr67615326plb.164.1670281900808; Mon, 05 Dec 2022 15:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281900; cv=none; d=google.com; s=arc-20160816; b=OPAjcREkeyMB6UsVU91ElB3Tmq5EqCd6a0GWToMrv2wlUb3tyn/h+5iJS6s4bZ+RNy mUATN6mznZeQI6bqVw4wGg7yJfh2hCaZl9GjuJWj8i9ElKzLClMkb44qX721SXW68bzc XKNudX2A+4pTHKD6lwQM7ex1w66RNPnvfnAUrNZoESg/ooqAP/TZqeq+s+gCcbPEalul S9qCalX9UXFxEBrgmB4JAn7vS9lboV9DqgFeKSBSrbZXLgaE+EAE/NUZKByz3iN5QrOI snihvtYChTk0HT5yStn5hzMI4HpKxrLndJPzmyHORU3BainUg0Lq6T4yh0U5FbLHM3dv j4xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TLb5XnMDpgcYHy4frIqgmGqxPwmmsgK8DLbiJhJicSI=; b=h+k5M2JN35pfuXs9ZnIFx4JaKsTO1VJY3X0RNW3Bt1Asz+Hs/LMwb05bq+Vq7ID5ls dqsM8h4fRc9cyR+3RB+8ePt2EX1JlvWwWJqfpG/yAV3tO4r0v+9Pna+M08d1E0ZgNsxy ocwi77wGy4piia1nRCTVxenlSD+mwvlwcubRBxwHN7LydLcityQc9mbqYarZkFY2fo/F c7vgor522ovSrRIJmCN2uo7JW0aAvlk8PHLfp4Bdwraf/Ovrl8IV5gxSRO0OPFRO106w RDawcT+y8Zeovg8WcyYJlZnxh8znoHPgtrERfe0w//cTOivk8GJDrH59L6Bh9ayzupep lyfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YxuueYy6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij27-20020a170902ab5b00b001890c6feffasi15157699plb.568.2022.12.05.15.11.27; Mon, 05 Dec 2022 15:11:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YxuueYy6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234045AbiLEXJs (ORCPT + 99 others); Mon, 5 Dec 2022 18:09:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232897AbiLEXIr (ORCPT ); Mon, 5 Dec 2022 18:08:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFAC21F2D1 for ; Mon, 5 Dec 2022 15:08:43 -0800 (PST) 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 7B909614C0 for ; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417514573545860?= X-GMAIL-MSGID: =?utf-8?q?1751417514573545860?= 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