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

Re: [PATCH v6 03/13] vpci: move lock outside of struct vpci


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Tue, 8 Feb 2022 09:03:17 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=O23HV0Tc8xdEJ3ADIkfZrEzuetkkxLNqodA8J1DyP5k=; b=TwhK3b9exLnubiJGxZlx1cNgI0nI6lUsNC3rmNpzLmVQcY532qo2c3wPr0XbedJ84IP9VgXk3p9BtP553mhDZHL6Isj1xl7mdZhGi9FbFH0onQaMolo8AsorgSChzYOUpTDJeZ0HN0ljrDrjjIVrn+aNB+PGQzML4OWlOLZrqnUADx3C/0NV6co4ypqlvmCA5cGOAZqT6OBrmuqOlBDYsS9HnbMg1X5K6pUMcztDO9KMPd9od/VuOLGfTi5ojbMCFE18skCmKxTN6Z/ETIGBUR/c5NpwD4ClaOqAz+Wn3O45dVaTV9BdHdDEmXkNSrVBS5vQcayPFFv96M8AJDPP6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YhsKF3nvBlI2whbVx0B45eXpgqMvORdT+vVDUs/Gu23PFEuAOz4s0QxF9BERuL+5uHysxMflJhBKcY74f/cchiLCnLS5a9/IW9z5ju/4yW73l+xu0yg4BzUq9oEpJnPHZTmwRGTt0cAn5aXVc2yelmsVz+KlNrEf7EkRAZmEctPtW8gGL7/5svd4oqaVSlF18PK2xMirCLwvdrtWEsb3aikqS5ZXQj7LccFF7X3YozzmWV16hozP7y+k38SvAKFZXR2Dk+L66OEfKRCnfCdsjxdUEmeDIm4mhwmMsH51uSCS1+BRuYabgueSnFmyYogrX9qcDw1KePnvzZC8ZOhM6g==
  • Cc: "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Tue, 08 Feb 2022 09:03:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYGZFc/MnzQOjwVEeBBUHLSW0md6yDBUkAgAASSACAAATYAIAAD/WAgAAKNgCAAAbfgIAABnuAgAAQvgCAAAMCAIAAAY4AgAADxICAABrnAIAABAgAgAR3CoCAABt5gIAAEpuAgAAE5ICAAASKAIAAAiiAgAAKNYCAAARNAIAAC1wAgAACRYCAAAGVgIAABJiAgAAB5wCAAPjsgIAAFvmAgAABioA=
  • Thread-topic: [PATCH v6 03/13] vpci: move lock outside of struct vpci


On 08.02.22 10:57, Jan Beulich wrote:
> On 08.02.2022 08:35, Oleksandr Andrushchenko wrote:
>> 1.1. Semi read lock upgrade in modify bars
>> --------------------------------------------------------------
>> In this case both vpci_read and vpci_write take a read lock and when it comes
>> to modify_bars:
>>
>> 1. read_unlock(d->vpci_lock)
>> 2. write_lock(d->vpci_lock)
>> 3. Check that pdev->vpci is still available and is the same object:
>> if (pdev->vpci && (pdev->vpci == old_vpci) )
>> {
>>       /* vpci structure is valid and can be used. */
>> }
>> else
>> {
>>       /* vpci has gone, return an error. */
>> }
>>
>> Pros:
>> - no per-device vpci lock is needed?
>> - solves overlap code ABBA in modify_bars
>> - readers and writers are NOT serialized
>> - NO need to carefully select read paths, so they are guaranteed not to lead
>>     to lock upgrade use-cases
>>
>> Cons:
>> - ???
> The "pdev->vpci == old_vpci" is fragile: The struct may have got re-
> allocated, and it just so happened that the two pointers are identical.
>
> Same then for the subsequent variant 2.
Yes, it is possible. We can add an ID number to pdev->vpci,
so each new allocated vpci structure has a unique ID which can be used
to compare vpci structures. It can be something like pdev->vpci->id = 
d->vpci_id++;
with id being uint32_t for example
>
> Jan
>
>

 


Rackspace

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