summaryrefslogtreecommitdiff
path: root/ipc
diff options
context:
space:
mode:
authorKOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp>2011-07-23 11:57:36 +0900
committerSteven Rostedt <rostedt@rostedt.homelinux.com>2013-08-16 21:59:06 -0400
commitfe73b0fd6c4be6474dfb79fa8174e7a0a3df8271 (patch)
tree2ad1d6dc530437f0838f624eb09a3e33a646c6c4 /ipc
parent916db190ecbe8fe3c124f8ef9418160bc7b46783 (diff)
downloadlinux-rt-fe73b0fd6c4be6474dfb79fa8174e7a0a3df8271.tar.gz
ipc/mqueue: Add a critical section to avoid a deadlock
(Repost for v3.0-rt1 and changed the distination addreses) I have tested the following patch on v3.0-rt1 with PREEMPT_RT_FULL. In POSIX message queue, if a sender process uses SCHED_FIFO and has a higher priority than a receiver process, the sender will be stuck at ipc/mqueue.c:452 452 while (ewp->state == STATE_PENDING) 453 cpu_relax(); Description of the problem (receiver process) 1. receiver changes sender's state to STATE_PENDING (mqueue.c:846) 2. wake up sender process and "switch to sender" (mqueue.c:847) Note: This context switch only happens in PREEMPT_RT_FULL kernel. (sender process) 3. sender check the own state in above loop (mqueue.c:452-453) *. receiver will never wake up and cannot change sender's state to STATE_READY because sender has higher priority Signed-off-by: Yoshitake Kobayashi <yoshitake.kobayashi@toshiba.co.jp> Cc: viro@zeniv.linux.org.uk Cc: dchinner@redhat.com Cc: npiggin@kernel.dk Cc: hch@lst.de Cc: arnd@arndb.de Link: http://lkml.kernel.org/r/4E2A38A0.1090601@toshiba.co.jp Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mqueue.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 2d06b545bfdb..eec1d993ae5f 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -844,15 +844,19 @@ static inline void pipelined_receive(struct mqueue_inode_info *info)
wake_up_interruptible(&info->wait_q);
return;
}
+ /*
+ * Keep them in one critical section for PREEMPT_RT:
+ */
+ preempt_disable_rt();
msg_insert(sender->msg, info);
list_del(&sender->list);
sender->state = STATE_PENDING;
wake_up_process(sender->task);
smp_wmb();
sender->state = STATE_READY;
+ preempt_enable_rt();
}
-
-SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
+ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
size_t, msg_len, unsigned int, msg_prio,
const struct timespec __user *, u_abs_timeout)
{