From: Jason Baron <jbaron@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>,
Frederic Weisbecker <fweisbec@gmail.com>,
linux-kernel@vger.kernel.org, David Miller <davem@davemloft.net>,
Mike Galbraith <efault@gmx.de>,
Steven Rostedt <rostedt@goodmis.org>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [RFC][PATCH 7/7] perf: Optimize sw events
Date: Fri, 15 Oct 2010 10:18:16 -0400 [thread overview]
Message-ID: <20101015141816.GA2822@redhat.com> (raw)
In-Reply-To: <1287134043.29097.1331.camel@twins>
On Fri, Oct 15, 2010 at 11:14:03AM +0200, Peter Zijlstra wrote:
> > Index: linux-2.6/include/linux/perf_event.h
> > ===================================================================
> > --- linux-2.6.orig/include/linux/perf_event.h
> > +++ linux-2.6/include/linux/perf_event.h
> > @@ -1013,15 +1013,17 @@ static inline void perf_fetch_caller_reg
> > static inline void
> > perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
> > {
> > - if (atomic_read(&perf_swevent_enabled[event_id])) {
> > - struct pt_regs hot_regs;
> > + struct pt_regs hot_regs;
> >
> > - if (!regs) {
> > - perf_fetch_caller_regs(&hot_regs);
> > - regs = &hot_regs;
> > - }
> > - __perf_sw_event(event_id, nr, nmi, regs, addr);
> > + JUMP_LABEL(&perf_swevent_enabled[event_id], have_event);
> > + return;
> > +
> > +have_event:
> > + if (!regs) {
> > + perf_fetch_caller_regs(&hot_regs);
> > + regs = &hot_regs;
> > }
> > + __perf_sw_event(event_id, nr, nmi, regs, addr);
> > }
> >
>
> OK, so it appears I only compile tested this bit without jump_label
> support, with that bit added back this horribly fails to compile like:
>
> In file included from /usr/src/linux-2.6/arch/x86/mm/fault.c:13:
> /usr/src/linux-2.6/include/linux/perf_event.h: In function ‘perf_sw_event.clone.0’:
> /usr/src/linux-2.6/include/linux/perf_event.h:1018: warning: asm operand 0 probably doesn’t match constraints
> /usr/src/linux-2.6/include/linux/perf_event.h:1018: error: impossible constraint in ‘asm’
>
>
> The relevant snippet from the .i file reads:
>
> static inline void
> perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
> {
> struct pt_regs hot_regs;
>
> do { asm goto("1:" ".byte 0xe9 \n\t .long 0\n\t" ".pushsection __jump_table, \"a\" \n\t" " " ".quad" " " "1b, %l[" "have_event" "], %c0 \n\t" ".popsection \n\t" : : "i" (&perf_swevent_enabled[event_id]) : : have_event); } while (0);
> return;
>
> have_event:
> if (!regs) {
> perf_fetch_caller_regs(&hot_regs);
> regs = &hot_regs;
> }
> __perf_sw_event(event_id, nr, nmi, regs, addr);
> }
>
>
> Anybody got any clue as to why this goes splat?
>
Couple issues here. The key value: "&perf_swevent_enabled[event_id]"
is determined at run-time, so we can't associated the jump label with
keys that are run-time dependent. The second thing is that there is
array indexing, so essentially the jump label code would need to be
smart enough to associated the correct index with each instance of
'perf_sw_event' - unfortunately its not that smart :(
So, two possible suggestions:
1)
I see that PERF_COUNT_SW_MAX is 9. So, we could explicitly split out the
9 cases into 9 separate inline functions where the keys would be:
&perf_swevent_enabled[PERF_COUNT_SW_CPU_CLOCK]
&perf_swevent_enabled[PERF_COUNT_SW_TASK_CLOCK]
this probably wouldn't look to ugly if there was a macro that took each
software id, and spit out the appropriate inline. I see there aren't
that many 'perf_sw_event()' calls either to update.
2)
If you could define a single global variable that was set if any of the
indexes of the perf_swevent_enabled[] array were set. This potentially
woulnd't be as efficient as #1 as it would create false positives.
thanks,
-Jason
next prev parent reply other threads:[~2010-10-15 14:18 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-14 20:34 [RFC][PATCH 0/7] perf and jump_label bits Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 1/7] perf: Fix task refcount issues Peter Zijlstra
2010-10-15 18:14 ` Frederic Weisbecker
2010-10-15 20:02 ` Matt Helsley
2010-10-18 19:19 ` [tip:perf/core] perf: Fix task refcount bugs tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 2/7] perf: Find task before event alloc Peter Zijlstra
2010-10-18 19:20 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 3/7] perf, hw_breakpoint: Fix crash in hw_breakpoint creation Peter Zijlstra
2010-10-15 13:47 ` Frederic Weisbecker
2010-10-15 13:52 ` Peter Zijlstra
2010-10-18 19:20 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 4/7] jump_label: More consitent naming Peter Zijlstra
2010-10-18 19:21 ` [tip:perf/core] jump_label: Use more consistent naming tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 5/7] jump_label: atomic_t interface Peter Zijlstra
2010-10-15 14:01 ` Frederic Weisbecker
2010-10-18 19:21 ` [tip:perf/core] jump_label: Add " tip-bot for Peter Zijlstra
2010-10-18 19:21 ` [tip:perf/core] perf: Use jump_labels to optimize the scheduler hooks tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 6/7] perf: use jump_label " Peter Zijlstra
2010-10-15 13:59 ` Frederic Weisbecker
2010-10-17 9:52 ` Peter Zijlstra
2010-10-17 10:16 ` Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 7/7] perf: Optimize sw events Peter Zijlstra
2010-10-15 9:14 ` Peter Zijlstra
2010-10-15 14:18 ` Jason Baron [this message]
2010-10-15 14:57 ` Peter Zijlstra
2010-10-15 15:02 ` Jason Baron
2010-10-15 19:32 ` Steven Rostedt
2010-10-15 19:54 ` Peter Zijlstra
2010-10-16 6:27 ` Ingo Molnar
2010-10-15 14:04 ` Frederic Weisbecker
2010-10-15 14:08 ` Peter Zijlstra
2010-10-15 14:11 ` Frederic Weisbecker
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=20101015141816.GA2822@redhat.com \
--to=jbaron@redhat.com \
--cc=davem@davemloft.net \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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).