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=-9.9 required=3.0 tests=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 4A600C35254 for ; Mon, 17 Feb 2020 10:27:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F6F42464E for ; Mon, 17 Feb 2020 10:27:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="PcW8jZ7w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729086AbgBQK1b (ORCPT ); Mon, 17 Feb 2020 05:27:31 -0500 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:39925 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729151AbgBQK1b (ORCPT ); Mon, 17 Feb 2020 05:27:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1581935251; x=1613471251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=noSLYb1CP/9HIx9FUVJwc4ZRGLjE8MhCwuZnuaCR6MU=; b=PcW8jZ7wwV6c3vlBjB3stHTnMKn95169ZeMdqPRAnrB+VC7puQKFfBdU Yi6SGYApSgg/gmVNzt93jQa+0jqUFxprnjqz1lXsfjALWY4ne1duS/ocw el2aKCS9NYOsKE6TCS458ArJXF1vpiudmRiiN2dOfIlL1lvPUsL1YZmuM Y=; IronPort-SDR: sTRa+7B9JfDyukr3WOLLnr9UI7EJR8Bgv7YWdTMMr0A8NzioSXgbBIHCBq6xL5+Jl5Nqg1ViH2 mtnDEN7ORsGQ== X-IronPort-AV: E=Sophos;i="5.70,452,1574121600"; d="scan'208";a="17477633" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2c-2225282c.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 17 Feb 2020 10:27:16 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2c-2225282c.us-west-2.amazon.com (Postfix) with ESMTPS id 8D46DA33CA; Mon, 17 Feb 2020 10:27:13 +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; Mon, 17 Feb 2020 10:27:13 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.161.214) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 17 Feb 2020 10:27:03 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 05/14] mm/damon: Implement callbacks Date: Mon, 17 Feb 2020 11:25:35 +0100 Message-ID: <20200217102544.29012-6-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217102544.29012-1-sjpark@amazon.com> References: <20200217102544.29012-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.214] X-ClientProxiedBy: EX13D30UWB004.ant.amazon.com (10.43.161.51) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@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 pattrns 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 --- mm/damon.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/damon.c b/mm/damon.c index 56725faca51f..90f61e378a61 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -83,6 +83,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); }; /* Get a random number in [l, r) */ @@ -814,9 +818,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_flush_aggregated(ctx); kdamond_split_regions(ctx); } -- 2.17.1