From patchwork Mon Dec 5 23:08:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13065159 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 CE8DBC4708E for ; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35CD08E0002; Mon, 5 Dec 2022 18:08:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E5E28E0001; Mon, 5 Dec 2022 18:08:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1602D8E0002; Mon, 5 Dec 2022 18:08:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 017748E0001 for ; Mon, 5 Dec 2022 18:08:37 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A00B840BFE for ; Mon, 5 Dec 2022 23:08:37 +0000 (UTC) X-FDA: 80209793874.02.74C59B6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 32B41160017 for ; Mon, 5 Dec 2022 23:08:37 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aGqyxLYt; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670281717; 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=uTHA4SIQIhmMj8FU6fVNHThq8PKwPoAk2kDFLhcViYo=; b=EeIszjYvn5BQUrFgmt5HYIcf7DAe6I3dKsguuJQ/S8jpVoVPUrpT6IcE4SR6DJVsev69NF KEsuxpbrm4+1KNQwXodJ/eAnuaHcBudyBg134emrqvHhBwQMTeaVtoxHSayPe1nQnBBsi6 K6/A/mZoTgD2Bu6L2Or1V6lfJYiASnQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aGqyxLYt; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670281717; a=rsa-sha256; cv=none; b=K5S6amg1bau2YqIW+JcVw5L1GkeHH0V68pM40pYobMLO9AyK/Y64wSFgyU4+2cRcVwJ2Xt I7G7vfXJFnePGB9e0NEM0KQBDfylcFWLsfzoTA+4U1GGAnLpcGhNFm2VFN0VPXmVlEjL5x JEpfavX0UBibwBZbPDoVhi5/RFnWdWc= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 35593614BF; Mon, 5 Dec 2022 23:08:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52C3FC433C1; Mon, 5 Dec 2022 23:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281716; bh=uCWJLFwuqt/uYoggtv+VNAi//FJy9wJmlgEE2fqnn4o=; h=From:To:Cc:Subject:Date:From; b=aGqyxLYt1i6BDlsSZ6G18PysS9WnfLLylfgdhFqtdKBOAm3qRisSadwy3k1YYAdeO ZUC71L0yBEisbpAmbSWq+qwPE9KRhHuzSLyB3VdBIK602dey9h2NB8gyteHWIoxY4Y VnwEiHyHqOV54fiw1mA8qRyZe5XgC8bMShy/e0GfReb6KYXSHKI2CoO3Y1vU7lviHo iJAEIvRLYAK2zzQI+PeBI6CDLrQx2hNgmajXloGgeP0HS/hBc0YyIQMAVSZshAC+qN JoX5NvYhkghvFp9zJfG96l0J5P8FT78CxOOVBoZkx+bcWKqbMYnB5EmrTLh36FDqxt NG9qqJcSfcEsQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 00/11] implement DAMOS filtering for anon pages and Date: Mon, 5 Dec 2022 23:08:19 +0000 Message-Id: <20221205230830.144349-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Stat-Signature: s3t4h7g5wbpey8971t18sm931wm6ea6i X-Rspam-User: X-Spamd-Result: default: False [1.82 / 9.00]; BAYES_HAM(-3.78)[94.38%]; R_MISSING_CHARSET(2.50)[]; IRL_BL_25(2.00)[52.25.139.140:received]; MID_CONTAINS_FROM(1.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; BAD_REP_POLICIES(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; DMARC_POLICY_ALLOW(0.00)[kernel.org,none]; RCPT_COUNT_SEVEN(0.00)[9]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[kernel.org:+]; RCVD_COUNT_THREE(0.00)[3]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20201202]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(0.00)[+a:dfw.source.kernel.org]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 32B41160017 X-Rspamd-Server: rspam06 X-HE-Tag: 1670281717-700470 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: Changes from RFC v2 (https://lore.kernel.org/damon/20221130200937.118005-1-sj@kernel.org/) - Rebased on latest mm-unstable ---- DAMOS let users do system operations in a data access pattern oriented way. The data access pattern, which is extracted by DAMON, is somewhat accurate more than what user space could know in many cases. However, in some situation, users could know something more than the kernel about the pattern or some special requirements for some types of memory or processes. For example, some users would have slow swap devices and knows latency-ciritical processes and therefore want to use DAMON-based proactive reclamation (DAMON_RECLAIM) for only non-anonymous pages of non-latency-critical processes. For such restriction, users could exclude the memory regions from the initial monitoring regions and use non-dynamic monitoring regions update monitoring operations set including fvaddr and paddr. They could also adjust the DAMOS target access pattern. For dynamically changing memory layout and access pattern, those would be not enough. To help the case, add an interface, namely DAMOS filters, which can be used to avoid the DAMOS actions be applied to specific types of memory, to DAMON kernel API (damon.h). At the moment, it supports filtering anonymous pages and/or specific memory cgroups in or out for each DAMOS scheme. This patchset adds the support for all DAMOS actions that 'paddr' monitoring operations set supports ('pageout', 'lru_prio', and 'lru_deprio'), and the functionality is exposed via DAMON kernel API (damon.h) the DAMON sysfs interface (/sys/kernel/mm/damon/admins/), and DAMON_RECLAIM module parameters. Patches Sequence ---------------- First patch implements DAMOS filter interface to DAMON kernel API. Second patch makes the physical address space monitoring operations set to support the filters from all supporting DAMOS actions. Third patch adds anonymous pages filter support to DAMON_RECLAIM, and the fourth patch documents the DAMON_RECLAIM's new feature. Fifth to seventh patches implement DAMON sysfs files for support of the filters, and eighth patch connects the file to use DAMOS filters feature. Ninth patch adds simple self test cases for DAMOS filters of the sysfs interface. Finally, following two patches (tenth and eleventh) document the new features and interfaces. Patchset History ---------------- Changes from RFC v2 (https://lore.kernel.org/damon/20221130200937.118005-1-sj@kernel.org/) - Rebased on latest mm-unstable Changes from RFC v1 (https://lore.kernel.org/damon/20221124212114.136863-1-sj@kernel.org/) - sysfs: Clean up filters directory from scheme directory cleanup path - sysfs: Link newly created filter to the scheme - sysfs: Ignore removed memcg when checking path - sysfs: Guard 'struct mem_cgroup' access with CONFIG_MEMCG (kernel test robot) SeongJae Park (11): mm/damon/core: implement damos filter mm/damon/paddr: support DAMOS filters mm/damon/reclaim: add a parameter called skip_anon for avoiding anonymous pages reclamation Docs/admin-guide/damon/reclaim: document 'skip_anon' parameter mm/damon/sysfs-schemes: implement filters directory mm/damon/sysfs-schemes: implement filter directory mm/damon/sysfs-schemes: connect filter directory and filters directory mm/damon/sysfs-schemes: implement scheme filters selftests/damon/sysfs: test filters directory Docs/admin-guide/mm/damon/usage: document DAMOS filters of sysfs Docs/ABI/damon: document scheme filters files .../ABI/testing/sysfs-kernel-mm-damon | 29 ++ .../admin-guide/mm/damon/reclaim.rst | 9 + Documentation/admin-guide/mm/damon/usage.rst | 48 ++- include/linux/damon.h | 51 +++ mm/damon/core.c | 39 ++ mm/damon/paddr.c | 71 +++- mm/damon/reclaim.c | 19 + mm/damon/sysfs-schemes.c | 370 +++++++++++++++++- tools/testing/selftests/damon/sysfs.sh | 29 ++ 9 files changed, 652 insertions(+), 13 deletions(-)