From patchwork Fri Jul 28 20:34:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp699028vqg; Fri, 28 Jul 2023 14:23:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHB5U0v/yAqq7IWsSMhxog7j/BMLeUnuf5Odq4AkGSHot0oL2Z+3VGwpX935oqEqPJcvWUv X-Received: by 2002:a17:906:1051:b0:997:e7d9:50f7 with SMTP id j17-20020a170906105100b00997e7d950f7mr390668ejj.66.1690579387323; Fri, 28 Jul 2023 14:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690579387; cv=none; d=google.com; s=arc-20160816; b=D0CEnfNuQx7jqp3eP+/2/3AcCxu1vNM+3j5pywpH+by+0L9fzrI+SplTHO3PJxDE3L YSLfcZ0490ut55I7Pwsp7UUXectnbxi5C4LNuwew/NOoDhOyzqbZ8rI8XaKcneWJ03vX vb0/7NQZmvuVWRbfbGrhsalPgDDdh7N/uIPjrttxH5hfMnU4oFbvu7anRqFs+asi2/+a sROnc1nz/kBniGvYcak3FtqiTz5uGmi7IR7HYXuEW7+f1qAjo0S5FDWdJagfS3xz6Aq0 k12Wup/4DNfz95Smr/FW0iM0WP5An5qYB+ycDp7LQVC6W2ATyWj1Qvhsq3O/SIYFLIQ2 wFGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f1+kUO/1jvUs16oQPMZPa4+TQlRIDLtHo6KkeqNkj7g=; fh=8oGWbdHExGIIBBigm5y9/rZRjvqmeY+HpW+qV30w+go=; b=tkSzUnyCf77Iwb029oGhdW9uqIOo9Di2DITpwq+FgxPJxp12lBfnA+VSr4At2QwhV/ r2sBev9kj0WP4H1UJh6Dhhs+lnP6DPlev67Omy9ymLvpm3GK0e1rG2+xkiR6mEiXA5sz 3yAI0G+Fbt2GkbSitWYsNUS9yg15SChKtx7+x0uU+rRgQFiuYdS/ETptYP9OdaIZyCRQ tobhN4zgFDX4EsFnj/l6MzXJnb1iGtlP1kR5F/b/TzBViDRpqu8XsDS+H/PsmbG9fhH4 iE9es9+lRapdyds0w+mM2DyRjFqFe4fiZhqKhT/ZR85q2jR3zx/3D/XxWJtPxHEAgOye D2Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p2r8hu9C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a170906038c00b00991dfb5dfb7si3607064eja.573.2023.07.28.14.22.43; Fri, 28 Jul 2023 14:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p2r8hu9C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233189AbjG1UfA (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232766AbjG1Uey (ORCPT ); Fri, 28 Jul 2023 16:34:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E43A449E for ; Fri, 28 Jul 2023 13:34:50 -0700 (PDT) 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 B92D062203 for ; Fri, 28 Jul 2023 20:34:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B668BC433C9; Fri, 28 Jul 2023 20:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576489; bh=RNhaUHFt4yEDSg34n1AIbUDtUgo0To5YvQtFN1055is=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p2r8hu9CmFI364JLZUBG5moYhkILhGzb8EUF5UUqi4zpjISMyATubHTf8iaRu+Y3e B7Mb9YlocLRyG+jrKWyvPFKDQJHIHMnMaPTd9txEMbGeYRaSJwgaAbCHqkHQg9K0fW VibqHFWGC5EnpYUnVK2qUxRfeduyXd72rk2CDLfw2EbHQyq+wZyKy/1sqT5yCbjDgj /aoJsj5yLhShWP70po7j3u8d9kh4bpVU6glpe2lFV8+KPa5zSjLDjgg/5R/XkpKt2P EevGd1FGvMBFcAwR88pJIotq/h/bcab83pCI7HEFhB+wwMDetEl+nhyJtU+EfdmRb8 2FkRJskRSLGqA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 01/13] mm/damon/core: introduce address range type damos filter Date: Fri, 28 Jul 2023 20:34:32 +0000 Message-Id: <20230728203444.70703-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772700971712452623 X-GMAIL-MSGID: 1772700971712452623 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 cbe5a1cc27c4..c061d289c832 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -906,6 +906,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) { @@ -932,6 +982,8 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, } 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 Fri Jul 28 20:34:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp697499vqg; Fri, 28 Jul 2023 14:19:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlGArOPd8pW0/CaJeMfuZkYnK8ShgcaNGhv+zdLN9WgP3mYaOH3NJe95Bv3hS4ooRBCfpxiu X-Received: by 2002:a17:906:9b:b0:99b:4d3c:d7e4 with SMTP id 27-20020a170906009b00b0099b4d3cd7e4mr449171ejc.63.1690579156385; Fri, 28 Jul 2023 14:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690579156; cv=none; d=google.com; s=arc-20160816; b=v0oniAGFi5STFU2sJ46nIbgStpw+mTmWmnzbRIcHkjj08VSIpdLTv0Egqidzim43Do se7YXGHNXjkgxw2Gq26W7dcArHc0RFjikQg/Jd3K2hjOMAbAMqK0sQVpaR+eEIQYmr0Z +g4xqtab43cp1kfTXswjrAf/G4NP22Low0BTbk/VBtaS7K2EOGF+TjxQpwpSNRrWMQGo OQFknN9FFj4qmwgPhAAe3s1hrNk5Bz4dN7stTv8PA6D3cAbjLXASavcJJqzGBFrlw4ei Oo55piM5OcIWOD3JR30LA0vx/xzk1nTeQVr9UJ5H+yiNOq5MpPiO1x5Q86nrJ8FjT22z YtDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zxVpN4g06DUCb7PKXyAD338noc2KODnd6S5Q4w7jTog=; fh=8oGWbdHExGIIBBigm5y9/rZRjvqmeY+HpW+qV30w+go=; b=lpesor8fPPQyLno5kJiQkQ6fwvkdtadJ1z4nUelTH+w8ufiLpfLx94y87aJdmfZopU MuBBI3hqgfQ54EUKXL0/KFhXlQlcIVq3BUJpZ7MJaSneVnW3YntKkEI5K7cgEKBIndPh j2ODdX+HfhpK4fWHsa17oSRUFJVQQM1mxc9spTmdzW8Q+8oaFMRAdxuC1YniFlTSn+Ny WZ6kddWuik2y06yO/MStU4tX+5QVpVWlvhYQwzOyF5ccWIV371tbf2PTr2AijPRDDmUH XuWXU7WHloSLMIc8fGy95W21Mbifo0wxoXyXy4jQaVoM3vMo2M+XHzoZtoTK2CkGls/h KsVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qEqsPnDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v9-20020a170906488900b0099bcba9df15si2852606ejq.605.2023.07.28.14.18.52; Fri, 28 Jul 2023 14:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qEqsPnDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231896AbjG1UfI (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232941AbjG1Uey (ORCPT ); Fri, 28 Jul 2023 16:34:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFC5344A0 for ; Fri, 28 Jul 2023 13:34:50 -0700 (PDT) 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 5E07062209 for ; Fri, 28 Jul 2023 20:34:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DF4BC433CA; Fri, 28 Jul 2023 20:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576489; bh=JP7uB7/G+cUBWmCMFTcCRqLSa2LcbVSrJBh+8gJznBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qEqsPnDTJzgFVqfu9V8EzsZlJlOVBtwCUd28gFsY/AzjTQsZhZQksDgaSHRkRvXm6 l3JmnJRVO+FpqhUHnEBOWdcaXQfMAG9/39tTQYzHzN1prb1O/bPdPv1kPt8Auwz/5D jjYGnpBfoMfmgM4oSg5UDHunwAmxiVSwcyEzQTP/oXG5pTb73/hEKtZ0XgBxx2q6s8 ZyGQTXlE3Ps1FA+5JnDoErKrZO8u8BKTzajZt0R1+WIrtbuOJHsuLZx/b3rVLGIgME FZMqUi57nVG89VRujJdxFHqvDZ1vymbdZLhk8ZLlSPzkG/ZxwgmTLxXbJBw5HTGc2e zSvAEuArFDBfA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 02/13] mm/damon/sysfs-schemes: support address range type DAMOS filter Date: Fri, 28 Jul 2023 20:34:33 +0000 Message-Id: <20230728203444.70703-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772700729094589863 X-GMAIL-MSGID: 1772700729094589863 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 Fri Jul 28 20:34:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp698924vqg; Fri, 28 Jul 2023 14:22:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgM/D9DVlocsLhdix6MgvNGE4h1wRlcYQj2ravQbXObLCH8YnIMKl+Apk/LWmJKOJEFxcP X-Received: by 2002:a17:906:7a1e:b0:99b:cfda:eded with SMTP id d30-20020a1709067a1e00b0099bcfdaededmr459830ejo.52.1690579373140; Fri, 28 Jul 2023 14:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690579373; cv=none; d=google.com; s=arc-20160816; b=NM1FqohwmouKFH9x9gAn8Z62fJ8MhR57gmEkeZkW5J7FLN9rFmpJ20t2UYVrSQ+PQQ ybC/XjDEa9mBeMyMlIx+9ZURT4q/pXbaUh610OyMsQbt5h6hjur4OE5FOMkng0Cj+kd0 pxvwrIKeFkh4qeHtmVFoODOAzA6Sz8O1nlJ9bvevzOdwWcjvvE5OlkUa5lqLGSBvJS8I Z3Hpn+qeKl3LbbBvssizvMRBYWPFbtdUiI4tJDwVVt0kdnCt9qqzN7M+xLRTc2upc14I ftqsVwWcoCZjnJz90EevXLeOip+NUeRWcUAOU6L8lkL8jyf7U4+VlO1feksqwOULqkgt YYLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RQJieNk/pr3XHQEgPwJ68VYP9y4g7GJ/7AtQ8sbJiBc=; fh=hJpvtmYKYE0BOPLgUEDgOmGgYMxmJ79pj0vtAYRNCO4=; b=G73jc/zNCx9mS21/ajQXEkVm112pF98oTVI1weFRco5zWYM4aYAlG2zWITw7d6wGZr Qa+eTgdl7UClSDgI3z+ixViYupxn3RBOjpOaCTXd+9AFZxJ+FGwW0JT8Kqx/cFG7EvyZ RGU3cFclv6HuDKlb84Pnr96+bWX38n3cp7qFkhOuJbQX0HVGl3WLsq2+fWKx/WYdTTwk fbchdkoyDOJSdvui2BS4FFsTwy+avC2OqIV1GsDrS0Uw4KffIcv9NZflYiUguvukw5EV hInbvyNvt50bTdL8HC+6PDMYjNaYThyslW/uxYEze66ep3ILjWpO7CDYSw0EKwINYMgl jIRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kZVzJF7D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a1709063b0e00b00982733d446csi1999933ejf.410.2023.07.28.14.22.28; Fri, 28 Jul 2023 14:22:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kZVzJF7D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233075AbjG1UfP (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233672AbjG1Ue6 (ORCPT ); Fri, 28 Jul 2023 16:34:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2818544B9; Fri, 28 Jul 2023 13:34:53 -0700 (PDT) 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 D4BD1621FD; Fri, 28 Jul 2023 20:34:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C68D0C433C8; Fri, 28 Jul 2023 20:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576491; bh=cjc8ooSUQ83tCK1u+lTmvslo5pngriB995qOBl2lfEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZVzJF7D3covRVxGV8qlNVSYryTJADsCE2nkG3JlMM6KW9d11TNHzemNIWTQimTJK ffO0M4jAfUNnDSYV4c9DRRIB0VliGAVfq2/WXiijhELaaucip42BKwqrIHBcjqIaJD bVnh67z2b8iM5uSNPfJCZ1KxJ5yeEkYjeM8YTtQ4idTBJQzHSnwyViTad4T/Ago0h4 h1HmW4PEjGdHDzBE+c0WSscxqojOd5yWq1PEFp9djhuFqImKaV0iUCkHaYqWM+1D5U LEC5LNT0heATO0ErxPQA1r1Qhcp8va2vn+6A5rWmwm3Muli5fwkwIJopgiP201Ruvx 5GI/wU1T9CLGg== 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: [RFC PATCH 04/13] selftests/damon/sysfs: test address range damos filter Date: Fri, 28 Jul 2023 20:34:35 +0000 Message-Id: <20230728203444.70703-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772700957001459193 X-GMAIL-MSGID: 1772700957001459193 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 Fri Jul 28 20:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp693543vqg; Fri, 28 Jul 2023 14:10:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHBv81sQUOJ1vx99K9V1JHEXV6TGG87FQ+WguG4Zvco+BiTbaaViLGGDbaAT4nduqI12+ns X-Received: by 2002:a05:6a00:218a:b0:684:6bd8:4e3b with SMTP id h10-20020a056a00218a00b006846bd84e3bmr3680458pfi.19.1690578620086; Fri, 28 Jul 2023 14:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690578620; cv=none; d=google.com; s=arc-20160816; b=NkaHs+T50kiwgqnKxBzqBaXJxTecITV1PvUFe+F4RJMT2uD/PdGXi8JmmEIBpTkav6 5Chx/ZnCkc/zn6UP4dq/7D8/0FNx7Wl5hEkOV8Wd7TNHQzCt2CAwKc7uU+g5LZ4ohWTN iivvNUDoF6hgxBrOhkENirDrEYQyb+O0Y7PMrKFCBYa1C5rPhkrGM0wF+Or5tJw800G6 DZ2AS011bb0lL0z2sO9E53bjcx8CPKUnmiPVJEzGMttCMZyBq7QxlzcEr9JvH1yGsu3l XnTb8WlDSC7zchsMdkjzmL7n8D5MHf0yIjdOPYXa7vWzd5yzbvCcgGesYl+I2iyzPvp3 j/dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N2Dh371ZmBlYpauiue0Vw10+cKdgFzpWgDU1O6AHC1g=; fh=Jn9vwBBsv0/M243wtBPWgrycE99QwFHXCzusFnO8K0Y=; b=cjR5Ur02Ev2ZnMs402zB5ngRPqJnwRg/dHbAHRQUjtfzgbSX6XUJ7vrbrCIPW8ebSw dvi1XHyCmeh+F/4w8Ofeb/OJEVUco7eVjjXZVBvHV94ONVXQNEUQOz6fXY069TQF7My0 EOupnofqRS4J301/vAqolxt8G3035XW0cA6EmqSNuqhaC9FOvbvyHLHNSin3ffSDljmL F2b6WG986d1yX17SqTz/XusQHt1Xpqw5wLmcqt3X45bPa9ly03HxmY6/Mzxylqwxdgqt nyd6h6uKnoXjJUALUSBFppAjLOmZVFn4tMr+43fGd0ZQbG2aSM6r/WedYH128iNlvy2p SftQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=heq5ttnp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a63d40b000000b00563477c3519si3544419pgh.488.2023.07.28.14.10.07; Fri, 28 Jul 2023 14:10:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=heq5ttnp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235066AbjG1UfL (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233880AbjG1Ue6 (ORCPT ); Fri, 28 Jul 2023 16:34:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E723A44B7; Fri, 28 Jul 2023 13:34:53 -0700 (PDT) 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 95B786220B; Fri, 28 Jul 2023 20:34:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81061C433C9; Fri, 28 Jul 2023 20:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576492; bh=OCzjAXySbo2P2W2ofPo/GLfYFykKqV/gINis3/IWY+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=heq5ttnp+0povkEP2NQq2cKCGH6lIIYkoMJQgmhO9vQAax7BDzcr7DdU1Q787/Wq6 Q9YeJVWmEHUFLd5qRENHxmVH7CqsLYHLU+C9jYL0lY2f9fTzGd89JOSSEKcugjH5qV +4OBdFvsT2CsHNrjMfFwwft/J4k+Sn3di3qmQeI8yWpwnFfHQadtT9Nhb/Sh+YCC+o 13cM5XYudDgbte9YduCx4h3FLlpSG0BPdG2nb3Nhzv20aF3IqPZIVxzyK5nrHmLY1z cePPG89HaxuFAEeiheYUlMAMH8JDYucg43I689mqC6DQhyBbg3QctN4ksFohaXYEeh kBPKIAB9Al3EA== 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: [RFC PATCH 05/13] Docs/mm/damon/design: update for address range filters Date: Fri, 28 Jul 2023 20:34:36 +0000 Message-Id: <20230728203444.70703-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772700167052014626 X-GMAIL-MSGID: 1772700167052014626 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 Fri Jul 28 20:34:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp693294vqg; Fri, 28 Jul 2023 14:09:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGPJk1DW9zP9wZLTWE8VL9eb2aQuAcan5xgEBY01g7DKFXM8yfqs1MSiWIDAcaniVk1yFKI X-Received: by 2002:a17:903:18f:b0:1b8:10a:d925 with SMTP id z15-20020a170903018f00b001b8010ad925mr3382436plg.5.1690578582670; Fri, 28 Jul 2023 14:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690578582; cv=none; d=google.com; s=arc-20160816; b=HmVBr3WUtrsVfQdizyWdESHpY82vJoDnnoKq7fw64mmB43Bb8xJAjISYnuPdxdKU0k ki2mgxzXYZPaubzxD8i4VF2z9BEND5Zoqu1vee/5L6qClq43rQ/B5vH5p2ggH7ifZ9YF 7xKBDyJu7N0RS/4rq8YmouBsZamHc6WHC4XTvgoCfvEJSUTRFnUTHlAY71CVb5xruP+T GuoGla8Uzciado6/U4pwDxUvhyGepQ5EPJzXQ74RQuQK3VcnoaDj/TvFpBDNzPFl3bpa oJjMR9FxWhele3jkcq2ZP9f+oXAGCPRghB4E5MboZE/q4uxwYhhAPzXdGnvRWHtFkprO xj7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LR7oqG+00nkekBNt3o+wrtZoDLPaShEuwa/PeYioeco=; fh=Jn9vwBBsv0/M243wtBPWgrycE99QwFHXCzusFnO8K0Y=; b=JPDjpf+7Eq5cAj6mnGyqbCobwsXI2qfdgiE5inppS3hfPPqHGoWKp/Fd2A+vwmm7ko MiU4mKTwvu2dGj23FZtmURdqfi/M3hLDsre1qNBEh+46kQNCPVztKpNyBvBP5BPxd9fN jhoqnYk5jgcyS3qocGxevKLQQJtm9ldaWnFipAgBb7r8DTnxgN0E7tczYXo9+tEWQVj5 y/Np1Lp9vHmU465+2jyqQZfDCL/i8ubJ6G2SOGSUr0QqrCL2QO5IFa56Hg/LBr327rxd n4E7Umv2KvxRw0qW0Uf0kmRAORQtO7xQSdYeH8ekdcgiwnVySLZnI1nSnnTn5snRU0rg i3hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SrxOU/dN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a170903018100b001b53a3fbcc3si3646858plg.328.2023.07.28.14.09.29; Fri, 28 Jul 2023 14:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SrxOU/dN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232876AbjG1UfV (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233839AbjG1UfA (ORCPT ); Fri, 28 Jul 2023 16:35:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18244492; Fri, 28 Jul 2023 13:34:54 -0700 (PDT) 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 4D70362206; Fri, 28 Jul 2023 20:34:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BC43C433CB; Fri, 28 Jul 2023 20:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576492; bh=0npm47qE7mM3V04g26fYupZB0KuQfvcIrbkch6jch58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SrxOU/dNh7jCfSKEdcp2NaJS0/E9e7SwsZdBuNxy5RQsHjiWpl6nQFNDHC1cgMXoN YZMJtZg+OwctxSsEr9MpVt052ifmf3dVP/0yjPdxdwc5CjViezW6aLvDbyZTnruc4t pZCSvfk5WEVpX2pvYQY4gf5yFA62IQ1ppZpYH2hQENmnJNk6w4B2rvQwCY96KJ3FLN 1FhQFQBA8qhXEIJgCbaRbZtd5GJW54biKuy3jEc0aTf32BaIPXauFRF1vvYxwPrOeh qcTZTdaCusboMSVeL/RRJ8U2FRA3+UCrNT4Ad55sFhFPYEIwEbToVXf+cQeQI6bqLe C2sMA5joPS5qg== 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: [RFC PATCH 06/13] Docs/ABI/damon: update for address range DAMOS filter Date: Fri, 28 Jul 2023 20:34:37 +0000 Message-Id: <20230728203444.70703-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772700127904295915 X-GMAIL-MSGID: 1772700127904295915 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 Fri Jul 28 20:34:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127879 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp700442vqg; Fri, 28 Jul 2023 14:26:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGwcSX398vCAsKooZ6cfZeNW4njTDdODgtMfC2tzTfhjqiniVgO7ZTHa/mDlpi2DM3yKn80 X-Received: by 2002:a17:906:2216:b0:99b:4956:e4df with SMTP id s22-20020a170906221600b0099b4956e4dfmr390806ejs.11.1690579610857; Fri, 28 Jul 2023 14:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690579610; cv=none; d=google.com; s=arc-20160816; b=J4M0vvKWGtvwWapsB0qiep9OqmIro+pYj8FTXOIGsmgwdZtQydHGotf/7QdTQL4dsg 8vo6vOhsNNacQFtW5H6OWWXn6nqjuY/Yz1cudYBHblKK8pvrVsY8DFiqtgirethIZoEw y5/49i5hpmGF2pXYZxaW8fwd2AFsEpTZaoYeCq8yOMon8DkcCGuamc1YJAbPS7mElTIZ xQEmJ0RP5j2bs3OtIEoM1V16n0pKkGqowc4MiGCIFCrsUbi4OCAEHIU6QSKiB9CfMst1 IGNPfazYYsXUr+6rKIOuvEgjq9dkQA+uU2HThXJuRGYGXPL1yhCFclWAO+8L7uvYoRq0 rpZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DEONY+l/f78gQJGa931FtpQgT8QXzC08LkXhFbdcU0A=; fh=Jn9vwBBsv0/M243wtBPWgrycE99QwFHXCzusFnO8K0Y=; b=m2cF97nN/oQCqNKjvKLdidCWP0HThCiNoWc5aE7+aHwkgLKN6A5IflTVecK0KIxdyM TbHOpv6HskG4sF4Gon88Fx9859xn5+GUziMyy6rV0z66TKp2dPXQNBeKQl2Uzi0zMjke utVVO8AnWHZ45SsXPHuxDIdQowFvCvyE5gpgo8F2p7wolXMG/ez0jPiRNPfyDsbfDp3v ctUVQwmpErBiwGGHYtkhzwIGiww1oEkFyXlGIz26Skc+zO2qv8ciV8NWu/OGzFcB0qCw mbDTU2eCfsJUjsLT56+tpJJ4QdVRDsPWf8pLzi+sIFqrttmGxJPKkPwfJRkAjpgM1WRt 6uxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CiBEtbKQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a1709063b0e00b00982733d446csi1999933ejf.410.2023.07.28.14.26.26; Fri, 28 Jul 2023 14:26:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CiBEtbKQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235087AbjG1UfR (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233708AbjG1UfA (ORCPT ); Fri, 28 Jul 2023 16:35:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFAA14490; Fri, 28 Jul 2023 13:34:54 -0700 (PDT) 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 0888562207; Fri, 28 Jul 2023 20:34:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAF58C433CA; Fri, 28 Jul 2023 20:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576493; bh=mWNsxedk/0WTpVC5xcDAG+vRRRu0kRA2F/h2AlUSJkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CiBEtbKQkxm2uJu76Q7F8N2yDxl7U5CsSNj+H9GfJqYbtTv7BZogItSj796IfRVIR reirwqk2lf3SQmPHseotaQPiwRXIv4DFNdE+HCeISoYCebyK8fyGjqQ8W7W40YSkt+ ekvACadx5lNO4AbeT1UpcZwlZRfaFTUeki1AZoqq1pn+TiQpFMqT70qy6wOK2IWr4/ T6zFjbNqKY91/5trFT+gdfYXLSUjglkvFNyyagx8TzGMljLf09PSPnMSUZ/EkJ9rqm ZQGqEVzV7Mf6CflFGRu02KLrdkoWza77p9pW4Qrx72dMFkuZ9Ets1DZNdBAL1IhH8z ykHmI5hTachgQ== 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: [RFC PATCH 07/13] Docs/admin-guide/mm/damon/usage: update for address range type DAMOS filter Date: Fri, 28 Jul 2023 20:34:38 +0000 Message-Id: <20230728203444.70703-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772701206049175198 X-GMAIL-MSGID: 1772701206049175198 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 Fri Jul 28 20:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp698371vqg; Fri, 28 Jul 2023 14:21:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDDi++8pqPVApLh2pBzCzv7s2DxHBKGOYAweCHZigK0eNBmCLPsagpwaa2aECqx/64cgQ7 X-Received: by 2002:a17:907:75ed:b0:982:79fa:4532 with SMTP id jz13-20020a17090775ed00b0098279fa4532mr459173ejc.53.1690579288327; Fri, 28 Jul 2023 14:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690579288; cv=none; d=google.com; s=arc-20160816; b=H4Jo+rFlisGf8svzgL2sq1As4jBeholji9fYue3wt9jinGNqKRJQAeKFswLGMcgoty pSGA9uv/Cn87GtpfJIwUTYX4pooQ4Q6wKX++AErPE/Yy8GltiQ2VHzokRZdX0uD8bNLj 02pluzOdWyQGJc8BqRLkE+feb8k1CxQW/PoX4/gkGddybP8JzZKiNI+gHmqVUN0C23Tl 4EVOHq4eQaSGvxbJEnGNA3cplh9dQck3yM8ft8ih6G+Mbn/V4zeNFwVvU+EPg+ynbWnv Ible2bZktgeXIv3e+1lqYk0VKBYr3qjyMbaQUkAGQmQ7e2YJT03HM70bSIbrCpH7T+oy s3QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hHpclYYfcFMIQd/3SqHzyTRgnAlb9aEAxJFCK7Cjch4=; fh=8oGWbdHExGIIBBigm5y9/rZRjvqmeY+HpW+qV30w+go=; b=XoN7esAvYO9n2gmYnOXiCOXOLt98bvnFDXd8DK4D9Y5sh7lARG3GngHMAvb1lfMU65 oPZYgmJhi6nBSwCZrgbpLKQGmjDoFmyhroYr5r/UYP8b5mL6CDC48j7VykN/DiFWV5G3 wYgqfpDEXf8WjU8Xg94+Hc0bxoiQqiwFmiSczTwO+SmtFJpwvl/WFIeqwqWDN/78sBO9 DVrFimwzCiYA8Nj5wxIcUYpVmWWGL/fSJag05LxChihFdpPm3tD6B6/tQtQ65optuX8P C2pR/VeRXxAzyLREdSxpz/FxTgaLav+mtfl+ZDgAbkMO2/JU9jpwMzwtxaYy+sNg5Qql tDJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YrOFSGFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f25-20020a1709067f9900b00991cbb3d4a6si3171029ejr.115.2023.07.28.14.21.03; Fri, 28 Jul 2023 14:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YrOFSGFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235287AbjG1UfY (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234197AbjG1UfB (ORCPT ); Fri, 28 Jul 2023 16:35:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E7134494 for ; Fri, 28 Jul 2023 13:34:55 -0700 (PDT) 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 A2B676220C for ; Fri, 28 Jul 2023 20:34:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A610AC433C9; Fri, 28 Jul 2023 20:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576494; bh=lBNvXKzEBU9SpXm5U6wWrF6OxTFy+UZXhLu/dKriIQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YrOFSGFNnrBc5Reg0+yJCBH7k9bWeWBT5Gq+TF4ipLVskyigsxce3viD7Y6iwy+S/ whBMJQI/svZuVbpeKEWFPGGOlDIiJ1yfXFd9TBr57ujIvjkA9LgLV0wAppx2r9Xt0K 3BdjuxLZa+l5OQTbe2UyHjBtMo0AYThLHmfBix6+VAbWj3e05tx9OkPH5QN0LcENxS 8msdjvmyMmwUNx//uRUz0LW6+dyERhdC6rb4ilktALtVGfP7mVHc1IcgSkbHlxDai0 zrFGFjGmYl8Nx8x2urnvKcX+I5dNy/iSIC/E6qe8SBndPORNPboomgqV2t0rO/e9Jn blzDGsBDvqg9w== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 08/13] mm/damon/core: implement target type damos filter Date: Fri, 28 Jul 2023 20:34:39 +0000 Message-Id: <20230728203444.70703-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772700868057158805 X-GMAIL-MSGID: 1772700868057158805 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 c061d289c832..334bc5823d83 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -906,13 +906,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); @@ -944,13 +954,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; @@ -982,7 +992,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, } 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 Fri Jul 28 20:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp685613vqg; Fri, 28 Jul 2023 13:53:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFUZvUEdxKRimgAxQ2mW54wD3EXRUnhW7Jt+SrW8hN3AJyaYOtQ+/wm6l7auSgnhYcaEGXo X-Received: by 2002:a17:90a:b790:b0:267:f66a:f25f with SMTP id m16-20020a17090ab79000b00267f66af25fmr2743909pjr.11.1690577611479; Fri, 28 Jul 2023 13:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690577611; cv=none; d=google.com; s=arc-20160816; b=XZa8vkMXggAORBNpd1lvt5iT2XuMIpUA59Wpk1LNt2THAMGY2fi6i9bPdi4C0qbP8I rqLo65gNADlEsdf1WAtYSKnqXbKo4b7iDa07Wtc3SBHF3DbC7y5zwo+CtU/Z03/eLsLL 8KleiINSdBJWy6hTQ3pSXZTMf1DyQUuz97akUUwbTb1A44ngN1FeTL7330zxO+xn9bbb X2+EUH013oVSI1EotEGDIiHi5uvmzKAkgaPlFABUfAmADRSc47e3K1PTJEnpoOayKqCu S57bI9LQeDrldYtCWSm0WTOnU4zrfuwMMEBojL1/yUA9/3rFkncrVZLJTLfhxBr/zmPW +aVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/kPvdyaF0vEK5qYkstLmLzJYcBFMKcv9CmUtYtZboIA=; fh=8oGWbdHExGIIBBigm5y9/rZRjvqmeY+HpW+qV30w+go=; b=wnTS7bsiYHoDRMD3eZhsJc9UrRbzvvQjAzSjIfoB8ircAamRaq9d7OZH07CzMvcRLY sQE6Jo3mjVYVhiiQZL4aMgr2BXZ7oMLr7GGmMRsnlcd16ICDRO8KUMix5SioxeuaNV6s lsgWXvcm1qUmA2JDLiE0F1sJMLVtiLC4BGvvAoSdfOa1fkG4pml8+HAMYOEaTPfm5cBZ nLREIoFZMYhySx/2Jm0y7boTDrzUNjqj4QgTKjSahPSY3AJbJulwf1dlNy9ENyMlKobV 2vP8Ve66xpkDo5aHiCuyC6+GBtQ8Wb0tuqkpHoc4GBqwiO5nrX9GIz3lJf+YxZWlSBOz 3S4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T8PVYgKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot6-20020a17090b3b4600b002630cae4f47si5292276pjb.66.2023.07.28.13.53.17; Fri, 28 Jul 2023 13:53:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T8PVYgKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234889AbjG1Uf1 (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234217AbjG1UfD (ORCPT ); Fri, 28 Jul 2023 16:35:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C754497 for ; Fri, 28 Jul 2023 13:34:55 -0700 (PDT) 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 39E78621FF for ; Fri, 28 Jul 2023 20:34:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44EADC433C8; Fri, 28 Jul 2023 20:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576494; bh=Z5TufRLeeFt1IBETpXgGonzkgtF37kqef1//j1myid4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T8PVYgKS6PhpVB48g8KXiKO4k/4GohZSRliIWj6R8O15K5G2kmG3fnkO0dbOgFkhl /UIHcmpSyJadZWQStltOcf4TGAZaLSowi0asMBRi5Z25HoZhta724/fvsHSQ8I11dY m0D2LjqwzdyKx4hl4XteU2v1tlgB8ElHctrSEsXcU7G5B6pCvO3pYtQe09rd02zLfr x5+D+Qc8R/BZ+Kms/T9KuXAgCUV1tqJo1KVQDt+oxGtbopKr6djuCFIfNOdrhkt9m3 oCcs97pGo1x5w4rXqcln4QseMgiqsejzcN5BQNS9bsf387Cz+oFRuJyfs37iSJb33t eF9hu+cVBOMxw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 09/13] mm/damon/sysfs-schemes: support target damos filter Date: Fri, 28 Jul 2023 20:34:40 +0000 Message-Id: <20230728203444.70703-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772699109322285167 X-GMAIL-MSGID: 1772699109322285167 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 Fri Jul 28 20:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp698848vqg; Fri, 28 Jul 2023 14:22:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlHQGTYWKQdMX3esvgJ1M+pGPccw69ZAxnWjRQ7zyYkfG99XMplsWErTC2v1qtI6YOal6/2A X-Received: by 2002:a17:907:a0c6:b0:98e:2334:af12 with SMTP id hw6-20020a170907a0c600b0098e2334af12mr360352ejc.45.1690579360133; Fri, 28 Jul 2023 14:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690579360; cv=none; d=google.com; s=arc-20160816; b=xlBhSKA1vCwxbdHkJV/w/CbXrh0qpQtDfNWRfrfMY0ZVux/kN1SGZGPOcpZfrUL3Uh UPVfbcY+gOUwGbU8ynLbAeOJC6RXTFo2XCqgeoLS/xf/qCX2DCHlw8TEiO3LtwQZkc7U 4UV2P3t4GZRiGlySx8UyrKYGNOZ+DM1tlB8/g3eZXgb/6uwE7MCdtCyQJ63iazMwrphq cpSo7Kn94CApyGhapboEGyyEnl87P2ZyuYzvGxv0fGd1izKdOVwT2w1sDRRgn5xdxuVg 9vrhur9kB/cofdttqXvrHtHONAlMnk9OuQDqe4YAaYEjuNmRVePmbt4C+B4/DsvOAZ1j skkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fdzWJripOcM/GiUUkWYEsIFDFoKl4JpaJcuoDMjVXR8=; fh=hJpvtmYKYE0BOPLgUEDgOmGgYMxmJ79pj0vtAYRNCO4=; b=Q1odiuk5l6eEH2rJ17sBTr00d9EvxSmu06VYHq7MkppTJgsZ1TSgs99wLBxhtJPx6P t4TmqggQFu78Ynumoo589v51cyW7FW56y/+Jsx6d6J3xEevT7+y9f9+FTkzmVJlB3MTI Bz8QfzFqJ568RcA8aTHatHqf7x4/ojqVr72S1wmd5dknH+IP2S+nJzTfL8jkSyVK3tGL c5Bv5018VtuOSEgA/KLJlVwRsxlWLLnKbfySTeDm5VztqyNN0IWBxTGVY2VbVUmo6W8F dMZXTJwXTmnzoFsZ/oWpL47BoJZtjPbBkHWnAyS89hOmy2UgqiduH4NEPOIiOaza2WQl 54pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EECfAg33; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22-20020a170906071600b0099b7a166716si3204010ejb.245.2023.07.28.14.22.16; Fri, 28 Jul 2023 14:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EECfAg33; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233254AbjG1Ufb (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234725AbjG1UfE (ORCPT ); Fri, 28 Jul 2023 16:35:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67E3C449E; Fri, 28 Jul 2023 13:34:56 -0700 (PDT) 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 E9F6362203; Fri, 28 Jul 2023 20:34:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9C1FC433C7; Fri, 28 Jul 2023 20:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576495; bh=MiKQzUem1fzoQJpnZETahxS4bhAx7AKf5JO3KUUBnl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EECfAg33GG9SqqlWc+wrfsEImXkF6d6ycMp0inrJhToqWOJS5w+mziQY6qM1+VzOW yJAIbvcLzdspQMARFZjzy3AmCo6BqmfM3NWAvL0pkpWx7Yt6sRBXwoVkE5fusXqmub w5oLIoINT3xsuDNIolN8nJBcIRzbtGocgGMwepvXDhuG2FYfsA9T8hDMGzLkIvm22b FoyimEg865ElGcknEIKuhd5UsKo6vGoFtEtm1IFw/No6ZJIxShh4HmDL7Oe645TXVZ Lrkivg25m27CUtgTcmVblB1UPsAmTCbpO+ItKQ5IVNkZpQ7/X7HRuBHnbgzbf/ZajY NNTeUXrLf0J4w== 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: [RFC PATCH 10/13] selftests/damon/sysfs: test damon_target filter Date: Fri, 28 Jul 2023 20:34:41 +0000 Message-Id: <20230728203444.70703-11-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772700943137350601 X-GMAIL-MSGID: 1772700943137350601 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 Fri Jul 28 20:34:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp719614vqg; Fri, 28 Jul 2023 15:14:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrlBhCZiNhngYtRleRoPpuIZINtTkFSK+eg7avUL0XLAtKFuewmyF8LFfVaQrE5AJOxYMX X-Received: by 2002:a05:6808:144:b0:3a6:f2d5:4bc2 with SMTP id h4-20020a056808014400b003a6f2d54bc2mr3759732oie.16.1690582486818; Fri, 28 Jul 2023 15:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690582486; cv=none; d=google.com; s=arc-20160816; b=FzAKjFYxDe6zFnd8R3yebKByo3laevTMmkv85NH6X2X2IeySqB8wD8yzc92YNOJpkd WTR/+X8phsAD/FE0kMTGbV0u2OPdA7b8L6hmm4PBZOQHJBg2JLfCm44PgqbCVxNlQbou xobNIDtEXkIKMWOwPeh2xTX5ElM49ZgL84oks/5j5ZPopk7izOzY+pY9f5xJTH3MYRVv RO0FBKx5keK+WCanQzeoB0m13jHmVtESSz4NejzRJnArIbRKsSLq2+1RFu+VOupnEMRB I14Smn9MvHy1mcdkxSwqvs/3nz9mVnJJ3BkSGNQ5B8Hp8O/u99er7FlgnxKCLKT2jH8o X/VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eduCnC+OYEyOqU/7eWjUVOUI0rGHQmq49SKw029YYYk=; fh=Jn9vwBBsv0/M243wtBPWgrycE99QwFHXCzusFnO8K0Y=; b=xoskas4YLSs3dvZb72uuFsEZKWsnAh3hmcaVUf+PT82D5adCGQz+boW9gsMOYvicQD C6cWaA2m+enR16stskvskFlIrqqwNIE24Hp9P3bNu4pXqEwZhficdgf10eMS74jbirdf lyd9b8SyGSyUKtOAXhO1H3JoMHu6SXNW50fHCWWHL34GlNpaFLMfR74UDVs/BMRp8fYj EXqJavGaGvv3OSFBJspj3B9n/idsSdemy3sTXyM86ZqBehw2s/ryELeUgYhJAIJpNy2U hs5zfa6uDqs35APyPL6rwURAsj/hWcnZ9Cf+4yrOFjYrbKsnsGdikLz6S2JRy/r5xDTd w6MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OxWEhRuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a17090a64c700b00263ba5d7088si5065988pjm.48.2023.07.28.15.14.33; Fri, 28 Jul 2023 15:14:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OxWEhRuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231449AbjG1Ufd (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234807AbjG1UfE (ORCPT ); Fri, 28 Jul 2023 16:35:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D37A44B1; Fri, 28 Jul 2023 13:34:57 -0700 (PDT) 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 A747762205; Fri, 28 Jul 2023 20:34:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93157C433CB; Fri, 28 Jul 2023 20:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576496; bh=/3fkCyEgrxb/AUOocTnJxHaLWQx7r2oBGZrkuNBIGj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxWEhRuPcnfrcCVwBiXAj7XlQmmkMrkW9e3U/XpZL+HwfZYSYxvDTK5NHZ3PAyPG6 U8vjA9kEWx5bcJ05v0Z7MHa4bCwtMcGu8JCoYAlrEuJlCc7Vs7yyR1v/Sxx8AY4gfZ Rw47IgpK69FeRYLEkwZWWigquez9wdXepYBOd5mb5fOCaqcRIYMh/HbwR+mAwukQcL tsjQgy/BD9KP302rVfPdIHEJ0+GnxpHGFfbSeDr/Uo22p1aCiX6TZMCWTl5RbLO+R8 Ab1ecYyLD2f4biH6bjWAY5swpY2S9TkcobXnu7R2EqLBDptkXTK7f6lWry3g+yYHfP I7uhEvHyiwGGw== 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: [RFC PATCH 11/13] Docs/mm/damon/design: update for DAMON monitoring target type DAMOS filter Date: Fri, 28 Jul 2023 20:34:42 +0000 Message-Id: <20230728203444.70703-12-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772704221433454156 X-GMAIL-MSGID: 1772704221433454156 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 Fri Jul 28 20:34:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127880 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp705225vqg; Fri, 28 Jul 2023 14:39:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlHSGZV2ut/hHRUG3yAUvAmwbj6gW1w4KZm1K/a6y1Jcf40qZ/JoHI/19Wk7wycxe64S/Sns X-Received: by 2002:a2e:8199:0:b0:2b9:aa4d:3728 with SMTP id e25-20020a2e8199000000b002b9aa4d3728mr2770144ljg.29.1690580356470; Fri, 28 Jul 2023 14:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690580356; cv=none; d=google.com; s=arc-20160816; b=Hf+tLvVqSo7wWzGwkGMMwuDchvluVTf6ehTbi43P46rwqZLPyRRGWSlckZts55Wp4M bUWBq0NVZcfV4iC4ANOR5rKWm8oECPwYJYQzHe/TMu6cEBFmWtQcIuHAVJLVl7BM5mhx 26yxiYPRYLvtDGyb0BeJ1WpnwsUSjZZzbdLWSQzIeVzxQ9EgFr3wR3wS8FstlIsIWxiN D7v7bSXwEF8n/++31k8zbgZSJZa0UlzNrnnokNvsS/un3AynMCtUZefQvKErlrFbxtyD FsJEoQYQaru0arLNQeQZj1gv7m/3OIupOhukTY/n2i0uhjbvWTx/xs1uDfJj3g2rv1Y0 U4Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TCUsqQmJnKJM5svbADdALKq1EVL3eMqwc5DVaHvmSMg=; fh=Jn9vwBBsv0/M243wtBPWgrycE99QwFHXCzusFnO8K0Y=; b=cD4t4zrhlVZYcSLSvBuSSClVSpwr51msnd/UHYu3jRkWakqIIYAQlsXp6QwdTN+yl2 WrtpPfoexu2//CqMdhYLDqAwBogC/URtqrDK5vjqT/gKAYke1coNXDz8IUFpOkaQ1p6P z8dXHYYegWB8fqRtCeFawOEEnZhYY6ZGrTh+QovCSeRsv509wmq6xahqseX7H15OkF+q Knwh6mWvypOJzuMqvMPUGYskEjh/f/lDDzC6csGBZyqK5puM4q4iyecigv7RsMn/1e7/ CKaVMuOxTSwmEa+4ybvqwNZPjHQWAb8vKLBCNqdo0WkOLw85ZWamRHdAAjN0qx3fJ5I5 zhMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rea+yT0I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz21-20020a170906f2d500b00982a5377650si3152853ejb.247.2023.07.28.14.38.51; Fri, 28 Jul 2023 14:39:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rea+yT0I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235491AbjG1Ufk (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234827AbjG1UfF (ORCPT ); Fri, 28 Jul 2023 16:35:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69AC244B0; Fri, 28 Jul 2023 13:34:57 -0700 (PDT) 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 0114D6220E; Fri, 28 Jul 2023 20:34:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50472C433C9; Fri, 28 Jul 2023 20:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576496; bh=vyjBGWyxBLS7yKk1ryFlF7UDmbUqwEQwLNgOkCH6QUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rea+yT0IiwPGhhE0KEND4yApkw5a3ILg6BoIRM7AwSF2wCqS1qY+//EtMqzze8Odt xvJ58ujCsX21oar+Bcm3nIwbXsznDchR6t7ykIJ8WteZ9IBaM+SRQAItGePyDKRyoz nFJCVeodxBpFWwK5n9pfFfio1UJcbio51qqREQquQDwnokFsyrUJSTouI/uELCp8r9 58W76e0TNy8z/akRdaoJ9tfVPEhPZKvI1TP8Nah4cKXlumcE6G+/wuIOAksrqLZMO1 NaJLOWwoPrUT5MdfTpg+xPu8M9V2XqZhalpiWr9NQRPFw3tshGmQOjTYgHwt2Y0CB3 pMGiohUJ4mCOw== 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: [RFC PATCH 12/13] Docs/ABI/damon: update for DAMON monitoring target type DAMOS filter Date: Fri, 28 Jul 2023 20:34:43 +0000 Message-Id: <20230728203444.70703-13-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772701987535053387 X-GMAIL-MSGID: 1772701987535053387 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 Fri Jul 28 20:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 127862 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp685769vqg; Fri, 28 Jul 2023 13:54:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlERE2XRgb8i0KBYIEZrzaSGmHAHR1DohE6GoYo+0JnzxcVMllo7SnipyKf/AVnGb0pf3dMb X-Received: by 2002:a17:90b:4c89:b0:268:3582:a6be with SMTP id my9-20020a17090b4c8900b002683582a6bemr2810266pjb.33.1690577646101; Fri, 28 Jul 2023 13:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690577646; cv=none; d=google.com; s=arc-20160816; b=ZM1EqA1HE+3e9HLQdjRwyFJVjld+Qcblve8s8GEczV3AF/OA5qfFEYHS4T9cXmALMS rZvO10vwjypVX+qH5Dt6pso9TFTu5IZlK9B2n30G9xZW6QZWuqICNU0neAV+wPCr3n5W 0jtAIO0BtbWWaIjHFnGMMy0DorQ8vGf2WBK/s4D26MLKOxMP52Rjd23daTYLiJUwqlzQ xy/FDWTjlYnMx+o4vqdsKkRPFigylUzGvjLPwy8nGNnSPZ+hKT6op1nFWjK4W48NE6y2 QCGHed/pNDYdUPUbuW/a442JFjxZ504IZQQLwj6uO/EEi9lO4hBvDaUgIiYWAbmj8U+N CL4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iuunIUn62bhZjdaFR+qEAwFTLHuVOYMKzjEUqds7ss8=; fh=Jn9vwBBsv0/M243wtBPWgrycE99QwFHXCzusFnO8K0Y=; b=oQSuvbPN5S+XwNdaC8W/G14G4qQC4bHEWkPHoVChfGjMiU8KIAfMM/srkC2hmFjQ6A 3ondwqbfV5O004y+1VjP3B6iyq33t2PY2THllzXaOi78Rwt96Zzet2dKzCWIfls/2XZQ oH8L3vg2ZhRt6hc338vwrlvfY88cSf1nBSOlf/RZl5NoUT0EmJYJVPTGgP2UPe7Vuhv2 GcZ9EWWn7wOani0hFNAyy65jbEg8oorpq6qd9xOfJEpvo37FSV/70lHGff9EgPGtAkKv JixbDJdSX6tq4eEEdSvMrYIGEtyFtz41cjfVWdOJxN4DdQvX7ffB0d3Nj4F0QQG5dP4n x28Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kCfYKwe4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot6-20020a17090b3b4600b002630cae4f47si5292276pjb.66.2023.07.28.13.53.52; Fri, 28 Jul 2023 13:54:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kCfYKwe4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235148AbjG1Ufh (ORCPT + 99 others); Fri, 28 Jul 2023 16:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233923AbjG1UfF (ORCPT ); Fri, 28 Jul 2023 16:35:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9507E4483; Fri, 28 Jul 2023 13:34:58 -0700 (PDT) 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 1C1FF621DE; Fri, 28 Jul 2023 20:34:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B4C7C433CA; Fri, 28 Jul 2023 20:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690576497; bh=jeC4GAEfQQwmVnTIZskvg6L9vM/nrayE2m9ijer6n98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kCfYKwe4QL89JDRqiWJGihImM+qcoMbDWecJ7hn5Iu+Tfw0wwq6G5Soa4tXigbIs+ cKRMiMjzFiwRgTa6FFAOyZ/Cj4fLXYlE0wrBytmbm3mQbInHJDivY+r/aUeIdGg3oE Mttwki34KUH6dQ4afT+n7RpDZEfriIuE5WtcfXH3hSOT9fbYJoS/uhCmYL6v6zaHlF 8kHxycb0NP0w8mRdV0JOMb4kDQW6JCY/h32sSZ8ZyZ3iqHTsijHYjs8Co5cqxVWS7F bRGrb21xaEpee+/SLZW1SB2C5OnDQu3NvdTvQg0bZ/zZxF8gJPpGUrIvZB02FSjVjY AEaMp+FQ3zbXQ== 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: [RFC PATCH 13/13] Docs/admin-guide/mm/damon/usage: update for DAMON monitoring target type DAMOS filter Date: Fri, 28 Jul 2023 20:34:44 +0000 Message-Id: <20230728203444.70703-14-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728203444.70703-1-sj@kernel.org> References: <20230728203444.70703-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772699146012089634 X-GMAIL-MSGID: 1772699146012089634 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: