From patchwork Thu Jan 9 17:51:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13933069 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 CBDFCE7719A for ; Thu, 9 Jan 2025 17:51:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 637AE6B00B2; Thu, 9 Jan 2025 12:51:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E6DF6B00B3; Thu, 9 Jan 2025 12:51:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 487606B00B4; Thu, 9 Jan 2025 12:51:40 -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 DEE7E6B00B2 for ; Thu, 9 Jan 2025 12:51:39 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 96625434B5 for ; Thu, 9 Jan 2025 17:51:39 +0000 (UTC) X-FDA: 82988655918.17.0A78BCC Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf19.hostedemail.com (Postfix) with ESMTP id EDBC31A001B for ; Thu, 9 Jan 2025 17:51:37 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=muOPzRPW; spf=pass (imf19.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=1736445098; 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:references:dkim-signature; bh=guyOvknUBxI8ZQuJohfoVYQzH8D4jHXIsqQ0X1M0FHc=; b=t+9diQT/03l8V5vxvsroUvYejBJB2Lh2m6PYw5sqM7w/stqB7Gfhwr0qnod+wcHRnJyY2g Qm8AeYRnoKIXZYM0EP/Jwgy+sBYCdTy9+GPJWZdGdxtS904xetW5lOxIfNmdlyXU0+9Nx+ mzCBGLtCiNDjLnGdTUYXAUPYPcp4YGs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=muOPzRPW; spf=pass (imf19.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736445098; a=rsa-sha256; cv=none; b=NfpteYicVoJ8s3P/Oo6+TvHrVRXQ0XzgUEsLoiGDPC6E1UPP42EHl6W2WVTkR89cRXsGCx Gl18oGUTDySIh6L3PwF61TNZxY873cJZw45C8Qk2O5VTpQyJnfAoeOd/P7awT8kv8d9Stc i13dLz+ohZbxURdAGX8q8mVJM3NuurQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id D2879A42160; Thu, 9 Jan 2025 17:49:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA164C4CED2; Thu, 9 Jan 2025 17:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736445097; bh=woo04ygL2lxI0dVd85HArE72awMxk5N2D1/jValkf2I=; h=From:To:Cc:Subject:Date:From; b=muOPzRPW3Nr68uZt8dg57w9O3cgi6VuGjMnUCVtlyLgoA0CjjuyVx4Z7BbgdyzArE bBQoK74AXble0yFErTawdkb1VlzHqvgDyAMC2rGPGS/OAF84pRA9Dz9omHmKkwt+kY s73d/MufXJNoScOTY22nt8JGwPWVlZDdQrXFN6nlXpqCiPOMFxEF2sOIHnOAXS7qfH epzPkzyCdI5mL9/tQsD1WVr7s63JZSNsE3zyYcX//gnBPJYlRw5VRk6SpgSYAZBeir geSdGPlrQthIburKjhhmiS5IIZZ7LSVi/4PyevunzXUFia1UWK1jLIxWC+l938u9Z1 lNvylffMyBOtQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 00/10] mm/damon: extend DAMOS filters for inclusion Date: Thu, 9 Jan 2025 09:51:16 -0800 Message-Id: <20250109175126.57878-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: EDBC31A001B X-Stat-Signature: dsfmgiftirjznncaaxz9xm6hh4dzhmnx X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736445097-722582 X-HE-Meta: U2FsdGVkX1+U5AeT1gjNRxKgMO3LYt5mvR7F/xC1DHzVEQnteNf+EEivbVMj0SV16t9YucmqF1/vUbEPNrOsoMQwLwE6lbk9UCP+1D3cjjGAsDjZY3fg6kejW5pAgwATRMnT3hjbYy0XYMVEPjXyjwaETw3JgSuTUUOnIiUEdmR0w+2m5FgVnLooQ+3M765nuSchTnNgNAF/uVsrlfbnXZKCio3/+0+ij93Ru/vmxVjYVLu9kwEQN+xGAljqTp+pWOSYlb1M/4NUO5TnAAe/q2zYqNxpMRj8LsPtA650LHGP6YXfD5jkMdCezCgnynbeU8EwEnNc2eB5qXux0Y52ksnTu4Jn3kjEB24wQ0i6jcCCGqrdoUm4+5w5EPPmLevj0yeWWLiP9d+jO0RonCdI5TXlx6Omkr8YvksnLsF6A+rAE7qpBibl8vJ7G81Vj5fauwgOMvaU4rJDEnqq1cK8aum8g2X11sTdNsq8oPYxI3WaJQj2PzlBnt/VmJBxsetzSVT4mbh9rTQA7hoLbTETCkzzn9lawfqeplsgdcgcsyeMEMD3F8cvtMmkDWhsWWiAQarQKgelI9BJKCocYez3py/ORECLcvXQ4B/GU/wudQhxdGiLHDzXW+jleTJe5oEU4R0+Gihlf4aNofsNSwZhggc1fZpLTBn/TP4Jv/jfWy/drVqdY+CsaGaWuPnaLFXzNRWo5K3aWfvKibRQ0fYk2Yp/HloggJ8hUhg6D0C3jlQ1npEHerWY63vNxBO0nsno7nJOpwOYv1DKz2KJerK0uTtfeODweHHRLJSP4/xKBYDFtchX67R0HvkLGw6v/50b7FMYOq1lRrmmW49JyvVAAl71/I/8J1miqvBENW+EpBENFaGHRc8AOXL2qtAh3ydpwji6uLvownHTCzUXTW/OuW37DSRncZUR+jQpKK2gyGuqg7AsJ4sOw924HTEOA9b88wxfb7RvSLqebSNtrLJ r85AXOy7 NOITl6S3LSLR8rn4B+pUwfnMmvgdzTXKkwposV635lBeL+9YPtcGhBPKMVaJlNUHuHXVwAQpS/WAf1/ajEVNis/UUJXe2DG/RNtwlqGnvvInnWwqFkNctWSNGRm+YOlg6wF8IPsB9RNLITlgKYhx9ycWANBg4JPvaU8qUuSf2zooVFsXk2VFN06KA8I8VyfoilMLKs3ELYt3xmQsDqdWTkiNESwoFyLWn1DYiodujaJDQWJc= 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 fitlers are exclusive filters. It only excludes memory of given criterias from the DAMOS action targets. This has below limitations. First, the name is not explicitly explaining the behavior. This actually resulted in users' confusions[1]. Secondly, combined uses of multiple filters provide only restriced coverages. For example, building a DAMOS scheme that applies the action to memory that belongs to cgroup A "or" cgroup B is impossible. A workaround would be using two schemes that fitlers out memory that not belong to cgroup A and cgroup B, respectively. It is cumbersome, and difficult to control quota-like per-scheme features in an orchestration. Monitoring of filters-passed memory statistic will also be complicated. Extend DAMOS filters to support not only exclusion (rejecting), but also inclusion (allowing) behavior. For this, add a new damos_filter struct field called 'allow' for DAMON kernel API users. The filter works as an inclusion or exclusion filter when it is set or unset, respectively. For DAMON user-space ABI users, add a DAMON sysfs file of same name under DAMOS filter sysfs directory. To prevent exposing a behavioral change to old users, set rejecting as the default behavior. Note that allow-filters work for only inclusion, not exclusion of memory that not satisfying the criteria. And the default behavior of DAMOS for memory that no filter has involved is that the action can be applied to those memory. Also, filters-passed memory statistics are for any memory that passed through the DAMOS filters check stage. These implies installing allow-filters at the endof the filter list is useless. Refer to the design doc change of this series for more details. [1] https://lore.kernel.org/20240320165619.71478-1-sj@kernel.org Revision History ================ Changes from v1 (https://lore.kernel.org/20250107201739.79484-1-sj@kernel.org) - Correct wrong comments and documents about pass filters without successing block filters - Rename 'pass/block' to 'allow/reject' (to avoid confusion with sz_[ops]_filter_pass) Changes from RFC v2 (https://lore.kernel.org/20241227210819.63776-1-sj@kernel.org) - Wordsmith messages - Wordsmith design documentation about monitoring-purpose usage - Rebase on latest mm-unstable Changes from RFC v1 (https://lore.kernel.org/20241226221445.78433-1-sj@kernel.org) - Fix encoding issue on the last patch SeongJae Park (10): mm/damon: fixup damos_filter kernel-doc mm/damon/core: add damos_filter->allow field mm/damon/core: support damos_filter->allow mm/damon/paddr: support damos_filter->allow mm/damon: add 'allow' argument to damos_new_filter() mm/damon/sysfs-schemes: add a file for setting damos_filter->allow Docs/mm/damon/design: document allow/reject DAMOS filter behaviors Docs/ABI/damon: document DAMOS filter allow sysfs file Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of design doc Docs/admin-guide/mm/damon/usage: document DAMOS filter 'allow' sysfs file .../ABI/testing/sysfs-kernel-mm-damon | 13 +++-- Documentation/admin-guide/mm/damon/usage.rst | 54 ++++++++++--------- Documentation/mm/damon/design.rst | 33 ++++++++++-- include/linux/damon.h | 15 +++--- mm/damon/core.c | 12 +++-- mm/damon/paddr.c | 9 ++-- mm/damon/reclaim.c | 2 +- mm/damon/sysfs-schemes.c | 32 ++++++++++- mm/damon/tests/core-kunit.h | 14 ++--- 9 files changed, 127 insertions(+), 57 deletions(-)