linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation
@ 2020-04-14  1:51 Xiao Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Xiao Yang @ 2020-04-14  1:51 UTC (permalink / raw)
  To: rostedt
  Cc: mingo, linux-kernel, linux-kselftest, linux-trace-devel,
	ice_yangxiao, Xiao Yang

Traced event can trigger 'snapshot' operation(i.e. calls snapshot_trigger()
or snapshot_count_trigger()) when register_snapshot_trigger() has completed
registration but doesn't allocate buffer for 'snapshot' event trigger.  In
the rare case, 'snapshot' operation always detects the lack of allocated
buffer so make register_snapshot_trigger() allocate buffer first.

trigger-snapshot.tc in kselftest reproduces the issue on slow vm:
-----------------------------------------------------------
cat trace
...
ftracetest-3028  [002] ....   236.784290: sched_process_fork: comm=ftracetest pid=3028 child_comm=ftracetest child_pid=3036
     <...>-2875  [003] ....   240.460335: tracing_snapshot_instance_cond: *** SNAPSHOT NOT ALLOCATED ***
     <...>-2875  [003] ....   240.460338: tracing_snapshot_instance_cond: *** stopping trace here!   ***
-----------------------------------------------------------

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 kernel/trace/trace_events_trigger.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index dd34a1b46a86..3a74736da363 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -1088,14 +1088,10 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
 			  struct event_trigger_data *data,
 			  struct trace_event_file *file)
 {
-	int ret = register_trigger(glob, ops, data, file);
-
-	if (ret > 0 && tracing_alloc_snapshot_instance(file->tr) != 0) {
-		unregister_trigger(glob, ops, data, file);
-		ret = 0;
-	}
+	if (tracing_alloc_snapshot_instance(file->tr) != 0)
+		return 0;
 
-	return ret;
+	return register_trigger(glob, ops, data, file);
 }
 
 static int
-- 
2.25.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation
  2020-04-15  1:46   ` Steven Rostedt
@ 2020-04-15  1:59     ` Xiao Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Xiao Yang @ 2020-04-15  1:59 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Markus Elfring, linux-kselftest, linux-trace-devel, linux-kernel,
	Ingo Molnar, Xiao Yang

On 2020/4/15 9:46, Steven Rostedt wrote:
> On Wed, 15 Apr 2020 09:40:20 +0800
> Xiao Yang<yangx.jy@cn.fujitsu.com>  wrote:
>
>> On 2020/4/14 15:54, Markus Elfring wrote:
>>>> Traced event can trigger 'snapshot' operation(i.e. calls snapshot_trigger()
>>>
>>> I suggest to improve the change description.
>>>
>>> * Adjustment:
>>>     … operation (i. e. …
>> Hi Markus,
>>
>> Which part of description do you want to change or could you provide an
>> example for reference?
>
> That part is fine for me.
>
>>
>>>
>>> * Will the tag “Fixes” become relevant?
>>
>> Do you mean to add the following "Fixes" tag?
>> Fixes: 93e31ffbf417 "tracing: Add 'snapshot' event trigger command"
>>
>
> Yeah, that fixes tag is appropriate. But I usually add those myself, you
> don't need to resend.
Hi Steven,

Thanks for your quick reply.
Got it and I will keep the v2 patch.

Thanks,
Xiao Yang
>
> -- Steve
>
>
> .
>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation
  2020-04-15  1:40 ` Xiao Yang
@ 2020-04-15  1:46   ` Steven Rostedt
  2020-04-15  1:59     ` Xiao Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2020-04-15  1:46 UTC (permalink / raw)
  To: Xiao Yang
  Cc: Markus Elfring, linux-kselftest, linux-trace-devel, linux-kernel,
	Ingo Molnar, Xiao Yang

On Wed, 15 Apr 2020 09:40:20 +0800
Xiao Yang <yangx.jy@cn.fujitsu.com> wrote:

> On 2020/4/14 15:54, Markus Elfring wrote:
> >> Traced event can trigger 'snapshot' operation(i.e. calls snapshot_trigger()  
> >
> > I suggest to improve the change description.
> >
> > * Adjustment:
> >    … operation (i. e. …  
> Hi Markus,
> 
> Which part of description do you want to change or could you provide an 
> example for reference?

That part is fine for me.

> 
> >
> > * Will the tag “Fixes” become relevant?  
> 
> Do you mean to add the following "Fixes" tag?
> Fixes: 93e31ffbf417 "tracing: Add 'snapshot' event trigger command"
> 

Yeah, that fixes tag is appropriate. But I usually add those myself, you
don't need to resend.

-- Steve

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation
  2020-04-14  7:54 Markus Elfring
@ 2020-04-15  1:40 ` Xiao Yang
  2020-04-15  1:46   ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2020-04-15  1:40 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-kselftest, linux-trace-devel, linux-kernel, Ingo Molnar,
	Steven Rostedt, Xiao Yang

On 2020/4/14 15:54, Markus Elfring wrote:
>> Traced event can trigger 'snapshot' operation(i.e. calls snapshot_trigger()
>
> I suggest to improve the change description.
>
> * Adjustment:
>    … operation (i. e. …
Hi Markus,

Which part of description do you want to change or could you provide an 
example for reference?

>
> * Will the tag “Fixes” become relevant?

Do you mean to add the following "Fixes" tag?
Fixes: 93e31ffbf417 "tracing: Add 'snapshot' event trigger command"

Thanks,
Xiao Yang
>
> Regards,
> Markus
>
>
> .
>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation
@ 2020-04-14  7:54 Markus Elfring
  2020-04-15  1:40 ` Xiao Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-04-14  7:54 UTC (permalink / raw)
  To: Xiao Yang, linux-kselftest, linux-trace-devel
  Cc: linux-kernel, Ingo Molnar, Steven Rostedt, Xiao Yang

> Traced event can trigger 'snapshot' operation(i.e. calls snapshot_trigger()

I suggest to improve the change description.

* Adjustment:
  … operation (i. e. …

* Will the tag “Fixes” become relevant?

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-15  1:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14  1:51 [PATCH v2] tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation Xiao Yang
2020-04-14  7:54 Markus Elfring
2020-04-15  1:40 ` Xiao Yang
2020-04-15  1:46   ` Steven Rostedt
2020-04-15  1:59     ` Xiao Yang

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).