Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v5 16/20] drm/xe/svm: Add xe_svm_range_validate_and_evict() function
Date: Wed, 30 Apr 2025 09:15:43 +0530	[thread overview]
Message-ID: <53f0955b-0236-4b49-a2cf-e74b7d0c8300@intel.com> (raw)
In-Reply-To: <9f3f41e3-f3d0-49d6-ad3f-e725d86cd210@intel.com>



On 30-04-2025 09:04, Ghimiray, Himal Prasad wrote:
> 
> 
> On 30-04-2025 00:12, Matthew Brost wrote:
>> On Tue, Apr 29, 2025 at 04:12:29PM +0530, Himal Prasad Ghimiray wrote:
>>> The xe_svm_range_validate_and_evict() function checks if a range is
>>> valid and located in the desired memory region. Additionally, if the
>>> range is valid in VRAM but the desired region is SMEM, it evicts the
>>> ranges to SMEM.
>>>
>>> v2
>>> - Fix function stub in xe_svm.h
>>> - Fix doc
>>>
>>> v3 (Matthew Brost)
>>> - Remove extra new line
>>> - s/range->base.flags.has_devmem_pages/xe_svm_range_in_vram
>>>
>>> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
>>> ---
>>>   drivers/gpu/drm/xe/xe_svm.c | 37 +++++++++++++++++++++++++++++++++++++
>>>   drivers/gpu/drm/xe/xe_svm.h | 12 ++++++++++++
>>>   2 files changed, 49 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
>>> index 90fae13b77ae..55c5373b7989 100644
>>> --- a/drivers/gpu/drm/xe/xe_svm.c
>>> +++ b/drivers/gpu/drm/xe/xe_svm.c
>>> @@ -637,6 +637,43 @@ static bool xe_svm_range_is_valid(struct 
>>> xe_svm_range *range,
>>>           && (!devmem_only || range->base.flags.migrate_devmem);
>>>   }
>>> +/**
>>> + * xe_svm_range_validate_and_evict() - Check if the SVM range is valid
>>> + * @vm: xe_vm pointer
>>> + * @range: Pointer to the SVM range structure
>>> + * @tile_mask: Mask representing the tiles to be checked
>>> + * @devmem_only: if true range needs to be in devmem
>>> + *
>>> + * The xe_svm_range_validate_and_evict() function checks if a range is
>>> + * valid and located in the desired memory region. Additionally, if the
>>> + * range is valid in VRAM but the desired region is SMEM, it evicts the
>>> + * ranges to SMEM.
>>> + *
>>> + * Return: true if the range is valid, false otherwise
>>> + */
>>> +bool xe_svm_range_validate_and_evict(struct xe_vm *vm,
>>> +                     struct xe_svm_range *range,
>>> +                     u8 tile_mask, bool devmem_only)
>>
>> s/devmem_only/devmem_preferred
> 
> Sure
> 
>>
>>> +{
>>> +    bool range_evict = false;
>>> +    bool ret;
>>> +
>>> +    xe_svm_notifier_lock(vm);
>>> +
>>> +    ret = (range->tile_present & ~range->tile_invalidated & 
>>> tile_mask) == tile_mask &&
>>> +           (devmem_only == xe_svm_range_in_vram(range));

I see xe_svm_range_in_vram is moved to using READ_ONCE in
https://patchwork.freedesktop.org/patch/650869/?series=147846&rev=5.

Since we are in agreement of using locking here, how about using
range->base.flags.has_devmem_pages instead of xe_svm_range_in_vram().


>>> +
>>> +    if (!ret && !devmem_only && xe_svm_range_in_vram(range))
>>> +        range_evict = true;
>>> +
>>> +    xe_svm_notifier_unlock(vm);
>>> +
>>> +    if (range_evict)
>>> +        drm_gpusvm_range_evict(&vm->svm.gpusvm, &range->base);
>>
>> Sorry missed this eariler. I think this step should be left to latter in
>> the software pipeline - e.g., In prefetch_ranges in the following patch.
>>
>> Migration are costly and this is the step we'd want to thread for
>> performancd. So if some migrations are done in vm_bind_ioctl_ops_create
>> and other in prefetch_ranges it would make the threading logic tricky
>> comapred all migrations being done in prefetch_ranges.
> 
> Agreed, will move to prefetch_ranges
> 
>>
>> Matt
>>
>>> +
>>> +    return ret;
>>> +}
>>> +
>>>   #if IS_ENABLED(CONFIG_DRM_XE_DEVMEM_MIRROR)
>>>   static struct xe_vram_region *tile_to_vr(struct xe_tile *tile)
>>>   {
>>> diff --git a/drivers/gpu/drm/xe/xe_svm.h b/drivers/gpu/drm/xe/xe_svm.h
>>> index 9be7bb25725c..e6f71ad0b17b 100644
>>> --- a/drivers/gpu/drm/xe/xe_svm.h
>>> +++ b/drivers/gpu/drm/xe/xe_svm.h
>>> @@ -83,6 +83,10 @@ int xe_svm_range_get_pages(struct xe_vm *vm, 
>>> struct xe_svm_range *range,
>>>   bool xe_svm_range_needs_migrate_to_vram(struct xe_svm_range *range, 
>>> struct xe_vma *vma,
>>>                       bool preferred_region_is_vram);
>>> +bool xe_svm_range_validate_and_evict(struct xe_vm *vm,
>>> +                     struct xe_svm_range *range,
>>> +                     u8 tile_mask, bool devmem_only);
>>> +
>>>   /**
>>>    * xe_svm_range_has_dma_mapping() - SVM range has DMA mapping
>>>    * @range: SVM range
>>> @@ -276,6 +280,14 @@ bool xe_svm_range_needs_migrate_to_vram(struct 
>>> xe_svm_range *range, struct xe_vm
>>>       return false;
>>>   }
>>> +static inline
>>> +bool xe_svm_range_validate_and_evict(struct xe_vm *vm,
>>> +                     struct xe_svm_range *range,
>>> +                     u8 tile_mask, bool devmem_only)
>>> +{
>>> +    return false;
>>> +}
>>> +
>>>   #define xe_svm_assert_in_notifier(...) do {} while (0)
>>>   #define xe_svm_range_has_dma_mapping(...) false
>>> -- 
>>> 2.34.1
>>>
> 


  parent reply	other threads:[~2025-04-30  3:46 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29 10:42 [PATCH v5 00/20] Prefetch Support for svm ranges Himal Prasad Ghimiray
2025-04-29 10:36 ` ✓ CI.Patch_applied: success for Prefetch Support for svm ranges (rev4) Patchwork
2025-04-29 10:37 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-29 10:38 ` ✓ CI.KUnit: success " Patchwork
2025-04-29 10:42 ` [PATCH v5 01/20] drm/gpusvm: Introduce devmem_only flag for allocation Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 02/20] drm/xe: Strict migration policy for atomic SVM faults Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 03/20] drm/gpusvm: Add timeslicing support to GPU SVM Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 04/20] drm/xe: Timeslice GPU on atomic SVM fault Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 05/20] drm/xe: Add atomic_svm_timeslice_ms debugfs entry Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 06/20] drm/xe: Introduce xe_vma_op_prefetch_range struct for prefetch of ranges Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 07/20] drm/xe: Make xe_svm_alloc_vram public Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 08/20] drm/xe/svm: Helper to add tile masks to svm ranges Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 09/20] drm/xe/svm: Make to_xe_range a public function Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 10/20] drm/xe/svm: Make xe_svm_range_* end/start/size public Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 11/20] drm/xe/vm: Update xe_vma_ops_incr_pt_update_ops to take an increment value Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 12/20] drm/xe/vm: Add an identifier in xe_vma_ops for svm prefetch Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 13/20] drm/xe: Rename lookup_vma function to xe_find_vma_by_addr Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 14/20] drm/xe/svm: Refactor usage of drm_gpusvm* function in xe_svm Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 15/20] drm/xe/svm: Make xe_svm_range_needs_migrate_to_vram() public Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 16/20] drm/xe/svm: Add xe_svm_range_validate_and_evict() function Himal Prasad Ghimiray
2025-04-29 18:42   ` Matthew Brost
     [not found]     ` <9f3f41e3-f3d0-49d6-ad3f-e725d86cd210@intel.com>
2025-04-30  3:45       ` Ghimiray, Himal Prasad [this message]
2025-04-30  3:49         ` Matthew Brost
2025-04-29 10:42 ` [PATCH v5 17/20] drm/gpusvm: Introduce drm_gpusvm_range_find_or_insert_start() function Himal Prasad Ghimiray
2025-04-29 18:35   ` Matthew Brost
2025-04-30  3:40     ` Ghimiray, Himal Prasad
2025-04-30  4:21       ` Matthew Brost
2025-04-29 10:42 ` [PATCH v5 18/20] drm/xe/svm: Add xe_svm_range_find_or_insert_start() Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 19/20] drm/xe/svm: Implement prefetch support for SVM ranges Himal Prasad Ghimiray
2025-04-29 10:42 ` [PATCH v5 20/20] drm/xe/vm: Add debug prints for SVM range prefetch Himal Prasad Ghimiray
2025-04-29 10:46 ` ✓ CI.Build: success for Prefetch Support for svm ranges (rev4) Patchwork
2025-04-29 10:49 ` ✓ CI.Hooks: " Patchwork
2025-04-29 10:51 ` ✓ CI.checksparse: " Patchwork
2025-04-29 12:47 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-06  7:14 ` ✗ Xe.CI.BAT: " Patchwork
2025-05-06  7:51 ` ✓ Xe.CI.BAT: success " Patchwork

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=53f0955b-0236-4b49-a2cf-e74b7d0c8300@intel.com \
    --to=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=thomas.hellstrom@linux.intel.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