Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2480684ybt; Tue, 16 Jun 2020 07:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzuz99mSprP3zR1WGn/5zua8O0gD24UZdLCxWg307o5tFNENYXSka/xcE6pGayuGUF72wy X-Received: by 2002:a17:906:6dcd:: with SMTP id j13mr2805984ejt.131.1592316861831; Tue, 16 Jun 2020 07:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592316861; cv=none; d=google.com; s=arc-20160816; b=dLZNDahfGDPsgZL5IrBu+6puCvKZ1vibEVgpxnID5LpdKWFxylz5VBOUptWFaT1TBA k2rNOSPVcC6ra1eQld8W8eVjVeCjdVrYdpBiv9t84H8T5P6y6PsZieDBQX8+55/RxCqZ BkhZYUs46ABnxtmcvfG/kM8Ec39F2qnaMIkSg3QoXXtFBiCGx24FFSS9nyn0GEQZvAFt D7RZRejxKAcEhJM684gYaf6DtTUsP0QTl98PGw7DrFbx2abbchBB09sIZY4jIA6dYur/ 90FZJ0hyLR4OT9TXlkFB4spZJhNZ8m6hGRW5rxkoXtBprp50HqsYhAAfXEyBybrwqlIj XICQ== 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=q+Nsa1rMhPliL3hgNpWPbU9ylD4jN5dyGMzMCWUn4Uc=; b=ziCdOb9TzezYENRc2FoH8uAq2dGc1KVm/z2BEeDwZ2ldSkTvxZftWkGoHao2cgtik+ 79sbBx2b8rqf2TCnUk86GSEAyQJu8HuP3SXNRMh1MXgEYPNhxMAaHIDs4jERdGyS1Isf HeQ9SliID1t7CV4q7K7cXbstLB6Z3UNHtsg3U3XNUh7wk95OAGwYqgpt3JuQCT1cGCBi AapZVktJjky3rtn0ju8eMOqeGodY6pf6EL83lobLh5Phqjwvzw4mxO2hftthnLnM/fnb tLqE5jJvSgQFOm+9pOS31/+TX9bOhsQANXh8fjl0Dt5ctulXpYxowDgwlZ9HWtQKfyUd 4jYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=o5l0hfwK; 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 n15si11076508edt.88.2020.06.16.07.13.57; Tue, 16 Jun 2020 07:14:21 -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=o5l0hfwK; 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 S1729087AbgFPOL7 (ORCPT + 99 others); Tue, 16 Jun 2020 10:11:59 -0400 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:7908 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728596AbgFPOL6 (ORCPT ); Tue, 16 Jun 2020 10:11:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1592316718; x=1623852718; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=q+Nsa1rMhPliL3hgNpWPbU9ylD4jN5dyGMzMCWUn4Uc=; b=o5l0hfwK2Z0EmuIgxlDgUBfSJNLVna08GQpQ03i6CLf5e8UnInwT/E0a 2Jm8HdTMUwUZpbooVrmxkLNCrKCHUNYAnEuc9aVsQ7qqBiwDhi8K226II Bb3EuTEC6QVEYrEcKqEQmvOMAH8DOomTsuobiuSDUdi/YsZGMBErlgewp w=; IronPort-SDR: gbUQTKYv5Do84JwuUEoHQrXZspHuB50NpoYZYqY2xV58Iy5Y1rez1KvGKsNbiUWrPXku2YTdL5 ONNZckaOC9uw== X-IronPort-AV: E=Sophos;i="5.73,518,1583193600"; d="scan'208";a="36588935" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-53356bf6.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 16 Jun 2020 14:11:53 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-53356bf6.us-west-2.amazon.com (Postfix) with ESMTPS id 7065FA228C; Tue, 16 Jun 2020 14:11:50 +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; Tue, 16 Jun 2020 14:11:49 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.162.109) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 16 Jun 2020 14:11:18 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v4 6/8] mm/damon/debugfs: Support physical memory monitoring Date: Tue, 16 Jun 2020 16:08:11 +0200 Message-ID: <20200616140813.17863-7-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616140813.17863-1-sjpark@amazon.com> References: <20200616140813.17863-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.109] X-ClientProxiedBy: EX13D01UWB004.ant.amazon.com (10.43.161.157) To EX13D31EUA001.ant.amazon.com (10.43.165.15) 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 fdf3425befb2..efd6428bd85e 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -1918,6 +1918,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