From: George Dunlap <george.dunlap@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
Dario Faggioli <dario.faggioli@citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times.
Date: Thu, 8 Jun 2017 15:34:23 +0100 [thread overview]
Message-ID: <4e1fdf8c-a7dd-0177-f3c4-9ddd708ea47e@citrix.com> (raw)
In-Reply-To: <5938408902000078001608F8@prv-mh.provo.novell.com>
On 07/06/17 17:06, Jan Beulich wrote:
>>>> On 07.06.17 at 17:55, <dario.faggioli@citrix.com> wrote:
>> On Wed, 2017-06-07 at 08:46 -0600, Jan Beulich wrote:
>>>>>> On 01.06.17 at 19:33, <dario.faggioli@citrix.com> wrote:
>>>>
>>>> In 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.
>>>
>>> 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 ...
>>>
>>>> @@ -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?
>>>
>> 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.
>
> 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?
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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-08 14:35 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 17:33 [PATCH 00/15] xen/tools: add tracing to various Xen subsystems Dario Faggioli
2017-06-01 17:33 ` [PATCH 01/15] xen: in do_softirq() sample smp_processor_id() once and for all Dario Faggioli
2017-06-07 14:38 ` Jan Beulich
2017-06-08 14:12 ` George Dunlap
2017-06-08 14:20 ` George Dunlap
2017-06-08 14:42 ` Jan Beulich
2017-06-01 17:33 ` [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times Dario Faggioli
2017-06-01 17:53 ` Andrew Cooper
2017-06-01 23:08 ` Dario Faggioli
2017-06-07 14:46 ` Jan Beulich
2017-06-07 15:55 ` Dario Faggioli
2017-06-07 16:06 ` Jan Beulich
2017-06-08 14:34 ` George Dunlap [this message]
2017-06-08 14:37 ` George Dunlap
2017-06-01 17:33 ` [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing Dario Faggioli
2017-06-01 18:02 ` Andrew Cooper
2017-06-01 23:12 ` Dario Faggioli
2017-06-07 15:05 ` Jan Beulich
2017-06-07 15:45 ` Dario Faggioli
2017-06-07 15:58 ` Jan Beulich
2017-06-08 14:53 ` George Dunlap
2017-06-08 15:34 ` Jan Beulich
2017-06-08 14:59 ` George Dunlap
2017-06-01 17:34 ` [PATCH 04/15] tools: xenalyze: fix dumping of PM_IDLE events Dario Faggioli
2017-06-08 15:06 ` George Dunlap
2017-06-01 17:34 ` [PATCH 05/15] xen: make it possible to disable tracing in Kconfig Dario Faggioli
2017-06-01 18:43 ` Andrew Cooper
2017-06-07 11:01 ` Julien Grall
2017-06-07 15:14 ` Jan Beulich
2017-06-08 15:16 ` George Dunlap
2017-06-08 15:35 ` Jan Beulich
2017-06-08 15:37 ` George Dunlap
2017-06-08 15:44 ` Jan Beulich
2017-06-08 15:17 ` George Dunlap
2017-06-01 17:34 ` [PATCH 06/15] xen: trace IRQ enabling/disabling Dario Faggioli
2017-06-01 19:08 ` Andrew Cooper
2017-06-01 23:42 ` Dario Faggioli
2017-06-08 15:51 ` George Dunlap
2017-06-08 16:05 ` Jan Beulich
2017-06-07 11:16 ` Julien Grall
2017-06-07 15:22 ` Dario Faggioli
2017-06-09 10:51 ` Julien Grall
2017-06-09 10:53 ` Julien Grall
2017-06-09 10:55 ` George Dunlap
2017-06-09 11:00 ` Julien Grall
2017-06-08 16:01 ` George Dunlap
2017-06-08 16:11 ` Dario Faggioli
2017-06-09 10:41 ` Jan Beulich
2017-06-01 17:34 ` [PATCH 07/15] tools: tracing: handle IRQs on/off events in xentrace and xenalyze Dario Faggioli
2017-06-13 15:58 ` George Dunlap
2017-06-01 17:34 ` [PATCH 08/15] xen: trace RCU behavior Dario Faggioli
2017-06-09 10:48 ` Jan Beulich
2017-06-13 16:05 ` George Dunlap
2017-06-01 17:34 ` [PATCH 09/15] tools: tracing: handle RCU events in xentrace and xenalyze Dario Faggioli
2017-06-13 16:12 ` George Dunlap
2017-06-01 17:34 ` [PATCH 10/15] xen: trace softirqs Dario Faggioli
2017-06-09 10:51 ` Jan Beulich
2017-06-01 17:34 ` [PATCH 11/15] tools: tracing: handle RCU events in xentrace and xenalyze Dario Faggioli
2017-06-01 17:35 ` [PATCH 12/15] xen: trace tasklets Dario Faggioli
2017-06-09 10:59 ` Jan Beulich
2017-06-09 11:17 ` Dario Faggioli
2017-06-09 11:29 ` Jan Beulich
2017-06-01 17:35 ` [PATCH 13/15] tools: tracing: handle tasklets events in xentrace and xenalyze Dario Faggioli
2017-06-01 17:35 ` [PATCH 14/15] xen: trace timers Dario Faggioli
2017-06-01 17:35 ` [PATCH 15/15] tools: tracing: handle timers events in xentrace and xenalyze Dario Faggioli
2017-06-07 14:13 ` [PATCH 00/15] xen/tools: add tracing to various Xen subsystems Konrad Rzeszutek Wilk
2017-06-08 16:45 ` Dario Faggioli
2017-06-13 16:34 ` George Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4e1fdf8c-a7dd-0177-f3c4-9ddd708ea47e@citrix.com \
--to=george.dunlap@citrix.com \
--cc=JBeulich@suse.com \
--cc=dario.faggioli@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).