xen/tools: add tracing to various Xen subsystems
cover xen/tools: add tracing to various Xen subsystems
Hello,
While chasing and dealing with bugs, over this last period, I've found myself augmenting Xen with quite a few new tracing capabilities, especially focusing on:
- IRQ being disabled and (re)enabled (in addition to the already existing tracing of IRQ related activity that we have);
- RCU;
- softirqs (I think I sent a preliminary version of this, long ago, but can't be sure);
- tasklets;
- timers;
And, apart from the first 4 patches (which are random, but still tracing related, of course, improvements), this is what this patch series does: it adds tracing to the Xen susystems listed above.
That happens, one subsystem after another, in patches 6 to 15.
Patch 5 deserves special mention. In fact, now that we have Kconfig, I thought it could be a nice thing to make it possible to select, at build config time, whether we want tracing or not, in the hypervisor (like, for instance, we do for performance counters).
To be honest, my goal was to be able to compile tracing off, and run benchmarks, to assess how much of a overhead tracing introduces, but then I decided it was worth doing this properly, and now sending it. I am still running those benchmarks. Preliminary results seems to be showing that having tracing support in the hypervisor does not (when it's disabled, of course) introduce too much overhead. Still, I think it could be useful, to people that wants a very specificly tailored version of Xen (embedded, small footprint, etc.), to be able to rip it off nice and easily (e.g., like OpenXT guys did for schedulers).
Of course, I will report here what I find, when benchmarks will finish running. (In the meantime, patch 5 has some data about .text section shrinking in its changelog.)
I also thought, for similar reasons, that it would have been good to be able to also individually enable or disable the new tracing I'm introducing with this series. This potentially applies even to the tracing we already have in tree (e.g., one may want to have tracing compiled in, for everything except that for scheduling), and I'd be up for working on this. However, in this series, I am touching really hot paths (with the exception, maybe, of RCU), and so I think it is even more important to be able to disable tracing for them, for minimum overhead.
For instance, the IRQ enabling and disabling tracing, I find it really really usable for understanding certain class of behavior, and, with some scripting and some more gnuplot "magic" (which I'll also share shortly) we can also use it to automatically measure and graph for how long interrupt are kept disabled, in various places within the hypervisor (Jennifer has done a similar analysis for XenServer, a while back). But it is very invasive, so you want to be able to turn it on and off.
As said, I don't have all the result I need to present conclusions, but what I see in preliminary data is that, although the tracing we currently have in Xen is not too bad, performance wise, this new IRQs on/off tracing does have an impact on performance, just for being there in the code (i.e., even when it is there in the code but is *disabled*).
Of course, all this fine grain control of tracing options is hidden under XEN_CONFIG_EXPERT, and all the new tracing is disabled by default.
There is a branch with this series here:
git://xenbits.xen.org/people/dariof/xen.git rel/tracing/xen-internals
http://xenbits.xen.org/gitweb/?p=people/dariof/xen.git;a=shortlog;h=refs/heads/rel/tracing/xen-internals
And Travis is happy about it:
https://travis-ci.org/fdario/xen/builds/238421024
Let me know what you think.
Thanks and Regards,
Dario
---
Dario Faggioli (15):
xen: in do_softirq() sample smp_processor_id() once and for all.
xen: tracing: avoid checking tb_init_done multiple times. xen/tools: tracing: several improvements on IRQs tracing
tools: xenalyze: fix dumping of PM_IDLE events.
xen: make it possible to disable tracing in Kconfig.
xen: trace IRQ enabling/disabling
tools: tracing: handle IRQs on/off events in xentrace and xenalyze
xen: trace RCU behavior
tools: tracing: handle RCU events in xentrace and xenalyze
xen: trace softirqs
tools: tracing: handle RCU events in xentrace and xenalyze
xen: trace tasklets
tools: tracing: handle tasklets events in xentrace and xenalyze
xen: trace timers
tools: tracing: handle timers events in xentrace and xenalyze
tools/xentrace/analyze.h | 1 tools/xentrace/formats | 39 +++ tools/xentrace/xenalyze.c | 525 +++++++++++++++++++++++++++++++++++- xen/Kconfig.debug | 50 +++ xen/arch/x86/hvm/svm/entry.S | 2 xen/arch/x86/irq.c | 61 +++- xen/arch/x86/trace.c | 23 ++ xen/common/rcupdate.c | 82 +++++- xen/common/softirq.c | 66 ++++- xen/common/spinlock.c | 16 + xen/common/tasklet.c | 87 ++++++ xen/common/timer.c | 158 ++++++++++- xen/common/trace.c | 57 +++- xen/drivers/cpufreq/utility.c | 7 xen/include/asm-arm/arm32/system.h | 12 + xen/include/asm-arm/arm64/system.h | 12 + xen/include/asm-x86/system.h | 85 +++++- xen/include/public/trace.h | 48 +++ xen/include/xen/rwlock.h | 33 ++ xen/include/xen/trace.h | 30 ++ 20 files changed, 1320 insertions(+), 74 deletions(-)
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 1/15 xen: in do_softirq() sample smp_processor_id() once and for all.
In fact, right now, we read it at every iteration of the loop. The reason it's done like this is how context switch was handled on IA64 (see commit ae9bfcdc, "[XEN] Various softirq cleanups" [1]).
However:
1) we don't have IA64 any longer, and all the achitectures that we do support, are ok with sampling once and for all;
2) sampling at every iteration (slightly) affect performance;
3) sampling at every iteration is misleading, as it makes people believe that it is currently possible that SCHEDULE_SOFTIRQ moves the execution flow on another CPU (and the comment, by reinforcing this belief, makes things even worse!).
Therefore, let's:
- do the sampling once and for all, and remove the comment;
- leave an ASSERT() around, so that, if context switching logic changes (in current or new arches), we will notice.
[1] Some more (historical) information here:
http://old-list-archives.xenproject.org/archives/html/xen-devel/2006-06/msg01262.html
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Tim Deegan <[email protected]>
--- xen/common/softirq.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
xen/common/softirq.c +2 -6
@@ -27,16 +27,12 @@ static DEFINE_PER_CPU(unsigned int, batching);static void __do_softirq (unsigned long ignore_mask) { -unsigned int i, cpu; +unsigned int i, cpu =smp_processor_id ();unsigned long pending;for ( ; ; ) { -/* -* Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ may move -* us to another processor. -*/ - cpu =smp_processor_id (); +ASSERT (cpu ==smp_processor_id ());if (rcu_pending (cpu) )rcu_check_callbacks (cpu);
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 01/15] xen: in do_softirq() sample smp_processor_id() once and for all.
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
In fact, right now, we read it at every iteration of the loop. The reason it's done like this is how context switch was handled on IA64 (see commit
ae9bfcdc, "[XEN] Various softirq cleanups" [1]).However:
1) we don't have IA64 any longer, and all the achitectures that we do support, are ok with sampling once and for all;
2) sampling at every iteration (slightly) affect performance;
3) sampling at every iteration is misleading, as it makes people believe that it is currently possible thatSCHEDULE_SOFTIRQmoves the execution flow on another CPU (and the comment, by reinforcing this belief, makes things even worse!).
Quoted 4 lines
Therefore, let's:
- do the sampling once and for all, and remove the comment;
- leave anASSERT()around, so that, if context switching logic changes (in current or new arches), we will notice.
I'm not convinced. The comment clearly says "may", and I don't think the performance overhead of smp_processor_id() is that high. Keeping the code as is allows some future port to do context switches like ia64 did, if that's more efficient there.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 01/15] xen: in do_softirq() sample smp_processor_id() once and for all.
Quoted 19 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
In fact, right now, we read it at every iteration of the loop. The reason it's done like this is how context switch was handled on IA64 (see commit
ae9bfcdc, "[XEN] Various softirq cleanups" [1]).However:
1) we don't have IA64 any longer, and all the achitectures that we do support, are ok with sampling once and for all;
2) sampling at every iteration (slightly) affect performance;
3) sampling at every iteration is misleading, as it makes people believe that it is currently possible thatSCHEDULE_SOFTIRQmoves the execution flow on another CPU (and the comment, by reinforcing this belief, makes things even worse!).Quoted 4 lines
Therefore, let's:
- do the sampling once and for all, and remove the comment;
- leave anASSERT()around, so that, if context switching logic changes (in current or new arches), we will notice.
Quoted 4 lines
I'm not convinced. The comment clearly says "may", and I don't think the performance overhead of
smp_processor_id()is that high. Keeping the code as is allows some future port to do context switches like ia64 did, if that's more efficient there.
In English, "may" not only means "has a possibility of not happening", but also means "has a possibility of happening". That's false in the hypervisor code the way it's currently written. If I said, "Bring a water pistol to the XenSummit because Jan may burst into flames" I think you'd say I was implying something false. :-)
I think it would be better to remove it. There are doubtless *lots* of places in the code now that implicitly rely on context_switch() never returning. The ASSERT() will catch this issue quickly enough if we ever re-introduce that behavior.
On the other hand, unless there's a noticeable performance overhead, this isn't a big issue.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 01/15] xen: in do_softirq() sample smp_processor_id() once and for all.
In reply to Dario FaggioliQuoted 13 lines · Dario Faggioli
In fact, right now, we read it at every iteration of the loop. The reason it's done like this is how context switch was handled on IA64 (see commit
ae9bfcdc, "[XEN] Various softirq cleanups" [1]).However:
1) we don't have IA64 any longer, and all the achitectures that we do support, are ok with sampling once and for all;
2) sampling at every iteration (slightly) affect performance;
3) sampling at every iteration is misleading, as it makes people believe that it is currently possible thatSCHEDULE_SOFTIRQmoves the execution flow on another CPU (and the comment, by reinforcing this belief, makes things even worse!).
Quoted 2 lines
Therefore, let's:
- do the sampling once and for all, and remove the comment;
"Once and for all" has a much stronger sense of finality than you're using here: reading smp_processor_id() in that function "once and for all" would mean you would never have to read it on that function, on that particular core, ever again, until the end of the universe. :-)
I think I'd say, "only once". The scope of the "only" in that case is "this function call", not "all calls forever".
With that changed:
(Although we till need Jan's acquiescence.)
Quoted 35 lines
- leave an
ASSERT()around, so that, if context switching logic changes (in current or new arches), we will notice.[1] Some more (historical) information here:
http://old-list-archives.xenproject.org/archives/html/xen-devel/2006-06/msg01262.htmlSigned-off-by Dario Faggioli <[email protected]>---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Tim Deegan <[email protected]>--- xen/common/softirq.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)xen/common/softirq.c +1
-1@@ -27,16 +27,12 @@ static DEFINE_PER_CPU(unsigned int, batching);static void __do_softirq (unsigned long ignore_mask) { -unsigned int i, cpu; +unsigned int i, cpu =smp_processor_id ();unsigned long pending;for ( ; ; )
xen/common/softirq.c static DEFINE_PER_CPU(unsigned int, batching); · line 38
Quoted 10 lines
xen/common/softirq.c +1
-5{ -/* -* Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ may move -* us to another processor. -*/ - cpu =smp_processor_id (); +ASSERT (cpu ==smp_processor_id ());if (rcu_pending (cpu) )rcu_check_callbacks (cpu);
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 01/15] xen: in do_softirq() sample smp_processor_id() once and for all.
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.06.17 at 16:20, <[email protected]> wrote:
Quoted 13 lines · Dario Faggioli
In fact, right now, we read it at every iteration of the loop. The reason it's done like this is how context switch was handled on IA64 (see commit
ae9bfcdc, "[XEN] Various softirq cleanups" [1]).However:
1) we don't have IA64 any longer, and all the achitectures that we do support, are ok with sampling once and for all;
2) sampling at every iteration (slightly) affect performance;
3) sampling at every iteration is misleading, as it makes people believe that it is currently possible thatSCHEDULE_SOFTIRQmoves the execution flow on another CPU (and the comment, by reinforcing this belief, makes things even worse!).Quoted 2 lines
Therefore, let's:
- do the sampling once and for all, and remove the comment;"Once and for all" has a much stronger sense of finality than you're using here: reading
smp_processor_id()in that function "once and for all" would mean you would never have to read it on that function, on that particular core, ever again, until the end of the universe. :-)
Quoted 8 lines
I think I'd say, "only once". The scope of the "only" in that case is "this function call", not "all calls forever".
With that changed:
Reviewed-by George Dunlap <[email protected]>(Although we till need Jan's acquiescence.)
I've voiced my opinion, but I don't mean to block the patch. After all there's no active issue the change introduces.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/15 xen: tracing: avoid checking tb_init_done multiple times.
In reply to Dario FaggioliIn fact, when calling __trace_var() directly, we can assume that tb_init_done has been checked to be true, and the if is hence redundant.
While there, also:
- still in __trace_var(), move the check that the event is actually being traced up a little bit (to bail as soon as possible, if it is not);
- make it explicit that tb_init_done is likely 0 in trace_will_trace_event(), as it is almost everywhere in the code.
---
Cc: George Dunlap <[email protected]>
--- xen/common/trace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
xen/common/trace.c +3 -5
@@ -311,7 +311,7 @@ static int tb_set_size(unsigned int pages)int trace_will_trace_event (u32 event) { -if ( !tb_init_done ) +if (likely (!tb_init_done) )return 0 ;/*
@@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,unsigned int extra_word;bool_t started_below_highwater; -if ( !tb_init_done ) +/* If the event is not interesting, bail, as early as possible */ +if ( (tb_event_mask & event) ==0 )return ;/* Convert byte count into word count, rounding up */
@@ -705,9 +706,6 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,/* Round size up to nearest word */ extra = extra_word *sizeof (u32); -if ( (tb_event_mask & event) ==0 ) -return ; -/* match class */ if ( ((tb_event_mask >>TRC_CLS_SHIFT ) & (event >>TRC_CLS_SHIFT )) ==0 )return ;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
Quoted 33 lines · Dario Faggioli
In fact, when calling
__trace_var()directly, we can assume thattb_init_donehas been checked to be true, and the if is hence redundant.While there, also:
- still in__trace_var(), move the check that the event is actually being traced up a little bit (to bail as soon as possible, if it is not);
- make it explicit thattb_init_doneis likely 0 intrace_will_trace_event(), as it is almost everywhere in the code.Signed-off-by Dario Faggioli <[email protected]>---
Cc: George Dunlap <[email protected]>--- xen/common/trace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)xen/common/trace.c +1
-1@@ -311,7 +311,7 @@ static int tb_set_size(unsigned int pages)int trace_will_trace_event (u32 event) { -if ( !tb_init_done ) +if (likely (!tb_init_done) )return 0 ;/*
xen/common/trace.c void __trace_var(u32 event, bool_t cycles, unsigned int extra, · line 692
Quoted 2 lines
xen/common/trace.c +0
-0@@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,unsigned int extra_word;bool_t started_below_highwater;
You probably want an ASSERT(tb_init_done) here to keep callers in check.
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
Quoted 19 lines
xen/common/trace.c +2
-4-if ( !tb_init_done ) +/* If the event is not interesting, bail, as early as possible */ +if ( (tb_event_mask & event) ==0 )return ;/* Convert byte count into word count, rounding up */ @@ -705,9 +706,6 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,/* Round size up to nearest word */ extra = extra_word *sizeof (u32); -if ( (tb_event_mask & event) ==0 ) -return ; -/* match class */ if ( ((tb_event_mask >>TRC_CLS_SHIFT ) & (event >>TRC_CLS_SHIFT )) ==0 )return ;
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
Quoted 13 lines · Andrew Cooper
xen/common/trace.c void __trace_var(u32 event, bool_t cycles, · line 693
Quoted 8 lines · Dario Faggioli
xen/common/trace.c +0
-0@@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles,unsigned int extra, unsigned int extra_word; bool_t started_below_highwater;You probably want an
ASSERT(tb_init_done)here to keep callers in check.
Indeed! And in fact, I did have one. But only to discover that it triggers! :-O
After looking at this better, I figured out that the existing check (the one that this patch kills) is not just redundant, but only a best effort measure.
In fact, we still haven't acquired any locks here. If I put the ASSERT() and, between when I call __trace_var() and when the ASSERT() is reached, someone manages to set tb_init_done=0, the ASSERT(), as said, fires.
However, that is no better in current code. In fact, it is very well possible that someone manages to set tb_init_done=0 *right after*, here in __trace_var(), we check it with the if.
Actually, I think having the check there is misleading, because it makes one think that tb_init_done is guaranteed to be and stay 0 below it, while that isn't true at all. And this is therefore just another reason to get rid of it, IMO. But, sadly, I can't replace it with an ASSERT(). :-(
Quoted 2 lines
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
Thanks, let me know if this still stands.
Quoted 9 lines
Quoted 8 lines
- if( !tb_init_done )
+ /* If the event is not interesting, bail, as early as possible */
+ if ( (tb_event_mask& event) == 0 )
return;
/* Convert byte count into word count, rounding up */
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
In reply to Dario FaggioliQuoted 4 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
In fact, when calling
__trace_var()directly, we can assume thattb_init_donehas been checked to be true, and the if is hence redundant.
The "assume" here worries me: What if there's a single place somewhere that a grep can't easily find where no check is present? Is it certain that ...
xen/common/trace.c void __trace_var(u32 event, bool_t cycles, unsigned int extra, · line 696
Quoted 8 lines
xen/common/trace.c +2
-1@@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,unsigned int extra_word;bool_t started_below_highwater; -if ( !tb_init_done ) +/* If the event is not interesting, bail, as early as possible */ +if ( (tb_event_mask & event) ==0 )return ;
... this check would always be false then (i.e. tb_event_mask is always zero) in that case?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
Quoted 10 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
In fact, when calling
__trace_var()directly, we can assume thattb_init_donehas been checked to be true, and the if is hence redundant.The "assume" here worries me: What if there's a single place somewhere that a grep can't easily find where no check is present? Is it certain that ...
Quoted 14 lines
Quoted 10 lines
xen/common/trace.c +0
-0@@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles,unsigned int extra, unsigned int extra_word; bool_t started_below_highwater;
- if( !tb_init_done )
+ /* If the event is not interesting, bail, as early as possible */
+ if ( (tb_event_mask& event) == 0 )
return;... this check would always be false then (i.e.
tb_event_maskis always zero) in that case?
As said when replying to Andrew, I originally put an ASSERT() there.
That made me realize, though, that the existing if(!tb_init_done) is ineffective and potentially racy (or, if you want to be kind "it's a best effort kind of measure") already.
In fact, even right now, without my patches, we don't hold the tracing lock when we execute that if. Nothing prevents tb_init_done to become 0 _right_after_ we saw it being 1 and decide to go ahead.
This, to me, looks like an even more compelling reason to remove it. But I think I can improve the commit message so that it explains this thing that I just said above too.
Thanks and Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 07.06.17 at 17:55, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
In fact, when calling
__trace_var()directly, we can assume thattb_init_donehas been checked to be true, and the if is hence redundant.The "assume" here worries me: What if there's a single place somewhere that a grep can't easily find where no check is present? Is it certain that ...
Quoted 5 lines
xen/common/trace.c +0
-0@@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles,unsigned int extra, unsigned int extra_word;bool_t started_below_highwater;Quoted 9 lines
xen/common/trace.c void __trace_var(u32 event, bool_t cycles, unsigned int extra, · line 696
Quoted 5 lines
xen/common/trace.c +2
-1-if( !tb_init_done ) +/* If the event is not interesting, bail, as early as possible */ +if ( (tb_event_mask & event) ==0 )return ;... this check would always be false then (i.e.
tb_event_maskis always zero) in that case?As said when replying to Andrew, I originally put an
ASSERT()there.That made me realize, though, that the existing
if(!tb_init_done)is ineffective and potentially racy (or, if you want to be kind "it's a best effort kind of measure") already.
Quoted 7 lines
In fact, even right now, without my patches, we don't hold the tracing lock when we execute that if. Nothing prevents
tb_init_doneto become 0 _right_after_ we saw it being 1 and decide to go ahead.This, to me, looks like an even more compelling reason to remove it. But I think I can improve the commit message so that it explains this thing that I just said above too.
Well, my question wasn't about a possible race (as the code would need to be able to deal with that no matter what change you do here), but about the case where tb_init_done has never been set. Would tb_event_mask be reliably zero in that case, no matter what other operations may have been performed?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
Quoted 40 lines · Jan Beulich
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 07.06.17 at 17:55, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
In fact, when calling
__trace_var()directly, we can assume thattb_init_donehas been checked to be true, and the if is hence redundant.The "assume" here worries me: What if there's a single place somewhere that a grep can't easily find where no check is present? Is it certain that ...
Quoted 5 lines
xen/common/trace.c +0
-0@@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles,unsigned int extra, unsigned int extra_word;bool_t started_below_highwater;Quoted 9 lines
xen/common/trace.c void __trace_var(u32 event, bool_t cycles, unsigned int extra, · line 696
Quoted 5 lines
xen/common/trace.c +2
-1-if( !tb_init_done ) +/* If the event is not interesting, bail, as early as possible */ +if ( (tb_event_mask & event) ==0 )return ;... this check would always be false then (i.e.
tb_event_maskis always zero) in that case?As said when replying to Andrew, I originally put an
ASSERT()there.That made me realize, though, that the existing
if(!tb_init_done)is ineffective and potentially racy (or, if you want to be kind "it's a best effort kind of measure") already.Quoted 7 lines
In fact, even right now, without my patches, we don't hold the tracing lock when we execute that if. Nothing prevents
tb_init_doneto become 0 _right_after_ we saw it being 1 and decide to go ahead.This, to me, looks like an even more compelling reason to remove it. But I think I can improve the commit message so that it explains this thing that I just said above too.
Quoted 5 lines
Well, my question wasn't about a possible race (as the code would need to be able to deal with that no matter what change you do here), but about the case where
tb_init_donehas never been set. Wouldtb_event_maskbe reliably zero in that case, no matter what other operations may have been performed?
Looks like tb_event_mask can be set even if opt_tbuf_size == 0; so yes, if someone enabled the event mask before allocating any buffers, *and* there was a bug where __trace_var() was called without first checking tb_init_done, then we might get past this point.
But it looks like that's still OK -- we'll then bail when our bit in tb_cpu_mask isn't set, or finally bail when we find t_bufs to be zero.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
In reply to Dario FaggioliQuoted 3 lines · Dario Faggioli
In fact, when calling
__trace_var()directly, we can assume thattb_init_donehas been checked to be true, and the if is hence redundant.
You probably want to adjust the comment before the smp_rmb() that mentions tb_init_done as well.
Other than that, looks good.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/15 xen/tools: tracing: several improvements on IRQs tracing
In reply to Dario FaggioliMore specifically:
- the handling of the TRC_HW_IRQ_HANDLED is fixed, both in xentrace_format and in xenalyze;
- simple events for recording when we enter and exit the do_IRQ function, as well as when we deal with a guest IRQ, are added;
- tracing of IRQs handled with direct vectors is also added.
With all the above, a trace will now look like this (using xenalyze):
0.001299072 .x- d32768v5 irq_enter, irq 80000000
0.001299072 .x- d32768v5 irq_direct, vec fa, handler = 0xffff82d08026d7e4 0.001300014 .x- d32768v5 raise_softirq nr 0
0.001300487 .x- d32768v5 irq_exit irq 80000000, in_irq = 0
Or like this:
0.049437892 -|- d32767v12 irq_enter, irq 4 0.049437892 -|- d32767v12 irq_handled irq 4, 85428 cycles 0.049474336 -|- d32767v12 irq_exit irq 4, status = 0x0, in_irq = 0
Making it much easier to figure out when interrupt processing start, what it does and when it ends.
---
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- tools/xentrace/formats | 6 ++++ tools/xentrace/xenalyze.c | 56 +++++++++++++++++++++++++++++++++++----- xen/arch/x86/irq.c | 61 +++++++++++++++++++++++++++++++++++++------- xen/include/public/trace.h | 4 +++ 4 files changed, 109 insertions(+), 18 deletions(-)
tools/xentrace/formats +5 -1
@@ -197,7 +197,11 @@ 0x00802005 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) move_vector [ irq = %(1)d had vector 0x%(2)x on CPU%(3)d ] 0x00802006 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) assign_vector [ irq = %(1)d = vector 0x%(2)x, CPU mask: 0x%(3)08x ] 0x00802007 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) bogus_vector [ 0x%(1)x ] -0x00802008 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_irq [ irq = %(1)d, began = %(2)dus, ended = %(3)dus ] +0x00802008 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_handled [ irq = %(1)d, dur = 0x%(3)08x%(2)08x ] +0x00802009 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) direct_vector [ vector 0x%(1)x, handler = 0x%(3)08x%(2)08x ] +0x0080200a CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_irq [ irq = %(1)d ] +0x0080200b CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_guest_irq [ irq = %(1)d ] +0x0080200c CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_exit [ irq = %(1)d, status = 0x%(2)x, in_irq = %(3)d ] 0x00084001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hpet create [ tn = %(1)d, irq = %(2)d, delta = 0x%(4)08x%(3)08x, period = 0x%(6)08x%(5)08x ] 0x00084002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pit create [ delta = 0x%(1)016x, period = 0x%(2)016x ]
tools/xentrace/xenalyze.c +49 -7
74 lines not on this page · raw message
xen/arch/x86/irq.c +51 -10
109 lines not on this page · raw message
xen/include/public/trace.h +4 -0
@@ -271,6 +271,10 @@#define TRC_HW_IRQ_ASSIGN_VECTOR (TRC_HW_IRQ + 0x6)#define TRC_HW_IRQ_UNMAPPED_VECTOR (TRC_HW_IRQ + 0x7)#define TRC_HW_IRQ_HANDLED (TRC_HW_IRQ + 0x8) +#define TRC_HW_IRQ_DIRECT_VECTOR (TRC_HW_IRQ + 0x9) +#define TRC_HW_IRQ_ENTER (TRC_HW_IRQ + 0xA) +#define TRC_HW_IRQ_GUEST (TRC_HW_IRQ + 0xB) +#define TRC_HW_IRQ_EXIT (TRC_HW_IRQ + 0xC)/* * Event Flags
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
Quoted 9 lines · Dario Faggioli
More specifically:
- the handling of theTRC_HW_IRQ_HANDLEDis fixed, both inxentrace_formatand in xenalyze;
- simple events for recording when we enter and exit thedo_IRQfunction, as well as when we deal with a guest IRQ, are added;
- tracing of IRQs handled with direct vectors is also added.
Quoted 5 lines
With all the above, a trace will now look like this (using xenalyze):
0.001299072 .x- d32768v5
irq_enter, irq 80000000
0.001299072 .x- d32768v5irq_direct, vec fa, handler =0xffff82d08026d7e4
Please consistently use 0x$hex. vec in particular has 10/16ths of its values which are completely ambiguous between hex and decimal.
~Andrew
Quoted 59 lines
0.001300014 .x- d32768v5
raise_softirqnr 0 0.001300487 .x- d32768v5irq_exitirq 80000000,in_irq= 0Or like this:
0.049437892 -|- d32767v12 irq_enter, irq 4 0.049437892 -|- d32767v12 irq_handled irq 4, 85428 cycles 0.049474336 -|- d32767v12 irq_exit irq 4, status = 0x0, in_irq = 0Making it much easier to figure out when interrupt processing start, what it does and when it ends.
Signed-off-by Dario Faggioli <[email protected]>---
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>--- tools/xentrace/formats | 6 ++++ tools/xentrace/xenalyze.c | 56 +++++++++++++++++++++++++++++++++++----- xen/arch/x86/irq.c | 61 +++++++++++++++++++++++++++++++++++++------- xen/include/public/trace.h | 4 +++ 4 files changed, 109 insertions(+), 18 deletions(-)tools/xentrace/formats +5
-1@@ -197,7 +197,11 @@ 0x00802005 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) move_vector [ irq = %(1)d had vector 0x%(2)x on CPU%(3)d ] 0x00802006 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) assign_vector [ irq = %(1)d = vector 0x%(2)x, CPU mask: 0x%(3)08x ] 0x00802007 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) bogus_vector [ 0x%(1)x ] -0x00802008 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_irq [ irq = %(1)d, began = %(2)dus, ended = %(3)dus ] +0x00802008 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_handled [ irq = %(1)d, dur = 0x%(3)08x%(2)08x ] +0x00802009 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) direct_vector [ vector 0x%(1)x, handler = 0x%(3)08x%(2)08x ] +0x0080200a CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_irq [ irq = %(1)d ] +0x0080200b CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_guest_irq [ irq = %(1)d ] +0x0080200c CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_exit [ irq = %(1)d, status = 0x%(2)x, in_irq = %(3)d ] 0x00084001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hpet create [ tn = %(1)d, irq = %(2)d, delta = 0x%(4)08x%(3)08x, period = 0x%(6)08x%(5)08x ] 0x00084002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pit create [ delta = 0x%(1)016x, period = 0x%(2)016x ]tools/xentrace/xenalyze.c +3
-2@@ -8380,19 +8380,45 @@ void irq_process(struct pcpu_info *p) { }break ; } -case TRC_HW_IRQ_HANDLED : +case TRC_HW_IRQ_ENTER : +case TRC_HW_IRQ_GUEST : {struct { -int irq, start_tsc, end_tsc; +int32_t irq; } *r = (typeof (r ))ri->d;
tools/xentrace/xenalyze.c void irq_process(struct pcpu_info *p) { · line 8393
Quoted 10 lines
tools/xentrace/xenalyze.c +2
-5-int arctime; - arctime = r->end_tsc - r->start_tsc;if ( opt.dump_all ) { -printf (" %s irq_handled irq %x %d (%d,%d)\n" , - ri->dump_header, - r->irq, arctime, r->start_tsc, r->end_tsc); +printf (" %s irq_%s, irq %x\n" , ri->dump_header, + ri->event ==TRC_HW_IRQ_ENTER ?"enter" :"guest" , r->irq);
irq %#x
Quoted 4 lines
tools/xentrace/xenalyze.c +4
-0+ } +break ; + } +case TRC_HW_IRQ_DIRECT_VECTOR :
tools/xentrace/xenalyze.c void irq_process(struct pcpu_info *p) { · line 8407
Quoted 10 lines
tools/xentrace/xenalyze.c +10
-0+ { +struct { +uint32_t vec; +uint64_t handler; + } __attribute__((packed)) *r = (typeof (r ))ri->d; + +if ( opt.dump_all ) + { +printf (" %s irq_direct, vec %x, handler = %p\n" , + ri->dump_header, r->vec, (void *)r->handler);
vec %02x
tools/xentrace/xenalyze.c void irq_process(struct pcpu_info *p) { · line 8420
Quoted 13 lines
tools/xentrace/xenalyze.c +13
-0+ } +break ; + } +case TRC_HW_IRQ_HANDLED : + { +struct { +int32_t irq; +uint64_t arctime; + } __attribute__((packed)) *r = (typeof (r ))ri->d; + +if ( opt.dump_all ) + { + printf(" %s irq_handled irq %x, %"PRIu64" cycles\n",
irq %#x
Quoted 76 lines
tools/xentrace/xenalyze.c +17
-0+ ri->dump_header, r->irq, r->arctime); }if ( opt.scatterplot_irq ) {@@ -8407,6 +8433,22 @@ void irq_process(struct pcpu_info *p) { }break ; } +case TRC_HW_IRQ_EXIT : + { +struct { +int32_t irq, status; +uint32_t in_irq; + } *r = (typeof (r ))ri->d; + +if ( opt.dump_all ) + { +printf (" %s irq_exit irq %x" , ri->dump_header, r->irq); +if ( r->status !=-1 ) +printf (", status = 0x%x" , r->status); +printf (", in_irq = %d\n" , r->in_irq); + } +break ; + }case TRC_HW_IRQ_ASSIGN_VECTOR : {struct {xen/arch/x86/irq.c +22
-3@@ -100,11 +100,15 @@ static void trace_irq_mask(u32 event, int irq, int vector, cpumask_t *mask) unsigned int irq:16, vec:16;unsigned int mask[6 ]; } d; + +if (likely (!tb_init_done) ) +return ; + d.irq = irq; d.vec = vector;memset (d.mask,0 ,sizeof (d.mask));memcpy (d.mask, mask,min (sizeof (d.mask),sizeof (cpumask_t))); -trace_var (event,1 ,sizeof (d), &d); +__trace_var (event,1 ,sizeof (d), &d); }static int __init __bind_irq_vector (int irq,int vector,const cpumask_t *cpu_mask)@@ -804,23 +808,54 @@ void alloc_direct_apic_vector(spin_unlock (&lock); } +static inline void trace_irq_handled (int irq,uint64_t time) +{ +struct __packed { +int32_t irq; +uint64_t time; + } d; + +if (likely (!tb_init_done) ) +return ; + + d.irq = irq; + d.time = time; +__trace_var (TRC_HW_IRQ_HANDLED ,0 ,sizeof (d), &d); +} +void do_IRQ (struct cpu_user_regs *regs) {struct irqaction *action; -uint32_t tsc_in; -struct irq_desc *desc; +uint64_t tsc_in =0 ; +struct irq_desc *desc =NULL ;unsigned int vector = (u8 )regs->entry_vector;int irq =__get_cpu_var (vector_irq[vector]);
xen/arch/x86/irq.c void alloc_direct_apic_vector( · line 840
Quoted 10 lines
xen/arch/x86/irq.c +2
-2struct cpu_user_regs *old_regs =set_irq_regs (regs);perfc_incr (irqs);this_cpu (irq_count)++; +TRACE_1D (TRC_HW_IRQ_ENTER , irq);irq_enter (); -if (irq <0 ) { -if (direct_apic_vector[vector] !=NULL ) { +if (irq <0 )
Spaces.
xen/arch/x86/irq.c void alloc_direct_apic_vector( · line 842
Quoted 2 lines
xen/arch/x86/irq.c +2
-0+ { +if (direct_apic_vector[vector] !=NULL )
Spaces.
xen/arch/x86/irq.c void alloc_direct_apic_vector( · line 852
Quoted 10 lines
xen/arch/x86/irq.c +10
-0+ { +if (unlikely (tb_init_done) ) + { +struct __packed { +uint32_t vec; +uint64_t handler; + } d; + + d.vec = vector; + d.handler = (uint64_t )direct_apic_vector[vector];
As there is no code inbetween, you can do this as a straight initialisation of d.
i.e.
} d = { vector, (uint64_t)direct_apic_vector[vector] };
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
Quoted 53 lines
xen/arch/x86/irq.c +15
-5+__trace_var (TRC_HW_IRQ_DIRECT_VECTOR ,0 ,sizeof (d), &d); + } (*direct_apic_vector[vector])(regs); - }else { + } +else + {const char *kind =", LAPIC" ;if (apic_isr_read (vector) )@@ -884,9 +919,13 @@ void do_IRQ(struct cpu_user_regs *regs) desc->rl_quantum_start = now; } - tsc_in = tb_init_done ?get_cycles () :0 ; +if (unlikely (tb_init_done) ) + { +__trace_var (TRC_HW_IRQ_GUEST ,0 ,sizeof (irq), &irq); + tsc_in =get_cycles (); + }__do_IRQ_guest (irq); -TRACE_3D (TRC_HW_IRQ_HANDLED , irq, tsc_in,get_cycles ()); +trace_irq_handled (irq,get_cycles () - tsc_in); goto out_no_end; }@@ -907,9 +946,10 @@ void do_IRQ(struct cpu_user_regs *regs) { desc->status &= ~IRQ_PENDING ;spin_unlock_irq (&desc->lock); - tsc_in = tb_init_done ?get_cycles () :0 ; +if (unlikely (tb_init_done) ) + tsc_in =get_cycles (); action->handler (irq, action->dev_id, regs); -TRACE_3D (TRC_HW_IRQ_HANDLED , irq, tsc_in,get_cycles ()); +trace_irq_handled (irq,get_cycles () - tsc_in);spin_lock_irq (&desc->lock); }@@ -922,6 +962,7 @@ void do_IRQ(struct cpu_user_regs *regs)spin_unlock (&desc->lock); out_no_unlock:irq_exit (); +TRACE_3D (TRC_HW_IRQ_EXIT , irq, desc ==NULL ?-1 : desc->status,in_irq ());set_irq_regs (old_regs); }xen/include/public/trace.h +0
-0
xen/include/public/trace.h line 280
Quoted 10 lines
xen/include/public/trace.h +4
-0@@ -271,6 +271,10 @@#define TRC_HW_IRQ_ASSIGN_VECTOR (TRC_HW_IRQ + 0x6)#define TRC_HW_IRQ_UNMAPPED_VECTOR (TRC_HW_IRQ + 0x7)#define TRC_HW_IRQ_HANDLED (TRC_HW_IRQ + 0x8) +#define TRC_HW_IRQ_DIRECT_VECTOR (TRC_HW_IRQ + 0x9) +#define TRC_HW_IRQ_ENTER (TRC_HW_IRQ + 0xA) +#define TRC_HW_IRQ_GUEST (TRC_HW_IRQ + 0xB) +#define TRC_HW_IRQ_EXIT (TRC_HW_IRQ + 0xC)/* * Event Flags
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
Quoted 13 lines · Andrew Cooper
Quoted 12 lines · Dario Faggioli
More specifically:
- the handling of theTRC_HW_IRQ_HANDLEDis fixed, both inxentrace_formatand in xenalyze;
- simple events for recording when we enter and exit thedo_IRQfunction, as well as when we deal with a guest IRQ, are added;
- tracing of IRQs handled with direct vectors is also added.With all the above, a trace will now look like this (using xenalyze):
Quoted 8 lines
Quoted 3 lines
0.001299072 .x- d32768v5
irq_enter, irq 80000000 0.001299072 .x- d32768v5irq_direct, vec fa, handler =0xffff82d08026d7e4Please consistently use 0x$hex. vec in particular has 10/16ths of its
values which are completely ambiguous between hex and decimal.
I fully agree. The file is not super consistent about this already, and I was basically following the suit of the majority of existing cases.
But I really do agree, so I'll probably make a pre-patch, that converts everyone to 0x$hex, and then use it in this patch as well.
Quoted 11 lines
Quoted 10 lines
+ {
+ if (unlikely(tb_init_done))
+ {
+ struct__packed{
+ uint32_t vec;
+ uint64_t handler;
+ } d;
+
+ d.vec = vector;
+ d.handler = (uint64_t)direct_apic_vector[vector];
Quoted 9 lines
As there is no code inbetween, you can do this as a straight initialisation of d.
i.e.
} d = { vector, (uint64_t)direct_apic_vector[vector] };
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
Ok, thanks. I'll take care of this, and of all the others print format and style comments.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
In reply to Dario FaggioliQuoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
More specifically:
- the handling of theTRC_HW_IRQ_HANDLEDis fixed, both inxentrace_formatand in xenalyze;
- simple events for recording when we enter and exit thedo_IRQfunction, as well as when we deal with a guest IRQ, are added;
On x86. What about ARM?
Quoted 10 lines
- tracing of IRQs handled with direct vectors is also added.
With all the above, a trace will now look like this (using xenalyze):
0.001299072 .x- d32768v5
irq_enter, irq 80000000
0.001299072 .x- d32768v5irq_direct, vec fa, handler =0xffff82d08026d7e40.001300014 .x- d32768v5raise_softirqnr 0
0.001300487 .x- d32768v5irq_exitirq 80000000,in_irq= 0
The IRQ number looks bogus here, and I'm not convinced giving a bogus example in a commit message is a good idea. I realize this is presumably a result of vector_irq[] being initialized to INT_MIN, but I would say the trace points would then better be moved so that no bogus data is being recorded.
Quoted 5 lines
xen/arch/x86/irq.c +0
-1@@ -884,9 +919,13 @@ void do_IRQ(struct cpu_user_regs *regs) desc->rl_quantum_start = now; } - tsc_in = tb_init_done ?get_cycles () :0 ;
xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 930
Quoted 10 lines
xen/arch/x86/irq.c +6
-1+if (unlikely (tb_init_done) ) + { +__trace_var (TRC_HW_IRQ_GUEST ,0 ,sizeof (irq), &irq); + tsc_in =get_cycles (); + }__do_IRQ_guest (irq); -TRACE_3D (TRC_HW_IRQ_HANDLED , irq, tsc_in,get_cycles ()); +trace_irq_handled (irq,get_cycles () - tsc_in); goto out_no_end; }
Before this change, the get_cycles() invocation was after the tb_init_done check. Now you move it ahead of it (as the function arguments are evaluated before executing the function body) - are you sure all compiler versions will suitably re-order this?
Additionally I'm afraid this will trigger compiler warnings on at least some compiler versions, as tsc_in is now possibly uninitialized (and there's no clear way to disprove this for the compiler, again because function arguments are being evaluated before the function body is reached).
As to get_cycles() itself - is the relatively imprecise time stamp it produces really good enough for tracing? I notice that there are only very few other users of that function.
xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 965
Quoted 5 lines
xen/arch/x86/irq.c +1
-0@@ -922,6 +962,7 @@ void do_IRQ(struct cpu_user_regs *regs)spin_unlock (&desc->lock); out_no_unlock:irq_exit (); +TRACE_3D (TRC_HW_IRQ_EXIT , irq, desc ==NULL ?-1 : desc->status,in_irq ());
The ordering of irq_{enter,exit}() and TRACE_{1,3}D() may be preferable from a trace quality pov, but as far as the system is concerned you're adding code which runs in interrupt context without being aware of that. This may be a latent issue.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
Quoted 11 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
More specifically:
- the handling of theTRC_HW_IRQ_HANDLEDis fixed, both inxentrace_formatand in xenalyze;
- simple events for recording when we enter and exit thedo_IRQfunction, as well as when we deal with a guest IRQ, are added;On x86. What about ARM?
We don't have tracing at all on ARM. I guess I can mention this in the commit message (and, perhaps, even add an 'x86' tag to the subject).
Quoted 12 lines
Quoted 11 lines
- tracing of IRQs handled with direct vectors is also added.
With all the above, a trace will now look like this (using xenalyze):
0.001299072 .x- d32768v5
irq_enter, irq 80000000 0.001299072 .x- d32768v5irq_direct, vec fa, handler =0xffff82d08026d7e4
0.001300014 .x- d32768v5raise_softirqnr 0 0.001300487 .x- d32768v5irq_exitirq 80000000,in_irq= 0
Quoted 6 lines
The IRQ number looks bogus here, and I'm not convinced giving a bogus example in a commit message is a good idea. I realize this is presumably a result of vector_irq[] being initialized to
INT_MIN, but I would say the trace points would then better be moved so that no bogus data is being recorded.
Ok, I'll have a look at how to achieve that.
Quoted 22 lines
Quoted 7 lines
xen/arch/x86/irq.c +0
-0@@ -884,9 +919,13 @@ void do_IRQ(struct cpu_user_regs *regs) desc->rl_quantum_start = now; }
- tsc_in =tb_init_done?get_cycles(): 0; + if (unlikely(tb_init_done))
+ {Quoted 8 lines
+ __trace_var(TRC_HW_IRQ_GUEST, 0, sizeof(irq), &irq); + tsc_in =
get_cycles();
+ }
__do_IRQ_guest(irq);
- TRACE_3D(TRC_HW_IRQ_HANDLED, irq,tsc_in,get_cycles()); + trace_irq_handled(irq,get_cycles()-tsc_in); gotoout_no_end;
}Before this change, the
get_cycles()invocation was after thetb_init_donecheck. Now you move it ahead of it (as the function arguments are evaluated before executing the function body) - are you sure all compiler versions will suitably re-order this?
Quoted 6 lines
Additionally I'm afraid this will trigger compiler warnings on at least some compiler versions, as
tsc_inis now possibly uninitialized (and there's no clear way to disprove this for the compiler, again because function arguments are being evaluated before the function body is reached).
I understand and (now that I see it) agree with your remark on when get_cycles() is called. I'll reorganize things so that the patched behavior matches the existing one.
OTOH, I'm not sure I see the "potentially uninitialized" issue for tsc_in, but since I'm reworking the code, I'll keep that in mind too.
Quoted 4 lines
As to
get_cycles()itself - is the relatively imprecise time stamp it produces really good enough for tracing? I notice that there are only very few other users of that function.
Yes, that's also something I was wondering. It's what is being used currently, so I thought it was like that for a reason, and that it wasn't this patch job to change that.
But if it's judged to be fine to turn this into NOW() (done either here, or in a dedicated patch)., I'm all for it.
Quoted 5 lines
Quoted 5 lines
xen/arch/x86/irq.c +0
-0@@ -922,6 +962,7 @@ void do_IRQ(struct cpu_user_regs *regs) spin_unlock(&desc->lock);
out_no_unlock:
irq_exit();
+ TRACE_3D(TRC_HW_IRQ_EXIT, irq, desc == NULL ? -1 : desc-
Quoted 7 lines
Quoted 1 line
Quoted 1 line
status,
in_irq());The ordering of irq_{enter,exit}() and TRACE_{1,3}D() may be preferable from a trace quality pov, but as far as the system is concerned you're adding code which runs in interrupt context without being aware of that. This may be a latent issue.
Sorry, I don't understand your concern(s). What is it that I am not aware of, and what is it that could be a latent issue?
About the position of those tracepoints: the nice thing about IRQ_EXIT following irq_exit() is that I can record the result of in_irq(), which will tell whether or not we're dealing with a nested interrupt. I don't
do the same for IRQ_ENTER, but, not that I think about it, I guess I
could.
However, if what you're saying is that they need to stay within the irq_enter()-irq_exit() section, I can certainly make that happen. The trace needs to be interpreted knowing where the tracepoints are anyway (and that's true for each and every event already), so no big deal, really.
Thanks and Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 07.06.17 at 17:45, <[email protected]> wrote:
Quoted 23 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
xen/arch/x86/irq.c +0
-1@@ -884,9 +919,13 @@ void do_IRQ(struct cpu_user_regs *regs) desc->rl_quantum_start = now; } - tsc_in = tb_init_done ?get_cycles () :0 ;xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 930
Quoted 10 lines
xen/arch/x86/irq.c +6
-1+if (unlikely (tb_init_done) ) + { +__trace_var (TRC_HW_IRQ_GUEST ,0 ,sizeof (irq), &irq); + tsc_in =get_cycles (); + }__do_IRQ_guest (irq); -TRACE_3D (TRC_HW_IRQ_HANDLED , irq, tsc_in,get_cycles ()); +trace_irq_handled (irq,get_cycles () - tsc_in); goto out_no_end; }Before this change, the
get_cycles()invocation was after thetb_init_donecheck. Now you move it ahead of it (as the function arguments are evaluated before executing the function body) - are you sure all compiler versions will suitably re-order this?Quoted 6 lines
Additionally I'm afraid this will trigger compiler warnings on at least some compiler versions, as
tsc_inis now possibly uninitialized (and there's no clear way to disprove this for the compiler, again because function arguments are being evaluated before the function body is reached).
Quoted 6 lines
I understand and (now that I see it) agree with your remark on when
get_cycles()is called. I'll reorganize things so that the patched behavior matches the existing one.OTOH, I'm not sure I see the "potentially uninitialized" issue for
tsc_in, but since I'm reworking the code, I'll keep that in mind too.
You initialize tsc_in only when tb_init_done is set, but you use it without that conditional. And even if you used it under that same conditional, older compiler versions aren't able to track that fact (same conditional) and raise a warning anyway.
Quoted 10 lines
Quoted 4 lines
As to
get_cycles()itself - is the relatively imprecise time stamp it produces really good enough for tracing? I notice that there are only very few other users of that function.Yes, that's also something I was wondering. It's what is being used currently, so I thought it was like that for a reason, and that it wasn't this patch job to change that.
But if it's judged to be fine to turn this into
NOW()(done either here, or in a dedicated patch)., I'm all for it.
Right, I didn't necessarily mean for this to be done here, I merely wanted to raise the fact (remembering that for the other time handling code using "synced" TSC reads was quite a bit of an accuracy improvement).
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
xen/arch/x86/irq.c +1
-0@@ -922,6 +962,7 @@ void do_IRQ(struct cpu_user_regs *regs)spin_unlock (&desc->lock); out_no_unlock:irq_exit (); + TRACE_3D(TRC_HW_IRQ_EXIT, irq, desc == NULL ? -1 : desc-Quoted 7 lines
Review void do_IRQ(struct cpu_user_regs *regs) · line 966
Quoted 1 line
(quoted diff) +0
-0>status, in_irq());The ordering of irq_{enter,exit}() and TRACE_{1,3}D() may be preferable from a trace quality pov, but as far as the system is concerned you're adding code which runs in interrupt context without being aware of that. This may be a latent issue.
Sorry, I don't understand your concern(s). What is it that I am not aware of, and what is it that could be a latent issue?
About the position of those tracepoints: the nice thing about
IRQ_EXITfollowingirq_exit()is that I can record the result ofin_irq(), which will tell whether or not we're dealing with a nested interrupt. I don't
do the same forIRQ_ENTER, but, not that I think about it, I guess I
could.
Quoted 5 lines
However, if what you're saying is that they need to stay within the irq_enter()-irq_exit() section, I can certainly make that happen. The trace needs to be interpreted knowing where the tracepoints are anyway (and that's true for each and every event already), so no big deal, really.
Yes, it's really just this latter fact - it would feel more safe from an overall system pov if you had
irq_enter();
TRACE_1D();
...
TRACE_3D();
irq_exit();Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
Quoted 35 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 07.06.17 at 17:45, <[email protected]> wrote:
Quoted 23 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
xen/arch/x86/irq.c +0
-1@@ -884,9 +919,13 @@ void do_IRQ(struct cpu_user_regs *regs) desc->rl_quantum_start = now; } - tsc_in = tb_init_done ?get_cycles () :0 ;xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 930
Quoted 10 lines
xen/arch/x86/irq.c +6
-1+if (unlikely (tb_init_done) ) + { +__trace_var (TRC_HW_IRQ_GUEST ,0 ,sizeof (irq), &irq); + tsc_in =get_cycles (); + }__do_IRQ_guest (irq); -TRACE_3D (TRC_HW_IRQ_HANDLED , irq, tsc_in,get_cycles ()); +trace_irq_handled (irq,get_cycles () - tsc_in); goto out_no_end; }Before this change, the
get_cycles()invocation was after thetb_init_donecheck. Now you move it ahead of it (as the function arguments are evaluated before executing the function body) - are you sure all compiler versions will suitably re-order this?Quoted 6 lines
Additionally I'm afraid this will trigger compiler warnings on at least some compiler versions, as
tsc_inis now possibly uninitialized (and there's no clear way to disprove this for the compiler, again because function arguments are being evaluated before the function body is reached).I understand and (now that I see it) agree with your remark on when
get_cycles()is called. I'll reorganize things so that the patched behavior matches the existing one.
Quoted 7 lines
Quoted 2 lines
OTOH, I'm not sure I see the "potentially uninitialized" issue for
tsc_in, but since I'm reworking the code, I'll keep that in mind too.You initialize
tsc_inonly whentb_init_doneis set, but you use it without that conditional. And even if you used it under that same conditional, older compiler versions aren't able to track that fact (same conditional) and raise a warning anyway.
This patch changes thing to initialize tsc_in on declaration (at the top of the function).
If we want to keep the compiler "uninitialized variable" analysis around, that would have to go away and we'd want to do something like was there before. (I'm ambivalent about it, but I know Jan likes it.)
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
Quoted 40 lines
Quoted 1 line
Quoted 1 line · On 08.06.17 at 16:53, <[email protected]> wrote:
Quoted 38 lines · Jan Beulich
Quoted 37 lines
Quoted 1 line
Quoted 1 line · On 07.06.17 at 17:45, <[email protected]> wrote:
Quoted 23 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:33, <[email protected]> wrote:
xen/arch/x86/irq.c +0
-1@@ -884,9 +919,13 @@ void do_IRQ(struct cpu_user_regs *regs) desc->rl_quantum_start = now; } - tsc_in = tb_init_done ?get_cycles () :0 ;xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 930
Quoted 10 lines
xen/arch/x86/irq.c +6
-1+if (unlikely (tb_init_done) ) + { +__trace_var (TRC_HW_IRQ_GUEST ,0 ,sizeof (irq), &irq); + tsc_in =get_cycles (); + }__do_IRQ_guest (irq); -TRACE_3D (TRC_HW_IRQ_HANDLED , irq, tsc_in,get_cycles ()); +trace_irq_handled (irq,get_cycles () - tsc_in); goto out_no_end; }Before this change, the
get_cycles()invocation was after thetb_init_donecheck. Now you move it ahead of it (as the function arguments are evaluated before executing the function body) - are you sure all compiler versions will suitably re-order this?Quoted 6 lines
Additionally I'm afraid this will trigger compiler warnings on at least some compiler versions, as
tsc_inis now possibly uninitialized (and there's no clear way to disprove this for the compiler, again because function arguments are being evaluated before the function body is reached).I understand and (now that I see it) agree with your remark on when
get_cycles()is called. I'll reorganize things so that the patched behavior matches the existing one.OTOH, I'm not sure I see the "potentially uninitialized" issue for
tsc_in, but since I'm reworking the code, I'll keep that in mind too.
Quoted 7 lines
Quoted 4 lines
You initialize
tsc_inonly whentb_init_doneis set, but you use it without that conditional. And even if you used it under that same conditional, older compiler versions aren't able to track that fact (same conditional) and raise a warning anyway.This patch changes thing to initialize
tsc_inon declaration (at the top of the function).
Oh, it's only now that I actually see an initializer is being added. I'm sorry for the noise then.
Quoted 3 lines
If we want to keep the compiler "uninitialized variable" analysis around, that would have to go away and we'd want to do something like was there before. (I'm ambivalent about it, but I know Jan likes it.)
No, I'm fine with the change. I was just being blind.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing
In reply to Dario FaggioliQuoted 19 lines · Dario Faggioli
More specifically:
- the handling of theTRC_HW_IRQ_HANDLEDis fixed, both inxentrace_formatand in xenalyze;
- simple events for recording when we enter and exit thedo_IRQfunction, as well as when we deal with a guest IRQ, are added;
- tracing of IRQs handled with direct vectors is also added.With all the above, a trace will now look like this (using xenalyze):
0.001299072 .x- d32768v5
irq_enter, irq 80000000
0.001299072 .x- d32768v5irq_direct, vec fa, handler =0xffff82d08026d7e40.001300014 .x- d32768v5raise_softirqnr 0
0.001300487 .x- d32768v5irq_exitirq 80000000,in_irq= 0Or like this:
Quoted 8 lines
0.049437892 -|- d32767v12 irq_enter, irq 4 0.049437892 -|- d32767v12 irq_handled irq 4, 85428 cycles 0.049474336 -|- d32767v12 irq_exit irq 4, status = 0x0, in_irq = 0Making it much easier to figure out when interrupt processing start, what it does and when it ends.
Signed-off-by Dario Faggioli <[email protected]>
Generally looks good to me. I mostly agree with the commentary as well.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 4/15 tools: xenalyze: fix dumping of PM_IDLE events.
In reply to Dario FaggioliIn fact, not all the information present in the trace record were used and printed.
---
George Dunlap <[email protected]>
Ian Jackson <[email protected]>
Wei Liu <[email protected]>
--- tools/xentrace/xenalyze.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
tools/xentrace/xenalyze.c +19 -5
@@ -8269,9 +8269,10 @@ void pm_process(struct pcpu_info *p) {break ;case TRC_PM_IDLE_ENTRY :if (opt.dump_all ) -printf (" %s pm_idle_start c%d\n" , +printf (" %s pm_idle_start c%d, pm_tick=%u, exp=%dus, pred=%dus\n" , ri->dump_header, - ri->d[0 ]); + ri->d[0 ], ri->d[1 ], + ri->d[2 ], ri->d[3 ]);if ( ri->d[0 ] <=CSTATE_MAX ) { p->power_state=ri->d[0 ];
@@ -8280,9 +8281,22 @@ void pm_process(struct pcpu_info *p) {break ;case TRC_PM_IDLE_EXIT :if (opt.dump_all ) -printf (" %s pm_idle_end c%d\n" , - ri->dump_header, - ri->d[0 ]); + { +int i; + +printf (" %s pm_idle_end c%d pm_tick=%u" , + ri->dump_header, ri->d[0 ], ri->d[1 ]); +printf (", irr_status=%d" , ri->d[2 ]); +for (i =3 ; i <=5 ; i++) + { +if (ri->d[i] ==0 ) +break ; +printf (",%d" , ri->d[i]); + } +if (i ==6 ) +printf (",..." ); +printf ("\n" ); + }if ( p->power_state != ri->d[0 ] && p->power_state !=CSTATE_INVALID ) printf("Strange, pm_idle_end %d, power_state %d!\n",
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 04/15] tools: xenalyze: fix dumping of PM_IDLE events.
Quoted 4 lines · Dario Faggioli
In fact, not all the information present in the trace record were used and printed.
Signed-off-by Dario Faggioli <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 5/15 xen: make it possible to disable tracing in Kconfig.
In reply to Dario FaggioliAnd compile it out of the hypervisor entirely.
Code and other sections' sizes change as follows.
Output of size:
vanilla patched-Y patched-N
text 1929007 1929007 1902783
data 337784 337784 337688
bss 1310464 1310464 1310336
Output of size -A:
vanilla patched-Y patched-N
.text 1372602 1372602 1348026
.rodata 312152 312152 310680 .init.text 244209 244209 244033 .init.data 224576 224576 224576
.data 57472 57472 57376
.bss 1310464 1310464 1310336
Total 23026516 23027008 22858069
No functional change intended.
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Doug Goldstein <[email protected]>
--- xen/Kconfig.debug | 8 ++++++++ xen/arch/x86/hvm/svm/entry.S | 2 ++ xen/arch/x86/trace.c | 23 +++++++++++++++++++++++ xen/common/trace.c | 39 +++++++++++++++++++++++++++++++++++---- xen/drivers/cpufreq/utility.c | 7 +++++-- xen/include/xen/trace.h | 30 +++++++++++++++++++++++++++++- 6 files changed, 102 insertions(+), 7 deletions(-)
xen/Kconfig.debug +8 -0
@@ -98,6 +98,14 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. +config TRACING + bool "Tracing" + default y + ---help--- + Enables collecting traces of events occurring in the hypervisor + in per-CPU ring buffers. The 'xentrace' tool can be used to read + the buffers and dump the content on the disk. + config VERBOSE_DEBUG bool "Verbose debug messages"
xen/arch/x86/hvm/svm/entry.S +2 -0
@@ -61,10 +61,12 @@ __UNLIKELY_END(nsvm_hap) call svm_asid_handle_vmrun +#ifdef CONFIG_TRACING cmpb $0,tb_init_done(%rip) UNLIKELY_START(nz, svm_trace) call svm_trace_vmentry UNLIKELY_END(svm_trace) +#endif mov VCPU_svm_vmcb(%rbx),%rcx mov UREGS_rax(%rsp),%rax
xen/arch/x86/trace.c +23 -0
@@ -1,3 +1,4 @@ +#ifdef CONFIG_TRACING #include <xen/init.h> #include <xen/kernel.h> #include <xen/lib.h>
@@ -157,3 +158,25 @@ void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte) __trace_var(event, 1/*tsc*/, sizeof(d), &d); } } +#else /* !CONFIG_TRACING */ +#include <xen/kernel.h> +#include <xen/trace.h> + +void __trace_pv_trap (int trapnr,unsigned long eip, +int use_error_code,unsigned error_code) +{ +} +void __trace_pv_page_fault (unsigned long addr,unsigned error_code) +{ +} +void __trace_trap_one_addr (unsigned event,unsigned long va) +{ +} +void __trace_trap_two_addr (unsigned event,unsigned long va1, +unsigned long va2) +{ +} +void __trace_ptwr_emulation (unsigned long addr,l1_pgentry_t npte) +{ +} +#endif /* CONFIG_TRACING */
xen/common/trace.c +35 -4
@@ -48,6 +48,11 @@ static unsigned int opt_tevt_mask;integer_param ("tbuf_size" , opt_tbuf_size);integer_param ("tevt_mask" , opt_tevt_mask); +#ifdef CONFIG_TRACING +/* a flag recording whether initialization has been done */ +/* or more properly, if the tbuf subsystem is enabled right now */ +int tb_init_done__read_mostly ; +/* Pointers to the meta-data objects for all system trace buffers */ static struct t_info *t_info;static unsigned int t_info_pages;
@@ -64,10 +69,6 @@ static u32 t_buf_highwater; static DEFINE_PER_CPU(unsigned long, lost_records); static DEFINE_PER_CPU(unsigned long, lost_records_first_tsc); -/* a flag recording whether initialization has been done */ -/* or more properly, if the tbuf subsystem is enabled right now */ -int tb_init_done__read_mostly ; -/* which CPUs tracing is enabled on */ static cpumask_t tb_cpu_mask;
@@ -868,6 +869,36 @@ void __trace_hypercall(uint32_t event, unsigned long op, __trace_var(event, 1, sizeof(uint32_t) * (1 + (a - d.args)), &d); } +#else /* !CONFIG_TRACING */ +void __init init_trace_bufs (void ) +{ + opt_tbuf_size =0 ; +} + +int tb_control (xen_sysctl_tbuf_op_t *tbc) +{ +static DEFINE_SPINLOCK (lock); +int rc =0 ; + +spin_lock (&lock); + +switch ( tbc->cmd ) + { +case XEN_SYSCTL_TBUFOP_get_info: + tbc->evt_mask =0 ; + tbc->buffer_mfn =0 ; + tbc->size =0 ; +break ; +default : + rc = -ENOSYS ; +break ; + } + +spin_unlock (&lock); + +return rc; +} +#endif /* CONFIG_TRACING */ /* * Local variables:
xen/drivers/cpufreq/utility.c +5 -2
@@ -362,11 +362,14 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,if (cpu_online (policy->cpu) && cpufreq_driver->target) { -unsigned int prev_freq = policy->cur; +uint32_t d[2 ] = { policy->cur,0 }; retval = cpufreq_driver->target (policy, target_freq, relation);if ( retval ==0 ) -TRACE_2D (TRC_PM_FREQ_CHANGE , prev_freq/1000 , policy->cur/1000 ); + { + d[1 ] = policy->cur/1000 ; +trace_var (TRC_PM_FREQ_CHANGE ,1 ,sizeof (d), d); + } }return retval;
xen/include/xen/trace.h +29 -1
@@ -21,7 +21,11 @@#ifndef __XEN_TRACE_H__#define __XEN_TRACE_H__ +#ifdef CONFIG_TRACING extern int tb_init_done; +#else +#define tb_init_done 0 +#endif #include <public/sysctl.h> #include <public/trace.h>
@@ -33,6 +37,7 @@ void init_trace_bufs(void);/* used to retrieve the physical address of the trace buffers */ int tb_control (struct xen_sysctl_tbuf_op *tbc); +#ifdef CONFIG_TRACING int trace_will_trace_event (u32 event);void __trace_var (u32 event,bool_t cycles,unsigned int extra,const void *);
@@ -113,7 +118,7 @@ void __trace_hypercall(uint32_t event, unsigned long op, } \ } while ( 0 ) -#define TRACE_6D (_e,d1,d2,d3,d4,d5,d6) \ +#define TRACE_6D (_e,d1,d2,d3,d4,d5,d6) \ do { \ if ( unlikely(tb_init_done) ) \ { \
@@ -127,5 +132,28 @@ void __trace_hypercall(uint32_t event, unsigned long op,__trace_var (_e,1 ,sizeof (_d), _d); \ } \ } while ( 0 ) +#else /* !CONFIG_TRACING */ +#define trace_will_trace_event (u) (0) +static inline void __trace_var (u32 event,bool_t cycles,unsigned int extra, +const void *extra_data) +{ +} +static inline void trace_var (u32 event,int cycles,int extra, +const void *extra_data) +{ +} +static inline void __trace_hypercall (uint32_t event,unsigned long op, +const xen_ulong_t *args) +{ +} + +#define TRACE_0D (e) do {} while ( 0 ) +#define TRACE_1D (e,d1) do {} while ( 0 ) +#define TRACE_2D (e,d1,d2) do {} while ( 0 ) +#define TRACE_3D (e,d1,d2,d3) do {} while ( 0 ) +#define TRACE_4D (e,d1,d2,d3,d4) do {} while ( 0 ) +#define TRACE_5D (e,d1,d2,d3,d4,d5) do {} while ( 0 ) +#define TRACE_6D (e,d1,d2,d3,d4,d5,d6) do {} while ( 0 ) +#endif /* CONFIG_TRACING */ #endif /* __XEN_TRACE_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
Quoted 16 lines · Dario Faggioli
And compile it out of the hypervisor entirely.
Code and other sections' sizes change as follows.
Output of
size:
vanilla patched-Y patched-N
text 1929007 1929007 1902783
data 337784 337784 337688
bss 1310464 1310464 1310336Output of
size -A:
vanilla patched-Y patched-N
.text 1372602 1372602 1348026.rodata 312152 312152 310680 .init.text 244209 244209 244033 .init.data 224576 224576 224576
Quoted 7 lines
.data 57472 57472 57376
.bss 1310464 1310464 1310336
Total 23026516 23027008 22858069No functional change intended.
Signed-off-by Dario Faggioli <[email protected]>
I'm tempted to ack it on that diffstat alone ;p
However, I've got some suggestions to improve it.
Quoted 24 lines
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Doug Goldstein <[email protected]>--- xen/Kconfig.debug | 8 ++++++++ xen/arch/x86/hvm/svm/entry.S | 2 ++ xen/arch/x86/trace.c | 23 +++++++++++++++++++++++ xen/common/trace.c | 39 +++++++++++++++++++++++++++++++++++---- xen/drivers/cpufreq/utility.c | 7 +++++-- xen/include/xen/trace.h | 30 +++++++++++++++++++++++++++++- 6 files changed, 102 insertions(+), 7 deletions(-)xen/Kconfig.debug +0
-0
xen/Kconfig.debug config PERF_ARRAYS · line 107
Quoted 10 lines
xen/Kconfig.debug +7
-0@@ -98,6 +98,14 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. +config TRACING + bool "Tracing" + default y + ---help--- + Enables collecting traces of events occurring in the hypervisor + in per-CPU ring buffers. The 'xentrace' tool can be used to read + the buffers and dump the content on the disk.
The grammar here is a little unusual. How about extending it a little to this?
The tracing infrastructure allows Xen to record a log of events in per-CPU ring buffers, in binary form. These rings can be accessed in userspace with the 'xentrace' tool, and interpreted using 'xenalyze' or 'xentrace_format'.
Quoted 9 lines
xen/Kconfig.debug +1
-0+ config VERBOSE_DEBUG bool "Verbose debug messages"xen/arch/x86/hvm/svm/entry.S +0
-0
xen/arch/x86/hvm/svm/entry.S __UNLIKELY_END(nsvm_hap) · line 69
Quoted 9 lines
xen/arch/x86/hvm/svm/entry.S +2
-0@@ -61,10 +61,12 @@ __UNLIKELY_END(nsvm_hap) call svm_asid_handle_vmrun +#ifdef CONFIG_TRACING cmpb $0,tb_init_done(%rip) UNLIKELY_START(nz, svm_trace) call svm_trace_vmentry UNLIKELY_END(svm_trace) +#endif
You can also enclose svm_trace_vmentry() in svm.c with #ifdefary
Quoted 27 lines
xen/arch/x86/hvm/svm/entry.S +0
-0mov VCPU_svm_vmcb(%rbx),%rcx mov UREGS_rax(%rsp),%raxxen/arch/x86/trace.c +12
-0@@ -1,3 +1,4 @@ +#ifdef CONFIG_TRACING #include <xen/init.h> #include <xen/kernel.h> #include <xen/lib.h> @@ -157,3 +158,25 @@ void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte) __trace_var(event, 1/*tsc*/, sizeof(d), &d); } } +#else /* !CONFIG_TRACING */ +#include <xen/kernel.h> +#include <xen/trace.h> + +void __trace_pv_trap (int trapnr,unsigned long eip, +int use_error_code,unsigned error_code) +{ +} +void __trace_pv_page_fault (unsigned long addr,unsigned error_code) +{ +}
xen/arch/x86/trace.c void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte) · line 181
Quoted 10 lines
xen/arch/x86/trace.c +10
-0+void __trace_trap_one_addr (unsigned event,unsigned long va) +{ +} +void __trace_trap_two_addr (unsigned event,unsigned long va1, +unsigned long va2) +{ +} +void __trace_ptwr_emulation (unsigned long addr,l1_pgentry_t npte) +{ +}
These should all be static inlines in a header file. This will avoid forcing the compiler to insert a bunch of empty functions and have to call them, and it allows you to modify the x86 Makefile to be
andrewcoop@andrewcoop:/local/xen.git/xen$ git diff
xen/arch/x86/Makefile +1 -1
@@ -59,7 +59,7 @@ obj-y += srat.o obj-y += string.o obj-y += sysctl.o obj-y += time.o -obj-y += trace.o +obj-$(CONFIG_TRACE) += trace.o obj-y += traps.o obj-y += usercopy.o obj-y += x86_emulate.o
If you are feeling super keen, it would be great to move trace.c into the pv/ directory (as it is entirely PV specific), in line with cleanup that myself and Wei are slowly doing.
If you are going to do the move, it would be better to split that out into a separate patch ahead of introducing CONFIG_TRACE, and take the opportunity to fix the trailing whitespace and style issues in the file.
Quoted 29 lines
xen/arch/x86/trace.c +1
-0+#endif /* CONFIG_TRACING */ xen/common/trace.c +5
-4@@ -48,6 +48,11 @@ static unsigned int opt_tevt_mask;integer_param ("tbuf_size" , opt_tbuf_size);integer_param ("tevt_mask" , opt_tevt_mask); +#ifdef CONFIG_TRACING +/* a flag recording whether initialization has been done */ +/* or more properly, if the tbuf subsystem is enabled right now */ +int tb_init_done__read_mostly ; +/* Pointers to the meta-data objects for all system trace buffers */ static struct t_info *t_info;static unsigned int t_info_pages;@@ -64,10 +69,6 @@ static u32 t_buf_highwater; static DEFINE_PER_CPU(unsigned long, lost_records); static DEFINE_PER_CPU(unsigned long, lost_records_first_tsc); -/* a flag recording whether initialization has been done */ -/* or more properly, if the tbuf subsystem is enabled right now */ -int tb_init_done__read_mostly ; -/* which CPUs tracing is enabled on */ static cpumask_t tb_cpu_mask;
xen/common/trace.c void __trace_hypercall(uint32_t event, unsigned long op, · line 872
Quoted 4 lines
xen/common/trace.c +1
-0@@ -868,6 +869,36 @@ void __trace_hypercall(uint32_t event, unsigned long op, __trace_var(event, 1, sizeof(uint32_t) * (1 + (a - d.args)), &d); } +#else /* !CONFIG_TRACING */
Newlines here please.
xen/common/trace.c void __trace_hypercall(uint32_t event, unsigned long op, · line 875
Quoted 3 lines
xen/common/trace.c +3
-0+void __init init_trace_bufs (void ) +{ + opt_tbuf_size =0 ;
Why do you need this? I can't see it referenced anywhere outside of CONFIG_TRACING.
xen/common/trace.c void __trace_hypercall(uint32_t event, unsigned long op, · line 879
Quoted 4 lines
xen/common/trace.c +4
-0+} + +int tb_control (xen_sysctl_tbuf_op_t *tbc) +{
This also should be a static inline which return -EOPNOTSUPP.
Doing so would also allow common/trace.c to become obj-$(CONFIG_TRACE) as well.
Quoted 34 lines
xen/common/trace.c +22
-0+static DEFINE_SPINLOCK (lock); +int rc =0 ; + +spin_lock (&lock); + +switch ( tbc->cmd ) + { +case XEN_SYSCTL_TBUFOP_get_info: + tbc->evt_mask =0 ; + tbc->buffer_mfn =0 ; + tbc->size =0 ; +break ; +default : + rc = -ENOSYS ; +break ; + } + +spin_unlock (&lock); + + return rc; +} +#endif /* CONFIG_TRACING */ /* * Local variables: xen/drivers/cpufreq/utility.c +0
-1@@ -362,11 +362,14 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,if (cpu_online (policy->cpu) && cpufreq_driver->target) { -unsigned int prev_freq = policy->cur;
xen/drivers/cpufreq/utility.c int __cpufreq_driver_target(struct cpufreq_policy *policy, · line 373
Quoted 10 lines
xen/drivers/cpufreq/utility.c +5
-1+uint32_t d[2 ] = { policy->cur,0 }; retval = cpufreq_driver->target (policy, target_freq, relation);if ( retval ==0 ) -TRACE_2D (TRC_PM_FREQ_CHANGE , prev_freq/1000 , policy->cur/1000 ); + { + d[1 ] = policy->cur/1000 ; +trace_var (TRC_PM_FREQ_CHANGE ,1 ,sizeof (d), d); + } }
Is this hunk supposed to live in this patch?
Quoted 36 lines
xen/drivers/cpufreq/utility.c +0
-0return retval;xen/include/xen/trace.h +6
-1@@ -21,7 +21,11 @@#ifndef __XEN_TRACE_H__#define __XEN_TRACE_H__ +#ifdef CONFIG_TRACING extern int tb_init_done; +#else +#define tb_init_done 0 +#endif #include <public/sysctl.h> #include <public/trace.h> @@ -33,6 +37,7 @@ void init_trace_bufs(void);/* used to retrieve the physical address of the trace buffers */ int tb_control (struct xen_sysctl_tbuf_op *tbc); +#ifdef CONFIG_TRACING int trace_will_trace_event (u32 event);void __trace_var (u32 event,bool_t cycles,unsigned int extra,const void *);@@ -113,7 +118,7 @@ void __trace_hypercall(uint32_t event, unsigned long op, } \ } while ( 0 ) -#define TRACE_6D (_e,d1,d2,d3,d4,d5,d6) \ +#define TRACE_6D (_e,d1,d2,d3,d4,d5,d6) \ do { \ if ( unlikely(tb_init_done) ) \ { \
xen/include/xen/trace.h void __trace_hypercall(uint32_t event, unsigned long op, · line 136
Quoted 5 lines
xen/include/xen/trace.h +2
-0@@ -127,5 +132,28 @@ void __trace_hypercall(uint32_t event, unsigned long op, __trace_var(_e, 1, sizeof(_d), _d); \ } \ } while ( 0 ) +#else /* !CONFIG_TRACING */ +#define trace_will_trace_event (u) (0)
This needs to be a static inline, otherwise you get different behaviour WRT evaluating its arguments.
trace_will_trace_event() also looks like it is in need of turning into a bool function.
~Andrew
Quoted 14 lines
xen/include/xen/trace.h +13
-0+static inline void __trace_var (u32 event,bool_t cycles,unsigned int extra, +const void *extra_data) +{ +} +static inline void trace_var (u32 event,int cycles,int extra, +const void *extra_data) +{ +} +static inline void __trace_hypercall (uint32_t event,unsigned long op, +const xen_ulong_t *args) +{ +} +
xen/include/xen/trace.h void __trace_hypercall(uint32_t event, unsigned long op, · line 159
Quoted 10 lines
xen/include/xen/trace.h +8
-0+#define TRACE_0D (e) do {} while ( 0 ) +#define TRACE_1D (e,d1) do {} while ( 0 ) +#define TRACE_2D (e,d1,d2) do {} while ( 0 ) +#define TRACE_3D (e,d1,d2,d3) do {} while ( 0 ) +#define TRACE_4D (e,d1,d2,d3,d4) do {} while ( 0 ) +#define TRACE_5D (e,d1,d2,d3,d4,d5) do {} while ( 0 ) +#define TRACE_6D (e,d1,d2,d3,d4,d5,d6) do {} while ( 0 ) +#endif /* CONFIG_TRACING */ #endif /* __XEN_TRACE_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
Hi,
Quoted 11 lines · Andrew Cooper
On 01/06/17 18:34, Dario Faggioli wrote:
These should all be static inlines in a header file. This will avoid forcing the compiler to insert a bunch of empty functions and have to call them, and it allows you to modify the x86Makefileto beandrewcoop@andrewcoop:/local/xen.git/xen$ git diffxen/arch/x86/Makefile +0
-0
xen/arch/x86/Makefile obj-y += srat.o · line 65
Quoted 8 lines
xen/arch/x86/Makefile +1
-1@@ -59,7 +59,7 @@ obj-y += srat.o obj-y += string.o obj-y += sysctl.o obj-y += time.o -obj-y += trace.o +obj-$(CONFIG_TRACE) += trace.o obj-y += traps.o obj-y += usercopy.o obj-y += x86_emulate.o
I would use similar things for common/trace.c too. This would let the user remove all tracing code at build time.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
In reply to Dario Faggiolixen/Kconfig.debug config PERF_ARRAYS · line 103
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/Kconfig.debug +3
-0@@ -98,6 +98,14 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. +config TRACING + bool "Tracing" + default y
default DEBUG (you don't want to suggest turning it on for a release build)
xen/common/trace.c static unsigned int opt_tevt_mask; · line 54
Quoted 10 lines
xen/common/trace.c +4
-0@@ -48,6 +48,11 @@ static unsigned int opt_tevt_mask;integer_param ("tbuf_size" , opt_tbuf_size);integer_param ("tevt_mask" , opt_tevt_mask); +#ifdef CONFIG_TRACING +/* a flag recording whether initialization has been done */ +/* or more properly, if the tbuf subsystem is enabled right now */ +int tb_init_done__read_mostly ;
Switch to bool at once? And in any event correct the comment style please.
xen/drivers/cpufreq/utility.c int __cpufreq_driver_target(struct cpufreq_policy *policy, · line 365
Quoted 8 lines
xen/drivers/cpufreq/utility.c +1
-1@@ -362,11 +362,14 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,if (cpu_online (policy->cpu) && cpufreq_driver->target) { -unsigned int prev_freq = policy->cur; +uint32_t d[2 ] = { policy->cur,0 };
Notwithstanding Andrew's question about the placement of this hunk the ", 0" seems pointless to me.
xen/drivers/cpufreq/utility.c void init_trace_bufs(void); · line 41
Quoted 6 lines
xen/drivers/cpufreq/utility.c +1
-0@@ -33,6 +37,7 @@ void init_trace_bufs(void);/* used to retrieve the physical address of the trace buffers */ int tb_control (struct xen_sysctl_tbuf_op *tbc); +#ifdef CONFIG_TRACING int trace_will_trace_event (u32 event);
Please have a blank line between these, two of them around the matching #else, and one ahead of the #endif.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/Kconfig.debug +0
-0@@ -98,6 +98,14 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms.
Quoted 6 lines
xen/Kconfig.debug config PERF_ARRAYS · line 103
Quoted 3 lines
xen/Kconfig.debug +3
-0+config TRACING + bool "Tracing" + default ydefault DEBUG (you don't want to suggest turning it on for a release build)
In the past I've found it pretty useful to have on in release builds of XenServer, to analyze performance problems a customer was having, and sometimes to see where the guest was crashing.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 08.06.17 at 17:16, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/Kconfig.debug +0
-0@@ -98,6 +98,14 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms.Quoted 6 lines
xen/Kconfig.debug config PERF_ARRAYS · line 103
Quoted 3 lines
xen/Kconfig.debug +3
-0+config TRACING + bool "Tracing" + default ydefault DEBUG (you don't want to suggest turning it on for a release build)
Quoted 3 lines
In the past I've found it pretty useful to have on in release builds of XenServer, to analyze performance problems a customer was having, and sometimes to see where the guest was crashing.
Well, that's your choice. I'm only asking to default to off in release builds, not to prevent enabling it.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 08.06.17 at 17:16, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
xen/Kconfig.debug config PERF_ARRAYS · line 103
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/Kconfig.debug +3
-0@@ -98,6 +98,14 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. +config TRACING + bool "Tracing" + default ydefault DEBUG (you don't want to suggest turning it on for a release build)
Quoted 6 lines
Quoted 3 lines
In the past I've found it pretty useful to have on in release builds of XenServer, to analyze performance problems a customer was having, and sometimes to see where the guest was crashing.
Well, that's your choice. I'm only asking to default to off in release builds, not to prevent enabling it.
Of course; the question is, as you say, what we're "suggesting"; and what people will experience if they just go with the default.
If it were up to me I'd leave it on by default, but I don't have a strong opinion.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 08.06.17 at 17:37, <[email protected]> wrote:
Quoted 20 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 08.06.17 at 17:16, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/Kconfig.debug +0
-0@@ -98,6 +98,14 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms.Quoted 6 lines
xen/Kconfig.debug config PERF_ARRAYS · line 103
Quoted 3 lines
xen/Kconfig.debug +3
-0+config TRACING + bool "Tracing" + default ydefault DEBUG (you don't want to suggest turning it on for a release build)
In the past I've found it pretty useful to have on in release builds of XenServer, to analyze performance problems a customer was having, and sometimes to see where the guest was crashing.
Quoted 8 lines
Quoted 2 lines
Well, that's your choice. I'm only asking to default to off in release builds, not to prevent enabling it.
Of course; the question is, as you say, what we're "suggesting"; and what people will experience if they just go with the default.
If it were up to me I'd leave it on by default, but I don't have a strong opinion.
If you look at that section in Kconfig.debug, nothing defaults to y, and I think this is appropriate for debug options in general. I additionally think that defaults suggested in EXPERT mode should match the values automatically chosen in non-EXPERT mode.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/15] xen: make it possible to disable tracing in Kconfig.
In reply to Dario FaggioliQuoted 16 lines · Dario Faggioli
And compile it out of the hypervisor entirely.
Code and other sections' sizes change as follows.
Output of
size:
vanilla patched-Y patched-N
text 1929007 1929007 1902783
data 337784 337784 337688
bss 1310464 1310464 1310336Output of
size -A:
vanilla patched-Y patched-N
.text 1372602 1372602 1348026.rodata 312152 312152 310680 .init.text 244209 244209 244033 .init.data 224576 224576 224576
Quoted 7 lines
.data 57472 57472 57376
.bss 1310464 1310464 1310336
Total 23026516 23027008 22858069No functional change intended.
Signed-off-by Dario Faggioli <[email protected]>
Thanks Dario -- patch looks good overall; I agree with all of Jan and Andy's comments that I haven't responded to. :-)
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 6/15 xen: trace IRQ enabling/disabling
In reply to Dario FaggioliTrace when interrupts are disabled and (re)enabled. Basically, we replace the IRQ disabling and enabling functions with helpers that does the same, but also output the proper trace record.
For putting in the record something that will let us identify _where_ in the code (i.e., in what function) the IRQ manipulation is happening, use either:
- current_text_addr(),
- or __builtin_return_address(0).
In fact, depending on whether the disabling/enabling happens in macros (like for local_irq_disable() and local_irq_enable()) or in actual functions (like in spin_lock_irq*()), it is either:
- the actual content of the instruction pointer when IRQ are disabled/enabled,
- or the return address of the utility function where IRQ are disabled/enabled,
that will tell us what it is the actual piece of code that is asking for the IRQ manipulation operation.
Gate this with its specific Kconfig option, and keep it in disabled state by default (i.e., don't build it, if not explicitly specified), as the impact on performance may be non negligible.
---
Cc: George Dunlap <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jennifer Herbert <[email protected]>
--- xen/Kconfig.debug | 11 ++++- xen/common/spinlock.c | 16 +++++-- xen/common/trace.c | 10 +++- xen/include/asm-arm/arm32/system.h | 12 +++++ xen/include/asm-arm/arm64/system.h | 12 +++++ xen/include/asm-x86/system.h | 85 ++++++++++++++++++++++++++++++++++-- xen/include/public/trace.h | 2 + xen/include/xen/rwlock.h | 33 +++++++++++--- 8 files changed, 161 insertions(+), 20 deletions(-)
xen/Kconfig.debug +10 -1
@@ -98,7 +98,7 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. -config TRACING +menuconfig TRACING bool "Tracing" default y ---help---
@@ -106,6 +106,15 @@ config TRACING in per-CPU ring buffers. The 'xentrace' tool can be used to read the buffers and dump the content on the disk. +config TRACE_IRQSOFF + bool "Trace when IRQs are disabled and (re)enabled" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible to generate events _every_ time IRQs are disabled + and (re)enabled, with also an indication of where that happened. + Note that this comes with high overead and produces huge amount of + tracing data. config VERBOSE_DEBUG bool "Verbose debug messages"
xen/common/spinlock.c +12 -4
@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) ) +trace_irq_disable_ret ();_spin_lock (lock); }
@@ -158,7 +160,9 @@ unsigned long _spin_lock_irqsave(spinlock_t *lock) {unsigned long flags; -local_irq_save (flags); +_local_irq_save (flags); +if (unlikely (tb_init_done) ) +trace_irq_save_ret (flags);_spin_lock (lock);return flags; }
@@ -175,13 +179,17 @@ void _spin_unlock(spinlock_t *lock)void _spin_unlock_irq (spinlock_t *lock) {_spin_unlock (lock); -local_irq_enable (); +if (unlikely (tb_init_done) ) +trace_irq_enable_ret (); +_local_irq_enable (); }void _spin_unlock_irqrestore (spinlock_t *lock,unsigned long flags) {_spin_unlock (lock); -local_irq_restore (flags); +if (unlikely (tb_init_done) ) +trace_irq_restore_ret (flags); +_local_irq_restore (flags); }int _spin_is_locked (spinlock_t *lock)
xen/common/trace.c +8 -2
@@ -722,7 +722,12 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,/* Read tb_init_done /before/ t_bufs. */ smp_rmb (); -spin_lock_irqsave (&this_cpu (t_lock), flags); +/* +* spin_lock_irqsave() would call local_irq_save(), which (may) +* call __trace_var(). Open code it to avoid recursing. +*/ +_local_irq_save (flags); +spin_lock (&this_cpu (t_lock)); buf =this_cpu (t_bufs);
@@ -809,7 +814,8 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,__insert_record (buf, event, extra, cycles, rec_size, extra_data); unlock: -spin_unlock_irqrestore (&this_cpu (t_lock), flags); +spin_unlock (&this_cpu (t_lock)); +_local_irq_restore (flags);/* Notify trace buffer consumer that we've crossed the high water mark. */ if ( likely(buf!=NULL)
xen/include/asm-arm/arm32/system.h +12 -0
@@ -4,6 +4,8 @@#include <asm/arm32/cmpxchg.h> +#include <xen/trace.h> +#define local_irq_disable () asm volatile ( "cpsid i @ local_irq_disable\n" : : : "cc" )#define local_irq_enable () asm volatile ( "cpsie i @ local_irq_enable\n" : : : "cc" )
@@ -41,6 +43,16 @@ static inline int local_irq_is_enabled(void)#define local_abort_enable () __asm__("cpsie a @ __sta\n" : : : "memory", "cc")#define local_abort_disable () __asm__("cpsid a @ __sta\n" : : : "memory", "cc") +/* We do not support tracing (at all) yet */ +#define trace_irq_disable_ret () do { } while ( 0 ) +#define trace_irq_enable_ret () do { } while ( 0 ) +#define trace_irq_save_ret (_x) do { } while ( 0 ) +#define trace_irq_restore_ret (_x) do { } while ( 0 ) +#define _local_irq_disable () local_irq_disable() +#define _local_irq_enable () local_irq_enable() +#define _local_irq_save (_x) local_irq_save(_x) +#define _local_irq_restore (_x) local_irq_restore(_x) +static inline int local_fiq_is_enabled (void ) {unsigned long flags;
xen/include/asm-arm/arm64/system.h +12 -0
@@ -4,6 +4,8 @@#include <asm/arm64/cmpxchg.h> +#include <xen/trace.h> +/* Uses uimm4 as a bitmask to select the clearing of one or more of * the DAIF exception mask bits: * bit 3 selects the D mask,
@@ -44,6 +46,16 @@ : "memory"); \ }) +/* We do not support tracing (at all) yet */ +#define trace_irq_disable_ret () do { } while ( 0 ) +#define trace_irq_enable_ret () do { } while ( 0 ) +#define trace_irq_save_ret (_x) do { } while ( 0 ) +#define trace_irq_restore_ret (_x) do { } while ( 0 ) +#define _local_irq_disable () local_irq_disable() +#define _local_irq_enable () local_irq_enable() +#define _local_irq_save (_x) local_irq_save(_x) +#define _local_irq_restore (_x) local_irq_restore(_x) +static inline int local_irq_is_enabled (void ) {unsigned long flags;
xen/include/asm-x86/system.h +80 -5
112 lines not on this page · raw message
xen/include/public/trace.h +2 -0
@@ -275,6 +275,8 @@#define TRC_HW_IRQ_ENTER (TRC_HW_IRQ + 0xA)#define TRC_HW_IRQ_GUEST (TRC_HW_IRQ + 0xB)#define TRC_HW_IRQ_EXIT (TRC_HW_IRQ + 0xC) +#define TRC_HW_IRQ_DISABLE (TRC_HW_IRQ + 0xD) +#define TRC_HW_IRQ_ENABLE (TRC_HW_IRQ + 0xE)/* * Event Flags
xen/include/xen/rwlock.h +25 -8
@@ -73,14 +73,19 @@ static inline void _read_lock(rwlock_t *lock)static inline void _read_lock_irq (rwlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) ) +trace_irq_disable_ret ();_read_lock (lock); }static inline unsigned long _read_lock_irqsave (rwlock_t *lock) {unsigned long flags; -local_irq_save (flags); + +_local_irq_save (flags); +if (unlikely (tb_init_done) ) +trace_irq_save_ret (flags);_read_lock (lock);return flags; }
@@ -100,13 +105,17 @@ static inline void _read_unlock(rwlock_t *lock)static inline void _read_unlock_irq (rwlock_t *lock) {_read_unlock (lock); -local_irq_enable (); +if (unlikely (tb_init_done) ) +trace_irq_enable_ret (); +_local_irq_enable (); }static inline void _read_unlock_irqrestore (rwlock_t *lock,unsigned long flags) {_read_unlock (lock); -local_irq_restore (flags); +if (unlikely (tb_init_done) ) +trace_irq_restore_ret (flags); +_local_irq_restore (flags); }static inline int _rw_is_locked (rwlock_t *lock)
@@ -130,7 +139,9 @@ static inline void _write_lock(rwlock_t *lock)static inline void _write_lock_irq (rwlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) ) +trace_irq_disable_ret ();_write_lock (lock); }
@@ -138,7 +149,9 @@ static inline unsigned long _write_lock_irqsave(rwlock_t *lock) {unsigned long flags; -local_irq_save (flags); +_local_irq_save (flags); +if (unlikely (tb_init_done) ) +trace_irq_save_ret (flags);_write_lock (lock);return flags; }
@@ -171,13 +184,17 @@ static inline void _write_unlock(rwlock_t *lock)static inline void _write_unlock_irq (rwlock_t *lock) {_write_unlock (lock); -local_irq_enable (); +if (unlikely (tb_init_done) ) +trace_irq_enable_ret (); +_local_irq_enable (); }static inline void _write_unlock_irqrestore (rwlock_t *lock,unsigned long flags) {_write_unlock (lock); -local_irq_restore (flags); +if (unlikely (tb_init_done) ) +trace_irq_restore_ret (flags); +_local_irq_restore (flags); }static inline int _rw_is_write_locked (rwlock_t *lock)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 22 lines · Dario Faggioli
Trace when interrupts are disabled and (re)enabled. Basically, we replace the IRQ disabling and enabling functions with helpers that does the same, but also output the proper trace record.
For putting in the record something that will let us identify _where_ in the code (i.e., in what function) the IRQ manipulation is happening, use either:
-current_text_addr(),
- or__builtin_return_address(0).In fact, depending on whether the disabling/enabling happens in macros (like for
local_irq_disable()andlocal_irq_enable()) or in actual functions (like in spin_lock_irq*()), it is either:
- the actual content of the instruction pointer when IRQ are disabled/enabled,
- or the return address of the utility function where IRQ are disabled/enabled,
that will tell us what it is the actual piece of code that is asking for the IRQ manipulation operation.
Quoted 6 lines
Gate this with its specific
Kconfigoption, and keep it in disabled state by default (i.e., don't build it, if not explicitly specified), as the impact on performance may be non negligible.Signed-off-by Dario Faggioli <[email protected]>
This reminds me that I need to dust off my series which fixes local_irq_save() to not capture its variables by name.
I.e. it would be used as "flags = local_irq_save();" in the normal C way.
I'm fairly sure I can also improve the generated assembly.
Quoted 34 lines
---
Cc: George Dunlap <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jennifer Herbert <[email protected]>--- xen/Kconfig.debug | 11 ++++- xen/common/spinlock.c | 16 +++++-- xen/common/trace.c | 10 +++- xen/include/asm-arm/arm32/system.h | 12 +++++ xen/include/asm-arm/arm64/system.h | 12 +++++ xen/include/asm-x86/system.h | 85 ++++++++++++++++++++++++++++++++++-- xen/include/public/trace.h | 2 + xen/include/xen/rwlock.h | 33 +++++++++++--- 8 files changed, 161 insertions(+), 20 deletions(-)xen/Kconfig.debug +1
-1@@ -98,7 +98,7 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. -config TRACING +menuconfig TRACING bool "Tracing" default y ---help---@@ -106,6 +106,15 @@ config TRACING in per-CPU ring buffers. The 'xentrace' tool can be used to read the buffers and dump the content on the disk.
xen/Kconfig.debug config TRACING · line 117
Quoted 10 lines
xen/Kconfig.debug +9
-0+config TRACE_IRQSOFF + bool "Trace when IRQs are disabled and (re)enabled" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible to generate events _every_ time IRQs are disabled + and (re)enabled, with also an indication of where that happened. + Note that this comes with high overead and produces huge amount of + tracing data.
You've got mixed tabs/spaces here.
Quoted 8 lines
xen/Kconfig.debug +0
-0config VERBOSE_DEBUG bool "Verbose debug messages"xen/common/spinlock.c +0
-0
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 157
Quoted 9 lines
xen/common/spinlock.c +3
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) ) +trace_irq_disable_ret ();_spin_lock (lock); }
Is it sensible to do this way around?
By writing the trace record while interrupts are disabled, you do prevent nesting in the general case (but not in NMIs/MCEs or the irqsave() variants), but you increase the critical region while interrupts are disabled.
Alternatively, writing the trace record outside of the critical region would reduce the size of the region. Interpretation logic already needs to cope with nesting, so is one extra level of nesting in this corner case a problem?
Does the logic cope with the fact that interrupt gates automatically disable interrupts?
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 18 lines · Andrew Cooper
Quoted 5 lines · Dario Faggioli
xen/common/spinlock.c +0
-0xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 157
Quoted 9 lines
xen/common/spinlock.c +3
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock) void _spin_lock_irq(spinlock_t *lock) { ASSERT(local_irq_is_enabled()); - local_irq_disable(); + _local_irq_disable(); + if ( unlikely(tb_init_done) ) + trace_irq_disable_ret(); _spin_lock(lock); }Is it sensible to do this way around?
Well, I guess either variant has up and down sides, and it looks to me that there is no way to measure this, without interfering with the behavior of the thing being measured ("Once upon a time, there was a cat, who lived in a box. His name was Schrödinger..." :-D :-D :-D)
Quoted 4 lines
By writing the trace record while interrupts are disabled, you do prevent nesting in the general case (but not in NMIs/MCEs or the
irqsave()variants),
Forgive the ignorance, what's special about NMIs/MCAs that is relevant for this? About _irqsave(), I'm also not sure what you mean, as _irqsave() is already done differently than this.
Quoted 3 lines
but you increase the critical region while
interrupts are disabled.
I know.
Quoted 7 lines
Alternatively, writing the trace record outside of the critical region
would reduce the size of the region. Interpretation logic already needs
to cope with nesting, so is one extra level of nesting in this corner case a problem?
TBH, I was indeed trying to offer to the component that will be looking at and interpreting the data, the as clear as possible view on when IRQs are _actually_ disabled and enabled. As in, if nesting occurs, only the event corresponding to:
- the first local_irq_disable()
- the last local_irq_enable()
I.e., to not require that it (the interpretation logic) does understand nesting.
But more than this, what I was concerned about was the accuracy of the reporting itself. In fact, if I do as you suggest, I can be interrupted (as interrupts are still on) after having called trace_irq_disable(). That means the report will show higher IRQ disabled time period, for this instance, than what the reality is.
And the same is true on the enabling side, when I call trace_irq_enable() _before_ re-enabling interrupts, which has the same bad effect on the length of IRQ disabled section.
Maybe, considering that anything that will interrupt me in these cases, are other interrupts, that will most likely disable interrupts themselves, I should not worry too much about this... What do you think?
Quoted 3 lines
Does the logic cope with the fact that interrupt gates automatically disable interrupts?
Ah, right. No, it does not. I probably should mention this in the changelog. Any ideas of how to deal with that? If yes, I'm more than happy to fix this...
Thanks and Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 60 lines · Dario Faggioli
Quoted 18 lines · Andrew Cooper
Quoted 5 lines · Dario Faggioli
xen/common/spinlock.c +0
-0xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 157
Quoted 9 lines
xen/common/spinlock.c +3
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) ) +trace_irq_disable_ret ();_spin_lock (lock); }Is it sensible to do this way around?
Well, I guess either variant has up and down sides, and it looks to me that there is no way to measure this, without interfering with the behavior of the thing being measured ("Once upon a time, there was a cat, who lived in a box. His name was Schrödinger..." :-D :-D :-D)
Quoted 4 lines
By writing the trace record while interrupts are disabled, you do prevent nesting in the general case (but not in NMIs/MCEs or the
irqsave()variants),Forgive the ignorance, what's special about NMIs/MCAs that is relevant for this? About
_irqsave(), I'm also not sure what you mean, as_irqsave()is already done differently than this.Quoted 3 lines
but you increase the critical region while
interrupts are disabled.I know.
Quoted 7 lines
Alternatively, writing the trace record outside of the critical region
would reduce the size of the region. Interpretation logic already needs
to cope with nesting, so is one extra level of nesting in this corner case a problem?TBH, I was indeed trying to offer to the component that will be looking at and interpreting the data, the as clear as possible view on when IRQs are _actually_ disabled and enabled. As in, if nesting occurs, only the event corresponding to:
- the firstlocal_irq_disable()
- the lastlocal_irq_enable()I.e., to not require that it (the interpretation logic) does understand nesting.
But more than this, what I was concerned about was the accuracy of the reporting itself. In fact, if I do as you suggest, I can be interrupted (as interrupts are still on) after having called
trace_irq_disable(). That means the report will show higher IRQ disabled time period, for this instance, than what the reality is.
Quoted 8 lines
And the same is true on the enabling side, when I call
trace_irq_enable()_before_ re-enabling interrupts, which has the same bad effect on the length of IRQ disabled section.Maybe, considering that anything that will interrupt me in these cases, are other interrupts, that will most likely disable interrupts themselves, I should not worry too much about this... What do you think?
I think it would make the analysis easier to do it the way you've done it. It certainly does increase the length of the actual critical section, but we're already assuming that all of this code is going to be disabled unless people specifically want to do IRQ analysis, so I don't think that should be an issue.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
In reply to Dario FaggioliQuoted 8 lines
Quoted 1 line
Quoted 1 line · On 02.06.17 at 01:42, <[email protected]> wrote:
Quoted 4 lines · Andrew Cooper
By writing the trace record while interrupts are disabled, you do prevent nesting in the general case (but not in NMIs/MCEs or the
irqsave()variants),Forgive the ignorance, what's special about NMIs/MCAs that is relevant for this?
NMI/#MC can nest nevertheless, so preventing nesting in the common case doesn't mean you won't see nesting at all.
Quoted 6 lines
Quoted 3 lines
Does the logic cope with the fact that interrupt gates automatically disable interrupts?
Ah, right. No, it does not. I probably should mention this in the changelog. Any ideas of how to deal with that? If yes, I'm more than happy to fix this...
Well, respective entry points will need to update tracking state. See how Linux has placed certain macros to that effect on various entry paths.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
In reply to Dario FaggioliHi Dario,
Quoted 80 lines · Dario Faggioli
Trace when interrupts are disabled and (re)enabled. Basically, we replace the IRQ disabling and enabling functions with helpers that does the same, but also output the proper trace record.
For putting in the record something that will let us identify _where_ in the code (i.e., in what function) the IRQ manipulation is happening, use either:
-current_text_addr(),
- or__builtin_return_address(0).In fact, depending on whether the disabling/enabling happens in macros (like for
local_irq_disable()andlocal_irq_enable()) or in actual functions (like in spin_lock_irq*()), it is either:
- the actual content of the instruction pointer when IRQ are disabled/enabled,
- or the return address of the utility function where IRQ are disabled/enabled,
that will tell us what it is the actual piece of code that is asking for the IRQ manipulation operation.Gate this with its specific
Kconfigoption, and keep it in disabled state by default (i.e., don't build it, if not explicitly specified), as the impact on performance may be non negligible.Signed-off-by Dario Faggioli <[email protected]>---
Cc: George Dunlap <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jennifer Herbert <[email protected]>--- xen/Kconfig.debug | 11 ++++- xen/common/spinlock.c | 16 +++++-- xen/common/trace.c | 10 +++- xen/include/asm-arm/arm32/system.h | 12 +++++ xen/include/asm-arm/arm64/system.h | 12 +++++ xen/include/asm-x86/system.h | 85 ++++++++++++++++++++++++++++++++++-- xen/include/public/trace.h | 2 + xen/include/xen/rwlock.h | 33 +++++++++++--- 8 files changed, 161 insertions(+), 20 deletions(-)xen/Kconfig.debug +10
-1@@ -98,7 +98,7 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. -config TRACING +menuconfig TRACING bool "Tracing" default y ---help---@@ -106,6 +106,15 @@ config TRACING in per-CPU ring buffers. The 'xentrace' tool can be used to read the buffers and dump the content on the disk. +config TRACE_IRQSOFF + bool "Trace when IRQs are disabled and (re)enabled" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible to generate events _every_ time IRQs are disabled + and (re)enabled, with also an indication of where that happened. + Note that this comes with high overead and produces huge amount of + tracing data. config VERBOSE_DEBUG bool "Verbose debug messages"xen/common/spinlock.c +0
-0
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 154
Quoted 6 lines
xen/common/spinlock.c +2
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) )
__trace_var already contain a "if ( !tb_init_done )". It sounds pointless to do it twice, and also I think it is not obvious to understand the meaning of the check (i.e what is tb_init_done).
Would it be possible to hide this check and avoid check tb_init_done twice?
Quoted 14 lines
xen/include/asm-arm/arm32/system.h +2
-0@@ -4,6 +4,8 @@#include <asm/arm32/cmpxchg.h> +#include <xen/trace.h> +#define local_irq_disable () asm volatile ( "cpsid i @ local_irq_disable\n" : : : "cc" )#define local_irq_enable () asm volatile ( "cpsie i @ local_irq_enable\n" : : : "cc" )
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 46
Quoted 4 lines
xen/include/asm-arm/arm32/system.h +1
-0@@ -41,6 +43,16 @@ static inline int local_irq_is_enabled(void)#define local_abort_enable () __asm__("cpsie a @ __sta\n" : : : "memory", "cc")#define local_abort_disable () __asm__("cpsid a @ __sta\n" : : : "memory", "cc") +/* We do not support tracing (at all) yet */
I know that some bits are missing for ARM, but the patch #5 contradicts this comment as you have CONFIG_TRACE=y by default.
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 55
Quoted 9 lines
xen/include/asm-arm/arm32/system.h +9
-0+#define trace_irq_disable_ret () do { } while ( 0 ) +#define trace_irq_enable_ret () do { } while ( 0 ) +#define trace_irq_save_ret (_x) do { } while ( 0 ) +#define trace_irq_restore_ret (_x) do { } while ( 0 ) +#define _local_irq_disable () local_irq_disable() +#define _local_irq_enable () local_irq_enable() +#define _local_irq_save (_x) local_irq_save(_x) +#define _local_irq_restore (_x) local_irq_restore(_x) +
This does not need to be duplicated in both asm-arm/arm{32,64}/system.h. You could directly implement them in asm-arm/system.h.
Also, I would prefer if you stay consistent with x86. I.e non-underscore versions are calling the underscore versions and not the invert.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 2 lines · Julien Grall
Hi Dario,
Hi,
Quoted 17 lines · Dario Faggioli
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 154
Quoted 11 lines
xen/common/spinlock.c +2
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock) void _spin_lock_irq(spinlock_t *lock) { ASSERT(local_irq_is_enabled()); - local_irq_disable(); + _local_irq_disable(); + if ( unlikely(tb_init_done) )
__trace_varalready contain a "if ( !tb_init_done )". It sounds pointless to do it twice, and also I think it is not obvious to understand the meaning of the check (i.e what istb_init_done).
Quoted 3 lines
Would it be possible to hide this check and avoid check
tb_init_donetwice?
I totally agree. And in fact, in another patch, I remove the tb_init_done check in __trace_var(). Reason behind this is that all the callers of __trace_var() (the main one being trace_var()), already checks for tb_init_done themselves.
In fact, the explicit check in the caller, is the (only) basis on which one decides to call either trace_var() or __trace_var().
This here is one of the call sites where I think the check is better done in the caller.
Quoted 22 lines
Quoted 22 lines
xen/include/asm- renamed from xen/include/asm-arm/arm32/system.h +0
-0
arm/arm32/system.h
index c617b40..20871ad 100644xen/include/asm-arm/arm32/system.h +2
-0@@ -4,6 +4,8 @@ #include <asm/arm32/cmpxchg.h> +#include <xen/trace.h> + #define local_irq_disable() asm volatile ( "cpsid i @ local_irq_disable\n" : : : "cc" ) #define local_irq_enable() asm volatile ( "cpsie i @local_irq_enable\n" : : : "cc" )
xen/include/asm-arm/arm32/system.h +0
-0@@ -41,6 +43,16 @@ static inline int local_irq_is_enabled(void) #define local_abort_enable() __asm__("cpsie a @ __sta\n" : : : "memory", "cc") #define local_abort_disable() __asm__("cpsid a @ __sta\n" : : : "memory", "cc")
Quoted 6 lines
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 48
Quoted 1 line
xen/include/asm-arm/arm32/system.h +1
-0+/* We do not support tracing (at all) yet */ I know that some bits are missing for ARM, but the patch #5 contradicts
this comment as you haveCONFIG_TRACE=yby default.
No sure what you mean. Tracing is de facto on by default right now, despite it not being implemented for ARM. So what I'm doing is basically keeping things as they are.
If you think it should be off by default, well, let's talk about it... but I'm not sure this is really what you are saying/asking.
Quoted 5 lines
Quoted 5 lines
xen/include/asm-arm/arm32/system.h +5
-0+#define trace_irq_disable_ret () do { } while ( 0 ) +#define trace_irq_enable_ret () do { } while ( 0 ) +#define trace_irq_save_ret (_x) do { } while ( 0 ) +#define trace_irq_restore_ret (_x) do { } while ( 0 ) +#define _local_irq_disable () local_irq_disable()
Quoted 9 lines
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 55
Quoted 4 lines
xen/include/asm-arm/arm32/system.h +4
-0+#define _local_irq_enable () local_irq_enable() +#define _local_irq_save (_x) local_irq_save(_x) +#define _local_irq_restore (_x) local_irq_restore(_x) +This does not need to be duplicated in both asm-
arm/arm{32,64}/system.h.
You could directly implement them inasm-arm/system.h.
Ok, thanks.
Quoted 4 lines
Also, I would prefer if you stay consistent with x86. I.e non- underscore
versions are calling the underscore versions and not the invert.
Well, I know it is counterintuitive, but it's the easiest way of getting over this, i.e., without the need of a lot of stubs, and touching as few existing code as possible.
But I certainly can give it a try doing it as you say, and see how it ends up looking like.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 30 lines · Dario Faggioli
Quoted 2 lines · Julien Grall
Hi Dario,
Hi,
Quoted 17 lines · Dario Faggioli
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 154
Quoted 11 lines
xen/common/spinlock.c +2
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) )
__trace_varalready contain a "if ( !tb_init_done )". It sounds pointless to do it twice, and also I think it is not obvious to understand the meaning of the check (i.e what istb_init_done).Quoted 3 lines
Would it be possible to hide this check and avoid check
tb_init_donetwice?I totally agree. And in fact, in another patch, I remove the
tb_init_donecheck in__trace_var(). Reason behind this is that all the callers of__trace_var()(the main one beingtrace_var()), already checks fortb_init_donethemselves.
Quoted 5 lines
In fact, the explicit check in the caller, is the (only) basis on which one decides to call either
trace_var()or__trace_var().This here is one of the call sites where I think the check is better done in the caller.
I admit, it is a bit confusing to require the caller to check tb_init_done. It adds more code and IHMO counterintuitive.
Quoted 29 lines
Quoted 23 lines
Quoted 23 lines
xen/include/asm- renamed from xen/include/asm-arm/arm32/system.h +0
-0
arm/arm32/system.h
index c617b40..20871ad 100644xen/include/asm-arm/arm32/system.h +2
-0@@ -4,6 +4,8 @@#include <asm/arm32/cmpxchg.h> +#include <xen/trace.h> +#define local_irq_disable () asm volatile ( "cpsid i @ local_irq_disable\n" : : : "cc" )#define local_irq_enable () asm volatile ( "cpsie i @local_irq_enable\n" : : : "cc" )
xen/include/asm-arm/arm32/system.h +0
-0@@ -41,6 +43,16 @@ static inline int local_irq_is_enabled(void)#define local_abort_enable () __asm__("cpsie a @ __sta\n" : : : "memory", "cc")#define local_abort_disable () __asm__("cpsid a @ __sta\n" : : : "memory", "cc")Quoted 6 lines
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 48
Quoted 1 line
xen/include/asm-arm/arm32/system.h +1
-0+/* We do not support tracing (at all) yet */ I know that some bits are missing for ARM, but the patch #5 contradicts
this comment as you haveCONFIG_TRACE=yby default.
Quoted 6 lines
No sure what you mean. Tracing is de facto on by default right now, despite it not being implemented for ARM. So what I'm doing is basically keeping things as they are.
If you think it should be off by default, well, let's talk about it... but I'm not sure this is really what you are saying/asking.
I mean that CONFIG_TRACE=y by default gives the impression that tracing is supported on ARM. This is not the case, hence your comment. So I think it should be off my default until we get the support. BTW, it is only a couple of simple patches but they never made upstreamed :/
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
xen/include/asm-arm/arm32/system.h +5
-0+#define trace_irq_disable_ret () do { } while ( 0 ) +#define trace_irq_enable_ret () do { } while ( 0 ) +#define trace_irq_save_ret (_x) do { } while ( 0 ) +#define trace_irq_restore_ret (_x) do { } while ( 0 ) +#define _local_irq_disable () local_irq_disable()Quoted 9 lines
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 55
Quoted 4 lines
xen/include/asm-arm/arm32/system.h +4
-0+#define _local_irq_enable () local_irq_enable() +#define _local_irq_save (_x) local_irq_save(_x) +#define _local_irq_restore (_x) local_irq_restore(_x) +This does not need to be duplicated in both asm-
arm/arm{32,64}/system.h.
You could directly implement them inasm-arm/system.h.Ok, thanks.
Quoted 7 lines
Quoted 4 lines
Also, I would prefer if you stay consistent with x86. I.e non- underscore
versions are calling the underscore versions and not the invert.Well, I know it is counterintuitive, but it's the easiest way of getting over this, i.e., without the need of a lot of stubs, and touching as few existing code as possible.
Can you detail here? The only things I was asking is to do:
#define _local_irq_disable() ......
#define local_irq_disable() _local_irq_disable.
The callers would still use local_irq_disable() and the code would be consistent with x86.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 33 lines · Julien Grall
Quoted 30 lines · Dario Faggioli
Quoted 2 lines · Julien Grall
Hi Dario,
Hi,
Quoted 17 lines · Dario Faggioli
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 154
Quoted 11 lines
xen/common/spinlock.c +2
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) )
__trace_varalready contain a "if ( !tb_init_done )". It sounds pointless to do it twice, and also I think it is not obvious to understand the meaning of the check (i.e what istb_init_done).Quoted 3 lines
Would it be possible to hide this check and avoid check
tb_init_donetwice?I totally agree. And in fact, in another patch, I remove the
tb_init_donecheck in__trace_var(). Reason behind this is that all the callers of__trace_var()(the main one beingtrace_var()), already checks fortb_init_donethemselves.
Quoted 8 lines
Quoted 5 lines
In fact, the explicit check in the caller, is the (only) basis on which one decides to call either
trace_var()or__trace_var().This here is one of the call sites where I think the check is better done in the caller.
I admit, it is a bit confusing to require the caller to check
tb_init_done. It adds more code and IHMO counterintuitive.
BTW, I am not responsible of this code, so if the REST maintainers are happy with that then fine.
Quoted 77 lines
Quoted 30 lines
Quoted 24 lines
Quoted 24 lines
xen/include/asm- renamed from xen/include/asm-arm/arm32/system.h +0
-0
arm/arm32/system.h
index c617b40..20871ad 100644xen/include/asm-arm/arm32/system.h +2
-0@@ -4,6 +4,8 @@#include <asm/arm32/cmpxchg.h> +#include <xen/trace.h> +#define local_irq_disable () asm volatile ( "cpsid i @ local_irq_disable\n" : : : "cc" )#define local_irq_enable () asm volatile ( "cpsie i @local_irq_enable\n" : : : "cc" )
xen/include/asm-arm/arm32/system.h +0
-0@@ -41,6 +43,16 @@ static inline int local_irq_is_enabled(void)#define local_abort_enable () __asm__("cpsie a @ __sta\n" : : : "memory", "cc")#define local_abort_disable () __asm__("cpsid a @ __sta\n" : : : "memory", "cc")Quoted 6 lines
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 48
Quoted 1 line
xen/include/asm-arm/arm32/system.h +1
-0+/* We do not support tracing (at all) yet */ I know that some bits are missing for ARM, but the patch #5 contradicts
this comment as you haveCONFIG_TRACE=yby default.Quoted 6 lines
No sure what you mean. Tracing is de facto on by default right now, despite it not being implemented for ARM. So what I'm doing is basically keeping things as they are.
If you think it should be off by default, well, let's talk about it... but I'm not sure this is really what you are saying/asking.
I mean that
CONFIG_TRACE=yby default gives the impression that tracing is supported on ARM. This is not the case, hence your comment. So I think it should be off my default until we get the support. BTW, it is only a couple of simple patches but they never made upstreamed :/Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
xen/include/asm-arm/arm32/system.h +5
-0+#define trace_irq_disable_ret () do { } while ( 0 ) +#define trace_irq_enable_ret () do { } while ( 0 ) +#define trace_irq_save_ret (_x) do { } while ( 0 ) +#define trace_irq_restore_ret (_x) do { } while ( 0 ) +#define _local_irq_disable () local_irq_disable()Quoted 9 lines
xen/include/asm-arm/arm32/system.h static inline int local_irq_is_enabled(void) · line 55
Quoted 4 lines
xen/include/asm-arm/arm32/system.h +4
-0+#define _local_irq_enable () local_irq_enable() +#define _local_irq_save (_x) local_irq_save(_x) +#define _local_irq_restore (_x) local_irq_restore(_x) +This does not need to be duplicated in both asm-
arm/arm{32,64}/system.h.
You could directly implement them inasm-arm/system.h.Ok, thanks.
Quoted 7 lines
Quoted 4 lines
Also, I would prefer if you stay consistent with x86. I.e non- underscore
versions are calling the underscore versions and not the invert.Well, I know it is counterintuitive, but it's the easiest way of getting over this, i.e., without the need of a lot of stubs, and touching as few existing code as possible.
Can you detail here? The only things I was asking is to do:
#define
_local_irq_disable()......#define
local_irq_disable()_local_irq_disable.The callers would still use
local_irq_disable()and the code would be consistent with x86.Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
In reply to Julien GrallQuoted 33 lines · Julien Grall
Quoted 30 lines · Dario Faggioli
Quoted 2 lines · Julien Grall
Hi Dario,
Hi,
Quoted 17 lines · Dario Faggioli
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 154
Quoted 11 lines
xen/common/spinlock.c +2
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) )
__trace_varalready contain a "if ( !tb_init_done )". It sounds pointless to do it twice, and also I think it is not obvious to understand the meaning of the check (i.e what istb_init_done).Quoted 3 lines
Would it be possible to hide this check and avoid check
tb_init_donetwice?I totally agree. And in fact, in another patch, I remove the
tb_init_donecheck in__trace_var(). Reason behind this is that all the callers of__trace_var()(the main one beingtrace_var()), already checks fortb_init_donethemselves.
Quoted 8 lines
Quoted 5 lines
In fact, the explicit check in the caller, is the (only) basis on which one decides to call either
trace_var()or__trace_var().This here is one of the call sites where I think the check is better done in the caller.
I admit, it is a bit confusing to require the caller to check
tb_init_done. It adds more code and IHMO counterintuitive.
Because a number of the traces include a certain amount if "marshalling" work ahead of time; there's no point in making space for a struct on the stack, carefully reading and sorting all kinds if things to put into it, only to have the data ignored because tracing isn't enabled (which is by far the most common case).
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 40 lines · George Dunlap
Quoted 39 lines · Julien Grall
Quoted 35 lines · Dario Faggioli
Quoted 2 lines · Julien Grall
Hi Dario,
Hi,
Quoted 17 lines · Dario Faggioli
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 154
Quoted 11 lines
xen/common/spinlock.c +2
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable (); +if (unlikely (tb_init_done) )
__trace_varalready contain a "if ( !tb_init_done )". It sounds pointless to do it twice, and also I think it is not obvious to understand the meaning of the check (i.e what istb_init_done).Quoted 3 lines
Would it be possible to hide this check and avoid check
tb_init_donetwice?I totally agree. And in fact, in another patch, I remove the
tb_init_donecheck in__trace_var(). Reason behind this is that all the callers of__trace_var()(the main one beingtrace_var()), already checks fortb_init_donethemselves.In fact, the explicit check in the caller, is the (only) basis on which one decides to call either
trace_var()or__trace_var().This here is one of the call sites where I think the check is better done in the caller.
Quoted 8 lines
Quoted 2 lines
I admit, it is a bit confusing to require the caller to check
tb_init_done. It adds more code and IHMO counterintuitive.Because a number of the traces include a certain amount if "marshalling" work ahead of time; there's no point in making space for a struct on the stack, carefully reading and sorting all kinds if things to put into it, only to have the data ignored because tracing isn't enabled (which is by far the most common case).
At the moment all the callers have the semantic:
if ( !unlikely(tb_init_done) )
trace_irq_*
So why not hiding that in the macro trace_irq_disable/trace_irq_enable...?
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
In reply to Dario FaggioliQuoted 62 lines · Dario Faggioli
Trace when interrupts are disabled and (re)enabled. Basically, we replace the IRQ disabling and enabling functions with helpers that does the same, but also output the proper trace record.
For putting in the record something that will let us identify _where_ in the code (i.e., in what function) the IRQ manipulation is happening, use either:
-current_text_addr(),
- or__builtin_return_address(0).In fact, depending on whether the disabling/enabling happens in macros (like for
local_irq_disable()andlocal_irq_enable()) or in actual functions (like in spin_lock_irq*()), it is either:
- the actual content of the instruction pointer when IRQ are disabled/enabled,
- or the return address of the utility function where IRQ are disabled/enabled,
that will tell us what it is the actual piece of code that is asking for the IRQ manipulation operation.Gate this with its specific
Kconfigoption, and keep it in disabled state by default (i.e., don't build it, if not explicitly specified), as the impact on performance may be non negligible.Signed-off-by Dario Faggioli <[email protected]>---
Cc: George Dunlap <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jennifer Herbert <[email protected]>--- xen/Kconfig.debug | 11 ++++- xen/common/spinlock.c | 16 +++++-- xen/common/trace.c | 10 +++- xen/include/asm-arm/arm32/system.h | 12 +++++ xen/include/asm-arm/arm64/system.h | 12 +++++ xen/include/asm-x86/system.h | 85 ++++++++++++++++++++++++++++++++++-- xen/include/public/trace.h | 2 + xen/include/xen/rwlock.h | 33 +++++++++++--- 8 files changed, 161 insertions(+), 20 deletions(-)xen/Kconfig.debug +1
-1@@ -98,7 +98,7 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. -config TRACING +menuconfig TRACING bool "Tracing" default y ---help---@@ -106,6 +106,15 @@ config TRACING in per-CPU ring buffers. The 'xentrace' tool can be used to read the buffers and dump the content on the disk.
xen/Kconfig.debug config TRACING · line 117
Quoted 10 lines
xen/Kconfig.debug +9
-0+config TRACE_IRQSOFF + bool "Trace when IRQs are disabled and (re)enabled" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible to generate events _every_ time IRQs are disabled + and (re)enabled, with also an indication of where that happened. + Note that this comes with high overead and produces huge amount of + tracing data.
*overhead (yours is missing an 'h')
I think I might emphasize that the overhead well be present even when tracing is off. What about something like this?
"Note that this comes with an overhead even when tracing is disabled; and has a high overhead and produces a large amount of tracing data when enabled."
With that change:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
Quoted 27 lines · George Dunlap
Quoted 26 lines · Dario Faggioli
xen/Kconfig.debug +0
-0@@ -98,7 +98,7 @@ config PERF_ARRAYS---help---
Enables software performance counter array histograms.xen/Kconfig.debug +1
-1-config TRACING +menuconfig TRACINGbool "Tracing"
default y
---help---xen/Kconfig.debug +0
-0@@ -106,6 +106,15 @@ config TRACINGin per-CPU ring buffers. The 'xentrace' tool can be used to read
the buffers and dump the content on the disk.xen/Kconfig.debug +2
-0+config TRACE_IRQSOFF + bool "Trace when IRQs are disabled and (re)enabled" ifEXPERT = "y"
xen/Kconfig.debug +4
-0+ default n + depends on TRACING + ---help--- + Makes it possible to generate events _every_ time IRQsare disabled
Quoted 9 lines
Quoted 5 lines
+ and (re)enabled, with also an indication of where that happened.
+ Note that this comes with high overead and produces huge amount of
+ tracing data.I think I might emphasize that the overhead well be present even when tracing is off. What about something like this?
Yes, good point.
Quoted 5 lines
"Note that this comes with an overhead even when tracing is disabled; and has a high overhead and produces a large amount of tracing data when
enabled."
I like it, I'll go for it.
Quoted 4 lines
With that change:
Acked-by George Dunlap <[email protected]>
Thanks and Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 06/15] xen: trace IRQ enabling/disabling
In reply to Dario Faggiolixen/Kconfig.debug config TRACING · line 111
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/Kconfig.debug +3
-0@@ -106,6 +106,15 @@ config TRACING in per-CPU ring buffers. The 'xentrace' tool can be used to read the buffers and dump the content on the disk. +config TRACE_IRQSOFF + bool "Trace when IRQs are disabled and (re)enabled" if EXPERT = "y" + default n
I'm not aware of any behavioral difference between this an not specifying a default at all, so I'd like to ask to follow suit (see surrounding code) and omit this line.
xen/common/spinlock.c void _spin_lock(spinlock_t *lock) · line 153
Quoted 8 lines
xen/common/spinlock.c +1
-1@@ -150,7 +150,9 @@ void _spin_lock(spinlock_t *lock)void _spin_lock_irq (spinlock_t *lock) {ASSERT (local_irq_is_enabled ()); -local_irq_disable (); +_local_irq_disable ();
Hmm, looks you're introducing new non-static, underscore-prefixed symbols. Please don't, use e.g. a "arch_" prefix or a "_notrace" suffix instead.
xen/include/asm-x86/system.h line 8
Quoted 7 lines
xen/include/asm-x86/system.h +1
-0@@ -5,6 +5,8 @@#include <xen/bitops.h> #include <asm/processor.h> +#include <xen/trace.h>
Why?
Quoted 66 lines
xen/include/asm-x86/system.h +62
-0@@ -214,6 +216,79 @@ static always_inline unsigned long __xadd( "ri" ( (x) & X86_EFLAGS_IF ) ); \ }) +#ifdef CONFIG_TRACE_IRQSOFF + +#define TRACE_LOCAL_ADDR ((uint64_t) current_text_addr()) +#define TRACE_RET_ADDR ((uint64_t) __builtin_return_address(0)) + +#define trace_irq_disable (_a) \ +({ \ + uint64_t addr = _a; \ + __trace_var(TRC_HW_IRQ_DISABLE, 1, sizeof(addr), &addr); \ +}) +#define trace_irq_enable (_a) \ +({ \ + uint64_t addr = _a; \ + __trace_var(TRC_HW_IRQ_ENABLE, 1, sizeof(addr), &addr); \ +}) +#define trace_irq_save (_x, _a) \ +({ \ + uint64_t addr = _a; \ + if ( _x & X86_EFLAGS_IF ) \ + __trace_var(TRC_HW_IRQ_DISABLE, 1, sizeof(addr), &addr); \ +}) +#define trace_irq_restore (_x, _a) \ +({ \ + uint64_t addr = _a; \ + if ( _x & X86_EFLAGS_IF ) \ + __trace_var(TRC_HW_IRQ_ENABLE, 1, sizeof(addr), &addr); \ +}) + +#define trace_irq_disable_ret () trace_irq_disable(TRACE_RET_ADDR) +#define trace_irq_enable_ret () trace_irq_enable(TRACE_RET_ADDR) +#define trace_irq_save_ret (_x) trace_irq_save(_x, TRACE_RET_ADDR) +#define trace_irq_restore_ret (_x) trace_irq_restore(_x, TRACE_RET_ADDR) + +#define local_irq_disable () \ +({ \ + bool_t irqon = local_irq_is_enabled(); \ + _local_irq_disable(); \ + if ( unlikely(tb_init_done && irqon) ) \ + trace_irq_disable(TRACE_LOCAL_ADDR); \ +}) + +#define local_irq_enable () \ +({ \ + if ( unlikely(tb_init_done) ) \ + trace_irq_enable(TRACE_LOCAL_ADDR); \ + _local_irq_enable(); \ +}) + +#define local_irq_save (_x) \ +({ \ + local_save_flags(_x); \ + _local_irq_disable(); \ + if ( unlikely(tb_init_done) ) \ + trace_irq_save(_x, TRACE_LOCAL_ADDR); \ +}) + +#define local_irq_restore (_x) \ +({ \ + if ( unlikely(tb_init_done) ) \ + trace_irq_restore(_x, TRACE_LOCAL_ADDR); \ + _local_irq_restore(_x); \ +})
xen/include/asm-x86/system.h static always_inline unsigned long __xadd( · line 290
Quoted 10 lines
xen/include/asm-x86/system.h +10
-0+#else /* !TRACE_IRQSOFF */ +#define trace_irq_disable_ret () do { } while ( 0 ) +#define trace_irq_enable_ret () do { } while ( 0 ) +#define trace_irq_save_ret (_x) do { } while ( 0 ) +#define trace_irq_restore_ret (_x) do { } while ( 0 ) +#define local_irq_disable () _local_irq_disable() +#define local_irq_enable () _local_irq_enable() +#define local_irq_save (_x) _local_irq_save(_x) +#define local_irq_restore (_x) _local_irq_restore(_x) +#endif /* TRACE_IRQSOFF */
None of this looks to be arch-specific.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 7/15 tools: tracing: handle IRQs on/off events in xentrace and xenalyze
In reply to Dario Faggioliso the trace will show properly decoded info, rather than just a bunch of hex codes.
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Jennifer Herbert <[email protected]>
--- tools/xentrace/formats | 2 ++ tools/xentrace/xenalyze.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
tools/xentrace/formats +2 -0
@@ -202,6 +202,8 @@ 0x0080200a CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_irq [ irq = %(1)d ] 0x0080200b CPU%(cpu)d %(tsc)d (+%(reltsc)8d) do_guest_irq [ irq = %(1)d ] 0x0080200c CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_exit [ irq = %(1)d, status = 0x%(2)x, in_irq = %(3)d ] +0x0080200d CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_disable [ from = 0x%(2)08x%(1)08x ] +0x0080200e CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_enable [ from = 0x%(2)08x%(1)08x ] 0x00084001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hpet create [ tn = %(1)d, irq = %(2)d, delta = 0x%(4)08x%(3)08x, period = 0x%(6)08x%(5)08x ] 0x00084002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pit create [ delta = 0x%(1)016x, period = 0x%(2)016x ]
tools/xentrace/xenalyze.c +16 -0
@@ -8562,6 +8562,22 @@ void irq_process(struct pcpu_info *p) { }break ; } +case TRC_HW_IRQ_DISABLE : +case TRC_HW_IRQ_ENABLE : + { +struct { +uint64_t addr; + } *r = (typeof (r ))ri->d; + +if ( opt.dump_all ) + { +printf (" %s irq_%s, from %p\n" , + ri->dump_header, + ri->event ==TRC_HW_IRQ_DISABLE ?"disable" :"enable" , + (void *)r->addr); + } +break ; + }case TRC_HW_IRQ_CLEAR_VECTOR :case TRC_HW_IRQ_MOVE_FINISH :default :
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 07/15] tools: tracing: handle IRQs on/off events in xentrace and xenalyze
Quoted 4 lines · Dario Faggioli
so the trace will show properly decoded info,
rather than just a bunch of hex codes.Signed-off-by Dario Faggioli <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 8/15 xen: trace RCU behavior
In reply to Dario FaggioliMaking it possible generate events showing the activity and the behavior of the RCU subsystem.
Gate this with its specific Kconfig option (under CONFIG_TRACING), and keep it in disabled state by default.
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
--- xen/Kconfig.debug | 8 ++++ xen/common/rcupdate.c | 82 ++++++++++++++++++++++++++++++++++++++++---- xen/include/public/trace.h | 14 ++++++++ 3 files changed, 97 insertions(+), 7 deletions(-)
xen/Kconfig.debug +8 -0
@@ -116,6 +116,14 @@ config TRACE_IRQSOFF Note that this comes with high overead and produces huge amount of tracing data. +config TRACE_RCU + bool "Trace RCU behavior" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible generate events showing the activity and the + behavior of the RCU subsystem. + config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG
xen/common/rcupdate.c +75 -7
169 lines not on this page · raw message
xen/include/public/trace.h +14 -0
@@ -39,6 +39,7 @@#define TRC_PV 0x0020f000/* Xen PV traces */ #define TRC_SHADOW 0x0040f000/* Xen shadow tracing */ #define TRC_HW 0x0080f000/* Xen hardware-related traces */ +#define TRC_XEN 0x0100f000/* Xen misc traces (RCU, softirq, etc) */ #define TRC_GUEST 0x0800f000/* Guest-generated traces */ #define TRC_ALL 0x0ffff000#define TRC_HD_TO_EVENT (x) ((x)&0x0fffffff)
@@ -92,6 +93,9 @@#define TRC_HW_PM 0x00801000/* Power management traces */ #define TRC_HW_IRQ 0x00802000/* Traces relating to the handling of IRQs */ +/* Trace subclasses for Xen internals */ +#define TRC_XEN_RCU 0x01001000/* RCU traces */ +/* Trace events per class */ #define TRC_LOST_RECORDS (TRC_GEN + 1)#define TRC_TRACE_WRAP_BUFFER (TRC_GEN + 2)
@@ -278,6 +282,16 @@#define TRC_HW_IRQ_DISABLE (TRC_HW_IRQ + 0xD)#define TRC_HW_IRQ_ENABLE (TRC_HW_IRQ + 0xE) +/* Trace events for RCU */ +#define TRC_XEN_RCU_FORCE_QSTATE (TRC_XEN_RCU + 0x1) +#define TRC_XEN_RCU_CALL_RCU (TRC_XEN_RCU + 0x2) +#define TRC_XEN_RCU_START_BATCH (TRC_XEN_RCU + 0x3) +#define TRC_XEN_RCU_DO_BATCH (TRC_XEN_RCU + 0x4) +#define TRC_XEN_RCU_CPU_QUIET (TRC_XEN_RCU + 0x5) +#define TRC_XEN_RCU_CHECK_QSTATE (TRC_XEN_RCU + 0x6) +#define TRC_XEN_RCU_DO_CALLBKS (TRC_XEN_RCU + 0x7) +#define TRC_XEN_RCU_PENDING (TRC_XEN_RCU + 0x8) +/* * Event Flags *
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 08/15] xen: trace RCU behavior
xen/common/rcupdate.c static int qhimark = 10000; · line 98
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/common/rcupdate.c +4
-0@@ -92,6 +92,57 @@ static int qhimark = 10000;static int qlowmark =100 ;static int rsinterval =1000 ; +#ifdef CONFIG_TRACE_RCU +static inline void trace_call_rcu (void *func) +{ +uint64_t addr = (uint64_t )func;
I've probably overlooked something similar in patch 6 - why uint64_t rather than unsigned long? Does this even build without warning for ARM32?
xen/common/rcupdate.c static int qhimark = 10000; · line 105
Quoted 6 lines
xen/common/rcupdate.c +6
-0+if (likely (!tb_init_done) ) +return ; + +__trace_var (TRC_XEN_RCU_CALL_RCU ,0 ,sizeof (addr), &addr); +} +static inline void trace_start_batch (const cpumask_t *m)
Blank lines between functions please.
xen/common/rcupdate.c static int qhimark = 10000; · line 112
Quoted 7 lines
xen/common/rcupdate.c +7
-0+{ +uint32_t mask[6 ]; + +if (likely (!tb_init_done) ) +return ; + +memset (mask,0 ,sizeof (mask));
Perhaps better use {} as initializer?
xen/common/rcupdate.c static int qhimark = 10000; · line 113
Quoted 1 line
xen/common/rcupdate.c +1
-0+memcpy (mask, m,min (sizeof (mask),sizeof (cpumask_t)));
sizeof(*m)
Quoted 4 lines
xen/common/rcupdate.c +4
-0+#define trace_force_qstate () TRACE_0D(TRC_XEN_RCU_FORCE_QSTATE) +#define trace_cpu_quiet () TRACE_0D(TRC_XEN_RCU_CPU_QUIET) +#define trace_check_qstate (p) TRACE_1D(TRC_XEN_RCU_CHECK_QSTATE, p) +#define trace_do_callbacks () TRACE_0D(TRC_XEN_RCU_DO_CALLBKS)
xen/common/rcupdate.c static int qhimark = 10000; · line 143
Quoted 10 lines
xen/common/rcupdate.c +10
-0+#define trace_pending (p) TRACE_1D(TRC_XEN_RCU_PENDING, p) +#else /* !TRACE_RCU */ +#define trace_call_rcu (f) do {} while ( 0 ) +#define trace_start_batch (m) do {} while ( 0 ) +#define trace_do_batch (f, q) do {} while ( 0 ) +#define trace_force_qstate () do {} while ( 0 ) +#define trace_cpu_quiet () do {} while ( 0 ) +#define trace_check_qstate (p) do {} while ( 0 ) +#define trace_do_callbacks () do {} while ( 0 ) +#define trace_pending (p) do {} while ( 0 )
Here and elsewhere please make sure you evaluate macro arguments consistently (i.e. exactly once regardless of tracing being enabled or disabled).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 08/15] xen: trace RCU behavior
In reply to Dario FaggioliQuoted 56 lines · Dario Faggioli
Making it possible generate events showing the activity and the behavior of the RCU subsystem.
Gate this with its specific
Kconfigoption (underCONFIG_TRACING), and keep it in disabled state by default.
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>--- xen/Kconfig.debug | 8 ++++ xen/common/rcupdate.c | 82 ++++++++++++++++++++++++++++++++++++++++---- xen/include/public/trace.h | 14 ++++++++ 3 files changed, 97 insertions(+), 7 deletions(-)xen/Kconfig.debug +8
-0@@ -116,6 +116,14 @@ config TRACE_IRQSOFF Note that this comes with high overead and produces huge amount of tracing data. +config TRACE_RCU + bool "Trace RCU behavior" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible generate events showing the activity and the + behavior of the RCU subsystem. + config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUGxen/common/rcupdate.c +10
-0@@ -92,6 +92,57 @@ static int qhimark = 10000;static int qlowmark =100 ;static int rsinterval =1000 ; +#ifdef CONFIG_TRACE_RCU +static inline void trace_call_rcu (void *func) +{ +uint64_t addr = (uint64_t )func; + +if (likely (!tb_init_done) ) +return ; + +__trace_var (TRC_XEN_RCU_CALL_RCU ,0 ,sizeof (addr), &addr); +}
xen/common/rcupdate.c static int qhimark = 10000; · line 114
Quoted 10 lines
xen/common/rcupdate.c +10
-0+static inline void trace_start_batch (const cpumask_t *m) +{ +uint32_t mask[6 ]; + +if (likely (!tb_init_done) ) +return ; + +memset (mask,0 ,sizeof (mask)); +memcpy (mask, m,min (sizeof (mask),sizeof (cpumask_t))); +__trace_var (TRC_XEN_RCU_START_BATCH ,0 ,sizeof (mask), &mask);
Another possibility here would be to say something like:
size = min(sizeof(mask), sizeof(cpumask_t))memcpy(mask, m, size)__trace_var(..., 0, size, &mask)
That would result in a more efficient log on systems which, say, had defied NR_CPUS to something relatively small for efficiency reasons; and you wouldn't need to clear the unused bits.
Everything else looks good (with Jan's comments).
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 9/15 tools: tracing: handle RCU events in xentrace and xenalyze
In reply to Dario Faggioli---
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/xentrace/analyze.h | 1 tools/xentrace/formats | 9 ++++ tools/xentrace/xenalyze.c | 114 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-)
tools/xentrace/analyze.h +1 -0
@@ -13,6 +13,7 @@#define TRC_PV_MAIN 5#define TRC_SHADOW_MAIN 6#define TRC_HW_MAIN 7 +#define TRC_XEN_MAIN 8#define TRC_LOST_RECORDS_END (TRC_GEN + 50)
tools/xentrace/formats +9 -0
@@ -205,6 +205,15 @@ 0x0080200d CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_disable [ from = 0x%(2)08x%(1)08x ] 0x0080200e CPU%(cpu)d %(tsc)d (+%(reltsc)8d) irq_enable [ from = 0x%(2)08x%(1)08x ] +0x01001001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_force_qstate [ ] +0x01001002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_call [ fn = 0x%(2)08x%(1)08x ] +0x01001003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_start_batch [ CPU mask: 0x%(6)08x%(5)08x%(4)08x%(3)08x%(2)08x%(1)08x ] +0x01001004 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_do_batch [ fn = 0x%(2)08x%(1)08x, qlen = 0x%(4)08x%(3)08x ] +0x01001005 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_cpu_quiet [ ] +0x01001006 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_check_qstate [ pending = %(d)d ] +0x01001007 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_do_callbacks [ ] +0x01001008 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_pending [ %(1)d ] + 0x00084001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hpet create [ tn = %(1)d, irq = %(2)d, delta = 0x%(4)08x%(3)08x, period = 0x%(6)08x%(5)08x ] 0x00084002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pit create [ delta = 0x%(1)016x, period = 0x%(2)016x ] 0x00084003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rtc create [ delta = 0x%(1)016x , period = 0x%(2)016x ]
tools/xentrace/xenalyze.c +113 -1
144 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 09/15] tools: tracing: handle RCU events in xentrace and xenalyze
Quoted 1 line · Dario Faggioli
Signed-off-by Dario Faggioli <[email protected]>
Looks good; you'll just have to adjust the START_BATCH code if you make that a variable-sized record.
If that doesn't end up happening:
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 10/15 xen: trace softirqs
In reply to Dario FaggioliMaking it possible generate events showing the activity and the behavior of the softirq subsystem.
Gate this with its specific Kconfig option (under CONFIG_TRACING), and keep it in disabled state by default.
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
--- xen/Kconfig.debug | 8 ++++++ xen/common/softirq.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/public/trace.h | 7 +++++ 3 files changed, 73 insertions(+)
xen/Kconfig.debug +8 -0
@@ -124,6 +124,14 @@ config TRACE_RCU Makes it possible generate events showing the activity and the behavior of the RCU subsystem. +config TRACE_SOFTIRQS + bool "Trace when softirqs are raised and handled" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible to generate events related to raising and + handling of softirqs within Xen. + config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG
xen/common/softirq.c +58 -0
94 lines not on this page · raw message
xen/include/public/trace.h +7 -0
@@ -95,6 +95,7 @@/* Trace subclasses for Xen internals */ #define TRC_XEN_RCU 0x01001000/* RCU traces */ +#define TRC_XEN_SIRQ 0x01002000/* Traces relating to softirqs */ /* Trace events per class */ #define TRC_LOST_RECORDS (TRC_GEN + 1)
@@ -292,6 +293,12 @@#define TRC_XEN_RCU_DO_CALLBKS (TRC_XEN_RCU + 0x7)#define TRC_XEN_RCU_PENDING (TRC_XEN_RCU + 0x8) +/* Trace events for softirqs */ +#define TRC_XEN_SIRQ_HANDLER (TRC_XEN_SIRQ + 0x1) +#define TRC_XEN_SIRQ_RAISE_MASK (TRC_XEN_SIRQ + 0x2) +#define TRC_XEN_SIRQ_RAISE_CPU (TRC_XEN_SIRQ + 0x3) +#define TRC_XEN_SIRQ_RAISE (TRC_XEN_SIRQ + 0x4) +/* * Event Flags *
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 10/15] xen: trace softirqs
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:34, <[email protected]> wrote:
xen/Kconfig.debug config TRACE_RCU · line 133
Quoted 10 lines
xen/Kconfig.debug +7
-0@@ -124,6 +124,14 @@ config TRACE_RCU Makes it possible generate events showing the activity and the behavior of the RCU subsystem. +config TRACE_SOFTIRQS + bool "Trace when softirqs are raised and handled" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible to generate events related to raising and + handling of softirqs within Xen.
Indentation (and again no default please). Other comments given earlier apply here (and generally to other patches in this series).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 11/15 tools: tracing: handle RCU events in xentrace and xenalyze
In reply to Dario Faggioli---
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/xentrace/formats | 5 +++ tools/xentrace/xenalyze.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)
tools/xentrace/formats +5 -0
@@ -214,6 +214,11 @@ 0x01001007 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_do_callbacks [ ] 0x01001008 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rcu_pending [ %(1)d ] +0x01002001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) softirq_handler [ nr:pending_mask = 0x%(1)08x ] +0x01002002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) softirq_raise_cpumask [ nr = %(1)d, CPU mask: 0x%(7)08x%(6)08x%(5)08x%(4)08x%(3)08x%(2)08x ] +0x01002003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) softirq_raise_cpu [ nr:cpu = 0x%(1)08x ] +0x01002004 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) softirq_raise [ nr = %(1)d ] + 0x00084001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hpet create [ tn = %(1)d, irq = %(2)d, delta = 0x%(4)08x%(3)08x, period = 0x%(6)08x%(5)08x ] 0x00084002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pit create [ delta = 0x%(1)016x, period = 0x%(2)016x ] 0x00084003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rtc create [ delta = 0x%(1)016x , period = 0x%(2)016x ]
tools/xentrace/xenalyze.c +82 -0
100 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 12/15 xen: trace tasklets
In reply to Dario FaggioliMaking it possible generate events showing the activity and the behavior of tasklets.
Gate this with its specific Kconfig option (under CONFIG_TRACING), and keep it in disabled state by default.
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
--- xen/Kconfig.debug | 8 ++++ xen/common/tasklet.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/public/trace.h | 9 +++++ 3 files changed, 104 insertions(+)
xen/Kconfig.debug +8 -0
@@ -132,6 +132,14 @@ config TRACE_SOFTIRQS Makes it possible to generate events related to raising and handling of softirqs within Xen. +config TRACE_TASKLETS + bool "Trace when tasklets are queued and scheduled" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Make it possible to generate events related to scheduling, + queueing and running of tasklets within Xen. + config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG
xen/common/tasklet.c +87 -0
133 lines not on this page · raw message
xen/include/public/trace.h +9 -0
@@ -96,6 +96,7 @@/* Trace subclasses for Xen internals */ #define TRC_XEN_RCU 0x01001000/* RCU traces */ #define TRC_XEN_SIRQ 0x01002000/* Traces relating to softirqs */ +#define TRC_XEN_TSKLT 0x01004000/* Traces relating to tasklets */ /* Trace events per class */ #define TRC_LOST_RECORDS (TRC_GEN + 1)
@@ -299,6 +300,14 @@#define TRC_XEN_SIRQ_RAISE_CPU (TRC_XEN_SIRQ + 0x3)#define TRC_XEN_SIRQ_RAISE (TRC_XEN_SIRQ + 0x4) +/* Trace events for tasklets */ +#define TRC_XEN_TASKLET_ENQUEUE (TRC_XEN_TSKLT + 0x1) +#define TRC_XEN_TASKLET_SCHEDULE (TRC_XEN_TSKLT + 0x2) +#define TRC_XEN_TASKLET_WORK (TRC_XEN_TSKLT + 0x3) +#define TRC_XEN_TASKLET_KILL (TRC_XEN_TSKLT + 0x4) +#define TRC_XEN_TASKLET_INIT (TRC_XEN_TSKLT + 0x5) +#define TRC_XEN_TASKLET_MIGR (TRC_XEN_TSKLT + 0x6) +/* * Event Flags *
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 12/15] xen: trace tasklets
Quoted 71 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:35, <[email protected]> wrote:
xen/common/tasklet.c +64
-0@@ -30,10 +30,87 @@ static DEFINE_PER_CPU(struct list_head, softirq_tasklet_list);/* Protects all lists and tasklet structures. */ static DEFINE_SPINLOCK (tasklet_lock); +#ifdef CONFIG_TRACE_TASKLETS +static inline void trace_enqueue (const struct tasklet *t) +{ +uint64_t addr; + +if (likely (!tb_init_done) ) +return ; + + addr = (uint64_t )t->func; +__trace_var (TRC_XEN_TASKLET_ENQUEUE ,0 ,sizeof (addr), &addr); +} +static inline void trace_schedule (const struct tasklet *t) +{ +struct { +uint64_t addr; +int16_t sched_on, is_sirq; + } d; + +if (likely (!tb_init_done) ) +return ; + + d.addr = (uint64_t )t->func; + d.sched_on = t->scheduled_on; + d.is_sirq = t->is_softirq; +__trace_var (TRC_XEN_TASKLET_SCHEDULE ,1 ,sizeof (d), &d); +} +static inline void trace_work (const struct tasklet *t) +{ +uint64_t addr; + +if (likely (!tb_init_done) ) +return ; + + addr = (uint64_t )t->func; +__trace_var (TRC_XEN_TASKLET_WORK ,1 ,sizeof (addr), &addr); +} +static inline void trace_kill (const struct tasklet *t) +{ +struct { +uint64_t addr; +int16_t sched_on, is_run; + } d; + +if (likely (!tb_init_done) ) +return ; + + d.addr = (uint64_t )t->func; + d.sched_on = t->scheduled_on; + d.is_run = t->is_running; +__trace_var (TRC_XEN_TASKLET_KILL ,0 ,sizeof (d), &d); +} +static inline void trace_init (const struct tasklet *t) +{ +struct { +uint64_t addr; +uint32_t is_sirq; + } d; + +if (likely (!tb_init_done) ) +return ; + + d.addr = (uint64_t )t->func; + d.is_sirq = t->is_softirq; +__trace_var (TRC_XEN_TASKLET_INIT ,0 ,sizeof (d), &d);
xen/common/tasklet.c static DEFINE_PER_CPU(struct list_head, softirq_tasklet_list); · line 106
Quoted 10 lines
xen/common/tasklet.c +10
-0+} +#define trace_migrate () TRACE_0D(TRC_XEN_TASKLET_MIGR); +#else +#define trace_enqueue (t) do {} while ( 0 ) +#define trace_schedule (t) do {} while ( 0 ) +#define trace_work (t) do {} while ( 0 ) +#define trace_kill (t) do {} while ( 0 ) +#define trace_migrate () do {} while ( 0 ) +#define trace_init (t) do {} while ( 0 ) +#endif /* TRACE_TASKLETS */
Seeing how such additions add up, I think I'd prefer if you put them into header files instead of cluttering source files this way. You could have one such header per traceable component.
xen/common/tasklet.c static void migrate_tasklets_from_cpu(unsigned int cpu, struct list_head *list) · line 266
Quoted 10 lines
xen/common/tasklet.c +5
-0@@ -178,6 +258,11 @@ static void migrate_tasklets_from_cpu(unsigned int cpu, struct list_head *list)spin_lock_irqsave (&tasklet_lock, flags); +if (list_empty (list) ) + goto out; + +trace_migrate (); +while ( !list_empty (list) )
Two alternatives:
if ( !list_empty(list) )
trace_migrate();
(avoiding the goto) or
if ( list_empty(list) )
goto out;
trace_migrate();
do {
...
} while ( !list_empty(list) );(avoiding the redundant check).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 12/15] xen: trace tasklets
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:35, <[email protected]> wrote:
xen/common/tasklet.c +1
-0@@ -30,10 +30,87 @@ static DEFINE_PER_CPU(struct list_head, +#else
Quoted 12 lines
xen/common/tasklet.c static DEFINE_PER_CPU(struct list_head, softirq_tasklet_list); · line 106
Quoted 7 lines
xen/common/tasklet.c +7
-0+#define trace_enqueue (t) do {} while ( 0 ) +#define trace_schedule (t) do {} while ( 0 ) +#define trace_work (t) do {} while ( 0 ) +#define trace_kill (t) do {} while ( 0 ) +#define trace_migrate () do {} while ( 0 ) +#define trace_init (t) do {} while ( 0 ) +#endif /* TRACE_TASKLETS */ Seeing how such additions add up, I think I'd prefer if you put them into header files instead of cluttering source files this way. You could have one such header per traceable component.
Right, good point.
As a matter of fact, the components dealt with in this series, have their own header already, such as:
xen/include/xen/rcupdate.h
xen/include/xen/timer.h
xen/include/xen/softirq.h
xen/include/xen/tasklet.h
I guess I can put these there?
Quoted 22 lines
Quoted 11 lines
xen/common/tasklet.c +0
-0@@ -178,6 +258,11 @@ static void migrate_tasklets_from_cpu(unsigned int cpu, struct list_head *list)
spin_lock_irqsave(&tasklet_lock, flags);
+ if (list_empty(list))
+ goto out;xen/common/tasklet.c +3
-0+ + trace_migrate(); +while ( !list_empty(list) )
Two alternatives:
if ( !list_empty(list) )
trace_migrate();(avoiding the goto) or
if (
list_empty(list))
goto out;
Quoted 8 lines
trace_migrate();
do {
...
} while ( !list_empty(list) );(avoiding the redundant check).
Sure.
Thanks and Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 12/15] xen: trace tasklets
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 09.06.17 at 13:17, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 01.06.17 at 19:35, <[email protected]> wrote:
xen/common/tasklet.c +1
-0@@ -30,10 +30,87 @@ static DEFINE_PER_CPU(struct list_head, +#else Quoted 12 lines
xen/common/tasklet.c static DEFINE_PER_CPU(struct list_head, softirq_tasklet_list); · line 106
Quoted 7 lines
xen/common/tasklet.c +7
-0+#define trace_enqueue (t) do {} while ( 0 ) +#define trace_schedule (t) do {} while ( 0 ) +#define trace_work (t) do {} while ( 0 ) +#define trace_kill (t) do {} while ( 0 ) +#define trace_migrate () do {} while ( 0 ) +#define trace_init (t) do {} while ( 0 ) +#endif /* TRACE_TASKLETS */ Seeing how such additions add up, I think I'd prefer if you put them into header files instead of cluttering source files this way. You could have one such header per traceable component.
Right, good point.
As a matter of fact, the components dealt with in this series, have their own header already, such as:
Quoted 6 lines
xen/include/xen/rcupdate.h
xen/include/xen/timer.h
xen/include/xen/softirq.h
xen/include/xen/tasklet.hI guess I can put these there?
No, please don't - these definitions don't need to be seen by everyone including these headers. Instead I'd like to suggest having a separate trace/ directory where they could all go (at once eliminating the need to prefix their names with e.g. trace_).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 13/15 tools: tracing: handle tasklets events in xentrace and xenalyze
In reply to Dario Faggioli---
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/xentrace/formats | 7 +++ tools/xentrace/xenalyze.c | 92 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
tools/xentrace/formats +7 -0
@@ -219,6 +219,13 @@ 0x01002003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) softirq_raise_cpu [ nr:cpu = 0x%(1)08x ] 0x01002004 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) softirq_raise [ nr = %(1)d ] +0x01004001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_enqueue [ fn = 0x%(2)08x%(1)08x ] +0x01004002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_schedule [ fn = 0x%(2)08x%(1)08x, is_sirq:sched_on = 0x%(3)08x ] +0x01004003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_work [ fn = 0x%(2)08x%(1)08x ] +0x01004004 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_kill [ fn = 0x%(2)08x%(1)08x, is_run:sched_on = 0x%(3)08x ] +0x01004005 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_init [ fn = 0x%(2)08x%(1)08x, is_sirq = %(3)d ] +0x01004006 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_migr [ ] + 0x00084001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hpet create [ tn = %(1)d, irq = %(2)d, delta = 0x%(4)08x%(3)08x, period = 0x%(6)08x%(5)08x ] 0x00084002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pit create [ delta = 0x%(1)016x, period = 0x%(2)016x ] 0x00084003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rtc create [ delta = 0x%(1)016x , period = 0x%(2)016x ]
tools/xentrace/xenalyze.c +92 -0
110 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 14/15 xen: trace timers
In reply to Dario FaggioliMaking it possible generate events showing the activity and the behavior of timers.
Gate this with its specific Kconfig option (under CONFIG_TRACING), and keep it in disabled state by default.
---
Cc: George Dunlap <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
--- xen/Kconfig.debug | 9 +++ xen/common/timer.c | 158 ++++++++++++++++++++++++++++++++++++++++++-- xen/include/public/trace.h | 12 +++ 3 files changed, 173 insertions(+), 6 deletions(-)
xen/Kconfig.debug +9 -0
@@ -140,6 +140,15 @@ config TRACE_TASKLETS Make it possible to generate events related to scheduling, queueing and running of tasklets within Xen. ++config TRACE_TIMERS + bool "Trace when timers are armed and fires" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible to generate events related to the timers + subsystems, such as, creation, initialization, queueing, + firing and removal of timers. + config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG
xen/common/timer.c +152 -6
239 lines not on this page · raw message
xen/include/public/trace.h +12 -0
@@ -97,6 +97,7 @@#define TRC_XEN_RCU 0x01001000/* RCU traces */ #define TRC_XEN_SIRQ 0x01002000/* Traces relating to softirqs */ #define TRC_XEN_TSKLT 0x01004000/* Traces relating to tasklets */ +#define TRC_XEN_TIMER 0x01008000/* Trace relating to timer events */ /* Trace events per class */ #define TRC_LOST_RECORDS (TRC_GEN + 1)
@@ -308,6 +309,17 @@#define TRC_XEN_TASKLET_INIT (TRC_XEN_TSKLT + 0x5)#define TRC_XEN_TASKLET_MIGR (TRC_XEN_TSKLT + 0x6) +/* Trace events for timers */ +#define TRC_XEN_TIMER_RMENTRY (TRC_XEN_TIMER + 0x1) +#define TRC_XEN_TIMER_ADDENTRY (TRC_XEN_TIMER + 0x2) +#define TRC_XEN_TIMER_SET (TRC_XEN_TIMER + 0x3) +#define TRC_XEN_TIMER_STOP (TRC_XEN_TIMER + 0x4) +#define TRC_XEN_TIMER_MIGRATE (TRC_XEN_TIMER + 0x5) +#define TRC_XEN_TIMER_KILL (TRC_XEN_TIMER + 0x6) +#define TRC_XEN_TIMER_EXEC (TRC_XEN_TIMER + 0x7) +#define TRC_XEN_TIMER_REPRGR (TRC_XEN_TIMER + 0x8) +#define TRC_XEN_TIMER_HOVERFL (TRC_XEN_TIMER + 0x9) +/* * Event Flags *
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 15/15 tools: tracing: handle timers events in xentrace and xenalyze
In reply to Dario Faggioli---
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/xentrace/formats | 10 +++ tools/xentrace/xenalyze.c | 141 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+)
tools/xentrace/formats +10 -0
@@ -226,6 +226,16 @@ 0x01004005 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_init [ fn = 0x%(2)08x%(1)08x, is_sirq = %(3)d ] 0x01004006 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) tasklet_migr [ ] +0x01008001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_rmentry [ t = 0x%(2)08x%(1)08x, cpu:status = %(3)08x ] +0x01008002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_addentry [ t = 0x%(2)08x%(1)08x, cpu:status = %(3)08x ] +0x01008003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_set [ t = 0x%(2)08x%(1)08x, fn = 0x%(4)08x%(3)08x exp=0x%(6)08x%(5)08x ] +0x01008004 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_stop [ t = 0x%(2)08x%(1)08x ] +0x01008005 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_migr [ t = 0x%(2)08x%(1)08x ] +0x01008006 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_kill [ t = 0x%(2)08x%(1)08x ] +0x01008007 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_exec [ t = 0x%(2)08x%(1)08x, tard=0x%(4)08x%(3)08x ] +0x01008008 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_reprogr [ deadline=0x%(2)08x%(1)08x ] +0x01008009 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) timer_hoverfl [ old_lim:new_lim=0x%(1)08x ] + 0x00084001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hpet create [ tn = %(1)d, irq = %(2)d, delta = 0x%(4)08x%(3)08x, period = 0x%(6)08x%(5)08x ] 0x00084002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pit create [ delta = 0x%(1)016x, period = 0x%(2)016x ] 0x00084003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) rtc create [ delta = 0x%(1)016x , period = 0x%(2)016x ]
tools/xentrace/xenalyze.c +141 -0
159 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 17 lines · Dario Faggioli
Hello,
While chasing and dealing with bugs, over this last period, I've found myself augmenting Xen with quite a few new tracing capabilities, especially focusing on:
- IRQ being disabled and (re)enabled (in addition to the already existing tracing of IRQ related activity that we have);
- RCU;
- softirqs (I think I sent a preliminary version of this, long ago, but can't be sure);
- tasklets;
- timers;And, apart from the first 4 patches (which are random, but still tracing related, of course, improvements), this is what this patch series does: it adds tracing to the Xen susystems listed above.
Quoted 6 lines
That happens, one subsystem after another, in patches 6 to 15.
Patch 5 deserves special mention. In fact, now that we have
Kconfig, I thought it could be a nice thing to make it possible to select, at build config time, whether we want tracing or not, in the hypervisor (like, for instance, we do for performance counters).
Did you have thoughts on perhaps using asm goto as an alterantive to unlikely?
In Linux it is called jump labels or such - the idea is that the code has (by default and on x86) five NOP instructions. But you can patch it over and add an call to the unlikely code.
But perhaps that is more of an future idea as looking at the Linux code it looks quite large and not that simple.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Dario Faggioli
Patch 5 deserves special mention. In fact, now that we have
Kconfig, I thought
it could be a nice thing to make it possible to select, at build config time,
whether we want tracing or not, in the hypervisor (like, for instance, we do
for performance counters).
Quoted 7 lines
Did you have thoughts on perhaps using asm goto as an alterantive to unlikely?
In Linux it is called jump labels or such - the idea is that the code has (by default and on x86) five NOP instructions. But you can patch it over and add an call to the unlikely code.
Yes, I know. I've never actually looked at the code, but I know they do that, and I think it's cool.
Quoted 4 lines
But perhaps that is more of an future idea as looking at the Linux code
it looks quite large and not that simple.
I would love for us to do something similar in Xen. I've _thought_ about that many times, but that's it. :-/
Let's see... right now, I can't look into this, as I agree with you that it would be a major piece of work.
But yes, it's been in my thoughts! :-)
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 83 lines · Dario Faggioli
Hello,
While chasing and dealing with bugs, over this last period, I've found myself augmenting Xen with quite a few new tracing capabilities, especially focusing on:
- IRQ being disabled and (re)enabled (in addition to the already existing tracing of IRQ related activity that we have);
- RCU;
- softirqs (I think I sent a preliminary version of this, long ago, but can't be sure);
- tasklets;
- timers;And, apart from the first 4 patches (which are random, but still tracing related, of course, improvements), this is what this patch series does: it adds tracing to the Xen susystems listed above.
That happens, one subsystem after another, in patches 6 to 15.
Patch 5 deserves special mention. In fact, now that we have
Kconfig, I thought it could be a nice thing to make it possible to select, at build config time, whether we want tracing or not, in the hypervisor (like, for instance, we do for performance counters).To be honest, my goal was to be able to compile tracing off, and run benchmarks, to assess how much of a overhead tracing introduces, but then I decided it was worth doing this properly, and now sending it. I am still running those benchmarks. Preliminary results seems to be showing that having tracing support in the hypervisor does not (when it's disabled, of course) introduce too much overhead. Still, I think it could be useful, to people that wants a very specificly tailored version of Xen (embedded, small footprint, etc.), to be able to rip it off nice and easily (e.g., like OpenXT guys did for schedulers).
Of course, I will report here what I find, when benchmarks will finish running. (In the meantime, patch 5 has some data about .text section shrinking in its changelog.)
I also thought, for similar reasons, that it would have been good to be able to also individually enable or disable the new tracing I'm introducing with this series. This potentially applies even to the tracing we already have in tree (e.g., one may want to have tracing compiled in, for everything except that for scheduling), and I'd be up for working on this. However, in this series, I am touching really hot paths (with the exception, maybe, of RCU), and so I think it is even more important to be able to disable tracing for them, for minimum overhead.
For instance, the IRQ enabling and disabling tracing, I find it really really usable for understanding certain class of behavior, and, with some scripting and some more gnuplot "magic" (which I'll also share shortly) we can also use it to automatically measure and graph for how long interrupt are kept disabled, in various places within the hypervisor (Jennifer has done a similar analysis for XenServer, a while back). But it is very invasive, so you want to be able to turn it on and off.
As said, I don't have all the result I need to present conclusions, but what I see in preliminary data is that, although the tracing we currently have in Xen is not too bad, performance wise, this new IRQs on/off tracing does have an impact on performance, just for being there in the code (i.e., even when it is there in the code but is *disabled*).Of course, all this fine grain control of tracing options is hidden under
XEN_CONFIG_EXPERT, and all the new tracing is disabled by default.There is a branch with this series here:
git://xenbits.xen.org/people/dariof/xen.gitrel/tracing/xen-internals
http://xenbits.xen.org/gitweb/?p=people/dariof/xen.git;a=shortlog;h=refs/heads/rel/tracing/xen-internalsAnd Travis is happy about it:
https://travis-ci.org/fdario/xen/builds/238421024Let me know what you think.
Thanks and Regards,
Dario
---
Dario Faggioli (15):
xen: indo_softirq()samplesmp_processor_id()once and for all.
xen: tracing: avoid checkingtb_init_donemultiple times. xen/tools: tracing: several improvements on IRQs tracing
tools: xenalyze: fix dumping ofPM_IDLEevents.
xen: make it possible to disable tracing inKconfig.
xen: trace IRQ enabling/disabling
tools: tracing: handle IRQs on/off events in xentrace and xenalyze
Quoted 8 lines
xen: trace RCU behavior
tools: tracing: handle RCU events in xentrace and xenalyze
xen: trace softirqs
tools: tracing: handle RCU events in xentrace and xenalyze
xen: trace tasklets
tools: tracing: handle tasklets events in xentrace and xenalyze
xen: trace timers
tools: tracing: handle timers events in xentrace and xenalyze
Patches 10-15 look good to me too:
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel