From patchwork Fri Dec 27 21:08:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13922140 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 918ABE7718F for ; Fri, 27 Dec 2024 21:08:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CF176B0092; Fri, 27 Dec 2024 16:08:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7061B6B0095; Fri, 27 Dec 2024 16:08:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 509C26B0096; Fri, 27 Dec 2024 16:08:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3277B6B0092 for ; Fri, 27 Dec 2024 16:08:36 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E9E601C83B8 for ; Fri, 27 Dec 2024 21:08:35 +0000 (UTC) X-FDA: 82941976992.04.5A43D15 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 3AD46C0010 for ; Fri, 27 Dec 2024 21:08:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DrLt89ic; spf=pass (imf10.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=1735333684; 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=m5QMYnebddBwTZ7fOidojqM6nQwTKNchU7wZ4QXXzSgdaJklk1eJ6dzvF7iwcEex7XL8x7 2tERKuutNnvnmooJ56QDa5HLnqrGiK+zQoYglPxRBRJzK7SVe/MvYUK4DXV086m7hTIby3 DdcYbBiluBbcucmXEwCY1n6qosJB+jc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DrLt89ic; spf=pass (imf10.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=1735333684; a=rsa-sha256; cv=none; b=8mU9p7mVXRJ0Yif5RIJy5Gldrb/s8j/2elSC5yyt5c6cNkQPUWDEP/h+obUKUf2aj9Psl5 sCxNtAbAE7FrphVbjChaBYhanlqdmoLQhSTef3VhvoxXoFWuTpgAjW66IY1AuwRE+3hKok h01XG5j3UguizeRR9kzrMI5J1bqbgtI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4E9155C603B; Fri, 27 Dec 2024 21:07:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 437FBC4CEE2; Fri, 27 Dec 2024 21:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333713; bh=ZERQXRIpbhEDVEpD6J6LgTdFsTQpbeeZuCqI48fC6sI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DrLt89icA879gSM39Ub/e7HV147OGR4ZXrFChzBzd0p8ILo78pml8/I8T2/zDwh3h HwqflM4E+tOSgKiITbK/KpcoVrSaMURpRrKuUmmWrQYnL2tJ/UMRl21g8UZTJqEUMW u7/nRtrszEUkMjtWvMdxfLJNF96VeKKSqf7HLnDsmy79/C1QW6aGuOm19deAEEtY8r ZGSEt0Y0nqoSmj8QkS4XXzEUFf7ASUGCU9U0fp/5eSSd2JkMpfblFkMNE3Xa/SOU/C BVMNdxZus9nHeBjJpwZwK/p8HVVhNyPoUtgdRo0wOK6rChQGvh7k78/frABWDndXxx +ZHav/02/UuQA== 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 v2 06/10] mm/damon/sysfs-schemes: add a file for setting damos_filter->pass Date: Fri, 27 Dec 2024 13:08:15 -0800 Message-Id: <20241227210819.63776-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241227210819.63776-1-sj@kernel.org> References: <20241227210819.63776-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: neukmwawgoqhfjoaabww87xwm8cue394 X-Rspamd-Queue-Id: 3AD46C0010 X-Rspam-User: X-HE-Tag: 1735333695-561094 X-HE-Meta: U2FsdGVkX18076Ss/bj+6pTS9bZQUJVrHKk2W5OKbb2NDCXgVUXyBrAj6yg4ItOkxB4nWTpNVS0P9Fdb+tRWVLSoExO4EKETohIrY4m6IIAeGRf6+buAAbhIZiBEZgSYiU+XkXilHzGxJ34VgHIeqQCTM+8YHSoiFFuy3uDChfBiWEHCKRByGrcWJEwVmtPKcmSCXTzM80B2aqrgrf+17OzLZlBmq4HcrD6lvSQrAiONyyLVWlrKWvgs4WAclzCJQdtuf2cCpUfcJFfS/KFjBrKh0eSM25GUM2kQOXsSyrhOb5378gwRB5hhv5twWmXoTB5NHvF1SE9o3Q9YXgt/j0YojcMVnhiX0DIQ1V+1/4Tzuao/ZF0GfsGsYTqkXT8WCLG+cvDRvoUTTkr+r/icrAemQMBb4HcDdi11np2PfE92gGtQiH6ukurbpXEwhIyf+7qRB01DEJ517HFOdTHXon4dk/4FiLZVQfhCRuWftTiN/aW05/4B6AFBgDsQ0Q0MLAugPzgoG6jMnnF3Ca0RIhYVt53SLQO+NRhy3clI1S33ca3RfXgI4KANwATxNKiY+FVZDzs5+QT2fgZM81Lc5u4AX4xGjlTqvn9FznqM3wRUEhyF1ls6jhIj5z2v18vzSzObeRWsf7kvYhikWFR6pnz0X4pnpoPrdcTit1hGKpIJks4oEfwFhgrp/MwCZTIyMk9Wpga8ScuWEepHU3/8U/g26qZnAdh+fDRliBrFffUkgTyZWFQopMYMS2z2FK31Lp/Jzk4hEFyMmGAvGkEy7j0FH14R0FrfXnLeETbjX2IDoBWgJGiWHQ2V8/cwRlqNSw+U0CmsoLXoW+Tu8tZxqDCyYMXO2cCAM7aTj/i0pExwQYTGE9xrUm9swGv2cZDceRQOL+ven7m9n1txGAvadH0viVQXa2EbnkW/Ih0lk5CsjG7WsPoaTIP0dXQ2Snh/8Ns8SGGKZpK/c3Iodhw soNHVYeX QnHPWFCYdTyva80uBch1rIsmVbAJh2fC3zVdOHBLxKMN+pEeMKID30WRXIM98ycz2gz7RsB+M8YgW8BBCoEmcK/bC4wivwqmfZNNn41u+HkHk2JU03ijCIiSJLY2QW4dMwFYDNfeR+RIq4xiGlX+Dn/j6IKE3PK6oLrgqg0GVUo+JYi94YKA4D/o4MaQbOczVNO27UyxAEfofDluN2mn3PDdwuBamUqV1o/WpdP/rWNg054Y0f1Z6B8FjoaOW47PeZSHow8pYW6HfapUO0bcXJTsCiw== 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)