https://github.com/torvalds/linux
Revision d6f029130fb83b36fb709a187275b0494035d689 authored by Nicolas Pitre on 21 December 2005, 17:26:25 UTC, committed by Linus Torvalds on 22 December 2005, 17:17:39 UTC
Currently a simple

	void foo(void) { preempt_enable(); }

produces the following code on ARM:

foo:
	bic	r3, sp, #8128
	bic	r3, r3, #63
	ldr	r2, [r3, #4]
	ldr	r1, [r3, #0]
	sub	r2, r2, #1
	tst	r1, #4
	str	r2, [r3, #4]
	blne	preempt_schedule
	mov	pc, lr

The problem is that the TIF_NEED_RESCHED flag is loaded _before_ the
preemption count is stored back, hence any interrupt coming within that
3 instruction window causing TIF_NEED_RESCHED to be set won't be
seen and scheduling won't happen as it should.

Nothing currently prevents gcc from performing that reordering.  There
is already a barrier() before the decrement of the preemption count, but
another one is needed between this and the TIF_NEED_RESCHED flag test
for proper code ordering.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Acked-by: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent d5ea4e2
History
Tip revision: d6f029130fb83b36fb709a187275b0494035d689 authored by Nicolas Pitre on 21 December 2005, 17:26:25 UTC
[PATCH] fix race with preempt_enable()
Tip revision: d6f0291
File Mode Size
Documentation
arch
block
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
scripts
security
sound
usr
.gitignore -rw-r--r-- 391 bytes
COPYING -rw-r--r-- 18.3 KB
CREDITS -rw-r--r-- 87.5 KB
Kbuild -rw-r--r-- 1.2 KB
MAINTAINERS -rw-r--r-- 63.8 KB
Makefile -rw-r--r-- 42.8 KB
README -rw-r--r-- 14.7 KB
REPORTING-BUGS -rw-r--r-- 3.0 KB

README

back to top