mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: hrtimers: simplify lockdep handling
@ 2008-06-25 19:46 Steven Rostedt
  2008-06-26 11:06 ` Oleg Nesterov
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2008-06-25 19:46 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Thomas Gleixner, Arjan van de Ven, Heiko Carstens, Ingo Molnar,
	Peter Zijlstra, Andrew Morton, LKML


Hi Oleg,

I'm currently porting -rt to 26-rc7 and I came across this change:

Commit:     8e60e05fdc7344415fa69a3883b11f65db967b47

With the

-	double_spin_lock(&new_base->lock, &old_base->lock,
-			 smp_processor_id() < cpu);
+	spin_lock(&new_base->lock);
+	spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);


What's the reason that this is possible?  Is it because the migration
happens only on CPU hotplugging and that the CPU hotplugging code has
locks that would prevent a reversal of the lock taking?

I'm not arguing that the code is incorrect, but this looks like a subtlety
that can bite us later.

In other words, we really need comments around this code to explain to
casual viewers why this code is not deadlock prone. The change log here
and for 0d180406f2914aea3a78ddb880e2fe9ac78a9372 does not explain why the
straight forward taking of the locks is OK.

Thanks,

-- Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: hrtimers: simplify lockdep handling
  2008-06-25 19:46 hrtimers: simplify lockdep handling Steven Rostedt
@ 2008-06-26 11:06 ` Oleg Nesterov
  0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2008-06-26 11:06 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Thomas Gleixner, Arjan van de Ven, Heiko Carstens, Ingo Molnar,
	Peter Zijlstra, Andrew Morton, LKML

Hi Steven,

On 06/25, Steven Rostedt wrote:
> 
> I'm currently porting -rt to 26-rc7 and I came across this change:
> 
> Commit:     8e60e05fdc7344415fa69a3883b11f65db967b47
> 
> With the
> 
> -	double_spin_lock(&new_base->lock, &old_base->lock,
> -			 smp_processor_id() < cpu);
> +	spin_lock(&new_base->lock);
> +	spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
> 
> 
> What's the reason that this is possible?  Is it because the migration
> happens only on CPU hotplugging and that the CPU hotplugging code has
> locks that would prevent a reversal of the lock taking?

Yes. Even if we ignore CPU hotplugging locks, it is not possible that
2 migrate_timers()'s can take these locks in reverse order, this means
that both CPUs are dead and we are doing something meaningless.

> I'm not arguing that the code is incorrect, but this looks like a subtlety
> that can bite us later.
>
> In other words, we really need comments around this code to explain to
> casual viewers why this code is not deadlock prone. The change log here
> and for 0d180406f2914aea3a78ddb880e2fe9ac78a9372 does not explain why the
> straight forward taking of the locks is OK.

OK, I agree, I'll try to make the trivial doc patch.

But please note that the old code was confusing too, imho. It looked as
if we really have to avoid the deadlock, and the casual viewer (me) was
very confused when noticed the changes which added base_lock_keys and
double_spin_lock ;)

Oleg.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-26 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-25 19:46 hrtimers: simplify lockdep handling Steven Rostedt
2008-06-26 11:06 ` Oleg Nesterov

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®