Re: A bug in ftrace - dynamic fops

From: Steven Rostedt
Date: Thu Aug 11 2016 - 10:01:55 EST


On Thu, 11 Aug 2016 10:46:53 +0200 (CEST)
Miroslav Benes <mbenes@xxxxxxx> wrote:

> On Tue, 9 Aug 2016, Steven Rostedt wrote:
>
> > On Tue, 9 Aug 2016 10:16:00 +0200 (CEST)
> > Miroslav Benes <mbenes@xxxxxxx> wrote:
> >
> >
> > > I agree it is kind of shooting oneself in the foot bug, because explicit
> > > call to a sleeping function may not be the brightest thing to do. However
> > > I see two (closely related) issues with this.
> > >
> > > 1. It is a change in behaviour. Ftrace silently relies on an atomicity of
> > > ops->func(). I don't see it documented anywhere, but it did not matter
> > > because the atomicity was always guaranteed as described above. Now there
> > > is a possibility to achieve a situation which breaks the assumption. It
> > > makes me worried.
> >
> > Why? It's something that a kernel developer should be aware of. I mean,
> > that ops->func can easily be called from *any* context, like irq,
> > softirq, or even an NMI. One who hooks into any function of the kernel
> > should understand that it has special requirements, just like we don't
> > document that you can't sleep in an NMI.
> >
> > And if you only hook to functions that can sleep, then great! You are
> > allowed to do that too. Just like calling a module function that can
> > sleep. You need to make sure nothing is calling your function when you
> > unload the module. I don't see anything that is deceptive here.
>
> At least the comment in ftrace_shutdown() is deceptive.

Which comment? It may require an update to be less "deceptive".

-- Steve

>
> But well, I understood your opinion from the first reply. I just didn't
> agree with it and that's why I expressed it.
>