From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,URIBL_DBL_ABUSE_MALW autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8305C35247 for ; Tue, 4 Feb 2020 01:34:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 91F292084E for ; Tue, 4 Feb 2020 01:34:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="IuElJFGP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91F292084E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 454B06B026F; Mon, 3 Feb 2020 20:34:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B82D6B0270; Mon, 3 Feb 2020 20:34:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2800D6B0271; Mon, 3 Feb 2020 20:34:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 108546B026F for ; Mon, 3 Feb 2020 20:34:35 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A26BB824934B for ; Tue, 4 Feb 2020 01:34:34 +0000 (UTC) X-FDA: 76450724868.27.fowl11_ad09971e5b04 X-HE-Tag: fowl11_ad09971e5b04 X-Filterd-Recvd-Size: 4066 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 4 Feb 2020 01:34:34 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E0932087E; Tue, 4 Feb 2020 01:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580780073; bh=6qqd4obpo3LtROJpqj4ZsW/8EdpecWknKxOgDxyr1bU=; h=Date:From:To:Subject:In-Reply-To:From; b=IuElJFGPZ8PdAwhnPW+1YULoO/aBRXy7ZT1mriqqnolsnN4Ez+js30aFpK3ilBHhG QyMOgKf8nDLfpJfGCW+QWJeBOh1U7mKqjXGEaivfydrzhLA1jPpKvErFKateO8xy11 +gi7SrevAIgmOk2zsNMTIzU6ZSLHshHapq+KqWgg= Date: Mon, 03 Feb 2020 17:34:32 -0800 From: Andrew Morton To: 1vier1@web.de, akpm@linux-foundation.org, dave@stgolabs.net, linux-mm@kvack.org, longman@redhat.com, manfred@colorfullife.com, mm-commits@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, will.deacon@arm.com Subject: [patch 15/67] ipc/mqueue.c: remove duplicated code Message-ID: <20200204013432.adPyN2kx-%akpm@linux-foundation.org> In-Reply-To: <20200203173311.6269a8be06a05e5a4aa08a93@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Davidlohr Bueso Subject: ipc/mqueue.c: remove duplicated code pipelined_send() and pipelined_receive() are identical, so merge them. [manfred@colorfullife.com: add changelog] Link: http://lkml.kernel.org/r/20191020123305.14715-3-manfred@colorfullife.com Signed-off-by: Davidlohr Bueso Signed-off-by: Manfred Spraul Cc: <1vier1@web.de> Cc: Peter Zijlstra Cc: Waiman Long Cc: Will Deacon Signed-off-by: Andrew Morton --- ipc/mqueue.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) --- a/ipc/mqueue.c~ipc-mqueuec-remove-duplicated-code +++ a/ipc/mqueue.c @@ -918,17 +918,12 @@ out_name: * The same algorithm is used for senders. */ -/* pipelined_send() - send a message directly to the task waiting in - * sys_mq_timedreceive() (without inserting message into a queue). - */ -static inline void pipelined_send(struct wake_q_head *wake_q, +static inline void __pipelined_op(struct wake_q_head *wake_q, struct mqueue_inode_info *info, - struct msg_msg *message, - struct ext_wait_queue *receiver) + struct ext_wait_queue *this) { - receiver->msg = message; - list_del(&receiver->list); - wake_q_add(wake_q, receiver->task); + list_del(&this->list); + wake_q_add(wake_q, this->task); /* * Rely on the implicit cmpxchg barrier from wake_q_add such * that we can ensure that updating receiver->state is the last @@ -937,7 +932,19 @@ static inline void pipelined_send(struct * yet, at that point we can later have a use-after-free * condition and bogus wakeup. */ - receiver->state = STATE_READY; + this->state = STATE_READY; +} + +/* pipelined_send() - send a message directly to the task waiting in + * sys_mq_timedreceive() (without inserting message into a queue). + */ +static inline void pipelined_send(struct wake_q_head *wake_q, + struct mqueue_inode_info *info, + struct msg_msg *message, + struct ext_wait_queue *receiver) +{ + receiver->msg = message; + __pipelined_op(wake_q, info, receiver); } /* pipelined_receive() - if there is task waiting in sys_mq_timedsend() @@ -955,9 +962,7 @@ static inline void pipelined_receive(str if (msg_insert(sender->msg, info)) return; - list_del(&sender->list); - wake_q_add(wake_q, sender->task); - sender->state = STATE_READY; + __pipelined_op(wake_q, info, sender); } static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr, _