From: Linus Torvalds <torvalds@linux-foundation.org>
To: Tejun Heo <tj@kernel.org>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
Yinghai Lu <yhlu.kernel@gmail.com>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [GIT PULL] percpu fixes for 2.6.32-rc6
Date: Tue, 10 Nov 2009 09:10:34 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.2.01.0911100903370.31845@localhost.localdomain> (raw)
In-Reply-To: <4AF90254.40909@kernel.org>
On Tue, 10 Nov 2009, Tejun Heo wrote:
>
> Please pull from the following percpu fix branch.
No way in hell.
> It fixes a possible deadlock caused by lock ordering inversion through
> irq.
.. and it does so by introducing a new bug. No thank you.
> +
> + /*
> + * pcpu_mem_free() might end up calling vfree() which uses
> + * IRQ-unsafe lock and thus can't be called with pcpu_lock
> + * held. Release and reacquire pcpu_lock if old map needs to
> + * be freed.
> + */
> + if (old) {
> + spin_unlock_irqrestore(&pcpu_lock, *flags);
> + pcpu_mem_free(old, size);
> + spin_lock_irqsave(&pcpu_lock, *flags);
> + }
Routines that drop and then re-take the lock should be banned, as it's
almost always a bug waiting to happen. As it is this time:
> return 0;
Now the caller will happily continue to traverse a list that may no longer
be valid, because you dropped the lock.
Really. This thing is total sh*t. It was misdesigned to start with, and
the calling convention is wrong. That 'pcpu_extend_area_map()' function
should be split up into two functions: 'pcpu_needs_to_extend()' that never
drops the lock, and 'pcpu_extend_area()' that _always_ drops the lock
(and then returns an error if it can't allocate the memory).
Not that shit-for-brains that may or may not drop the lock, and then
returns an incorrect error return depending on whether it did.
In other words: fix the sh*t, don't add even more to it. That 'return 0'
was and is wrong. It should have been a 'return 1'. And thank the Gods
that I looked at it,
Sure, you can fix the bug by just returning 1. But you can't fix the total
crap of a calling convention that way. Fix it properly as outlined above,
and remember: functions that drop locks that were held when called are
EVIL and almost always the source of really subtle races.
As it was in this case.
Linus
next prev parent reply other threads:[~2009-11-10 17:11 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-10 6:04 Tejun Heo
2009-11-10 17:10 ` Linus Torvalds [this message]
2009-11-10 18:33 ` Tejun Heo
2009-11-10 18:54 ` Linus Torvalds
2009-11-10 19:25 ` Tejun Heo
2009-11-10 19:37 ` Ingo Molnar
2009-11-10 19:50 ` Tejun Heo
2009-11-10 21:42 ` Linus Torvalds
2009-11-11 3:55 ` Tejun Heo
2009-11-11 11:31 ` Ingo Molnar
2009-11-11 12:21 ` Tejun Heo
2009-11-11 19:57 ` Ingo Molnar
2009-11-12 10:11 ` Tejun Heo
2009-11-12 10:36 ` Ingo Molnar
2009-11-12 10:58 ` Tejun Heo
2009-11-12 11:25 ` Ingo Molnar
2009-11-12 14:26 ` Oliver Neukum
2009-11-12 15:17 ` Linus Torvalds
2009-11-12 15:30 ` Tejun Heo
2009-11-12 15:45 ` Tejun Heo
2009-11-12 15:52 ` Linus Torvalds
2009-11-12 17:04 ` Andres Baldrich
2009-11-12 17:18 ` Linus Torvalds
2009-11-12 18:04 ` Ingo Molnar
2009-11-12 18:14 ` Andi Kleen
2009-11-12 11:07 ` Ingo Molnar
2009-11-12 11:29 ` Tejun Heo
2009-11-11 8:49 ` [PATCH percpu#for-linus] percpu: restructure pcpu_extend_area_map() to fix bugs and improve readability Tejun Heo
2009-11-11 19:25 ` Linus Torvalds
2009-11-10 19:44 ` [GIT PULL] percpu fixes for 2.6.32-rc6 Tejun Heo
2009-11-13 3:53 Tejun Heo
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.LFD.2.01.0911100903370.31845@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tj@kernel.org \
--cc=yhlu.kernel@gmail.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
Powered by JetHome