Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4503782pxv; Tue, 20 Jul 2021 05:24:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUnFQJOekWOhbQk0PlQlen3Oisr/QpnFtYiGu9y1cG48sIDaePEjzW12FroRsCBQGiyQHV X-Received: by 2002:a02:cc19:: with SMTP id n25mr26284612jap.140.1626783894049; Tue, 20 Jul 2021 05:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626783894; cv=none; d=google.com; s=arc-20160816; b=tn8e34eg30VJppMcIUebeevQy4f10zJUkY7bDNy8FdUssst+KkFDSOVNEeTgKRNd9+ pys8ZnhvPsh2MSV1q5AYmT289wurnecTNcFJjp/b21pCiqig5clVTb8GcyDHFrVS+oyO 8F6VwCT3VJ3umvWImFuTy0s0WNZzTbu9/id/3kUtz5gvT86+ZMLwoK0A3nuh9jbSH4q9 QHrK0djEJ6Dq5RYQZKjSQF7ChfoL4GrqlngW6fNYn0O1lSNbW8ecXiUGnHXf8qG4uSFo KLC9JcCSa13u1JOngeHDd1vYhAUzSYHCGlFe+Gm/CiVBM61RoiUPskt1XoGapE/liuTz GxEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iNGbB/CDGVuDFMCa3ISzJNPiN2+p07A27D9aSEv1vso=; b=SotMlRaXRu0EMASzTtPDTSm7L/Y6ny9WngWKAMeyHQp4kMUPebUZ4utC77nUQPi+sO /wqZm0rcLrzF0l0oUWxb090xYWTbxmBUEQY1ELCwggiXCTyhWlISKF3mwVzNRWBOV7uf cW8+PewNY0djgu16OReczqkFIEqXD40W9ZZfk0RIuAajfQtnRnJFfnfW3g6Q0y3qwTT1 GPfqvPHV39q2gnLcd2/MKt4W8Bb0gGgV+Zs/EwRFqQAUaQyxmBm8W9H7SuSr6/cfnZbG Bh/81C7AlbZvcnOT6e1oZ5oeeFVoHJb9+OKq2SlnRumdNQfFYNqEAXMvVaDo3XUJHWQn xn1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAlToWw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z6si12859576ilq.82.2021.07.20.05.24.41; Tue, 20 Jul 2021 05:24:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAlToWw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237683AbhGTLnG (ORCPT + 99 others); Tue, 20 Jul 2021 07:43:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:33178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236874AbhGTLmk (ORCPT ); Tue, 20 Jul 2021 07:42:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E85661165; Tue, 20 Jul 2021 12:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626783792; bh=k3u8kVux9MZ9aUC3HoK/CusB+Yi3Q/t7dbfUVU7znNo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YAlToWw6aOZLePABIn2HAXF+uAnzv+QapStGGsYQegZtpptH1zLoy2hLFK+48tIlQ wjYkxMwBn37OVQkBauBGy+aF7eh3th9UeG4AbmGbJVldn3wIZOqZ2vtsOVcH8mKbVO cTQ3D1UbjtDGkyyiOwgU6o5TUDei8ZTEoXFrSUIRAkC87ebV8emtK0D4ZqxLL+US3h X2weJd6lg4ru7eASwjqMCYf90P0wiSfe3Z4jDTt6MFXCojK+fA8gVjSg1Frepl76V/ 6X8F4lhEoPMYhQA0/pG5J4kyZW7PEUjN/vXRjejSPSf2ojPFzZvT1gN0fIepm5fi0/ pjIWx66FzHMng== Date: Tue, 20 Jul 2021 15:23:08 +0300 From: Leon Romanovsky To: Christophe JAILLET Cc: mustafa.ismail@intel.com, shiraz.saleem@intel.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] RDMA/irdma: Improve the way 'cqp_request' structures are cleaned when they are recycled Message-ID: References: <7f93f2a2c2fd18ddfeb99339d175b85ffd1c6398.1626713915.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7f93f2a2c2fd18ddfeb99339d175b85ffd1c6398.1626713915.git.christophe.jaillet@wanadoo.fr> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 19, 2021 at 07:02:15PM +0200, Christophe JAILLET wrote: > A set of IRDMA_CQP_SW_SQSIZE_2048 (i.e. 2048) 'cqp_request' are > pre-allocated and zeroed in 'irdma_create_cqp()' (hw.c). These > structures are managed with the 'cqp->cqp_avail_reqs' list which keeps > track of available entries. > > In 'irdma_free_cqp_request()' (utils.c), when an entry is recycled and goes > back to the 'cqp_avail_reqs' list, some fields are reseted. > > However, one of these fields, 'compl_info', is initialized within > 'irdma_alloc_and_get_cqp_request()'. > > Move the corresponding memset to 'irdma_free_cqp_request()' so that the > clean-up is done in only one place. This makes the logic more easy to > understand. I'm not so sure. The function irdma_alloc_and_get_cqp_request() returns prepared cqp_request and all users expect that it will returned cleaned one. The reliance on some other place to clear part of the structure is prone to errors. Thanks > > This also saves this memset in the case that the 'cqp_avail_reqs' list is > empty and a new 'cqp_request' structure must be allocated. This memset is > useless, because the structure is already kzalloc'ed. > > Signed-off-by: Christophe JAILLET > --- > drivers/infiniband/hw/irdma/utils.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c > index 5bbe44e54f9a..66711024d38b 100644 > --- a/drivers/infiniband/hw/irdma/utils.c > +++ b/drivers/infiniband/hw/irdma/utils.c > @@ -445,7 +445,6 @@ struct irdma_cqp_request *irdma_alloc_and_get_cqp_request(struct irdma_cqp *cqp, > > cqp_request->waiting = wait; > refcount_set(&cqp_request->refcnt, 1); > - memset(&cqp_request->compl_info, 0, sizeof(cqp_request->compl_info)); > > return cqp_request; > } > @@ -475,6 +474,7 @@ void irdma_free_cqp_request(struct irdma_cqp *cqp, > cqp_request->request_done = false; > cqp_request->callback_fcn = NULL; > cqp_request->waiting = false; > + memset(&cqp_request->compl_info, 0, sizeof(cqp_request->compl_info)); > > spin_lock_irqsave(&cqp->req_lock, flags); > list_add_tail(&cqp_request->list, &cqp->cqp_avail_reqs); > -- > 2.30.2 >