RE: [PATCH 4/6] Drivers: hv: vmbus: Introduce vmbus_request_addr_match()

Michael Kelley (LINUX)
2022-04-11T02:32:30Z

From: Andrea Parri <parri.andrea@gmail.com> Sent: Friday, April 8, 2022 1:38 PM
>
> > > > In the case where a specific match is required, and trans_id is
> > > > valid but the addr's do not match, it looks like this function will
> > > > return the addr that didn't match, without removing the entry.
> > >
> > > Yes, that is consistent with the description on vmbus_request_addr_match():
> > >
> > > Returns the memory address stored at @trans_id, or VMBUS_RQST_ERROR if
> > > @trans_id is not contained in the requestor.
> > >
> > >
> > > > Shouldn't it return VMBUS_RQST_ERROR in that case?
> > >
> > > Can certainly be done, although I'm not sure to follow your concerns. Can
> > > you elaborate?
> > >
> >
> > Having the function return "success" when it failed to match is unexpected
> > for me. There's only one invocation where we care about matching
> > (in hv_compose_msi_msg). In that invocation the purpose for matching is to
> > not remove the wrong entry, and the return value is ignored. So I think
> > it all works correctly.
>
> You're reading it wrongly: the point is that there's nothing wrong in *not
> removing the "wrong entry" (or in failing to match). In the mentioned use,
> that means the channel callback has already processed "our" request, and
> that we don't have to worry about the ID. (Otherwise, i.e. if we do match,
> the callback will eventually scream "Invalid transaction".)
>
>
> > Just thinking out loud, maybe vmbus_request_addr_match() should be
> > renamed to vmbus_request_addr_remove(), and not have a return value?
>
> Mmh. We have vmbus_request_addr() that (always) removes the ID; it seems
> a _remove() would just add to the confusion. And removing the return value
> would mean duplicating most of vmbus_request_addr() in the "new" function.
> So, I'm not convinced that's the right thing to do. I'm inclined to leave
> this patch as is (and, as usual, happy to be proven wrong).
>

I'll defer to your judgment. I don't see anything that broken with the
patch as written, so I can live with it as is.

Michael