Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2396186ybv; Mon, 24 Feb 2020 04:35:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzOMwSVmp/opM//iyu4hwhe0cCBqKYJED8cy3sPNnQqyB4NX4RedmP4oeSZnb05pUCaI4g9 X-Received: by 2002:a54:4091:: with SMTP id i17mr12735776oii.99.1582547710489; Mon, 24 Feb 2020 04:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582547710; cv=none; d=google.com; s=arc-20160816; b=jg9bqjaORvb2Yz5czNUiS6h7WPO8nGBANM4WzI1xqIpptOjrxolS5/kYFqF12ZaM1n SlOmxvURF812+/d/IxZaevvQ+7jbpm1LBDnnZ8tTrEcjmIcEEeCPctfp3HTTsjFqdCV3 YVCWs9izoxwDz8Zp3ewwsOoiNTsstM5syuOOD5hIS9GsZBMOpvJB7ch6ALh+NpTu/4bu D9Vs54CeMEaZKw8nGkalAu2D2EW2GrVu91jik7/pNrYN5TcJht+h4+d4I8+qTyNhgsJz 9sASIKQ9/PnsqYxacpEH2PyzRZocM56yShoNVugbmUZYGfdcK0FT0azF7hvuyYtRN1nw Efjw== 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=weeHoQhUDaIKmcIzoigoC/Hxvz+bNtYyztdsYxajgwU=; b=erUW/1QEiIxh4jf5r01nWKDPANc3AwzyfIKnRGChvnu3XebSFHSibp2ci2ROtVWply lFRKswuxg8tcm/hg4w39+aVja2lT4WBpW4B5whUXT7EMsw4I/wO8tYwHQAh3BPrIU4yf HCH9TRAWhyMOo4Q0nXC7eupn+gpO6p8wpFV6NSdze5ZbFSwzPhzUSQBleF7fjtewjam8 AjmSzJWY/lCBsgowxlErSd0AOllGXapOgN+W3BDieGWAGiBSMjXyAPyTW9keYT34UhzD d932lP05tS72ItD81JkAdCprhWdJFVm1wiriR5NhEaeBWov9wvvLYiWcYNhRpen1Tyi/ FgTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=ECA0thfc; 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 d14si4523146oic.201.2020.02.24.04.34.58; Mon, 24 Feb 2020 04:35:10 -0800 (PST) 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=ECA0thfc; 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 S1727636AbgBXMd0 (ORCPT + 99 others); Mon, 24 Feb 2020 07:33:26 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:61969 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbgBXMd0 (ORCPT ); Mon, 24 Feb 2020 07:33:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1582547606; x=1614083606; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=weeHoQhUDaIKmcIzoigoC/Hxvz+bNtYyztdsYxajgwU=; b=ECA0thfc9tDveJzJWygM3fWRvzd2LO8g/QfLzb+2DKXhyoHWgLGLAbwK LiO3J7QwbjwsgXwkeM1tm4bn5f9FHZdGYLQdvdxnUjCcu6Frv5ZwyDL84 tAKBLxRZYRw4giqCqHTAI5H96x1aCCpAWY9rdWJqVs55/Yg5jvXZwAt9M g=; 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) 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 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