[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] vpci: introduce per-domain lock to protect vpci structure
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- Date: Tue, 15 Feb 2022 12:44:35 +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=e/8wOfS7JIg+pQSfbhLxI/OXivap1yWICDnRSbbQeU0=; b=SIEDZ5uvWLBNyG3jDvYOP59ECCZdTVdF30LrLZif9O53I+WzNU0SseHLXB1zF9OW6ECMX6Za0JacU8WALHjGlFKwcaFfxvdkTmKqUkuj2YMbQMEqk5snkiiUe2ISGnILNb+4xIyktWaIms1MIGsRcLPsU551gOzJyegq6G8bxthcOMT8ZYNQaPPtYBdtEjtLBG2CU4X+YjtXSEot+78EE2crsCt+KnmIEp8sM/Wh2bZg+h7Ms4vbLHm4zfQ/TmSAhyVfWApBQB7XwceUa1w+4mf5SZzmsrPqk79ltiQ4xG1pTUKREL5jSTzDpNXMbiwHMDMhNB55V1H0lrtay1QEXw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aY5GIhPUlEuQJfbGZsALbBEw4zp/rTd2GUQQ92MgaJX848N05jV0EYsxSbJp8D/IjlPkh9pGM+V7AZVnjBPJG97GlpuWVmyRTzD0AKnohD8SMYpQ9/Ozyih59L/tj8JPKon6MEjGV6ywR3QohuvAT+V8tSSvgAi+/WztVxC9qXpYwmJnQ4IbJ8I+MdHhXUPziKzt9rodTf26I+3mID6Zk9XS6E1CcGeCnSerDc+VnKBPxIRiyodV0krAkMkyAi6aOz3TIspIAVQa7PpklnvX1LwCuQb3WnIo0mOplf7hYotmkoioqGt7NfRY7L4Mj3GSwNZJc/3WoFSMLf2dqenKGQ==
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Tue, 15 Feb 2022 12:45:05 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYIkOs9pmsZb0l5kefj1m3qdTVCayUboeAgAAGwYCAAAeVgIAAAZQAgAABlwCAAAEVAIAADewA
- Thread-topic: [PATCH v2] vpci: introduce per-domain lock to protect vpci structure
On 15.02.22 13:54, Oleksandr Andrushchenko wrote:
>
> On 15.02.22 13:50, Jan Beulich wrote:
>> On 15.02.2022 12:45, Oleksandr Andrushchenko wrote:
>>> I'm on your side, I just want to hear that we all agree pcidevs
>>> needs to be converted into rwlock according with the plan you
>>> suggested and at least now it seems to be an acceptable solution.
>> I'd like to express worries though about the conversion of this
>> recursive lock into an r/w one.
> Could you please elaborate more on this?
What if we just do the following:
static spinlock_t _pcidevs_lock = SPIN_LOCK_UNLOCKED;
static rwlock_t DEFINE_RWLOCK(_pcidevs_rwlock);
void pcidevs_lock(void)
{
read_lock(&_pcidevs_rwlock);
spin_lock_recursive(&_pcidevs_lock);
}
void pcidevs_unlock(void)
{
spin_unlock_recursive(&_pcidevs_lock);
read_unlock(&_pcidevs_rwlock);
}
void pcidevs_read_lock(void)
{
read_lock(&_pcidevs_rwlock);
}
void pcidevs_read_unlock(void)
{
read_unlock(&_pcidevs_rwlock);
}
void pcidevs_write_lock(void)
{
write_lock(&_pcidevs_rwlock);
}
void pcidevs_write_unlock(void)
{
write_unlock(&_pcidevs_rwlock);
}
1. This way most of the code continues to use pcidevs_{lock|unlock}.
2. We need to change writers, those which can add /remove pdev, to use
pcidevs_write_{un}lock
3. Those, which do not modify pdevs (vpci_{read|write}), will use
pcidevs_read_lock
4. We do not introduce d->vpci_rwlock and use pcidevs_{read|write}_lock
as vpci doesn't seem to need to acquire _pcidevs_lock + we use pdev->vpci->lock
as it is now
Is this something which may address your worries?
Thank you,
Oleksandr
|