From patchwork Tue Feb 15 18:45:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12747502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6332C433FE for ; Tue, 15 Feb 2022 18:46:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 068966B007D; Tue, 15 Feb 2022 13:46:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F32466B007E; Tue, 15 Feb 2022 13:46:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF93F6B0080; Tue, 15 Feb 2022 13:46:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id CEFD16B007D for ; Tue, 15 Feb 2022 13:46:41 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 89323181AC9CC for ; Tue, 15 Feb 2022 18:46:41 +0000 (UTC) X-FDA: 79145895402.25.419AB6D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 187994000D for ; Tue, 15 Feb 2022 18:46:40 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 52BC661711; Tue, 15 Feb 2022 18:46:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F86C340EC; Tue, 15 Feb 2022 18:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644950800; bh=AxnbO0uNmq3XAyTYYIhSWm/tXyJR3KLtDqV4YrpqgG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NtlRdCapi8bHoDNqbL5gqE2Cskucm55p+rh4cz/gyh4wXmjdxWNu+guDCAu6lfnoc ZIAtU+BfSa9pg3dYXdyPNEO6T8TVcFhIRlneaFSKrXecQjkb4YRtURlC1Wuo7fLeTz OX+ZK0gjikz9x9IrB0ih5lmYGTRejcANx/HYlDQESvb7vLUBOPeEw62LUyIc01Afc4 GhwuyPnu6C9uYQlBy/uPWl+W7d7pCcQDE4emOI8JZvIAlZCeaXRY4dkcpthpED06q1 JuSDNXDGeSqOeSuhGdLxlOr4fdFXCmsoMtj3wCz0j16gD6fj5EZSIN/JZZo2OOd1ym Op9Xwo0Edz/6w== From: SeongJae Park To: akpm@linux-foundation.org Cc: xhao@linux.alibaba.com, rientjes@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 3/8] mm/damon/paddr,vaddr: Register themselves to DAMON in subsys_initcall Date: Tue, 15 Feb 2022 18:45:58 +0000 Message-Id: <20220215184603.1479-4-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220215184603.1479-1-sj@kernel.org> References: <20220215184603.1479-1-sj@kernel.org> X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 187994000D X-Stat-Signature: tsp4by3k911kagphg6htmwbx5ehn1wim X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NtlRdCap; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1644950800-360285 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This commit makes the monitoring operations for the physical address space and virtual address spaces register themselves to DAMON in the subsys_initcall step. Later, in-kernel DAMON user code can use them via damon_select_ops() without have to unnecessarily depend on all possible monitoring operations implementations. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 20 ++++++++++++++++++++ mm/damon/vaddr.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 9f0abd0369bc..d968bb38bd5d 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -273,3 +273,23 @@ void damon_pa_set_operations(struct damon_ctx *ctx) ctx->ops.apply_scheme = damon_pa_apply_scheme; ctx->ops.get_scheme_score = damon_pa_scheme_score; } + +static int __init damon_pa_initcall(void) +{ + struct damon_operations ops = { + .id = DAMON_OPS_PADDR, + .init = NULL, + .update = NULL, + .prepare_access_checks = damon_pa_prepare_access_checks, + .check_accesses = damon_pa_check_accesses, + .reset_aggregated = NULL, + .target_valid = damon_pa_target_valid, + .cleanup = NULL, + .apply_scheme = damon_pa_apply_scheme, + .get_scheme_score = damon_pa_scheme_score, + }; + + return damon_register_ops(&ops); +}; + +subsys_initcall(damon_pa_initcall); diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index c0eb32025f9b..87475ba37bec 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -752,4 +752,24 @@ void damon_va_set_operations(struct damon_ctx *ctx) ctx->ops.get_scheme_score = damon_va_scheme_score; } +static int __init damon_va_initcall(void) +{ + struct damon_operations ops = { + .id = DAMON_OPS_VADDR, + .init = damon_va_init, + .update = damon_va_update, + .prepare_access_checks = damon_va_prepare_access_checks, + .check_accesses = damon_va_check_accesses, + .reset_aggregated = NULL, + .target_valid = damon_va_target_valid, + .cleanup = NULL, + .apply_scheme = damon_va_apply_scheme, + .get_scheme_score = damon_va_scheme_score, + }; + + return damon_register_ops(&ops); +}; + +subsys_initcall(damon_va_initcall); + #include "vaddr-test.h"