All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
Cc: "julien@xen.org" <julien@xen.org>,
	"sstabellini@kernel.org" <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <Oleksandr_Tyshchenko@epam.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Artem Mygaiev <Artem_Mygaiev@epam.com>,
	"roger.pau@citrix.com" <roger.pau@citrix.com>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Rahul Singh <rahul.singh@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 11/11] xen/arm: Translate virtual PCI bus topology for guests
Date: Mon, 27 Sep 2021 16:16:16 +0200	[thread overview]
Message-ID: <67bf6cff-5e1f-0770-f212-b6bc0d82838e@suse.com> (raw)
In-Reply-To: <e0ee94e4-4076-ac51-f5a8-d895220d1522@epam.com>

On 27.09.2021 16:04, Oleksandr Andrushchenko wrote:
> 
> On 27.09.21 16:51, Jan Beulich wrote:
>> On 27.09.2021 15:43, Oleksandr Andrushchenko wrote:
>>> On 27.09.21 16:34, Jan Beulich wrote:
>>>> On 27.09.2021 14:08, Oleksandr Andrushchenko wrote:
>>>>> On 27.09.21 14:31, Jan Beulich wrote:
>>>>>> On 23.09.2021 14:55, Oleksandr Andrushchenko wrote:
>>>>>>> --- a/xen/drivers/passthrough/pci.c
>>>>>>> +++ b/xen/drivers/passthrough/pci.c
>>>>>>> @@ -890,6 +890,31 @@ int pci_remove_virtual_device(struct domain *d, const struct pci_dev *pdev)
>>>>>>>         return 0;
>>>>>>>     }
>>>>>>>     
>>>>>>> +/*
>>>>>>> + * Find the physical device which is mapped to the virtual device
>>>>>>> + * and translate virtual SBDF to the physical one.
>>>>>>> + */
>>>>>>> +bool pci_translate_virtual_device(struct vcpu *v, pci_sbdf_t *sbdf)
>>>>>> Why struct vcpu, when you only need ...
>>>>>>
>>>>>>> +{
>>>>>>> +    struct domain *d = v->domain;
>>>>>> ... this? It's also not really logical for this function to take a
>>>>>> struct vcpu, as the translation should be uniform within a domain.
>>>>> Agree, struct domain is just enough
>>>>>> Also - const please (as said elsewhere before, ideally wherever possible
>>>>>> and sensible).
>>>>> Ok
>>>>>>> +    struct vpci_dev *vdev;
>>>>>>> +    bool found = false;
>>>>>>> +
>>>>>>> +    pcidevs_lock();
>>>>>>> +    list_for_each_entry ( vdev, &d->vdev_list, list )
>>>>>>> +    {
>>>>>>> +        if ( vdev->sbdf.sbdf == sbdf->sbdf )
>>>>>>> +        {
>>>>>>> +            /* Replace virtual SBDF with the physical one. */
>>>>>>> +            *sbdf = vdev->pdev->sbdf;
>>>>>>> +            found = true;
>>>>>>> +            break;
>>>>>>> +        }
>>>>>>> +    }
>>>>>> For a DomU with just one or at most a couple of devices, such a brute
>>>>>> force lookup may be fine. What about Dom0 though? The physical topology
>>>>>> gets split at the segment level, so maybe this would by a reasonable
>>>>>> granularity here as well?
>>>>> Not sure I am following why topology matters here. We are just trying to
>>>>> match one SBDF (as seen by the guest) to other SBDF (physical,
>>>>> as seen by Dom0), so we can proxy DomU's configuration space access
>>>>> to the proper device in Dom0.
>>>> Topology here matters only in so far as I've suggested to have separate
>>>> lists per segment, to reduce look times. Other methods of avoiding a
>>>> fully linear search are of course possible as well.
>>> Ah, with that that respect then of course. But let's be realistic.
>>> How many PCI devices are normally passed through to a guest?
>>> I can assume this is probably less than 10 most of the time.
>>> By assuming that the number of devices is small I see no profit,
>>> but unneeded complexity in accounting virtual devices per segment
>>> and performing the relevant lookup. So, I would go with a single list
>>> and "brute force lookup" unless it is clearly seen that this needs to be
>>> optimized.
>>
>> Just to repeat my initial reply: "For a DomU with just one or at most
>> a couple of devices, such a brute force lookup may be fine. What about
>> Dom0 though?" If the code uses the simpler form because it's only
>> going to be used for DomU, then that's fine for now. But such latent
>> issues will want recording - e.g. by TODO comments or at the very
>> least suitable pointing out in the description.
> 
> As we do not emulate virtual bus topology for Dom0 then it is
> 
> clearly seen that the code may only have impact on DomUs.
> 
> But anyways, virtual bus topology for DomUs is emulated with
> 
> a single segment 0. We have a single list of virtual SBDFs,
> 
> again, for virtual segment 0, which maps those virtual SBDFs
> 
> to physical SBDFs. So, we go over the list of virtual devices
> 
> assigned to that guest and match the virtual SBDF in question to
> 
> its counterpart in Dom0. I can't see how this can be optimized or
> 
> needs that optimization because of the fact that Dom0 may have
> 
> multiple segments...
> 
> So, how would that comment look like?

Well - if the plan is that this code would never be used for Dom0,
then all is fine as is, I guess. But as you can see the Dom0 plans
on Arm wrt vPCI weren't clear to me at all.

Jan



  reply	other threads:[~2021-09-27 14:17 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 12:54 [PATCH v2 00/11] PCI devices passthrough on Arm, part 3 Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 01/11] vpci: Make vpci registers removal a dedicated function Oleksandr Andrushchenko
2021-09-28 11:15   ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 02/11] vpci: Add hooks for PCI device assign/de-assign Oleksandr Andrushchenko
2021-09-29  9:35   ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 03/11] vpci/header: Move register assignments from init_bars Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 04/11] vpci/header: Add and remove register handlers dynamically Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 05/11] vpci/header: Implement guest BAR register handlers Oleksandr Andrushchenko
2021-09-29  9:27   ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 06/11] vpci/header: Handle p2m range sets per BAR Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 07/11] vpci/header: program p2m with guest BAR view Oleksandr Andrushchenko
2021-09-29  8:13   ` Michal Orzel
2021-09-29  8:16     ` Jan Beulich
2021-09-29  8:24       ` Oleksandr Andrushchenko
2021-09-29  8:36         ` Jan Beulich
2021-09-29  8:58           ` Oleksandr Andrushchenko
2021-09-29  8:16     ` Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 08/11] vpci/header: Emulate PCI_COMMAND register for guests Oleksandr Andrushchenko
2021-09-28  7:34   ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 09/11] vpci/header: Reset the command register when adding devices Oleksandr Andrushchenko
2021-09-28  7:38   ` Michal Orzel
2021-09-23 12:55 ` [PATCH v2 10/11] vpci: Add initial support for virtual PCI bus topology Oleksandr Andrushchenko
2021-09-28  7:48   ` Michal Orzel
2021-09-28  7:59     ` Jan Beulich
2021-09-28  8:17       ` Michal Orzel
2021-09-28 12:58         ` Oleksandr Andrushchenko
2021-09-29  9:03           ` Oleksandr Andrushchenko
2021-09-29  9:09             ` Jan Beulich
2021-09-29 11:56               ` Oleksandr Andrushchenko
2021-09-29 12:54                 ` Jan Beulich
2021-09-29 13:16                   ` Oleksandr Andrushchenko
2021-09-29 13:23                     ` Jan Beulich
2021-09-29 13:49                       ` Oleksandr Andrushchenko
2021-09-29 14:07                         ` Jan Beulich
2021-09-29 14:16                           ` Oleksandr Andrushchenko
2021-09-23 12:55 ` [PATCH v2 11/11] xen/arm: Translate virtual PCI bus topology for guests Oleksandr Andrushchenko
2021-09-27 11:31   ` Jan Beulich
2021-09-27 12:08     ` Oleksandr Andrushchenko
2021-09-27 13:34       ` Jan Beulich
2021-09-27 13:43         ` Oleksandr Andrushchenko
2021-09-27 13:51           ` Jan Beulich
2021-09-27 14:04             ` Oleksandr Andrushchenko
2021-09-27 14:16               ` Jan Beulich [this message]
2021-09-27 14:20                 ` Oleksandr Andrushchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67bf6cff-5e1f-0770-f212-b6bc0d82838e@suse.com \
    --to=jbeulich@suse.com \
    --cc=Artem_Mygaiev@epam.com \
    --cc=Oleksandr_Andrushchenko@epam.com \
    --cc=Oleksandr_Tyshchenko@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=rahul.singh@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.