From patchwork Wed Aug 2 21:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D7D7C04A94 for ; Wed, 2 Aug 2023 21:43:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF17A2801F6; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B531E2801EB; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A6EA2801F6; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7BD852801EB for ; Wed, 2 Aug 2023 17:43:24 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3C101C036A for ; Wed, 2 Aug 2023 21:43:24 +0000 (UTC) X-FDA: 81080491128.01.1D39FBA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 6CE86C0004 for ; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="MGXW/no8"; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691012602; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/kPvdyaF0vEK5qYkstLmLzJYcBFMKcv9CmUtYtZboIA=; b=B8IuwiAMNWaJWXyyIOPn3lxtSF3NVjFg3Diih6dT6rP0/vgVin93gHzEJ237ACYf6bFOLj 5lnlgzXEBZdum21LUMKB0NxmirbyqOCQma0GUVo61jAN8n9sRfNcl1BIVOBI14u32O9nAA RhPttXHx8/phhDLbltNEeUPdAF2IAdA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691012602; a=rsa-sha256; cv=none; b=x/1yR526RuDCG9qPozijkW4dMkAqvWPvOIcA9siamHjQFvI5vwTySfARDRRDsAajRkRn0C c664ctwwVN+Fa+0WJKyWFvnemLrozRTHX4dKvtmT6+HFhgnVi4++DBL327F75tVRxPBYE2 G0Gu7EVKY2EW6pEppDSg+/FsqSDbJCI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="MGXW/no8"; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2D71C61B5D; Wed, 2 Aug 2023 21:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 864C3C433BF; Wed, 2 Aug 2023 21:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691012601; bh=Z5TufRLeeFt1IBETpXgGonzkgtF37kqef1//j1myid4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGXW/no8kpmZgpQpS3OiSc3SSTkLbifo0+BdHXTF7aQ9MCoo6qcnEBrp0nq4ukQUf Ag3+nuYsoDCyPt4EH++KRhy7E++Eo7xh3gSL/5rLy5nalVdj0ieh1nqoGZBSkMcO2Q wWUlA1IE7UsJT5pw8B29eHbAGRuqJhbiLaXbDYhwgxYQ1lSyNweW1c7nG6wmkAmqBq dBxpzsKclteCHtOChtqidh0wXZuKzu0R3kfTWEEiA8oFlH8zZpNsDLwvkUvgLkbtPR /ea40Qks1h8F2LQdIl4cJCZyiSj3eltppdoEUSYwwCQOJDNXV2tup7XXkze3Vfz2Ga IzbsOMIF/h6RA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/13] mm/damon/sysfs-schemes: support target damos filter Date: Wed, 2 Aug 2023 21:43:08 +0000 Message-Id: <20230802214312.110532-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802214312.110532-1-sj@kernel.org> References: <20230802214312.110532-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6CE86C0004 X-Rspam-User: X-Stat-Signature: u5jpaqki313q9h3sr3cz6zammf9u6mei X-Rspamd-Server: rspam03 X-HE-Tag: 1691012602-893133 X-HE-Meta: U2FsdGVkX19Zbfzk+OoI0tONNl9hSorLY4BGegy3lsZjHeL9JKexvJdQ1Chthb7HM6Ui9E44eDIUeGotd3bbroBraq1K8qt1/71JvjqeB8Sl83le2ihzVA626Z2FKxGsjtl+5XkooDSCIxSZBOn6fffRIJmwkEURmk5toBLV618mbx3qfTyNkM1bImqUSgU4YjsTxQNbp4VRQ87Cg9zoDilLtPe9RzNHRBYdS1eJdOQybTIG3/EYFki/O2rWR44cT/RsT7W8Shq2ttXZRsONSub5trA32kd9NeqZkpj075y7M2sTAqVhgNf6LQVQU8y5mKEMBLEpsFiy9yZ5EuLAPcsvihwkHMOh8Wg5mWqADAxg5D5V/3csFZrW4HejE1nS0hWZ5WXFlizXdCYGCwOqVYZ1AJQeIVHNCpZimBLDhwYB3MP3ruhvjGCzdrdcOzyML2Rn5DpB99LjFrq1ankUsGflqk4B0pZXp9VY93CJf0b010oHwwPiPJw+nk3fUPaq74Mjr4wLHNztgwC96LUdmKwhRSNcAJ/vQ7e5ojyVy7ZHJYMATnmB5yEO7AfO6QgMONAWNULLJtXwYWDBj2fc896CK0Ui15MX3wtjZzoQb1M77ulQHCTA6icUhmNM1NZzAO8/3GyGpJS6tVnqB8GYka9t6COPeDKcZkDerfhAeI4Colb1YvoqBD9FSFSBxv+5DjTX47iB/0X9oB4ItNMTcvY915i6u5GKcg4XOfVlQEjb40k62FUjPhMm+FsKYrjl0OW31fdu7CD9W9pMc+gMA4zp4/jIuiL0GrehYXt0j5qtCRMDos3ZsO6bdzvoVZ8+iZgE7Jk7KxleQs2p1+RCG5bzkv2te6s1ovV1A2uVkuW4/fZxa46pasTWX2zvQaZHewNJm8OfMgkIl+3YDlwQ+lmdoYrNL36Hp2kps6nQPLJQOZH3NaUud/735mMc57cTp6HX6zlMWQOLUnhDsUy a9RMjpzo aEuR6q+oeIZLeCWqTDYkNb/GapNKwonYiEOETwFQbyhfABLE9jocWdR40kwF96W6t4DH5Kgvg44QZGmtiuU7TSS89IJBIuoNcwnmvRHxwlVpqfg0+vDvD/2AhNIsKcJ9COP0C+GS2wLe8V4DUlOxsJjWlnTUYuyeb9tN7GMm1Yd4Lp4hFvyyMjVBmhpVyA6W2VDnp1slI27P1YPYgh0/0IMRQ3QYp0J8OzLVBz18OL1zslQzQ66Nlk2opmLytEIHAXY3vStqHntoyKErSYYlxDIvotn4se4bqIJ+Ir6wIEveCKYGwGsALcqbXMykqyjhhK6n79DIDb0MVFcQgy9CEsYD4eQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Extend DAMON sysfs interface to support the DAMON monitoring target based DAMOS filter. Users can use it via writing 'target' to the filter's 'type' file and specifying the index of the target from the corresponding DAMON context's monitoring targets list to 'target_idx' sysfs file. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 03ddba3e216d..527e7d17eb3b 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -283,6 +283,7 @@ struct damon_sysfs_scheme_filter { bool matching; char *memcg_path; struct damon_addr_range addr_range; + int target_idx; }; static struct damon_sysfs_scheme_filter *damon_sysfs_scheme_filter_alloc(void) @@ -295,6 +296,7 @@ static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", "memcg", "addr", + "target", }; static ssize_t type_show(struct kobject *kobj, @@ -413,6 +415,25 @@ static ssize_t addr_end_store(struct kobject *kobj, return err ? err : count; } +static ssize_t damon_target_idx_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + + return sysfs_emit(buf, "%d\n", filter->target_idx); +} + +static ssize_t damon_target_idx_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damon_sysfs_scheme_filter *filter = container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + int err = kstrtoint(buf, 0, &filter->target_idx); + + return err ? err : count; +} + static void damon_sysfs_scheme_filter_release(struct kobject *kobj) { struct damon_sysfs_scheme_filter *filter = container_of(kobj, @@ -437,12 +458,16 @@ static struct kobj_attribute damon_sysfs_scheme_filter_addr_start_attr = static struct kobj_attribute damon_sysfs_scheme_filter_addr_end_attr = __ATTR_RW_MODE(addr_end, 0600); +static struct kobj_attribute damon_sysfs_scheme_filter_damon_target_idx_attr = + __ATTR_RW_MODE(damon_target_idx, 0600); + static struct attribute *damon_sysfs_scheme_filter_attrs[] = { &damon_sysfs_scheme_filter_type_attr.attr, &damon_sysfs_scheme_filter_matching_attr.attr, &damon_sysfs_scheme_filter_memcg_path_attr.attr, &damon_sysfs_scheme_filter_addr_start_attr.attr, &damon_sysfs_scheme_filter_addr_end_attr.attr, + &damon_sysfs_scheme_filter_damon_target_idx_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_scheme_filter); @@ -1539,6 +1564,8 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, return -EINVAL; } filter->addr_range = sysfs_filter->addr_range; + } else if (filter->type == DAMOS_FILTER_TYPE_TARGET) { + filter->target_idx = sysfs_filter->target_idx; } damos_add_filter(scheme, filter);