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: 2639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2519955wrr; Mon, 5 Dec 2022 15:09:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4xiZpaS3/4Ho5V4UwrKZKp9kPsJsUjoic2aLJImb+InymP8IZ/jEjPLKjTap3X2XA37RBh X-Received: by 2002:a63:556:0:b0:478:ad47:ca4f with SMTP id 83-20020a630556000000b00478ad47ca4fmr8661956pgf.73.1670281784994; Mon, 05 Dec 2022 15:09:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670281784; cv=none; d=google.com; s=arc-20160816; b=1LEvxHOZ/xldXIVpw2L06aVd6ttEfL1M/doMP4v8KJiSgD8TNQbJsTImlc4hPgAaEo seLvgErsHV3oc2RNJyAXFwCSokLj5VbcoCo3hineDb2xxJVQEKuqTbRHURSFV6sKKhxw LlLtoarH8YC5L2qOrZ1C6qWMD6JNvryNXcej5pfGpPLaoUVUScVLOVqDVtcd1RvtbHqf vV3ZHqeVqGghltZnAsBaNC+sWH1p8NIlJkkLBWImhFJg9NGpXTe7AgCDZ+3FsnqY0Ng5 Me6VOEkTljJZFCThrtCBv3XAaZwdIL3uck1mmWdf+OCmz8XVO0n1Sf2Si26w+tr8hnpU jgYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uTHA4SIQIhmMj8FU6fVNHThq8PKwPoAk2kDFLhcViYo=; b=IIIDpha1sV9Bb8Fm3kl62rzB92MZRjidZycAf8Bs5pDXGG3EdkfujwZCAHavf524lj WDqC0zR+2H50yUBCc0vnfkEMkWAzmHeVhJOh1pWAOX6g6wqMLJu24/PheGF6gGFc/hFs 5pk7I4v6ShEtkWIKtCcC/7XSJwmQtzsCNjVur8O4dIF2UGs+hcWKhemX3oWQId57rfvz LuY/FgsoSJBSn9Dm9rR0WIENgQiFnl5FM/KoxXEbtMMQyCAS9aRSN3s0X5dKhe/7M/gk 2RInMytgmAbB1lwhxkU1WL4NItKnQ0tsdHcVW7C8f1DzJbD9uin+XYGVkEgRrnFsGQtO L8oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aGqyxLYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oj4-20020a17090b4d8400b001fac102fdeesi16262365pjb.95.2022.12.05.15.09.31; Mon, 05 Dec 2022 15:09:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aGqyxLYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232284AbiLEXIu (ORCPT + 99 others); Mon, 5 Dec 2022 18:08:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231722AbiLEXIj (ORCPT ); Mon, 5 Dec 2022 18:08:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F04CE16; Mon, 5 Dec 2022 15:08:38 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 3C771B8111A; Mon, 5 Dec 2022 23:08:37 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751417393143788828?= X-GMAIL-MSGID: =?utf-8?q?1751417393143788828?= 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(-)