From: Roland Dreier <rdreier@cisco.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: linux-scsi@vger.kernel.org, scst-devel@lists.sourceforge.net,
linux-rdma@vger.kernel.org, James.Bottomley@suse.de,
Vu Pham <vu@mellanox.com>, Roland Dreier <rolandd@cisco.com>,
David Dillow <dave@thedillows.org>
Subject: Re: [PATCH 4/7] [SCSI] scst: Add SRP target driver
Date: Thu, 06 Jan 2011 11:00:10 -0800 [thread overview]
Message-ID: <adahbdldfid.fsf@cisco.com> (raw)
In-Reply-To: <AANLkTineDYxbjEdtfBJ6WjLfxs2VvqnQ9v887vExHga7@mail.gmail.com> (Bart Van Assche's message of "Thu, 6 Jan 2011 18:41:41 +0100")
> I'll have a look at converting these atomic operations into regular
> locking. The current implementation should be fine though.
I believe that the current implementation is correct. However it is
much harder for someone naive like me to understand, since using cmpxchg
is much subtler than just using a lock to protect data. If this isn't
on the hottest of hot paths then I think cmpxchg is over-optimization --
much better to have less fancy code.
> > Also, there is processing_compl:
> >
> > > +static void srpt_completion(struct ib_cq *cq, void *ctx)
> > > +{
> > > + struct srpt_rdma_ch *ch = ctx;
> > > +
> > > + BUG_ON(!ch);
> > > + atomic_inc(&ch->processing_compl);
> >
> > and
> >
> > > +static void srpt_unregister_channel(struct srpt_rdma_ch *ch)
> > > ...
> > > + while (atomic_read(&ch->processing_compl))
> > > + ;
> >
> > this seems racy to me -- I don't see any reason why we couldn't have:
> >
> > srpt_completion()
> >
> > srpt_unregister_channel()
> > processing_compl == 0,
> > continue
> >
> > atomic_inc(&ch->processing_compl);
> >
> > finish unregistering channel
> >
> > use unregistered channel
>
> I'm not sure what the above pseudo-code should do ?
I'm trying to illustrate the race by showing what two different contexts
might be doing -- the left column is one context, the right column is
the other context.
In this specific case, if the while loop testing processing_compl
actually ever does anything then I don't see how it could be safe -- if
srpt_completion() could be executing during the while loop, then I don't
see anything that prevents the while loop from finishing before
srpt_completion does its atomic_inc().
> Regarding the current implementation: there is a hard requirement in
> SCST that no new commands are queued for a given session after
> scst_unregister_session() has been invoked. So
> scst_unregister_session() must only be invoked after the IB queue pair
> has been reset *and* srpt_completion() has finished. It would be great
> if that could be implemented without using one or another kind of
> counter. I'm not sure however whether it is possible to eliminate the
> "processing_compl" counter entirely.
I don't pretend to understand the flow of code here. But it seems the
only safe way to implement this cleanup code is to stop posting work
requests and then wait until all the requests you've posted are
complete. Trying to wait for the completion handler to stop executing
does not seem possible to implement in a safe way.
- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2011-01-06 19:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-20 17:49 [PATCH 4/7] [SCSI] scst: Add SRP target driver Bart Van Assche
2010-12-21 1:50 ` Jack Wang
[not found] ` <544F03C80B314396A5517F4CD1A848B6-aA8Fybl81pBv1O+Z8WTAqQ@public.gmane.org>
2010-12-21 9:50 ` Bart Van Assche
[not found] ` <201012201849.27639.bvanassche-HInyCGIudOg@public.gmane.org>
2011-01-05 20:21 ` Roland Dreier
[not found] ` <adaaajfdrtr.fsf-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2011-01-06 17:41 ` Bart Van Assche
2011-01-06 19:00 ` Roland Dreier [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=adahbdldfid.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=James.Bottomley@suse.de \
--cc=bvanassche@acm.org \
--cc=dave@thedillows.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=rolandd@cisco.com \
--cc=scst-devel@lists.sourceforge.net \
--cc=vu@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).