brintos

brintos / linux-shallow public Read only

0
0
Text · 874 B · 7cf9657 Raw
43 lines · c
1// SPDX-License-Identifier: GPL-2.02/*3 * Common Primitives for DAMON Modules4 *5 * Author: SeongJae Park <sj@kernel.org>6 */7 8#include <linux/damon.h>9 10#include "modules-common.h"11 12/*13 * Allocate, set, and return a DAMON context for the physical address space.14 * @ctxp:	Pointer to save the point to the newly created context15 * @targetp:	Pointer to save the point to the newly created target16 */17int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp,18		struct damon_target **targetp)19{20	struct damon_ctx *ctx;21	struct damon_target *target;22 23	ctx = damon_new_ctx();24	if (!ctx)25		return -ENOMEM;26 27	if (damon_select_ops(ctx, DAMON_OPS_PADDR)) {28		damon_destroy_ctx(ctx);29		return -EINVAL;30	}31 32	target = damon_new_target();33	if (!target) {34		damon_destroy_ctx(ctx);35		return -ENOMEM;36	}37	damon_add_target(ctx, target);38 39	*ctxp = ctx;40	*targetp = target;41	return 0;42}43