All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
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
Date: Wed, 21 Jul 2021 08:11:26 +0300	[thread overview]
Message-ID: <YPesftdeBpzJUhMZ@unreal> (raw)
In-Reply-To: <629bc34e-ef41-9af6-9ed7-71865251a62c@wanadoo.fr>

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

      reply	other threads:[~2021-07-21  5:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19 17:02 [PATCH] RDMA/irdma: Improve the way 'cqp_request' structures are cleaned when they are recycled Christophe JAILLET
2021-07-20 12:23 ` Leon Romanovsky
2021-07-20 13:05   ` Christophe JAILLET
2021-07-21  5:11     ` Leon Romanovsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YPesftdeBpzJUhMZ@unreal \
    --to=leon@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mustafa.ismail@intel.com \
    --cc=shiraz.saleem@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.