From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Or Har-Toov <ohartoov@nvidia.com>,
linux-rdma@vger.kernel.org, Maher Sanalla <msanalla@nvidia.com>
Subject: Re: [PATCH rdma-next 2/3] IB/mad: Remove unnecessary done list by utilizing MAD states
Date: Tue, 10 Dec 2024 15:00:34 -0400 [thread overview]
Message-ID: <20241210190034.GK2347147@nvidia.com> (raw)
In-Reply-To: <8f746ee2eac86138b1051908b95a21fdff24af6c.1733233636.git.leonro@nvidia.com>
On Tue, Dec 03, 2024 at 03:52:22PM +0200, Leon Romanovsky wrote:
> From: Or Har-Toov <ohartoov@nvidia.com>
>
> Remove the done list, which has become unnecessary with the
> introduction of the `state` parameter.
>
> Previously, the done list was used to ensure that MADs removed from
> the wait list would still be in some list, preventing failures in
> the call to `list_del` in `ib_mad_complete_send_wr`.
Yuk, that is a terrible reason for this. list_del_init() would solve
that problem.
> @@ -1772,13 +1771,11 @@ ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
> void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr)
> {
> mad_send_wr->timeout = 0;
> - if (mad_send_wr->state == IB_MAD_STATE_WAIT_RESP) {
> + list_del(&mad_send_wr->agent_list);
This is doing more than the commit message says, we are now changing
the order for when the mad is in the list, here you are removing it as
soon as it becomes done, or semi-done instead of letting
ib_mad_complete_send_wr() always remove it.
I couldn't find a reason it is not OK, but I think it should be in the
commit message.
> static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
> @@ -2249,7 +2246,9 @@ void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
> }
>
> /* Remove send from MAD agent and notify client of completion */
> - list_del(&mad_send_wr->agent_list);
> + if (mad_send_wr->state == IB_MAD_STATE_SEND_START)
> + list_del(&mad_send_wr->agent_list);
> +
This extra if is confusing now.. There are two callers to
ib_mad_complete_send_wr(), the receive path did ib_mark_mad_done()
first so state should be DONE or EARLY_RESP and the list_del was done
already.
The other one is send completion which should have state be SEND_START
*and* we hit an error making the send, then we remove it from the list?
Again I think this needs to go further and stop using ->status as part
of the FSM too.
Trying again, maybe like this:
spin_lock_irqsave(&mad_agent_priv->lock, flags);
if (ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)) {
ret = ib_process_rmpp_send_wc(mad_send_wr, mad_send_wc);
if (ret == IB_RMPP_RESULT_CONSUMED)
goto done;
} else
ret = IB_RMPP_RESULT_UNHANDLED;
if (mad_send_wr->state == IB_MAD_STATE_SEND_START) {
if (mad_send_wc->status != IB_WC_SUCCESS &&
mad_send_wr->timeout) {
wait_for_response(mad_send_wr);
goto done;
}
/* Otherwise error posting send */
list_del(&mad_send_wr->agent_list);
}
WARN_ON(mad_send_wr->state != IB_MAD_STATE_EARLY_RESP &&
mad_send_wr->state != IB_MAD_STATE_DONE);
mad_send_wr->state = IB_MAD_STATE_DONE;
mad_send_wr->status = mad_send_wc->status;
adjust_timeout(mad_agent_priv);
spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
Though that might require changing cancel_mad too, as in the other
message, I think with the FSM cancel_mad should put the state to DONE
and leave the status alone.
This status fiddling is probably another patch.
Jason
next prev parent reply other threads:[~2024-12-10 19:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 13:52 [PATCH rdma-next 0/3] Add Flow Control for Solicited MADs Leon Romanovsky
2024-12-03 13:52 ` [PATCH rdma-next 1/3] IB/mad: Replace MAD's refcount with a state machine Leon Romanovsky
2024-12-10 16:12 ` Jason Gunthorpe
2024-12-03 13:52 ` [PATCH rdma-next 2/3] IB/mad: Remove unnecessary done list by utilizing MAD states Leon Romanovsky
2024-12-10 19:00 ` Jason Gunthorpe [this message]
2024-12-10 23:51 ` Or Har-Toov
2024-12-03 13:52 ` [PATCH rdma-next 3/3] IB/mad: Add flow control for solicited MADs Leon Romanovsky
2024-12-10 20:12 ` Jason Gunthorpe
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=20241210190034.GK2347147@nvidia.com \
--to=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=msanalla@nvidia.com \
--cc=ohartoov@nvidia.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.