From: Steven Rostedt <rostedt@goodmis.org>
To: Michael Sartain <mikesart@fastmail.com>
Cc: linux-kernel@vger.kernel.org, Joel Fernandes <joelaf@google.com>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] tracing: Add saved_tgids file to show cached pid to tgid mappings
Date: Fri, 30 Jun 2017 17:50:57 -0400 [thread overview]
Message-ID: <20170630175057.71de9d39@gandalf.local.home> (raw)
In-Reply-To: <20170630171748.sf5rnjb7pyws6ewu@mikesart-cos>
On Fri, 30 Jun 2017 11:17:50 -0600
Michael Sartain <mikesart@fastmail.com> wrote:
> Export the cached pid / tgid mappings to userspace. This allows user
> apps to translate the pids from a trace to their respective thread
> group.
>
> Example saved_tgids file with pid / tgid values separated by ' ':
>
> # cat saved_tgids
> 1048 1048
> 1047 1047
> 7 7
> 1049 1047
> 1054 1047
> 1053 1047
>
> [ Impact: let userspace apps reading binary buffer know tgid's ]
Impact line? Linus put a kibosh on this a while ago...
https://lkml.org/lkml/2009/4/15/296
Although, I will admit that this line is actually useful. Just remove
the brackets.
>
> Signed-off-by: Michael Sartain <mikesart@fastmail.com>
> ---
> kernel/trace/trace.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 59 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 68c214b..ca84c97 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -4692,6 +4692,7 @@ static const struct file_operations tracing_readme_fops = {
> static void *saved_cmdlines_next(struct seq_file *m, void *v, loff_t *pos)
> {
> unsigned int *ptr = v;
> + long tgid_check = (long) m->private;
I really don't like the subtle use of having m->private != NULL mean
this is for tgid listing.
In fact, I don't see the purpose of reusing the seq code. The cmdlines
and tgid map are quite different. Just create its own functions. I
don't see the benefit of trying to reuse this except for making the
code more complex.
-- Steve
>
> if (*pos || m->count)
> ptr++;
> @@ -4702,6 +4703,8 @@ static void *saved_cmdlines_next(struct seq_file *m, void *v, loff_t *pos)
> ptr++) {
> if (*ptr == -1 || *ptr == NO_CMDLINE_MAP)
> continue;
> + if (tgid_check && !trace_find_tgid(*ptr))
> + continue;
>
> return ptr;
> }
> @@ -4713,6 +4716,10 @@ static void *saved_cmdlines_start(struct seq_file *m, loff_t *pos)
> {
> void *v;
> loff_t l = 0;
> + long tgid_check = (long) m->private;
> +
> + if (tgid_check && !tgid_map)
> + return NULL;
>
> preempt_disable();
> arch_spin_lock(&trace_cmdline_lock);
> @@ -4743,6 +4750,14 @@ static int saved_cmdlines_show(struct seq_file *m, void *v)
> return 0;
> }
>
next prev parent reply other threads:[~2017-06-30 21:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 17:17 Michael Sartain
2017-06-30 21:50 ` Steven Rostedt [this message]
2017-06-30 23:37 ` Joel Fernandes
2017-07-01 0:32 ` Michael Sartain
2017-07-02 1:47 ` kbuild test robot
2017-07-02 2:03 ` kbuild test robot
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=20170630175057.71de9d39@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=joelaf@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mikesart@fastmail.com \
--cc=mingo@redhat.com \
/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
all inboxes | Powered by JetHome®