mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 10:54:27 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.2.01.0911101042140.31845@localhost.localdomain> (raw)
In-Reply-To: <4AF9B1FD.1010408@kernel.org>



On Wed, 11 Nov 2009, Tejun Heo wrote:
> 
> If I'm missing something, I'm sure you'll hammer it into me.

Here's from the comments on that function:

 * RETURNS:
 * 0 if noop, 1 if successfully extended, -errno on failure.

and here's from one of the main callers:

                list_for_each_entry(chunk, &pcpu_slot[slot], list) {
		...
                        switch (pcpu_extend_area_map(chunk, &flags)) {
                        case 0:
                                break;
                        case 1:
                                goto restart;   /* pcpu_lock dropped, restart */

where that '&pcpu_slot[slot]' list is protected by the pcpu_lock, and 
nothing else. At least according to all the _other_ comments in that file. 
Including the one that very much tries to _explain_ the locking at the 
top, quote:

  "The latter is a spinlock and protects the index data structures - chunk 
   slots, chunks and area maps in chunks."

So as far as I can tell, either the comments are all crap, the whole 
restart code is pointless and in fact the whole spin-lock is seemingly 
almost entirely pointless to begin with (since pcpu_alloc_mutex is the 
only thing that matters), or the code is buggy.

Also, quite frankly, even if the code _isn't_ buggy, it's still wrong to 
release a lock that somebody else took. It's a sure-fire way to write 
unmaintainable code with bugs almost guaranteed in the future. Yes, it 
happens, and sometimes it's the only sane way to do it, but in this case 
that really isn't true as far as I can tell.

>From my (admittedly fairly quick) look, my suggested split-up really would 
make the code _more_ readable (no need for that subtle "negative, zero or 
positive all mean different things" logic), and hopefully avoid the whole 
"drop the lock that somebody else took", because we could drop it in the 
caller where it was taken.

So it all boils down to: the code is unquestionably ugly and almost 
certainly broken. And if it isn't broken, then _all_ the comments are 
total crap. 

Your choice. 

			Linus

  reply	other threads:[~2009-11-10 18:55 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
2009-11-10 18:33   ` Tejun Heo
2009-11-10 18:54     ` Linus Torvalds [this message]
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.0911101042140.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