Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1632500lqo; Sun, 12 May 2024 10:55:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcVeKiSVnR/g1x33x/B3MiGjjqbivUjywl47UV1Kcu/ENzwVrLoYMcAJFWFWxGEc+pDuOA6U25MnS+QRPbMkP51SC8XlWSiFMqxI0QGg== X-Google-Smtp-Source: AGHT+IG2e5911KVcg7HHejnldHzYOkIAchg/M6Z478eMRFwZ/nNnV921xJFGu9zBLH61Z1ChfOCO X-Received: by 2002:a17:902:d488:b0:1e6:36cc:5c65 with SMTP id d9443c01a7336-1ef433d4b3amr105700265ad.0.1715536541114; Sun, 12 May 2024 10:55:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715536541; cv=pass; d=google.com; s=arc-20160816; b=w8EnbL/1GPOjbQP32tsAu2A/KPVV0Af9Up69yUFdA4/v+lszyNEwqEQQbiXJVQxqCx njv1dW9iV2v/JYXJJqRxu36qWMOWJiSh+igB7uYCN2ApTQHn4XPT9Cneiy6hSkclnE9+ who3zeQXUV04oOB2V1eTL/eWaE1vSJzvwH9+vXIP8vKbi8TKmkGbLEtOfnLf976XEBKi EFnhmnXACRmca/05Qt7ko1jjgCqlkthVakyWK3zndSuN9QOWycxU1aTy9y0/5ht/Pim3 X/JFIvfODD2u86q1YmlVtX8bPGPczdySsJ1n8nxqn/i4rqXJ/kI0B3ucsg+7NTrEgBpH 7XRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WUgsl/5ybdNu4qkI+6u65k35N4e07c2u/T6CFojNSRo=; fh=JMl/DvMBb7rnohgeCyGSHaiRWR8l1zXyUgDRzbTz/Hc=; b=kyR4JpKnCtaazAfdSM2+aeqsQGitr9HOG+LDYoRgmFdUs0+F8J1jxhx454xKaQUg0d NzgCG/neOuvZA7iJKwGqEcp2O05Z5u37jBKdseowGI9Q9oW5bxz10bCE/4fS7eDm76R0 HujlfjMNPY6jpKe+rGDUfjdN1QCFQbIweFHvpUtdJJv4QTaoQncdeUlSD6ZW/nhpB/+X lvBt1ZHMmHC5mRem1JlYP35oLPwSA/6n5M4E6JyOuX+SHqmhyfNOrQrQZC0LoYlP4liE aCzezjmxqw0ZpduL0QHQocGNnL5MqVAB9dU8GvwWflPk5KJz9AXLKN4ECBe6LiZJeQpR ZJmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fOCDVk1p; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176964-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b9d14fcsi77222145ad.127.2024.05.12.10.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 10:55:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176964-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fOCDVk1p; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176964-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B9A20280FD0 for ; Sun, 12 May 2024 17:55:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 745F254FB5; Sun, 12 May 2024 17:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fOCDVk1p" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FD0953804; Sun, 12 May 2024 17:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715536498; cv=none; b=ngL2mn4KPxXJmvFnwiBa53Jip2bfRI5Tv40vrZXZt4TaeCJT7W6oGGPFmfouWqGniZ60tGwuql6zeOXJ0y+suvGmkOFe+l5YlyZZ9XXxOLkYClekl/fPYM99YU/aHp0aXQtABjQ7gJfxJWxVpLuCNI4BY73UlQyZDWFOTU6S20Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715536498; c=relaxed/simple; bh=HjyWpv2l8S24lCKx7/me+IFm1iDwuNsUj8wbeOXFYY0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bSRsFcKnnn6pv6w5sCjAUkfc0F8t/nIbTxgebOeeDyvJ7Ep7TmqhrNxg45XrCHW8ucbwc0IJ3LnZsquvVgeEILYJeezJTUG8gPLqnqvplb5dn/zynNQECtktVXdQwLAAkhnzVA8vNE3y9CHqkHuHzeZb6y+8zrcKGRNH6aKslXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fOCDVk1p; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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", }; -- 2.39.2