[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 5/6] tools/oxenstored: Rework Domain evtchn handling to use port_pair


  • To: Christian Lindig <christian.lindig@xxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Thu, 1 Dec 2022 14:22:49 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aNs7/LTaElDmCxfc7+lCH20vWS9USDw/JV+/wAZvdWU=; b=P1KMnx6yvwekkOhsFArGbATtw3OnubM+Neg5S/ysMYKr+1TOULmPp4yjFJ14KCAgdq3/Clwa+8F7ZzqaEkM2h8AU0+UITe6O4KUzxdDW9lqWW7zgJd6ObWWaG10zsDKkvWl4UerKmcFsXp0D+mvYf1pjdEqhPUqr5GEqY39phP9cbVviDnz0YqLWbTJLyUzUky3J3Xn0/9b2FqvceyA3IYzIh5dIljBKqu34C5n1+rFiWPwWFmFcmjiiwhIMVveJX6Sh6CfRdjdLVCDZlxbSRz+2bpInMZoYhX+Qqh+rn+AQq1BZxyYRqQqDIb+waarFMWaZmgw2lX6xbvpI2IZe/w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MiYWyjTcusNh+mWf7rYP/+4rRtmNNfDRzBh2NTQetdHrOv7Y2d1BGiyuIFhSeXbATreUevedRxpVXCV70mMAiYZuEAjnWPxc6bjuMGb7mY7+meZQcQyhHNyQYfpnVrtnflFPOCly0Px3M7DKoZwyq2ZreVNY7twjR0Zczg2dPnRuIrLkV8PjQrq750KHmqibBeE6fKGpyTZEoD8Sb05Ej1eehFciWgE0ZpI8VmH9zQhr57A41sRM+FU8eQAXRpCcIPnHsKB+4alepdCjB4kbxzaeOTwFgzlriWafA4uagrMNnMrysUR3H7vmtejBHj/hK3AJmmqCMowTDD0b3Rm7Dg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Edwin Torok <edvin.torok@xxxxxxxxxx>, Rob Hoes <Rob.Hoes@xxxxxxxxxx>
  • Delivery-date: Thu, 01 Dec 2022 14:23:01 +0000
  • Ironport-data: A9a23:by554qmL7wnIYHONF6vIzxXo5gycJ0RdPkR7XQ2eYbSJt1+Wr1Gzt xJJDG3XOfjcN2T1Ko12Ot7ip0IEvp+Hxt5nSVdt+HozRiMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icf3grHmeIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE4p7aqaVA8w5ARkP6kR5AaGzRH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 cQaNTFObx2EvsO3moKZS9NTqOQZc/C+aevzulk4pd3YJdAPZMifBo/stZpf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVk1A3jOOF3Nn9I7RmQe18mEqCq 32A1GP+GhwAb/SUyCaf82LqjejK9c/+cNJMTOPiqaY76LGV7jEyKB0yWUXjmue0iRSwdZFxK 0pO9BN7+MDe82TuFLERRSaQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3Oc6TCIn/ kWElNToAXpoqrL9dJ6G3rKdrDf3My5FK2YHPXMAVVFdv4Klp5wvhBXSSNolCLSyktD+BTD3x XaNsTQ6gLIQy8UM0s1X4Gz6vt5lnbCRJiZd2+kddjvNAt9RDGJ9W7GV1A==
  • Ironport-hdrordr: A9a23:wdyOd6tEswTGIkBuFCkg82GM7skCXoAji2hC6mlwRA09TyXGra 2TdaUgvyMc1gx7ZJh5o6H6BEGBKUmslqKceeEqTPqftXrdyRGVxeZZnMffKlzbamfDH4tmuZ uIHJIOb+EYYWIasS++2njBLz9C+qjJzEnLv5a5854Fd2gDBM9dBkVCe3+m+yZNNWt77O8CZf 6hD7181l+dkBosDviTNz0gZazuttfLnJXpbVovAAMm0hCHiXeF+aP3CB+R2zYZSndqza05+W bIvgTl7uH72svLiyP05iv21dB7idHhwtxMCIiljdUUECzljkKFdZlsQLqLuREyuaWK5EwxmN fBjh88N4BY6m/XfEuyvRzxsjOQngoG2jvH8xu1kHHjqcv2SHYREMxan79UdRPf9g4JoMx8+L gj5RPbi7NnSTf72Ajt7dnBUB9n0mCup2A5rOIVh3tDFaMDdb5qq5AF9k89KuZDIMu60vFjLA BdNrCa2B9kSyLdU5kfhBg3/DWYZAV2Iv5BeDlbhiXa6UkMoJkz9Tpk+CVWpAZ9yHt6cegF2w 2MCNUXqFkFJPVmEp5VFaMPR9C6BXfKRg+JOGWOIU7/HKVCIH7VrYXriY9Frd1CVaZ4u6faoq 6xJm9wpCo3YQbjGMeO1JpE/lTER3i8Ry3kzoVb64JisrPxSbL3OWnbIWpe2PeIsrEaGInWSv yzMJVZD7vqKnbvA59A20n7V4NJIXcTXcUJspIwWk6IoMjMNor239arOMr7Nf7oC3IpS2n/Cn wMUHz6I9hB9FmiXjvijB3YSxrWCzjCFFJLYd3nFsQoufsw39d3w3koYHyCl7G2ACwHtLAqd0 1jJ76imr+npACNjBT101k=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZBNyGN5BP0zs1Y0yrWzYQCqLnUq5Y7uIAgAAoLIA=
  • Thread-topic: [PATCH v2 5/6] tools/oxenstored: Rework Domain evtchn handling to use port_pair

On 01/12/2022 11:59, Christian Lindig wrote:
>> On 30 Nov 2022, at 16:54, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx> wrote:
>>
>> Inter-domain event channels are always a pair of local and remote ports.
>> Right now the handling is asymmetric, caused by the fact that the evtchn is
>> bound after the associated Domain object is constructed.
>>
>> First, move binding of the event channel into the Domain.make() constructor.
>> This means the local port no longer needs to be an option.  It also removes
>> the final callers of Domain.bind_interdomain.
>>
>> Next, introduce a new port_pair type to encapsulate the fact that these two
>> should be updated together, and replace the previous port and remote_port
>> fields.  This refactoring also changes the Domain.get_port interface 
>> (removing
>> an option) so take the opportunity to name it get_local_port instead.
>>
>> Also, this fixes a use-after-free risk with Domain.close.  Once the evtchn 
>> has
>> been unbound, the same local port number can be reused for a different
>> purpose, so explicitly invalidate the ports to prevent their accidental 
>> misuse
>> in the future.
>>
>> This also cleans up some of the debugging, to always print a port pair.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>> ---
>> CC: Christian Lindig <christian.lindig@xxxxxxxxxx>
>> CC: David Scott <dave@xxxxxxxxxx>
>> CC: Edwin Torok <edvin.torok@xxxxxxxxxx>
>> CC: Rob Hoes <Rob.Hoes@xxxxxxxxxx>
> Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx>

Thanks.

>
>> v2:
>> * New
>> ---
>> tools/ocaml/xenstored/connections.ml |  9 +----
>> tools/ocaml/xenstored/domain.ml      | 75 
>> ++++++++++++++++++------------------
>> tools/ocaml/xenstored/domains.ml     |  2 -
>> 3 files changed, 39 insertions(+), 47 deletions(-)
>>
>> diff --git a/tools/ocaml/xenstored/connections.ml 
>> b/tools/ocaml/xenstored/connections.ml
>> index 7d68c583b43a..a80ae0bed2ce 100644
>> --- a/tools/ocaml/xenstored/connections.ml
>> +++ b/tools/ocaml/xenstored/connections.ml
>> @@ -48,9 +48,7 @@ let add_domain cons dom =
>>      let xbcon = Xenbus.Xb.open_mmap ~capacity (Domain.get_interface dom) 
>> (fun () -> Domain.notify dom) in
>>      let con = Connection.create xbcon (Some dom) in
>>      Hashtbl.add cons.domains (Domain.get_id dom) con;
>> -    match Domain.get_port dom with
>> -    | Some p -> Hashtbl.add cons.ports p con;
>> -    | None -> ()
>> +    Hashtbl.add cons.ports (Domain.get_local_port dom) con
> I would prefer Hashtbl.replace. Hashtbl.add shadows an existing binding which 
> becomes visible again after Hashtabl.remove. When we are sure that we only 
> have one binding per key, we should use replace instead of add.

That's surprising behaviour.  Presumably the add->replace suggestion
applies the other hashtable here (cons.domains)?  And possibly elsewhere
too.

~Andrew

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.