From patchwork Thu Jan 9 17:51:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13933074 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 3F062E77199 for ; Thu, 9 Jan 2025 17:51:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E28346B00B7; Thu, 9 Jan 2025 12:51:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB21C6B00B8; Thu, 9 Jan 2025 12:51:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C04CD6B00B9; Thu, 9 Jan 2025 12:51:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 97A726B00B7 for ; Thu, 9 Jan 2025 12:51:46 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5764D1C6BA5 for ; Thu, 9 Jan 2025 17:51:46 +0000 (UTC) X-FDA: 82988656212.30.6F768C7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id B1AD680009 for ; Thu, 9 Jan 2025 17:51:44 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P8NlydKr; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1736445104; 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=uDcVV+/QHzwh9jBJfBXo0hpUbUbzRbpugec7AlGNIQM=; b=OmefAMz52b2NTKAz2cKzbrOnesVoBIWcb60JzQVp+KHegEkLYm5dS2s3Mdjj2vQ0dVwYmo Onm5CLFqCoGsvSq7RG5m5GoSv+XLEwJvPZ6XyixzgLhnlgLezTmFjPxil/DCTa9wkROkrb gDKHUdZWj96Nut3nyFQfH/sILXQrFBQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P8NlydKr; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736445104; a=rsa-sha256; cv=none; b=veuf4qlW9wZyjqPwhw9h/90b1QduFn+oRjc4fIBKeQ2KQGGIYOMb2cVA+4Re2dP/8xZKJX dOhDh7qbA0R3YCX2poYTFKMrpQDlhhQ8oTONcfE64jyGWm4huh+bhUz21mrcj7kUWH27Pe DcC6GZU7l3wJux6L7rsP8KyYOgHcVOs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D40315C5CC9; Thu, 9 Jan 2025 17:51:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E877C4CEE2; Thu, 9 Jan 2025 17:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736445103; bh=qmaIUnx59dUjwJkr4G+Ggfwt4z+WkdllmHRXE6wuoJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8NlydKrZFuP8R5wAjf7JbfscwIPB64jz+BGzzEkjRkiQZqySwJ97bJzTajtYLk+F 0xXmae4ZRT78XzzUs1KT7FmLdBlxWrn0RMcxKFtG7TO2kA6sR8YMDUTmrws2e3ycFG 2ttU3NmCipytEE+qOvbm25XhIsMPT6hQUQ2YCu6FSo4LXdibz9bnQ1QqJ9wYOE4Cjs rstP5YUKEr+Ekx6gMov2qd3AWBoffGg9Rd/b3dZUMjRaTLR+SPsAaATPfHLCno6uNc jQhulsnR2GHmgyX6YJVmV+IWHp8k6De+eqP+SueNmgk84xgIVzB/CHwqp6WhUiAnLT U7/MjPM6Y6uSw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 06/10] mm/damon/sysfs-schemes: add a file for setting damos_filter->allow Date: Thu, 9 Jan 2025 09:51:22 -0800 Message-Id: <20250109175126.57878-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250109175126.57878-1-sj@kernel.org> References: <20250109175126.57878-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: B1AD680009 X-Stat-Signature: tpqfet5mucemhq7rrxi79y7xi7znyc8h X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736445104-495921 X-HE-Meta: U2FsdGVkX1+btuvBVm50RBIJJQ6BnKLOz+t8Xd49WmLR6wcZeKE+cZMoBmUJtAZr1e42vAbGOrDvw1pgPOM8czxbHiFClSnkhL5KSe7a/psh/SYIzV8qF0rNJkJTn074+G9gJXKUNkrvA3cCtGxAd82cYKU9zm0uynQJ5+Dak0RmZOcAviaGOFl9s2xviwfB+LtoiT8TFMZQQH09xEuC85XnNSlWhX3eZEf6y3X4W6IgMn0kOQM32AFzwXSu9Sjmuj5TbEBdu92KCQk+Lr+w+H1mi17eblUu6IUEX/xvE/JCnhwEw0y0QXS0THXGAHb20DXq1qRcYINGz1p9SazfbkoR+aziqrBpKiFu9GeKX/xZRgjcZ7nb9PQwR2YGRXTTeeyikZEGLX6qZqB2CnXjM+PXQgwyIfH7MsWuzLi4CbCuKsAQ0B78t1jGWCwsFnBT3D2NntYHo3X5oHnw140wu2de5j4OxyL5ORpC3nIMFhfzUy0rKtOkON0+ym8t4gNR9euLjFCifJHVelipb2MFtbSun8UyF2wA4FEiUzUaWqHLYEl3eXk1PjtD0XOB/UD/SpunZsorjUddH++F6dvYYN4aphEpyPGQ4QrbzFmK4GfXWCb2nZCAoBYF8xgeoF2nobYzgJRmR7KmxTMBDeovNvv04Hnqq0RejqgzrU1Izlbo5/90tPgTYlqkFVyw+VCTB2BblBIBYD+j7RMWSQ51WSXoz2KOEPMwxAg1luL6kxtUNhqtf/2PdhUJ0IeKNHGXVbtunSWDv/iai6zuZczfySl82f9fNLuAv0g1Uih+puWQM6y1tJ+yRRvW013EhqvKmBnera1hLOJKLV3Yn7QEN3PCsRtKF9ZMD9Zc7erMM+Owyf+j9XxGP8zOKF8FZdNtg23XZUlLNEs5q2LGki+BuUpkAcfUJfhnI+OQ7IaXc8ZLKQcYP04FGYMow7ckEi5GrmFc9L+MLLzIPE2thMt Ll/mxs1G xa/+w33TWcyy3EIIorhv2ji+YPsIaECpKbOil2vnsq/PXkGoKoO+oeWUEQAxJWgpf7N3HDeUj8UgyMz/42yhiB8k8mN+q6AJ93CHdYKFA0r9EugHW8QveCTzaZClk4rfDSZuRnue+Ax5UaBrYpcJHLTZT35H7wPMAwtCgsJ2tvqxIvfHe9zo2JQfbbeUvyJVSxzQ61qitrVn8+ac9vG9sWVw6UDWVvZGH2ax1ChZvQ6rhjoYb/Syye/5ltXvxFdNSBbpXb/WKHjsVY3q6U6fruTxFkA== 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 'allow' 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..98f93ae9f59e 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 allow; 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 allow_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->allow ? 'Y' : 'N'); +} + +static ssize_t allow_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 allow; + int err = kstrtobool(buf, &allow); + + if (err) + return err; + + filter->allow = allow; + 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_allow_attr = + __ATTR_RW_MODE(allow, 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_allow_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->allow); int err; if (!filter)