From: Andrea Parri <parri.andrea@xxxxxxxxx> Sent: Friday, April 8, 2022 9:47 AM > > > > @@ -1300,25 +1294,60 @@ u64 vmbus_request_addr(struct vmbus_channel > > > *channel, u64 trans_id) > > > if (!trans_id) > > > return VMBUS_RQST_ERROR; > > > > > > - spin_lock_irqsave(&rqstor->req_lock, flags); > > > - > > > /* Data corresponding to trans_id is stored at trans_id - 1 */ > > > trans_id--; > > > > > > /* Invalid trans_id */ > > > - if (trans_id >= rqstor->size || !test_bit(trans_id, rqstor->req_bitmap)) { > > > - spin_unlock_irqrestore(&rqstor->req_lock, flags); > > > + if (trans_id >= rqstor->size || !test_bit(trans_id, rqstor->req_bitmap)) > > > return VMBUS_RQST_ERROR; > > > - } > > > > > > req_addr = rqstor->req_arr[trans_id]; > > > - rqstor->req_arr[trans_id] = rqstor->next_request_id; > > > - rqstor->next_request_id = trans_id; > > > + if (rqst_addr == VMBUS_RQST_ADDR_ANY || req_addr == rqst_addr) { > > > + rqstor->req_arr[trans_id] = rqstor->next_request_id; > > > + rqstor->next_request_id = trans_id; > > > > > > - /* The already held spin lock provides atomicity */ > > > - bitmap_clear(rqstor->req_bitmap, trans_id, 1); > > > + /* The already held spin lock provides atomicity */ > > > + bitmap_clear(rqstor->req_bitmap, trans_id, 1); > > > + } > > > > 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. Just thinking out loud, maybe vmbus_request_addr_match() should be renamed to vmbus_request_addr_remove(), and not have a return value? That would be a bit more consistent with the actual purpose. Michael