[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <PH0PR21MB30258AE4C3CD9674E953C765D7E99@PH0PR21MB3025.namprd21.prod.outlook.com>
Date: Fri, 8 Apr 2022 17:41:19 +0000
From: "Michael Kelley (LINUX)" <mikelley@...rosoft.com>
To: Andrea Parri <parri.andrea@...il.com>
CC: KY Srinivasan <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>,
Wei Hu <weh@...rosoft.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Rob Herring <robh@...nel.org>,
Krzysztof Wilczynski <kw@...ux.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 4/6] Drivers: hv: vmbus: Introduce
vmbus_request_addr_match()
From: Andrea Parri <parri.andrea@...il.com> 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
Powered by blists - more mailing lists