Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1008983iob; Fri, 13 May 2022 19:27:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFxgopBpaBMv+BTXrVQhqnubZx0gTl638iZ6BYcqRLknF1oN/c94nUEPrIxit7r0qAuynO X-Received: by 2002:adf:fb10:0:b0:207:af88:1eb9 with SMTP id c16-20020adffb10000000b00207af881eb9mr6109002wrr.238.1652495259367; Fri, 13 May 2022 19:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652495259; cv=none; d=google.com; s=arc-20160816; b=pahvVe+I3dkihJbs5RxXYsT5XAHqXXp68DL4pdNBvStG0PhFg7w6wmNd+FjRU87ANF CkxxIv88CbmAXXJcjAb5SjoH4X9Wz2FBKDS7DHXBkz73L5Z2YVies589pXB0G0Q86hfx oldpINQv1m3XXqUAX+mrPynvhHjMoA9yfcB3xamNb2D20vuYG5YndkSdfbtg4bRQMvM6 td4vyUvDztDeCi2RfXG/ILrCY5sUCCDYG1VQJafuU9e/zvQ8Yc/WHM7PsU3DC4mqE4Hu pg7UTUN0R3mur2rb6iWksrNOzXTcQPL/6cRET8sXbJ0jaG6axdt2wwzHk58cd7rWwbYL PCbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature; bh=FiMvHi/jNStjQz83qTtLgulNbRWZIACS5Wk75COHCPs=; b=Uh9l/BEAUFwl9YB1KTwZmNUsHePM0PGVrW6Z/lsJhmKGs/EdcG6tlFekwx2wtVwrum S8JZ87zUd98Y3pw7FoPjJ9Bke8MN0N1Pr8HYJTq76gHTxsORIh+5xBA8EbD8uKdNXH8g UMfEgNq+Uqjb6VjqA/yxe/W/F+7SIncV/TptvycBgGTmxZsXrURSAnMHCUrzCOEaA48A blV/cGgY5gvcDUvC0ZYZDbBs5aIIjI65tzD0CrJBzF4xAL9laPQKl8QbHX8ySdquKf2X 4XNoDGuhG3bR1EGQzqrbYzABbrYngG++FfdsLw8JrYXTxj7vx3F/o5z10oNowFZ6ShrH 8Oew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=G8xkcMwf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v5-20020adfebc5000000b0020ad572632bsi3368542wrn.413.2022.05.13.19.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=G8xkcMwf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC01830D66C; Fri, 13 May 2022 17:42:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381726AbiEMPBj (ORCPT + 99 others); Fri, 13 May 2022 11:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381878AbiEMPBM (ORCPT ); Fri, 13 May 2022 11:01:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC82F48332 for ; Fri, 13 May 2022 08:00:39 -0700 (PDT) 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 888CE62294 for ; Fri, 13 May 2022 15:00:39 +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 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.17.1