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 E2A54C11D30 for ; Mon, 24 Feb 2020 12:33:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A7EA320866 for ; Mon, 24 Feb 2020 12:33:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="esLSV08U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7EA320866 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 489F16B0006; Mon, 24 Feb 2020 07:33:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 439AA6B000A; Mon, 24 Feb 2020 07:33:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 329AA6B000C; Mon, 24 Feb 2020 07:33:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 16FB46B0006 for ; Mon, 24 Feb 2020 07:33:27 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E5791180AD807 for ; Mon, 24 Feb 2020 12:33:26 +0000 (UTC) X-FDA: 76524961212.24.place37_583d068e61020 X-HE-Tag: place37_583d068e61020 X-Filterd-Recvd-Size: 4419 Received: from smtp-fw-9101.amazon.com (smtp-fw-9101.amazon.com [207.171.184.25]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 12:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1582547607; x=1614083607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=weeHoQhUDaIKmcIzoigoC/Hxvz+bNtYyztdsYxajgwU=; b=esLSV08UVr/YcfHuleGkOynhVvHVTMLmy9YduFOm0T33YFqVF2/OZgZG XkyXUID58wBR3SjGbMvKHjegS/DiqscAWTY7umTsqBLwqxS1HlSyi/z2Y tjpJqjdKtkwuJtyYZ7qEaPotTbZIvQn/Yo1hgGukKQ+YzCt4n7IW2hcYA s=; IronPort-SDR: T83MG9QY90gwDAPmSw8L1Ibtd/ND31zWoNbmr1OGrbuZR+nxtWs9ceJNFeWTgGWNLJVwjwGxug 7ywEIbVUf5xA== X-IronPort-AV: E=Sophos;i="5.70,480,1574121600"; d="scan'208";a="18696393" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2a-22cc717f.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 24 Feb 2020 12:33:25 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2a-22cc717f.us-west-2.amazon.com (Postfix) with ESMTPS id 68FE6A23F3; Mon, 24 Feb 2020 12:33:23 +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, 24 Feb 2020 12:33:23 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.162.53) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 24 Feb 2020 12:33:11 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 05/14] mm/damon: Implement callbacks Date: Mon, 24 Feb 2020 13:30:38 +0100 Message-ID: <20200224123047.32506-6-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224123047.32506-1-sjpark@amazon.com> References: <20200224123047.32506-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.53] X-ClientProxiedBy: EX13D19UWC003.ant.amazon.com (10.43.162.184) To EX13D31EUA001.ant.amazon.com (10.43.165.15) 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 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 6a17408e83c2..554720778e8a 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