Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5175389pxv; Tue, 20 Jul 2021 22:12:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxlZRNSCe8zNuwbJakWf29Row576l0hNSLlKCIGHeZ14iTYI2EPgSMiEW24CZ2Kww31kjq X-Received: by 2002:a05:6e02:f53:: with SMTP id y19mr24397556ilj.181.1626844365447; Tue, 20 Jul 2021 22:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626844365; cv=none; d=google.com; s=arc-20160816; b=x6wMS69mvXTe7u7SXo0GNiN7RSSnCGx/Ww+WNAEb0YSq1jq1njGdUohm46UiNBha4Z QjZ2Q/2I3SbPlWLFiFv7HiQ7cfWMwLNHfBVlzxeM0wFKw02xOcKLqMuplGzWXjyOeUI2 zpe98S4CGjL9RFOixuTsUf1XTE47okxYozL9pkle67igvUYOwK1j8OyUPBv3c1DAqC1d id/ZrLDupJtz2qBgQsRN8vvTxcMLq6Qbt3LKGOwaPlejlJShhwNmVStDbdh1IjU5r0rf 9+DZ5a1rA1zoS7LWyLKnoD0z6NFotx7U1vlY2eN7PezLMPPQWGiPyQjqOrFsk0oX8L6/ FO9g== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=snDOJH8G14tNjYtilxJbcByBNPsOK0WtOkVB7E7hUg8=; b=o71ERuYgK+e6d7nbwoCs+qX5r1Qnsmxp6Jl1qC7CrA79e6dWsW4VYin84/A/R2AnPq DPZF32W9FDwo4AihmQ165Oldxpx3vJhaSwHjc6MtjqSdBL/ZsUK1gy0ar0seER+tC50h Lk71UD5mbSyux3VdGvatkA6LDr800l/Ef/dcpWvamjsZMMvShr+KQ3LYNkZW142I1YR4 9TIeZDFS9/2G/tH9/995xUOp07r7osnpwq6ish3YRkmES26WkY2qcs5Ghnle8UPpD3Ru rkoDZnUQ9Hv3I44cBeDU0nmWKTirWed/chi4Glv07wbj5fHBCrFK+cNkTGLiIe5w0wJN OUkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J6vKnKOX; 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 e20si19211388iow.6.2021.07.20.22.12.33; Tue, 20 Jul 2021 22:12:45 -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=J6vKnKOX; 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 S232733AbhGUEbP (ORCPT + 99 others); Wed, 21 Jul 2021 00:31:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:46112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232512AbhGUEaw (ORCPT ); Wed, 21 Jul 2021 00:30:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5348A60FE7; Wed, 21 Jul 2021 05:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626844290; bh=pHR2j/1bWtegDLobNbANc0THMPZSOJdmsO6JZSbVrvE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J6vKnKOXleULywJpU2/cJo1wUEgINlSqz+X3/vhpRUHMVbyrFw8cAF3eniYRXbIcX ooVQAQ55DDXEUPMEKxCHncH47HJpZo3LpJQpF0TrM5Sb141gYAaF/+QFDahjfp0mZz xWTweK9B+tqUcrVYS8qC7qpXQJtWaQfl6jlh0Jr0O+YmBUtCAWchWXaJANZYtP2QEI F5jIJgjo4+c46dT4gm4LwFuF7d2WGx8Zh0SLzrlvLwAG7uIaWs2PcxGNg+ZwhnOY1V ie0CclnW/SbXKuPyrN9hX5r3ohW2zh1bYuw69p7Uv6iwduEMdA/VS59vT/E89YVMUA 4oRawwzvbkmHQ== Date: Wed, 21 Jul 2021 08:11:26 +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> <629bc34e-ef41-9af6-9ed7-71865251a62c@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <629bc34e-ef41-9af6-9ed7-71865251a62c@wanadoo.fr> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 20, 2021 at 03:05:55PM +0200, Christophe JAILLET wrote: > Le 20/07/2021 ? 14:23, Leon Romanovsky a ?crit?: > > 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. > > Ok, so maybe, moving: > cqp_request->request_done = false; > cqp_request->callback_fcn = NULL; > cqp_request->waiting = false; > from 'irdma_free_cqp_request()' to 'irdma_alloc_and_get_cqp_request()' to > make explicit what is reseted makes more sense? I think so, but it requires double check that these cleared values are not used after irdma_free_cqp_request(). This is another reason why clearing fields after _free_ routine is mostly wrong. It hides errors when data is accessed after release. Thanks