From: Ingo Molnar <mingo@elte.hu>
To: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: hpa@zytor.com, tglx@linutronix.de, andi@firstfloor.org,
hch@infradead.org, linux-kernel@vger.kernel.org,
Arjan van de Ven <arjan@linux.intel.com>
Subject: Re: [patch 2/2] x86, fpu: lazy allocation of FPU area - v5
Date: Tue, 11 Mar 2008 10:08:16 +0100 [thread overview]
Message-ID: <20080311090816.GF25110@elte.hu> (raw)
In-Reply-To: <20080310222955.703291000@linux-os.sc.intel.com>
* Suresh Siddha <suresh.b.siddha@intel.com> wrote:
> asmlinkage void math_state_restore(void)
> {
> struct task_struct *me = current;
> - clts(); /* Allow maths ops (or we recurse) */
>
> - if (!used_math())
> - init_fpu(me);
> + if (!used_math()) {
> + local_irq_enable();
> + /*
> + * does a slab alloc which can sleep
> + */
> + if (init_fpu(me)) {
> + /*
> + * ran out of memory!
> + */
> + do_group_exit(SIGKILL);
> + return;
> + }
> + local_irq_disable();
> + }
> +
> + clts(); /* Allow maths ops (or we recurse) */
> restore_fpu_checking(&me->thread.xstate->fxsave);
> task_thread_info(me)->status |= TS_USEDFPU;
> me->fpu_counter++;
hm, three things:
firstly, the clts is now done _after_ fpu_init() - are you sure that's
OK? We do it in this order so that FINIT [on older cpus] does not fault.
secondly, while i know you were responding to review feedback from
others, but the do_group_exit(SIGKILL) looks quite bad. It's totally
undebuggable to the user - not even a coredump will be generated AFAICS
- and the user has no idea that this all happened due to out-of-memory.
A (forced) SIGBUS is our usual answer to out-of-memory situations. [such
as when a pagetable allocation fails] If you get review feedback that
suggests a crappy solution then please resist it! :-)
thirdly, the irq enable/disable worries me. Can it ever trigger in
kernel code that has irqs off? If it happens when kernel uses the FPU in
irqs-off sections (to do SSE optimized routines, etc.) then enabling
irqs is dangerous - the original callsite had it disabled for a reason.
At minimum we should add a debug check to math_state_restore(),
something like:
WARN_ON_ONCE(!(regs->flags & X86_EFLAGS_IF))
(this means we need to pass regs to math_state_restore())
Ingo
next prev parent reply other threads:[~2008-03-11 9:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-10 22:28 [patch 1/2] x86, fpu: split FPU state from task struct - v5 Suresh Siddha
2008-03-10 22:28 ` [patch 2/2] x86, fpu: lazy allocation of FPU area " Suresh Siddha
2008-03-11 9:08 ` Ingo Molnar [this message]
2008-03-11 20:57 ` Suresh Siddha
2008-03-10 22:56 ` [patch 1/2] x86, fpu: split FPU state from task struct " Andi Kleen
2008-03-11 5:07 ` Alexey Dobriyan
2008-03-11 8:35 ` Ingo Molnar
2008-03-11 10:09 ` Alexey Dobriyan
2008-03-11 10:11 ` Ingo Molnar
2008-03-11 20:22 ` Suresh Siddha
2008-03-11 20:19 ` Suresh Siddha
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=20080311090816.GF25110@elte.hu \
--to=mingo@elte.hu \
--cc=andi@firstfloor.org \
--cc=arjan@linux.intel.com \
--cc=hch@infradead.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=suresh.b.siddha@intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.