Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1329662rbb; Mon, 26 Feb 2024 06:12:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWtQ6N82BmKRhPgtR6bvoZ8PBbRA/qbj+hEN6cEksrE9mLOsvfwuF8HtTLr2goNBkdTVQW17dddRzicj4dCqfIFZLaygsEsm7Cepc+9Jw== X-Google-Smtp-Source: AGHT+IEIjkbagfVdf8O2LlvmmsWt3+QffO+xOYGYXfmPE/BceABC7RteDlPVeANeQnsPjrKFhImq X-Received: by 2002:a67:fdc7:0:b0:471:b991:6cae with SMTP id l7-20020a67fdc7000000b00471b9916caemr4442201vsq.26.1708956730269; Mon, 26 Feb 2024 06:12:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708956730; cv=pass; d=google.com; s=arc-20160816; b=J52JLl+LU1B0BOo1XLtbx2Z7qujOoo6EYdhbBJKR+Gx47QdSIokdELcs7azcMfMOE1 SDxNhBSuURmPCcR4d0ji8dh4J7ZkqiQvY/tBeY7/jTPG/REmq0N/y9De89XttzJuCEx7 SS9kj8FNjpepUAz0MhrUZCj5fFmD/NUBQFCY4Q9gDB73qUNFutPFspJzlK49KWCV3qXE 4vyWvf03S0eZSYnICZaebPSQObjigj/8G1NyMG3z9AaM+DjJ0+FcfI6uDUaScn+E4g9L z+5/iUxt7aqVcLDM6fB95crKfycGCT1akfYI/E6X4aTnZjGC0tcriaOX5nMxT5wygoXw yJTw== 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; bh=zXbLP2GSUHeXTzjP624Gn+oPXDlC4J4rQeiJ29BCBCE=; fh=egwJU2bb679B4Zi0WdxyKykgfACRkSkUGxyHY52POxM=; b=sjMyAbHotqe8j724JYUq2OVwEkT3yWrp4aGG1TPOypLHFA11Bysh5H7CKeuF7p5nEg E0GwlZ8JH9Brsblar7F8nD71l14IP/mL8vq37d8BLBiDXV2Ug4+0bPT1V0mlodcHL3RA TiZFYqReN/YJiMMcgnYNwPB+0wI2OKnyq0nbnwFEZPtgP3Gxb1tpAsH4P4QGYUCAlXmJ OmUh74Hzog9KQdw0yaBk+C05XaXgBmibkDDamLkNR0Cr30NTTh+IDG7bXaw5c3w2wNOm n2iarI11OyznrJGeiewGA6Anj4QTRMl/MGy8mBtyYhNqKkO65qJv/vr9ZBpPn9cX6dbh iseg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-81586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81586-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j1-20020a056102000100b004705004c8a4si484382vsp.387.2024.02.26.06.12.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 06:12:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-81586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81586-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 96F5C1C29D51 for ; Mon, 26 Feb 2024 14:11:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A75E12E1D2; Mon, 26 Feb 2024 14:06:27 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9B1712C819; Mon, 26 Feb 2024 14:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956386; cv=none; b=jFOm5JhzzJkEpRw+VImrQ+nFNHGnsck0DYMwI1MkOCBLeGlw1O45XJQ2ut7JmASSruny3hznA0Ra9ns5+xsNqDlyzU+L3ZOjXpY2ZwJ2I1ptDeLBTNpFCZQbjp41w3enOztgfAFReaqv4xERmoXhPKpob0Mh4DTi2iPJX6u/HUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956386; c=relaxed/simple; bh=rwgghmTg7o4FR0Bv2KuCZkmTtPHv9JXSryRKMphOOMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X+dNMT/Vk+ENbb8+TCPs5edVVyZcZ9Cb+llQELWEwkuu9CjDs+0YziuTdZyJlMFtQZGB9mVLxHxFmC5MR2L20LwTEvgKIvBW4J1A4C3odNKDkHZu+qcJodgucBqmEXQPnfXG92Gz5bMHrpnYq8UXoMykdMF7o5G1kdZIS1jIztA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d6dff70000001748-93-65dc9ade7648 From: Honggyu Kim To: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Cc: akpm@linux-foundation.org, apopple@nvidia.com, baolin.wang@linux.alibaba.com, dave.jiang@intel.com, honggyu.kim@sk.com, hyeongtak.ji@sk.com, kernel_team@skhynix.com, linmiaohe@huawei.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lizhijian@cn.fujitsu.com, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, rakie.kim@sk.com, rostedt@goodmis.org, surenb@google.com, yangx.jy@fujitsu.com, ying.huang@intel.com, ziy@nvidia.com, 42.hyeyoo@gmail.com Subject: [PATCH v2 7/7] mm/damon/sysfs-schemes: apply target_nid for promote and demote actions Date: Mon, 26 Feb 2024 23:05:53 +0900 Message-ID: <20240226140555.1615-8-honggyu.kim@sk.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240226140555.1615-1-honggyu.kim@sk.com> References: <20240226140555.1615-1-honggyu.kim@sk.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsXC9ZZnoe69WXdSDZa1cVtM7DGwmLN+DZvF rhshFv/3HmO0ePL/N6vFiZuNbBad35eyWFzeNYfN4t6a/6wWR9afZbFYdwvI2nz2DLPF4uVq Fvs6HjBZHP76hsli8qUFbBYvppxhtDg5azKLxeyj99gdhD3+H5zE7LH09Bs2jw1NQGLnrLvs Hi37brF7LNhU6tFy5C2rx+I9L5k8Nq3qZPPY9GkSu8eJGb9ZPHY+tPR4sXkmo0dv8zs2j8+b 5AL4o7hsUlJzMstSi/TtErgyPl+/wVTwQ76iqe8rWwNjr2QXIyeHhICJxLEtr1hh7L2rzzCC 2GwCahJXXk5i6mLk4BARcJBY9VWhi5GLg1mggUXix+dLLCA1wgLxEiu27wPr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zs/dxAiMtWW1fybuYPxy2f0QowAHoxIPr0PtnVQh1sSy4srcQ4wSHMxKIrzhMjdThXhTEiur Uovy44tKc1KLDzFKc7AoifN6hacmCAmkJ5akZqemFqQWwWSZODilGhjNfZR5/H8w5K5/oMaV Y7nh34Ppcn3CBydPUVNkPLBLYOv6U00bsl53xitqxr+L+F4TvfNi5YUdIfFxIqxS28oFOnQP JGv0b3lRYO4jc03guYyn96xV6R6z1vlvqTzA5jKD+9xvw00WryXCAn49CPO/LvWttOIS143F y+IzlzhrTombvf9R9SQlluKMREMt5qLiRACjXRGRsQIAAA== X-CFilter-Loop: Reflected From: Hyeongtak Ji This patch changes DAMOS_PROMOTE and DAMOS_DEMOTE to use target_nid of sysfs as the destination NUMA node of migration. This has been tested on qemu as follows: $ cd /sys/kernel/mm/damon/admin/kdamonds/ $ cat contexts//schemes//action promote $ echo 1 > 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) 0 501 601 1101 Signed-off-by: Hyeongtak Ji Signed-off-by: Honggyu Kim --- mm/damon/paddr.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 37a7b34a36dd..5e057a69464f 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -240,9 +240,9 @@ enum migration_mode { */ static unsigned int migrate_folio_list(struct list_head *migrate_folios, struct pglist_data *pgdat, - enum migration_mode mm) + enum migration_mode mm, + int target_nid) { - int target_nid; unsigned int nr_succeeded; nodemask_t allowed_mask; int reason; @@ -250,12 +250,14 @@ static unsigned int migrate_folio_list(struct list_head *migrate_folios, switch (mm) { case MIG_PROMOTE: - target_nid = next_promotion_node(pgdat->node_id); + if (target_nid == NUMA_NO_NODE) + target_nid = next_promotion_node(pgdat->node_id); reason = MR_PROMOTION; vm_event = PGPROMOTE; break; case MIG_DEMOTE: - target_nid = next_demotion_node(pgdat->node_id); + if (target_nid == NUMA_NO_NODE) + target_nid = next_demotion_node(pgdat->node_id); reason = MR_DEMOTION; vm_event = PGDEMOTE_DIRECT; break; @@ -358,7 +360,8 @@ static enum folio_references folio_check_references(struct folio *folio) */ static unsigned int damon_pa_migrate_folio_list(struct list_head *folio_list, struct pglist_data *pgdat, - enum migration_mode mm) + enum migration_mode mm, + int target_nid) { unsigned int nr_migrated = 0; struct folio *folio; @@ -399,7 +402,7 @@ static unsigned int damon_pa_migrate_folio_list(struct list_head *folio_list, /* 'folio_list' is always empty here */ /* Migrate folios selected for migration */ - nr_migrated += migrate_folio_list(&migrate_folios, pgdat, mm); + nr_migrated += migrate_folio_list(&migrate_folios, pgdat, mm, target_nid); /* Folios that could not be migrated are still in @migrate_folios */ if (!list_empty(&migrate_folios)) { /* Folios which weren't migrated go back on @folio_list */ @@ -426,7 +429,8 @@ static unsigned int damon_pa_migrate_folio_list(struct list_head *folio_list, * common function for both cases. */ static unsigned long damon_pa_migrate_pages(struct list_head *folio_list, - enum migration_mode mm) + enum migration_mode mm, + int target_nid) { int nid; unsigned int nr_migrated = 0; @@ -449,12 +453,14 @@ static unsigned long damon_pa_migrate_pages(struct list_head *folio_list, } nr_migrated += damon_pa_migrate_folio_list(&node_folio_list, - NODE_DATA(nid), mm); + NODE_DATA(nid), mm, + target_nid); nid = folio_nid(lru_to_folio(folio_list)); } while (!list_empty(folio_list)); nr_migrated += damon_pa_migrate_folio_list(&node_folio_list, - NODE_DATA(nid), mm); + NODE_DATA(nid), mm, + target_nid); memalloc_noreclaim_restore(noreclaim_flag); @@ -499,7 +505,8 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s, break; case MIG_PROMOTE: case MIG_DEMOTE: - applied = damon_pa_migrate_pages(&folio_list, mm); + applied = damon_pa_migrate_pages(&folio_list, mm, + s->target_nid); break; default: /* Unexpected migration mode. */ -- 2.34.1