On 2/10/23 12:50, Christian König wrote:
Am 07.02.23 um 11:50 schrieb Danilo Krummrich:
On 2/7/23 10:35, Christian König wrote:
<snip>
However, I still don't see why we would want to merge over buffer
boundaries, because ultimately we'll end up splitting such a merged
mapping later on anyway once one of the buffers is destroyed.
Well the key point is all approaches have some pros and cons.
If we merge and decide to only do that inside certain boundaries then
those boundaries needs to be provided and checked against. This burns
quite some CPU cycles
If we just merge what we can we might have extra page table updates
which cost time and could result in undesired side effects.
If we don't merge at all we have additional housekeeping for the
mappings and maybe hw restrictions.
Absolutely agree, hence I think it would be beneficial to leave the
decision to the driver which approach to pick.
For instance, if a driver needs to keep track of these bounds anyway
because it needs to track separate page tables for sparse regions, there
is no additional overhead, but the nice effect of being able not avoid
unnecessary merges and subsequent splits.
Also, as explained in one of the previous mails in nouveau we can have
separate PTs for sparse mappings with large page sizes and separate
PTs for memory backed mappings with smaller page sizes overlaying
them. Hence, I need to track a single sparse mapping per buffer
spanning the whole buffer (which I do with a region) and the actual
memory backed mappings within the same range.
Now, this might or might not be unique for Nvidia hardware. If nouveau
would be the only potential user, plus we don't care about potentially
merging mappings over buffer boundaries and hence producing
foreseeable splits of those merged mappings, we could get rid of
regions entirely.
This sounds similar to what AMD hw used to have up until gfx8 (I think),
basically sparse resources where defined through a separate mechanism to
the address resolution of the page tables. I won't rule out that other
hardware has similar approaches.
On the other hand when you have separate page tables for address
translation and sparse handling then why not instantiate two separate VM
manager instances for them?
As mentioned above, for some drivers there could be a synergy between
keeping track of those separate page tables and using these boundaries
for merge decisions.
Also, having a separate manager instance would lead to have less
lightweight nodes for sparse regions, since we'd also carry the fields
needed for memory backed mappings. Furthermore there wouldn't be a
"generic relationship" between the nodes of the two separate manager
instances, like a mapping node has a pointer to the region it resides
in. This may be useful to e.g. do some sanity checks, unmap all mappings
of a given region, etc.
Of course drivers could code this relationship within the driver
specific structures around the mapping nodes, but I think it would be
nice to generalize that and have this built-in.
Regards,
Christian.
Regards,
Christian.
So you need to be able to handle this case anyway and the approach
with the regions won't help you at all preventing that.
Regards,
Christian.