From patchwork Wed Mar 18 11:27:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11445013 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F19214DD for ; Wed, 18 Mar 2020 11:32:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A28520771 for ; Wed, 18 Mar 2020 11:32:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="r2Pzfefe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A28520771 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 57EED6B000D; Wed, 18 Mar 2020 07:32:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 52E6D6B006C; Wed, 18 Mar 2020 07:32:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41F2C6B0073; Wed, 18 Mar 2020 07:32:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 2C5856B000D for ; Wed, 18 Mar 2020 07:32:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CD5268245571 for ; Wed, 18 Mar 2020 11:32:54 +0000 (UTC) X-FDA: 76608271068.21.smoke32_19614d8e5b353 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,prvs=339ded45b=sjpark@amazon.com,,RULES_HIT:30054:30064,0,RBL:207.171.190.10:@amazon.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: smoke32_19614d8e5b353 X-Filterd-Recvd-Size: 4749 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 18 Mar 2020 11:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1584531175; x=1616067175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IIweUbJ6ywSxmEcEsqVWoNZ/WqTFK20tUG13PKDxXU8=; b=r2Pzfefe1BUMtbCotQrPl/iIIqzUqOresoK7kcW3RlXjRLQ71HfaylVa rjG3DJb7FoNg06KBtDJf4nL4JgEanzeHvlARjqChf0L1P+o2BZIw85P6y VqKaZ6e1q4MK03LOGPpJIfpDO6nthk/HRWIuYaf7WvIhSfhmB4dj4JmMX Y=; 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 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) 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 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); }