From patchwork Tue Jan 7 20:17:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13929581 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 53FA9E77197 for ; Tue, 7 Jan 2025 20:18:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 400876B009B; Tue, 7 Jan 2025 15:18:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AD556B009C; 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 228236B009D; Tue, 7 Jan 2025 15:18:17 -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 E51846B009B for ; Tue, 7 Jan 2025 15:18:16 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 67FAAB0257 for ; Tue, 7 Jan 2025 20:18:16 +0000 (UTC) X-FDA: 82981767792.26.3DF0E06 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 9C73380002 for ; Tue, 7 Jan 2025 20:18:14 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OxeN3wM1; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736281094; a=rsa-sha256; cv=none; b=wJ3ukN6k3G3H3rnsfHy6zSISvCfk5nfpb4BnQZ2t5vsVVFFSRCyGOetds5VbEiNHFEC1JJ eoUV/V3yK1joHY77dWn6M+5XhaYSFCSXT8pT7gqcuOqIwfHwRYz8FGVp7gpm4USXfOyv+g M6fPUu1d9RL4P0NaW9h5R8PEPq7K4NU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OxeN3wM1; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1736281094; 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=iManCdE4JXv5RBIj7XwkgzTRGofzmdht+/ZNcrSHRI0=; b=q4700Q55Vc3ifCuvgSn2PtEc/9A7pM4kmt6RyQ016mtpAtOxiiUERMl1gB27xL8871+iWk 5Uuz0L5HGUboOaOSsiysjk4wOfi7/ZKHdCSl59e5FK2YRn1C/cxuWPY/MEadgw3wz8OgLN TfC7FTrLGhLdluNi0G/Se8WSZnZts/0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CD1655C5EAD; Tue, 7 Jan 2025 20:17:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E427C4CEDE; Tue, 7 Jan 2025 20:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281093; bh=SeGgDvPfXuXgeFvtGluC78K25dToIj5MV+FyPl+BzUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxeN3wM1Vi1ShZ4pD2Rd4hdVw6Q7pn9tsFM/OnmFfbLKq4vdhzB8yi0XG9CUdls77 nDdeUxE1UjCDw9/z8lYYUtlYUSnh/cIhMGztGIxuZf+QPxJS9prq0NBjr+ym28T3kU gV9SOvM/KWk/rtRb0zI77NdRZJ7ldMThEWIbUhpEkMVPBtJGJ/N++5WuWzFsiR3rx+ 8/vbaa97U8+Vu9KJHF2kzFc9y/T5co7hS9ezK5u9UnTK/Wk9Kt0zr5/hByOAOb94+z GcnUN7id7QXHugoMQ+PmBGYtA/JF/vt+PzYaHwDc9qNXihcnUwjLQsj25XkllfjBGh p46hnywfBlBMw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/10] mm/damon: add pass argument to damos_new_filter() Date: Tue, 7 Jan 2025 12:17:34 -0800 Message-Id: <20250107201739.79484-6-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9C73380002 X-Stat-Signature: ic6g5uauqk3iuw7fwegyjh3bwdh8nq5u X-HE-Tag: 1736281094-719160 X-HE-Meta: U2FsdGVkX19eSeGt3sAMhKn2v79sIjfQe2qugFl/zisgUmpAL2nbdkiI46xiwDFx3iGsd0UPdow/n5HGWQXsnHJaNneuQPDQPmaxNmclflBM/cm5OISAExRlT/MBvMzXWZ3kHp1hgUrDGhaK6rPWAOOOU28gNM1xI2lndWk5OtV7tP2TNpoGLp515RKjuqepPmeXt36cRLtpN2bhmiHqI3PdKxZg+ACIOhYOTUGWUc60sRZc0VSlNrNe/weihmTfqtJ3rdRPoBn9MsXQ2mO6mQkmrquJGAJyIgoFKWwh9xjXXSmJzTpaVzzNd1fDODC5V+4aKZbvrXjvwDtZI5vhTjnSHw/RM4KxTMxTgpJX10B8o3uTrg1Tys3WxLGest/Caz4qfan47IJ9e1PIo/OWJbNeqxMyCdy6LNLgGq92rYhK4QQXnbssr6t9edY1KR753ZLjg9BHqAj3IL2pYKEs+qmCO0ZN3ZoihCpGHY8Km8ojT8xAefb9D8NYQgMvFamyprZTk4s3Gd6zZIDDkQ5vQH8AT/p8ekqepviA/witdxLg6foAl0qDRiK24NitZpN2mM/FMAkWWGMa7gwn6UDzBxxqprhC7XkMlO2ugsMJyfqZ19RwMzECtqeOnOFebAlavpmbaGsonOx8D/XfcHMU1EyvpoxbijQRABRfe+M/pSZnRjuxBdGv/oTFmDJxm0uRmBddRWHQbZN3FvJ7hFkYFKZPpOEj+8umsiAlazDAHT9JwpE61VibOgAtyStokbpWd5fRlxSA3G07wukQL71GDvXGD6ib4NuGZ/3djqv25NSBG/FjtRQaEivmJUz2mY3nWle84YmW/6JLZZqlOqQfDNXP0Zx/Pz5cUaHZVDFTGt8BZ5eDo7uabi68zIwIjXwOnSWBbF2txojRRSpQJaXXILVYtL4jN/e4e5N1/3BEegaaGDXNhWFbCKcqIkGe4PNcbrlvganOP/U27KnkE7z fbtdeOjU 1WCNaSnroKg0hVhQIpqSzyTDrM3lnBYP41YpQGsd6dJNOFhQJ7uzWrO6fd9EohWCd3C8Uc4vDCL2dk4Uc/cS98eJ5lQCOJxTH0krfSktKlkodPgfuc05AfJYxJyj2oerPwu1uI+BhhEL0bAhyrD88TU8zLJ6LDSMw1WwW5bd4UtiKmbE3nORXFs2lIUR9l9QAIUAJ721CUjo0iPPiVFU4BmP5Mg+NifEaFqgoXQH2eRN5D2vnzopUctpvcS/vdv+KtaHYa+blndvLzU9Ns5HvVMsJRw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000052, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: DAMON API users should set damos_filter->pass manually to use a DAMOS pass filter, since damos_new_filter() unsets the field always. It is cumbersome and easy to mistake. Add an arugment for setting the field to damos_new_filter(). Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 +- mm/damon/core.c | 7 ++++--- mm/damon/paddr.c | 3 ++- mm/damon/reclaim.c | 2 +- mm/damon/sysfs-schemes.c | 2 +- mm/damon/tests/core-kunit.h | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index baeb884ed156..27593dadbd76 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -801,7 +801,7 @@ void damon_update_region_access_rate(struct damon_region *r, bool accessed, struct damon_attrs *attrs); struct damos_filter *damos_new_filter(enum damos_filter_type type, - bool matching); + bool matching, bool pass); void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); diff --git a/mm/damon/core.c b/mm/damon/core.c index 71db2c754e6d..13f12d82de5f 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -266,7 +266,7 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, } struct damos_filter *damos_new_filter(enum damos_filter_type type, - bool matching) + bool matching, bool pass) { struct damos_filter *filter; @@ -275,7 +275,7 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type, return NULL; filter->type = type; filter->matching = matching; - filter->pass = false; + filter->pass = pass; INIT_LIST_HEAD(&filter->list); return filter; } @@ -806,7 +806,8 @@ static int damos_commit_filters(struct damos *dst, struct damos *src) continue; new_filter = damos_new_filter( - src_filter->type, src_filter->matching); + src_filter->type, src_filter->matching, + src_filter->pass); if (!new_filter) return -ENOMEM; damos_commit_filter_arg(new_filter, src_filter); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 71cb02128b46..cd89500efc22 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -259,7 +259,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s, } } if (install_young_filter) { - filter = damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, true); + filter = damos_new_filter( + DAMOS_FILTER_TYPE_YOUNG, true, false); if (!filter) return 0; damos_add_filter(s, filter); diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 9e0077a9404e..a675150965e0 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -221,7 +221,7 @@ static int damon_reclaim_apply_parameters(void) } if (skip_anon) { - filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); + filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, false); if (!filter) goto out; damos_add_filter(scheme, filter); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index deeaf23c1fcf..9a883e8aea1c 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1901,7 +1901,7 @@ 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); + sysfs_filter->matching, false); int err; if (!filter) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 8f58d3424c21..532c6a6f21f9 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -411,7 +411,7 @@ static void damos_test_new_filter(struct kunit *test) { struct damos_filter *filter; - filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); + filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, false); KUNIT_EXPECT_EQ(test, filter->type, DAMOS_FILTER_TYPE_ANON); KUNIT_EXPECT_EQ(test, filter->matching, true); KUNIT_EXPECT_PTR_EQ(test, filter->list.prev, &filter->list); @@ -425,7 +425,7 @@ static void damos_test_filter_out(struct kunit *test) struct damon_region *r, *r2; struct damos_filter *f; - f = damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true); + f = damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true, false); f->addr_range = (struct damon_addr_range){ .start = DAMON_MIN_REGION * 2, .end = DAMON_MIN_REGION * 6};