From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 4/4] trace-cmd: Move find_pid_by_cid() into add_guest()
Date: Thu, 28 Apr 2022 11:06:35 -0400 [thread overview]
Message-ID: <20220428150635.789051-5-rostedt@goodmis.org> (raw)
In-Reply-To: <20220428150635.789051-1-rostedt@goodmis.org>
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
To simplify the code even more, move the find_pid_by_cid() into
add_guest() to map the main pid process to the cid.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-vm.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/tracecmd/trace-vm.c b/tracecmd/trace-vm.c
index bf2b0695d09b..cabe4baffecb 100644
--- a/tracecmd/trace-vm.c
+++ b/tracecmd/trace-vm.c
@@ -86,6 +86,8 @@ static void find_tasks(struct trace_guest *guest)
closedir(dir);
}
+static void find_pid_by_cid(struct trace_guest *guest);
+
static struct trace_guest *add_guest(unsigned int cid, const char *name)
{
struct trace_guest *guest;
@@ -103,6 +105,7 @@ static struct trace_guest *add_guest(unsigned int cid, const char *name)
guest->cid = cid;
guest->pid = -1;
+ find_pid_by_cid(guest);
find_tasks(guest);
return guest;
@@ -341,11 +344,8 @@ struct trace_guest *trace_get_guest(unsigned int cid, const char *name)
if (cid > 0) {
guest = get_guest_by_cid(cid);
- if (!guest && name) {
+ if (!guest && name)
guest = add_guest(cid, name);
- if (guest)
- find_pid_by_cid(guest);
- }
}
return guest;
}
@@ -355,7 +355,6 @@ struct trace_guest *trace_get_guest(unsigned int cid, const char *name)
#define VM_CID_ID "address='"
static void read_guest_cid(char *name)
{
- struct trace_guest *guest;
char *cmd = NULL;
char line[512];
char *cid;
@@ -377,9 +376,7 @@ static void read_guest_cid(char *name)
cid_id = strtol(cid + strlen(VM_CID_ID), NULL, 10);
if ((cid_id == INT_MIN || cid_id == INT_MAX) && errno == ERANGE)
continue;
- guest = add_guest(cid_id, name);
- if (guest)
- find_pid_by_cid(guest);
+ add_guest(cid_id, name);
break;
}
--
2.35.1
prev parent reply other threads:[~2022-04-28 15:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 15:06 [PATCH 0/4] trace-cmd: Clean ups for agent communications Steven Rostedt
2022-04-28 15:06 ` [PATCH 1/4] trace-cmd: Move add_guest_info() into trace-vm.c Steven Rostedt
2022-04-28 15:06 ` [PATCH 2/4] trace-cmd: Simplify add_guest() Steven Rostedt
2022-04-28 15:06 ` [PATCH 3/4] trace-cmd: Move find_tasks() into add_guest() Steven Rostedt
2022-04-28 15:06 ` Steven Rostedt [this message]
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=20220428150635.789051-5-rostedt@goodmis.org \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.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;
as well as URLs for NNTP newsgroup(s).