From patchwork Wed Aug 2 21:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA8B4C04FDF for ; Wed, 2 Aug 2023 21:43:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5163B2801EF; Wed, 2 Aug 2023 17:43:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 425DD2801EB; Wed, 2 Aug 2023 17:43:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2785D2801EF; Wed, 2 Aug 2023 17:43:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 140A82801EB for ; Wed, 2 Aug 2023 17:43:20 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CF13241022 for ; Wed, 2 Aug 2023 21:43:19 +0000 (UTC) X-FDA: 81080490918.08.EA58670 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 1C631180011 for ; Wed, 2 Aug 2023 21:43:17 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XTxyZN9w; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012598; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=m2EB/ZNIq7o1p24186AiZxZCg7n63aXOu1SRfHcwmTQ=; b=7BLnf2L/DekizPV+VywD/ouUUzfLY5TbZiLZE9seNvCIOaRBvjlHhVMnviyXurBvv7PNgu T1/RT/rJzf1XSX3jj7aunqDsR2TU7S6T+Y2T6iNdQmeFTugZPuDz3PlfznKQXXdp2gFduK 4fQmeAJtYlTNd4n3nZxeOeNQqrGpuCI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XTxyZN9w; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012598; a=rsa-sha256; cv=none; b=Uc2KtYbSbHd9k9ckzdeU4ybPRk1kQ3EmTMczGYB9Yv+a/ID0zvCeveN2sk6L6Wzh3mj3p9 jO37KdYq22fD5v8Ni/k2rgr8DJDSkCyBDK/4yjxZG29QeU/Zr2S4vE+3g64v9Uk766AM/7 2fUx2FcUknJMDb6DfI2397Dn/5HHBHk= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3F82F61B3B; Wed, 2 Aug 2023 21:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 411BEC433C7; Wed, 2 Aug 2023 21:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012596; bh=kMVc66oZXCOktM4R7/awXD6J4keYYzNjFUaNutsI2bU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTxyZN9wgm81uYCBD8tsYa8GiyQrknkGGCqGP+Zp6Wc+lvHBHfpOQUmIBlKSTGYmh 1UKD17lJBeOavBqNqJh3fOpnflBOMfvY+Bx0jYBVEh9fZDHTjC1jP/dOaSqYFRl+jQ veY9IxAu4ARncosqjFWMds8VXLP9r2WxtyD1BaEJhw27OGS7l0Q+iUKN5psDk0se7K fo0JmD6X43tdBI8eG86p92nY0vo9ypmrouOlHNvXMWIrOP1qktU2tIGPQ6yqqpzsfG st/A6Dt42kSWmistvHhdf0bjHrvd2e8qx+VIySEG2VKdtpNHM1uHAeQMlcVifJDMHs fhvvpLexHQ2Hw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/13] mm/damon/core: introduce address range type damos filter Date: Wed, 2 Aug 2023 21:43:00 +0000 Message-Id: <20230802214312.110532-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 7fpp1zkuhgj8t177qubz8ga3puyfc6wj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1C631180011 X-HE-Tag: 1691012597-789948 X-HE-Meta: U2FsdGVkX198tc3AqapgQoMdxt+i1oKU9Ytx9io19X8Vnu3SDPpDqB1gpjMVly27OpOyPZXn9r6O/CRLd9KJSq7s8GMFreou8MZ74eJVdQq6WCsT9pe+G8eg6oyDx8k2UxnLZtl/3H6B5iyllkiKp7etuTbc0kKH5DTKAD5b6F3G3tle6RmkGLL1lopNRlELMWWJ4FacPYMdxfJRkp1BeIMbHOe7sfrCGX4z6G1vgB197I6a3q2MiXVdZc3DGcNDVGtvQSaLHP5FkbAow8RxP+HftzXfyW+mqv/GWYpld8j4ID9+vcDj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 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Users can know special characteristic of specific address ranges. NUMA nodes or special objects or buffers in virtual address space could be such examples. For such cases, DAMOS schemes could required to be applied to only specific address ranges. Implement yet another type of DAMOS filter for the purpose. Note that the existing filter types, namely anon pages and memcg DAMOS filters needed page level type check. Because such check can be done efficiently in the opertions set layer, those filters are handled in operations set layer. Specifically, only paddr operations set implementation supports these filters. Also, because statistics counting is done in the DAMON core layer, the regions that filtered out by these filters are counted as tried but failed to the statistics. Unlike those, address range based filters can efficiently handled in the core layer. Hence, do the handling in the layer, and count the regions that filtered out by those as the scheme has not tried for the region. This difference should clearly documented. Signed-off-by: SeongJae Park --- include/linux/damon.h | 22 +++++++++++++----- mm/damon/core.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index d5d4d19928e0..476f37a883a4 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -226,16 +226,24 @@ struct damos_stat { * 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. + * @DAMOS_FILTER_TYPE_ADDR: Address range. * @NR_DAMOS_FILTER_TYPES: Number of filter types. * - * The support of each filter type is up to running &struct damon_operations. - * &enum DAMON_OPS_PADDR is supporting all filter types, while - * &enum DAMON_OPS_VADDR and &enum DAMON_OPS_FVADDR are not supporting any - * filter types. + * The anon pages type and memcg type filters are handled by underlying + * &struct damon_operations as a part of scheme action trying, and therefore + * accounted as 'tried'. In contrast, other types are handled by core layer + * before trying of the action and therefore not accounted as 'tried'. + * + * The support of the filters that handled by &struct damon_operations depend + * on the running &struct damon_operations. + * &enum DAMON_OPS_PADDR supports both anon pages type and memcg type filters, + * while &enum DAMON_OPS_VADDR and &enum DAMON_OPS_FVADDR don't support any of + * the two types. */ enum damos_filter_type { DAMOS_FILTER_TYPE_ANON, DAMOS_FILTER_TYPE_MEMCG, + DAMOS_FILTER_TYPE_ADDR, NR_DAMOS_FILTER_TYPES, }; @@ -244,18 +252,20 @@ enum damos_filter_type { * @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. + * @addr_range: Address range if @type is DAMOS_FILTER_TYPE_ADDR. * @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. + * Support of each filter type depends on the running &struct damon_operations + * and the type. Refer to &enum damos_filter_type for more detai. */ struct damos_filter { enum damos_filter_type type; bool matching; union { unsigned short memcg_id; + struct damon_addr_range addr_range; }; struct list_head list; }; diff --git a/mm/damon/core.c b/mm/damon/core.c index eb9580942a5c..f3a821215230 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -878,6 +878,56 @@ static void damos_update_stat(struct damos *s, s->stat.sz_applied += sz_applied; } +static bool __damos_filter_out(struct damon_target *t, struct damon_region *r, + struct damos_filter *filter) +{ + bool matched = false; + unsigned long start, end; + + switch (filter->type) { + case DAMOS_FILTER_TYPE_ADDR: + start = ALIGN_DOWN(filter->addr_range.start, DAMON_MIN_REGION); + end = ALIGN_DOWN(filter->addr_range.end, DAMON_MIN_REGION); + + /* inside the range */ + if (start <= r->ar.start && r->ar.end <= end) { + matched = true; + break; + } + /* outside of the range */ + if (r->ar.end <= start || end <= r->ar.start) { + matched = false; + break; + } + /* start before the range and overlap */ + if (r->ar.start < start) { + damon_split_region_at(t, r, start - r->ar.start); + matched = false; + break; + } + /* start inside the range */ + damon_split_region_at(t, r, end - r->ar.start); + matched = true; + break; + default: + break; + } + + return matched == filter->matching; +} + +static bool damos_filter_out(struct damon_target *t, struct damon_region *r, + struct damos *s) +{ + struct damos_filter *filter; + + damos_for_each_filter(filter, s) { + if (__damos_filter_out(t, r, filter)) + return true; + } + return false; +} + static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, struct damon_region *r, struct damos *s) { @@ -895,6 +945,8 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, goto update_stat; damon_split_region_at(t, r, sz); } + if (damos_filter_out(t, r, s)) + return; ktime_get_coarse_ts64(&begin); if (c->callback.before_damos_apply) err = c->callback.before_damos_apply(c, t, r, s); From patchwork Wed Aug 2 21:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3483AC001E0 for ; Wed, 2 Aug 2023 21:50:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A95662801FC; Wed, 2 Aug 2023 17:50:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A45CD2801EB; Wed, 2 Aug 2023 17:50:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90DED2801FC; Wed, 2 Aug 2023 17:50:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7DE402801EB for ; Wed, 2 Aug 2023 17:50:07 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 45C9080580 for ; Wed, 2 Aug 2023 21:50:07 +0000 (UTC) X-FDA: 81080508054.12.677064D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 825384000D for ; Wed, 2 Aug 2023 21:50:05 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=d7xhpD4E; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691013005; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zxVpN4g06DUCb7PKXyAD338noc2KODnd6S5Q4w7jTog=; b=QDK6+y1yYxD+ufn7P3ETkm/te5aWO3lx7FMa9Txq9xPJHuSaKencNWQGhltWJtflDoouEW NtHE2blThOOnUxrjI8xn4GFN/1qpotoy+dbhFkcGQFxxSCfPdPwafHBueM+Ry5geDh2Ce8 JBwKUXmQUNEW6FE0iKqMKdhD7cdH0DA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=d7xhpD4E; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691013005; a=rsa-sha256; cv=none; b=BmHC6y36RBQoCl6VnixwjLCTeUyOIRfRW9Y2sH4i0wjGL1L2ghrRk6yZrFXEFJwii+GGFp pXSJnWvo5LyLJVs2kU4ouGuB3rHk45n/zcRQua1aMAmlJfDiqeOmgjrsk5we4YABDSwWs9 Aq7ftsosOnMUecGkSrgik3Cl2PtaFXY= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF4C661B41; Wed, 2 Aug 2023 21:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5911C433C9; Wed, 2 Aug 2023 21:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012597; bh=JP7uB7/G+cUBWmCMFTcCRqLSa2LcbVSrJBh+8gJznBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7xhpD4E6+xzHmLfpPR8xGJeolAoLBdQ9cU9bmsPDrhUUzqAQB3BxkMswSpzjfR7F bZc3Fqr8n6GnLlqOfjjloocRUENNRBb6HKHdzqmAYeY82HvBo/5IlyyO6BqiyHQnij dUzqJPM7nGRPpbnBigsMKPqICuvROkUfZbHmLB9QiP7TRI7y7YStlKiqvORxaaIrYO 56CifiuxP5cepT2YUYx7ld/O9AQQw5Kf1eRKYDuxPmxQSJZeaYsRmtMiZlcXClpoPh emu8Mso4037QQC16Eiv96YfdCCV3p08+4tqrovf0W5WO8TOlmLqyn9Ra5cl2E9Xze4 IAfLeY30ehFPQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/13] mm/damon/sysfs-schemes: support address range type DAMOS filter Date: Wed, 2 Aug 2023 21:43:01 +0000 Message-Id: <20230802214312.110532-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 825384000D X-Stat-Signature: 5jto335o6i7qkhhq83exrdcyykm41iw5 X-Rspam-User: X-HE-Tag: 1691013005-752380 X-HE-Meta: U2FsdGVkX1/wn+cbTrILk3ubbvy1Lbi9Tkx8uDJJhZr3gBO1c9ST0qFRxiNNMJGKPo2YDeTajsY3mf331hQEhQV7G1TG+/pVjHFyILVqGwGi6g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9RGW3dJr6p+R2EFkg8EF6S5cBXYHiqZGr8/fV5ebIl8050gqlq/pklGfTQjC5rBO8L/RSt+TlsIXgSuQOdcwdniDlWBD0CZrQg/t46tUvsiJUzLTWd7CH7kkLJLeZnb0XpsHEFgwYKIme6Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Extend DAMON sysfs interface to support address range based DAMOS filters, by adding a special keyword for the filter//type file, namely 'addr', and two files under filter// for specifying the start and the end addresses of the range, namely 'addr_start' and 'addr_end'. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 9a015079f3a4..03ddba3e216d 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -282,6 +282,7 @@ struct damon_sysfs_scheme_filter { enum damos_filter_type type; bool matching; char *memcg_path; + struct damon_addr_range addr_range; }; static struct damon_sysfs_scheme_filter *damon_sysfs_scheme_filter_alloc(void) @@ -293,6 +294,7 @@ static struct damon_sysfs_scheme_filter *damon_sysfs_scheme_filter_alloc(void) static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", "memcg", + "addr", }; static ssize_t type_show(struct kobject *kobj, @@ -373,6 +375,44 @@ static ssize_t memcg_path_store(struct kobject *kobj, return count; } +static ssize_t addr_start_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, "%lu\n", filter->addr_range.start); +} + +static ssize_t addr_start_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); + int err = kstrtoul(buf, 0, &filter->addr_range.start); + + return err ? err : count; +} + +static ssize_t addr_end_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, "%lu\n", filter->addr_range.end); +} + +static ssize_t addr_end_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); + int err = kstrtoul(buf, 0, &filter->addr_range.end); + + return err ? err : count; +} + static void damon_sysfs_scheme_filter_release(struct kobject *kobj) { struct damon_sysfs_scheme_filter *filter = container_of(kobj, @@ -391,10 +431,18 @@ static struct kobj_attribute damon_sysfs_scheme_filter_matching_attr = static struct kobj_attribute damon_sysfs_scheme_filter_memcg_path_attr = __ATTR_RW_MODE(memcg_path, 0600); +static struct kobj_attribute damon_sysfs_scheme_filter_addr_start_attr = + __ATTR_RW_MODE(addr_start, 0600); + +static struct kobj_attribute damon_sysfs_scheme_filter_addr_end_attr = + __ATTR_RW_MODE(addr_end, 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, + &damon_sysfs_scheme_filter_addr_start_attr.attr, + &damon_sysfs_scheme_filter_addr_end_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_scheme_filter); @@ -1484,7 +1532,15 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, damos_destroy_filter(filter); return err; } + } else if (filter->type == DAMOS_FILTER_TYPE_ADDR) { + if (sysfs_filter->addr_range.end < + sysfs_filter->addr_range.start) { + damos_destroy_filter(filter); + return -EINVAL; + } + filter->addr_range = sysfs_filter->addr_range; } + damos_add_filter(scheme, filter); } return 0; From patchwork Wed Aug 2 21:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8809EC00528 for ; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B561C2801F0; Wed, 2 Aug 2023 17:43:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB7062801EB; Wed, 2 Aug 2023 17:43:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86DE82801F0; Wed, 2 Aug 2023 17:43:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7023F2801EB for ; Wed, 2 Aug 2023 17:43:21 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3A5FCC05FE for ; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) X-FDA: 81080491002.26.FC5D2AF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 5D83740009 for ; Wed, 2 Aug 2023 21:43:19 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LvH1bZLS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012599; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H7I3qOLZIoxUPB4H66Z79LzMY2GKKRBloWv4nV8FqAk=; b=tzuceuokA3THg8W71cWIU037VkKThXqcsIDTRQ0Q7JF+7JZoegVflSw0DLkIFP8UHgWBMa WM59geid92iCptfkH00uKL8v1Qx7wfxudPX0frcgjtnhkNhMBxozq/GAp5jWsI0pG3aEwO RzZMNTx8e94eZg8uCmggnygJY1/A/LU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LvH1bZLS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012599; a=rsa-sha256; cv=none; b=aCrWGlQCRIfhNpoySW1I8cRZn7BMLbBQ3RIOLufVUVwW4fdGtQ52P0hQKzqHCLhFOrkAcE Xp92OmyuJ7h5rQiExdrLZYgk204+MCZfX5BV94dMTNvAl4cu4ndV8wA3bLFIle5roMOn1l 764Wdp1MJvAQ0dIflFSx3rCZbunVdz0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9671261B32; Wed, 2 Aug 2023 21:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 761AFC433CB; Wed, 2 Aug 2023 21:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012598; bh=plLKrdhuxTu4fXv62XEDStD9l4o2qp5Q+Y0GoiThmrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LvH1bZLSqUYN0scYv4lgnIiiDHf/QbLHgwsHOhtc3Vu4diL5ne6xiURe9ZI79A1j/ OIqJB+nLKkuOOaOvyLxQ13IN+eONATxWLDnpP64G30W9BWufAZcpdYRYmciHUccQOC nhQyU6uhjVaGyeL6rKJbEg02JFLwjDrrpcGMyjMQNTgRaAs0UTGGvfs/QmfY/lo7Qt 4s7GgdsMoCuHY+hP5os6TKeBmnMtJFXcc7fVhfKPACmGAsu6Ap7zZjyreNQ8Em5OWJ VpOG7/Q3fTDf75C/ilhCKDeDXjPE5ROuB8ebDYWwLJuMDDxyvuQDvsAXCahfNfp5eJ UdAuCeJNT/CBA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/13] mm/damon/core-test: add a unit test for __damos_filter_out() Date: Wed, 2 Aug 2023 21:43:02 +0000 Message-Id: <20230802214312.110532-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: okxj1sfgrfxeiw4jb45o5oejki7shg5e X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5D83740009 X-HE-Tag: 1691012599-135819 X-HE-Meta: U2FsdGVkX1+JWYm+UW2DxiIh/M99s+yzRy0v9wAnBqwTBBGVPe5mqVxS69J9Fn7RLB2LhWJOmLHJmJuX8HjbHAMqo0MDGDXLEgZB8EgE8MCzY/Dp7gCMK5r5nVZjYn8fYLSegoloWaxb/wzWpZQCPWlCVtwHqQaaC5/OoaI/542z5pJzglJyFS76rS2VEd8ftKWSE9Den9NVY8isqLfBW0UhK6A2fnUUourSj0F3NXWtN9zhFaFf4zb4tUQefyE1NJL3o/hkbpg9OB/8siCVAqw3pGQ4Yvt7eT1k/oWBVziCEBtumMIquyeRJymQF0klpLniJdbwhVmdmISBPFRPCEqY8isIMesL9lun6klbSfI1yVddfKqZ01PmwflI317RPnRnZrgaCS92PdUS83JTWgpLsKFYSZPvfaajh2d4CIo8JRmUb6FA+O09vOclOPkU1Mzmab8NrPDj4l/XUPrAF2vmCUKNkZFFjs+kAReMu8XlYLhllxtynKohTO8apL19he1G4zrhCDd8cltmkgt0tF2O997X1QRJiJS2CQ4eXapUHXEvp7CfYI6wxUVICvoieDtWhB7E5gkVnEIIy8ec0TuJ97rcVFMmNeW53WPzyCe1Fi3cm129DWnJlClLCHlWx2ffgkon5gYi2O5HxqmtzAU0vpkpCLpz2z/qjWtx8wQATPq6/HeOKBfBT+BO07iv0jvfIZ4Ug+rW5FFAeyp50ZqbVyL/MEOObhXNNQLFsUPRoaV48iPcCQEQLi5L8kMXTkl+/fjNc6zRuKdypxpzigRuoUSJs2P7IANo7xm4wDAR6esmZ2MItFlWWirsb1ioLtuHj9g9Qlz7NlhFFBDiV8tHZyR5Fvju0g3TeTlr64mw/o2KX4ROmtikjY91TxlX//1FBA0IOjph6DqVC4a1dbv7zlfL6IxPitHrTqkKq6PAPeQ1aDMBY9ptboUC2aaxxSYNqe6/e9xak2AOtHa wudwqZbf 21pvQPlOliZJ2yNN2MmSgupAcbEcMyTfdG34PR1nE1apENB+WnX/XC8k99pLd30RdVmL03aLnRqvpQI+ziN+BzwM3en4qWEpqgoAxbi3inF3v+5nNhqqo9+apXjh2htpdGut1o/cYvOYqCBOi8h27ybeafr8qG5+rbyZPQUXfZzgvPvoxlhPnvrSDmFeam3b3I1sJzEfN8a46qoJyUPvyJeHYYGpC0g3OV0Ges4rcnAFfNhOs29oh3bK2CeTaUW3nvaCEHbCo5mh7GQKM6d7/U6/HNe3kyiQ0gwSLh8IufjIH8jI5TeKvaG7dE+yxtdyJMqvnYsWOysLuTux1eDjT0qS0LoAR6ccT03n+WrACWC0nsW2QTKgSbTY44b2cyT12x8va X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Implement a kunit test for the core of address range DAMOS filter handling, namely __damos_filter_out(). The test especially focus on regions that overlap with given filter's target address range. Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index 4bddbfe243c3..6cc8b245586d 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -353,6 +353,66 @@ static void damos_test_new_filter(struct kunit *test) damos_destroy_filter(filter); } +static void damos_test_filter_out(struct kunit *test) +{ + struct damon_target *t; + struct damon_region *r, *r2; + struct damos_filter *f; + + f = damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true); + f->addr_range = (struct damon_addr_range){ + .start = DAMON_MIN_REGION * 2, .end = DAMON_MIN_REGION * 6}; + + t = damon_new_target(); + r = damon_new_region(DAMON_MIN_REGION * 3, DAMON_MIN_REGION * 5); + damon_add_region(r, t); + + /* region in the range */ + KUNIT_EXPECT_TRUE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1); + + /* region before the range */ + r->ar.start = DAMON_MIN_REGION * 1; + r->ar.end = DAMON_MIN_REGION * 2; + KUNIT_EXPECT_FALSE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1); + + /* region after the range */ + r->ar.start = DAMON_MIN_REGION * 6; + r->ar.end = DAMON_MIN_REGION * 8; + KUNIT_EXPECT_FALSE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1); + + /* region started before the range */ + r->ar.start = DAMON_MIN_REGION * 1; + r->ar.end = DAMON_MIN_REGION * 4; + KUNIT_EXPECT_FALSE(test, __damos_filter_out(NULL, t, r, f)); + /* filter should have split the region */ + KUNIT_EXPECT_EQ(test, r->ar.start, DAMON_MIN_REGION * 1); + KUNIT_EXPECT_EQ(test, r->ar.end, DAMON_MIN_REGION * 2); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2); + r2 = damon_next_region(r); + KUNIT_EXPECT_EQ(test, r2->ar.start, DAMON_MIN_REGION * 2); + KUNIT_EXPECT_EQ(test, r2->ar.end, DAMON_MIN_REGION * 4); + damon_destroy_region(r2, t); + + /* region started in the range */ + r->ar.start = DAMON_MIN_REGION * 2; + r->ar.end = DAMON_MIN_REGION * 8; + KUNIT_EXPECT_TRUE(test, __damos_filter_out(NULL, t, r, f)); + /* filter should have split the region */ + KUNIT_EXPECT_EQ(test, r->ar.start, DAMON_MIN_REGION * 2); + KUNIT_EXPECT_EQ(test, r->ar.end, DAMON_MIN_REGION * 6); + KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2); + r2 = damon_next_region(r); + KUNIT_EXPECT_EQ(test, r2->ar.start, DAMON_MIN_REGION * 6); + KUNIT_EXPECT_EQ(test, r2->ar.end, DAMON_MIN_REGION * 8); + damon_destroy_region(r2, t); + + damon_free_target(t); + damos_free_filter(f); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -366,6 +426,7 @@ static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_update_monitoring_result), KUNIT_CASE(damon_test_set_attrs), KUNIT_CASE(damos_test_new_filter), + KUNIT_CASE(damos_test_filter_out), {}, }; From patchwork Wed Aug 2 21:43:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 252D9C05052 for ; Wed, 2 Aug 2023 21:43:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27CEC2801F1; Wed, 2 Aug 2023 17:43:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2054E2801EB; Wed, 2 Aug 2023 17:43:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 007932801F1; Wed, 2 Aug 2023 17:43:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E1A312801EB for ; Wed, 2 Aug 2023 17:43:21 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AF4D4A093A for ; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) X-FDA: 81080491002.25.8645CD5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 13DF920012 for ; Wed, 2 Aug 2023 21:43:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="ikb6ovw/"; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012600; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RQJieNk/pr3XHQEgPwJ68VYP9y4g7GJ/7AtQ8sbJiBc=; b=1J8+jJoSScv3l+6/rsl139AITH1OGyDYjc0ui+ApEubUVDLNIILnxREw/OUbI5UD6bwg3s qW/+au5n+bjXIvjE+FhjFxthu8WrqaCja2O2uRs03T5bdlsNAmBvN5omdI8ragYOlQSGii 6UIbN1WaNsNK9u0i3JdCPRrWlK0bDzg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012600; a=rsa-sha256; cv=none; b=nP50iX+DxW4T5ls2kJNkEo1G0wU3h1SNrHTP+osSMw6LfX1xA7E+9m6DUwSo6wUc6rPaoC f3J2mwJN0UBR+QLnWP6IXf1g7NCXejhtTTabXCHqzStGO9dnBnXc6SA0oIWnuFhcY/+GEw Oy61scrNkZ/CbwWYaDWai402pXvBwVs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="ikb6ovw/"; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 43E1A61B30; Wed, 2 Aug 2023 21:43:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A000C433CC; Wed, 2 Aug 2023 21:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012598; bh=cjc8ooSUQ83tCK1u+lTmvslo5pngriB995qOBl2lfEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ikb6ovw/+AobHS2orGwswuXn2tlkNHwauXcRV6Typ+Y049vivhXS52JNo31EJITXY emfTMVPVnHa84OqOMbZVTo5kbKeKGHOpjFsOIeWxAksOBD1KxT8ZuTuTDN9rHg/Wtg F6AsCQyf2TOaPUNj4vCWIaI9DFBrBCpREyoQkRdtVM0UMwWQZ0IvN7lTXtGoZETgG1 Zy9ankfs8/EVYFpEOb4r0JbOi6tvKYPa9H418hI6X4RnEuTQTALWYSvV2UiFkf7cm9 hWtnjYErjiGV3ODf3wRp8IeVQt7UDKHS7oVF7VZO8K+omnCY5RDlEJw9kWy79bTpag AZGMQFafNxOcQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/13] selftests/damon/sysfs: test address range damos filter Date: Wed, 2 Aug 2023 21:43:03 +0000 Message-Id: <20230802214312.110532-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 13DF920012 X-Rspam-User: X-Stat-Signature: m7b5zhjkka95cozunft4zzsqp7rqn6q5 X-Rspamd-Server: rspam03 X-HE-Tag: 1691012599-579327 X-HE-Meta: U2FsdGVkX19XiocGmkp7TIywL5bZ4TNi9hGXwO1ZQhoDjcUCZhz6/JED3RzB7Q6tW77xjcXHBz+pRLdnZ+PPw6kSDu/88Y8/aK3AkRooyiB9EYGV/h5v5Key/TT0a+EzOROqFirRv5DfHdYseEUo5RBIdjL0g6wY72JyFdjZvUXAsd3K8XcWgbslqvTCbQ84o7Uet2WWUEceLyIbohfU+OwenY1E5osrN9Vmfwovo/b2/23RXAliffa8mJHtYbg/FpehiukJ1DVvIowMVSQApHpS0ifq9o5PWfUUsNrUJwHj7V5gGVRIy2srzXwOcD/qr3mHDxzh39QFtqumdyR6vvnDgMtJW4n5PDCqXda6gH8y7M0X04J/4h3MsT7TBpiyEB6e+ITq/m8hbzQ0zG+AcZM7nUcPRziKwguPNPM7bDlP01j0+GfQ1uSJv8pJtdZA1toLTydgpa+s/tJmw+9BGY/M0TCQCKqPB+9SiEZ191c7Yqeb+AoT3xYqTWPCqw+QpTDohV+CUh7rUBZ4lf8gPLibMpAMRISGQwl/pdcTxbivUHIrRaKNNHcRX6cdl6PyxMqL2IyWFHiArkPbjRBzN+U7p3ygqnbLjyVMsysnlLaIJwvSXRb4zMDswG4Ob/bhXSsoC2Q8R12gIzm/dAMWozLZATG8nXDdWRQNPjs+vooDeyiGaxld0zIeIj3UGZzHSIKKgXa+UjIkiGpXry7kJJBQuXv3hV84joVDbFZaMmeOdLqhlP47v8Fbf3VFPNpmCXVGqPWz1A4pYXyQrrnuHbPY8i85dri+4+Qfj7OieYOISmIs6u28kTRmBNpbyDJKVpEWaP/4KO+v3EmXtX3k4JyFlgG2958DEPm1aNHpRs/hMgmUmUCPuFxnb/Rel013sllBnZ+O87O3etX1ksuIkAUudOSY+/gM0mtR142WnEy1UluWIiGOONd8gajbN/8cuMuAKG8FDQVenSq0ffz 60yiyUkO nXolei23i8YThVgqz9pTeq0Bd7B9/hJb1kbxDwgKoJ6wnrL5Wdw9uwqn3u1XTKDkXty5mnCWJ+pkZk23D0S+UjotMrbduXo18VgipgXmWNMa4+PzwmTg2P2HFCKCKvKAt4Ocyg6Pp1sVUVHb2IYC73DVUMCHDUS41jF9zGMDzvEiPzHrKfUX9jdMXwl6EbSikZ5nFdrct/9+nSwCdzGZiSl7oE0Bo/aRYgDP00Xlrnz5b1NTqK19uMaBehczPLkJhA7Gpi1FnNk1cW0843j7880083Coc1UiH4oTl/SMVInU2/RtsoJ9nCYJkHZvghne7izvkXYV+iI9jQ2QFRDBV9oaUwg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a selftest for checking existence of addr_{start,end} files under DAMOS filter directory, and 'addr' damos filter type input of DAMON sysfs interface. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/sysfs.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh index 967e27267549..5677cfd342fc 100644 --- a/tools/testing/selftests/damon/sysfs.sh +++ b/tools/testing/selftests/damon/sysfs.sh @@ -103,9 +103,12 @@ test_filter() 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_succ "$filter_dir/type" "addr" "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" + ensure_file "$filter_dir/addr_start" "exist" "600" + ensure_file "$filter_dir/addr_end" "exist" "600" } test_filters() From patchwork Wed Aug 2 21:43:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 951B2C04FE0 for ; Wed, 2 Aug 2023 21:43:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDAEA2801F2; Wed, 2 Aug 2023 17:43:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C65BF2801EB; Wed, 2 Aug 2023 17:43:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8FB52801F2; Wed, 2 Aug 2023 17:43:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 930A42801EB for ; Wed, 2 Aug 2023 17:43:22 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 51B37C05FE for ; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) X-FDA: 81080491044.22.A504B52 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id AAFB8C000B for ; Wed, 2 Aug 2023 21:43:20 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KUY46xF7; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012600; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N2Dh371ZmBlYpauiue0Vw10+cKdgFzpWgDU1O6AHC1g=; b=rtq5bDngRXp7Fe6aSRQv7L1y7n1LBa/nQ0HYfxW5ueoFcZSRbRTtwad5MlfUDCOy2XcpsT vTFadR9gvwiD7yk8Qfgx5a3k4wQ4fub5PgQvsgpubgWBcPMTRcX9UxvlqQBoQaOR8iRs1H zD1otm1woVjqRyMF4VlpW9hUXMhmYjY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012600; a=rsa-sha256; cv=none; b=IYDt/bxuOXAwRh25CGfd2IkGUkgmx2uEkuq50MLoz3APZcNBLMoeBBR3nQUisT+NBpIyRQ YLpKnCLLiA+r+LzQO/3mbpDzUQGvesgPb3S1YLhqD0+IHNCrsuSeQE/A00k9hqhtHYxJ3t /AdAqRhK48Cdt+HhoPOxMCi4CJTj7tM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KUY46xF7; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EF47A61B51; Wed, 2 Aug 2023 21:43:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF748C433C7; Wed, 2 Aug 2023 21:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012599; bh=OCzjAXySbo2P2W2ofPo/GLfYFykKqV/gINis3/IWY+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KUY46xF7JqWyv4xqIFT5XLrz9FauytM1EkCm1oel9sWJQ0iCMj0WzZBtKq2pXQ+eH 2wuOPp+Gpx8XS7jBUD5QU1IobXgPnT/MdQMklMZD/IoaZQRWBVJfnLrtqGBljC1BZ8 oSrKO0CnfUwrjpnPBPt7lHU4RAIrgaJY18cWctBUEzU/3n+5ZfAZdkq9XBuaANfRKO QYaY46+oWoNTKZJrtiEGDB8ls7al1YS94keLHmddp2Es71dupRGlPFPdY9Clwc9uI6 f3waIxdyaJ652r3kNBOxrQAZXy7XuA9Owyh3fs5aRS/bIsxrpEHBuERf7H7wP0Ptxl FekurPKo97gLg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/13] Docs/mm/damon/design: update for address range filters Date: Wed, 2 Aug 2023 21:43:04 +0000 Message-Id: <20230802214312.110532-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: AAFB8C000B X-Rspam-User: X-Stat-Signature: kwhbnp5simo81zmixdtnrtrr8kqrmaib X-Rspamd-Server: rspam03 X-HE-Tag: 1691012600-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FrNf5bEt/FR8+YVNRA/oLP5wkGnOcmMEAR6A7wWjySWbiNQANurGL5FVWw8HHR3dsBoueiaQiUfFOIpg1HLlpPjITzwnFeQbx+I1kV1wOZshc0H+QaBTzf8kbr3A6gQyN5EjAN1HfvrEviOzkggDnJRzI7ehb1Vz/dONuobPBk0Ec2U+uL4DCghuy6gsMcOy+Ykk5prGbuqMbcpTssTx42BsoQciPThOKqAkGLFRPXIQxIF2cYtgYuRKDS1PwghbSTOMsw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update DAMON design document's DAMOS filters section for address range DAMOS filters. Because address range filters are handled by the core layer and it makes difference in schemes tried regions and schemes statistics, clearly describe it. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst index 4bfdf1d30c4a..134912166f5a 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -380,12 +380,21 @@ number of filters for each scheme. Each filter specifies the type of target memory, and whether it should exclude the memory of the type (filter-out), or all except the memory of the type (filter-in). -As of this writing, anonymous page type and memory cgroup type are supported by -the feature. Some filter target types can require additional arguments. For -example, the memory cgroup filter type asks users to specify the file path of -the memory cgroup for the filter. Hence, users can apply specific schemes to -only anonymous pages, non-anonymous pages, pages of specific cgroups, all pages -excluding those of specific cgroups, and any combination of those. +Currently, anonymous page, memory cgroup, and address range type filters are +supported by the feature. Some filter target types can require additional +arguments. For example, the memory cgroup filter type asks users to specify +the file path of the memory cgroup for the filter, while the address range type +asks the start and end addresses of the range. Hence, users can apply specific +schemes to only anonymous pages, non-anonymous pages, pages of specific +cgroups, all pages excluding those of specific cgroups, pages in specific +address range, and any combination of those. + +To handle filters efficiently, the address range type filter is handled by the +core layer, while others are handled by operations set. If a memory region is +filtered by the core layer-handled filter, it is not counted as the scheme has +tried to the region. In contrast, if a memory regions is filtered by an +operations set layer-handled filter, it is counted as the scheme has tried. +The difference in accounting leads to changes in the statistics. Application Programming Interface From patchwork Wed Aug 2 21:43:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 643FEC001E0 for ; Wed, 2 Aug 2023 21:43:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B06AF2801F5; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1B572801F4; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D23E2801F3; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 622982801EB for ; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 418A9160D0C for ; Wed, 2 Aug 2023 21:43:23 +0000 (UTC) X-FDA: 81080491086.13.39411F3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 5DC0440010 for ; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DmuvGpQG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012601; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LR7oqG+00nkekBNt3o+wrtZoDLPaShEuwa/PeYioeco=; b=V4UHkhrBajF8Au4qyNSU44pwC61b2VKiRbsv1t6nHO7TRKhDvukPCmP5sOgPVUfPUBM6aQ Vdd8b94K7mkrPYj1ZLEp7hJqBy70snU5ofgJMAgN5fyw7suHhsZV0sFU3oSA26kSFtKCdO XEEQjyEDOLIokFymkRrbi1TyLwJQMhs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DmuvGpQG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012601; a=rsa-sha256; cv=none; b=omVzqd8qZLCMe6WvfcPy6Z7yP+YDp4eob35ivhxYLFkeJ5YTMurfp2wbpNTdJZ5uUHpI7O mfhhrM0RMvyYE9+a5Jze47RdBM70Jz/Npj0x3yImMSiGCetbpO5yM0VxFf/7jpwd/FaZft fkboQdW0CPSNRk0ziK6jmYwmHmpri0c= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9E12161B4D; Wed, 2 Aug 2023 21:43:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92052C433C9; Wed, 2 Aug 2023 21:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012600; bh=0npm47qE7mM3V04g26fYupZB0KuQfvcIrbkch6jch58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DmuvGpQGlAkUw9hAqOZXqKjRKwBsAsxuCPkSHgm3kIYifPfLVO8FNIUzDNc0uD73H T2bNTn8jozkgprT0X4+pUyK4KHv5/i/rCTnZ5ZNvSDKiGsTwE+/VopQNhY15M1vXzo HVlFk0wPQygfnrmkrsbp0AlO7ROtpMId1UtWLbaeuX48W2/Zo2wcsLHJwxkPNew9Ul NR/JuPLAV/rjcCR5zCCzk8ohmpZm4BA/mdMSi7G4f7r2JRvO2Ki+EG/KPdskeYJz9s oQJjc9Q5Uq6DZv+iMiYuBJkS0fS3AyLf+dplficscCvhTwev1ZKXzRzcTv5YcRmW/+ vc8M30ajpgunw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/13] Docs/ABI/damon: update for address range DAMOS filter Date: Wed, 2 Aug 2023 21:43:05 +0000 Message-Id: <20230802214312.110532-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5DC0440010 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 8ya5hknr39zixyyf7jgkg9pky6bsm9mj X-HE-Tag: 1691012601-934884 X-HE-Meta: U2FsdGVkX1/WEzCU8p0B8Egx6EKBKaeKPWeNotpByOh+r3QCho1dR4xjZSsrNYQpDDKp3xjwFXQ0lo8Yjaf5OL2/B6A48Lh1Bgjqevr+oGcvSiNHi6f3UzDRZWXQ4hyYb2qES8m4LDh/uL5fgrPb5eznd2b2W8zRJSsHnaTxqt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fJMXy3NMHMuAqwAc20mLy1GD+eUL6OPpDIzgb3aJuHqi3wJSuAcsyK9CaUo7f/uLW2ZAwIwTVbUJvJBEH29rL3dQ6Egi8SMrROjbNrpTniynlMg3X6yWyIlvQXndHkgXwYaRacHkXZkDpUQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update DAMON ABI document for address ranges type DAMOS filter files. Signed-off-by: SeongJae Park --- .../ABI/testing/sysfs-kernel-mm-damon | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index 3d9aaa1cafa9..0bc074d4618c 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -271,8 +271,9 @@ What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters/ 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. + the memory of the interest. 'anon' for anonymous pages, + 'memcg' for specific memory cgroup, or 'addr' for address range + (an open-ended interval) can be written and read. What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//memcg_path Date: Dec 2022 @@ -281,6 +282,21 @@ 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//addr_start +Date: Jul 2023 +Contact: SeongJae Park +Description: If 'addr' is written to the 'type' file, writing to or reading + from this file sets or gets the start address of the address + range for the filter. + +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//addr_end +Date: Jul 2023 +Contact: SeongJae Park +Description: If 'addr' is written to the 'type' file, writing to or reading + from this file sets or gets the end address of the address + range for the filter. + + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//matching Date: Dec 2022 Contact: SeongJae Park From patchwork Wed Aug 2 21:43:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07B29C04FE0 for ; Wed, 2 Aug 2023 21:43:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D34B2801F3; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 030FD2801F4; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B06132801F3; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 845602801EB for ; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5E3581A01E3 for ; Wed, 2 Aug 2023 21:43:23 +0000 (UTC) X-FDA: 81080491086.12.79BB352 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id A35F44000D for ; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VguX3rgr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012601; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DEONY+l/f78gQJGa931FtpQgT8QXzC08LkXhFbdcU0A=; b=YgL6dMtlwHWNq1bK2pzhpTJqyIOi6Qe+JpzU+iVq6rNPPDSU2aufRP+KGEhY37d6/Omlql G8iwx8QXKcLTbjGiVRUJumGVLdDii9mLbPpBhKskN2lWNB6s2+lVh5zJswMqvhewBDMXsI 3iZ+SVm2J4TiagMQtBLEyrR5oNHS3vQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VguX3rgr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012601; a=rsa-sha256; cv=none; b=jLZZQbUHB1o7DKLkBZ+NYcipV1zH9kmwlW6HqZegD70ZQrGmBSIZ9JvKikY7+ceE27/MI+ i4MBhOb/851jaINkXY4ks8ktS97k0bE4MmWPcsBtDNK7dbG19NrFx1yBs5KnpFuMwWxGbF h5u2BhGg3UWaTnqmz3xCWiYdUrZUpVo= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 57B2A61B38; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46091C433C8; Wed, 2 Aug 2023 21:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012600; bh=mWNsxedk/0WTpVC5xcDAG+vRRRu0kRA2F/h2AlUSJkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VguX3rgruXsHFHwRc94yQOIa+8CYImY184CQKh8Axbc20nSL0haxJ1BelLK/Kl+lI kx6SxHyD4tWBMYM783i5u1pCUHe8HhYxsL2rlAMIDalMA/pSzobIQ0kVeRHt927q43 GY99HKHbl5lQyYKaFi3aRreMREW3OX9bCuEV484vLCMGbeKJ4VP8Lm7SQ79For4EkF SjBOeZ5HDzCAWDDmCcfQFXZT0w4jFLg/Z9z3Gm5AKvvbTgI7BD2W96ssE1UHndwOAr aXvpzW8AJ1doO6vO8cwLIrvsu32nTnqlSx2DXFNUYFcDtH52KVI+1vYP/0A+ZQEjWC kT0MuCjPoXQLA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/13] Docs/admin-guide/mm/damon/usage: update for address range type DAMOS filter Date: Wed, 2 Aug 2023 21:43:06 +0000 Message-Id: <20230802214312.110532-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: hh4f1kdmftzm4ctw1f3bb8m6zsyrs5d1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A35F44000D X-HE-Tag: 1691012601-259958 X-HE-Meta: U2FsdGVkX1+OGJavqopQTD+Ca1sIIKmNNgrxZRcGL7EyF3SURBNdyUjmAmE/Xn2yQdAkQBKmtA+6dGWCkaBu3RuXIO6kqhWIclnULkxTVUrYqCSKUKIHssZAR7dS43JzF/nrA+vr1Sn6pBhlvbvX1vcQmTnX+KlczicPjwzXEhUhcBqOWqFg6d9ZInhEpjVGEopB4ecDi+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l3QztTjM3wmG7Ydod0kAXM4MG8cAH3c04s4mp5iUj5JcmhPPBgm/9aiJv53IclYl4BD0T4qE/kNAjFgS1zrEXQLbDPQg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update DAMON usage document for the newly added address range type DAMOS filter. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 31 +++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 1859dd6c3834..a9cb9949b796 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -363,15 +363,18 @@ 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. +Each filter directory contains five files, namely ``type``, ``matcing``, +``memcg_path``, ``addr_start``, and ``addr_end``. To ``type`` file, you can +write one of three special keywords: ``anon`` for anonymous pages, ``memcg`` +for specific memory cgroup, or ``addr`` for specific address range (an +open-ended interval) 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. In case of the +address range filtering, you can specify the start and end address of the range +to ``addr_start`` and ``addr_end`` files, respectively. 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``.:: @@ -385,8 +388,14 @@ pages of all memory cgroups except ``/having_care_already``.:: echo /having_care_already > 1/memcg_path echo N > 1/matching -Note that filters are currently supported only when ``paddr`` -`implementation ` is being used. +Note that ``anon`` and ``memcg`` filters are currently supported only when +``paddr`` `implementation ` is being used. + +Also, memory regions that are filtered out by ``addr`` filters are not counted +as the scheme has tried to those, while regions that filtered out by other type +filters are counted as the scheme has tried to. The difference is applied to +:ref:`stats ` and :ref:`tried regions +`. .. _sysfs_schemes_stats: From patchwork Wed Aug 2 21:43:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE30AC04FDF for ; Wed, 2 Aug 2023 21:43:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B0A32801F4; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 537552801EB; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EC132801F6; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F0B622801EB for ; Wed, 2 Aug 2023 17:43:23 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CD8FF1A0398 for ; Wed, 2 Aug 2023 21:43:23 +0000 (UTC) X-FDA: 81080491086.05.71B7ED0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 33A5A20006 for ; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UkhmslLe; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012602; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qJrAVQE+YnJ0ZTiwPMzL9TE3JJVsBZGJM4ozXLNk6Ik=; b=gmqvKD+8cHreVSZ7zkH0zGqMeYnWgeEjfKEzO/WccO8jIypM7lOSesgBaA9ixdG7Qc3fCV Y5l55G9G+DS3V7rJx0kRj59/RDWRr0/RaQhknKs52rc1XOPLiJyTwW1veC9FYi4qYjqIyK 1Qjwirwj4LdNlYmLakRbmDuSokPUuZE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012602; a=rsa-sha256; cv=none; b=zt6GkeDTlqWPaGX5EpWxyPSoV0qt/SaB4MaBTKsoIxNBgwi4pjJMkaU0r9PPrQldJQrwWa 3UlY6XCX8sg9O2HKg6H50oIZNcSWfaxKtIU36swkw0e8aUu7TsXMvuY3CAhX6uxHMDzZMc 5OCk9uZK+c6bIkSl1wrQ58o/o5bq/wg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UkhmslLe; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DF98361B30; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE167C433CD; Wed, 2 Aug 2023 21:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012601; bh=LLJzB0sVUowPypLPfilJ9ll9ROg8ZjWHW/Z5wJ/sStk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UkhmslLe0GxP2N2+y3vPzxbdNelf/f7eD7yOiTdPNuPH3Itbqqte/gVni+fJGpTId eAkcCedieQMwCnPUJXlPpJouMGDauK0+Krf5yG1mC53UZ7DivLlFCceJmwK8z5ve9p 7b+MEHH8TIDEEN2qUQX2lwcKLVC912GT3PSqdlJsMbBkcOHd23z/vHfI2vwsv0zM1Y AzAbZUETtNv77HAr6UUwxHJ6XDVCNskTBruIlMWojbvqOQwxebuD9iO2QW+0Bjqn4d Qdb96Vu+ztR+6ZkQnom5xLHlcC41PLs2dXATGe2NW+ppJu8ai81YPoYiz2q0vuqaP3 Em2hDewK4gfhA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/13] mm/damon/core: implement target type damos filter Date: Wed, 2 Aug 2023 21:43:07 +0000 Message-Id: <20230802214312.110532-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 33A5A20006 X-Rspam-User: X-Stat-Signature: ts959pw1acre7s5w943b5tg3uyy84kba X-Rspamd-Server: rspam03 X-HE-Tag: 1691012602-194203 X-HE-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nVgfMxBsmXG9T7y406T2mkwwHcfinK4TXd/uaz5vMtaifvax9FuIhZsMQTUeUC6BJbAG+mgTdgQD1cteP66y4HSBHExI7bD6/jl+N+HqR513F1lE20jtWOip+mm4hB1mB8r8LM8pN88tdHdWOuj+AgZ6fXB6bQq/Fpf+EeUzy9ldhXsc9bWCdM/b8ZNTuKhymlMoyFZtYXqzIKRc4pCmZSMl56r10nf9SO7muh2n/fjuDCYfcnlV3g3DoK59YA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: One DAMON context can have multiple monitoring targets, and DAMOS schemes are applied to all targets. In some cases, users need to apply different scheme to different targets. Retrieving monitoring results via DAMON sysfs interface' 'tried_regions' directory could be one good example. Also, there could be cases that cgroup DAMOS filter is not enough. All such use cases can be worked around by having multiple DAMON contexts having only single target, but it is inefficient in terms of resource usage, thogh the overhead is not estimated to be huge. Implement DAMON monitoring target based DAMOS filter for the case. Like address range target DAMOS filter, handle these filters in the DAMON core layer, since it is more efficient than doing in operations set layer. This also means that regions that filtered out by monitoring target type DAMOS filters are counted as not tried by the scheme. Hence, target granularity monitoring results retrieval via DAMON sysfs interface becomes available. Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 ++++++ mm/damon/core.c | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 476f37a883a4..ae2664d1d5f1 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -227,6 +227,7 @@ struct damos_stat { * @DAMOS_FILTER_TYPE_ANON: Anonymous pages. * @DAMOS_FILTER_TYPE_MEMCG: Specific memcg's pages. * @DAMOS_FILTER_TYPE_ADDR: Address range. + * @DAMOS_FILTER_TYPE_TARGET: Data Access Monitoring target. * @NR_DAMOS_FILTER_TYPES: Number of filter types. * * The anon pages type and memcg type filters are handled by underlying @@ -244,6 +245,7 @@ enum damos_filter_type { DAMOS_FILTER_TYPE_ANON, DAMOS_FILTER_TYPE_MEMCG, DAMOS_FILTER_TYPE_ADDR, + DAMOS_FILTER_TYPE_TARGET, NR_DAMOS_FILTER_TYPES, }; @@ -253,6 +255,9 @@ enum damos_filter_type { * @matching: If the matching page should filtered out or in. * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. * @addr_range: Address range if @type is DAMOS_FILTER_TYPE_ADDR. + * @target_idx: Index of the &struct damon_target of + * &damon_ctx->adaptive_targets if @type is + * DAMOS_FILTER_TYPE_TARGET. * @list: List head for siblings. * * Before applying the &damos->action to a memory region, DAMOS checks if each @@ -266,6 +271,7 @@ struct damos_filter { union { unsigned short memcg_id; struct damon_addr_range addr_range; + int target_idx; }; struct list_head list; }; diff --git a/mm/damon/core.c b/mm/damon/core.c index f3a821215230..bcd2bd9d6c10 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -878,13 +878,23 @@ static void damos_update_stat(struct damos *s, s->stat.sz_applied += sz_applied; } -static bool __damos_filter_out(struct damon_target *t, struct damon_region *r, - struct damos_filter *filter) +static bool __damos_filter_out(struct damon_ctx *ctx, struct damon_target *t, + struct damon_region *r, struct damos_filter *filter) { bool matched = false; + struct damon_target *ti; + int target_idx = 0; unsigned long start, end; switch (filter->type) { + case DAMOS_FILTER_TYPE_TARGET: + damon_for_each_target(ti, ctx) { + if (ti == t) + break; + target_idx++; + } + matched = target_idx == filter->target_idx; + break; case DAMOS_FILTER_TYPE_ADDR: start = ALIGN_DOWN(filter->addr_range.start, DAMON_MIN_REGION); end = ALIGN_DOWN(filter->addr_range.end, DAMON_MIN_REGION); @@ -916,13 +926,13 @@ static bool __damos_filter_out(struct damon_target *t, struct damon_region *r, return matched == filter->matching; } -static bool damos_filter_out(struct damon_target *t, struct damon_region *r, - struct damos *s) +static bool damos_filter_out(struct damon_ctx *ctx, struct damon_target *t, + struct damon_region *r, struct damos *s) { struct damos_filter *filter; damos_for_each_filter(filter, s) { - if (__damos_filter_out(t, r, filter)) + if (__damos_filter_out(ctx, t, r, filter)) return true; } return false; @@ -945,7 +955,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, goto update_stat; damon_split_region_at(t, r, sz); } - if (damos_filter_out(t, r, s)) + if (damos_filter_out(c, t, r, s)) return; ktime_get_coarse_ts64(&begin); if (c->callback.before_damos_apply) From patchwork Wed Aug 2 21:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D7D7C04A94 for ; Wed, 2 Aug 2023 21:43:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF17A2801F6; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B531E2801EB; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A6EA2801F6; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7BD852801EB for ; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3C101C036A for ; Wed, 2 Aug 2023 21:43:24 +0000 (UTC) X-FDA: 81080491128.01.1D39FBA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 6CE86C0004 for ; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="MGXW/no8"; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012602; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/kPvdyaF0vEK5qYkstLmLzJYcBFMKcv9CmUtYtZboIA=; b=B8IuwiAMNWaJWXyyIOPn3lxtSF3NVjFg3Diih6dT6rP0/vgVin93gHzEJ237ACYf6bFOLj 5lnlgzXEBZdum21LUMKB0NxmirbyqOCQma0GUVo61jAN8n9sRfNcl1BIVOBI14u32O9nAA RhPttXHx8/phhDLbltNEeUPdAF2IAdA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012602; a=rsa-sha256; cv=none; b=x/1yR526RuDCG9qPozijkW4dMkAqvWPvOIcA9siamHjQFvI5vwTySfARDRRDsAajRkRn0C c664ctwwVN+Fa+0WJKyWFvnemLrozRTHX4dKvtmT6+HFhgnVi4++DBL327F75tVRxPBYE2 G0Gu7EVKY2EW6pEppDSg+/FsqSDbJCI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="MGXW/no8"; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2D71C61B5D; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 864C3C433BF; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012601; bh=Z5TufRLeeFt1IBETpXgGonzkgtF37kqef1//j1myid4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGXW/no8kpmZgpQpS3OiSc3SSTkLbifo0+BdHXTF7aQ9MCoo6qcnEBrp0nq4ukQUf Ag3+nuYsoDCyPt4EH++KRhy7E++Eo7xh3gSL/5rLy5nalVdj0ieh1nqoGZBSkMcO2Q wWUlA1IE7UsJT5pw8B29eHbAGRuqJhbiLaXbDYhwgxYQ1lSyNweW1c7nG6wmkAmqBq dBxpzsKclteCHtOChtqidh0wXZuKzu0R3kfTWEEiA8oFlH8zZpNsDLwvkUvgLkbtPR /ea40Qks1h8F2LQdIl4cJCZyiSj3eltppdoEUSYwwCQOJDNXV2tup7XXkze3Vfz2Ga IzbsOMIF/h6RA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/13] mm/damon/sysfs-schemes: support target damos filter Date: Wed, 2 Aug 2023 21:43:08 +0000 Message-Id: <20230802214312.110532-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6CE86C0004 X-Rspam-User: X-Stat-Signature: u5jpaqki313q9h3sr3cz6zammf9u6mei X-Rspamd-Server: rspam03 X-HE-Tag: 1691012602-893133 X-HE-Meta: U2FsdGVkX19Zbfzk+OoI0tONNl9hSorLY4BGegy3lsZjHeL9JKexvJdQ1Chthb7HM6Ui9E44eDIUeGotd3bbroBraq1K8qt1/71JvjqeB8Sl83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YPYgh0/0IMRQ3QYp0J8OzLVBz18OL1zslQzQ66Nlk2opmLytEIHAXY3vStqHntoyKErSYYlxDIvotn4se4bqIJ+Ir6wIEveCKYGwGsALcqbXMykqyjhhK6n79DIDb0MVFcQgy9CEsYD4eQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Extend DAMON sysfs interface to support the DAMON monitoring target based DAMOS filter. Users can use it via writing 'target' to the filter's 'type' file and specifying the index of the target from the corresponding DAMON context's monitoring targets list to 'target_idx' sysfs file. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 03ddba3e216d..527e7d17eb3b 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -283,6 +283,7 @@ struct damon_sysfs_scheme_filter { bool matching; char *memcg_path; struct damon_addr_range addr_range; + int target_idx; }; static struct damon_sysfs_scheme_filter *damon_sysfs_scheme_filter_alloc(void) @@ -295,6 +296,7 @@ static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", "memcg", "addr", + "target", }; static ssize_t type_show(struct kobject *kobj, @@ -413,6 +415,25 @@ static ssize_t addr_end_store(struct kobject *kobj, return err ? err : count; } +static ssize_t damon_target_idx_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, "%d\n", filter->target_idx); +} + +static ssize_t damon_target_idx_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); + int err = kstrtoint(buf, 0, &filter->target_idx); + + return err ? err : count; +} + static void damon_sysfs_scheme_filter_release(struct kobject *kobj) { struct damon_sysfs_scheme_filter *filter = container_of(kobj, @@ -437,12 +458,16 @@ static struct kobj_attribute damon_sysfs_scheme_filter_addr_start_attr = static struct kobj_attribute damon_sysfs_scheme_filter_addr_end_attr = __ATTR_RW_MODE(addr_end, 0600); +static struct kobj_attribute damon_sysfs_scheme_filter_damon_target_idx_attr = + __ATTR_RW_MODE(damon_target_idx, 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, &damon_sysfs_scheme_filter_addr_start_attr.attr, &damon_sysfs_scheme_filter_addr_end_attr.attr, + &damon_sysfs_scheme_filter_damon_target_idx_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_scheme_filter); @@ -1539,6 +1564,8 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, return -EINVAL; } filter->addr_range = sysfs_filter->addr_range; + } else if (filter->type == DAMOS_FILTER_TYPE_TARGET) { + filter->target_idx = sysfs_filter->target_idx; } damos_add_filter(scheme, filter); From patchwork Wed Aug 2 21:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338870 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFDE2C001E0 for ; Wed, 2 Aug 2023 21:43:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BCDC2801F7; Wed, 2 Aug 2023 17:43:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81EDA2801EB; Wed, 2 Aug 2023 17:43:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FB512801F7; Wed, 2 Aug 2023 17:43:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 430932801EB for ; Wed, 2 Aug 2023 17:43:25 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 15AB41205B3 for ; Wed, 2 Aug 2023 21:43:25 +0000 (UTC) X-FDA: 81080491170.30.C75EF5B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 77E34160011 for ; Wed, 2 Aug 2023 21:43:23 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KNpNnySG; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012603; a=rsa-sha256; cv=none; b=cNc3qdeMfhrG0LpeFQjGZY8j58c4iWqYgeAi1FwNyrmL5s723wCOcptc/zuffjOZTX9qpO fJXyEtBJR3lTPt9ApVMoUlfMFaHv8mfWoOJ4AaQyT5zTBsrzj2JH0vs+l30Gkc7EBE0aHt wZSwLigLUzZ7L7PG50tsKTtv1tP6KPE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KNpNnySG; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012603; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fdzWJripOcM/GiUUkWYEsIFDFoKl4JpaJcuoDMjVXR8=; b=RMqwjDp5PqifJoLX4ZjeojhpbqUX8UhlHPEBzgMN29ter/gkZuNfSq+N3bW9KrEvyQaSPe +l+lYNUDFGX31TiIMnqD8sslPXM/VI5bmQQFEAjFtJocGYLaWiId7sdjaICD3K9J9oFkqH z7jX2lS47808gpEDH6LxL68urnXF1AY= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BA24E61B2A; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C740C433CB; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012602; bh=MiKQzUem1fzoQJpnZETahxS4bhAx7AKf5JO3KUUBnl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KNpNnySGcLwwD9KynrkvcNXQaBRN2V1X98Grk3mr3pGzY865PxRj0dR3+DzNO+I8w hHZqYL0RWX3o6cMHKlY52OMbqe/PwKTQf9K1he85PgX4Ig5eyxoKnhKINzRLDWc2qL c8AI/p7rQnIUnRc0f3gWXf8qhLlPWJgZWRQFlDUpg8b4HwYKp/bXNLjWHBMHceg1HF eQwQPwGIOaDkkp4rfC4gyN4uKtsW0FW1oIMg/ImKkJNj9cNfIImyaYUs2S3ofFaBqm wcAefhDChku+yGHFBeObxNq15C5S2UX6piTUqZRuEoBQWjgEL2GG8msiTo028SJJuP epEhbvqJedrjQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/13] selftests/damon/sysfs: test damon_target filter Date: Wed, 2 Aug 2023 21:43:09 +0000 Message-Id: <20230802214312.110532-11-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 77E34160011 X-Stat-Signature: 91duqnsyhojs3fsbu1bx4m743ng7kj3b X-Rspam-User: X-HE-Tag: 1691012603-496947 X-HE-Meta: U2FsdGVkX19EvR1CfRN18TzuxDhD/+4Nf3dtLrqke7FEO/wlzoKnz7D0WDHJ7aGtUTW5lZOq3Bz2B5r8utFhhAqBmJuZPRny2mRLVD++5X7Tsc3zRme7pgAToR9EJgEtedCUv+iRnPuvRbNqWlp2Jw+mWunuaLwO177J82rjiizCTeiDO3tspWyH7xoNIYgSsiskdOOgHFdUuaog08x0bE8n+ewrTVkG7nt8iNSmTwUZZwLQzyQkB5a+wbah/6RDjxCw1Z9mcxM+0JAwpqenjiFF5ZuK2RNazvjbINgf85rCHP/AiqgOe3RoUaJ2S/5JRH+/poSLwKnlxFn5CyzIps5WajZdg6MwFfw6qRMCKnTRggSQBI4SN8ltG3NOxAk8sWskzOhUZsm6/KY3TFeiUwaoIpqlKUe+uRMa/DE3QpBtNrpvUWTWhLGpA8hNmfJSJRgkA9OCCNQXwHrIIrczPyZSQPBYe3K6iCNMH5khgZaOfI8lV7WIoDHa7gw0o4Vu4gSxQbNxe0uqcnRVx1+zCp4xtqfgJfhTeY446uEDYUqBIW20aBQ4KGyX3YzeCkJ6DjHrtjrLUNMVvdOx6VUemCVU/cIhPxS/I1gcx99Ubp/mv5Po5SdVIM1wt9cktecwTIa1FpUQIM5V57S0o2bX0aDsR3fVfwM6U61zoIOGgv4TeDDyojkKZqlrPmDzauVv75FTrCYFpfzNVJuaFz9Ahkjh6Wc5bAB/6sVlPdi8KMtz7R+jdu9yOObVay3i5i5wBqpWALry9L7GHZeeEtbo6fIAM3yrZ6YIF6tEJ1/cOgJ+CMtULA1SR3d5ojGUhLPfMMSo3XDlrNAdtrvrLO4M3PhyNLx+C32PJddWB8g2pajXflPdubYkXIm1oaTHSTX543wi2v4IHynev0C/Sbq7G6sSrO+F8rKWwEMibg28XUr6E5EOSbKH7dhvNfQ0BP1EM3xmWa+UCc1vb2h1feN 8MaUsGxb UKN3eBgX6P5Jog4TqeccUrd/6YnOQxK5AGemOZ81SWUsHbLGS2TDZDFoNnCTLXh1sDBzaLuSnmIla4bBhSffhe+v+wof/J382JAyOARM+LpO42r8H+Yv3o84/ybidG9wFLqKJWZPPUfP3glnEIkgJBv9KGTUvX9+tOesXe2fbjEztAEAoOwsCJfP+d4pCE+zQLXTH4GSAm1njslhypDPaeoKfvx8ffEJM6r1yZtsLVKpRl81E4SOt9Wuv4MJfsjEIGWR+dy5GWU4CUxxX9WDawMnhUc+Gec+N7M5S1dOlPq14ZqmH0UOV0XZfqYf6TRqD1rlUUVnddTnaMjDplR5VerYQqelBXXMT+OBkspAsJIDEzc2W4InZo+UXGMgQhZ2GRuhr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Test existence of files and validity of input keyword for DAMON monitoring target based DAMOS filter on DAMON sysfs interface. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/sysfs.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh index 5677cfd342fc..60a9a305aef0 100644 --- a/tools/testing/selftests/damon/sysfs.sh +++ b/tools/testing/selftests/damon/sysfs.sh @@ -104,11 +104,13 @@ test_filter() ensure_write_succ "$filter_dir/type" "anon" "valid input" ensure_write_succ "$filter_dir/type" "memcg" "valid input" ensure_write_succ "$filter_dir/type" "addr" "valid input" + ensure_write_succ "$filter_dir/type" "target" "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" ensure_file "$filter_dir/addr_start" "exist" "600" ensure_file "$filter_dir/addr_end" "exist" "600" + ensure_file "$filter_dir/damon_target_idx" "exist" "600" } test_filters() From patchwork Wed Aug 2 21:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69760C04A94 for ; Wed, 2 Aug 2023 21:43:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C6092801F8; Wed, 2 Aug 2023 17:43:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D9612801EB; Wed, 2 Aug 2023 17:43:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18F222801F8; Wed, 2 Aug 2023 17:43:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EC96F2801EB for ; Wed, 2 Aug 2023 17:43:25 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C1D021607A6 for ; Wed, 2 Aug 2023 21:43:25 +0000 (UTC) X-FDA: 81080491170.22.A91F977 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 26B0E4001C for ; Wed, 2 Aug 2023 21:43:23 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=X95R9KkV; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012604; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eduCnC+OYEyOqU/7eWjUVOUI0rGHQmq49SKw029YYYk=; b=ZjxpO9d/X7tEN7HbgtBfTQsMToGKaeWAAq9CP2gg+MNhST3cFqYghnSiywyddb0v6KLDHF Z58h2U+eYaz1IGf7b7aKAOyzuENJ7G08Rgub/zvn7z4d8ZGhNu1w9sL6fO3/iDsTYs8stP 6w0oh9dUIf8S0nIMV9InRjwh2rtXbKw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=X95R9KkV; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012604; a=rsa-sha256; cv=none; b=L50v06JWoySwv8/4mgxWQyd6HktSi3yNCRebBEvZ63ri0U6iqg7SlnUN1DgXZ+w5qdQUrL +cMGBlW15uG1o+9la/BVQS70/1L+8bBnYI5jWvwxrcahk1tO1NbGfvYLLXMDX0L9n2TnSB urE+FihYZA+joAxZ9vPUjMiXqz/smXY= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D14E661B57; Wed, 2 Aug 2023 21:43:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C19FDC433C7; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012603; bh=/3fkCyEgrxb/AUOocTnJxHaLWQx7r2oBGZrkuNBIGj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X95R9KkVDRr3ki6dAqNlbFqXrxEEVHX/lRSSI/qgwcWgfiI3zUd3Q0zIpTOOV3Y63 CDVO7N6DcY+b2efTSCZMfcUIqZaxXdSLdXxtoRCtwVWub6Y1PQXdzwzNvTpesl1v3q gNKU9OORW1ki6GBIb2+Em6y/0kUEy32D5bhIATAPvd4mFg4NB0zWPZuFJH/9w2/LBP QhaBucUBUfqEmbqHMF2QbYb5iAaM1Bo88hLb5yxRHpmgTZCIMtw5koCerfYDy8tQm2 AhADeaeCFqIJCgjvwj2dD9IhR7Gyv3ZMEpHB/ZnKFjoXVfmcYHPWRuZpvhORippGWG YF1l2ciI4grCQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/13] Docs/mm/damon/design: update for DAMON monitoring target type DAMOS filter Date: Wed, 2 Aug 2023 21:43:10 +0000 Message-Id: <20230802214312.110532-12-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 26B0E4001C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: xeryp4prka7muhf3oey3mk1qazad6mu5 X-HE-Tag: 1691012603-348336 X-HE-Meta: U2FsdGVkX1+RsPym+IRkRbWkIlV9HKRmunegsmIIrWhRuk/CLNeaorigFLZQUxw0izqHloWFATDaij4JSgXa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lCY/OdYEEh10L6H9j7t6Cz6EgIShJC1OFidZkBekAIbdjb8vduu+9TohGqkVRab0PHLrQufR6dcmu2RyMEQ4vMLfqFYYpeQbBmfLP24oq40tfwrgD5gzUdK/gDHZBJuK1+fi2MwszLfao5hOU5f/1i78z+BtkmylyAqtnyA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update DAMON design document for the newly added DAMON monitoring target type DAMOS filter. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 33 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst index 134912166f5a..a20383d01a95 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -380,21 +380,24 @@ number of filters for each scheme. Each filter specifies the type of target memory, and whether it should exclude the memory of the type (filter-out), or all except the memory of the type (filter-in). -Currently, anonymous page, memory cgroup, and address range type filters are -supported by the feature. Some filter target types can require additional -arguments. For example, the memory cgroup filter type asks users to specify -the file path of the memory cgroup for the filter, while the address range type -asks the start and end addresses of the range. Hence, users can apply specific -schemes to only anonymous pages, non-anonymous pages, pages of specific -cgroups, all pages excluding those of specific cgroups, pages in specific -address range, and any combination of those. - -To handle filters efficiently, the address range type filter is handled by the -core layer, while others are handled by operations set. If a memory region is -filtered by the core layer-handled filter, it is not counted as the scheme has -tried to the region. In contrast, if a memory regions is filtered by an -operations set layer-handled filter, it is counted as the scheme has tried. -The difference in accounting leads to changes in the statistics. +Currently, anonymous page, memory cgroup, address range, and DAMON monitoring +target type filters are supported by the feature. Some filter target types +require additional arguments. The memory cgroup filter type asks users to +specify the file path of the memory cgroup for the filter. The address range +type asks the start and end addresses of the range. The DAMON monitoring +target type asks the index of the target from the context's monitoring targets +list. Hence, users can apply specific schemes to only anonymous pages, +non-anonymous pages, pages of specific cgroups, all pages excluding those of +specific cgroups, pages in specific address range, pages in specific DAMON +monitoring targets, and any combination of those. + +To handle filters efficiently, the address range and DAMON monitoring target +type filters are handled by the core layer, while others are handled by +operations set. If a memory region is filtered by a core layer-handled filter, +it is not counted as the scheme has tried to the region. In contrast, if a +memory regions is filtered by an operations set layer-handled filter, it is +counted as the scheme has tried. The difference in accounting leads to changes +in the statistics. Application Programming Interface From patchwork Wed Aug 2 21:43:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12573C00528 for ; Wed, 2 Aug 2023 21:43:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E893A2801F9; Wed, 2 Aug 2023 17:43:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E154B2801EB; Wed, 2 Aug 2023 17:43:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C174A2801F9; Wed, 2 Aug 2023 17:43:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A3E972801EB for ; Wed, 2 Aug 2023 17:43:26 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7352B40753 for ; Wed, 2 Aug 2023 21:43:26 +0000 (UTC) X-FDA: 81080491212.18.335D259 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id C55C540005 for ; Wed, 2 Aug 2023 21:43:24 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=InKTFXgl; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012604; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TCUsqQmJnKJM5svbADdALKq1EVL3eMqwc5DVaHvmSMg=; b=NIqQkixeWuf/5lS6yv64l7C00RscpB5wMzl08DV/rK+1dggJAG40Hwt9K2twbyaepMT2Bj tsd7fZZoGqN7YbIc7WiUxJ/BX885WRlA97ONJJ1xta45kK35j4HZZtVM4vcebdvL+fqD1o IGQN3DwcnhVIv05ZCvdRKwXJJGU4e0M= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=InKTFXgl; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012604; a=rsa-sha256; cv=none; b=LjBGcXjofBMVpMojQ5mKru8FKgpzWzMRpb8uW4Lrv6cOs1n/Ov5idgWYr/b7Mnxcg33P3r j2bwZNilRcDuMnYR7cRpKz/lLTe+ioxMnH3qmxxyvGLR+4q+oqnRQiGCpeCfjNmFKC3jgb Gs52MRMzqpfCf2FpSM37wqHvPMK2oCw= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 80EDE61B38; Wed, 2 Aug 2023 21:43:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76513C433AB; Wed, 2 Aug 2023 21:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012603; bh=vyjBGWyxBLS7yKk1ryFlF7UDmbUqwEQwLNgOkCH6QUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=InKTFXglKyqDxzYPMq7NxuLc1kuCMy7s7lSSgw9zcaoztarPdVrWFnCGfQbaD8diT XYkrtAgwTrLYuesB6SPbEwxHNv7DbcZ+Zy2RmEoVzRNJJV0ad47F/S3+7M4Df8R0lb v/FVFU7wdrXt4u4P9/4cy8TUxl1WNvh/Auirz4Xmdfn4kx1gaXYFlALCP0law6E6we 9ySCKnGfQv0yhHkaC1GvNYxVSigA+7WxkHolZNxxjsevvCJ1zdTF+QPVFZ9IwHU+y3 9J43bQ+duZE008f243VXYMyqt1QkpgLLQOpPfgULP8cHLSS/fHir5X/eCgj7vhrBnH QR5XuDszSHpTA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/13] Docs/ABI/damon: update for DAMON monitoring target type DAMOS filter Date: Wed, 2 Aug 2023 21:43:11 +0000 Message-Id: <20230802214312.110532-13-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: cjn4pkookn8ac4c7zyhx7k9mthy4hgcw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C55C540005 X-HE-Tag: 1691012604-237251 X-HE-Meta: U2FsdGVkX18UGG5SmCNG2DdCKCpTExyEFqg8E56o0Qfhlnq3pIQ8aRHXCz67UVJNAWO8p6xS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FSp6yibnTrwg8v66dGsFNnto/fUZ9bfitqAtdk5iJJqMSoCAhdG1nCJVmLJGMIASIdhBlavN1ljwCUz83iOX80vfAepdIsVcz1ixmxRBFztpE+PsUI25vsj4HVJSVDClnNp7zHAPUtnM7QUKrdi+7mavGALwUqzj3Ubo9UqCrWEyisnSmtBg0Z1laTairqdXo1J6k16xZkfQ91OazTajri2Qxs8SCerHbdD/7w7ay0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update DAMON ABI document for the newly added DAMON monitoring target type DAMOS filter. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index 0bc074d4618c..334352d198f8 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -272,8 +272,9 @@ 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, - 'memcg' for specific memory cgroup, or 'addr' for address range - (an open-ended interval) can be written and read. + 'memcg' for specific memory cgroup, 'addr' for address range + (an open-ended interval), or 'target' for DAMON monitoring + target can be written and read. What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//memcg_path Date: Dec 2022 @@ -296,6 +297,12 @@ Description: If 'addr' is written to the 'type' file, writing to or reading from this file sets or gets the end address of the address range for the filter. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//target_idx +Date: Dec 2022 +Contact: SeongJae Park +Description: If 'target' is written to the 'type' file, writing to or + reading from this file sets or gets the index of the DAMON + monitoring target of the interest. What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//filters//matching Date: Dec 2022 From patchwork Wed Aug 2 21:43:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E5A4C04A94 for ; Wed, 2 Aug 2023 21:43:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF1FB2801FA; Wed, 2 Aug 2023 17:43:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B550B2801EB; Wed, 2 Aug 2023 17:43:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E2952801FA; Wed, 2 Aug 2023 17:43:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 76B692801EB for ; Wed, 2 Aug 2023 17:43:27 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 560EE120FE6 for ; Wed, 2 Aug 2023 21:43:27 +0000 (UTC) X-FDA: 81080491254.11.01FDBDF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id AAFD8C0005 for ; Wed, 2 Aug 2023 21:43:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hoWA1fuv; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012605; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iuunIUn62bhZjdaFR+qEAwFTLHuVOYMKzjEUqds7ss8=; b=BcWz845KiGFoTDF9Bl+SrdYyL7ydY0nQgbaiOAX2EX17W91AxEuWD9w8q6qfUPtsy5iKzu DRZRzzhC6/ZSafzgv0B17qbJG/AvoegdHoxer4T19FbzbANxt81qmEDS5f8mArxDQ1oBJo zunwmJcbjOp/2q9idwMErXQywbxRVT0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012605; a=rsa-sha256; cv=none; b=iOyhOaRIpFabO5BfJoyoQPNSWU99jMD6MXVrdK6KrA8JdEeBAEp/z8+BXktE55ZxDMxuHl AYHasMQk401GUFWM0rBgxNhb4NoAHCiHZNDGQLZkIjZR9a2ET2gw57TLAaD5fFfEJqcNYH K7aFKjq02EgF1AhCJZy4+CHrzgqanGQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hoWA1fuv; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5CFAE61B6B; Wed, 2 Aug 2023 21:43:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2885FC433CA; Wed, 2 Aug 2023 21:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012604; bh=jeC4GAEfQQwmVnTIZskvg6L9vM/nrayE2m9ijer6n98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hoWA1fuvDjK7jXhUhoEI65MmGUs7H6QEze0nam2eSmQQDmKFqwbEc7ntj+UTqkneK s4V78zjTnozT3fM3yX/OWz1tCwvhnBtviwrfyEqCpROqYVe+H58xxnNHCrW6kpG0U+ JfEyQScqzF993YUJ7gMeYUcyg+IYEmqdJEcNAZn4CL3Zv5SqighkfbzL2O+Y/acMFw JQyEs1Docsz/CwWvVuiYbxfTuk/A6rfZ3aQYHL1HFWVWpjJiPICbVZEmzELUXP/ErR Kak42ueYfq7zOBq8BrEh/YZeMTARGPU9y7ifjguZbR1kbjoyPqdgg3UPBGHm15Vncu pVaT/urDi+FOw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/13] Docs/admin-guide/mm/damon/usage: update for DAMON monitoring target type DAMOS filter Date: Wed, 2 Aug 2023 21:43:12 +0000 Message-Id: <20230802214312.110532-14-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: AAFD8C0005 X-Rspam-User: X-Stat-Signature: ib1mt7xiw4dz7c9s34ns3s1tryqjgbwo X-Rspamd-Server: rspam03 X-HE-Tag: 1691012605-838196 X-HE-Meta: U2FsdGVkX1/U+Y+u7RpbAZS7mUiz6CzHpaG/okb3gRZWhwz6TZ0xhEm6BirGz4RxJh/KAjKke5diO8CQJEXYk35dupF8/Y/gSdHdALomHBWwaezcCmuYtD13ONQG+ywHQdi8oYQyBRCITUaCys09P/L/oqWQCceprL2EMxjk8TKx9nHWsl7MOp0YM/a8bJxJUsffnTks7ZNsQJjL1KVSGh8O2Xn9wczy/dk3X9V3ZDnSvrEgd/vZTjaTHK0Pl7Ve7+Gz366CpEa2KwSB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icity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update DAMON usage document for newly added DAMON monitoring target type DAMOS filter. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 37 +++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index a9cb9949b796..084f0a32b421 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -363,18 +363,21 @@ 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 five files, namely ``type``, ``matcing``, -``memcg_path``, ``addr_start``, and ``addr_end``. To ``type`` file, you can -write one of three special keywords: ``anon`` for anonymous pages, ``memcg`` -for specific memory cgroup, or ``addr`` for specific address range (an -open-ended interval) 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. In case of the -address range filtering, you can specify the start and end address of the range -to ``addr_start`` and ``addr_end`` files, respectively. 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. +Each filter directory contains six files, namely ``type``, ``matcing``, +``memcg_path``, ``addr_start``, ``addr_end``, and ``target_idx``. To ``type`` +file, you can write one of four special keywords: ``anon`` for anonymous pages, +``memcg`` for specific memory cgroup, ``addr`` for specific address range (an +open-ended interval), or ``target`` for specific DAMON monitoring target +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. In case of the address range +filtering, you can specify the start and end address of the range to +``addr_start`` and ``addr_end`` files, respectively. For the DAMON monitoring +target filtering, you can specify the index of the target between the list of +the DAMON context's monitoring targets list to ``target_idx`` 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``.:: @@ -391,11 +394,11 @@ pages of all memory cgroups except ``/having_care_already``.:: Note that ``anon`` and ``memcg`` filters are currently supported only when ``paddr`` `implementation ` is being used. -Also, memory regions that are filtered out by ``addr`` filters are not counted -as the scheme has tried to those, while regions that filtered out by other type -filters are counted as the scheme has tried to. The difference is applied to -:ref:`stats ` and :ref:`tried regions -`. +Also, memory regions that are filtered out by ``addr`` or ``target`` filters +are not counted as the scheme has tried to those, while regions that filtered +out by other type filters are counted as the scheme has tried to. The +difference is applied to :ref:`stats ` and +:ref:`tried regions `. .. _sysfs_schemes_stats: