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

Re: [PATCH v8 02/13] vpci: use per-domain PCI lock to protect vpci structure


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Mon, 24 Jul 2023 00:07:48 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; 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=wD7/Jabcn1UV7MQK1uTOOIY4SnZey2eDV/1k0Ya8ttE=; b=Ki3tb9DkIS88lWAgbMyFGZHdyBMU+ZE4gfg/tFT63eMIOJ1QkXfeFdBbh2HwO97HOJG2Ugd3uN9S5sXqVmN2osaj8ERlvt9e7IawGoPsfgG4aLa390DCBD8x8SIhbGNWrTzfXnzFg22ZmLlbOt2iYMm71pXfGlucZxGovXMlHz77STSssDjuawgL0ppQ8i/l44+56V2S2FpsCzg/Tofu/iOuRsaHYc76hCKOxqgLjv4H2gDQ3I/4CoYJNUfcNAe8PMpj5452TRTbV0ex1xAAw2f8dFe+ZqjCzNGSw5qahdJONMyIFFlo/k0PgRP31e9Cbsg7zQXmcyRMbhIofbVWYg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bvNSJdgdbARLywpXSnLaNmjgocDyZsfyKm6zscmEBg5Vj8YzLDF0VNHbvKNjN5OHze6N0kFoA55lpvJzRhKmt2QCzXD3VUxznhUW4qA4IrQWE+wCJL07qmRsTQkMF67tgZzNIO3fEwEH46bhQkhEefD6Zch7B3vYjNHCV1X9GB70r7xcTtHFIhNtU3QEoJSSYiXFIq+8MvQ+XNOxwa56XdQsh0atiQT7IdiM2v0Mph8WFIgcgd5mEE6nhZoNLiEM2MrhpJGuvBMfWgkTXrj+5fzUBtLMkzX4ViEK2T7bNg07jhv+WP2KWYC9emXV05E9R0aHiAo1sqaT5Db3apotng==
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Mon, 24 Jul 2023 00:08:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZuqGrLMJPz1ipBEu4urExXp8yi6/CgxUAgAAjhICAAAaPAIAFYwcA
  • Thread-topic: [PATCH v8 02/13] vpci: use per-domain PCI lock to protect vpci structure

Hi Roger,

Roger Pau Monné <roger.pau@xxxxxxxxxx> writes:

> On Thu, Jul 20, 2023 at 03:27:29PM +0200, Jan Beulich wrote:
>> On 20.07.2023 13:20, Roger Pau Monné wrote:
>> > On Thu, Jul 20, 2023 at 12:32:31AM +0000, Volodymyr Babchuk wrote:
>> >> @@ -447,8 +476,16 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, 
>> >> unsigned int size,
>> >>  
>> >>      /*
>> >>       * Find the PCI dev matching the address, which for hwdom also 
>> >> requires
>> >> -     * consulting DomXEN.  Passthrough everything that's not trapped.
>> >> +     * consulting DomXEN. Passthrough everything that's not trapped.
>> >> +     * If this is hwdom, we need to hold locks for both domain in case if
>> >> +     * modify_bars is called()
>> > 
>> > Typo: the () wants to be at the end of modify_bars().
>> > 
>> >>       */
>> >> +    read_lock(&d->pci_lock);
>> >> +
>> >> +    /* dom_xen->pci_lock always should be taken second to prevent 
>> >> deadlock */
>> >> +    if ( is_hardware_domain(d) )
>> >> +        read_lock(&dom_xen->pci_lock);
>> > 
>> > For modify_bars() we also want the locks to be in write mode (at least
>> > the hw one), so that the position of the BARs can't be changed while
>> > modify_bars() is iterating over them.
>> 
>> Isn't changing of the BARs happening under the vpci lock?
>
> It is.
>
>> Or else I guess
>> I haven't understood the description correctly: My reading so far was
>> that it is only the presence (allocation status / pointer validity) that
>> is protected by this new lock.
>
> Hm, I see, yes.  I guess it was a previous patch version that also
> took care of the modify_bars() issue by taking the lock in exclusive
> mode here.
>
> We can always do that later, so forget about that comment (for now).

Are you sure? I'd rather rework the code to use write lock in the
modify_bars(). This is why we began all this journey in the first place.

-- 
WBR, Volodymyr

 


Rackspace

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