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=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 9FF3BC433E0 for ; Wed, 5 Aug 2020 07:03:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6519B22B45 for ; Wed, 5 Aug 2020 07:03:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="FoBuz7+2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6519B22B45 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 0CDC86B0006; Wed, 5 Aug 2020 03:03:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07D5A6B0007; Wed, 5 Aug 2020 03:03:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E87526B000A; Wed, 5 Aug 2020 03:03:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id D22D66B0006 for ; Wed, 5 Aug 2020 03:03:24 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 72BD8180AD820 for ; Wed, 5 Aug 2020 07:03:24 +0000 (UTC) X-FDA: 77115623928.03.burn54_4004f0826fad Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id A44AA28A05A for ; Wed, 5 Aug 2020 07:03:21 +0000 (UTC) X-HE-Tag: burn54_4004f0826fad X-Filterd-Recvd-Size: 5872 Received: from smtp-fw-4101.amazon.com (smtp-fw-4101.amazon.com [72.21.198.25]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Wed, 5 Aug 2020 07:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1596611002; x=1628147002; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=qEyO3NjOJgBbi06zZ5Eyf5uiQGCDh0wt+SIXSMbxXjs=; b=FoBuz7+2lJp0E7qAp5oKkZdnfS7Di8nRhkp5YiqWjk1mDv3QGgrJ7E5B RpTF6ODoSnBIuHFBJx70Z2wu2D3Q/4Kpiye0LBG+Wac9CYtY9L3sButTZ lMAw3d7h7tGilJuYeR75Q1zifNP/zufQt5IjZbo/1AlY0lzRReN+4Rx+o w=; IronPort-SDR: +oMl3lt0gfbUgWw/YdBcmZv1+Cp4lWhZOkuJP030jhL5YT/5WTvhaaVsbCnA44++IV+bR4e9SP NMyzFlBxDkeA== X-IronPort-AV: E=Sophos;i="5.75,436,1589241600"; d="scan'208";a="46228955" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 05 Aug 2020 07:03:21 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com (Postfix) with ESMTPS id BE137A21BF; Wed, 5 Aug 2020 07:03:09 +0000 (UTC) Received: from EX13D31EUA001.ant.amazon.com (10.43.165.15) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 Aug 2020 07:03:08 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.160.26) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 Aug 2020 07:02:51 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v6 07/10] mm/damon/debugfs: Support physical memory monitoring Date: Wed, 5 Aug 2020 08:59:48 +0200 Message-ID: <20200805065951.18221-8-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805065951.18221-1-sjpark@amazon.com> References: <20200805065951.18221-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.26] X-ClientProxiedBy: EX13D24UWB002.ant.amazon.com (10.43.161.159) To EX13D31EUA001.ant.amazon.com (10.43.165.15) X-Rspamd-Queue-Id: A44AA28A05A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 debugfs interface 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 callbacks of the monitoring context for the debugfs user for physical memory. This will internally add one fake monitoring target process, which has pid as -1. Unlike the virtual memory monitoring, DAMON debugfs will not automatically set the monitoring target region. Therefore, users should also set the monitoring target address region using the 'init_regions' debugfs file. While doing this, the 'pid' in the input should be '-1'. Finally, the physical memory monitoring will not automatically terminated because it has fake monitoring target process. The user should explicitly turn off the monitoring by writing 'off' to the 'monitor_on' debugfs file. Signed-off-by: SeongJae Park --- mm/damon.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mm/damon.c b/mm/damon.c index c8d834ce188d..0b6960f62ae9 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -2035,9 +2035,27 @@ static ssize_t debugfs_target_ids_write(struct file *file, return PTR_ERR(kbuf); nrs = kbuf; - if (!strncmp(kbuf, "pidfd ", 6)) { - received_pidfds = true; - nrs = &kbuf[6]; + if (!strncmp(kbuf, "paddr\n", count)) { + /* Configure the context for physical memory monitoring */ + ctx->init_target_regions = kdamond_init_phys_regions; + ctx->update_target_regions = kdamond_update_phys_regions; + ctx->prepare_access_checks = kdamond_prepare_phys_access_checks; + ctx->check_accesses = kdamond_check_phys_accesses; + ctx->target_valid = NULL; + + /* target id is meaningless here, but we set it just for fun */ + snprintf(kbuf, count, "-1 "); + } else { + /* Configure the context for virtual memory monitoring */ + ctx->init_target_regions = kdamond_init_vm_regions; + ctx->update_target_regions = kdamond_update_vm_regions; + ctx->prepare_access_checks = kdamond_prepare_vm_access_checks; + ctx->check_accesses = kdamond_check_vm_accesses; + ctx->target_valid = kdamond_vm_target_valid; + if (!strncmp(kbuf, "pidfd ", 6)) { + received_pidfds = true; + nrs = &kbuf[6]; + } } targets = str_to_target_ids(nrs, ret, &nr_targets); -- 2.17.1