intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>
Cc: intel-xe@lists.freedesktop.org,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Boris Brezillon" <bbrezillon@kernel.org>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v6 04/26] drm/gpuvm: Introduce DRM_GPUVM_SM_MAP_OPS_FLAG_SPLIT_MADVISE flag
Date: Tue, 12 Aug 2025 18:58:58 +0200	[thread overview]
Message-ID: <DC0LXQF855NM.1ODUF3CKB5X4K@kernel.org> (raw)
In-Reply-To: <20250807164338.1832254-5-himal.prasad.ghimiray@intel.com>

On Thu Aug 7, 2025 at 6:43 PM CEST, Himal Prasad Ghimiray wrote:
> @@ -2110,6 +2110,8 @@ __drm_gpuvm_sm_map(struct drm_gpuvm *gpuvm,
>  {
>  	struct drm_gpuva *va, *next;
>  	u64 req_end = req->op_map.va.addr + req->op_map.va.range;
> +	bool is_madvise_ops = (req->flags & DRM_GPUVM_SM_MAP_OPS_FLAG_SPLIT_MADVISE);

Let's just call this 'madvise'.

> +	bool needs_map = !is_madvise_ops;
>  	int ret;
>  
>  	if (unlikely(!drm_gpuvm_range_valid(gpuvm, req->op_map.va.addr, req->op_map.va.range)))
> @@ -2122,26 +2124,35 @@ __drm_gpuvm_sm_map(struct drm_gpuvm *gpuvm,
>  		u64 range = va->va.range;
>  		u64 end = addr + range;
>  		bool merge = !!va->gem.obj;
> +		bool skip_madvise_ops = is_madvise_ops && merge;

IIUC, you're either going for continue or break in this case. I think continue
would always be correct and break is an optimization if end <= req_end?

If that's correct, please just do either

	if (madvise && va->gem.obj)
		continue;

or

	if (madvise && va->gem.obj) {
		if (end > req_end)
			break;
		else
			continue;
	}

instead of sprinkling the skip_madvise_ops checks everywhere.

>  
> +		needs_map = !is_madvise_ops;
>  		if (addr == req->op_map.va.addr) {
>  			merge &= obj == req->op_map.gem.obj &&
>  				 offset == req->op_map.gem.offset;
>  
>  			if (end == req_end) {
> -				ret = op_unmap_cb(ops, priv, va, merge);
> -				if (ret)
> -					return ret;
> +				if (!is_madvise_ops) {
> +					ret = op_unmap_cb(ops, priv, va, merge);
> +					if (ret)
> +						return ret;
> +				}
>  				break;
>  			}
>  
>  			if (end < req_end) {
> -				ret = op_unmap_cb(ops, priv, va, merge);
> -				if (ret)
> -					return ret;
> +				if (!is_madvise_ops) {
> +					ret = op_unmap_cb(ops, priv, va, merge);

I think we should pass madvise as argument to op_unmap_cb() and make it a noop
internally rather than having all the conditionals.

> +					if (ret)
> +						return ret;
> +				}
>  				continue;
>  			}
>  
>  			if (end > req_end) {
> +				if (skip_madvise_ops)
> +					break;
> +
>  				struct drm_gpuva_op_map n = {
>  					.va.addr = req_end,
>  					.va.range = range - req->op_map.va.range,
> @@ -2156,6 +2167,9 @@ __drm_gpuvm_sm_map(struct drm_gpuvm *gpuvm,
>  				ret = op_remap_cb(ops, priv, NULL, &n, &u);
>  				if (ret)
>  					return ret;
> +
> +				if (is_madvise_ops)
> +					needs_map = true;

I don't like this needs_map state...

Maybe we could have

	struct drm_gpuvm_map_req *op_map = madvise ? NULL : req;

at the beginning of the function and then change this line to

	if (madvise)
		op_map = req;

and op_map_cb() can just handle a NULL pointer.

Yeah, I feel like that's better.

  parent reply	other threads:[~2025-08-12 16:59 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-07 16:43 [PATCH v6 00/26] MADVISE FOR XE Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 01/26] drm/gpuvm: Pass map arguments through a struct Himal Prasad Ghimiray
2025-08-08  5:03   ` Matthew Brost
2025-08-09 12:43   ` Danilo Krummrich
2025-08-11  6:54     ` Ghimiray, Himal Prasad
2025-08-12 16:51   ` Danilo Krummrich
2025-08-12 17:55     ` Ghimiray, Himal Prasad
2025-08-07 16:43 ` [PATCH v6 02/26] drm/gpuvm: Kill drm_gpuva_init() Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 03/26] drm/gpuvm: Support flags in drm_gpuvm_map_req Himal Prasad Ghimiray
2025-08-08  5:04   ` Matthew Brost
2025-08-09 12:46   ` Danilo Krummrich
2025-08-11  6:56     ` Ghimiray, Himal Prasad
2025-08-07 16:43 ` [PATCH v6 04/26] drm/gpuvm: Introduce DRM_GPUVM_SM_MAP_OPS_FLAG_SPLIT_MADVISE flag Himal Prasad Ghimiray
2025-08-08  5:20   ` Matthew Brost
2025-08-09 13:23   ` Danilo Krummrich
2025-08-11  6:52     ` Ghimiray, Himal Prasad
2025-08-12 16:06       ` Danilo Krummrich
2025-08-12 17:52         ` Ghimiray, Himal Prasad
2025-08-12 16:58   ` Danilo Krummrich [this message]
2025-08-12 17:54     ` Ghimiray, Himal Prasad
2025-08-07 16:43 ` [PATCH v6 05/26] drm/xe/uapi: Add madvise interface Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 06/26] drm/xe/vm: Add attributes struct as member of vma Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 07/26] drm/xe/vma: Move pat_index to vma attributes Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 08/26] drm/xe/vma: Modify new_vma to accept struct xe_vma_mem_attr as parameter Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 09/26] drm/gpusvm: Make drm_gpusvm_for_each_* macros public Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 10/26] drm/xe/svm: Split system allocator vma incase of madvise call Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 11/26] drm/xe: Allow CPU address mirror VMA unbind with gpu bindings for madvise Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 12/26] drm/xe/svm: Add xe_svm_ranges_zap_ptes_in_range() for PTE zapping Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 13/26] drm/xe: Implement madvise ioctl for xe Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 14/26] drm/xe/svm : Add svm ranges migration policy on atomic access Himal Prasad Ghimiray
2025-08-08  5:42   ` Matthew Brost
2025-08-07 16:43 ` [PATCH v6 15/26] drm/xe/madvise: Update migration policy based on preferred location Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 16/26] drm/xe/pat: Add helper for compression mode of pat index Himal Prasad Ghimiray
2025-08-08  5:47   ` Matthew Brost
2025-08-07 16:43 ` [PATCH v6 17/26] drm/xe/svm: Support DRM_XE_SVM_MEM_RANGE_ATTR_PAT memory attribute Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 18/26] drm/xe/uapi: Add flag for consulting madvise hints on svm prefetch Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 19/26] drm/xe/svm: Consult madvise preferred location in prefetch Himal Prasad Ghimiray
2025-08-08  0:30   ` Matthew Brost
2025-08-07 16:43 ` [PATCH v6 20/26] drm/xe/bo: Add attributes field to xe_bo Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 21/26] drm/xe/bo: Update atomic_access attribute on madvise Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 22/26] drm/xe/madvise: Skip vma invalidation if mem attr are unchanged Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 23/26] drm/xe/vm: Add helper to check for default VMA memory attributes Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 24/26] drm/xe: Reset VMA attributes to default in SVM garbage collector Himal Prasad Ghimiray
2025-08-07 17:13   ` Matthew Brost
2025-08-07 16:43 ` [PATCH v6 25/26] drm/xe: Enable madvise ioctl for xe Himal Prasad Ghimiray
2025-08-07 16:43 ` [PATCH v6 26/26] drm/xe/uapi: Add UAPI for querying VMA count and memory attributes Himal Prasad Ghimiray
2025-08-07 18:02 ` ✗ CI.checkpatch: warning for MADVISE FOR XE (rev6) Patchwork
2025-08-07 18:03 ` ✓ CI.KUnit: success " Patchwork
2025-08-07 18:18 ` ✗ CI.checksparse: warning " Patchwork
2025-08-07 19:11 ` ✓ Xe.CI.BAT: success " Patchwork
2025-08-07 21:16 ` ✓ Xe.CI.Full: " 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=DC0LXQF855NM.1ODUF3CKB5X4K@kernel.org \
    --to=dakr@kernel.org \
    --cc=bbrezillon@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=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;
as well as URLs for NNTP newsgroup(s).