Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2907643pxb; Tue, 13 Apr 2021 13:18:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhga+lGh1X0vdpnT8Mmn0V09Xd/zgaP8jV0f3PhXuqBK2csS70ImtrS7oXXlE7tG2IbLE3 X-Received: by 2002:a17:90b:344e:: with SMTP id lj14mr1831724pjb.89.1618345105644; Tue, 13 Apr 2021 13:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618345105; cv=none; d=google.com; s=arc-20160816; b=onDElRVuJvaqTsurWeFvelNSlnikH8t5JCzqISUpKwT7aewNnW3aCEtZmkDUXG/AN1 rchLdX4K4lLbN0fcCWsiLYoEmiIjA0/VZwxrI7oRwIwmRO8pvlccn1OD+5iKv6i0jqhG EwILpzt9NedBVbJuTwlqrw1S+OrBDzp31YlXaNB6rWqUONbTHUogvvq4UJwM+KvEbG9+ l8uSITZL1K3uLGRzOg5WT3oDXXRHQVK5IVdEangg8n85xgC7KCyduTfdYrekqBs5I1t9 TCaOHp9sip6lN6HBuXYsk6VXEYfD7Stf+BodfPFFs1lnuxavG9m4m8sEUZ0f5JaF5eLp 89/g== 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=oFqKLkrC0pfjFDZSkQm3R6YEhdys+zZhe0jCbcfj1yhse3CXAbGrhQMXE3uF55G4g/ AbKOCRipI5X7iLfsrD5bHQshZbO7Kw5fuJd9IWiC7Y6yp5e8lhdZDxbnYyWkvG4/63z1 IbhujHEZsTpB69u4OR2NLmo3I9uB5FKOY00Agesr8Kdcj5VLy66RTKW/nX7HBz0/IxY+ zrMTHeTEcw5gMcyvKGgxoA5YI+Ay19XbpVrTgBmFUMOfRddCZCV72W3zNLRwD+Afabwz YbEQz9BUBh+vOlfQzB/RCh1cMz34PHcquQk9wkqkkJh0quEYxlunmBMjyMKdhh4zcXEV oVOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lNFCtbmP; 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 y7si15465279plg.223.2021.04.13.13.18.13; Tue, 13 Apr 2021 13:18:25 -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=lNFCtbmP; 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 S239354AbhDMOac (ORCPT + 99 others); Tue, 13 Apr 2021 10:30:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239007AbhDMO3x (ORCPT ); Tue, 13 Apr 2021 10:29:53 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B379C061756; Tue, 13 Apr 2021 07:29:32 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id o17so9525437qkl.13; Tue, 13 Apr 2021 07:29:32 -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=lNFCtbmP/CnDET2v2guZgcKJRaTNEq4G67+XiFXJOjgF49bgYTbEIre+zvMl4k7eaW a/SfDQ2UDfuLnMeHUW43yrpZ/juHoli5EZbEmJC725yS5pOLMRA8OPAJTO8GfzJWKf08 PBiMn7NfTvD+IO0uMetkP27WSv/Vf8fh14noTzRMzd7tTczsVqYzlJYm/xvJNO20movC mpSI5NFE0NvFLaEn0jBUWTwTwyewxHyG4X+LgGBYqI1LT2Ggejdpjw9ObXuRHZvBXfHH gJrbz/d9NgIV44Po6odVlPSUC1YXV57uzmDiY48U4wVtqx89VRPfp4oknMwYb3oHmFIv 1loA== 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=mPvHrguSPwZ2lngyu3CXZGxyzRRZ7pEhrRvSCMOiWiaE+AgXhRERCBjZ/F4GOxh5VY nPXHEoD7WSuq2ZNLOmT5Nifr1C4LT7ruh2PE8S+vkKP3fBIi1Ve0VxoFIZsLVZKgRJLg wnotkjuGtr4VntwE4EFjBq57FRNMW5TMxI3W39qPSKHAryyzLimYbmgZ3iCmJ6qfOSwV MrTq+rvt0iaopqJ3f0Ne1FKf5Mh+y/ks0+rfx0+1Du4xGPizd5Kb6GUxRoUf8jnueef/ zEiiJ/e0UPY2C2FuBIxDQEW0zfjySJ34xuSNlsTw06zV3h4rEM/DsKc3QrHdFTDQ1Vm+ KxIw== X-Gm-Message-State: AOAM531Nh2eQz2bbdiWht5nqXZwZXhBRy6y7sXudksCEKG3fIBHfYYl7 E25vcjjNs7yxK++WrTcQymc= X-Received: by 2002:ae9:eb57:: with SMTP id b84mr1340348qkg.378.1618324171818; Tue, 13 Apr 2021 07:29:31 -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 2sm6160911qko.134.2021.04.13.07.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 07:29:31 -0700 (PDT) From: SeongJae Park 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, greg@kroah.com, gthelen@google.com, guoju.fgj@alibaba-inc.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 v28 06/13] mm/damon: Add a tracepoint Date: Tue, 13 Apr 2021 14:28:57 +0000 Message-Id: <20210413142904.556-7-sj38.park@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210413142904.556-1-sj38.park@gmail.com> References: <20210413142904.556-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