Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp547679pxb; Tue, 19 Oct 2021 08:10:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxky0MVVpTjG2o8DlqXOLdmOQdpN5u/+BrGo5gficdNrBtiJ9127qDxXp0INfCL2pNlt1y/ X-Received: by 2002:a05:651c:200e:: with SMTP id s14mr7471079ljo.397.1634656223398; Tue, 19 Oct 2021 08:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634656223; cv=none; d=google.com; s=arc-20160816; b=ZlSM9NrMQ8Q3b92OZ4wVBjxxAIZJQBvhuadc2U+qnm6yKCyMXSwo1gLNRkwSopn2UL uBx0bJdch/TpCgjfz+MpqDiHDzYf+B2h6xCcs0Rn8aZGkDidk7SYSW4DOcJ8KzQ+gf2i 98ZqX7Tw1IU1i/7ZZ2qz078KWC23VrbmTqu3N/yHivKFkZgDh55rDgxzltngaZ45LpNY iQaGBVZOhR1MBEBdQHMBZa+MIImwM6Hv5HKIM4LOPJ9E3qZ7dyXI5cEQXweDGO1FSCA5 rpL2fq9UkDCx/pB2+Tw51ztUo88coiacopzII1kYN5OPC4PTXiSTSrNSfNoLsna78STw snZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=o6Z3wtlgq20txw2+Et0kOZLDdVeir31471oPdVlFfu4=; b=Z2SYoOnYBf51FeEJ9dYxfcJmO/XHc7iV0JQqtjeK5h2mEME3P5VSYeZhzTis7jtvNG 1ht5czjAIhG/8BTJT3RpZrfNnmeqK75w4GtlYzKm3VL4mxmr9AgyQ2jHEIo6l+/JYuAX cDEkQjldhbUBoCO36mUmakq3L0/qYfxUf4QeVnAveoWlr5fWMdzNrPJ8+N7f6LnqILd0 pNpBLfoeITsTC1etMx2qwGvcZe3Lhp8fbRwTJBZuB2wXVahrrjrVxW1t4UvodZxSLnRo zqGZUfp8dG1FDyePf8gOGj/8zIvD+o5p2s0iHODtYVsQGbPRb6kqCpRo9EqZGNBztRY4 Jw6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m9+al89Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ji20si5657441ejc.64.2021.10.19.08.09.59; Tue, 19 Oct 2021 08:10:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m9+al89Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232752AbhJSPKF (ORCPT + 99 others); Tue, 19 Oct 2021 11:10:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:57532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232109AbhJSPKE (ORCPT ); Tue, 19 Oct 2021 11:10:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3525F6103D; Tue, 19 Oct 2021 15:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634656071; bh=OWvKAr2to9kAJNZAYsVeoYRYbSQNFp01JVyK9wyJw+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m9+al89Zh9k+IFNfsLlPn5zFktmRa/DXo4MnENdFNGlxDhFaBkSkEnsf0cWuAcYYn p7rSdavdFiCNkvNRhqgTqO4E6zjKPOYY3JZAZqXBIwr5t4SGx/GFJQCibeQpLyTOHw XNqjNw1FLvcF/8LXOwpFqCOuRvYYggWFdbNBe+HfL2NimQmcbC2NPSt6ayIOyDXgnc we19vyf+hmwXx+mXfs/e7Wk/bFjxeZGPIPDYfcy32NnqUhBeS13sqdt2n92oGqu/Yv 95+Zm80PS2E9n4F1cb5DVngUviKpIKKSYoHDsqLh2uVsZo53Ni213wN0IKvUGsy7E4 1BEoFP+a3vw3g== From: SeongJae Park To: akpm@linux-foundation.org Cc: SeongJae Park , Jonathan.Cameron@Huawei.com, amit@kernel.org, benh@kernel.crashing.org, corbet@lwn.net, david@redhat.com, dwmw@amazon.com, elver@google.com, foersleo@amazon.de, gthelen@google.com, markubo@amazon.de, rientjes@google.com, shakeelb@google.com, shuah@kernel.org, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/15] mm/damon/paddr: Support the pageout scheme Date: Tue, 19 Oct 2021 15:07:17 +0000 Message-Id: <20211019150731.16699-2-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211019150731.16699-1-sj@kernel.org> References: <20211019150731.16699-1-sj@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit makes the DAMON primitives for physical address space support the pageout action for DAMON-based Operation Schemes. With this commit, hence, users can easily implement system-level data access-aware reclamations using DAMOS. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index d7a2ecd09ed0..957ada55de77 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -11,7 +11,9 @@ #include #include #include +#include +#include "../internal.h" #include "prmtv-common.h" static bool __damon_pa_mkold(struct page *page, struct vm_area_struct *vma, @@ -211,6 +213,39 @@ bool damon_pa_target_valid(void *t) return true; } +int damon_pa_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, + struct damon_region *r, struct damos *scheme) +{ + unsigned long addr; + LIST_HEAD(page_list); + + if (scheme->action != DAMOS_PAGEOUT) + return -EINVAL; + + for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { + struct page *page = damon_get_page(PHYS_PFN(addr)); + + if (!page) + continue; + + ClearPageReferenced(page); + test_and_clear_page_young(page); + if (isolate_lru_page(page)) { + put_page(page); + continue; + } + if (PageUnevictable(page)) { + putback_lru_page(page); + } else { + list_add(&page->lru, &page_list); + put_page(page); + } + } + reclaim_pages(&page_list); + cond_resched(); + return 0; +} + void damon_pa_set_primitives(struct damon_ctx *ctx) { ctx->primitive.init = NULL; @@ -220,5 +255,5 @@ void damon_pa_set_primitives(struct damon_ctx *ctx) ctx->primitive.reset_aggregated = NULL; ctx->primitive.target_valid = damon_pa_target_valid; ctx->primitive.cleanup = NULL; - ctx->primitive.apply_scheme = NULL; + ctx->primitive.apply_scheme = damon_pa_apply_scheme; } -- 2.17.1