| From 3162cdd49621d5207529dd1f3839f9a205847d56 Mon Sep 17 00:00:00 2001 |
| From: Ingo Molnar <mingo@elte.hu> |
| Date: Fri, 3 Jul 2009 08:30:12 -0500 |
| Subject: [PATCH] ipc: Make the ipc code -rt aware |
| |
| commit 3c96a21d186d7cadff3e356ecbea8ee9ad2692aa in tip. |
| |
| RT serializes the code with the (rt)spinlock but keeps preemption |
| enabled. Some parts of the code need to be atomic |
| nevertheless. |
| |
| Protect it with preempt_disable/enable_rt pairts. |
| |
| [PG: drop ipc/sem.c part; no longer exists in update_queue] |
| |
| Signed-off-by: Ingo Molnar <mingo@elte.hu> |
| Signed-off-by: Thomas Gleixner <tglx@linutronix.de> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/ipc/mqueue.c b/ipc/mqueue.c |
| index c79bd57..02ee4ff 100644 |
| --- a/ipc/mqueue.c |
| +++ b/ipc/mqueue.c |
| @@ -818,12 +818,17 @@ static inline void pipelined_send(struct mqueue_inode_info *info, |
| struct msg_msg *message, |
| struct ext_wait_queue *receiver) |
| { |
| + /* |
| + * Keep them in one critical section for PREEMPT_RT: |
| + */ |
| + preempt_disable_rt(); |
| receiver->msg = message; |
| list_del(&receiver->list); |
| receiver->state = STATE_PENDING; |
| wake_up_process(receiver->task); |
| smp_wmb(); |
| receiver->state = STATE_READY; |
| + preempt_enable_nort(); |
| } |
| |
| /* pipelined_receive() - if there is task waiting in sys_mq_timedsend() |
| diff --git a/ipc/msg.c b/ipc/msg.c |
| index af42ef8..b1b796d 100644 |
| --- a/ipc/msg.c |
| +++ b/ipc/msg.c |
| @@ -260,12 +260,20 @@ static void expunge_all(struct msg_queue *msq, int res) |
| while (tmp != &msq->q_receivers) { |
| struct msg_receiver *msr; |
| |
| + /* |
| + * Make sure that the wakeup doesnt preempt |
| + * this CPU prematurely. (on PREEMPT_RT) |
| + */ |
| + preempt_disable_rt(); |
| + |
| msr = list_entry(tmp, struct msg_receiver, r_list); |
| tmp = tmp->next; |
| msr->r_msg = NULL; |
| wake_up_process(msr->r_tsk); |
| smp_mb(); |
| msr->r_msg = ERR_PTR(res); |
| + |
| + preempt_enable_rt(); |
| } |
| } |
| |
| @@ -612,6 +620,12 @@ static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg) |
| !security_msg_queue_msgrcv(msq, msg, msr->r_tsk, |
| msr->r_msgtype, msr->r_mode)) { |
| |
| + /* |
| + * Make sure that the wakeup doesnt preempt |
| + * this CPU prematurely. (on PREEMPT_RT) |
| + */ |
| + preempt_disable_rt(); |
| + |
| list_del(&msr->r_list); |
| if (msr->r_maxsize < msg->m_ts) { |
| msr->r_msg = NULL; |
| @@ -625,9 +639,11 @@ static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg) |
| wake_up_process(msr->r_tsk); |
| smp_mb(); |
| msr->r_msg = msg; |
| + preempt_enable_rt(); |
| |
| return 1; |
| } |
| + preempt_enable_rt(); |
| } |
| } |
| return 0; |
| -- |
| 1.7.1.1 |
| |