Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4427259ioa; Wed, 27 Apr 2022 03:44:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx30DOoNiRkkGpLojtO54kfX4aSlgYUGqCsM+KRwKJqnpqFWqNb7/CV4UyMOxObQUElY2Ng X-Received: by 2002:a63:1057:0:b0:3ab:a3fb:fb9e with SMTP id 23-20020a631057000000b003aba3fbfb9emr4893759pgq.590.1651056286778; Wed, 27 Apr 2022 03:44:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056286; cv=none; d=google.com; s=arc-20160816; b=ge4X4juzGjzDV+D0a/m2j582NIheqp/+rQQEhXY3MdIISaYe05rXyWazWA0uk6iJwn dgUAnZq4UPabqmtu3zjcm49dctjhuZ0nc4m7K7MdzP/NA0/lAQg4y9oLUc67vJRyBooz RFTEzgNFAySm2BYtanZHYKMX5ZKyzsBQ6ffbjxWLhljayCZE8Lpx5lREyfKGJh4GYiV0 6hH+gB825YdfyAD5CX1vm3fkAOUuzkmFlWabm+VROEjgaoARS+SpzGqotcekNt9XL9+Z FLrmBO0KnZk2OuNABEv5zO2MTEEbbPPMOq1TzlVMN2QV61heZ7nv0m4Ctvbt8Yi2wvY2 gowQ== 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=ULafVwYUDC98zC2Z69ijNg8ZSFYv9g1zM0qi3L0RUis=; b=ggCg35uVMjS93S3b2zzEMsd9amQhhdZqyLcxKnG8KAmsWH3r9b9u+uZk8+/YkV5i7z Gz0odj0vfyurRO1jeZMzFFZjn/Q2Xqm/GRjxEt+7lK0devqiZId6MCt9yJxmY49cxgzo /IiAEWxb+zDIxQyXA4UnBmEH2MlKigQgA64TNQTonS7urphhC8Rrf2cElBlQkS3GmccI gvtWgFKABl6TezQXDbbCbJ3SyzQzQXpCkfmHj6zigsEHcCwJr8sd9xNtuW9SjXo+EPiT AT15yjuLKuu+BurKf3Xo+/bDQO5btl0jeKt+23CRP1zbhrH3hakerc9fnE4uW8Aa+RiP 4LZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7XaVBw1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c17-20020a170902b69100b00153b2d165d8si1171918pls.480.2022.04.27.03.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:44:46 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7XaVBw1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C42022AC1D8; Wed, 27 Apr 2022 02:53:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbiDZUmI (ORCPT + 99 others); Tue, 26 Apr 2022 16:42:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355075AbiDZUmC (ORCPT ); Tue, 26 Apr 2022 16:42:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1757A99A for ; Tue, 26 Apr 2022 13:38:54 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id AA04961159 for ; Tue, 26 Apr 2022 20:38:53 +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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 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, }; -- 2.25.1