From patchwork Mon Mar 19 03:20:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 10291633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC84F60386 for ; Mon, 19 Mar 2018 03:21:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9E9A290AF for ; Mon, 19 Mar 2018 03:21:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEA4A290B1; Mon, 19 Mar 2018 03:21:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2590F290AF for ; Mon, 19 Mar 2018 03:21:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755178AbeCSDVz (ORCPT ); Sun, 18 Mar 2018 23:21:55 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55156 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754923AbeCSDVw (ORCPT ); Sun, 18 Mar 2018 23:21:52 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2J3CnLA123350; Mon, 19 Mar 2018 03:21:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2017-10-26; bh=Tp1NJBbiFpg5hhwXzUmCBGKvHkb8zfPFpGrBe/Nr3vw=; b=rX3jmJ/JfIOwvE7o1zMXZq0Pw/8yjOQ7JAm2R4d08yqMJLi9IaNb3IEMtJ+QZE+cswpD Ukr1cyCTQBW+rpD8mKKxY6hoNqhvdXEv37Pv796Ga83wUFK7LPpdx+InuLGOeIJaN8CY n4A44uK7Pdxc6h8ygrtmn74yUKRwOyYzDT2+NVNsdjK3TL7jmL7YNgKKunweSUmdJhHT wj8KhIJCT2x2VTxMFDXP4R7AIbxz1MKYeFvRh6SrVU+aV8lX3eM5ZcRV9Hc3nEKQLIha CTsHn1GI40dw/EyItOHVFtJX7YxXFbG1FCDTWceuiL37BoEUy/QexRlPghz3b8ds5yLc 5w== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2gt53nr0hm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Mar 2018 03:21:45 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2J3LiOh011415 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Mar 2018 03:21:44 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w2J3LhFe014076; Mon, 19 Mar 2018 03:21:43 GMT Received: from shipfan.cn.oracle.com (/10.113.210.105) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 18 Mar 2018 20:21:42 -0700 From: Zhu Yanjun To: monis@mellanox.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, yuval.shaia@oracle.com Subject: [PATCHv2 1/1] IB/rxe: optimize the recv process Date: Sun, 18 Mar 2018 23:20:52 -0400 Message-Id: <1521429652-25352-1-git-send-email-yanjun.zhu@oracle.com> X-Mailer: git-send-email 2.7.4 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8836 signatures=668693 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=697 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803190007 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In mcast recv process, the function skb_clone is used. In fact, the refcount can be increased to replace cloning a new skb since the original skb will not be modified before it is freed. This can make the performance better and save the memory. CC: Srinivas Eeda CC: Junxiao Bi Signed-off-by: Zhu Yanjun --- V1->V2: Following Yuval's advice, skb test is removed. --- drivers/infiniband/sw/rxe/rxe_recv.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c index 4c3f899..e0e4202 100644 --- a/drivers/infiniband/sw/rxe/rxe_recv.c +++ b/drivers/infiniband/sw/rxe/rxe_recv.c @@ -276,7 +276,7 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) { struct rxe_pkt_info *pkt = SKB_TO_PKT(skb); struct rxe_mc_grp *mcg; - struct sk_buff *skb_copy; + struct sk_buff *skb_reference; struct rxe_mc_elem *mce; struct rxe_qp *qp; union ib_gid dgid; @@ -309,16 +309,19 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) continue; /* if *not* the last qp in the list - * make a copy of the skb to post to the next qp + * make a reference of the skb to post to the next qp */ - skb_copy = (mce->qp_list.next != &mcg->qp_list) ? - skb_clone(skb, GFP_ATOMIC) : NULL; + skb_reference = NULL; + if (mce->qp_list.next != &mcg->qp_list) { + skb_reference = skb; + refcount_inc(&skb->users); + } pkt->qp = qp; rxe_add_ref(qp); rxe_rcv_pkt(rxe, pkt, skb); - skb = skb_copy; + skb = skb_reference; if (!skb) break; } @@ -328,8 +331,7 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) rxe_drop_ref(mcg); /* drop ref from rxe_pool_get_key. */ err1: - if (skb) - kfree_skb(skb); + kfree_skb(skb); } static int rxe_match_dgid(struct rxe_dev *rxe, struct sk_buff *skb)