Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1480732rwo; Wed, 2 Aug 2023 15:04:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGWmuCp4WDloMUOPcEFlUy1h0hk/dBrBp+dbfBBX8Xj1fDawHjpHU/F10bUTBtZboMjtxUN X-Received: by 2002:a17:906:ef8f:b0:99b:6c47:1145 with SMTP id ze15-20020a170906ef8f00b0099b6c471145mr5687398ejb.32.1691013890762; Wed, 02 Aug 2023 15:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691013890; cv=none; d=google.com; s=arc-20160816; b=sJvHLwIycFCyYmyW/wDL2776REBe8qJvcvupdULmz2wbMwSV/f6tMJJV+7kxjPdjqL R3yBxXZXjD+YB2S4YLLyszu/5I/L5M6QriYnrttWwWQKLZZfR3PXv6CWqSd8zRWy+QNp jGZ04M4Kmcvj09uBkBUGTYunKyGH8kqokRf5dJCCHnIJ6naPZJ2qPeqeFIR8vWwGZxKU 4W3boQnrIuBXqwXydsgRnxTB100cuH1lgVZ0c7GzNWkJKejCeR27pXoha4P/zAUJxmHX R6G3qLCl8Y4DefC1DMYRfHDzXCrpj35OPqCWeA3ycQNOUW4Feri3a4TPt8LkanGXVnsY QdEQ== 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=t2Ww2AyJq0ceiYfbfhcW7WFgn4aAZ4deHCTNhfoWqpL2Pq6ZzOc652CFv6OaCf8ryg WXjYw7AEtmTezmhhTO72lwGfCjw8NYxHoZneKSp9zwT/RUn7qlIf4xbSEv1gtvVAtyIu TODXv0Sq3aMGz64KFKbSBtPGqRXlqkhLBghB7/6lESKsmihqBd3Ix9rJ9bIVCD71vYO6 N3dH39j0PtW29+etInc5hHIOseadM2Jw4T9Ickg7tQtf8ucE3gM2DDknB0E7gc11QUhy ppUZaudlN5Su77LcUOnhexyCdvZwYZLg7n3Fbsx2nqZiVfEiXVXvZRyJh+aXn66+nB3h ikcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="MGXW/no8"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc23-20020a170906f91700b00992ad2f72fesi10979792ejb.537.2023.08.02.15.04.25; Wed, 02 Aug 2023 15:04: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="MGXW/no8"; 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 S233659AbjHBVnu (ORCPT + 99 others); Wed, 2 Aug 2023 17:43:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233192AbjHBVnX (ORCPT ); Wed, 2 Aug 2023 17:43:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12C72690 for ; Wed, 2 Aug 2023 14:43:22 -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 803BC61B66 for ; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 864C3C433BF; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012601; bh=Z5TufRLeeFt1IBETpXgGonzkgtF37kqef1//j1myid4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGXW/no8kpmZgpQpS3OiSc3SSTkLbifo0+BdHXTF7aQ9MCoo6qcnEBrp0nq4ukQUf Ag3+nuYsoDCyPt4EH++KRhy7E++Eo7xh3gSL/5rLy5nalVdj0ieh1nqoGZBSkMcO2Q wWUlA1IE7UsJT5pw8B29eHbAGRuqJhbiLaXbDYhwgxYQ1lSyNweW1c7nG6wmkAmqBq dBxpzsKclteCHtOChtqidh0wXZuKzu0R3kfTWEEiA8oFlH8zZpNsDLwvkUvgLkbtPR /ea40Qks1h8F2LQdIl4cJCZyiSj3eltppdoEUSYwwCQOJDNXV2tup7XXkze3Vfz2Ga IzbsOMIF/h6RA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/13] mm/damon/sysfs-schemes: support target damos filter Date: Wed, 2 Aug 2023 21:43:08 +0000 Message-Id: <20230802214312.110532-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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); -- 2.25.1