Commit e36287c6 authored by Hyeongtak Ji's avatar Hyeongtak Ji Committed by Andrew Morton
Browse files

mm/damon/sysfs-schemes: add target_nid on sysfs-schemes

This patch adds target_nid under
  /sys/kernel/mm/damon/admin/kdamonds/<N>/contexts/<N>/schemes/<N>/

The 'target_nid' can be used as the destination node for DAMOS actions
such as DAMOS_MIGRATE_{HOT,COLD} in the follow up patches.

[sj@kernel.org: document target_nid file]
  Link: https://lkml.kernel.org/r/20240618213630.84846-3-sj@kernel.org
Link: https://lkml.kernel.org/r/20240614030010.751-4-honggyu.kim@sk.com


Signed-off-by: default avatarHyeongtak Ji <hyeongtak.ji@sk.com>
Signed-off-by: default avatarHonggyu Kim <honggyu.kim@sk.com>
Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Gregory Price <gregory.price@memverge.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 8f75267d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -155,6 +155,12 @@ Contact: SeongJae Park <sj@kernel.org>
Description:	Writing to and reading from this file sets and gets the action
		of the scheme.

What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/target_nid
Date:		Jun 2024
Contact:	SeongJae Park <sj@kernel.org>
Description:	Action's target NUMA node id.  Supported by only relevant
		actions.

What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/apply_interval_us
Date:		Sep 2023
Contact:	SeongJae Park <sj@kernel.org>
+10 −1
Original line number Diff line number Diff line
@@ -374,6 +374,7 @@ struct damos_access_pattern {
 * @apply_interval_us:	The time between applying the @action.
 * @quota:		Control the aggressiveness of this scheme.
 * @wmarks:		Watermarks for automated (in)activation of this scheme.
 * @target_nid:		Destination node if @action is "migrate_{hot,cold}".
 * @filters:		Additional set of &struct damos_filter for &action.
 * @stat:		Statistics of this scheme.
 * @list:		List head for siblings.
@@ -389,6 +390,10 @@ struct damos_access_pattern {
 * monitoring context are inactive, DAMON stops monitoring either, and just
 * repeatedly checks the watermarks.
 *
 * @target_nid is used to set the migration target node for migrate_hot or
 * migrate_cold actions, which means it's only meaningful when @action is either
 * "migrate_hot" or "migrate_cold".
 *
 * Before applying the &action to a memory region, &struct damon_operations
 * implementation could check pages of the region and skip &action to respect
 * &filters
@@ -410,6 +415,9 @@ struct damos {
/* public: */
	struct damos_quota quota;
	struct damos_watermarks wmarks;
	union {
		int target_nid;
	};
	struct list_head filters;
	struct damos_stat stat;
	struct list_head list;
@@ -726,7 +734,8 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
			enum damos_action action,
			unsigned long apply_interval_us,
			struct damos_quota *quota,
			struct damos_watermarks *wmarks);
			struct damos_watermarks *wmarks,
			int target_nid);
void damon_add_scheme(struct damon_ctx *ctx, struct damos *s);
void damon_destroy_scheme(struct damos *s);

+4 −1
Original line number Diff line number Diff line
@@ -354,7 +354,8 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
			enum damos_action action,
			unsigned long apply_interval_us,
			struct damos_quota *quota,
			struct damos_watermarks *wmarks)
			struct damos_watermarks *wmarks,
			int target_nid)
{
	struct damos *scheme;

@@ -381,6 +382,8 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
	scheme->wmarks = *wmarks;
	scheme->wmarks.activated = true;

	scheme->target_nid = target_nid;

	return scheme;
}

+1 −1
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ static struct damos **str_to_schemes(const char *str, ssize_t len,

		pos += parsed;
		scheme = damon_new_scheme(&pattern, action, 0, &quota,
				&wmarks);
				&wmarks, NUMA_NO_NODE);
		if (!scheme)
			goto fail;

+2 −1
Original line number Diff line number Diff line
@@ -163,7 +163,8 @@ static struct damos *damon_lru_sort_new_scheme(
			/* under the quota. */
			&quota,
			/* (De)activate this according to the watermarks. */
			&damon_lru_sort_wmarks);
			&damon_lru_sort_wmarks,
			NUMA_NO_NODE);
}

/* Create a DAMON-based operation scheme for hot memory regions */
Loading