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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 09279C32750 for ; Wed, 31 Jul 2019 02:43:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D502D2089E for ; Wed, 31 Jul 2019 02:43:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727999AbfGaCnM (ORCPT ); Tue, 30 Jul 2019 22:43:12 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3255 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727714AbfGaCnL (ORCPT ); Tue, 30 Jul 2019 22:43:11 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A6BA23A9573FAE8280B4; Wed, 31 Jul 2019 10:43:08 +0800 (CST) Received: from [127.0.0.1] (10.61.25.96) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Wed, 31 Jul 2019 10:43:02 +0800 Subject: Re: [PATCH for-next 10/13] RDMA/hns: Remove unnecessary kzalloc To: Leon Romanovsky CC: , , , References: <1564477010-29804-1-git-send-email-oulijun@huawei.com> <1564477010-29804-11-git-send-email-oulijun@huawei.com> <20190730134025.GD4878@mtr-leonro.mtl.com> From: oulijun Message-ID: Date: Wed, 31 Jul 2019 10:43:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20190730134025.GD4878@mtr-leonro.mtl.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.61.25.96] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org ÔÚ 2019/7/30 21:40, Leon Romanovsky дµÀ: > On Tue, Jul 30, 2019 at 04:56:47PM +0800, Lijun Ou wrote: >> From: Lang Cheng >> >> For hns_roce_v2_query_qp and hns_roce_v2_modify_qp, >> we can use stack memory to create qp context data. >> Make the code simpler. >> >> Signed-off-by: Lang Cheng >> --- >> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 64 +++++++++++++----------------- >> 1 file changed, 27 insertions(+), 37 deletions(-) >> >> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c >> index 1186e34..07ddfae 100644 >> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c >> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c >> @@ -4288,22 +4288,19 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp, >> { >> struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device); >> struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); >> - struct hns_roce_v2_qp_context *context; >> - struct hns_roce_v2_qp_context *qpc_mask; >> + struct hns_roce_v2_qp_context ctx[2]; >> + struct hns_roce_v2_qp_context *context = ctx; >> + struct hns_roce_v2_qp_context *qpc_mask = ctx + 1; >> struct device *dev = hr_dev->dev; >> int ret; >> >> - context = kcalloc(2, sizeof(*context), GFP_ATOMIC); >> - if (!context) >> - return -ENOMEM; >> - >> - qpc_mask = context + 1; >> /* >> * In v2 engine, software pass context and context mask to hardware >> * when modifying qp. If software need modify some fields in context, >> * we should set all bits of the relevant fields in context mask to >> * 0 at the same time, else set them to 0x1. >> */ >> + memset(context, 0, sizeof(*context)); > "struct hns_roce_v2_qp_context ctx[2] = {};" will do the trick. > > Thanks > > . In this case, the mask is actually writen twice. if you do this, will it bring extra overhead when modify qp?