mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH 2/2] tracing/events/lockdep: move tracepoints within recursive protection
Date: Thu, 16 Apr 2009 14:29:28 -0400	[thread overview]
Message-ID: <20090416182928.GB13940@Krystal> (raw)
In-Reply-To: <alpine.DEB.2.00.0904161411320.20429@gandalf.stny.rr.com>

* Steven Rostedt (rostedt@goodmis.org) wrote:
> 
> On Thu, 16 Apr 2009, Peter Zijlstra wrote:
> > 
> > > That is, at thread context, you are at level 0, if an interrupt comes
> > > in, it sets you to level 1, if another interrupt comes in, it sets you to 
> > > level 2, and so on.
> > > 
> > > I guess we could add this into the irq_enter/exit sofirq_enter/exit and 
> > > nmi_enter/exit.
> > > 
> > > Thus we can have each task with a bitmask. When we start to trace, we set 
> > > the bit coresponding to the level the task is at.
> > > 
> > > Ie. in thread context, we set bit 0, if we are interrupted by a 
> > > softirq/irq/nmi, we set the level bit we are at. Hmm, we might be able to 
> > > do this via the preempt count already :-/
> > > 
> > > Just add the softirq/irq/nmi bits together.
> > > 
> > > The if the bit is already set we can dump out a warning.
> > > 
> > > I'll try that out.
> > 
> > static int *perf_swcounter_recursion_context(struct perf_cpu_context *cpuctx)
> > {
> >         if (in_nmi())
> >                 return &cpuctx->recursion[3];
> > 
> >         if (in_irq())
> >                 return &cpuctx->recursion[2];
> > 
> >         if (in_softirq())
> >                 return &cpuctx->recursion[1];
> > 
> >         return &cpuctx->recursion[0];
> > }
> > 
> > Is what I use for perf-counters.
> 
> But does that allow multi nested interrupts?
> 
> I'll try the preempt_count and let you know.
> 
> Thanks,
> 
> -- Steve
> 

In practice, I have used a "tracing nesting level" detection counter in
LTTng which drops events if they are at a nesting level of about 5 or
more if my memory serves me well. This should be enough to detect
recursive tracer calls before filling the stack while handling some of
the worse nesting we can think of (thread + softirq + irq + nmi).

And it's _really_ easy to implement, arch-independant, and has no
special corner-case.

Mathieu

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

  reply	other threads:[~2009-04-16 18:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-16 16:15 [PATCH 0/2] [GIT PULL] updates for event tester and lockdep tracer Steven Rostedt
2009-04-16 16:15 ` [PATCH 1/2] tracing/events: perform function tracing in event selftests Steven Rostedt
2009-04-17 16:10   ` [tip:tracing/core] " tip-bot for Steven Rostedt
2009-04-16 16:15 ` [PATCH 2/2] tracing/events/lockdep: move tracepoints within recursive protection Steven Rostedt
2009-04-16 16:47   ` Peter Zijlstra
2009-04-16 17:03     ` Steven Rostedt
2009-04-16 17:20       ` Peter Zijlstra
2009-04-16 17:38         ` Steven Rostedt
2009-04-16 17:49           ` Peter Zijlstra
2009-04-16 17:58             ` Steven Rostedt
2009-04-16 18:06               ` Peter Zijlstra
2009-04-16 18:12                 ` Steven Rostedt
2009-04-16 18:29                   ` Mathieu Desnoyers [this message]
2009-04-16 18:22               ` Mathieu Desnoyers
2009-04-16 17:45     ` Steven Rostedt
2009-04-16 17:53       ` Peter Zijlstra
2009-04-17  3:03         ` Steven Rostedt
2009-04-17  3:24           ` Steven Rostedt
2009-04-17  7:40             ` Peter Zijlstra
2009-04-17 16:03               ` [tip:core/urgent] lockdep: more robust lockdep_map init sequence tip-bot for Peter Zijlstra
2009-04-17  4:16           ` [PATCH 2/2] tracing/events/lockdep: move tracepoints within recursive protection Steven Rostedt
2009-04-17  4:36             ` Steven Rostedt
2009-04-17  4:52             ` Mathieu Desnoyers
2009-04-17 11:09               ` Steven Rostedt
2009-04-17 22:19                 ` [PATCH] x86 entry_64.S lockdep fix Mathieu Desnoyers
2009-04-18 13:54                   ` Steven Rostedt
2009-04-19  4:11                     ` Mathieu Desnoyers
2009-04-19  9:10                       ` Ingo Molnar
2009-04-17  7:44             ` [PATCH 2/2] tracing/events/lockdep: move tracepoints within recursive protection Peter Zijlstra
2009-04-16 16:40 ` [PATCH 0/2] [GIT PULL] updates for event tester and lockdep tracer Ingo Molnar

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=20090416182928.GB13940@Krystal \
    --to=mathieu.desnoyers@polymtl.ca \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®