From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 332713B8131; Tue, 12 May 2026 14:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778596621; cv=none; b=WTEMuWEf0QsnqJDp0ZMIU6r1KxOXVIbc8nQT1er6zZ9PNoF0TwAM/N97WGHu96ylmE6CwWRJlRpnw2Wh6f7Nl3KTWptu64J4uqQPQA5w9cBPgfgnx9UK39fyg2ChYn6hekktLeTCC98JDLr4yiRh87pGht9wBuhAEY65+3wrInY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778596621; c=relaxed/simple; bh=MsWu2zyYAy4V2rgxAX8KgVIMloArlsZthg7SEALRXSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l4EG+YF/YbqZrYohyePP321STU7+tdzyh/cv7VqxPiklUBavud/gYV4CrdKIlpU6rzyNOjm+sJDQIZZgpNwxr1VWxLNySg4Mjkff4MbhYit1UdiXvufUNlVitFmpqyoHTLFuzGv1WrZzPxJ0aL8pcGHlHB0h/v/CTkkbeBA0TGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t6WNwwQv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t6WNwwQv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8147C2BCF7; Tue, 12 May 2026 14:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778596621; bh=MsWu2zyYAy4V2rgxAX8KgVIMloArlsZthg7SEALRXSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t6WNwwQvGd4KqutwoIYQ2sBnmm/3oYmk78Mtm6HYhHckxSakRl4ARm0b7uwRfd/Ko v8Uv67OlLLlrEflPV7ZJiJ1MV/BofNocP6xoPRfR/xmHvzc+Pb2WKh9cDJZdqPUVeJ SusGM1c1eAfrXbLfEuhrqUCBwDYI02hqlbrgipo3Rwp1MNoQUEfwZjY2xuTJsqBGm3 uuL5uJ2iruOrcbPQkz4WT5mikUeF2dg4jVkBQpcegkKtrBuw3SYsK1rM4f/HUG153h n/E7SG/EFG1trclw1lyF+JBTwXNLIo1fNV2IpFJwo5t0k6siz97SValGPt9HPLE4gs +McRVtnOb/Xjw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 09/28] mm/damon/sysfs: implement probes dir Date: Tue, 12 May 2026 07:36:24 -0700 Message-ID: <20260512143645.113201-10-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260512143645.113201-1-sj@kernel.org> References: <20260512143645.113201-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Implement sysfs directory that can be used by the users to install data probes. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index d5863cc33d230..ccd19fc062f31 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -747,6 +747,35 @@ static const struct kobj_type damon_sysfs_intervals_ktype = { .default_groups = damon_sysfs_intervals_groups, }; +/* + * probes directory + */ + +struct damon_sysfs_probes { + struct kobject kobj; +}; + +static struct damon_sysfs_probes *damon_sysfs_probes_alloc(void) +{ + return kzalloc_obj(struct damon_sysfs_probes); +} + +static void damon_sysfs_probes_release(struct kobject *kobj) +{ + kfree(container_of(kobj, struct damon_sysfs_probes, kobj)); +} + +static struct attribute *damon_sysfs_probes_attrs[] = { + NULL, +}; +ATTRIBUTE_GROUPS(damon_sysfs_probes); + +static const struct kobj_type damon_sysfs_probes_ktype = { + .release = damon_sysfs_probes_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_probes_groups, +}; + /* * monitoring_attrs directory */ @@ -755,6 +784,7 @@ struct damon_sysfs_attrs { struct kobject kobj; struct damon_sysfs_intervals *intervals; struct damon_sysfs_ul_range *nr_regions_range; + struct damon_sysfs_probes *probes; }; static struct damon_sysfs_attrs *damon_sysfs_attrs_alloc(void) @@ -771,6 +801,7 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysfs_attrs *attrs) { struct damon_sysfs_intervals *intervals; struct damon_sysfs_ul_range *nr_regions_range; + struct damon_sysfs_probes *probes; int err; intervals = damon_sysfs_intervals_alloc(5000, 100000, 60000000); @@ -799,8 +830,22 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysfs_attrs *attrs) if (err) goto put_nr_regions_intervals_out; attrs->nr_regions_range = nr_regions_range; + + probes = damon_sysfs_probes_alloc(); + if (!probes) { + err = -ENOMEM; + goto put_nr_regions_intervals_out; + } + err = kobject_init_and_add(&probes->kobj, + &damon_sysfs_probes_ktype, &attrs->kobj, "probes"); + if (err) + goto put_probes_out; + attrs->probes = probes; return 0; +put_probes_out: + kobject_put(&probes->kobj); + attrs->probes = NULL; put_nr_regions_intervals_out: kobject_put(&nr_regions_range->kobj); attrs->nr_regions_range = NULL; @@ -817,6 +862,7 @@ static void damon_sysfs_attrs_rm_dirs(struct damon_sysfs_attrs *attrs) kobject_put(&attrs->nr_regions_range->kobj); damon_sysfs_intervals_rm_dirs(attrs->intervals); kobject_put(&attrs->intervals->kobj); + kobject_put(&attrs->probes->kobj); } static void damon_sysfs_attrs_release(struct kobject *kobj) -- 2.47.3