Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1101051ybt; Tue, 7 Jul 2020 07:50:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+AToC7lYbEX0ETbPxl6wUOCKb5AYhOQi9Px5n7EXnv5aMEiLF9ckAA2QizFuM1geTrQK3 X-Received: by 2002:a17:906:fa92:: with SMTP id lt18mr35975695ejb.534.1594133454513; Tue, 07 Jul 2020 07:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594133454; cv=none; d=google.com; s=arc-20160816; b=LodOt2LCPmEn8LECndnXE61cOxwgyiz4z7O2ImXcBkirZXeW4Vk8hBxcooRBb5BfTI +CCcGuh72uLqZz/ZQ6ozlEJ3N5VKf5RAPVv+7F4RdXD5ZbE9wxt3UR3QZS02Ahx+IbfK aLZAMpYLBObrau2OE1ELB4KSn8PRNLFoXUGFBDKm7OeHcruiGO9Knt92skNw8ONb4i5i rravVDxrh86ckw0GGBUdnFQ+cQybm8GQIOm2E8UWJhXdJar60o1wayHkpnZPrHxrDRnC 8OsX3r6FBlMHYELhMZhHYeeQOUFuU5JsrfyZDUCSjVcProiEmZJO9cEX6ua1RwAltBxp 8dOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:dkim-signature; bh=+vbXcdeK7B92i/MHecWnl6/xV/nYKLymz3AseHDLU/s=; b=Lnkzr1ikJH9mxfNx76FC/WGME/DpE/OzTFUQMcM+Vmgp/HhxpaX1wE2JkP3an+6eXQ WuadZ92gbAptnaCTgYxV0nvB+i7tbIlE9SvrWDp5nTD2v08Q5hINCq/XwxHDUWBcD72Y YkuOCDnRJMkOBJQGgvyK932NL6wAGEvpJ78qzpWdqPfCzI7C+Mn5YLcbbJX806hsn3l3 PzEViSEA5TNsuYskYVnXtru+xNLnKhdeN8Un1qaZK8nuyhG3sii9+5bIrm3Kaw17g+1B oW07nqYIKKiQKw9F0n7+pZzpGDSvRNXloTOqV8Z3NwDtN4eUXbKFz7qKq/6PimJ7akg1 h7/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=mPR9oZ0d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si14838292ejb.418.2020.07.07.07.50.30; Tue, 07 Jul 2020 07:50:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=mPR9oZ0d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgGGOte (ORCPT + 99 others); Tue, 7 Jul 2020 10:49:34 -0400 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:14759 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbgGGOte (ORCPT ); Tue, 7 Jul 2020 10:49:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1594133374; x=1625669374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=+vbXcdeK7B92i/MHecWnl6/xV/nYKLymz3AseHDLU/s=; b=mPR9oZ0dAAzrnO/RDQ6RorNx3fZ0PjOEg7iPQkfI7kQJ87zdl8uezbXY BO+UdwxJWgkYuuNguUU7ifCqinJneOmws/z0zIL2k6x6LtM4Wc19wFNLV 0kECVWelRtY8znCGhN/fpbTs2Ybi25HS5kQhbRMC4cWECHrQQLbaaMgvd g=; IronPort-SDR: G9e8ExdjtutXnlRxVA52Mz/ywdj3GSFYDuMznosnWnMfocKrAI5evJKhW8obGrT9mc8Yo/yq3M FHj7tTS3hLrQ== X-IronPort-AV: E=Sophos;i="5.75,324,1589241600"; d="scan'208";a="40470401" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-859fe132.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 07 Jul 2020 14:49:31 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-859fe132.us-west-2.amazon.com (Postfix) with ESMTPS id 021E7223850; Tue, 7 Jul 2020 14:49:27 +0000 (UTC) Received: from EX13D31EUA004.ant.amazon.com (10.43.165.161) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 7 Jul 2020 14:49:27 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.161.214) by EX13D31EUA004.ant.amazon.com (10.43.165.161) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 7 Jul 2020 14:49:06 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v5 08/11] mm/damon/debugfs: Support physical memory monitoring Date: Tue, 7 Jul 2020 16:45:37 +0200 Message-ID: <20200707144540.21216-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707144540.21216-1-sjpark@amazon.com> References: <20200707144540.21216-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.214] X-ClientProxiedBy: EX13D35UWC001.ant.amazon.com (10.43.162.197) To EX13D31EUA004.ant.amazon.com (10.43.165.161) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mm/damon.c b/mm/damon.c index fb533b2ee4bf..34c418ef4e5f 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -1928,6 +1928,23 @@ static ssize_t debugfs_pids_write(struct file *file, if (IS_ERR(kbuf)) return PTR_ERR(kbuf); + 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; + + /* Set the fake target task pid as -1 */ + 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; + } + targets = str_to_pids(kbuf, ret, &nr_targets); if (!targets) { ret = -ENOMEM; -- 2.17.1