From: Ingo Molnar <mingo@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Vince Weaver <vince@deater.net>,
Arnaldo Carvalho de Melo <acme@infradead.org>,
Jiri Olsa <jolsa@redhat.com>,
Matt Fleming <matt@console-pimps.org>,
Andy Lutomirski <luto@amacapital.net>,
Stephane Eranian <eranian@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org
Subject: Re: [RFD] perf syscall error handling
Date: Fri, 31 Oct 2014 10:27:13 +0100 [thread overview]
Message-ID: <20141031092713.GA23124@gmail.com> (raw)
In-Reply-To: <20141031072109.GD12706@worktop.programming.kicks-ass.net>
* Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, Oct 30, 2014 at 09:16:36PM -0400, Vince Weaver wrote:
> > On Thu, 30 Oct 2014, Peter Zijlstra wrote:
> >
> > > So would something simple, like an offset into the struct
> > > perf_event_attr pointing at the current field we're trying
> > > to process make sense? Maybe with negative offsets to
> > > indicate the syscall arguments?
> > >
> > > That would narrow down the 'WTF is wrong noaw' a lot I
> > > think. But then, I've not actually done a lot of userspace
> > > the last few years, so maybe I'm just dreaming things.
> >
> > well, as someone who spends a lot of time in userspace trying
> > to help people who report probems like 'perf_event_open()
> > returns EINVAL, what's wrong' I can say pretty much anything
> > will be an improvement.
>
> Right, the situation is dire indeed :/
>
> > What would really help is if we could somehow return the
> > filename/line-number of whatever source code file that's
> > setting errno.
> >
> > Even if perf_event_open() told me that hey, we're getting
> > EOPNOTSUPP due to the precise_ip parameter (something that
> > happened just yesterday) it's still a lot of grepping and
> > poking around source files to find out what's going on. It
> > would be much better if it just told me the issue was at
> > kernel/events/core.c line 995 or so, but I'm not sure how you
> > could pass that back to the user, and one could argue it
> > wouldn't help much the average user without a kernel tree
> > lying around.
>
> Would an additional bit mask help? With that we'd be able to
> finger the exact flag that causes pain.
Well, I don't really like bitmasks nor __LINE__/__FILE__
obscurity, those are non-starters because they are user
unfriendly.
What would work best is something like:
- user-space could request 'extended error code' passing from
kernel to user-space via a (default off) feature bit in
perf_attr, plus a user-space provided pointer to a string
buffer, and a maximum length value.
- old user-space or user-space that does not want it would not
be unaffected by the new 'extended error code' facility
- user-space gets back the regular errno (-EOPNOTSUPP or -ENOSYS
or -EINVAL, etc.) and a string. Strings are really the most
helpful information, because tools can just print that. They
can also match on specific strings and programmatically react
to them if they want to: we can promise to not arbitrarily
change error strings once they are introduced. (but even if
they change, user-space can still print them out.)
- in the kernel, instead of doing:
return -EOPNOTSUPP;
we'd do something like:
return perf_errno(-EOPNOTSUPP, "BTS not supported by this CPU architecture");
here the kernel would in the regular case just ignore the
string, but if user-space requested the 'extended errno'
facility, it would copy the (zero-delimited) error string to
perf_attr->errno_str, taking errno_len into account.
If no extended string was written then user-space can detect
this through the string not having been written to. (it can
initialize it to a zero string.)
Note the various advantages of this approach:
- it's hard to get the facility wrong on the user-space side: in
the simplest usage user-space simply prints out the error,
which will be obvious to the user in most cases.
- it's hard to get it wrong on the kernel side: it's really
similar to what we do today, plus a descriptive error string.
Developers should take care to use descriptive and unique
messages (but even duplicate messages will help in informing
the user).
- it's infinitely extensible, does not involve magic numbers nor
ever changing __LINE__ numbers and obscure source code file
names.
- it's really _easy_ to add good error information on the kernel
side: just add a perf_err() string passing method instead of a
dumb return -EINVAL. Also, the information is in a single
place, exactly where the problem occurs, so it will be easily
maintainable going forward.
Thanks,
Ingo
next prev parent reply other threads:[~2014-10-31 9:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-30 22:28 [RFD] perf syscall error handling Peter Zijlstra
2014-10-31 1:16 ` Vince Weaver
2014-10-31 7:21 ` Peter Zijlstra
2014-10-31 9:27 ` Ingo Molnar [this message]
2014-10-31 12:28 ` Matt Fleming
2014-10-31 21:22 ` Stephane Eranian
2014-11-01 5:30 ` Vince Weaver
2014-11-03 16:25 ` Arnaldo Carvalho de Melo
2014-11-03 16:50 ` Peter Zijlstra
2014-11-03 17:00 ` Arnaldo Carvalho de Melo
2014-11-03 17:12 ` Vince Weaver
2014-11-03 17:39 ` Peter Zijlstra
2014-11-10 10:27 ` Ingo Molnar
2014-11-10 12:15 ` Arnaldo Carvalho de Melo
2014-11-10 12:24 ` Ingo Molnar
2014-11-10 13:54 ` Arnaldo Carvalho de Melo
2014-11-10 14:14 ` David Ahern
2014-11-10 14:47 ` Ingo Molnar
2014-11-10 10:38 ` Ingo Molnar
2014-10-31 10:00 ` Arnaldo Carvalho de Melo
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=20141031092713.GA23124@gmail.com \
--to=mingo@kernel.org \
--cc=acme@infradead.org \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=matt@console-pimps.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vince@deater.net \
/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).