lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141002090745.GC3003@worktop.programming.kicks-ass.net>
Date:	Thu, 2 Oct 2014 11:07:45 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	mingo@...nel.org, torvalds@...ux-foundation.org,
	tglx@...utronix.de, ilya.dryomov@...tank.com,
	umgwanakikbuti@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 10/11] sched: Debug nested sleeps

On Wed, Oct 01, 2014 at 08:35:49PM +0200, Oleg Nesterov wrote:
> On 10/01, Peter Zijlstra wrote:
> > Sure, so the trivial problem is not actually going to sleep in the outer
> > wait primitive because the inner wait primitive reset ->state to
> > TASK_RUNNING.
> 
> But this means that fixup_sleep() must not be used?

Right, in case its an actual bug, we'll not use fixup_sleep(). Those are
only used to annotate the few odd cases.

> > So by always setting the ->state to TASK_RUNNING it never goes to sleep
> > and it'll revert to spinning,
> 
> But I tried to suggest to not set TASK_RUNNING?

That's what I understood, because that's the difference between
CONFIG_DEBUG_ATOMIC_SLEEP and not. Or I made a complete mess of things,
which could well have happened, I had a terrible headache yesterday.

> Peter, I am sorry for wasting your time, this is really minor, but still
> I'd like to understand.
> 
> Let me try again. With this series we have
> 
> 	#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
> 	#define fixup_sleep()	__set_current_state(TASK_RUNNING)
> 	#else
> 	#define fixup_sleep()	do { } while (0)
> 	#endif
> 
> and this means that we do not need __set_current_state(RUNNING) for
> correctness, just we want to shut up the warning in __might_sleep().
> This is fine (and the self-documenting helper is nice), but this means
> that CONFIG_DEBUG_ATOMIC_SLEEP adds a subtle difference.
> 
> For example, let's suppose that we do not have 01/11 which fixes
> mutex_lock(). Then this code
> 
> 	set_current_state(TASK_UNINTERRUPTIBLE);
> 	...
> 	fixup_sleep();
> 	...
> 	mutex_lock(some_mutex);
> 
> can hang, but only if !CONFIG_DEBUG_ATOMIC_SLEEP.

Right, but we should not use fixup_sleep() in this case, because its an
actual proper bug, we should fix it, not paper over it. Arguably we
should use preempt_schedule in mutex_lock() in that particular case, but
that's another discussion.

> So perhaps it makes sense to redefine it
> 
> 	#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
> 	#define fixup_sleep()	(current->task_state_change = 0)
> 	#else
> 	#define fixup_sleep()	do { } while (0)
> 	#endif
> 
> and change __might_sleep()
> 
> 	-	if (WARN(current->state != TASK_RUNNING,
> 	+	if (WARN(current->state != TASK_RUNNING && current->task_state_change != 0,
> 
> ?

So I'm hesitant to go that way because it adds extra state dependency.
What if someone 'forgets' to use the *set*state() helpers.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ