From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28B47C0018C for ; Wed, 16 Dec 2020 09:50:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFFD12313C for ; Wed, 16 Dec 2020 09:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726146AbgLPJuL (ORCPT ); Wed, 16 Dec 2020 04:50:11 -0500 Received: from smtp-fw-9103.amazon.com ([207.171.188.200]:50677 "EHLO smtp-fw-9103.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbgLPJuK (ORCPT ); Wed, 16 Dec 2020 04:50:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1608112210; x=1639648210; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=jk1a1eNXyHawqdXbc/seXg9Qwshk6tmctCaAv0I6QJY=; b=CjyE79m0mmFotSf8z/sB2FGeECkKmdo6TvzIqMkNkBsECzXc5qe+lA2B fLOArY9XNdSbTJy7hzYCQlcZ+6Yh0IvmJcVcr8qCsGhXhrgfjkaJPOHF6 5+yOCTFnVB646TcoAkiFv8uPvXOdAQxjcP8IxRmbLR84B8qRR/yGWjVtY U=; X-IronPort-AV: E=Sophos;i="5.78,424,1599523200"; d="scan'208";a="903546665" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9103.sea19.amazon.com with ESMTP; 16 Dec 2020 09:49:28 +0000 Received: from EX13D31EUA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com (Postfix) with ESMTPS id CCD37C1D03; Wed, 16 Dec 2020 09:45:57 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.161.31) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 16 Dec 2020 09:45:24 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v10 08/13] damon/dbgfs: Support physical memory monitoring Date: Wed, 16 Dec 2020 10:42:16 +0100 Message-ID: <20201216094221.11898-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201216094221.11898-1-sjpark@amazon.com> References: <20201216094221.11898-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.31] X-ClientProxiedBy: EX13D16UWB001.ant.amazon.com (10.43.161.17) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park This commit makes the 'damon-dbgfs' to support the physical memory monitoring, in addition to the virtual memory monitoring. Users can do the physical memory monitoring by writing a special keyword, 'paddr\n' to the 'pids' debugfs file. Then, DAMON will check the special keyword and configure the monitoring context to run using the primitives for physical memory. This will internally add one fake monitoring target process, which has target id 42. Unlike the virtual memory monitoring, the monitoring target region will not be automatically set. Therefore, users should also set the monitoring target address region using the 'init_regions' debugfs file. Finally, the physical memory monitoring will not automatically terminated. The user should explicitly turn off the monitoring by writing 'off' to the 'monitor_on' debugfs file. Signed-off-by: SeongJae Park --- mm/damon/Kconfig | 2 +- mm/damon/dbgfs.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/damon/Kconfig b/mm/damon/Kconfig index 89c06ac8c9eb..38f4cfce72dd 100644 --- a/mm/damon/Kconfig +++ b/mm/damon/Kconfig @@ -56,7 +56,7 @@ config DAMON_VADDR_KUNIT_TEST config DAMON_DBGFS bool "DAMON debugfs interface" - depends on DAMON_VADDR && DEBUG_FS + depends on DAMON_VADDR && DAMON_PADDR && DEBUG_FS help This builds the debugfs interface for DAMON. The user space admins can use the interface for arbitrary data access monitoring. diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 2f1ec6ebd9f0..ea03d7d5b879 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -462,6 +462,15 @@ static ssize_t dbgfs_target_ids_write(struct file *file, return PTR_ERR(kbuf); nrs = kbuf; + if (!strncmp(kbuf, "paddr\n", count)) { + /* Configure the context for physical memory monitoring */ + damon_pa_set_primitives(ctx); + /* target id is meaningless here, but we set it just for fun */ + scnprintf(kbuf, count, "42 "); + } else { + /* Configure the context for virtual memory monitoring */ + damon_va_set_primitives(ctx); + } targets = str_to_target_ids(nrs, ret, &nr_targets); if (!targets) { -- 2.17.1