From patchwork Fri May 13 15:00:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12848951 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 657F0C433EF for ; Fri, 13 May 2022 15:00:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7F278D0001; Fri, 13 May 2022 11:00:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B05296B007D; Fri, 13 May 2022 11:00:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CDC88D0001; Fri, 13 May 2022 11:00:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8D2BC6B007B for ; Fri, 13 May 2022 11:00:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6AA4B330BD for ; Fri, 13 May 2022 15:00:42 +0000 (UTC) X-FDA: 79461031524.10.6A77ABC Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf03.hostedemail.com (Postfix) with ESMTP id B7DA5200B8 for ; Fri, 13 May 2022 15:00:32 +0000 (UTC) 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 40202B8306C; Fri, 13 May 2022 15:00:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85191C34100; Fri, 13 May 2022 15:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652454038; bh=dvkE+Xle/CL236kYATrTSaFb/CzjqEqgY0TtOELuS3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G8xkcMwft8MJgi5PphUHDXBPYWeRuVAR9cEtuPyM3CN3b3Stzq8L9ooP1Xmc8xPc6 5PPqqjAnCV1UyX2GcnApgnhwTq94CHyWAsTfFHUSlxGkzjNq8SIehWGhdObmVyCSJI dg6QFE3X8lSkpdgqFCieCzbpPGH2nJrpP7BhimaJKGUoigLKieCQkTGNCK9L0IuftZ 0jyXQ3FsdasiWkPdTUqNpq4juzPBY7aWZ5jS70hVOn+avgDIPnQcFFedlc6nNpy9DB EwVsolHZXS/3tLcnqYnIkyh4xwa6N1BtPOLsU1FUi0Y5CCQXGb86NqZ0pNdy4lawcB Rj5bHogHTx8aQ== From: SeongJae Park To: Cc: linux-damon@amazon.com, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [RFC PATCH 3/3] mm/damon/paddr: Support DAMOS_COLD Date: Fri, 13 May 2022 17:00:00 +0200 Message-Id: <20220513150000.25797-4-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220513150000.25797-1-sj@kernel.org> References: <20220513150000.25797-1-sj@kernel.org> X-Stat-Signature: xqkk9kixeyotzjje5nybkz8jufx6rmny Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=G8xkcMwf; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B7DA5200B8 X-HE-Tag: 1652454032-429492 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: DAMOS_COLD is currently supported by the virtual address spaces monitoring operations set (vaddr). This commit adds support of the action to the physical address space monitoring operations set (paddr). Using this together with hot DAMOS action, users can proactively sort LRU lists so that performance degradation under memory pressure can be reduced. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 69980b922bf4..761b1580271c 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -249,6 +249,22 @@ static unsigned long damon_pa_mark_accessed(struct damon_region *r) return applied * PAGE_SIZE; } +static unsigned long damon_pa_cold(struct damon_region *r) +{ + unsigned long addr, applied = 0; + + for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { + struct page *page = damon_get_page(PHYS_PFN(addr)); + + if (!page) + continue; + deactivate_page(page); + put_page(page); + applied++; + } + return applied * PAGE_SIZE; +} + static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, struct damos *scheme) @@ -258,6 +274,8 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, return damon_pa_pageout(r); case DAMOS_HOT: return damon_pa_mark_accessed(r); + case DAMOS_COLD: + return damon_pa_cold(r); default: break; } @@ -273,6 +291,8 @@ static int damon_pa_scheme_score(struct damon_ctx *context, return damon_pageout_score(context, r, scheme); case DAMOS_HOT: return damon_hot_score(context, r, scheme); + case DAMOS_COLD: + return damon_pageout_score(context, r, scheme); default: break; }