From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EC2EE3AA4F6; Sun, 5 Jul 2026 20:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783285080; cv=none; b=So5cOlrke0McXBtF5EyQkWnQk/mcbzGPPHS79XOcvLPLshKu+iNKgx7l3kgfXfAohTjLEyGMQkFvSGGXoP2XouqaTuImc2rkTjjPU8qICBcu0jBgTuDRAExwRaadQ7zJMUpz+cFdH9tX00llM9jQO//NtYB17nXXZ4kVhX2hIqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783285080; c=relaxed/simple; bh=1qK22Wmyg+VPePlHBItbL0HDLucjvkb0yd+RYmjadoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cBe/GgzBcxF33LK7AWHYr//nwNfHPDuWEoeG+rxeesXx86X3k0Eirxo35pIY4HVsYM0qZr5YTK3zErUtvyAGL2yuBfYdF60hHKVUO2y2Jzrb5OcPz6SSLS60oTDD+n/Hwf6MPBZ84ZufrjKLtmJ42CHaRMJB0nyygc0PdUr1AL0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VX9GHMPj; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VX9GHMPj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FFD81F00AC4; Sun, 5 Jul 2026 20:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783285078; bh=yJOHjYArtxH1+/qkwlfdh08BuCLZ4ONkiqi8cM2xmzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VX9GHMPjitYbgUhbD/eOt0yomF/5zLP6SWMvxfHtW0JGPH746SuoFNYGBrDz4lyxT Kga7TpJYKyWu/7LQUo1wg0bN2sNSYJrHEqxF/DU3iYzasJM7t1jv3TiWp8GOtUdWt+ 1r2QSeei00367QX6veNOZzaX7U5NdDI/AkcznfwKnedgUvXacjuWgyHo6Cj5Yj+IO3 y9UBnpl4mkWOe55YEyavsEjXeUOhY/U1Fv2wS8RWIwRBGAfcEMsHWcxm8PXrkNWqHd IioLQheZphLpXPxRvD4/DNUA/bkUBMsMlp1SSQKG1v8sw/OGVTVgnaDjfzwblbh2R/ F8oeo7BD4HFQg== From: SJ Park To: Cc: SJ Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 13/16] mm/damon/sysfs: implement probe/weight file Date: Sun, 5 Jul 2026 13:57:35 -0700 Message-ID: <20260705205743.98656-14-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260705205743.98656-1-sj@kernel.org> References: <20260705205743.98656-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 a new sysfs file, 'weight', under probe directory. Users will be able to set the probe weight and enable the attributes only monitoring using it. Signed-off-by: SJ Park --- mm/damon/sysfs.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 6d7e36c9e509d..b5fe036f78015 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1065,6 +1065,7 @@ static const struct kobj_type damon_sysfs_filters_ktype = { struct damon_sysfs_probe { struct kobject kobj; + unsigned int weight; struct damon_sysfs_filters *filters; }; @@ -1100,12 +1101,35 @@ static void damon_sysfs_probe_rm_dirs(struct damon_sysfs_probe *probe) } } +static ssize_t weight_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct damon_sysfs_probe *probe = container_of(kobj, + struct damon_sysfs_probe, kobj); + + return sysfs_emit(buf, "%u\n", probe->weight); +} + +static ssize_t weight_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damon_sysfs_probe *probe = container_of(kobj, + struct damon_sysfs_probe, kobj); + int err = kstrtouint(buf, 0, &probe->weight); + + return err ? err : count; +} + static void damon_sysfs_probe_release(struct kobject *kobj) { kfree(container_of(kobj, struct damon_sysfs_probe, kobj)); } +static struct kobj_attribute damon_sysfs_probe_weight_attr = + __ATTR_RW_MODE(weight, 0600); + static struct attribute *damon_sysfs_probe_attrs[] = { + &damon_sysfs_probe_weight_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_probe); @@ -1965,6 +1989,7 @@ static int damon_sysfs_set_probes(struct damon_ctx *ctx, return -ENOMEM; damon_add_probe(ctx, p); sys_probe = sys_probes->probes_arr[i]; + p->weight = sys_probe->weight; err = damon_sysfs_set_probe(p, sys_probe); if (err) return err; -- 2.47.3