From patchwork Sun May 12 17:54:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13662810 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 EA253C25B4F for ; Sun, 12 May 2024 17:55:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8FC26B01A3; Sun, 12 May 2024 13:55:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C4926B01A2; Sun, 12 May 2024 13:55:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EF716B01A1; Sun, 12 May 2024 13:55:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5797B6B0193 for ; Sun, 12 May 2024 13:55:01 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C9346C06D2 for ; Sun, 12 May 2024 17:55:00 +0000 (UTC) X-FDA: 82110494760.15.24E89C2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 2A1D7A000B for ; Sun, 12 May 2024 17:54:59 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fOCDVk1p; spf=pass (imf15.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=1715536499; 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:in-reply-to:references:references:dkim-signature; bh=WUgsl/5ybdNu4qkI+6u65k35N4e07c2u/T6CFojNSRo=; b=I+Ti516ZpRHtbHKoVmx+QLCESUfz65XxIlT8AAgk5W944zKHAI6g2k9E1sVnEEokKOR2HT 6l5xIwB8UoxCep4Ij18lm9Ya3MYFwvYx4NynHd3z++r5RF39+SeJHv/4y4ZIuC9dzg08/a cYxkmYyCM6rnzUT6tjGaE9fbTSPN/fg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fOCDVk1p; spf=pass (imf15.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=1715536499; a=rsa-sha256; cv=none; b=R4K++a4l+szlL7YXY67RLdeVl+wSQXXYeo06y5Oq7ieuKYmvHfqLC0LBVok4WZezeduhP3 ngJLxPA02EXSnYoMGwq1wXBiOyIEhxdhlTCWbYlxahBO410cs7lgt9tBjMP4yopFnvLlzm sJz6e9jubvATDJlLOfStziCs91aS+O0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4BF3860B95; Sun, 12 May 2024 17:54:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9859EC32781; Sun, 12 May 2024 17:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715536498; bh=HjyWpv2l8S24lCKx7/me+IFm1iDwuNsUj8wbeOXFYY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fOCDVk1p+QvsfPxFZGFuR7GWACBBP/DSQaaw966CnXovAR+eXd/oKQbhPIvBEGNJW WTQHUMZ9Tir6K0G1me1gLjTnFp8gxKD5G54IzI7k95vWlEOnVljY1wuxU7/QDBBCl8 TDHLXrizha9Gkc88qZSd6RHLzJj7UZOJJ94y5SfZp0Bmlp1AxP2d6Ny1kiFKaOUi65 ZwJmbuljvTEJPIEv2qWLpvi27KZPbt50udjXkXo31GtgNtfkvlqK9vP6z8JLVmTpW/ +PKLUiobEZ0l3l+PoNCQZwFIZOS6ibjGA+OecvuI6B5vyICO5mrBbMg2/WaES2jZx9 gnXanyNFEMxhw== From: SeongJae Park To: Cc: Hyeongtak Ji , SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Honggyu Kim Subject: [RFC PATCH v4 5/5] mm/damon/paddr: introduce DAMOS_MIGRATE_HOT action for promotion Date: Sun, 12 May 2024 10:54:47 -0700 Message-Id: <20240512175447.75943-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240512175447.75943-1-sj@kernel.org> References: <20240512175447.75943-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2A1D7A000B X-Stat-Signature: 69y69mpmgbdrafze7seg7jirgpr4s834 X-HE-Tag: 1715536499-676333 X-HE-Meta: U2FsdGVkX1/RwZcqdesif7q1KpgKPAhIsNggJnZHdX3zRc270nURNVUELM/6T9rGkX3W6Oymqe6m0w46ROQeFVy4VtOT5w/3kdUKQXeFcd4wayW1aeUztEsnGEW1vLdvpQqgJjPZ6sxgYOW2Ntme4F+KvSZzbJkRwV6RSMF1G2txulcOEAnhuEhd/ueuj6Nm0yFwBue9mBRJUgWed9zD2PIL9GbRrZAC9Ntc1mLJk4xAWxQxmLgegsRIMnnXf1p+mKvvym3p6gAsdiJGhxthmAPjKbfDb+g5zOQBzeu+yHrQgmz2X/S2RdaQIjiOMuGlGequ4bp7LTLBsLVatdw4ccfdnIXCQ04FcCctXtPujGorU+RtcZJVThGbA0YvEk8mXJjdoMLbdLmghX5t9dBtt+po2AdBySdpbGFBpL5s9sO1EuSi2hUAGQABPRvDr/CE/XLbrzNZ2wjwb6Q7kh3cF21FCv0/U8EqjfVWD2/VMb1ONchNikbWCQc+GXKWwIOsZWqFmCz4Bd//B0VN9OGksKkfMnybDeUARJcsN0FZqsHes2uJBwE9SW4a4F6RiQna88cWX7Djh412Nh1Jaon4xostKD+hAnEm0stuWL4HVQWtCZiKoD4ewK4AatMIlNdjLoqgfXpQ3ikt0QoDPjHxrcBJTqjZVjMaiK+1N4WDTIOg1K5qtCxUauGOPKmS94h95xgS87N/yNH2YjhWyGDSMZHu03fibgtrFOba3pcEl9BOKHD5ef0aEh+Szz2URx3EiHL4fHA6xwB0WZuqD0ijgvFGqO/blsWoPmMIW6oyzUIBDX2vwimpoAipVJzAvxiRPc0LIhb1KOCewVuBeXqjW3X1+Krc+Udf2G8KINoqfnzrH1ckovXRZ+bSLyPbTvfdKi4DMIf04eyQ9mvP7MvgMrbL3Yx71iFT4233D2Wir4FStYLL5rd+0FNH1qxAKqTYRD9LWfu+qHe7VTGRWsy gnrZTZkA 78j8Y+LUFhjbDdNP8k2onQ4hAP7HF0cWySFnN5WmxxQsHr1szk53M3R9/am9Z8Q4uC8xjpz8czbi70SGz6ZjXjLJQnqhL3IjDKwXMTKYSrSkapdUQXTh8P3U9i2XhUZ+qdMIZSLyBqzLTnY9aijeFdFlMPoHKM4Xgtrty5tjUKAW7+qHoPKkO7YgvfVz1sU9eDxXXsW7d/5vNS5Onbs6wbHMNytmw7E4OOf37o7gokEz/covGilo2zHOGkEb/PHWo+e7X6ZruFxDcmGqeZAJnYPSr+KW8LbdOBIzHUlgM2FnuKg3P3E5HO7kaD0V/NN72NiZhVVncqnVbmTelaI4CqfbJpCzIp9iRZMKp 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: List-Subscribe: List-Unsubscribe: From: Hyeongtak Ji This patch introduces DAMOS_MIGRATE_HOT action, which is similar to DAMOS_MIGRATE_COLD, but proritizes hot pages. It migrates pages inside the given region to the 'target_nid' NUMA node in the sysfs. Here is one of the example usage of this 'migrate_hot' action. $ cd /sys/kernel/mm/damon/admin/kdamonds/ $ cat contexts//schemes//action migrate_hot $ echo 0 > contexts//schemes//target_nid $ echo commit > state $ numactl -p 2 ./hot_cold 500M 600M & $ numastat -c -p hot_cold Per-node process memory usage (in MBs) PID Node 0 Node 1 Node 2 Total -------------- ------ ------ ------ ----- 701 (hot_cold) 501 0 601 1101 Signed-off-by: Hyeongtak Ji Signed-off-by: Honggyu Kim Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 ++ mm/damon/paddr.c | 3 +++ mm/damon/sysfs-schemes.c | 1 + 3 files changed, 6 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 56714b6eb0d7..3d62d98d6359 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -105,6 +105,7 @@ struct damon_target { * @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE. * @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists. * @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists. + * @DAMOS_MIGRATE_HOT: Migrate the regions prioritizing warmer regions. * @DAMOS_MIGRATE_COLD: Migrate the regions prioritizing colder regions. * @DAMOS_STAT: Do nothing but count the stat. * @NR_DAMOS_ACTIONS: Total number of DAMOS actions @@ -123,6 +124,7 @@ enum damos_action { DAMOS_NOHUGEPAGE, DAMOS_LRU_PRIO, DAMOS_LRU_DEPRIO, + DAMOS_MIGRATE_HOT, DAMOS_MIGRATE_COLD, DAMOS_STAT, /* Do nothing but only record the stat */ NR_DAMOS_ACTIONS, diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index a468792d9162..81163206e70c 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -486,6 +486,7 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, return damon_pa_mark_accessed(r, scheme); case DAMOS_LRU_DEPRIO: return damon_pa_deactivate_pages(r, scheme); + case DAMOS_MIGRATE_HOT: case DAMOS_MIGRATE_COLD: return damon_pa_migrate(r, scheme); case DAMOS_STAT: @@ -508,6 +509,8 @@ static int damon_pa_scheme_score(struct damon_ctx *context, return damon_hot_score(context, r, scheme); case DAMOS_LRU_DEPRIO: return damon_cold_score(context, r, scheme); + case DAMOS_MIGRATE_HOT: + return damon_hot_score(context, r, scheme); case DAMOS_MIGRATE_COLD: return damon_cold_score(context, r, scheme); default: diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 880015d5b5ea..66fccfa776d7 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1458,6 +1458,7 @@ static const char * const damon_sysfs_damos_action_strs[] = { "nohugepage", "lru_prio", "lru_deprio", + "migrate_hot", "migrate_cold", "stat", };