From patchwork Tue Apr 26 20:38:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12827956 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 E559FC433F5 for ; Tue, 26 Apr 2022 20:38:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A92C6B0075; Tue, 26 Apr 2022 16:38:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E1AE6B0078; Tue, 26 Apr 2022 16:38:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A8756B007B; Tue, 26 Apr 2022 16:38:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 1998E6B0075 for ; Tue, 26 Apr 2022 16:38:56 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id E909180C6D for ; Tue, 26 Apr 2022 20:38:55 +0000 (UTC) X-FDA: 79400194230.16.70B3388 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf11.hostedemail.com (Postfix) with ESMTP id C7D814004C for ; Tue, 26 Apr 2022 20:38:52 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 604BCB82324; Tue, 26 Apr 2022 20:38:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 986A8C385A0; Tue, 26 Apr 2022 20:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651005533; bh=ye+LjKF19sj8g3+LRr6BvSaFMe97AXGWcgOi77vqX+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t7XaVBw134K8ApDrlwRjsp7ewuaN3S9FtArmXBU/1Y67xi4cbPkBASSJtAHGdNGii d3e9uJyqYrMnf7JcI6aF1Ya2Q9pdwpcVeR6AiWFxZAdQRyfkmRsG5RGJk774JjSSYZ IoQ/aLF5L5N2Y+MuHEkCBk9feeTPJ2ULfft9kDMWFwuw4TO0SRgyfA3Dk2dEMqukH8 yNEhOleftuRUHFPLXHqpJ9g4eK5Zz9ocZ6LFVhrWBnPGhxaFCx5Bh9vLTrsGStbezK QISOG77qZVvBCDcOo3sApIXh1oe1tJeIM7NAdi4IUjQUXbr/Qi9VBOLLmSFEOvniyN bDo1KF6RVn4yQ== From: sj@kernel.org To: akpm@linux-foundation.org Cc: linux-damon@amazon.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 2/4] mm/damon/sysfs: add a file for listing available monitoring ops Date: Tue, 26 Apr 2022 20:38:41 +0000 Message-Id: <20220426203843.45238-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426203843.45238-1-sj@kernel.org> References: <20220426203843.45238-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C7D814004C Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=t7XaVBw1; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Stat-Signature: e9a1wqycwdjby9dp9mnin4ismh6oy7u6 X-HE-Tag: 1651005532-246714 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: From: SeongJae Park DAMON programming interface users can know if specific monitoring ops set is registered or not using 'damon_is_registered_ops()', but there is no such method for the user space. To help the case, this commit adds a new DAMON sysfs file called 'avail_operations' under each context directory for listing available monitoring ops. Reading the file will list each registered monitoring ops on each line. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 48e434cd43d8..6ad6364780b8 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1810,6 +1810,21 @@ static void damon_sysfs_context_rm_dirs(struct damon_sysfs_context *context) kobject_put(&context->schemes->kobj); } +static ssize_t avail_operations_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + enum damon_ops_id id; + int len = 0; + + for (id = 0; id < NR_DAMON_OPS; id++) { + if (!damon_is_registered_ops(id)) + continue; + len += sysfs_emit_at(buf, len, "%s\n", + damon_sysfs_ops_strs[id]); + } + return len; +} + static ssize_t operations_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -1840,10 +1855,14 @@ static void damon_sysfs_context_release(struct kobject *kobj) kfree(container_of(kobj, struct damon_sysfs_context, kobj)); } +static struct kobj_attribute damon_sysfs_context_avail_operations_attr = + __ATTR_RO_MODE(avail_operations, 0400); + static struct kobj_attribute damon_sysfs_context_operations_attr = __ATTR_RW_MODE(operations, 0600); static struct attribute *damon_sysfs_context_attrs[] = { + &damon_sysfs_context_avail_operations_attr.attr, &damon_sysfs_context_operations_attr.attr, NULL, };