From patchwork Wed Dec 16 09:42:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11977149 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=ham 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 F16D3C4361B for ; Wed, 16 Dec 2020 09:49:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 829332313B for ; Wed, 16 Dec 2020 09:49:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 829332313B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0489F6B0072; Wed, 16 Dec 2020 04:49:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 002306B0073; Wed, 16 Dec 2020 04:49:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E53086B0074; Wed, 16 Dec 2020 04:49:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id CC3B56B0072 for ; Wed, 16 Dec 2020 04:49:31 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8B52B8249980 for ; Wed, 16 Dec 2020 09:49:31 +0000 (UTC) X-FDA: 77598672942.12.steel38_54180f72742b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 5F95818054D2D for ; Wed, 16 Dec 2020 09:49:31 +0000 (UTC) X-HE-Tag: steel38_54180f72742b X-Filterd-Recvd-Size: 5368 Received: from smtp-fw-9103.amazon.com (smtp-fw-9103.amazon.com [207.171.188.200]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 09:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1608112170; x=1639648170; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=jk1a1eNXyHawqdXbc/seXg9Qwshk6tmctCaAv0I6QJY=; b=stWTVIo3oDNPxYQKhdmGxUNbhgCeWUhYdlQn5ecpzPsfhfgkdsIG1edA UJB1D8ldT5yoMmYqc/EMOODRZ5F/9ILor/3zQcsbDEbxJITdrt+O17K1S kExdlGgtfnG+NbS5Wvq0j4cVHgAt6bP5ks7tcltCx30VuNyDpythIrrCK 4=; 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 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) 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: 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) {