From patchwork Thu Dec 9 16:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12667025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C86AC433EF for ; Thu, 9 Dec 2021 16:34:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4CEF6B0073; Thu, 9 Dec 2021 11:33:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DFCB56B0074; Thu, 9 Dec 2021 11:33:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEAF06B0075; Thu, 9 Dec 2021 11:33:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id BFF636B0073 for ; Thu, 9 Dec 2021 11:33:46 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8093C1837643C for ; Thu, 9 Dec 2021 16:33:36 +0000 (UTC) X-FDA: 78898801632.09.9F42392 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf19.hostedemail.com (Postfix) with ESMTP id E97D01A0005 for ; Thu, 9 Dec 2021 16:33:34 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0V-4XSLS_1639067604; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0V-4XSLS_1639067604) by smtp.aliyun-inc.com(127.0.0.1); Fri, 10 Dec 2021 00:33:26 +0800 From: Xin Hao To: sj@kernel.org Cc: xhao@linux.alibaba.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH V1 1/2] mm/damon/dbgfs: Avoid target_ids display wrong pid value Date: Fri, 10 Dec 2021 00:33:16 +0800 Message-Id: <008dfc6bc5edb802f759227111f5a0eff153e279.1639066954.git.xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E97D01A0005 X-Stat-Signature: isisetqwhf8cq5wb7bufcmgjx1s59mm6 Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-HE-Tag: 1639067614-258979 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: The return value of pid_vnr() is pid_t type which is defined by 'int', this may get a wrong pid value, if we set the return value type as 'unsigned long'. So there fix it. Signed-off-by: Xin Hao --- mm/damon/dbgfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 991b7fa0e858..97eebfb70ddf 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -281,17 +281,15 @@ static inline bool targetid_is_pid(const struct damon_ctx *ctx) static ssize_t sprint_target_ids(struct damon_ctx *ctx, char *buf, ssize_t len) { struct damon_target *t; - unsigned long id; - int written = 0; + int id, written = 0; int rc; damon_for_each_target(t, ctx) { - id = t->id; if (targetid_is_pid(ctx)) /* Show pid numbers to debugfs users */ - id = (unsigned long)pid_vnr((struct pid *)id); + id = (int)pid_vnr((struct pid *)t->id); - rc = scnprintf(&buf[written], len - written, "%lu ", id); + rc = scnprintf(&buf[written], len - written, "%d ", id); if (!rc) return -ENOMEM; written += rc; From patchwork Thu Dec 9 16:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12667021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBB44C433EF for ; Thu, 9 Dec 2021 16:33:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 599F66B0072; Thu, 9 Dec 2021 11:33:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 549506B0073; Thu, 9 Dec 2021 11:33:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 438D86B0074; Thu, 9 Dec 2021 11:33:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 330806B0072 for ; Thu, 9 Dec 2021 11:33:43 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E8450824556B for ; Thu, 9 Dec 2021 16:33:32 +0000 (UTC) X-FDA: 78898801464.10.888F2AF Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf24.hostedemail.com (Postfix) with ESMTP id 508DE180003 for ; Thu, 9 Dec 2021 16:33:30 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0V-4XSLS_1639067604; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0V-4XSLS_1639067604) by smtp.aliyun-inc.com(127.0.0.1); Fri, 10 Dec 2021 00:33:27 +0800 From: Xin Hao To: sj@kernel.org Cc: xhao@linux.alibaba.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH V1 2/2] mm/damon: Modify the display form of damon tracepoint Date: Fri, 10 Dec 2021 00:33:17 +0800 Message-Id: <1e019e8ffe8c040376ec59e918d301058cc58ade.1639066954.git.xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 508DE180003 X-Stat-Signature: 86hbo83mgdpg8s9psuay7htu86xbbqxk Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-HE-Tag: 1639067610-396103 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000177, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When I use the perf command to record damon monitor data, like below. # perf record -e damon:damon_aggregated # perf script ...target_id=18446462667479739520 nr_regions=13 281472805928960-281472942936064... ...target_id=18446462667479739520 nr_regions=13 281472942936064-281473080008704... ...target_id=18446462667479739520 nr_regions=13 281473080008704-281473216634880... From a user's point of view, the 'target_id' and 'damon_region' which displays in decimal are not very friendly, So there do some changes, keep the 'target_id' display consistent with 'dbgfs/target_ids' interface and 'damon_region' is displayed in hexadecimal, just like below. # perf record -e damon:damon_aggregated # perf script ...target_id=5522 nr_regions=14 ffff716a3000-ffff79893000... ...target_id=5522 nr_regions=14 ffff79893000-ffff819dc000... ...target_id=5522 nr_regions=14 ffff819dc000-ffff89bd9000... Signed-off-by: Xin Hao --- include/trace/events/damon.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.31.0 diff --git a/include/trace/events/damon.h b/include/trace/events/damon.h index 99ffa601e351..67de51814f4c 100644 --- a/include/trace/events/damon.h +++ b/include/trace/events/damon.h @@ -17,7 +17,7 @@ TRACE_EVENT(damon_aggregated, TP_ARGS(t, r, nr_regions), TP_STRUCT__entry( - __field(unsigned long, target_id) + __field(int, target_id) __field(unsigned int, nr_regions) __field(unsigned long, start) __field(unsigned long, end) @@ -26,7 +26,7 @@ TRACE_EVENT(damon_aggregated, ), TP_fast_assign( - __entry->target_id = t->id; + __entry->target_id = (int)pid_vnr((struct pid *)t->id); __entry->nr_regions = nr_regions; __entry->start = r->ar.start; __entry->end = r->ar.end; @@ -34,7 +34,7 @@ TRACE_EVENT(damon_aggregated, __entry->age = r->age; ), - TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u %u", + TP_printk("target_id=%u nr_regions=%u %lx-%lx: %u %u", __entry->target_id, __entry->nr_regions, __entry->start, __entry->end, __entry->nr_accesses, __entry->age)