From patchwork Thu Nov 24 21:21:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3615698wrr; Thu, 24 Nov 2022 13:22:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+siXaEVafF62P1WMEz+u/Q4phSwG2TTZUbedZOn2xDBHeOFP+lqYwjYLtyUHNF6U9BmJN X-Received: by 2002:a05:6402:1399:b0:461:53b0:2ac0 with SMTP id b25-20020a056402139900b0046153b02ac0mr31122776edv.153.1669324940310; Thu, 24 Nov 2022 13:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669324940; cv=none; d=google.com; s=arc-20160816; b=o8fClpfpvv2rn5T3njK+7T3cpzUrykhnPEggDibcI/5M6BZYgtOXD+uzZlVFQVKnl5 ff4S1zRHZobBANk8kyXNMtB0st/xI2SVvuddiNHG/TShflVkaNyWnD6X0kM6222adUnv UyYWPDoS/oAq3tLuUQ4MrnHcZFExi2kGwn11s+x5L4mSc/uSBPcthGY0pqich7mh64IV siHyBOXghuePaER8Sg/bBIFjk8h/9OlcNxeu6pT5uNH7kZXj2Xua2EAZjiZknfdJSxNl jxQ76e4CkscwhtdaNTc6jRZCvVw0xRGyYZ39Svxmhap3XWBMsS0ap0zauCCmKG5NGySh hhWA== 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=ycWoaO12O+YJYB0m55qHF5XnIC0C+dmyP2sXBGT4O9k=; b=a6bhZmzdMkBRHuEo5twkwUfoK7XDnbs+mA31ER0Z6Hc1ppdQWUELsRUny0qDNdm6oF aNLfO+2yeTlMi7mQhX2DzSVqitGyb0GxgmkdpBB8UWUon+p30LDaNlwxd09Ipoem9dPV K5X2wSEOGMQwkpX5DNPxJO3tybwtIbq4svI7XxopbdN0M8LrakBOdOzKTv6Q3sYMa1Vc 1vAHeP7AOpBwlm5IwY0VS5/cY0QvYi/hTGBvUBfl77yxytHhPUOXuUS1BizDkljyYW51 /J8McT+FRp+1+L9S1sONSz4ddEaa+3Ml3pYwG+A/ZcYBOeJ6imswlJtw3m9i4QwG1pQ1 wiFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gl6EnRqJ; 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 sd36-20020a1709076e2400b0078d3ab37efasi730031ejc.84.2022.11.24.13.21.56; Thu, 24 Nov 2022 13:22:20 -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=Gl6EnRqJ; 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 S229606AbiKXVVf (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbiKXVVX (ORCPT ); Thu, 24 Nov 2022 16:21:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A98293CF7 for ; Thu, 24 Nov 2022 13:21:22 -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 59CB3B82905 for ; Thu, 24 Nov 2022 21:21:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DDB0C433B5; Thu, 24 Nov 2022 21:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324880; bh=YFde7Cg3Hj4Ke5ExGefyiTVasYPENA1m1IEZnM/nGhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gl6EnRqJBxFjy18Iah9VqcR0bmZ1Jn/wwqzkIsrbgqDx/IfCPgTt5d9a94tbDkXFD 60k1/8ZNp/Fkiw63+YfOHXZ7Xj55J6NotdbVC9PyEiWAsI1JwE25fT9AxNm1lekOr0 vEMatfZS+8MRHgx/BkTGNHINHRcbDf/sLiI9w3F0MXtYND2uDCttF/8KFLaVgbRufU tzFfvm9f8yrvTC1sB6FcSMkgjooYlbTwwh4imj/W+Dd348xuySRGnTvlSuU9f72346 Rn/16RrolIPWiQ6RK2b9fxuiskaDMxnknY9Fq32EfifYbqCFzJTCG2gFLevrp7IXai 6wlagUCiBncwQ== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 01/11] mm/damon/core: implement damos filter Date: Thu, 24 Nov 2022 21:21:04 +0000 Message-Id: <20221124212114.136863-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414069050485582?= X-GMAIL-MSGID: =?utf-8?q?1750414069050485582?= 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 9cbcc143179e..d924657ad622 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -273,6 +273,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) { @@ -297,6 +331,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); @@ -325,6 +360,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 Thu Nov 24 21:21:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3615669wrr; Thu, 24 Nov 2022 13:22:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Uqk4W8qqGramGkHdz/YPY/aE/rELsndBRCIk6MCYznrVuVF57DAbyhuUG9A0/Riu0S4Wo X-Received: by 2002:a17:906:882:b0:7ad:e161:b026 with SMTP id n2-20020a170906088200b007ade161b026mr23629817eje.760.1669324935302; Thu, 24 Nov 2022 13:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669324935; cv=none; d=google.com; s=arc-20160816; b=vE0FRkW6TTHmIyN3IzmaH7GfKxnULRvuCZ1KatZXr9gu6tHHpMMVz6GvmT6v2BMSfr daXI3Q06kfjrAr3I9O8fiU3+MkZ9s/xVYFCkf6hBUsgA/b/aGl0ZGXiu3OTxmmNxBhxI 43Q7O1uRZj6khjK75gNCCPWCeTjkLUVATTkt8U0JuRJB/jsPts6X2koSQkXqK0/NioKh Q8YZCmYIPvMnekBbp9/jpFAVoBvrjfmyrGdo68KqP0RYhEKiUcBZvHU2pPXWLnyGQSI0 GYlDti7yD4UrJoZlyhA0S8oAlqLYh0w60HP22S6CvcyyajPBjLcS/SNRSjAIkybRUwYX L+vg== 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=sb5vRSeZLnHoY0lxvSTPfJKM14khVcepQJxBwqoQ92dz87ZQDwZganzleQR0mjAwoa x1sM20Tz95/eD8hHCU7xHB+ix8F32HG/ukMy3CNnzdnZXe0uSJ6i/1DXZPsTOVm8pyUg Lnac5zHU7IzqcqT4+o0asb1jfGh1hLEpYslFA1f83J3VO0kIgz/D9bBAxOkSB8mgQ7VD vX6ykrqLx2LbyWmcznuDCy/N9yxPcddaNBEVt/YYNEdeZn0sPqcqqLTUAfiZRwjoOiP2 Cj9Uoswg7DPN/O+qZGQIBDoLif41lBF0yLp0oB9abTEAIHPbOXeHTxarm5pN+4Ztfi+8 50Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="V+0V/Uoq"; 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 s13-20020a50ab0d000000b004694d005e82si1617115edc.571.2022.11.24.13.21.48; Thu, 24 Nov 2022 13:22:15 -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="V+0V/Uoq"; 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 S229625AbiKXVV0 (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiKXVVX (ORCPT ); Thu, 24 Nov 2022 16:21:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A62293CF6 for ; Thu, 24 Nov 2022 13:21:21 -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 3488F62258 for ; Thu, 24 Nov 2022 21:21:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A8D9C43150; Thu, 24 Nov 2022 21:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324880; bh=A+37s6JJXYN+1C0NX4ExPJftU7PAKfFK4zc/BA9nVsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V+0V/UoqSADE6pcLDhZbExhGqrYT4Q8hixpFvbQBtIq6Bj3mpP154eBt+hH0yZnPF sjEbxqQrqRwRIAGFNSdF4WLlSyzdwuIfiCNRf4yZMh/lHgz3zIQh/9XsneDPEthf5x dHkbbR/KPwDkpjuocYYxSEVkwBwLfv6TZBXEENrrySTPlPLDMqWC86RwQ1qXzmyvSb 4ZNk6T1mi0uXuLtfXpfoCc7M0E2NDBlUeytO6oZdIMx0M00hcuq8ZGyiRkgFX08Gng x0PtTaFaHv13Y98mbnIPQgHenGd/LdGPchqBOBwTa0fqjP40QdhT19S5SAuPjIoRQs 1ovdbbxYfl+Ow== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 02/11] mm/damon/paddr: support DAMOS filters Date: Thu, 24 Nov 2022 21:21:05 +0000 Message-Id: <20221124212114.136863-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414063706077135?= X-GMAIL-MSGID: =?utf-8?q?1750414063706077135?= 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 Thu Nov 24 21:21:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3615677wrr; Thu, 24 Nov 2022 13:22:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf7tMu9D0Nnd4U4ARtnmSigSp5QLn0M6jjvQ8YiuoSsH9i/rJTx+RwXAcB9b/PblnAmgOxhk X-Received: by 2002:a50:aa8f:0:b0:469:c5cc:855e with SMTP id q15-20020a50aa8f000000b00469c5cc855emr17565748edc.307.1669324937846; Thu, 24 Nov 2022 13:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669324937; cv=none; d=google.com; s=arc-20160816; b=s9ulbJ/xxftRWZVux+3Og29UU+nA8Adz2Flt3ewAKHMNU/xegNvZb9wH0cXiINhvwi W0iVr2+2nJR2AZV5b138DIpTP3krNEaJLAwaBlPF+cX9e+ch0hT6zc2qmSJcUiHUgCTb nsIWLkKDwi3xuLXS4D8uvveDtv9RCRRU4p5J6sPcdoWk8/1T7e6K3k2MRkMSaj1YYliS /JD8f2ibdFhx0qVkvWyA2HIo7SNRkdSnnnYdELp/moK3XmkZbPy1OyuzkrG1haK7MY1d WO8hzEJ5djwKFmmNSO+p/6OMy9pQvv82Uyly9/yxdt49B+7iuOJ8t9XjYKhwTX+6FOb9 nciA== 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=NRY5pKZrK6+SSgd2dfONu9Ol42XT+8voxENyyi27BBvPJ0nOKtpQQ/0p8exeoMhzdI PfGO/fxmYfzGhxXXCumjSFYWtUKuohiyF0PwT+hZv7Hcy8NOpGGC5jz6O/rpjbTEY+xo +oPW6EU0qZqRcC0i5Z6unxFaPEEgY5By8rhIc6zJlqK+SEUPwt1fMdPYvBq9sJN5ywB7 RT2SmyhL+PVQoyvu4HFb/z7JPWR/ffrtTcQ7WgwkEOzdG8zMJXW8i94hr/TZPyDWMoQ9 oRNuU3m5xP3aNheH/PDH2TKZLGFiCzgRsuOVrPxlzPe22o9DTtQxPpFIWzuzSKcSusvZ tUFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Scsna3CO; 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 hp22-20020a1709073e1600b007add8160fd9si1696211ejc.765.2022.11.24.13.21.53; Thu, 24 Nov 2022 13:22:17 -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=Scsna3CO; 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 S229632AbiKXVVa (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiKXVVX (ORCPT ); Thu, 24 Nov 2022 16:21:23 -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 E5DA993CDD for ; Thu, 24 Nov 2022 13:21:21 -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 6367D62259 for ; Thu, 24 Nov 2022 21:21:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0906C43145; Thu, 24 Nov 2022 21:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324881; bh=grt8f69Dz6AwyetZSMeMbFhewde1iaVMzadAT1LoRZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Scsna3COmwE6eGQjmyTlyjMBdHtCfsQzO5q1w/q8qp13kHeVLM7pYbq/hp9VTIvZ8 oeAq5Z4EryN0E8hwqg7wWWL1yCKYXc6Sx7c5qQOgw8qPvFUd0fYn2CR/0gb0nqE996 uv6/Ohyk8hja+94/N/7kXEdJVPkHFh8L4SNkSOG3vMKzBz+hGjxp33tPXRzvIiS37R hsAQFUCu1bE5lUpUt2KOZDM7wOX9x5xe5YvKgnVXWyiErEdkblKhL3siXJ1330TFuy JFhOYoDstdrsx5xYZTQhVJcTuPUxrNfXrJ8qjRnXPyEaXem/Rt6kFQiL66Bp/7ybkJ BJndOwSLhj+0g== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 03/11] mm/damon/reclaim: add a parameter called skip_anon for avoiding anonymous pages reclamation Date: Thu, 24 Nov 2022 21:21:06 +0000 Message-Id: <20221124212114.136863-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414066352457867?= X-GMAIL-MSGID: =?utf-8?q?1750414066352457867?= 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 Thu Nov 24 21:21:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3615750wrr; Thu, 24 Nov 2022 13:22:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf7PXhHBcppsQ1cw394C5E6DharKWLieIPffH0d+sT3Eh+NCBpTQHOJ6RDfE9ZiJhCOFHsy9 X-Received: by 2002:a17:906:f281:b0:7ae:3b9e:1d8a with SMTP id gu1-20020a170906f28100b007ae3b9e1d8amr27872893ejb.581.1669324948578; Thu, 24 Nov 2022 13:22:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669324948; cv=none; d=google.com; s=arc-20160816; b=avRdJmUp3YBPqpwcz5grD6DE8YqspIX3Mz2hQb5THK2/NhyN8d6kieyRDiR1klIKDg l4N3VM3/RdT40Rmg02eDtSEIJSjSrz8FCPVIGR1wnKi4MuhWEkl9Efxnqqf9JRi2HlmR D9NPPdnWgVh002xNBO8Iu9XPsVeVLceDHXFcnraQDPmeXEQvtxXfMtSyI7yfE9BVjma+ kTYVGugJeZrbfpuGLi40zVpcfkZVdGmEGahx6x3qBaS1ws9/jBHTZjuE1Vf3ABDwDkOT vp2897Z7qZZyjRIkhVpaiPf++RDBofqnuqfhszEJmbDwkcTIDnygU2azKEkhu2b8+Dxw BR4g== 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=M5WZyXd2P7Im82Y/rct29hUZvXQV8ww5RYblIhbiRB6ryAQVnYoEXeyE8Xyam6Q9iM EgJGYVyyFe7d32oJ1ivu51pQGd5/TjdYbMswLx70Y4atprqxkGVswipvKMgr1cfQ6J8A B0PBVkNH9zPasbALbUrvALEY/f+QpjMv0seou07lpnmxxRK2ElXrGDZbgYjiZRUe7vqd 3tTZ4/PDnyRovWxI7lUiHpaB0X3jFBA0IjTNfD74u/5fmAimOd2UDnVT5DqUMZkNFj4a ngql30ZsMSaDwjR8eFa+wKwQ6NYUMo6c1SAGRrF7r3NxrsfIzKH1XZaqghG/oAnjCTv2 BqsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SJmT6SE5; 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 qa40-20020a17090786a800b0078c47b4478esi955747ejc.106.2022.11.24.13.22.04; Thu, 24 Nov 2022 13:22:28 -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=SJmT6SE5; 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 S229526AbiKXVVk (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiKXVVZ (ORCPT ); Thu, 24 Nov 2022 16:21:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC10942D9; Thu, 24 Nov 2022 13:21:24 -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 20347B821DD; Thu, 24 Nov 2022 21:21:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67664C433D7; Thu, 24 Nov 2022 21:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324881; bh=ew0j918CPCZ3BCkCfl4ilV0ZC0sdlaLXkkNEQyNFiwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SJmT6SE5SJA1ZiuoIDKQK7YvF+WpstqdQXLA2OAwmGzcllHfgqeMqHBQmw3fIDzBh 6/4db/iEOf/VXaVubqIXasXS+XfUwUpC4hIG+yryfKETPVmo/SatiMQHssPRl9LxF2 HHd3aXxHc66tRm4Hs6ZmhQOYs/W4WRl81HNoyDx1kjhPKt9XkO4VkR0oxIeARx/ZWT p2w5sT7EmdFs/6tgNZtVwDDM4WtHoRa1vgujGujBRqBqfAZPEbQYUczoRmlOng9tL9 sU3WWusdLWjBWHoAb2N8MZqjiUK1cv71Jw3MesaBo1Rvo7NslMPD8xh+SrC+xjOStS u3xZsD3pP/T2g== 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: [RFC PATCH 04/11] Docs/admin-guide/damon/reclaim: document 'skip_anon' parameter Date: Thu, 24 Nov 2022 21:21:07 +0000 Message-Id: <20221124212114.136863-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414077538853009?= X-GMAIL-MSGID: =?utf-8?q?1750414077538853009?= 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 Thu Nov 24 21:21:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3615978wrr; Thu, 24 Nov 2022 13:23:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf7GHYujoD4vcT+SnYs5TdGsCy/E/t8HrkBUxko20yENipWXAPAznFLWv6PBsfVrPzBJGFf2 X-Received: by 2002:a05:6402:3808:b0:468:c911:d843 with SMTP id es8-20020a056402380800b00468c911d843mr31818084edb.422.1669324989837; Thu, 24 Nov 2022 13:23:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669324989; cv=none; d=google.com; s=arc-20160816; b=A0umQPJxY2jFxnVeeeqb8m4880l8QXCF8HtjIuYhA3IHHZ3KAUTRAuSq8Tz6r1cwGj Mf90LlaNTA83lmUpQ8hYTAK0w+ZPhxzMj40biE07niFTwzS0CIf+kewZ3jKD8eZP8qj6 CwjjYk3KzFnk39l7Sh+Ezg5Hp2mvQ9+lDF86BqAgE+8VF0XyAwywa0hQl8Sphx8n6lVB YlZ6NsCrPUcVwPimEWdd9AnYxBgmvKTGk1GFZifxWebJRqCTZt0L45FzCtcn1F5Rbemt awNz5Cye2qQu6AInsoB2WdNU5VsjjPva5vQFWSIjGHMYU0AvWrmB/PKYmL3q9KWFqH4y 4Fwg== 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=xD+fC0+gqF0wDdsAKbfeo7n67gtVELXAgj/Hou0Kp1GQvUvHOenLpgMRJ03jukM74f DlI6ggNU/1/ztiA0YTP2pmOxQCMbUdObqd7HSkpbZ6Cc38LqCiXWR7Elu149v+QweQBl 6Ul33PjIUAxThWsrKsIYCXzVH/IBYQgBHI/BvS4rEisu47wH5eCi4MOwBaAj5abjel2/ k897gu2o6NKl8b/JsdXOSvsyKpqbNYmW8O2GdDB1lo9/FR0u2h/rh3YTSYm+aFuPq4uQ 6PQmmyAgbm/zX1QPUhxqSwPkgIltxSrh3slQZye2Tw79+Y9Mo2rTvUm9JQSjU161Jo7O ZyiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gOP7mlJJ; 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 s25-20020a056402015900b00461dc830100si972019edu.452.2022.11.24.13.22.45; Thu, 24 Nov 2022 13:23:09 -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=gOP7mlJJ; 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 S229646AbiKXVVr (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229617AbiKXVV0 (ORCPT ); Thu, 24 Nov 2022 16:21:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B5F94A7C for ; Thu, 24 Nov 2022 13:21:25 -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 B7350B828DB for ; Thu, 24 Nov 2022 21:21:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A5F4C433B5; Thu, 24 Nov 2022 21:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324882; bh=MpYV+KbY79xvzeBIqlzmkGgEI6XBAJRwIre/bGlDx34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gOP7mlJJ1syTxKt2NTsf2/24L2YQ0ugKEYWXxekaidGUfYGZ+gvped+wtAf+53BKq L+UME89oAQahjiiRDswc5tjnB2H0rC/zztQs8uDen2UBJ75NpS7HhjV+YQIXbxR384 xrzV2R+Dg9JXGJ6nAsNOI2qRhJyjJn2INs9Q2pyeQdfGv4kgDBOClvTBzZ7rFTxSSX 5lChmz2X1Ft2ZJMk9226sx3OwkzeEXR3zBF8/iXM+vxZKD5J3Z8Msv4yHm01+SwbXd tRzYy+c9Y07Ivu4S+yMs/LQZ0lOm3unvJyLI3BGh8TK1wR//ToSx7L2xIST0UISdKb jhC4xJ1d1T16g== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 05/11] mm/damon/sysfs-schemes: implement filters directory Date: Thu, 24 Nov 2022 21:21:08 +0000 Message-Id: <20221124212114.136863-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414120233337432?= X-GMAIL-MSGID: =?utf-8?q?1750414120233337432?= 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 Thu Nov 24 21:21:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3615732wrr; Thu, 24 Nov 2022 13:22:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf7W9HQ3HbAFqL5rR5ohDyUtK5vioj4ekTljwE1ckHYrB5d0VpiHEkcrgXeeYDEPhEPpALEG X-Received: by 2002:a17:907:8d02:b0:7ad:f43a:cb07 with SMTP id tc2-20020a1709078d0200b007adf43acb07mr5424189ejc.562.1669324944763; Thu, 24 Nov 2022 13:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669324944; cv=none; d=google.com; s=arc-20160816; b=o37gkdaiEl9FKqAWhj4AHRVIJhZsHFbCwwKDMhafkGMvk6FXMl+WdyUv/vlYOm7Wxk OTkfdswxZAckZ8051cP6LNZO8Ba4yEW9JJA6dn9usKVQWoy4ElzZbkdFz0QVW39JT3P8 omsT2LSptsHDSMmuBS3bUgQ55vCyZhYNROsoxOmRnFq6xtHopVrJBLvM7GNdEGXEyZL1 fI4RoEaI3KNgcqvjvmLh/jIhKA7zYCV8sYuQXO/K6GXLcOHCxuFoSWUwifKb1BeGrE/o YYgQNVqTQQVxC5MIFXH4MXuBmJanJ95YytKlylP9faYlSw02oU4WRnPGdEU0rFPdipSt MxIw== 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=kbjfjut6pCBvv1ZhVE7mWAFORPGBAbcRylOQ5i6FQ4ki0/BT5Kdi1EaJe9x7VI/xGS 5O+HJbcuC7Ug7hkqeKf4QDd7NT/BhhLxWMFHRCXR+HFeo3rEmicHTPrsCzyEccRMn/Kh 7z6Ha2MR6bRzFWpLnR48+EhyxSIkplS0b6TL+9uCv1QCfSOny31eaBJAn/olYAGKCteN Cz7urfYFTYFQjBLc/JIGYfsKwC9mLjTCGsLwp2PzI6Wz9zVxAFAnr2I3rA68BsPFYqVw 3WXs5fTKQTLrIjhFx2+kS2QMotIErOUsavzp6G3Zh7Cb9vAkmfj8EZGsD/ldLmTFqvQi KHjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="th1NC/9C"; 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 o14-20020a170906974e00b0073d710fec77si1758827ejy.251.2022.11.24.13.22.00; Thu, 24 Nov 2022 13:22:24 -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="th1NC/9C"; 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 S229595AbiKXVVh (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbiKXVVY (ORCPT ); Thu, 24 Nov 2022 16:21:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1619F93CF6 for ; Thu, 24 Nov 2022 13:21:24 -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 A604F6223E for ; Thu, 24 Nov 2022 21:21:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0D3FC43470; Thu, 24 Nov 2022 21:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324883; bh=KP45fkenUtVNkuekA5wpVSKSKg+M620wUBu7fatA2gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=th1NC/9CqYR8H+krzv8GHNUBGsnG0hc0TrRpwJhni8NgC0Vtes22K4XcwXezWUksM LyjzdE4nUad+0bke+j02ePQEA8zAwN6Cac8orFTOTNMPBQWCxnhMib0zzA56qqlpei xpaxnY7lqe5wC9KZmKu9u3TiElifD1r3StC2Q9CivX1XLW1r/sOJn6vHuzQbHW4Fgg 9Zl6sMngKWBZ6CBfrCrZuAobXtcmZJQklEnbtHFgcdldIGHDlNbRYYnQmbnTKnW4Nv eKwQgm4YSS08f/5slcVfre8qaNKKsm+WbfgQtJ3ccj2QZ23y0v6SjLY3z1SQVHV/0v 575Ps2FI2RUMQ== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 06/11] mm/damon/sysfs-schemes: implement filter directory Date: Thu, 24 Nov 2022 21:21:09 +0000 Message-Id: <20221124212114.136863-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414073175181130?= X-GMAIL-MSGID: =?utf-8?q?1750414073175181130?= 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 Thu Nov 24 21:21:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3615801wrr; Thu, 24 Nov 2022 13:22:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rOMAZuaU9p61hsUNlw2oTvqPX76g6LE8kkbTz3c4NNjWC2ZpqUBb1BY+Lyh/0nMxI2loK X-Received: by 2002:a05:6402:5011:b0:469:9c84:3bdd with SMTP id p17-20020a056402501100b004699c843bddmr19116683eda.302.1669324958538; Thu, 24 Nov 2022 13:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669324958; cv=none; d=google.com; s=arc-20160816; b=yalqFbDN5GODaWDwcA0e05DNaCerUy8UIQHLi6nFyrdeazXugH0dSuvd81lLWfzaRg ks2lnRbXjSD/0J7uJ93trR8BIrXZw4D68y/lwyEdomWgLp6CVdnQo1syMv93pEZjUPqd EM4OXxcvY8s+LG/qBcioKxTkRhpMI7yvbSfuYHYNXd3qmZ0n8r2CQpMaZPxz6+Ty1ykC UYEbt6zOGwMv2IV+xAT1jI4XUjhqSXLRqFk6AhYvljm8EXGG35TXwb/ONOI6hJXRBC5S s9HfXOtvarwluPARMnrLMpGjUtUDFQi3i3830Ka6Jvc1mOG9/orhyoLBrAOqq5K/XeHT zzfQ== 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=L5uR5rYrk5WBOSUkHBxBiSbuM/EK1gm61GzegfZyReM=; b=HLJi8nb+o8J4NwyaICijxlkwBKjzxIkDoJ0J0twbcy+zUBNeNFjfvlcPS0FdVO6EfA rs/nTNU2D/zYdG+pRGIiaX2EYrxOtjwNF2CIWzuiJ4a/NlALPSpYTvIufeIOJMfTN7Ta 7Hjt9VrhIkSFpXfvQkf8QKRuqp89hK3Hq5WRlWNq9cy9FDbKOEqRIKwMsMUaJkRlZIwA qNG2e+y/ijKwp6VWWY6aVc5jdR3KzeWs6t8Pjs7NCEks6tyIo+XO5/Qxau2SQLOFJsT+ fPXvS8rJ0gqePlYOYvOe5WI3/dMgcEmN82gHzvmXYwlkP/p1MXBrA4wn/9fJYzpRw/YC Wsqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=csE2P2pP; 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 t20-20020a170906179400b007ad9885d2b1si1247270eje.301.2022.11.24.13.22.14; Thu, 24 Nov 2022 13:22:38 -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=csE2P2pP; 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 S229685AbiKXVVm (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbiKXVVZ (ORCPT ); Thu, 24 Nov 2022 16:21:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C9594A50 for ; Thu, 24 Nov 2022 13:21:24 -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 4732362256 for ; Thu, 24 Nov 2022 21:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E820C43145; Thu, 24 Nov 2022 21:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324883; bh=P6PPKcChryRiegofLGkES15aSEw/aJpUh0oNfEpl4kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=csE2P2pP80gwh9YjLKh9Ih3bnqn66ojFLUM6VT7+M/2+HoETHDkdMQvfgZ4/Gv7Cm GlyAmfjL2tClgHeSpoe4KSS4bfabmWQT2PfRA7FHssoVA2bn8kLknicRPVPM7TIjoV u+LUNjonDlYIYHphKh0ajOWEP3mOO1Tb4rp+tTArrAVvpTdn0OcpLyYBtu/x6gLIP1 NyBgK0wZkffaQxDltOfBkSd5de+FejYYAI8rX2AnthkOftYfxjEyB29v2P+CJcpzW6 OlLHkaL55NjZ2NxLHXoPdeNtmCcZLrQzzes7yUeE7l0kUXs26fGQdibS4XlRabDgbD 1kyLxx7xuDKXg== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 07/11] mm/damon/sysfs-schemes: connect filter directory and filters directory Date: Thu, 24 Nov 2022 21:21:10 +0000 Message-Id: <20221124212114.136863-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414087772225535?= X-GMAIL-MSGID: =?utf-8?q?1750414087772225535?= 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 | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index afbfc55a8e84..7f2bab617156 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; } From patchwork Thu Nov 24 21:21:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3616057wrr; Thu, 24 Nov 2022 13:23:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf640DB1FggCij9G+3NeQ/CjwKDaGp19P4gsjr1NRgiuRfv0vvtrmT0ftgSRysKm8Sri2yiE X-Received: by 2002:a17:906:1e83:b0:78d:addf:67c3 with SMTP id e3-20020a1709061e8300b0078daddf67c3mr20455530ejj.253.1669325011951; Thu, 24 Nov 2022 13:23:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669325011; cv=none; d=google.com; s=arc-20160816; b=saC/oYImKFvbDNVN+8LvXtu17Q6zitBPy22lUbnaUHsXpH6PMelPndIHnwrc50enrt xF0UEOCJhrzbr9fpJESSehjk5nGM2F9a+bu7gsShH2mJUi8ZmemD4ysOQIsAET9Uiuxf iw5YIAIeZbNmy4BFOcXEd5n0tRmm7qZnTQe5MWVgjm7cLJjSXgbyQIn14szp3QTm/v6V 7BW7cCpcWLMI9biXGQ7gjjXccZC3UGlDFUWQkE4jJcjNI41VcrNAqFD4wWumBMUsjd29 ZOExnjg4qTCiNcFoT0cHXJ0y/4RcVFm3Nb6aWV1qmeaasCZgjX062F+m0HwQMhTsjBN1 f9gw== 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=xPgizVh5v6TH4m1AiatgBsOnpDW0fqlTlenfaMEirS8=; b=quohip4/efp5owPUjc68GlNWYqW+STr/ZzpaNWMTQ+8/S2tslR2xBCCZn484IQg7Rh /5c45sR8cZA1qPRocGlh84IiBrHWYC+RxNRSY0alObUwl5vrMZbtb13sZdzCfr4QoEtK V9A6Ijfhb2yePwggJmfW6tJpDUl+0W6/eXyEKdzaKkJu6F6LZ0uEJ3dEiQp1cFaW5Anz 2nW0CHqHPhHeCK3w7A9/dQi11SREkSIurRY0uCYqvoLfw3vaS9ms7xhKoNwN0roZd5Dk B5NAYhR84VvBCsQCAb2oSFCcwpQ9QhDolRuwVFxfQuaAAjX5gSotaNOR9Estm//3p8/F PO4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HRxL/q2g"; 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 gb17-20020a170907961100b0077d1df3967asi1890053ejc.563.2022.11.24.13.23.08; Thu, 24 Nov 2022 13:23:31 -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="HRxL/q2g"; 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 S229690AbiKXVVo (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiKXVVZ (ORCPT ); Thu, 24 Nov 2022 16:21:25 -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 E1BA494A6D for ; Thu, 24 Nov 2022 13:21:24 -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 80F4B62257 for ; Thu, 24 Nov 2022 21:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD92CC43147; Thu, 24 Nov 2022 21:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324884; bh=FrCQktxb/IHIkJr0quKPsuPjXDJwuo+SRuylRA+I1fM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HRxL/q2g8NWpSQCutGPjfq4P2N/YBsWxmeL5Gok4EK2itrLtEnIQ24rhpi0GZzI2t FALEHRm3hMVoWYKWgI6T4Og4yKjy+KOh3oY1U3PFY4FGn6QUWwWVLwVW274l7eEn5w +utRorYUkFfkos6yTaO+uuKYX0gHxaYGdpRyX69kb3eMo51IKZW3ro8TBplYwathq7 Og8dIjZUI1YThNcJaBo9oyPITPqoo6MIADODcXVzRqwEL3iq04Agg2Msai9wMvIFbc 3jnNWAwmB8o4d0jzMIQwnIDjKtshiR7qvil6B+Ng13wZnj++p4uCBytRZp38XpgKGE ieAYUaSeE6fJw== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 08/11] mm/damon/sysfs-schemes: implement scheme filters Date: Thu, 24 Nov 2022 21:21:11 +0000 Message-Id: <20221124212114.136863-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414143535208365?= X-GMAIL-MSGID: =?utf-8?q?1750414143535208365?= 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 | 85 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7f2bab617156..6f014b328e6f 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1402,6 +1402,71 @@ 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_CGROUPS + cgroup_path(memcg->css.cgroup, memcg_path_buf, PATH_MAX); + if (sysfs_streq(memcg_path_buf, path)) + return true; +#endif + 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)) { + 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; + } + } + return 0; +} + static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_scheme *sysfs_scheme) { @@ -1410,6 +1475,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, @@ -1435,8 +1504,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, @@ -1447,6 +1525,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; @@ -1469,6 +1548,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 Thu Nov 24 21:21:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3616842wrr; Thu, 24 Nov 2022 13:26:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf6neTjebmCnXWP3Ur3LTHb6BzKvgsu0rwg8F9w2PJFLrSIwdPtl5qIGTWx1d92Hbp9BNbAd X-Received: by 2002:a17:906:7d50:b0:79e:4880:dd83 with SMTP id l16-20020a1709067d5000b0079e4880dd83mr19313523ejp.166.1669325178612; Thu, 24 Nov 2022 13:26:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669325178; cv=none; d=google.com; s=arc-20160816; b=Afhr1r0vOHsLqKRckx4FmGuvc/OvqZBbLX3SK7QYGjTj2Vdfqfo4qN54f4+c/n9ZBX JCUZRDzkXiWCLygtna2e+unmRy6OZTpOOq0P04Ie7vKzz492kt5wuqR9qo4fkQnQ9Cuf edD93yhcB+Gia9//+4EmaKv3NeW6xT/FQN8wivUcPb63s2Q4X9DLDzG7B9nVtAvhdkjc J0j3ckpSRAbhURBfEWl93q2KtGCKtQAE7VrBiAH+BfGBlt8qFTgLaS0+wDbT9rN59SHE TOhUF7JIyG5VdmuckoMijMLh9Q9of7fKLd/9ixUcBklKhqyIaD1itvlzCHEoCkHZjjIw 2qJw== 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=K/xuMP4I3E79vrL2c1HeLbbfM2iDHToY9qN0LUy9oMofpruDeqD87bdcIEijuurcPt ZaH4F1CDm4/wp80DrIuFB0+xxn7KqpyvXpESFIgnn5u2NzaV1JFaM5Rrt1O5jnxyAFQB 5LaDr1HZQ9P59gUHiVNGEX+esNrcgUmJPe1ByRCayNxDcJmUauEaFOkOzB0abCSYVY1k RMXxLPsBhGxNs7h1iypXPevcXFRqlUP53XkO12k5a72ksOCL2X3BuU14u2cyagszfWJk wvnbtEnKU7WKOzodLE/ORlKB/5qWftR2FwVt1+Bm+pbbQ7nroF62oApBl5l5J9Gq+6oB iDng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bg/AaYGu"; 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 t18-20020a1709063e5200b0078dbec0aa81si825579eji.214.2022.11.24.13.25.55; Thu, 24 Nov 2022 13:26:18 -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="bg/AaYGu"; 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 S229676AbiKXVVu (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbiKXVV0 (ORCPT ); Thu, 24 Nov 2022 16:21:26 -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 975D793CF7; Thu, 24 Nov 2022 13:21:25 -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 33C886223E; Thu, 24 Nov 2022 21:21:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83EE2C4314E; Thu, 24 Nov 2022 21:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324885; bh=qgpIYxCoLxiSbmookPCEJSX95mijzZoDksXEWue5IhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bg/AaYGuCYp4M6g57krHOS5GWS+hMi8p5mp+UkjqKaATqZdbygBxDo8pgT5J/V8X5 SeOHpO64VwGb7y2NaTnqWlKcalc/qi6/1yqlseWD2aN0cLZ/0YkzPD+ojVlCjvRKEV tSYo5MiT45nugk3U6ZhWpSImAmvbsV4ikvCk3UFc4RYwy3Ha4KpsJGmK3YSgVoFkQK x8D4bqBobH8wUsPcV4hGQ3erCz7bbPrQmYK9GHlUPwBQrZ6x6vEN9uq+K11ExWHJHy 2xNyShxK/2Ww69uIIYUGBPs7HvreQTYXdhvw2zuS7KG/0AVZPTh2PUzt8JDtgk8pt8 Y2I5aPTMH5/IA== 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: [RFC PATCH 09/11] selftests/damon/sysfs: test filters directory Date: Thu, 24 Nov 2022 21:21:12 +0000 Message-Id: <20221124212114.136863-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414318638350590?= X-GMAIL-MSGID: =?utf-8?q?1750414318638350590?= 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 Thu Nov 24 21:21:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3619136wrr; Thu, 24 Nov 2022 13:33:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Vz1MN36WnwsjWa4mbanqM84Uzo9e7PrZNoxI/nHMlu8k/zTAg6FyFrQgHbrPnAG482CvN X-Received: by 2002:a17:906:3a41:b0:78d:9caa:31b7 with SMTP id a1-20020a1709063a4100b0078d9caa31b7mr14751701ejf.263.1669325583588; Thu, 24 Nov 2022 13:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669325583; cv=none; d=google.com; s=arc-20160816; b=XoyZC+lBlCUz6aq/okX4GR6U5nJkmwElQJU22Hun1R8rBXE1M+KaObK9cHVlwsihRM IeVxkof+eNn/CGQEqDU+2pn9QZZ8T/81jHxJCLDAqqWWDBQH2wru1G3Vd4nKJ2j1Eoiy Bou0SCbnGjLgO1npr2w7qyH3MudXAc9CERjD03QT546+gIbT9n9ruCJ3SONKX0Zh7hYL ki/a/iorzis6yNU+jg7pA0eB6+OhSpiE4fJFWtuc64r9knLYNBW8uI/5jOgJiLRQojhe gg3+w/POclZjdS5O9mf/dnAoMZCSvymRFaPfMBQL37w0BqHmW3fiUQec5Ga1m/EWnv5+ tcEA== 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=hMZfvt7TwYaXBfs9CqbK1bd8l2XD6ykUEGu1i2bS5ruSJPmGrtDiLGGuU+U+wiIveB lXzEIKJ01bvfj52DjNDuyxlBopO4+XjEzQLtSoWne7YrLoPCXyODRJAolf6RASGFG1R5 TbzIp0I3fjRnAHaCfteUTF8l2DOJyK2iPtE/GCIFOANiuHychL9begAuNs94cQZO16UL o31MkIxGBTO2DpEfeYb2zVMUWv0RZFLLKguDTEb8sdw2MFagPHxrsWu3tVDXwVkMdNkf kq2W/it1MBn/rILQF5R+xvk7pyimFs9vXIUjVxJGolWT9aqmD0kPcLAmIz84E+1V/Tkg jSWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qUjgEscQ; 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 o9-20020a170906974900b0078223ff2756si1926137ejy.244.2022.11.24.13.32.37; Thu, 24 Nov 2022 13:33:03 -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=qUjgEscQ; 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 S229756AbiKXVVy (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbiKXVV3 (ORCPT ); Thu, 24 Nov 2022 16:21:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B300950E3; Thu, 24 Nov 2022 13:21:28 -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 EB52CB828DB; Thu, 24 Nov 2022 21:21:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39D8FC4347C; Thu, 24 Nov 2022 21:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324885; bh=r1rD9KyNMBqJg8aGe8o3Z8JXG+myDQ882BtgLSHPqNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUjgEscQClwo6WemlMmyVkQcyAdOazaD4oNfXaCdV2/UsJsDcRJsDeEGq2OaUHB0Q dZXgZFk9mMS2qVQZEBPnOPMqkJ6eeMeU5XxquL3Mh/lR/iwksqM9Mj2iofHucZwPDQ DhzkcbCF8tsK98kfcM+3CxgJudUlWk4s+59VPkmyRvSbTKFTuQ928ckHt/00s8bCXF Qcb7yPnReQEQNzhEyT0OPXVlsHqal9sqMXP/y5pzAJjcshjaMSy5dBVKU9GTx3+U+3 kameP1nAqmJIXnsz3XobD1ANGRnEHhNf7wOw/vMo5uekrxo2lu9HKwvI0lwgQD8otk mFPTE1n1JQD9A== 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: [RFC PATCH 10/11] Docs/admin-guide/mm/damon/usage: document DAMOS filters of sysfs Date: Thu, 24 Nov 2022 21:21:13 +0000 Message-Id: <20221124212114.136863-11-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414743317718048?= X-GMAIL-MSGID: =?utf-8?q?1750414743317718048?= 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 Thu Nov 24 21:21:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 25710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3616813wrr; Thu, 24 Nov 2022 13:26:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf4CkHEG+ZpGLMBoRzjFpp5gTYAKkf2C2Xjm/BK5bAoadXmB32fa3krvJtibf0kSfEGvLALj X-Received: by 2002:aa7:cc93:0:b0:462:6b8e:1ddb with SMTP id p19-20020aa7cc93000000b004626b8e1ddbmr31053175edt.276.1669325173020; Thu, 24 Nov 2022 13:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669325173; cv=none; d=google.com; s=arc-20160816; b=yLEf6W38eNerLJRA/sQh6kGA8K1vRnbh59vbr6Z2vjnwuWaKHL62KytCjGn5mYy1Fl Huar8yWRmQLR7xumtKbYtlgPVZvolggSMC/PVc0BD65/qrgC6ip2r++gBZ+vX1HVGmVA hXxevv1EtOhGsd68XDpO78r55G3jtjn68Yn0y99Q3jrUhxgY+HeNzxe72vystZdC+WCM fSVzpg96E4OPQ6x/wyoLFuDE9iG0wAwyOn9Gt0BtQ56XV09AgV6yNP+0h439gJaqKv9D qE5Rs/RO4DbU4kUfCKa01Iw1/2IQAE2ECM1SPTQFREdrSuRf2F/qBIiZkT7caP7MTH+9 5x5Q== 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=aWL9mIxdIGjHxuJI9Wbqwv0RgYFnrGCGf+4rTJtiyWJU7FTAMOTNgEGpJ3bRrWQFsv 0WOlYLl+EczDfbXTlcBws198/UkDYmZZfsC92SscGZ2ID5jrZX4veH3CeY6NJnAcMjar zlWZlNLBnheeEmbF2wGLwN7C+fWvYLma0UY+hbBHBwF7EM9706X5o+kJrCc1gbWum1al zOqpU0GZCeQfvofHY4/NtE1d4Yx7GcALKxKc4TjAVDTXZoIPkeLYPp+hkqhNLqk0scjl uHTs7i7msyex3wmiCHvuQYS2in+6WDvT1ZHfVUEcHJU7yxewPLK8s+HSCdND6zqu5rGf Eg9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YDg+vzz5; 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 ji10-20020a170907980a00b007b5ce4a436esi2225277ejc.513.2022.11.24.13.25.49; Thu, 24 Nov 2022 13:26:12 -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=YDg+vzz5; 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 S229751AbiKXVVw (ORCPT + 99 others); Thu, 24 Nov 2022 16:21:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiKXVV2 (ORCPT ); Thu, 24 Nov 2022 16:21:28 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D599674D for ; Thu, 24 Nov 2022 13:21:27 -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 E1E896224C for ; Thu, 24 Nov 2022 21:21:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E417CC43148; Thu, 24 Nov 2022 21:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669324886; bh=wsgdvbT/35uxHZu2m3onVtLPaAGvmOTx9y/8CzTLOOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YDg+vzz59qn2HGlc430DM8drl6oinc/UL0FpJCDPYW0zg6kwKIMMK7ZH91NR/v7Tc ntUk5ZVoJfTah+eY37CEbVI1t05GDdP8YA/IZrpMUoCqBmMfAWpDjV3wCdVTfK4CCS 3sFVxXLMWYVpheee7x+D4QjZJENE2FSd7g3hsONkaRcNY5G+5dczXqysiXaZeD+HzP /dLKkOBbMCOWzw0KRG4+LhOy700ioqjoBJQdIVUO67vhXsdrEZMfCGcE6Yt2epQRvP kpkaEj1Ly9oJjZgzRkQ9TarH/pCZjAPV/+mR98Y3xXdQjVm67hi/WP4tBua8Bv4twc 8vrIMAkhlxs3A== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 11/11] Docs/ABI/damon: document scheme filters files Date: Thu, 24 Nov 2022 21:21:14 +0000 Message-Id: <20221124212114.136863-12-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124212114.136863-1-sj@kernel.org> References: <20221124212114.136863-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?1750414312629971740?= X-GMAIL-MSGID: =?utf-8?q?1750414312629971740?= 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