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=-10.0 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 B6CCFC54E8D for ; Mon, 11 May 2020 12:37:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7144620746 for ; Mon, 11 May 2020 12:37:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="syp74Bd8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7144620746 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 1A511900042; Mon, 11 May 2020 08:37:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1568A900036; Mon, 11 May 2020 08:37:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01F39900042; Mon, 11 May 2020 08:37:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id DAD6B900036 for ; Mon, 11 May 2020 08:37:50 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9AC69180AD80F for ; Mon, 11 May 2020 12:37:50 +0000 (UTC) X-FDA: 76804389900.18.spade53_617f49572dc38 X-HE-Tag: spade53_617f49572dc38 X-Filterd-Recvd-Size: 5085 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Mon, 11 May 2020 12:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1589200670; x=1620736670; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3qzhEO45OCs2xK7YXoqTIw9W4rei20Zjp8AHQQpGetw=; b=syp74Bd8T5ReoZdWi1ltp2Myfn3FlYxl7d7TmpWmtVLh+auhFD4YhJOz qHRnAkgB87xCtnuRk3F4Rl0MrW3Tlq8A3vcYqA/BylCb9fXKbKb5DTXEp w0th/WvHiREuB6Ev1LjuPuAURkVz2Yz5+VgMD4y3Td1if4jPM6f44Vd1x w=; IronPort-SDR: ijEDsp/2QAQashspAjWy4I7QTeWERsghd33wV575sjyRQpFaalMCuVZTTCmxztYXlWMYowWyGA DFMl5rNxfuRg== X-IronPort-AV: E=Sophos;i="5.73,380,1583193600"; d="scan'208";a="43930682" Received: from sea32-co-svc-lb4-vlan2.sea.corp.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.47.23.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 11 May 2020 12:37:47 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id D4E0DA1FD2; Mon, 11 May 2020 12:37:35 +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.1497.2; Mon, 11 May 2020 12:37:35 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.161.253) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 May 2020 12:37:19 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 08/16] mm/damon: Implement callbacks Date: Mon, 11 May 2020 14:32:54 +0200 Message-ID: <20200511123302.12520-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511123302.12520-1-sjpark@amazon.com> References: <20200511123302.12520-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.253] X-ClientProxiedBy: EX13D06UWC001.ant.amazon.com (10.43.162.91) 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 62b9f90ed87b..264569b21502 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -55,6 +55,10 @@ struct damon_ctx { struct mutex kdamond_lock; 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, int *pids, ssize_t nr_pids); diff --git a/mm/damon.c b/mm/damon.c index 3d0f9428c925..6b01aa641503 100644 --- a/mm/damon.c +++ b/mm/damon.c @@ -851,6 +851,8 @@ static int kdamond_fn(void *data) kdamond_init_regions(ctx); while (!kdamond_need_stop(ctx)) { kdamond_prepare_access_checks(ctx); + if (ctx->sample_cb) + ctx->sample_cb(ctx); usleep_range(ctx->sample_interval, ctx->sample_interval + 1); @@ -858,6 +860,8 @@ static int kdamond_fn(void *data) 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