Skip to contentSkip to conversation

lib/intel_allocator: Limit last page if not reserved

PATCH In review Jonathan Cavitt 3 participants 5 messages Sep 19, 2023 Library code

lore
Share & tools
lore
#0 lore raw

cover lib/intel_allocator: Limit last page if not reserved

We currently limit the last page of the allocator space to avoid a hang on some platforms when a batch would be pinned in the last page. However, in the future, we may already be reserving the last page of the ppgtt in kernel space, so we would not need to limit the last page because gem_aperture_size would not report its existence in __intel_allocator_open_full when this is the case.

Check the gtt_size and only limit the last page if it's not already reserved by kernel space. This is generalized to if the reported page count is even.

CC Nirmoy Das <[email protected]>
CC Zbigniew Kempczynski <[email protected]>

Jonathan Cavitt (1):
lib/intel_allocator: Limit last page if not reserved

 lib/intel_allocator.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 lib/intel_allocator: Limit last page if not reserved

We currently limit the last page of the allocator space to avoid a hang on some platforms when a batch would be pinned in the last page. However, in the future, we may already be reserving the last page of the ppgtt in kernel space, so we would not need to limit the last page because gem_aperture_size would not report its existence in __intel_allocator_open_full when this is the case.

Check the gtt_size and only limit the last page if it's not already reserved by kernel space. This is generalized to if the reported page count is even.

---
 lib/intel_allocator.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
lib/intel_allocator.c +14 -10
index f0a9b7fb53..fc7836dcee 100644
@@ -53,12 +53,6 @@ static inline const char *reqstr(enum reqtype request_type)
 #define bind_debug(...) {}
 #endif
 
-/*
- * We limit allocator space to avoid hang when batch would be
- * pinned in the last page.
- */
-#define RESERVED 4096
-
 struct allocator {
 	int fd;
 	uint32_t ctx;
@@ -941,11 +935,21 @@ static uint64_t __intel_allocator_open_full(int fd, uint32_t ctx,
 		if (!end) {
 			igt_assert_f(can_report_gtt_size(fd), "Invalid fd\n");
 			gtt_size = gem_aperture_size(fd);
-			if (!gem_uses_full_ppgtt(fd))
+			if (!gem_uses_full_ppgtt(fd)) {
 				gtt_size /= 2;
-			else
-				gtt_size -= RESERVED;
-
+			} else {
+				/*
+				 * We limit allocator space to avoid hang when batch would be
+				 * pinned in the last page.
+				 *
+				 * The last page is reserved when the gtt_size is aligned
+				 * with an odd number of pages.
+				 */
+				uint64_t align = gtt_size % (SZ_4K * 2);
+				align += SZ_4K;
+				align %= (SZ_4K * 2);
+				gtt_size -= align;
+			}
 			req.open.end = gtt_size;
 		}
 
Signature · 1 line
2.25.1
#2 lore raw
Quoted 46 lines · Jonathan Cavitt

We currently limit the last page of the allocator space to avoid a hang on some platforms when a batch would be pinned in the last page. However, in the future, we may already be reserving the last page of the ppgtt in kernel space, so we would not need to limit the last page because gem_aperture_size would not report its existence in __intel_allocator_open_full when this is the case.

Check the gtt_size and only limit the last page if it's not already reserved by kernel space. This is generalized to if the reported page count is even.

---
 lib/intel_allocator.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
lib/intel_allocator.c +4 -10
index f0a9b7fb53..fc7836dcee 100644
@@ -53,12 +53,6 @@ static inline const char *reqstr(enum reqtype request_type)
 #define bind_debug(...) {}
 #endif
 
-/*
- * We limit allocator space to avoid hang when batch would be
- * pinned in the last page.
- */
-#define RESERVED 4096
-
 struct allocator {
 	int fd;
 	uint32_t ctx;
@@ -941,11 +935,21 @@ static uint64_t __intel_allocator_open_full(int fd, uint32_t ctx,
 		if (!end) {
 			igt_assert_f(can_report_gtt_size(fd), "Invalid fd\n");
 			gtt_size = gem_aperture_size(fd);
-			if (!gem_uses_full_ppgtt(fd))
+			if (!gem_uses_full_ppgtt(fd)) {
 				gtt_size /= 2;
-			else
-				gtt_size -= RESERVED;
-
+			} else {
+				/*
+				 * We limit allocator space to avoid hang when batch would be

lib/intel_allocator.c static uint64_t __intel_allocator_open_full(int fd, uint32_t ctx, · line 952

Quoted 10 lines
lib/intel_allocator.c +10 -0
+				 * pinned in the last page.
+				 *
+				 * The last page is reserved when the gtt_size is aligned
+				 * with an odd number of pages.
+				 */
+				uint64_t align = gtt_size % (SZ_4K * 2);
+				align += SZ_4K;
+				align %= (SZ_4K * 2);
+				gtt_size -= align;
+			}

If you're afraid you're entering danger zone from ppgtt perspective from IGTs just increase RESERVED to 8K/16K/32K/... (pick appropriate). Most IGTs don't care where's the limit of vm. If test will need to exercise those offsets it has api to increase end to real gtt size and play with those offsets.

--
Zbigniew

Quoted 6 lines
lib/intel_allocator.c +0 -0
 			req.open.end = gtt_size;
 		}
 
Signature · 1 line
2.25.1
#3 lore raw

[igt-dev] ✓ CI.xeBAT: success for lib/intel_allocator: Limit last page if not reserved

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: lib/intel_allocator: Limit last page if not reserved
URL : https://patchwork.freedesktop.org/series/123924/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7493_BAT -> XEIGTPW_9828_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (4 -> 4)
------------------------------

No changes in participating hosts

Known issues
------------

Here are the changes found in XEIGTPW_9828_BAT that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_addfb_basic@addfb25-x-tiled-legacy:
- bat-pvc-2: NOTRUN -> [SKIP][1] ([Intel XE#538]) +33 other tests skip
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@kms_cursor_legacy@basic-flip-after-cursor-atomic:
- bat-pvc-2: NOTRUN -> [SKIP][2] ([Intel XE#539]) +7 other tests skip
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@kms_flip@basic-flip-vs-dpms:
- bat-pvc-2: NOTRUN -> [SKIP][3] ([Intel XE#275] / [Intel XE#541]) +3 other tests skip
[3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@kms_flip@basic-flip-vs-wf_vblank@d-edp1:
- bat-adlp-7: [PASS][4] -> [FAIL][5] ([Intel XE#480]) +1 other test fail
[4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7493/bat-adlp-7/igt@kms_flip@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-adlp-7/igt@kms_flip@[email protected]

* igt@kms_force_connector_basic@force-connector-state:
- bat-pvc-2: NOTRUN -> [SKIP][6] ([Intel XE#540]) +3 other tests skip
[6]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-pvc-2: NOTRUN -> [SKIP][7] ([Intel XE#537]) +6 other tests skip
[7]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@kms_prop_blob@basic:
- bat-pvc-2: NOTRUN -> [SKIP][8] ([Intel XE#536])
[8]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@kms_psr@primary_page_flip:
- bat-pvc-2: NOTRUN -> [SKIP][9] ([Intel XE#535]) +2 other tests skip
[9]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@kms_psr@primary_page_flip.html

* igt@xe_evict@evict-beng-small-external:
- bat-pvc-2: NOTRUN -> [FAIL][10] ([Intel XE#389]) +3 other tests fail
[10]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@xe_evict@evict-small-cm:
- bat-pvc-2: NOTRUN -> [DMESG-FAIL][11] ([Intel XE#482]) +3 other tests dmesg-fail
[11]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@xe_exec_reset@virtual-close-fd-no-exec:
- bat-pvc-2: NOTRUN -> [DMESG-WARN][12] ([Intel XE#696])
[12]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@xe_guc_pc@freq_range_idle:
- bat-pvc-2: NOTRUN -> [SKIP][13] ([Intel XE#533]) +1 other test skip
[13]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@xe_guc_pc@freq_range_idle.html

* igt@xe_huc_copy@huc_copy:
- bat-pvc-2: NOTRUN -> [SKIP][14] ([Intel XE#255])
[14]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@xe_huc_copy@huc_copy.html

* igt@xe_intel_bb@render:
- bat-pvc-2: NOTRUN -> [SKIP][15] ([Intel XE#532])
[15]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@xe_live_ktest@migrate:
- bat-pvc-2: NOTRUN -> [SKIP][16] ([Intel XE#483]) +1 other test skip
[16]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

* igt@xe_pm_residency@gt-c6-on-idle:
- bat-pvc-2: NOTRUN -> [SKIP][17] ([Intel XE#531])
[17]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

#### Possible fixes ####

* igt@xe_module_load@load:
- bat-pvc-2: [INCOMPLETE][18] ([Intel XE#597]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7493/bat-pvc-2/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/bat-pvc-2/igt@[email protected]

[Intel XE#255]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/255
[Intel XE#275]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/275
[Intel XE#389]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/389
[Intel XE#480]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/480
[Intel XE#482]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/482
[Intel XE#483]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/483
[Intel XE#531]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/531
[Intel XE#532]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/532
[Intel XE#533]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/533
[Intel XE#535]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/535
[Intel XE#536]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/536
[Intel XE#537]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/537
[Intel XE#538]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/538
[Intel XE#539]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/539
[Intel XE#540]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/540
[Intel XE#541]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/541
[Intel XE#597]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/597
[Intel XE#696]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/696

Build changes
-------------

* IGT: IGT_7493 -> IGTPW_9828
* Linux: xe-376-9da40abcc0ccdf8fdfed4e21d76060bfcd35fe7d -> xe-383-fac2e20c785bd790c250e4f4799dfa28e44e7082

IGTPW_9828: 9828
IGT_7493: 2517e42d612e0c1ca096acf8b5f6177f7ef4bce7 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-376-9da40abcc0ccdf8fdfed4e21d76060bfcd35fe7d: 9da40abcc0ccdf8fdfed4e21d76060bfcd35fe7d xe-383-fac2e20c785bd790c250e4f4799dfa28e44e7082: fac2e20c785bd790c250e4f4799dfa28e44e7082

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9828/index.html

#4 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for lib/intel_allocator: Limit last page if not reserved

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: lib/intel_allocator: Limit last page if not reserved
URL : https://patchwork.freedesktop.org/series/123924/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13651 -> IGTPW_9828
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_9828 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_9828, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/index.html

Participating hosts (38 -> 35)
------------------------------

Additional (1): bat-rpls-2
Missing (4): bat-adlm-1 bat-atsm-1 fi-snb-2520m fi-pnv-d510

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_9828:

### IGT changes ###

#### Possible regressions ####

* igt@i915_module_load@load:
- bat-mtlp-8: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13651/bat-mtlp-8/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/bat-mtlp-8/igt@[email protected]

* igt@runner@aborted:
- bat-rpls-2: NOTRUN -> [FAIL][3]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/bat-rpls-2/igt@[email protected]

Known issues
------------

Here are the changes found in IGTPW_9828 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_parallel@engines@fds:
- bat-mtlp-6: [PASS][4] -> [ABORT][5] ([i915#9262])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13651/bat-mtlp-6/igt@gem_exec_parallel@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/bat-mtlp-6/igt@gem_exec_parallel@[email protected]

* igt@gem_exec_suspend@basic-s0@smem:
- bat-dg2-9: [PASS][6] -> [INCOMPLETE][7] ([i915#8797] / [i915#9275])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13651/bat-dg2-9/igt@gem_exec_suspend@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/bat-dg2-9/igt@gem_exec_suspend@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- fi-apl-guc: [PASS][8] -> [DMESG-FAIL][9] ([i915#5334])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13651/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html

#### Possible fixes ####

* igt@i915_selftest@live@execlists:
- fi-bsw-n3050: [ABORT][10] ([i915#7913]) -> [PASS][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13651/fi-bsw-n3050/igt@i915_selftest@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/fi-bsw-n3050/igt@i915_selftest@[email protected]

* igt@kms_chamelium_edid@hdmi-edid-read:
- {bat-dg2-13}: [DMESG-WARN][12] ([i915#7952]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13651/bat-dg2-13/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/bat-dg2-13/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#7952]: https://gitlab.freedesktop.org/drm/intel/issues/7952
[i915#8797]: https://gitlab.freedesktop.org/drm/intel/issues/8797
[i915#9262]: https://gitlab.freedesktop.org/drm/intel/issues/9262
[i915#9275]: https://gitlab.freedesktop.org/drm/intel/issues/9275

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_7493 -> IGTPW_9828

CI-20190529: 20190529
CI_DRM_13651: 61b71c3f061a44a6ab1dcf756918886aa03a5480 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_9828: 9828
IGT_7493: 2517e42d612e0c1ca096acf8b5f6177f7ef4bce7 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

Testlist changes
----------------

+igt@xe_mmio@mmio-invalid
+igt@xe_mmio@mmio-timestamp
+igt@xe_query@query-gts -igt@xe_exec_balancer@many-cm-parallel-basic -igt@xe_exec_balancer@many-cm-parallel-rebind -igt@xe_exec_balancer@many-cm-parallel-userptr -igt@xe_exec_balancer@many-cm-parallel-userptr-invalidate -igt@xe_exec_balancer@many-cm-parallel-userptr-invalidate-race -igt@xe_exec_balancer@many-cm-parallel-userptr-rebind -igt@xe_exec_balancer@many-execqueues-cm-parallel-basic -igt@xe_exec_balancer@many-execqueues-cm-parallel-rebind -igt@xe_exec_balancer@many-execqueues-cm-parallel-userptr -igt@xe_exec_balancer@many-execqueues-cm-parallel-userptr-invalidate -igt@xe_exec_balancer@many-execqueues-cm-parallel-userptr-invalidate-race -igt@xe_exec_balancer@many-execqueues-cm-parallel-userptr-rebind -igt@xe_exec_balancer@no-exec-cm-parallel-basic -igt@xe_exec_balancer@no-exec-cm-parallel-rebind -igt@xe_exec_balancer@no-exec-cm-parallel-userptr -igt@xe_exec_balancer@no-exec-cm-parallel-userptr-invalidate -igt@xe_exec_balancer@no-exec-cm-parallel-userptr-invalidate-race -igt@xe_exec_balancer@no-exec-cm-parallel-userptr-rebind -igt@xe_exec_balancer@once-cm-parallel-basic -igt@xe_exec_balancer@once-cm-parallel-rebind -igt@xe_exec_balancer@once-cm-parallel-userptr -igt@xe_exec_balancer@once-cm-parallel-userptr-invalidate -igt@xe_exec_balancer@once-cm-parallel-userptr-invalidate-race -igt@xe_exec_balancer@once-cm-parallel-userptr-rebind -igt@xe_exec_balancer@twice-cm-parallel-basic -igt@xe_exec_balancer@twice-cm-parallel-rebind -igt@xe_exec_balancer@twice-cm-parallel-userptr -igt@xe_exec_balancer@twice-cm-parallel-userptr-invalidate -igt@xe_exec_balancer@twice-cm-parallel-userptr-invalidate-race -igt@xe_exec_balancer@twice-cm-parallel-userptr-rebind -igt@xe_query@query-cs-cycles
-igt@xe_query@query-gt-list -igt@xe_query@query-invalid-cs-cycles

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9828/index.html