From: Joao Martins <joao.m.martins@oracle.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Yishai Hadas <yishaih@nvidia.com>,
jgg@nvidia.com, saeedm@nvidia.com, kvm@vger.kernel.org,
netdev@vger.kernel.org, kuba@kernel.org, kevin.tian@intel.com,
leonro@nvidia.com, maorg@nvidia.com, cohuck@redhat.com
Subject: Re: [PATCH V4 vfio 04/10] vfio: Add an IOVA bitmap support
Date: Fri, 26 Aug 2022 13:10:50 +0100 [thread overview]
Message-ID: <fd8eca29-f4d7-a148-e31d-45319385f2ad@oracle.com> (raw)
In-Reply-To: <20220826060257.6767231e.alex.williamson@redhat.com>
On 8/26/22 13:02, Alex Williamson wrote:
> On Fri, 26 Aug 2022 10:37:26 +0100
> Joao Martins <joao.m.martins@oracle.com> wrote:
>> On 8/26/22 00:15, Alex Williamson wrote:
>>> On Thu, 25 Aug 2022 23:24:39 +0100
>>> Joao Martins <joao.m.martins@oracle.com> wrote:
>>>> On 8/25/22 20:27, Alex Williamson wrote:
>>>>> Maybe it doesn't really make sense to differentiate the iterator from
>>>>> the bitmap in the API. In fact, couldn't we reduce the API to simply:
>>>>>
>>>>> int iova_bitmap_init(struct iova_bitmap *bitmap, dma_addr_t iova,
>>>>> size_t length, size_t page_size, u64 __user *data);
>>>>>
>>>>> int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *data,
>>>>> int (*fn)(void *data, dma_addr_t iova,
>>>>> size_t length,
>>>>> struct iova_bitmap *bitmap));
>>>>>
>>>>> void iova_bitmap_free(struct iova_bitmap *bitmap);
>>>>>
>>>>> unsigned long iova_bitmap_set(struct iova_bitmap *bitmap,
>>>>> dma_addr_t iova, size_t length);
>>>>>
>>>>> Removes the need for the API to have done, advance, iova, and length
>>>>> functions.
>>>>>
>>>> True, it would be simpler.
>>>>
>>>> Could also allow us to hide the iterator details enterily and switch to
>>>> container_of() from iova_bitmap pointer. Though, from caller, it would be
>>>> weird to do:
>>>>
>>>> struct iova_bitmap_iter iter;
>>>>
>>>> iova_bitmap_init(&iter.dirty, ....);
>>>>
>>>> Hmm, maybe not that strange.
>>>>
>>>> Unless you are trying to suggest to merge both struct iova_bitmap and
>>>> iova_bitmap_iter together? I was trying to keep them separate more for
>>>> the dirty tracker (IOMMUFD/VFIO, to just be limited to iova_bitmap_set()
>>>> with the generic infra being the one managing that iterator state in a
>>>> separate structure.
>>>
>>> Not suggesting the be merged, but why does the embedded mapping
>>> structure need to be exposed to the API? That's an implementation
>>> detail that's causing confusion and naming issues for which structure
>>> is passed and how do we represent that in the function name. Thanks,
>>
>> I wanted the convention to be that the end 'device' tracker (IOMMU or VFIO
>> vendor driver) does not have "direct" access to the iterator state. So it acesses
>> or modifies only the mapped bitmap *data*. The hardware tracker is always *provided*
>> with a iova_bitmap to set bits but it should not allocate, iterate or pin anything,
>> making things simpler for tracker.
>>
>> Thus the point was to have a clear division between how you iterate
>> (iova_bitmap_iter* API) and the actual bits manipulation (so far only
>> iova_bitmap_set()) including which data structures you access in the APIs, thus
>> embedding the least accessed there (struct iova_bitmap).
>>
>> The alternative is to reverse it and just allocate iter state in iova_bitmap_init()
>> and have it stored as a pointer say as iova_bitmap::iter. We encapsulate both and mix
>> the structures, which while not as clean but maybe this is not that big of a deal as
>> I thought it would be
>
> Is there really a need for struct iova_bitmap to be defined in a shared
> header, or could we just have a forward declaration? With the proposed
> interface above, iova_bitmap could be opaque to the caller if it were
> dynamically allocated, ex:
>
/facepalm Oh yes -- even better! Let me try that along with the other comments.
> struct iova_bitmap* iova_bitmap_alloc(dma_addr_t iova, size_t length,
> size_t page_size, u64 __user *bitmap);
>
> Thanks,
> Alex
>
next prev parent reply other threads:[~2022-08-26 12:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 15:10 [PATCH V4 vfio 00/10] Add device DMA logging support for mlx5 driver Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 01/10] net/mlx5: Introduce ifc bits for page tracker Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 02/10] net/mlx5: Query ADV_VIRTUALIZATION capabilities Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 03/10] vfio: Introduce DMA logging uAPIs Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 04/10] vfio: Add an IOVA bitmap support Yishai Hadas
2022-08-25 19:27 ` Alex Williamson
2022-08-25 22:24 ` Joao Martins
2022-08-25 23:15 ` Alex Williamson
2022-08-26 9:37 ` Joao Martins
2022-08-26 12:02 ` Alex Williamson
2022-08-26 12:10 ` Joao Martins [this message]
2022-08-26 13:01 ` Jason Gunthorpe
2022-08-26 12:58 ` Jason Gunthorpe
2022-08-15 15:11 ` [PATCH V4 vfio 05/10] vfio: Introduce the DMA logging feature support Yishai Hadas
2022-08-25 20:49 ` Alex Williamson
2022-08-25 22:26 ` Joao Martins
2022-08-25 22:46 ` Alex Williamson
2022-08-26 12:52 ` Jason Gunthorpe
2022-08-28 13:29 ` Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 06/10] vfio/mlx5: Init QP based resources for dirty tracking Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 07/10] vfio/mlx5: Create and destroy page tracker object Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 08/10] vfio/mlx5: Report dirty pages from tracker Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 09/10] vfio/mlx5: Manage error scenarios on tracker Yishai Hadas
2022-08-15 15:11 ` [PATCH V4 vfio 10/10] vfio/mlx5: Set the driver DMA logging callbacks Yishai Hadas
2022-08-25 11:13 ` [PATCH V4 vfio 00/10] Add device DMA logging support for mlx5 driver Yishai Hadas
2022-08-25 19:37 ` Alex Williamson
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=fd8eca29-f4d7-a148-e31d-45319385f2ad@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=leonro@nvidia.com \
--cc=maorg@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=yishaih@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).