linux/ipc
KOBAYASHI Yoshitake 8f665c88c9 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>
2020-10-14 00:59:13 +03:00
..
Makefile Add generic sys_ipc wrapper 2010-03-12 15:52:32 -08:00
compat.c ipc: fix compat msgrcv with negative msgtyp 2014-01-27 21:02:40 -08:00
compat_mq.c ipc: whitespace cleanup 2014-01-27 21:02:39 -08:00
ipc_sysctl.c ipc: always handle a new value of auto_msgmni 2014-11-21 09:23:04 -08:00
ipcns_notifier.c ipc: do not use a negative value to re-enable msgmni automatic recomputing 2008-07-25 10:53:42 -07:00
mq_sysctl.c ipc,mqueue: remove limits for the amount of system-wide queues 2014-02-25 15:25:45 -08:00
mqueue.c ipc/mqueue: Add a critical section to avoid a deadlock 2020-10-14 00:59:13 +03:00
msg.c ipc: Make the ipc code -rt aware 2020-10-14 00:59:13 +03:00
msgutil.c ipc, msg: fix message length check for negative values 2013-11-13 12:09:36 +09:00
namespace.c ipc: drop ipc_lock_by_ptr 2013-09-11 15:59:44 -07:00
sem.c ipc: remove braces for single statements 2014-01-27 21:02:39 -08:00
shm.c ipc: standardize code comments 2014-01-27 21:02:39 -08:00
syscall.c get rid of union semop in sys_semctl(2) arguments 2013-03-05 15:14:16 -05:00
util.c ipc: delete seq_max field in struct ipc_ids 2014-01-27 21:02:40 -08:00
util.h ipc: delete seq_max field in struct ipc_ids 2014-01-27 21:02:40 -08:00