From patchwork Tue Jan 7 20:17:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13929582 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 D6AE1E77198 for ; Tue, 7 Jan 2025 20:18:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEC156B009C; Tue, 7 Jan 2025 15:18:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B9D466B009D; Tue, 7 Jan 2025 15:18:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3BC06B009E; Tue, 7 Jan 2025 15:18:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 752DB6B009C for ; Tue, 7 Jan 2025 15:18:17 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2DCA2A0CD9 for ; Tue, 7 Jan 2025 20:18:17 +0000 (UTC) X-FDA: 82981767834.02.E020BF3 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf29.hostedemail.com (Postfix) with ESMTP id 9FAE2120004 for ; Tue, 7 Jan 2025 20:18:15 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=slJilpwI; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736281095; a=rsa-sha256; cv=none; b=2QV/ppq8jBo6NJJUz2i0e9HTIhxUSEs86I9OZT3YSkegUP/l13uJumJiAEve8o7ta6PnSn vszueUBVjy65lJHXjOO4wYQkIvO/l5ujmjegxlHtYgPlDOMqwT5mvJ2DX7jmhCaOlgAbI2 XtFaPUpQmRgKfV18Zm2F6RwRyeaEKLA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=slJilpwI; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736281095; 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=Upk9jKUU3qL8JK9t56ydCUhv2lLQWEh3nmJPJ5bv8mhRx9+blFcRqK2id3Im0VuZFCPzRU 3kif++Y5fi2NkUJdlAcC6CbD0go5X/2JlapH63iKn7OuWEFetR/qIbt69ILT4MXjkved69 LLiUhCai/2T8B7IQgRVrUC+AN2WDYoo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 4DE03A41D08; Tue, 7 Jan 2025 20:16:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE4C5C4CED6; Tue, 7 Jan 2025 20:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281094; bh=ZERQXRIpbhEDVEpD6J6LgTdFsTQpbeeZuCqI48fC6sI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slJilpwIOoWc2ruriXmweZYgn+/8so1cWoZ3VtcHYglEtfsQV3O5P/QcknYVWIl/6 Uj0dxHDQ4mFZQtIY755fd7pfC0oFdHjkFMyPMYtjAbmXbFcUggxCRpTakGpP852ZIB 7AgH7fKhj9cBedscF09kRtT7rEtw32LCiK+0HpAhqMMZ1JiQgmQivgjQMx/tI5jI3A Y+psKcsEi6caa/3wxr3kuMlvxtQf7UOsp50JIS4qNs8zIqExutcm3WC5DPjUbSxBgC 6PaUBjyu6mJA6AOD3Cr8srUrjYMY890PaT0zEfQlMEtz77lbUXwCgu7u6xQOFnC1/O JQnwkn3DV+TLA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/10] mm/damon/sysfs-schemes: add a file for setting damos_filter->pass Date: Tue, 7 Jan 2025 12:17:35 -0800 Message-Id: <20250107201739.79484-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: smjxajhdzw5idr7knqe74mfrrwudp5tx X-Rspam-User: X-Rspamd-Queue-Id: 9FAE2120004 X-Rspamd-Server: rspam08 X-HE-Tag: 1736281095-861601 X-HE-Meta: U2FsdGVkX1/baBww5nPm4syQOC15BFJugKArZAAmmT4ZEZ2qHd2RjuRc7xm9rypsa4aKszGncIeIOLo6rYhj4uvAujtc24m+4j/pTuhynxLv4+zfJBtyIHEtWywQd+oRqC1yql+rgk7QkROH+pf1oZ2Q1El657RIzQrfIF2CUxHigVaPrSc3p0RRCstrtjc3mpOFEXCsdZxY1lzydohkIXsfm1ID4UfX7pcwtpuxCWs22HDMEj/Q7WlJXzqql3p2D6E4+rtVs+B5YaLDpGB4ifburCbMAHJZ9t4yIHOqAVHVENIdAFgnn4YNe9575LmAj/xpcPdTS9P7+85McIlKT0fxCobdWaY6mAeznEZsIkreSAO//eTOij2sLHPWmzpaOlUOKiMgeDWyzccFEJNpqssfBQ+0N52jJhXZgmrN6yAuGRlwm/rpT4PAKx5AXEgJHZ1ZYzR9aCebN4AH+40ho314T3ylgpDfAv2LTDwPWf9B53PcVbDORsTv6Sr8CGQO/Zi1o1HsTSaBaf6blQv5Bd6n+IQl2df7trly8U9AD6qFrOqsuw11Pyy2blLkLiI2gnLHHcH/Q2XKw917IgGGGomhGuzzxgD7CqjymOmISM+PqqSm2k/Z7XSwJPthU0b279+8Jno50SMxrZVqNt3TyUW9RkY0YAJZRq2en6DBaJPYd9pnEdskdqwlU4lxWbD3mjrZmLUBBoNByhHUKQWuYWEH+qr3/9rAEDQTN9EjxYFxOYGYhVBGN8yFI+9vLEPR2ePJ7f4lBHcJB+Ir1S+usmDZ6v0bBHph6FrvEwnshPF1dcezCddjwXWLj2uEV8/8R6c1hOY3fWGsaxGdRIf8VbUlBWEVpUuXjMBZBxuzCTzALCfvs2nBjghYFGXrjM2nw5K33chj9SGzKVdDDeSHZU+Za7voECUvA/JkstjM5FAxq16rKqqFY7JSRpGIQ/wqHUAloMWYASi6Qk7UwrD 17nw74+k eATu9cQnmUxiw+7Ocn598DkfUi+wqqgMaXRRiAbxxzp6scum61DkGHMXAiIx+qgDCFkiiAvXyU74aWfC2ZZG1lRmnnwoY7Iw3wUnO1AHkbWCZTxyHXgLZxqZP6IwuPDyDUsBef9k5f8O5lZQFriU3jMV9UvPtO8apKgqacUQQr6iGf+7MO6eH6QVXbzsyW/fDkzKGgynAIzLpVvHU2GKOvE34pL9sQDPSetG7Sc8JDu97GhoyWQ59Nag/AGPu9OMuP5jvZL1jtb9WGZrIAeyRpzk1vw== 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)