From: Miroslav Benes <mbenes@suse.cz>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: A bug in ftrace - dynamic fops
Date: Thu, 11 Aug 2016 10:46:53 +0200 (CEST) [thread overview]
Message-ID: <alpine.LNX.2.00.1608111042220.26452@pobox.suse.cz> (raw)
In-Reply-To: <20160809081748.5c8e7d1b@gandalf.local.home>
On Tue, 9 Aug 2016, Steven Rostedt wrote:
> On Tue, 9 Aug 2016 10:16:00 +0200 (CEST)
> Miroslav Benes <mbenes@suse.cz> 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.
But well, I understood your opinion from the first reply. I just didn't
agree with it and that's why I expressed it.
> >
> > 2. Previously if someone called a function which could sleep he was
> > immediately warned not to do so via "sleeping in atomic context" BUG. Now
> > he wouldn't know. That's because in_atomic() and might_sleep()
> > infrastructure does not work in ops->func(). in_atomic() gives 0 even if
> > it is an atomic context in fact. But well, the comment for in_atomic() in
> > linux/preempt.h warns about exactly this situation I guess.
>
> It will warn if you hook to a function that can sleep. And if you never
> do, then there's nothing wrong. If the only functions you hook to can
> sleep, then it is fine for you to sleep in your code too. But if you
> do, you must synchronize that logic. You must make sure all functions
> are out of the sleep when you unresgister. Just like you must make sure
> all functions are out of a sleeping function in a module. This is
> kernel programming 101.
>
> I never saw a need to have sleeping functions being called by
> ops->func() and I don't know of a case that would. If there is a
> legitimate case (not hypothetical) and then I could add a way to
> postpone freeing of an ops if need be.
>
> Because note, that TASK_RCU will only be called when CONFIG_PREEMPT is
> enabled. It would be overkill to do it for !CONFIG_PREEMPT, thus it
> will not solve what you want here.
Fair enough. I can live with that.
Miroslav
next prev parent reply other threads:[~2016-08-11 8:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 8:57 Miroslav Benes
2016-08-08 14:53 ` Steven Rostedt
2016-08-09 8:16 ` Miroslav Benes
2016-08-09 12:17 ` Steven Rostedt
2016-08-11 8:46 ` Miroslav Benes [this message]
2016-08-11 14:01 ` Steven Rostedt
2016-08-11 14:08 ` Miroslav Benes
2016-08-11 14:33 ` Steven Rostedt
2016-08-11 14:54 ` Miroslav Benes
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=alpine.LNX.2.00.1608111042220.26452@pobox.suse.cz \
--to=mbenes@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®