Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp397316pxf; Thu, 18 Mar 2021 03:11:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmo5X4I8AHAGsdglHpE+Oh1/QbTKsJlEBDQBP/+gCS1sgrzpYvHvhb3bSPUtYyhoscEAwg X-Received: by 2002:aa7:c342:: with SMTP id j2mr2705980edr.8.1616062310664; Thu, 18 Mar 2021 03:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616062310; cv=none; d=google.com; s=arc-20160816; b=LOV5YWzNFrpXey1aMj9LAY6zGXZktZin4NCLTusQHJoxrknj/Bmz9lylPoQzJqKUDU q0AFINNSR52Ul1hcCdE89JxiQI6IBcoWfD3DEVVt1tQTMBaMFREKAg7f9lACJzy+mTOE B79aMZNnyZsGe/fhqXx9xUMpSraL6D7NJc9kK+CYAcjdk2mGi8i07BbFsa+byfZHKjl1 rtSsV1vS2v9uSTTCfydcVw1jiHkE091DbANNnNSTIU6mKsHso+TUzMsWodYFZaug7AWI uq5Np5F5iNWZveJYqlJGWcCFLj/4ibzMGCOLJvto+9dC/vx2tV8zK/gsilwPuB1IE93Y vDvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=CvzI94r9LiC7RH+dtcaRZqda/Y720VadPnKc/47pvNM=; b=ycK3byJBkusTEkAAsMMMSMvQYiZvE3iUiZJSs21OtpVuvAN4vZ4x1s1umYGFx2oXp+ Lot4DmwM8vTrOCCxk7/I6GVhCJ1u+6S0OjkxHYV/VRWG0Dd0gA9baV+sWEx33Z7wQs+c /Qz7qBrdksKLtEl7q5My215Eha4+vVzMmxOIpILzVswNLzLxjD2nYlmYYRX6I7AykN/+ 9eu82QYJ2+KozBFiWrmKaz48DrZptBQugsox+FV8QMhiGdkhLd3DD1OFBKe5FjdwQjtG wArur8sdYK24hEA5BkNvUVxr2k9rEZM5jbZAYmI90y87xo/9AmfTaomYYnRO+x4LUHRC Y2Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PuZxn3uG; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si1171431ejx.201.2021.03.18.03.11.27; Thu, 18 Mar 2021 03:11:50 -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=@gmail.com header.s=20161025 header.b=PuZxn3uG; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbhCRKKe (ORCPT + 99 others); Thu, 18 Mar 2021 06:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbhCRKKO (ORCPT ); Thu, 18 Mar 2021 06:10:14 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC467C06174A; Thu, 18 Mar 2021 03:10:13 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id l132so1376947qke.7; Thu, 18 Mar 2021 03:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CvzI94r9LiC7RH+dtcaRZqda/Y720VadPnKc/47pvNM=; b=PuZxn3uGlJkbrdBQV2EQcDqKqIG7oPBL7MI8XpTQDyVnCy3rTmqhcG04xOIbBbTjsW 75MlqlkVSZAf95wyHFsoDdF/lPPTyO5q+zt5n2TUlvXeOsYnkO5Sv9UogN7yM8f6kzSm Yt2IE057ESuiBBCFFlfptILYA2UL35R2KRz7yukFM+qfeWu0IbGOzJcEdUMrdInCykRp VQAhaPr/eReOJJDXRfgP2BZaEhl+RrEClDSVCCPFIz0/YoI/7CBIrh3A3KPiB1VCzzUx 865HDpfAxvQCHNiwfeTTLrgfuTScQYL44CS2svog0qt55gs7pmClneKcyFJjVGG7OIRH yCEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CvzI94r9LiC7RH+dtcaRZqda/Y720VadPnKc/47pvNM=; b=GXAzfjZ1px0CY69HFkIizgJK6vK9b1lAljvCkAdIsowaqrcQCS2y2MTncXKd+0+yBK 65k5R0dFA52PSQ9wBvyDD/2HP98D85MgvhreKIvYAkBObkfSO54spXysfZMLjLC6hnYi PFdf5kThyhR2YCIH4OwO10kbNZ12qKEZStqsJyoFlkNMRM8maNFgUVx575qaUdbg6tcz 8uYe3j07t6VLFqkTe7YU33ZllKXzHLiIKyiVo/T22J5nv91X3l/FGDlIJRPvk8CP8i8I J1k5pDp+929r2wq0Iaz6BSS52/JnvH+/yWQTXwDSj6CbILln1lQIQYYxW0BddZ55aeCP Fg5w== X-Gm-Message-State: AOAM532aDxGJ8fXEk3ZGnzOH5HqaRzFcLRA9vwRdNNPcvXAfj0jm3WH5 XFDOQz3beF+ohNx8iaKBtag= X-Received: by 2002:a37:270c:: with SMTP id n12mr3496348qkn.277.1616062213034; Thu, 18 Mar 2021 03:10:13 -0700 (PDT) Received: from localhost.localdomain (ec2-35-169-212-159.compute-1.amazonaws.com. [35.169.212.159]) by smtp.gmail.com with ESMTPSA id d16sm1358101qka.43.2021.03.18.03.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 03:10:12 -0700 (PDT) From: sj38.park@gmail.com To: akpm@linux-foundation.org Cc: SeongJae Park , Jonathan.Cameron@Huawei.com, acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, brendanhiggins@google.com, corbet@lwn.net, david@redhat.com, dwmw@amazon.com, elver@google.com, fan.du@intel.com, foersleo@amazon.de, gthelen@google.com, mgorman@suse.de, minchan@kernel.org, mingo@redhat.com, namhyung@kernel.org, peterz@infradead.org, riel@surriel.com, rientjes@google.com, rostedt@goodmis.org, rppt@kernel.org, shakeelb@google.com, shuah@kernel.org, sj38.park@gmail.com, snu@amazon.de, vbabka@suse.cz, vdavydov.dev@gmail.com, zgf574564920@gmail.com, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v25 06/13] mm/damon: Add a tracepoint Date: Thu, 18 Mar 2021 10:08:49 +0000 Message-Id: <20210318100856.34715-7-sj38.park@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210318100856.34715-1-sj38.park@gmail.com> References: <20210318100856.34715-1-sj38.park@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park This commit adds a tracepoint for DAMON. It traces the monitoring results of each region for each aggregation interval. Using this, DAMON can easily integrated with tracepoints supporting tools such as perf. Signed-off-by: SeongJae Park Reviewed-by: Leonard Foerster Reviewed-by: Steven Rostedt (VMware) --- include/trace/events/damon.h | 43 ++++++++++++++++++++++++++++++++++++ mm/damon/core.c | 7 +++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 include/trace/events/damon.h diff --git a/include/trace/events/damon.h b/include/trace/events/damon.h new file mode 100644 index 000000000000..2f422f4f1fb9 --- /dev/null +++ b/include/trace/events/damon.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM damon + +#if !defined(_TRACE_DAMON_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DAMON_H + +#include +#include +#include + +TRACE_EVENT(damon_aggregated, + + TP_PROTO(struct damon_target *t, struct damon_region *r, + unsigned int nr_regions), + + TP_ARGS(t, r, nr_regions), + + TP_STRUCT__entry( + __field(unsigned long, target_id) + __field(unsigned int, nr_regions) + __field(unsigned long, start) + __field(unsigned long, end) + __field(unsigned int, nr_accesses) + ), + + TP_fast_assign( + __entry->target_id = t->id; + __entry->nr_regions = nr_regions; + __entry->start = r->ar.start; + __entry->end = r->ar.end; + __entry->nr_accesses = r->nr_accesses; + ), + + TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u", + __entry->target_id, __entry->nr_regions, + __entry->start, __entry->end, __entry->nr_accesses) +); + +#endif /* _TRACE_DAMON_H */ + +/* This part must be outside protection */ +#include diff --git a/mm/damon/core.c b/mm/damon/core.c index b36b6bdd94e2..912112662d0c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -13,6 +13,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + /* Get a random number in [l, r) */ #define damon_rand(l, r) (l + prandom_u32_max(r - l)) @@ -388,8 +391,10 @@ static void kdamond_reset_aggregated(struct damon_ctx *c) damon_for_each_target(t, c) { struct damon_region *r; - damon_for_each_region(r, t) + damon_for_each_region(r, t) { + trace_damon_aggregated(t, r, damon_nr_regions(t)); r->nr_accesses = 0; + } } } -- 2.17.1