From: Xin Hao <xhao@linux.alibaba.com>
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 [thread overview]
Message-ID: <008dfc6bc5edb802f759227111f5a0eff153e279.1639066954.git.xhao@linux.alibaba.com> (raw)
In-Reply-To: <cover.1639066954.git.xhao@linux.alibaba.com>
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 <xhao@linux.alibaba.com>
---
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;
--
2.31.0
next prev parent reply other threads:[~2021-12-09 16:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 16:33 [PATCH V1 0/2] mm/damon: Do little changes Xin Hao
2021-12-09 16:33 ` Xin Hao [this message]
2021-12-09 16:33 ` [PATCH V1 2/2] mm/damon: Modify the display form of damon tracepoint Xin Hao
2021-12-09 16:46 ` SeongJae Park
2021-12-10 3:36 ` Xin Hao
2021-12-10 8:18 ` SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=008dfc6bc5edb802f759227111f5a0eff153e279.1639066954.git.xhao@linux.alibaba.com \
--to=xhao@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox