Skip to content

Commit ed29f17

Browse files
Davidlohr Buesotorvalds
authored andcommitted
ipc/mqueue.c: remove duplicated code
pipelined_send() and pipelined_receive() are identical, so merge them. [[email protected]: add changelog] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Davidlohr Bueso <[email protected]> Signed-off-by: Manfred Spraul <[email protected]> Cc: <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Waiman Long <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 39323c6 commit ed29f17

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

ipc/mqueue.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -918,17 +918,12 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
918918
* The same algorithm is used for senders.
919919
*/
920920

921-
/* pipelined_send() - send a message directly to the task waiting in
922-
* sys_mq_timedreceive() (without inserting message into a queue).
923-
*/
924-
static inline void pipelined_send(struct wake_q_head *wake_q,
921+
static inline void __pipelined_op(struct wake_q_head *wake_q,
925922
struct mqueue_inode_info *info,
926-
struct msg_msg *message,
927-
struct ext_wait_queue *receiver)
923+
struct ext_wait_queue *this)
928924
{
929-
receiver->msg = message;
930-
list_del(&receiver->list);
931-
wake_q_add(wake_q, receiver->task);
925+
list_del(&this->list);
926+
wake_q_add(wake_q, this->task);
932927
/*
933928
* Rely on the implicit cmpxchg barrier from wake_q_add such
934929
* that we can ensure that updating receiver->state is the last
@@ -937,7 +932,19 @@ static inline void pipelined_send(struct wake_q_head *wake_q,
937932
* yet, at that point we can later have a use-after-free
938933
* condition and bogus wakeup.
939934
*/
940-
receiver->state = STATE_READY;
935+
this->state = STATE_READY;
936+
}
937+
938+
/* pipelined_send() - send a message directly to the task waiting in
939+
* sys_mq_timedreceive() (without inserting message into a queue).
940+
*/
941+
static inline void pipelined_send(struct wake_q_head *wake_q,
942+
struct mqueue_inode_info *info,
943+
struct msg_msg *message,
944+
struct ext_wait_queue *receiver)
945+
{
946+
receiver->msg = message;
947+
__pipelined_op(wake_q, info, receiver);
941948
}
942949

943950
/* pipelined_receive() - if there is task waiting in sys_mq_timedsend()
@@ -955,9 +962,7 @@ static inline void pipelined_receive(struct wake_q_head *wake_q,
955962
if (msg_insert(sender->msg, info))
956963
return;
957964

958-
list_del(&sender->list);
959-
wake_q_add(wake_q, sender->task);
960-
sender->state = STATE_READY;
965+
__pipelined_op(wake_q, info, sender);
961966
}
962967

963968
static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,

0 commit comments

Comments
 (0)