From: Matthew Brost <matthew.brost@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v2 21/32] drm/gpusvm: Make drm_gpusvm_for_each_* macros public
Date: Wed, 14 May 2025 11:47:13 -0700 [thread overview]
Message-ID: <aCTlMR1L6ickQIQC@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250407101719.3350996-22-himal.prasad.ghimiray@intel.com>
On Mon, Apr 07, 2025 at 03:47:08PM +0530, Himal Prasad Ghimiray wrote:
> The drm_gpusvm_for_each_notifier, drm_gpusvm_for_each_notifier_safe and
> drm_gpusvm_for_each_range_safe macros are useful for locating notifiers
> and ranges within a user-specified range. By making these macros public,
> we enable broader access and utility for developers who need to leverage
> them in their implementations.
>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Assuming you have users of these, makes sense to make these public.
A couple of nits below.
> ---
> drivers/gpu/drm/drm_gpusvm.c | 89 +--------------------------------
> include/drm/drm_gpusvm.h | 96 +++++++++++++++++++++++++++++++++++-
> 2 files changed, 96 insertions(+), 89 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
> index 149ac56eff70..09708eef1c86 100644
> --- a/drivers/gpu/drm/drm_gpusvm.c
> +++ b/drivers/gpu/drm/drm_gpusvm.c
> @@ -391,97 +391,10 @@ struct drm_gpusvm_range *
> drm_gpusvm_range_find(struct drm_gpusvm_notifier *notifier, unsigned long start,
> unsigned long end)
> {
> - struct interval_tree_node *itree;
> -
> - itree = interval_tree_iter_first(¬ifier->root, start, end - 1);
> -
> - if (itree)
> - return container_of(itree, struct drm_gpusvm_range, itree);
> - else
> - return NULL;
> + return __drm_gpusvm_range_find(notifier, start, end);
My do you __drm_gpusvm_range_find as inline? Can't you just call
drm_gpusvm_range_find in public iterators?
Also I think rather than inlines for functions which touch the interval
tree, I'd leave those functions in drm_gpusvm.c - that is what
drm_gpuvm.c does.
> }
> EXPORT_SYMBOL_GPL(drm_gpusvm_range_find);
>
> -/**
> - * drm_gpusvm_for_each_range_safe() - Safely iterate over GPU SVM ranges in a notifier
> - * @range__: Iterator variable for the ranges
> - * @next__: Iterator variable for the ranges temporay storage
> - * @notifier__: Pointer to the GPU SVM notifier
> - * @start__: Start address of the range
> - * @end__: End address of the range
> - *
> - * This macro is used to iterate over GPU SVM ranges in a notifier while
> - * removing ranges from it.
> - */
> -#define drm_gpusvm_for_each_range_safe(range__, next__, notifier__, start__, end__) \
> - for ((range__) = drm_gpusvm_range_find((notifier__), (start__), (end__)), \
> - (next__) = __drm_gpusvm_range_next(range__); \
> - (range__) && (drm_gpusvm_range_start(range__) < (end__)); \
> - (range__) = (next__), (next__) = __drm_gpusvm_range_next(range__))
> -
> -/**
> - * __drm_gpusvm_notifier_next() - get the next drm_gpusvm_notifier in the list
> - * @notifier: a pointer to the current drm_gpusvm_notifier
> - *
> - * Return: A pointer to the next drm_gpusvm_notifier if available, or NULL if
> - * the current notifier is the last one or if the input notifier is
> - * NULL.
> - */
> -static struct drm_gpusvm_notifier *
> -__drm_gpusvm_notifier_next(struct drm_gpusvm_notifier *notifier)
> -{
> - if (notifier && !list_is_last(¬ifier->entry,
> - ¬ifier->gpusvm->notifier_list))
> - return list_next_entry(notifier, entry);
> -
> - return NULL;
> -}
> -
> -static struct drm_gpusvm_notifier *
> -notifier_iter_first(struct rb_root_cached *root, unsigned long start,
> - unsigned long last)
> -{
So make this one an exported function I think.
s/notifier_iter_first/drm_gpusvm_notifier_find
And adjust the arguments.
> - struct interval_tree_node *itree;
> -
> - itree = interval_tree_iter_first(root, start, last);
> -
> - if (itree)
> - return container_of(itree, struct drm_gpusvm_notifier, itree);
> - else
> - return NULL;
> -}
> -
> -/**
> - * drm_gpusvm_for_each_notifier() - Iterate over GPU SVM notifiers in a gpusvm
> - * @notifier__: Iterator variable for the notifiers
> - * @notifier__: Pointer to the GPU SVM notifier
> - * @start__: Start address of the notifier
> - * @end__: End address of the notifier
> - *
> - * This macro is used to iterate over GPU SVM notifiers in a gpusvm.
> - */
> -#define drm_gpusvm_for_each_notifier(notifier__, gpusvm__, start__, end__) \
> - for ((notifier__) = notifier_iter_first(&(gpusvm__)->root, (start__), (end__) - 1); \
> - (notifier__) && (drm_gpusvm_notifier_start(notifier__) < (end__)); \
> - (notifier__) = __drm_gpusvm_notifier_next(notifier__))
> -
> -/**
> - * drm_gpusvm_for_each_notifier_safe() - Safely iterate over GPU SVM notifiers in a gpusvm
> - * @notifier__: Iterator variable for the notifiers
> - * @next__: Iterator variable for the notifiers temporay storage
> - * @notifier__: Pointer to the GPU SVM notifier
> - * @start__: Start address of the notifier
> - * @end__: End address of the notifier
> - *
> - * This macro is used to iterate over GPU SVM notifiers in a gpusvm while
> - * removing notifiers from it.
> - */
> -#define drm_gpusvm_for_each_notifier_safe(notifier__, next__, gpusvm__, start__, end__) \
> - for ((notifier__) = notifier_iter_first(&(gpusvm__)->root, (start__), (end__) - 1), \
> - (next__) = __drm_gpusvm_notifier_next(notifier__); \
> - (notifier__) && (drm_gpusvm_notifier_start(notifier__) < (end__)); \
> - (notifier__) = (next__), (next__) = __drm_gpusvm_notifier_next(notifier__))
> -
> /**
> * drm_gpusvm_notifier_invalidate() - Invalidate a GPU SVM notifier.
> * @mni: Pointer to the mmu_interval_notifier structure.
> diff --git a/include/drm/drm_gpusvm.h b/include/drm/drm_gpusvm.h
> index 8093cc6ab1f4..8b70361db351 100644
> --- a/include/drm/drm_gpusvm.h
> +++ b/include/drm/drm_gpusvm.h
> @@ -491,6 +491,20 @@ __drm_gpusvm_range_next(struct drm_gpusvm_range *range)
> return NULL;
> }
>
> +static inline struct drm_gpusvm_range *
> +__drm_gpusvm_range_find(struct drm_gpusvm_notifier *notifier,
> + unsigned long start, unsigned long end)
> +{
> + struct interval_tree_node *itree;
> +
> + itree = interval_tree_iter_first(¬ifier->root, start, end - 1);
> +
> + if (itree)
> + return container_of(itree, struct drm_gpusvm_range, itree);
> + else
> + return NULL;
> +}
> +
> /**
> * drm_gpusvm_for_each_range() - Iterate over GPU SVM ranges in a notifier
> * @range__: Iterator variable for the ranges. If set, it indicates the start of
> @@ -504,8 +518,88 @@ __drm_gpusvm_range_next(struct drm_gpusvm_range *range)
> */
> #define drm_gpusvm_for_each_range(range__, notifier__, start__, end__) \
> for ((range__) = (range__) ?: \
> - drm_gpusvm_range_find((notifier__), (start__), (end__)); \
> + __drm_gpusvm_range_find((notifier__), (start__), (end__)); \
> (range__) && (drm_gpusvm_range_start(range__) < (end__)); \
> (range__) = __drm_gpusvm_range_next(range__))
>
> +/**
> + * drm_gpusvm_for_each_range_safe() - Safely iterate over GPU SVM ranges in a notifier
> + * @range__: Iterator variable for the ranges
> + * @next__: Iterator variable for the ranges temporay storage
> + * @notifier__: Pointer to the GPU SVM notifier
> + * @start__: Start address of the range
> + * @end__: End address of the range
> + *
> + * This macro is used to iterate over GPU SVM ranges in a notifier while
> + * removing ranges from it.
> + */
> +#define drm_gpusvm_for_each_range_safe(range__, next__, notifier__, start__, end__) \
> + for ((range__) = __drm_gpusvm_range_find((notifier__), (start__), (end__)), \
> + (next__) = __drm_gpusvm_range_next(range__); \
> + (range__) && (drm_gpusvm_range_start(range__) < (end__)); \
> + (range__) = (next__), (next__) = __drm_gpusvm_range_next(range__))
> +
> +/**
> + * __drm_gpusvm_notifier_next() - get the next drm_gpusvm_notifier in the list
> + * @notifier: a pointer to the current drm_gpusvm_notifier
> + *
> + * Return: A pointer to the next drm_gpusvm_notifier if available, or NULL if
> + * the current notifier is the last one or if the input notifier is
> + * NULL.
> + */
> +static inline struct drm_gpusvm_notifier *
> +__drm_gpusvm_notifier_next(struct drm_gpusvm_notifier *notifier)
> +{
This one seems reasonable as an inline.
Matt
> + if (notifier && !list_is_last(¬ifier->entry,
> + ¬ifier->gpusvm->notifier_list))
> + return list_next_entry(notifier, entry);
> +
> + return NULL;
> +}
> +
> +static inline struct drm_gpusvm_notifier *
> +notifier_iter_first(struct rb_root_cached *root, unsigned long start,
> + unsigned long last)
> +{
> + struct interval_tree_node *itree;
> +
> + itree = interval_tree_iter_first(root, start, last);
> +
> + if (itree)
> + return container_of(itree, struct drm_gpusvm_notifier, itree);
> + else
> + return NULL;
> +}
> +
> +/**
> + * drm_gpusvm_for_each_notifier() - Iterate over GPU SVM notifiers in a gpusvm
> + * @notifier__: Iterator variable for the notifiers
> + * @notifier__: Pointer to the GPU SVM notifier
> + * @start__: Start address of the notifier
> + * @end__: End address of the notifier
> + *
> + * This macro is used to iterate over GPU SVM notifiers in a gpusvm.
> + */
> +#define drm_gpusvm_for_each_notifier(notifier__, gpusvm__, start__, end__) \
> + for ((notifier__) = notifier_iter_first(&(gpusvm__)->root, (start__), (end__) - 1); \
> + (notifier__) && (drm_gpusvm_notifier_start(notifier__) < (end__)); \
> + (notifier__) = __drm_gpusvm_notifier_next(notifier__))
> +
> +/**
> + * drm_gpusvm_for_each_notifier_safe() - Safely iterate over GPU SVM notifiers in a gpusvm
> + * @notifier__: Iterator variable for the notifiers
> + * @next__: Iterator variable for the notifiers temporay storage
> + * @notifier__: Pointer to the GPU SVM notifier
> + * @start__: Start address of the notifier
> + * @end__: End address of the notifier
> + *
> + * This macro is used to iterate over GPU SVM notifiers in a gpusvm while
> + * removing notifiers from it.
> + */
> +#define drm_gpusvm_for_each_notifier_safe(notifier__, next__, gpusvm__, start__, end__) \
> + for ((notifier__) = notifier_iter_first(&(gpusvm__)->root, (start__), (end__) - 1), \
> + (next__) = __drm_gpusvm_notifier_next(notifier__); \
> + (notifier__) && (drm_gpusvm_notifier_start(notifier__) < (end__)); \
> + (notifier__) = (next__), (next__) = __drm_gpusvm_notifier_next(notifier__))
> +
> #endif /* __DRM_GPUSVM_H__ */
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-05-14 18:45 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 10:16 [PATCH v2 00/32] PREFETCH and MADVISE for SVM ranges Himal Prasad Ghimiray
2025-04-07 10:16 ` [PATCH v2 01/32] drm/xe: Introduce xe_vma_op_prefetch_range struct for prefetch of ranges Himal Prasad Ghimiray
2025-04-07 10:16 ` [PATCH v2 02/32] drm/xe: Make xe_svm_alloc_vram public Himal Prasad Ghimiray
2025-04-17 2:50 ` Matthew Brost
2025-04-21 4:06 ` Ghimiray, Himal Prasad
2025-04-07 10:16 ` [PATCH v2 03/32] drm/xe/svm: Helper to add tile masks to svm ranges Himal Prasad Ghimiray
2025-04-07 10:16 ` [PATCH v2 04/32] drm/xe/svm: Make to_xe_range a public function Himal Prasad Ghimiray
2025-04-07 10:16 ` [PATCH v2 05/32] drm/xe/svm: Make xe_svm_range_* end/start/size public Himal Prasad Ghimiray
2025-04-07 10:16 ` [PATCH v2 06/32] drm/xe/vm: Update xe_vma_ops_incr_pt_update_ops to take an increment value Himal Prasad Ghimiray
2025-04-17 0:10 ` Matthew Brost
2025-04-21 4:09 ` Ghimiray, Himal Prasad
2025-04-07 10:16 ` [PATCH v2 07/32] drm/xe/vm: Add an identifier in xe_vma_ops for svm prefetch Himal Prasad Ghimiray
2025-04-17 2:53 ` Matthew Brost
2025-04-07 10:16 ` [PATCH v2 08/32] drm/xe: Rename lookup_vma function to xe_find_vma_by_addr Himal Prasad Ghimiray
2025-04-07 22:42 ` kernel test robot
2025-04-07 10:16 ` [PATCH v2 09/32] drm/xe/svm: Allow unaligned addresses and ranges for prefetch Himal Prasad Ghimiray
2025-04-17 2:53 ` Matthew Brost
2025-04-07 10:16 ` [PATCH v2 10/32] drm/xe/svm: Refactor usage of drm_gpusvm* function in xe_svm Himal Prasad Ghimiray
2025-04-17 2:57 ` Matthew Brost
2025-04-21 4:30 ` Ghimiray, Himal Prasad
2025-04-07 10:16 ` [PATCH v2 11/32] drm/xe/svm: Add function to determine if range needs VRAM migration Himal Prasad Ghimiray
2025-04-17 3:05 ` Matthew Brost
2025-04-21 4:52 ` Ghimiray, Himal Prasad
2025-04-07 10:16 ` [PATCH v2 12/32] drm/gpusvm: Introduce vram_only flag for VRAM allocation Himal Prasad Ghimiray
2025-04-17 3:07 ` Matthew Brost
2025-04-21 4:55 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 13/32] drm/xe/svm: Incase of atomic access ensure get_pages happens from vram Himal Prasad Ghimiray
2025-04-17 4:19 ` Matthew Brost
2025-04-21 4:58 ` Ghimiray, Himal Prasad
2025-04-21 6:29 ` Ghimiray, Himal Prasad
2025-04-22 15:25 ` Matthew Brost
2025-04-22 15:27 ` Matthew Brost
2025-04-07 10:17 ` [PATCH v2 14/32] drm/xe/svm: Implement prefetch support for SVM ranges Himal Prasad Ghimiray
2025-04-17 4:54 ` Matthew Brost
2025-04-24 10:03 ` Ghimiray, Himal Prasad
2025-04-24 23:48 ` Matthew Brost
2025-04-28 6:44 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 15/32] drm/xe/vm: Add debug prints for SVM range prefetch Himal Prasad Ghimiray
2025-04-17 4:56 ` Matthew Brost
2025-04-07 10:17 ` [PATCH v2 16/32] Introduce drm_gpuvm_sm_map_ops_flags enums for sm_map_ops Himal Prasad Ghimiray
2025-04-07 10:30 ` Boris Brezillon
2025-05-26 13:48 ` Ghimiray, Himal Prasad
2025-04-07 22:42 ` kernel test robot
2025-04-07 10:17 ` [PATCH v2 17/32] drm/xe/uapi: Add madvise interface Himal Prasad Ghimiray
2025-04-17 18:19 ` Souza, Jose
2025-04-17 18:24 ` Souza, Jose
2025-04-22 15:34 ` Matthew Brost
2025-04-22 15:55 ` Souza, Jose
2025-04-22 16:19 ` Matthew Brost
2025-04-22 15:40 ` Matthew Brost
2025-04-22 16:02 ` Souza, Jose
2025-04-22 16:12 ` Matthew Brost
2025-04-22 16:16 ` Souza, Jose
2025-05-02 14:00 ` Thomas Hellström
2025-05-20 8:13 ` Ghimiray, Himal Prasad
2025-05-20 8:49 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 18/32] drm/xe/vm: Add attributes struct as member of vma Himal Prasad Ghimiray
2025-05-14 18:36 ` Matthew Brost
2025-05-20 9:27 ` Ghimiray, Himal Prasad
2025-05-27 17:37 ` Matthew Brost
2025-05-28 5:33 ` Ghimiray, Himal Prasad
2025-05-28 16:09 ` Matthew Brost
2025-05-28 16:16 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 19/32] drm/xe/vma: Move pat_index to vma attributes Himal Prasad Ghimiray
2025-05-14 18:37 ` Matthew Brost
2025-04-07 10:17 ` [PATCH v2 20/32] drm/xe/vma: Modify new_vma to accept struct xe_vma_mem_attr as parameter Himal Prasad Ghimiray
2025-05-13 2:36 ` Matthew Brost
2025-05-14 18:40 ` Matthew Brost
2025-05-20 9:28 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 21/32] drm/gpusvm: Make drm_gpusvm_for_each_* macros public Himal Prasad Ghimiray
2025-04-08 1:49 ` kernel test robot
2025-05-14 18:47 ` Matthew Brost [this message]
2025-04-07 10:17 ` [PATCH v2 22/32] drm/xe/svm: Split system allocator vma incase of madvise call Himal Prasad Ghimiray
2025-05-14 19:01 ` Matthew Brost
2025-05-20 9:46 ` Ghimiray, Himal Prasad
2025-05-14 19:02 ` Matthew Brost
2025-04-07 10:17 ` [PATCH v2 23/32] drm/xe: Implement madvise ioctl for xe Himal Prasad Ghimiray
2025-05-14 21:41 ` Matthew Brost
2025-05-20 10:15 ` Ghimiray, Himal Prasad
2025-05-28 5:22 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 24/32] drm/xe: Allow CPU address mirror VMA unbind with gpu bindings for madvise Himal Prasad Ghimiray
2025-05-14 19:20 ` Matthew Brost
2025-05-20 10:21 ` Ghimiray, Himal Prasad
2025-05-27 17:32 ` Matthew Brost
2025-04-07 10:17 ` [PATCH v2 25/32] drm/xe/svm : Add svm ranges migration policy on atomic access Himal Prasad Ghimiray
2025-05-14 22:21 ` Matthew Brost
2025-05-20 10:22 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 26/32] drm/xe/madvise: Update migration policy based on preferred location Himal Prasad Ghimiray
2025-05-14 22:04 ` Matthew Brost
2025-05-21 8:50 ` Ghimiray, Himal Prasad
2025-05-21 16:51 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 27/32] drm/xe/svm: Support DRM_XE_SVM_ATTR_PAT memory attribute Himal Prasad Ghimiray
2025-05-14 21:52 ` Matthew Brost
2025-05-21 8:51 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 28/32] drm/xe/uapi: Add flag for consulting madvise hints on svm prefetch Himal Prasad Ghimiray
2025-05-14 21:05 ` Matthew Brost
2025-05-21 8:52 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 29/32] drm/xe/svm: Consult madvise preferred location in prefetch Himal Prasad Ghimiray
2025-05-14 22:17 ` Matthew Brost
2025-04-07 10:17 ` [PATCH v2 30/32] drm/xe/uapi: Add uapi for vma count and mem attributes Himal Prasad Ghimiray
2025-05-14 21:08 ` Matthew Brost
2025-05-21 8:54 ` Ghimiray, Himal Prasad
2025-05-28 16:18 ` Ghimiray, Himal Prasad
2025-04-07 10:17 ` [PATCH v2 31/32] drm/xe/bo: Add attributes field to xe_bo Himal Prasad Ghimiray
2025-05-14 21:10 ` Matthew Brost
2025-04-07 10:17 ` [PATCH v2 32/32] drm/xe/bo: Update atomic_access attribute on madvise Himal Prasad Ghimiray
2025-05-14 22:31 ` Matthew Brost
2025-05-21 9:13 ` Ghimiray, Himal Prasad
2025-04-07 14:07 ` ✓ CI.Patch_applied: success for PREFETCH and MADVISE for SVM ranges (rev3) Patchwork
2025-04-07 14:07 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-07 14:09 ` ✓ CI.KUnit: success " Patchwork
2025-04-07 14:12 ` ✗ CI.Build: failure " Patchwork
2025-04-09 5:11 ` ✓ CI.Patch_applied: success for PREFETCH and MADVISE for SVM ranges (rev4) Patchwork
2025-04-09 5:11 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-09 5:12 ` ✓ CI.KUnit: success " Patchwork
2025-04-09 5:29 ` ✓ CI.Build: " Patchwork
2025-04-09 5:31 ` ✗ CI.Hooks: failure " Patchwork
2025-04-09 5:32 ` ✗ CI.checksparse: warning " Patchwork
2025-04-09 5:52 ` ✓ Xe.CI.BAT: success " Patchwork
2025-04-09 7:00 ` ✗ Xe.CI.Full: failure " 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=aCTlMR1L6ickQIQC@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--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