[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: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 7 Feb 2022 17:08:17 +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=Rx4MvDk5QIewHCsNtq9PZOT1rF/nb3JP8sHO7rhVH+k=; b=Yb8sAjhe5Ogv6FlZWKyhVLlSubzLJ+PXOqK6u6jbw8xKFMA8u8fLlNVGtsPKYiBuailgMFnIGXbqx1qdW2F2jDKddcXnuJRUNZ7NLl3TrWrlh02pGUW75SInFLV+7ZsIK1C3rdynOhIhUo1ZsHX0HxTRE1bJdeljtk/0ORg8hTPhAfWmUyG+W0e+/LosfHkXuPEhTitAQJrY0FZkYfXBsHAkaMzFtaYwf1v2/zwkOAWUkivC9L8OiWC/FNXa+T1vVJdt4pOnAgANiDwMULZeLLrP7bg/UZRDplaIygC6NXh4GnpQ7/5bF6TvyDq7FtF/QH5bg7+c3Pyck6JZh4D0Mg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VNaeeHvGsilSC0Kuc322HwmQa8JiSj47XKtR0NeuVuyiLRRZ41QLaQHYq1f1KX/9gRyNqXYSSpVKwwvY9gm/U1RjIer+YbvGuiQ/S4xJwIxLY9TwbQeHpCNOQtKLlh6AecdgJfS+cRoQUqMAjpPK3ffQCb0H0R1S6wNJnWQtNpCH+p9lKV7ltNfMVdgMQ+E2w6/5CcMLdHpJDVI5JAjpx5dwJfu7FiIWVDCZ7SRgj8eUBKgSYB9Rh6J8z8dzy5IKUPJckeSYfI086JzJvM0gB0t5x/ouG6Rhbb+DvDlaYmr1tdExfGU1dk9jSvxqtwVGwLGspaxCKxlHnGbpLTT5GQ==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, "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>
  • Delivery-date: Mon, 07 Feb 2022 16:08:38 +0000
  • Ironport-data: A9a23:QMdf4K0W/4TKb/AdAfbD5fN3kn2cJEfYwER7XKvMYLTBsI5bpzRVm mIdXTjUM/eCYGT1eoojaNi1pkMGuZDWnNQ1TABkpC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCanAZqTNMEn9700o5w7Fh2OaEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhr8FK2 MpPvsKLcAIpF6zgicZDCwlbKnQrVUFG0OevzXmXtMWSywvNcm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b1q0bg/953koLoDllZoG3DCblKKDLJ8IybZgZkT5/MVnrIJ6xGrX k+v+8VBPenbMs3SD1NMdhEuaf6O1K9Il2CKv+g1Okjz+AR+4KGDDRdJJxCJhSEEdOl1PYopz P0PoskT7wDj2BMmPszf1nJf9niWL2xGWKIi78lIDIjugwst61dDfZ2DVXOmvMDRM41BaxB4L CWViazOg6Vn6nDDK3djR2LQ2ed9hIgVvEwYxlE1OFnUyMHOgeU63UMN/G1vHBhV1BhOz8l6J nNvax9uPayL8jpl2JpDUmSrF10TDRGV4BWsmV4AlWmfREi0TG3damY6PL/Vrkwe9mtdeBld/ a2Zlzm5AWq7Ipmp03tgQ1NhptziUcd1p1/Ll82QFsiYG4U3PGj+iai0aGtU8xbqDKvdXqEcS TWGKAqoVZDGCA==
  • Ironport-hdrordr: A9a23:oduGBaF6Bl75yxXNpLqE7MeALOsnbusQ8zAXPidKOHtom62j5q STdZEgviMc5wx8ZJhNo7+90cq7IU80l6Qa3WB5B97LNmTbUQCTTb1K3M/PxCDhBj271sM179 YET0GmMqySMbGtt7eZ3DWF
  • Ironport-sdr: RQgt49YBbZYuTld1IJPQk8VkKRR/Fym01dt7Vv/0n8/pSDICe+cJ106jOHOp2WCB0l5rZCYvDO 48nja1N0cdzRBKZEqvAMnG+keppcvEvf1f5vUahgUfxWpEjlP4Cc3+YNPsxPbzer0Y3HeBVnfz QqbIWLaV9YYkXTwdJCdqLnyKjZzKQIfOeBYxysLDOgp47n0GoaMa00x9dXSz13V4YTcXjKDEe9 0tewcZjwVcEgnCq2Y0lhd3mhNB5uTHBJ68A0gCO7pDPRrXgapDuJ6O+YVF5I3uSTtT5biSgDYj hqpgyalFajlM6B8bOwoJM+m3
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Feb 07, 2022 at 04:26:56PM +0100, Jan Beulich wrote:
> On 07.02.2022 16:11, Oleksandr Andrushchenko wrote:
> > 
> > 
> > On 07.02.22 16:35, Oleksandr Andrushchenko wrote:
> >>
> >> 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
> > Linux doesn't implement write upgrade and it seems for a reason [1]:
> > "Also, you cannot “upgrade” a read-lock to a write-lock, so if you at _any_ 
> > time
> > need to do any changes (even if you don’t do it every time), you have to get
> > the write-lock at the very beginning."
> > 
> > So, I am not sure we can have the same for Xen...
> > 
> > At the moment I see at least two possible ways to solve the issue:
> > 1. Make vpci_write use write lock, thus make all write accesses synchronized
> > for the given domain, read are fully parallel
> 
> 1b. Make vpci_write use write lock for writes to command register and BARs
> only; keep using the read lock for all other writes.

We do not support writing to the BARs with memory decoding enabled
currently for dom0, so we would only need to pick the lock in write
mode for the command register and ROM BAR write handler AFAICT.

Thanks, Roger.



 


Rackspace

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