[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANpmjNP1wQvG0SNPP2L9QO=natf0XU8HXj-r2_-U4QZxtr-dVA@mail.gmail.com>
Date: Tue, 23 Feb 2021 16:10:42 +0100
From: Marco Elver <elver@...gle.com>
To: Dmitry Vyukov <dvyukov@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Namhyung Kim <namhyung@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Alexander Potapenko <glider@...gle.com>,
Al Viro <viro@...iv.linux.org.uk>,
Arnd Bergmann <arnd@...db.de>,
Christian Brauner <christian@...uner.io>,
Jann Horn <jannh@...gle.com>, Jens Axboe <axboe@...nel.dk>,
Matt Morehouse <mascasa@...gle.com>,
Peter Collingbourne <pcc@...gle.com>,
Ian Rogers <irogers@...gle.com>,
kasan-dev <kasan-dev@...glegroups.com>,
linux-arch <linux-arch@...r.kernel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
linux-m68k@...ts.linux-m68k.org,
"the arch/x86 maintainers" <x86@...nel.org>
Subject: Re: [PATCH RFC 4/4] perf/core: Add breakpoint information to siginfo
on SIGTRAP
On Tue, 23 Feb 2021 at 16:01, Dmitry Vyukov <dvyukov@...gle.com> wrote:
>
> On Tue, Feb 23, 2021 at 3:34 PM Marco Elver <elver@...gle.com> wrote:
> >
> > Encode information from breakpoint attributes into siginfo_t, which
> > helps disambiguate which breakpoint fired.
> >
> > Note, providing the event fd may be unreliable, since the event may have
> > been modified (via PERF_EVENT_IOC_MODIFY_ATTRIBUTES) between the event
> > triggering and the signal being delivered to user space.
> >
> > Signed-off-by: Marco Elver <elver@...gle.com>
> > ---
> > kernel/events/core.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index 8718763045fd..d7908322d796 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -6296,6 +6296,17 @@ static void perf_sigtrap(struct perf_event *event)
> > info.si_signo = SIGTRAP;
> > info.si_code = TRAP_PERF;
> > info.si_errno = event->attr.type;
> > +
> > + switch (event->attr.type) {
> > + case PERF_TYPE_BREAKPOINT:
> > + info.si_addr = (void *)(unsigned long)event->attr.bp_addr;
> > + info.si_perf = (event->attr.bp_len << 16) | (u64)event->attr.bp_type;
> > + break;
> > + default:
> > + /* No additional info set. */
>
> Should we prohibit using attr.sigtrap for !PERF_TYPE_BREAKPOINT if we
> don't know what info to pass yet?
I don't think it's necessary. This way, by default we get support for
other perf events. If user space observes si_perf==0, then there's no
information available. That would require that any event type that
sets si_perf in future, must ensure that it sets si_perf!=0.
I can add a comment to document the requirement here (and user space
facing documentation should get a copy of how the info is encoded,
too).
Alternatively, we could set si_errno to 0 if no info is available, at
the cost of losing the type information for events not explicitly
listed here.
What do you prefer?
> > + break;
> > + }
> > +
> > force_sig_info(&info);
> > }
> >
> > --
> > 2.30.0.617.g56c4b15f3c-goog
> >
Powered by blists - more mailing lists