Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1841292ybk; Mon, 11 May 2020 05:42:05 -0700 (PDT) X-Google-Smtp-Source: APiQypImkkCzKSdfwIz4V8apWDHjfh4sDrwx7MJQ4+8WTs1YtTaSHX7PZU8VCrJOK5i4qAVtfBGi X-Received: by 2002:aa7:d4cd:: with SMTP id t13mr13038712edr.30.1589200924976; Mon, 11 May 2020 05:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589200924; cv=none; d=google.com; s=arc-20160816; b=PK2Pkfn6h1k98lLIP9xO02kxcYJ51Z49VUh0deJVnlUoizIt9AmhWxSQDbDYOe89+D JPKu5NGKzyYwKI5BZqIZQ8DeTeKKcxxMmIKNaSm7hIdVBNL4I1NkcJSXMuTISH3EqSNA ogDOWKx8atDtl1550tWVTOaJIngRzktU1VHfnL7POK3jWk2Atw5XWbkINCVJ+4u3hbXD VArvL1hzuVXb9FS+DA4u833wOvqEIQzteAmuZhDCgmlO7nLrAVOWdfR18mEeb9cd24wS 7U93nnSNu629I8S/jkjKzvgyn2fvQ+wFqmlp8/mHT/A2Q/1XvWJ6xk0yVzc4EXyKC4If L0Ng== 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=3qzhEO45OCs2xK7YXoqTIw9W4rei20Zjp8AHQQpGetw=; b=vOMG/e54gjMFHSB8lYRkccgW2jDMZ+KeLWwJUEZar+JYe4iKyNnCbD5lI3LXZIdPj6 UhciMLLENcoukTYfsFTy7J9e2erbHXbcshmUi/ONBaa12p7uehReaELOeC/7X2K6i+mG YH1Wzek6nEIk++5Yq2szgHkX7GC0SDvKQo0YSVEiEO+YB/iFdDT/tMfNvj+zYNpCZhkS ED3VVXFFeWIZDlw8zGO0d6tnwCd2fDKAIH7NCDC1m7ytcJgIqZOONOJiC66tuL3VGL+q UoFzxmtQATCZTIG96ShgJmSZRwjWA0OYQyq3eqyCGdgJRH4NYUCDAwrbTJLRtGx6A8O/ LbBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=DbELwaiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id w11si5727616ede.42.2020.05.11.05.41.41; Mon, 11 May 2020 05:42:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=DbELwaiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729982AbgEKMhu (ORCPT + 99 others); Mon, 11 May 2020 08:37:50 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:51339 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbgEKMht (ORCPT ); Mon, 11 May 2020 08:37:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1589200669; x=1620736669; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3qzhEO45OCs2xK7YXoqTIw9W4rei20Zjp8AHQQpGetw=; b=DbELwaiEUOXUdXMnMWAftRS3mMEyp8FRSzvxtOqBXUOgWwpryO1jA9kF 8LKAdnrWTBY9Y+pECtX3tMXqu3V4UZaS6z2vdTe7McvFA1ODxFA4kGp2j D7Q3/xEu4MaUFroohH3FZ+eWLeAkSKCxgLQzXmPePHfNqBym3CP8j5K1T s=; 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) 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 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