Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp530500ybh; Wed, 18 Mar 2020 04:33:48 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsxqzqIFZK4NOHqV/5HJWuLZEe/W9VyuDHsCMPwWm6U970EhXmGVoeF02gStjDnC2AGncJd X-Received: by 2002:aca:37c3:: with SMTP id e186mr2789317oia.155.1584531228233; Wed, 18 Mar 2020 04:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584531228; cv=none; d=google.com; s=arc-20160816; b=R9vzucSwYH/xCT+/jvh80MPt0zPj7WS2gzueRGWWJq+WgYiOdh4gFA310j08HRDMg7 cN3KiWDQ0MmpDvzYJ0fur99p1ibwMSGlT7VyKG6NKzQkPUlwPhgkBFdhithfIk7dC3Wb r9wZiWQx0NZhNKE8ZizfagzRYRsye74Rrz4YyRueWTn9lmW4QBBDsZfgUau96fJxuwpn DO61kKKTkTSaHwRRu1yiXGslcPsGeEnEP45HpbDTUyY16Y6Bs3lAW6ca7bna679gK9e+ tM9oqTkzgfypY++8OdiVfo8khcm7PzDofsSNW1KynEh86O7Q8jLOuPZcJqm5B42g60Gl OqLw== 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=IIweUbJ6ywSxmEcEsqVWoNZ/WqTFK20tUG13PKDxXU8=; b=gD5A6EjCXEPGdQ+8M+53tNIpJ3pvaGly7d4mjjEE7CVC8fzQ7IPF8adFSgIk0Jiizv 4hIF3wIv0Pya1W/wJZVROTiHZRXu9Aoil1tTbvNTEbAiogVzIK2cxePiJHnIEFt50B12 5As+9Vqy6CO2PRlFmF7NriCKO5LZgNKvYIms/Y8gUjGRnJpLX79l+bt2D1k5l5ogmNsp DtF4ZQsFVkOqJjlloXGjv5ViQTUrH7ffztA6QZE4dwohUkWzwouLcV1ggBwEIjnaG+pq t59oplyPjvbcXE6wBLr1jAR6NtVStXc7K6pz+TXhpn70r8wFCxw6ciqHT6rTDFI+qVeN shJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=SlpBCYgO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id y65si3112941oie.92.2020.03.18.04.33.35; Wed, 18 Mar 2020 04:33:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=SlpBCYgO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727450AbgCRLcz (ORCPT + 99 others); Wed, 18 Mar 2020 07:32:55 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:42483 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgCRLcy (ORCPT ); Wed, 18 Mar 2020 07:32:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1584531174; x=1616067174; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IIweUbJ6ywSxmEcEsqVWoNZ/WqTFK20tUG13PKDxXU8=; b=SlpBCYgOcuiVX8O+xraTgbBjl8ei7tsivi8p6D047Zp5yP6uYJyYGGPx +IhlVEtIcd3bDXVmtvrH5iwOFpZll7+Mf7eKHa+nSqgnlkn8jgaa9fxpZ myAY+duIJzAr09FGNQFJCmrcQAKfKgmhhLBYzAm8rURdn+A4BM2ID59r9 E=; IronPort-SDR: ETsYFwWCXdqiKtV6jfvVJ1un7t8wySL4whgPWQh+9JbcrMmEtsPTXOPvBfEhrozL4akLUT1+Cz xz06oDSJsiKw== X-IronPort-AV: E=Sophos;i="5.70,567,1574121600"; d="scan'208";a="33271215" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1e-27fb8269.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 18 Mar 2020 11:32:51 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-27fb8269.us-east-1.amazon.com (Postfix) with ESMTPS id 428FFA0333; Wed, 18 Mar 2020 11:32:40 +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.1236.3; Wed, 18 Mar 2020 11:32:40 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.161.235) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 11:32:26 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 07/15] mm/damon: Implement callbacks Date: Wed, 18 Mar 2020 12:27:14 +0100 Message-ID: <20200318112722.30143-8-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318112722.30143-1-sjpark@amazon.com> References: <20200318112722.30143-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.235] X-ClientProxiedBy: EX13D28UWC001.ant.amazon.com (10.43.162.166) 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 implements callbacks for DAMON. Using this, DAMON users can install their callbacks for each step of the access monitoring so that they can do something interesting with the monitored access patterns online. For example, callbacks can report the monitored patterns to users or do some access pattern based memory management such as proactive reclamations or access pattern based THP promotions/demotions decision makings. Signed-off-by: SeongJae Park --- include/linux/damon.h | 4 ++++ mm/damon.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 64e327400749..cad3ee3d78db 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -56,6 +56,10 @@ struct damon_ctx { struct rnd_state rndseed; struct list_head tasks_list; /* 'damon_task' objects */ + + /* callbacks */ + void (*sample_cb)(struct damon_ctx *context); + void (*aggregate_cb)(struct damon_ctx *context); }; int damon_set_pids(struct damon_ctx *ctx, unsigned long *pids, ssize_t nr_pids); diff --git a/mm/damon.c b/mm/damon.c index 535337529d20..2e8af1ce4389 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -787,9 +787,13 @@ static int kdamond_fn(void *data) } mmput(mm); } + if (ctx->sample_cb) + ctx->sample_cb(ctx); if (kdamond_aggregate_interval_passed(ctx)) { kdamond_merge_regions(ctx, max_nr_accesses / 10); + if (ctx->aggregate_cb) + ctx->aggregate_cb(ctx); kdamond_reset_aggregated(ctx); kdamond_split_regions(ctx); } -- 2.17.1