From patchwork Thu Jan 9 17:51:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13933072 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 59B42E77197 for ; Thu, 9 Jan 2025 17:51:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 219476B00B6; Thu, 9 Jan 2025 12:51:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A6566B00B7; 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 F13A76B00B8; Thu, 9 Jan 2025 12:51:45 -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 8168A6B00B6 for ; Thu, 9 Jan 2025 12:51:45 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E21FF1C624E for ; Thu, 9 Jan 2025 17:51:44 +0000 (UTC) X-FDA: 82988656128.25.9DDA935 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf21.hostedemail.com (Postfix) with ESMTP id 569BA1C0006 for ; Thu, 9 Jan 2025 17:51:43 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qSj+cWsJ; spf=pass (imf21.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=1736445103; 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=be2ysnXKMlhXMMO02SYrECTiYwVzwQRkNZmINRuQ9vM=; b=yB7p1CKV327n7QIOhoIYQQzrJrwuCgNNIGpijnc1TEl2z08PR7pcpxEGoNQ52rHYF6gCJZ XFMyOqKUh1p5+beW10n/oYCUMaTrXc8hMTF4uUGCSb37qksL3NHMLBPnh43ITCXhOe8VKd JZbGq4yt6jV2k2GdvMbL0pC5IK9/DfM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736445103; a=rsa-sha256; cv=none; b=F38CMj90fL4ROZSZ8JvoCaGYVps4c03Csbg1tF3ZdbYLz9hpxzLeT/OeeRul4tjZxbdvY7 A8Dox8pNfyINb1WHyxtvn6NNLhuNbasdyIZKvAoXpZDy9B0B8ExHCULeZM0XvtGHRqyFZV N5dHhbzxFwvQEjuE9fq3SEKThcTXaLY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qSj+cWsJ; spf=pass (imf21.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 33402A42534; Thu, 9 Jan 2025 17:49:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54C31C4CEEA; Thu, 9 Jan 2025 17:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736445102; bh=VTPumCjyOZzpcnH5UkJNLIwC7RykeAkPieOWziLnSjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qSj+cWsJLxLYLKIerVnKmUOKM4kdgjseSjeI8f9V7mRbskhrL5TAk4RFZRQXcZfiQ LN7g8yMoqdqifi4p5cyyYwifg3EcoiwCQ7ioHusB1wN9VcsNGfEZjR+1VDJyz5fW3W Qa5MY/JaiSPH6D6RLU5XRpYMdcFSj1V+v6AdVJzMty5/7avSWb+daBp14+J9eW7AH7 PD7YAiQyJjWADMlon0yZqvdeclzCnkeqADaRVeBg4/kI6jjz1Ukkt3eky9CdWfaeN3 RIEcmXy4BTz3la+Yp4OpJfMxwusNmakZsMIQk/jOqsLW7w+p/WPXS6ynYT4qjmWMNa iu+qLWHg6eleQ== 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 05/10] mm/damon: add 'allow' argument to damos_new_filter() Date: Thu, 9 Jan 2025 09:51:21 -0800 Message-Id: <20250109175126.57878-6-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-Server: rspam10 X-Rspamd-Queue-Id: 569BA1C0006 X-Stat-Signature: rjefhd8udcgdazeajuahrwhf56hg9ekp X-Rspam-User: X-HE-Tag: 1736445103-975141 X-HE-Meta: U2FsdGVkX1+31VnQkhaX+glj0VrtlSqCg9sxg0VAbZ3PuC1iO9ushLsh4XgLy2o5bKFVUqm18Xy/KKIFB/8YDTbejXqqqpW6Y4b5PC1pZRoVyorNDHUoWwjm/lXsIWgZ6RCRDuI64okA+GEK2xZFKsxonwxTqpG1Y7PGxhdJnHQUdqzl+kSC4Akamb3c8RmD2KB6xSXR0cTqP8QRy34Wk39TJlSNmlUTB/wGeYVV0+3EaOwGL8LapBhfo7+UJm6qhY1dpb4sOHd14jOhy+qTBc4cPlX5X5eu98aI0J5zcQ4d7LBiVBDdPkavtJPSSEk4zFPGa7FMEDsjAzCaGkI8WF+g4rZ9LFQ3yWgaYBekwBgT/HWhdS99Tn4sybrcfhEZRAiK10zP0jizhWLdxyNofA+lJBTgJ/zgnhskJsdAVhZCY1Au6KQ4S3CNOjuQtlVvc6ycYxZQAnjslvfmkTaAddvVRKINlMEYV1/8BNkSUlROMTm7gqaP+ayCrJHiLbo58Cpbre/0xSS9Ng58kzuuUup07mPIBQd+2yRc7m3BqTM7XSXnG9SLeQk5axiA79zwK1oMq7n8xkcHWXB6CV4F0hUY4+mCe3lTe0e7RzfiMKIPuyBj9uVLxjmGZKM4gYMf6koVUZqTz6nDAiSLEZumkBYv2aPqXlJNgHHvXNDsRqtA77QQPTLsGBb8bCRdEvwN1MLeEXxwJSpXJ9Jzq1CWDYRW0lULUry6mHcf9qaki+VNoRrqdcCatBCylInhaRXyMOFpBRU0OFaeL5SchI9a4xLJwzR7SXF+p3fDw0hkd10yoVeyPudG5yGsWkqh2jzZnfLL2PMfozDEkU6OgzdWEYF0GweDySIQzTROrxwergAliOExanbFZhKsuIB+pgwWmC1pi1VYN19oHY2LmYrJdmTI1JfHb97xiejK89sgkET7YP6oBLkIzgmOxjUNh9u+94HDTViSRoje2IJxURV EMq3RRDR yIqfUH84+e3zu4p4cKwX71CcOr6cbF5TN5MBzbjA+qY8fz3Uj4xQn/BPmGQ3nXvJgxuW+zKfYR51+hQJLmnfF+TT9JZlFac5//Sqsbqja3HwW27mZ9qa4DwEegcp6QVdGpzmaR5fAQ1+ESXW1fEoqIqijX/csAEODYOuCNpI7LPj8duUWW2kZtoHR9dQ2axHpffA5qu91QWl2JjLDHjGJSkwdS8UoKTjcy+sSLI3bXA1cmWjIgxBCdqdrX6f7NtVL4shvH0DvT+jFeaNSQcQAwaptqA== 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: DAMON API users should set damos_filter->allow manually to use a DAMOS allow-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 8a2d104df5a3..0834d7ffcb84 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 allow); 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 76707b0635d6..55a435bdd89d 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 allow) { 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->allow = false; + filter->allow = allow; 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->allow); 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 817acfd4f8a2..6b4397de4199 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};