From patchwork Thu Jan 9 17:51:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13933071 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 DC694E77199 for ; Thu, 9 Jan 2025 17:51:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 859EC6B009E; Thu, 9 Jan 2025 12:51:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 808DF6B00B3; Thu, 9 Jan 2025 12:51:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6835C6B00B4; Thu, 9 Jan 2025 12:51:42 -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 0B2216B009E for ; Thu, 9 Jan 2025 12:51:42 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BADE01202FE for ; Thu, 9 Jan 2025 17:51:41 +0000 (UTC) X-FDA: 82988656002.15.0008F06 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 2722B1C0004 for ; Thu, 9 Jan 2025 17:51:39 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XgDCg4aO; spf=pass (imf21.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=1736445100; 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=DBymLb+DgrbeQ3sQckQBM7U131cEU/hAsc/00D6k+2c=; b=wGyOVH9gmM1rMDNWSlr2QKPJWtJRXPnt9lE+mUX1JAqmqqAWiv1dz5C5UOJGx9C3RCPTAo jJWM8YqQR7TU/7fRTJ3lUgD+8AZk8Mq8aGVa5Az34A1EHJKs9XgMUYRRxilsUxsmxe1wkb ZZAyPjjvFgtdT7sMiORKgcC0DzvX+2A= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XgDCg4aO; spf=pass (imf21.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=1736445100; a=rsa-sha256; cv=none; b=unjA02NPb2rGKqSaVpgAsHJ4G5v9Wqw0U+4WTrOestPsKGi2843pXVRFhHTf3flRq1H9dP WxpCpGGfnuStaF50cHGzhQcK2mGM7o+3eBSB6DMZy7KFJ0C6QZRVLSO1ZlllkEDa5X7Rpa BfbWO1x/Oovd0+XXYSbOGhzMerDdyoo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7C0215C5CB9; Thu, 9 Jan 2025 17:50:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CACFC4CEDF; Thu, 9 Jan 2025 17:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736445099; bh=b5/TGNrGU2BJ6e8ROpk/K/qKcaZatsIxBg3oBg+1uiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XgDCg4aOnSyKMLbHEiFCUeQulqorcmktJn7pvdk+KyGJPAAKYP3hw5WnF080ziHBY Cux41jLyFii6G1U+3tgU+voGlXx4KWqRYLpSEYExW+CVkQ5SSj6y4Gtr1m7oetsPxb AVNfrzOLWnPEEr9//e9rt1WVoUECGgS1L8P+J/xt47QJXSWgPcrvFeJI8DfJfH2hmR 6OlI1rFGwVWfYml11NanvbR6xZPOyAN/n2KEUDZ2YDkVbokqLZ/Fq/jNdbxNXtbfja dawTjerZ+LQVrDupRPjQRich0DOoWSQpmaea/jAlBS+ZKRUfGvgAX1JVimbYIXerqU I1Ol6vWUob6Fw== 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 02/10] mm/damon/core: add damos_filter->allow field Date: Thu, 9 Jan 2025 09:51:18 -0800 Message-Id: <20250109175126.57878-3-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: rspam05 X-Stat-Signature: akxbdke4zxtpx4wgaaw9i4zbxn3nobgu X-Rspamd-Queue-Id: 2722B1C0004 X-Rspam-User: X-HE-Tag: 1736445099-224148 X-HE-Meta: U2FsdGVkX19vA/0Qz7jqgWRiPIF+0ZK3ZUhEQmCv4TX2BrwTJENGuGEQ18pOk8KYCZGgD9S4yDiYV5kO5iFSUHM6Qzdpj8j5xvsHDv2jz8lHGgUb1i2hcm2s9NXS0QdA1BI6f4nZ4/9fEa2YYKvIAFiM1balzbJFmX9wcCX5xanXatJ0uMsiSQ4w3eRL5pxyXUpDv10ptmB5FcF8BEt1l32VAogyqr3t7nITJqy1imHnjzhqixfui6NcbLS14wG1NJ8ylFZZL5LBjnYZgeQVJSLfY2q1JJx2PHKnGqVr8Nu0hym99EIKK+S1YuMANw9HZdaZAt0ayaejIbyhzBH+GYJMgGJNdY463xaskqNoVPWeyNuanJCVez+4X5mvGN1RckIBVHZt/ZVnXp3ujdZfz4A/m1PVGLlAH88J2wXi7l7MH59zKFWmPEypKmOp6FXUkJA+1oBEib+MCHjoartELIBmHw293R+kSeyEWDRWthmcSfOSyblUg5nQtspjI1fvCLmGdOLiureAfvouVUz2m/9JaCWPDg24A4WPZkyVgHITkZ4LEPqlHpEOlKxj8VNFFjIMNCV8/5QEKzv/NodKVcbVa3GRbC5LG8bzioIOEkLBpsWMO2bK6UVO5niPnYwqI2GRWjBedsMD5/4LZckOgMNRI+3Qp4R+Y5QW+/Tmkwvv/hyAV0bADlXd4ysa9qag0zE53bNz1Hqqeqzth0A3xMCLYVbwhCs7237wdcN1McBPw6sc8592MDz+K03QWN3LKi2P2f1yEn0MaErfGb1tuil4QqDLJZujDf+VzRc15cAOEiiI3tvQXlyagHQNXrDxoaPU/Ir3n9fxFnqZAUcdH1+1e31cYGkWSmF8NmpUcKjT7nlglWCud+OYeL2b0vAmTPqxJW8e1ESzuMpnsyO9f3/8zInSXYsqnfh5KZKMWkAxRv1weAdaXH04HbOpFgVjFLymIz+fdf0ZlazkfL/ vpj4E44C WIbE/DC0Sf6FN/MLUaUc7NckO+63IJfyqyHJLCCgej/kfYxr3LJYgMAU5vMqN0pjLqeeNwpwTJlbTvy8UnBT0AZaEeB7GWrwr55aUG8CocT7Yn2bBcYXdC4txwfGowSttCtkyR0FwTNpG6hp1gw4+lAL9m9nWdbDXG/GULzs3CAvDMfvb12RS2tLjOKgLf3kzsjAi+UViS6v9xuPkrYeG+1yNNEgNZYJ2umVs7QNSknYdWczm9Zu3hSA8jeNfP1y3c4X7byHS+LHgjwpCSOunhPQqZg== 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: DAMOS filters work as only exclusive (reject) filters. This makes it easy to be confused, and restrictive at combining multiple filters for covering various types of memory. Add a field named 'allow' to damos_filter. The field will be used to indicate whether the filter should work for inclusion or exclusion. To keep the old behavior, set it as 'false' (work as exclusive filter) by default, from damos_new_filter(). Following two commits will make the core and operations set layers, which handles damos_filter objects, respect the field, respectively. Signed-off-by: SeongJae Park --- include/linux/damon.h | 4 +++- mm/damon/core.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 72afba74ac6d..8a2d104df5a3 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -348,7 +348,8 @@ enum damos_filter_type { /** * struct damos_filter - DAMOS action target memory filter. * @type: Type of the target memory. - * @matching: If the @type-matching memory should be filtered out. + * @matching: Whether this is for @type-matching memory. + * @allow: Whether to include or exclude the @matching memory. * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. * @addr_range: Address range if @type is DAMOS_FILTER_TYPE_ADDR. * @target_idx: Index of the &struct damon_target of @@ -365,6 +366,7 @@ enum damos_filter_type { struct damos_filter { enum damos_filter_type type; bool matching; + bool allow; union { unsigned short memcg_id; struct damon_addr_range addr_range; diff --git a/mm/damon/core.c b/mm/damon/core.c index 52e50f183ffe..bdde532ebbc8 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -275,6 +275,7 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type, return NULL; filter->type = type; filter->matching = matching; + filter->allow = false; INIT_LIST_HEAD(&filter->list); return filter; }