[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: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
- From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- Date: Mon, 7 Feb 2022 14:35:02 +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=GRojDeEmDv4UlyC6iOri4DoNWhCV9lp6lLLGdRBtIvo=; b=bBNMWmiSrKIDUSMSBCZK2Zy25kvXijROeuNIHReR05/cYuwzyRWlP1I/fXEfvESpHsqESmOz12H1v2HrNTO8rkEiiBouohfBvwBFWxm47Ay/JWpCm3MXaqn3BtTynVvKoTnbRGEHHCXiARK8qviBqYF6zdN8gNWGz2YxAqyzIfPSFvMk8fK0e2ncqfwRC159K1Md6DazIAePZXEAlbgWw5u3l9mtLMZpAfVs50WPTuPbS3+ALtMP77E8zJy08bwAJ7E1jRVSVeZByM3UFyP4kbH4h9pyf+nAKz6Cj3CIkUYs31/Yjo7Rlw23vtTalbM/xzv3iTmsvIo8jpBUWipG9A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A1SN0MQZIZr0om6V/g9lCvzQ0iXCW0uNtgmNHj7JAoasq+XzuYWYMSx0pqIBYMfc8x0A5tOmATxf+lkFAOZTjydWpycCYR4oipDIV9ZjeeWOEmabN8cGCdM71kg4ODdE4jg4sxwgoLI2gar+X6TK7d83Zp4s//72VwOz1NJq4kKaCPIJquJech0EphCFdvD9bvXilMblGDAve1byuluQ0oOaUFAzi+kok26iPGAMxcAFOGpXsmvj8FCI3dta3ti65ONoOu0bfDEkxeS1SbQ6b+f21kbDi6yGbug/R269eIh+QHfNv9N+qARakJoPQJZaEj7hmVjWx1q6Xw6plNaBWQ==
- 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>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- Delivery-date: Mon, 07 Feb 2022 14:35:12 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYGZFc/MnzQOjwVEeBBUHLSW0md6yDBUkAgAASSACAAATYAIAAD/WAgAAKNgCAAAbfgIAABnuAgAAQvgCAAAMCAIAAAY4AgAADxICAABrnAIAABAgAgAR3CoCAABt5gIAAEpuAgAAE5ICAAASKAIAAAiiA
- Thread-topic: [PATCH v6 03/13] vpci: move lock outside of struct vpci
On 07.02.22 16:27, Roger Pau Monné wrote:
> On Mon, Feb 07, 2022 at 03:11:03PM +0100, Jan Beulich wrote:
>> On 07.02.2022 14:53, Oleksandr Andrushchenko wrote:
>>> On 07.02.22 14:46, Roger Pau Monné wrote:
>>>> I think the per-domain rwlock seems like a good option. I would do
>>>> that as a pre-patch.
>>> It is. But it seems it won't solve the thing we started this adventure for:
>>>
>>> With per-domain read lock and still ABBA in modify_bars (hope the below
>>> is correctly seen with a monospace font):
>>>
>>> cpu0: vpci_write-> d->RLock -> pdev1->lock ->
>>> rom_write -> modify_bars: tmp (pdev2) ->lock
>>> cpu1: vpci_write-> d->RLock pdev2->lock -> cmd_write -> modify_bars:
>>> tmp (pdev1) ->lock
>>>
>>> There is no API to upgrade read lock to write lock in modify_bars which
>>> could help,
>>> so in both cases vpci_write should take write lock.
>> Hmm, yes, I think you're right: It's not modify_bars() itself which needs
>> to acquire the write lock, but its (perhaps indirect) caller. Effectively
>> vpci_write() would need to take the write lock if the range written
>> overlaps the BARs or the command register.
> I'm confused. If we use a per-domain rwlock approach there would be no
> need to lock tmp again in modify_bars, because we should hold the
> rwlock in write mode, so there's no ABBA?
this is only possible with what you wrote below:
>
> We will have however to drop the per domain read and vpci locks and
> pick the per-domain lock in write mode.
I think this is going to be unreliable. We need a reliable way to
upgrade read lock to write lock.
Then, we can drop pdev->vpci_lock at all, because we are always
protected with d->rwlock and those who want to free pdev->vpci
will use write lock.
So, per-domain rwlock with write upgrade implemented minus pdev->vpci
should do the trick
> Thanks, Roger.
Thank you,
Oleksandr
|