From: "Du, Changbin" <changbin.du@intel.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: "Du, Changbin" <changbin.du@intel.com>,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf ftrace: Fix the buffer size in __write_tracing_file
Date: Tue, 9 Jan 2018 14:10:33 +0800 [thread overview]
Message-ID: <20180109061033.hxlwz2j2xfzwiknn@intel.com> (raw)
In-Reply-To: <20180108143457.GA18380@krava>
On Mon, Jan 08, 2018 at 03:34:57PM +0100, Jiri Olsa wrote:
> On Mon, Jan 08, 2018 at 11:05:12AM +0800, Du, Changbin wrote:
> > Hi Olsa,
> > What about this fix now? Thanks!
> >
> > On Tue, Dec 26, 2017 at 05:26:56PM +0800, changbin.du@intel.com wrote:
> > > From: Changbin Du <changbin.du@intel.com>
> > >
> > > The terminal character '\0' should take into account as size of the string
> > > buffer. Without this fix, the '--graph-funcs', '--nograph-funcs' and
> > > '--trace-funcs' options didn't work as expected when the <func> doesn't
> > > exist.
> > >
> > > I didn't dive into kernel ftrace fops, but strace shows that if usersapce
> > > writes a non-terminated string, the kernel side will return success but
> > > no filter applied. After this fix in userspace, the kernel will return an
> > > error.
> > >
> > > $ sudo ./perf ftrace -a --graph-depth 1 --graph-funcs abcdefg
> > > 0) 0.140 us | rcu_all_qs();
> > > 3) 0.304 us | mutex_unlock();
> > > 0) 0.153 us | find_vma();
> > > 3) 0.088 us | __fsnotify_parent();
> > > 0) 6.145 us | handle_mm_fault();
> > > 3) 0.089 us | fsnotify();
> > > 3) 0.161 us | __sb_end_write();
> > > 3) 0.710 us | SyS_close();
> > > 3) 7.848 us | exit_to_usermode_loop();
> > >
> > > On above example, I specified function filter 'abcdefg' but all functions
> > > are enabled.
>
> hum, haven't checked, but looks like the filter is not working at all now:
>
> [root@krava perf]# ./perf ftrace -vv -a --graph-depth 1 --graph-funcs proc_sys_read
> write ' ' to tracing/set_ftrace_pid failed: Invalid argument
> [root@krava perf]# ./perf ftrace -vv -a --graph-depth 1 --graph-funcs SyS_read
> write ' ' to tracing/set_ftrace_pid failed: Invalid argument
> [root@krava perf]# ./perf ftrace -vv -a --graph-depth 1 --graph-funcs fsnotify
> write ' ' to tracing/set_ftrace_pid failed: Invalid argument
>
Thanks for your test. I forgot to test normal case and thought the err is expected...
This time I dived into kernel side, and found 3 issues (if I am all right) at the
kernel function trace_get_user(). This function has problems to process both complete
C string or not.
I will send the kernel patches and Cc you guys. And I still think it is better
let perf write a complete C string.
Thanks!
Changbin Du
> jirka
>
[...]
next prev parent reply other threads:[~2018-01-09 6:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-26 9:26 [PATCH] perf ftrace: Fix the buffer size in __write_tracing_file changbin.du
2018-01-08 3:05 ` Du, Changbin
2018-01-08 14:34 ` Jiri Olsa
2018-01-09 6:10 ` Du, Changbin [this message]
2018-01-09 6:35 ` Namhyung Kim
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=20180109061033.hxlwz2j2xfzwiknn@intel.com \
--to=changbin.du@intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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).