From: Thomas Gleixner <tglx@linutronix.de>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: mingo@redhat.com, hpa@zytor.com, LKML <linux-kernel@vger.kernel.org>
Subject: Re: irq_fpu_usable() is irreliable
Date: Tue, 17 Nov 2015 15:06:20 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.11.1511171438090.3761@nanos> (raw)
In-Reply-To: <CAHmME9rgXh3zQDfc2Yo_Au0CSg--X+ak=SQdS9DoXNsKK0TPmA@mail.gmail.com>
Jason,
On Tue, 17 Nov 2015, Jason A. Donenfeld wrote:
> The availability of the FPU in kernel space, as you know, is determined by
> this function:
>
> bool irq_fpu_usable(void)
> {
> return !in_interrupt() ||
> interrupted_user_mode() ||
> interrupted_kernel_fpu_idle();
> }
>
> My understanding is that the first check is !in_interrupt(), because if
> `current` is valid - if we are in process context - then we have a place to
> store the existing FPU regs in kernel_fpu_begin, to be restored later in
> kernel_fpu_end. Recently I've been tracking down a problem in
> which irq_fpu_usable() returns false, yet a stack trace shows the first
> function is the syscall entry point. This leads me to believe that
> in_interrupt() is not an adequate way of testing for a valid `current`.
This function has absolute nothing to do with current. current is
always valid. The function checks whether we can use the fpu safely in
kernel context.
> In my particular problematic case, the reason in_interrupt() was
> returning false is because a number of rcu_read_lock_bh()s were
> being held; IOW this is occurring in the ndo_start_xmit path of a
> network driver.
>
> I therefore propose changing the function to this:
>
> bool irq_fpu_usable(void)
> {
> return (!in_irq() && !in_nmi()) ||
> interrupted_user_mode() ||
> interrupted_kernel_fpu_idle();
> }
>
> What would you think of that?
That's broken. Assume we interrupted a kernel thread which fiddles
with the FPU and then on irq exit we run a softirq which tries to use
the FPU....
The real question in your case is WHY interrupted_kernel_fpu_idle()
returns false. We know for sure that in a syscall with BH disabled the
first two checks are false.
Thanks,
tglx
next parent reply other threads:[~2015-11-17 14:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAHmME9rgXh3zQDfc2Yo_Au0CSg--X+ak=SQdS9DoXNsKK0TPmA@mail.gmail.com>
2015-11-17 14:06 ` Thomas Gleixner [this message]
2015-11-17 14:51 ` Jason A. Donenfeld
2015-11-17 19:54 ` Jason A. Donenfeld
2015-11-17 11:39 Jason A. Donenfeld
2015-11-18 6:55 ` Ingo Molnar
2015-11-18 12:16 ` Jason A. Donenfeld
2015-11-18 19:59 ` Jason A. Donenfeld
2015-11-27 8:41 ` Ingo Molnar
2015-11-27 8:47 ` 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=alpine.DEB.2.11.1511171438090.3761@nanos \
--to=tglx@linutronix.de \
--cc=Jason@zx2c4.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/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®