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

Re: [PATCH v3] x86/msi: fix locking for SR-IOV devices


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Fri, 23 Aug 2024 14:02:30 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=101NKS/q49Y8PycYuNb81Md7WzKTjF3oRWtqwfWxQkQ=; b=vruaWaljg21/w5L/0+TNcGXHUQa6+oPjqgd9LsA/CEQYD5P7VwAHvHBkLFhDnFfTdngTXjXD8VCQGV9Yjxvq0k2IfZalitD+QrtHgEDRVgy8OvW4loTmIuEheh9vgTnK8fEFOCDZsGmyWGrzeBJXW1Ud1CC0eJeO2LPmz8RIzug8G2aVhLDiCV2BoXoWL5V3Xh+vej3phQfcvnzz+7eUk+3uSBn6QXzaknvdJjgFeA+8HmM1TY8x9TzVvrDQ9q3QCV9SF3PFTXsKewXD8Qtnv6bbjQ8ZuHeXviFaSA8+m/O89hPIlIHOJXVMzSfcKmSwFd9DFF1bTvgnyj+tbTHomw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GK8rCIA2VuON1aBW4iZhomC0nD6WFRYxBGmH294rNbm+SPTJX5keYkBvzXR4Ch/TroA9qpmgihTDhmm2HciEsDZ6Qb8qqkj/dw2EHMlmdEJd/D+jwjJG/Emkm20pDBK3HivRnwWMtJHz5T0khlMItctZs1idslZCau3LMg5f5n7vIhvfLPqsMMqPF0vJsAoxJOVXWUcEBSycdBFohUfQVvK1DdJ6HZ4hNPkCb4Q0GR/buxFtx4DZQJrdFN44WMvQHKsGYpo9Mp3O4o4Wbq9xDoRVyJ9BDD7nQ94dAm32HaTm4r7EiqtY69iZMnMjSBQqiAD+yFXAqQ3WMTW6uoH6xQ==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 23 Aug 2024 18:02:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 8/15/24 04:36, Jan Beulich wrote:
> On 15.08.2024 03:28, Stewart Hildebrand wrote:
>> On 8/13/24 10:01, Jan Beulich wrote:
>>> On 12.08.2024 22:39, Stewart Hildebrand wrote:
>>>> @@ -446,7 +448,27 @@ static void free_pdev(struct pci_seg *pseg, struct 
>>>> pci_dev *pdev)
>>>>  
>>>>      list_del(&pdev->alldevs_list);
>>>>      pdev_msi_deinit(pdev);
>>>> -    xfree(pdev);
>>>> +
>>>> +    if ( pdev->info.is_virtfn )
>>>> +    {
>>>> +        struct pci_dev *pf_pdev = pdev->virtfn.pf_pdev;
>>>> +
>>>> +        if ( pf_pdev )
>>>> +        {
>>>> +            list_del(&pdev->virtfn.next);
>>>> +            if ( pf_pdev->physfn.dealloc_pending &&
>>>> +                 list_empty(&pf_pdev->physfn.vf_list) )
>>>> +                xfree(pf_pdev);
>>>> +        }
>>>> +        xfree(pdev);
>>>> +    }
>>>> +    else
>>>> +    {
>>>> +        if ( list_empty(&pdev->physfn.vf_list) )
>>>> +            xfree(pdev);
>>>> +        else
>>>> +            pdev->physfn.dealloc_pending = true;
>>>> +    }
>>>
>>> Could I talk you into un-indenting the last if/else by a level, by making
>>> the earlier else and "else if()"?
>>>
>>> One aspect I didn't properly consider when making the suggestion: What if,
>>> without all VFs having gone away, the PF is re-added? In that case we
>>> would better recycle the existing structure. That's getting a little
>>> complicated, so maybe a better approach is to refuse the request (in
>>> pci_remove_device()) when the list isn't empty?
>>
>> Hm. Right. The growing complexity of maintaining these PF<->VF links
>> (introduced on a hunch that they may be useful in the future) is making
>> me favor the previous approach from v2 of simply copying the vf_len
>> array. So unless there are any objections I'll go back to that approach
>> for v4.
> 
> I continue to consider the earlier approach at least undesirable. The
> vf_len[] array shouldn't be copied around, risking for it to be / go
> stale. There should be one central place for every bit of information,
> unless there are very good reasons to duplicate something.

OK, I'll continue to refine the PF<->VF link approach for v4.



 


Rackspace

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