[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: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 15 Feb 2022 13:56:55 +0100
  • 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=Xdf5Z8VRt6KiPSDfUeY7PKAWUyi1LeDNdm/nayjz20o=; b=JQ6vWq9HAudmQelJ3rDaKvD0uLs6DDv2f3s78e3aFXaEnrUAMIpE6xjlfu5BvbJdrL3k8ED33EHQkXE/wgg0pLzx1aLC4k6wtzeAzbZQoImfo2Pq7mrFD1OOmHEXKjkCADEIKES41MzhlabgIHYGsrMF+9GyX83zkumkNxE4dQO8nBBkI3Rs6xI0jEbj5O31YSuzqbUaB1nJHCaN2e5iJJrp5CDSywnWAyVCwBTm+krdV2c1c5kL5FOMknE4xuw0ZDpySP/5/6ECAJ/1QolwVTZH7EKOoxrURusp8tddVbBVGfO9VOnQhvNm6UNtthvENFeGC2T4ccvYsu5n4Otzuw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WE4sA1ZBoT2AmRbF4gvI9XOM/Yb+/JslQ0A2/H6SIxDdAurLXfOi+YIU2Ysfnmqjd5GrR7StzD1oYkWYhZScaX3DJtmkPef7zmc2k0/zV8uq/UV8VqIs42aSFnRrK0fnv6SiJDz2RSA+5wbVLGEUGdJQaIpaDRg1Cb6MpdjRUyNtCnIHCHYmBeJlSgdrDlzIcDWmb24XYXeDO/L62tHShnqLYyQbW1E511ypPJFoI6xg4wuaKJqyNfWGXuD22jKZkkhROCL8mRr3t75Xi9fdHQ+k8GY6ZXpGgYC971XEKVOBuCio7payTLH/v8sN3Be1dlwSx+eN5YFG+Tj/4iHq+Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • 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>, Rahul Singh <rahul.singh@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 15 Feb 2022 12:57:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15.02.2022 13:44, Oleksandr Andrushchenko wrote:
> 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);
> }

Hmm, this is an interesting idea. Except that I'm not sure in how
far it'll be suitable: read_lock() won't lock out users of just
lock(), so the solution looks tailored to your vPCI use case. Yet
obviously (I think) read_lock() would want to become usable for
e.g. simple list traversal as well, down the road.

Jan




 


Rackspace

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