mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: tytso@mit.edu
Cc: Ingo Molnar <mingo@elte.hu>, Salman <sqazi@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	peterz@infradead.org, akpm@inux-foundation.org,
	linux-kernel@vger.kernel.org, tytso@google.com,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] Fix a race in pid generation that causes pids to be reused immediately.
Date: Wed, 9 Jun 2010 09:06:37 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.1006090857530.4506@i5.linux-foundation.org> (raw)
In-Reply-To: <20100609155041.GD6162@thunk.org>



On Wed, 9 Jun 2010, tytso@mit.edu wrote:
> 
> Salman had created a very nice ASCII art diagram of the race in the
> mail thread with the internal bug reporter who noticed the problem.
> We could include that, if you don't mind the commit description
> growing by 30-40 lines.  :-)

I don't horribly mind, but I also don't think it's necessarily all that 
useful to go that far. For the commit message, there are two real reasons:

 - explaining the patch itself upstream to make people like me understand 
   _why_ it needs to be applied.

   But then a denser explanation than a 30-40 line ASCII art diagram would 
   probably suffice.

 - explaning the code after-the-fact to people who end up seeing it in 
   log/blame output

   And then we don't care so much about the old bug per se, as about how 
   the code is supposed to work - so a lot of verbiage about what used to 
   happen is much less important than describing just what's going on with 
   the cmpxchg (where the "loop" is all the way from the original value 
   load, especially in this case where we don't have to loop all the way 
   back).

In fact, conceptually the cmpxchg loop is pretty much the whole function, 
it's just that if we know that any racing elements will be idempotent wrt 
anything but the final assignment of 'last_pid'. So we can end up just 
looping over the final part. I think _that_ is the clever part, and I 
think that is the part that needs explanation.

(And that is also why the diff itself doesn't include the "early part of 
the loop", and why I couldn't understand it purely as a patch - because it 
in this case the patch is "artificially small" because of how we don't 
need to loop all the way up)

> We do need to deal with pid wrap possibility just to be completely
> correct, although the chance of hitting _that_ are pretty remote.

That seems to be purely an artifact of the cleverness of avoiding re-doing 
the whole loop, no? If we _had_ re-done the whole loop (the "normal" 
cmpxchg model), we would have re-started the whole pid search and handled 
the overflow in the existing overflow handling code.

		Linus

  reply	other threads:[~2010-06-09 16:07 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-09  6:24 Salman
2010-06-09  6:53 ` Andi Kleen
2010-06-09  9:48 ` Ingo Molnar
2010-06-09 15:39   ` Linus Torvalds
2010-06-09 15:50     ` tytso
2010-06-09 16:06       ` Linus Torvalds [this message]
2010-06-09 17:10         ` tytso
2010-06-09 17:23           ` Linus Torvalds
2010-06-09 17:25             ` Linus Torvalds
2010-06-09 17:34               ` tytso
2010-06-09 17:43                 ` Linus Torvalds
2010-06-09 17:47                   ` tytso
2010-06-09 18:09                     ` Salman Qazi
2010-06-09 11:49 ` Michel Lespinasse
2010-06-09 12:37   ` tytso
2010-06-09 12:17 ` tytso
2010-06-09 21:00 Salman
2010-06-09 21:21 ` Linus Torvalds
2010-06-09 21:33   ` Peter Zijlstra
2010-06-09 22:20     ` Linus Torvalds
2010-06-09 22:27       ` Linus Torvalds
2010-06-10  0:08         ` Salman Qazi
2010-06-10  0:20           ` Linus Torvalds
     [not found]             ` <AANLkTilXJ0X2qxD9cNTlLayKzySEZu1HEZUWu--Go8kw@mail.gmail.com>
2010-06-10  5:55               ` Salman Qazi
2010-06-10 16:39                 ` Linus Torvalds
2010-06-10 20:09 Salman
2010-06-10 20:38 ` tytso
2010-06-10 21:04   ` Salman Qazi
2010-06-10 21:24 Salman
2010-06-11 17:17 Salman
2010-06-11 17:44 ` Linus Torvalds
2010-06-11 22:49   ` Salman
2010-06-11 23:07     ` Linus Torvalds
2010-06-14 23:58     ` Andrew Morton
2010-06-15  0:56       ` tytso
2010-06-15  1:55         ` Andrew Morton
2010-06-15  3:26           ` Paul Mackerras
2010-06-15  4:21             ` Andrew Morton
2010-06-15  4:38               ` Eric Dumazet
2010-06-15  6:57               ` Benjamin Herrenschmidt
2010-06-15  7:25               ` Paul Mackerras
2010-06-15 12:56           ` tytso
2010-06-15 13:06             ` Kyle McMartin
2010-06-15 14:35           ` Peter Zijlstra
2010-06-15 19:37             ` Andrew Morton

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.00.1006090857530.4506@i5.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@inux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=sqazi@google.com \
    --cc=tglx@linutronix.de \
    --cc=tytso@google.com \
    --cc=tytso@mit.edu \
    /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