From patchwork Tue Mar 30 09:05:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12172093 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 B6B8DC433C1 for ; Tue, 30 Mar 2021 09:06:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4F3AA6195D for ; Tue, 30 Mar 2021 09:06:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F3AA6195D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BF7BB6B0093; Tue, 30 Mar 2021 05:06:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCE926B0096; Tue, 30 Mar 2021 05:06:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AEB96B0095; Tue, 30 Mar 2021 05:06:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 66F286B0093 for ; Tue, 30 Mar 2021 05:06:12 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1F2B3181AF5C4 for ; Tue, 30 Mar 2021 09:06:12 +0000 (UTC) X-FDA: 77975958984.23.21A82E4 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf30.hostedemail.com (Postfix) with ESMTP id CB83FE0011F3 for ; Tue, 30 Mar 2021 09:06:03 +0000 (UTC) Received: by mail-qt1-f179.google.com with SMTP id l6so3171169qtq.2 for ; Tue, 30 Mar 2021 02:06:09 -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=R5PUWdERG+RkIKWxog/OwoHO5kXT1/1TlXkHhb3aLxDwHrGIsXYqKYLOS4HpzvjMeI SLJJ06ttW25PdsqtX+CXByEAMhTtGk7tgvyocRjXEJnCcTD12ijROBeYC4FucKjuHB/E IgpJOFD+hLyRkuv0Ey5DurWKSokHx4RcljxJrCRHPSXYbNWgDyvIhXGwOTl0IugQNdem lS5G86JTzLvcePdylQe3NG+ZOdem5sY791uiYtTBzg/8v6wqXcXUuOFj+JWxRbduO2B/ vJbW4yUno7gduLt2Fw4CU6FQrjZylzprzcLrWi4t3TMGIyxvIb8uroenBzxK2uDwSHqQ ZsTA== 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=FRRse4jMaJ6BSuNLMcAPhzpg8XTw+6aMZttC94dUHo7Fuep4lAkkqdW/mVA7ktbE8b drIyV+W5OcoMvEfF0YigOOscjYUtvFXs0QWqte77vUEAu/XGUcQltCmn1ZlvjiwQnYJZ tP2phMfPj4c5B8SnoJlAdxfzvCzDfLmjiqj6KNOHgoNuqygSAmoHz9olznDAHL/3B9nL gGbiOy1HM0yh2gY5x14PpONHq8JK+iYC5Eqj1yU6ofXMSi2zo87MD67A+0LofMPeF+dS xK01IWMGKFgIQ1r5yfSxZp1dMosWQoxGZkNVnDTZrV/z66bPZeYFDi/s62Da696bbn1K PQqw== X-Gm-Message-State: AOAM533pOJu3lN3zobr8yOceTVFKbwX0MmjJ22NHk7SjGn6tdzJnuBTB uV/yWx2dkZlDc1CmkoPtFfI= X-Google-Smtp-Source: ABdhPJw/fcEzbKkgvJDaEm+Jful1mHeW1N2jv4YLlOgs/xUbbkQnP+Cj1nNonnxoZvS68qpQvVPZlQ== X-Received: by 2002:ac8:431e:: with SMTP id z30mr26040963qtm.216.1617095168611; Tue, 30 Mar 2021 02:06:08 -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 8sm14630011qkc.32.2021.03.30.02.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 02:06:08 -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, 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 v26 06/13] mm/damon: Add a tracepoint Date: Tue, 30 Mar 2021 09:05:30 +0000 Message-Id: <20210330090537.12143-7-sj38.park@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210330090537.12143-1-sj38.park@gmail.com> References: <20210330090537.12143-1-sj38.park@gmail.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CB83FE0011F3 X-Stat-Signature: 4zgtwsp9iwwyrtotfie7ce716yi57xt7 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=mail-qt1-f179.google.com; client-ip=209.85.160.179 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617095163-892925 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 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; + } } }