From patchwork Thu Dec 26 22:14:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13921482 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 7E7F3E77188 for ; Thu, 26 Dec 2024 22:15:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 462736B0092; Thu, 26 Dec 2024 17:15:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36EFE6B0095; Thu, 26 Dec 2024 17:15:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 175AE6B0096; Thu, 26 Dec 2024 17:15:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D9C326B0092 for ; Thu, 26 Dec 2024 17:15:07 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 95BEAB0BEB for ; Thu, 26 Dec 2024 22:15:07 +0000 (UTC) X-FDA: 82938515394.26.66A1C8B Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf20.hostedemail.com (Postfix) with ESMTP id 576091C000B for ; Thu, 26 Dec 2024 22:14:22 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B9hDwO1E; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735251277; 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=kOSEhbHM51306icv78I717UU8N7Q1eIVUCIdSs5umFQ=; b=bmi5we1ouS1hqL7AyFeuZC8ctS3cBBbIdBq8+JFOc2mjbLEnfa/J1dmXAM/gtop5T+Hmis /lLNMkDIGGQhC2E8XKeRxfvwZ07J5JdSgH4nC5uc1gImjy3wnmYk//WuB7E6WVWyQllc3H 9N9VlxbVqIzYox0jEcfKNlwVYv2eEiM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735251277; a=rsa-sha256; cv=none; b=w6zwCPJ3rWCCWHGE93D1dZDgBs3qQP4PhXEM1UF5b4ZCrO2SkP3QxXQ2j9b314Uxmn6HCK n83d5OTU6GjxRj+d6oZiwhi5OLC1Hx7fUW70AgOP/vVdpoBt1Wb2Jx94+bzZT4wXQ4kpmM ihlGbsBVXmImKoiYGCswpTDC8AzScAs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B9hDwO1E; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id AF66CA40F4B; Thu, 26 Dec 2024 22:13:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37E88C4CED1; Thu, 26 Dec 2024 22:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735251305; bh=ZERQXRIpbhEDVEpD6J6LgTdFsTQpbeeZuCqI48fC6sI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B9hDwO1ET56DJbfUvA1NkwrMAmS4uGKkC/pY+lnPyDmXlFzZblsZPOf/hRnvjug2D Ijv/xdiTSf31U6r5mgZI+BBwJ1GgfipaG4Y1gOwChrjrnck9kcooqb522+Q1WRRJW8 6eGsDotNEvfM9quAQC1lcy/iuYXEjpfPRimjwTcBCFiGcfw0ZH+sl8vf7orfi+xnmv 6eQ9M3oA52KByjBcgcZmWHa1dni6RtyulWyT/RC9EOB/cJ5n9LMBE+u7n+wp6Frr4z zlfg3TPUFFZU00E4AWCp8Ikpg1SP/bwQTc38d5oWrfVgxHX+f4qxL4HSaSIhYk/PSU 1JGgegHMZXyrA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 06/10] mm/damon/sysfs-schemes: add a file for setting damos_filter->pass Date: Thu, 26 Dec 2024 14:14:41 -0800 Message-Id: <20241226221445.78433-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241226221445.78433-1-sj@kernel.org> References: <20241226221445.78433-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 576091C000B X-Stat-Signature: 74osutruzgctoo9qyeoeaxog4qmhfddd X-Rspam-User: X-HE-Tag: 1735251262-6605 X-HE-Meta: U2FsdGVkX18XJ2aUeu6dIHG+rlQDt7dUzFFEXJ3Zrb+j1FNObMTOxnLzgG4TUT3Jvvla7nvahIf5ngi1NvaLPjrdQobDWstVduJmUxXcku9sWmKsWtO6EUR/xC9pM7BWpijB6kn81Q4nEmvE6QK8TVXuBPmEzCqG44HGXCgNJx57iLbb3y+N0fQqM3Cx68u0Xpier2K1wgI85w5p9EBoF2wSQyFBnUNIJBcAcVSl9a6pBR197L1k4a2oAyp5VR41qtb3cwGsdcIDyyBNW1d0Jim9OqbCNat/1x+BHljmUmhvMtVNBuKX4EAI1OUeyHmy07dvvSRLCLRGndJqnoKJDgMn5zWzPYzcPbAEpuDTC00SV3b8kA7BmQAF7UO8gO6NBh7flHZLBF3arpiUS0EDsIQgPeAkSiKMnbaqc9PMQ09J8SVF9AXV6+81dGxQ9HWjSqCunL/g03V4GNAXwnBj7ZtXAjgY4B+DlIWRFK8aRSbQmkmC7kezuxG478Ar7FU8WrFCxRZMX1OC0K29kNrz/hBfVoH0/d92nvJGhfWUVM7uvuMiJc6E6S1nF1Ho2M3PoiJ5lRS1PWsiiadQPDlqlzhu6msY4uQr7Iur+iMdUvOZZuzCQESgS9RqKprF45d0LP5450HKQ8ssZYzKRCy1GGPxTZdbIzgKHVWGDPJ6zv9SajaSldo0EVGOUK/shJGIKYtUD+MqWVyliWs6V71tTv6OiXK66kBAtXNQAd1Bth5ZUkT92un8H/l6ZpFAB/wheDZ7HCu6HRrniSgPW/GB1z4sg1lAoFLQk5eQbMwDnTDL1SxhMvM4eyFippxLStafM+RgQqaUTtjqmu9/9T3vQwEUIZCraylkn6Iz4h7ncjdRHYXfCXHtj3sOHIlZliJijSiomYykSCkJr3WDtNa5h6XyK1GN85h2q+1mG1fQs1RriFOURMQvlqjr6lnegF75dXpFYp9Z41Nzs3q/nLw kRDFImyJ Ot2TfUXIcfafjoUuWauL0t3na3ybtVWnJeaqDUeMJAO/q5rfvAVG7sLTrSEWy1fFiiIh+Yj/ITFRN5eyVBF2XfbdvRa86wS9IXvgrFoLJyk4vnPQ+DPh1BoVN/O05Y023r3/p4+zXOnsInX6zCOrKThVu0k2j1FqCfL/mvVtaUEat/uwcDTyhyT6U11XyOFeKD+jsVsTWxXH8uqoagjNZl8P7+R1QMFd9HyHYJ1QrYun2j7zItHbjw2I45lRrS++8wv90TUihl1y7LFeaHXW/27zM4g== 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: List-Subscribe: List-Unsubscribe: Only kernel-space DAMON API users can use inclusive DAMOS filters. Add a sysfs file named 'pass' under DAMOS filter directory of DAMON sysfs interface, to let the user-space users use inclusive DAMOS filters. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 9a883e8aea1c..9e171046ee94 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -313,6 +313,7 @@ struct damon_sysfs_scheme_filter { struct kobject kobj; enum damos_filter_type type; bool matching; + bool pass; char *memcg_path; struct damon_addr_range addr_range; int target_idx; @@ -385,6 +386,30 @@ static ssize_t matching_store(struct kobject *kobj, return count; } +static ssize_t pass_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, "%c\n", filter->pass ? 'Y' : 'N'); +} + +static ssize_t pass_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); + bool pass; + int err = kstrtobool(buf, &pass); + + if (err) + return err; + + filter->pass = pass; + return count; +} + static ssize_t memcg_path_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -482,6 +507,9 @@ static struct kobj_attribute damon_sysfs_scheme_filter_type_attr = static struct kobj_attribute damon_sysfs_scheme_filter_matching_attr = __ATTR_RW_MODE(matching, 0600); +static struct kobj_attribute damon_sysfs_scheme_filter_pass_attr = + __ATTR_RW_MODE(pass, 0600); + static struct kobj_attribute damon_sysfs_scheme_filter_memcg_path_attr = __ATTR_RW_MODE(memcg_path, 0600); @@ -497,6 +525,7 @@ static struct kobj_attribute damon_sysfs_scheme_filter_damon_target_idx_attr = 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_pass_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, @@ -1901,7 +1930,8 @@ static int damon_sysfs_add_scheme_filters(struct damos *scheme, sysfs_filters->filters_arr[i]; struct damos_filter *filter = damos_new_filter(sysfs_filter->type, - sysfs_filter->matching, false); + sysfs_filter->matching, + sysfs_filter->pass); int err; if (!filter)