From patchwork Fri Dec 27 21:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13922134 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 24706E7718B for ; Fri, 27 Dec 2024 21:08:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DDFE6B007B; Fri, 27 Dec 2024 16:08:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 68DE86B0082; Fri, 27 Dec 2024 16:08:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57CC16B0083; Fri, 27 Dec 2024 16:08:30 -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 34F6C6B007B for ; Fri, 27 Dec 2024 16:08:30 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8B88F1A156F for ; Fri, 27 Dec 2024 21:08:29 +0000 (UTC) X-FDA: 82941975816.25.24F76B2 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf17.hostedemail.com (Postfix) with ESMTP id 0B7EF4000F for ; Fri, 27 Dec 2024 21:07:54 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tStbiETE; spf=pass (imf17.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=1735333663; 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=Ly3zeabHPCmb7x9KiiUJWcSX4sxwsLFQrKax3t9KO8A=; b=7LrZUgb68cVRBhQ698sJNSTyJriVWqF90KwGsFKwnDllsZy83x6knOkToaD5aFD5tBFTXB 2pQZvNRndlDL0lhWEhe99P14QHcr6s6/WnIn0GYNNOeQtDPZl3hJcULVR3kxLWWwopwsHP Wo1+aFU8QLabxu00WE1mD/+DnbKlbJk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tStbiETE; spf=pass (imf17.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=1735333663; a=rsa-sha256; cv=none; b=mRCQzP4G6KciIKAtvAsVH4NUudcLmrcqmPBbRpZjJoxMdBQbyZdh3gFFNbdGIm5yO9sC6V Yh5PEwaS/WfeuxfdHrXvbEymDFhxqt/Ep/tmuOZgbdXbUoU4JnrHvIPEKJ3cSHgz5PyPPo fg8ZwRX0iPNyrkiTHxDhTLFnBigoA1k= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 847C5A41A28; Fri, 27 Dec 2024 21:06:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D032AC4CED0; Fri, 27 Dec 2024 21:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333707; bh=Vt/oT9zECa50K2zX74ziPOY9ZJ8DMDBUW7KU9gy0O8s=; h=From:To:Cc:Subject:Date:From; b=tStbiETEAit92CAj1kCceZ3RybSVAIiIjsVZOHPi5FKRfSXA62h0dgJKz4NiefJmj AP5nJ8ZVt7Vk8eJRHuq2o8cNtfteVH8OU+goK6oNo2jY9S+HtZopAZl13qw4bZIqOF dZv//CAR5qqv2U0wlD2ymFAufAOI/TffUArS8z2gYmgslmPJpA+80CqsDz4ZPWLjby Lo+Fn1tQezEqIkyNoO4uoPob87hM6SF3PXlbKwEQHQexzumk9JmAuqsb6xAuxwSgHt qxXsCoCUe6cfAur7GWM0DDZK1XndY92lLssTN/k1aH3B8aWQmZ1B1WerfaaDIytl8D hoGeanWHvNR2Q== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 00/10] mm/damon: extend DAMOS filters for inclusion of target memory Date: Fri, 27 Dec 2024 13:08:09 -0800 Message-Id: <20241227210819.63776-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0B7EF4000F X-Rspam-User: X-Stat-Signature: rg1fpy4dexmfyebzemk3dgzzem5ozqd8 X-HE-Tag: 1735333674-554989 X-HE-Meta: U2FsdGVkX18dJf/ZHB5Ppb4EuD1VRQFKLzsxcsFnlhfIYEyIgJswBcfoYwh6nS9yuVY3787ylnR28YjDS/2w+iKp3m32aJFAFt8W8GkVxO7nNsOB822RCRan7rYSt96GSq5MOHNcVF6KFWEARt0N0BzUkRgbRq8JcAJ7STvuhFUQ7dgTXmalUrLb7vmooVRFbgCqtRVzZDyAr3VTO5Tcd+D4Zo+E4EeZ4J9NV3cs7RCpRFk6ge+LA6tWdy0IOZCr2gV990CqJiv+OSbNGQ1MiT/ino1zp9Qtw8lhDAaWsKHJUtrtRNhgwJ9IeozlDzrDAEqf/pdWUiIrzuTSslfoDXf70Ple0RLeY0c+h3A/37XuOWA3DEn9yATGETh6RB2loDl54kCScIHm7Rdahc3k0bPbPWwZ4NfKygJMb4L50x8a5zjyx/N2jxq8DZizV3bzRDDVDoIgqeWXmj/KtAv2gLnZ/N+p+fFidZxpw59mKcF6YvNxAjjILBg9Zpc1rfDIswJxVRXtIc4GKBAZt5jxq9QEiwaHC270zXLFIevWw98uQ5TwzFgCVpHeSXPn1eTrbpDZ56exC5ihh9wfdt/wptEPtjXa3fKWaNB2spMCg2QBqFqLldJUP18ZaXmwwbaDMykKVLZtzsLx1M+qKoefUdTIRodwAxRidT/+x2tsK1XOlaIJaRPFf1nERWL56+G7U3rgfExE+WNlTEn+q/9Owsvep/2QCQH4N8hDlG2Soa8Uxi3PpIEzDPVRu7pdqgr9D6eUDLueeEZvG86/nXp9BusHd2nwDtzK2HzAOTJlySJ4GEVnVoDEAyPAnasWZVqthNU+RbeQ3HuYDe4LX3+E+y99DMj8QJI8/JWm04B4CcA5yeFI0R4jrnv6VM41wrSS8HpIc9EZrfUWdTf+JaeAsbzG54SxGbWhUPRLDaIJs3KPPYRN+Ro2Vuq+pOjDwYFmd2jkL/mVqtWExAyWKyZ 2bz1ugxR VBO+bwcyqbOrfBvvrnVuRzDKHqb3pInL2SF7a9YkgyMFEBES0Xr1vmjwDizPq0v+QfQRk+AGHWeX7p+mgOpwJKPC9roaTZWVwbqn57NfWM0X3AVt1jPjf8jkMbiyigg0HE9m83tJn9qR9FpSbVXaLD4grpvVoaK0NMuzBNnMFaoo4UHdIwLYlg/l1Rcke3ursZhcHqGPo4obasDe0E+eTIfYk0IfVIML0P5Mhxijy2qdzyXU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 specific types from the DAMOS action targets. This has below problems. First, the name is not explicitly explaining the behavior. This actually resulted in confusions[1] and works to improve the siaution[2], including wordsmithing documentations and adding features to DAMON user-space tool, damo. Secondly, the functionality is restrictive. This is especially problematic when multiple filters need to be used. For example, building a DAMOS scheme that applies the action to memory that belongs to cgroup A "or" cgroup B is impossible. A workaroudn is using two schemes, each filtering out memory that not belong to cgroup A and cgroup B, respectively. It is cumbersome, and makes control of quota-like additional factors difficult. Extend DAMOS filters to support not only excluding (blocking), but also including (pass-through) behavior. For the extension, add a new damos_filter struct field called 'pass' for DAMON kernel API users. Using the API, add a DAMON sysfs file of same name under DAMOS filter sysfs directory, for DAMON user-space ABI users. To prevent breaking old users with a behavioral change, set the blocking as the default behavior. Note that DAMOS' default behavior without DAMOS filters is applying the action to any memory. And DAMOS filters work for only memory that satisfies 'type' and 'matching'. Hence installing pass filter without any block filter after them makes no filter-behavioral change. [1] https://lore.kernel.org/20240320165619.71478-1-sj@kernel.org [2] https://git.kernel.org/sj/damo/c/b6a722c85ff91e5abe9dd47135e300df243da056 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->pass field mm/damon/core: support damos_filter->pass mm/damon/paddr: support damos_filter->pass mm/damon: add pass argument to damos_new_filter() mm/damon/sysfs-schemes: add a file for setting damos_filter->pass Docs/mm/damon/design: document pass/block filters behaviors Docs/ABI/damon: document DAMOS filter pass 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 'pass' sysfs file .../ABI/testing/sysfs-kernel-mm-damon | 14 +++-- Documentation/admin-guide/mm/damon/usage.rst | 55 ++++++++++--------- Documentation/mm/damon/design.rst | 29 ++++++++-- 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, 125 insertions(+), 57 deletions(-)