OSDN Git Service

drm/amdkfd: Track unified memory when switching xnack mode
authorPhilip Yang <Philip.Yang@amd.com>
Thu, 8 Sep 2022 02:38:00 +0000 (22:38 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 30 Sep 2022 15:21:14 +0000 (11:21 -0400)
commit8a7c3ce108544334a9c7906f61d2701f433e44ee
treec7210a7ac7411d49496237e578e5d46bf7e91e27
parent730548ba023113a15e5233deebd49ffbb02b7322
drm/amdkfd: Track unified memory when switching xnack mode

Unified memory usage with xnack off is tracked to avoid oversubscribe
system memory, with xnack on, we don't track unified memory usage to
allow memory oversubscribe. When switching xnack mode from off to on,
subsequent free ranges allocated with xnack off will not unreserve
memory. When switching xnack mode from on to off, subsequent free ranges
allocated with xnack on will unreserve memory. Both cases cause memory
accounting unbalanced.

When switching xnack mode from on to off, need reserve already allocated
svm range memory. When switching xnack mode from off to on, need
unreserve already allocated svm range memory.

v6: Take prange lock to access range child list
v5: Handle prange child ranges
v4: Handle reservation memory failure
v3: Handle switching xnack mode race with svm_range_deferred_list_work
v2: Handle both switching xnack from on to off and from off to on cases

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.h