Staging
v0.5.1
https://github.com/torvalds/linux
Raw File
Tip revision: 815fb87b753055df2d9e50f6cd80eb10235fe3e9 authored by Linus Torvalds on 02 December 2023, 00:01:00 UTC
Merge tag 'pm-6.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Tip revision: 815fb87
modules-common.c
// SPDX-License-Identifier: GPL-2.0
/*
 * Common Primitives for DAMON Modules
 *
 * Author: SeongJae Park <sjpark@amazon.de>
 */

#include <linux/damon.h>

#include "modules-common.h"

/*
 * Allocate, set, and return a DAMON context for the physical address space.
 * @ctxp:	Pointer to save the point to the newly created context
 * @targetp:	Pointer to save the point to the newly created target
 */
int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp,
		struct damon_target **targetp)
{
	struct damon_ctx *ctx;
	struct damon_target *target;

	ctx = damon_new_ctx();
	if (!ctx)
		return -ENOMEM;

	if (damon_select_ops(ctx, DAMON_OPS_PADDR)) {
		damon_destroy_ctx(ctx);
		return -EINVAL;
	}

	target = damon_new_target();
	if (!target) {
		damon_destroy_ctx(ctx);
		return -ENOMEM;
	}
	damon_add_target(ctx, target);

	*ctxp = ctx;
	*targetp = target;
	return 0;
}
back to top