sycl: keep the device out of plain system memory

On kernel 7.0 the xe driver can oops (drm_pagemap_zdd_destroy from
__drm_pagemap_migrate_to_ram) when the CPU faults on a page its shared
virtual memory had migrated into VRAM. The backend reached plain system
memory in several ways; each now uses USM the runtime knows:

- RAD_MEM_HOST_PINNED/_MAPPED are sycl::aligned_alloc_host, not
  posix_memalign + prepare_for_device_copy. O_DIRECT cannot target those
  pages (EFAULT), so DirectFile bounces such transfers through an 8 MiB
  buffer. The 27B load is not slower (10.8 s read, disk-bound).
- Copies with a pageable side are staged through a host-USM bounce,
  synchronously (rare: startup and tests). The ranged copy stages a host
  range list even when its source is on the card, and refuses a pageable
  destination, which its kernel would write.
- scatter_rows' bad-index flag is host USM, not shared.
- Gates are gone (the documented state): a spinning kernel never sees a
  host store to host USM, and a device flag opened by a copy from another
  queue deadlocks behind copies queued past the gate. rad-kbench times
  ungated; the gate tests skip on backends without gates.

Checked: device_test (sycl) 70 cases, 0 failed; rad-kbench fixture
1989/1989; 27B int4 chat output byte-identical (c4c5ba5e727c) at
30.6 tok/s; no xe messages in the kernel log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
aneinanderandClaude Opus 5.5 committed 2026-11-18 17:56:05 +01:00
1 parent 4b70a96378
commit 8931aae8b2
5 files changed
+171 -143

No files matched your search

+3
View File
@@ -1414,6 +1414,7 @@ TEST(a_host_sync_on_an_event_not_made_for_it_is_refused) {
* copy land well inside 20 ms. */
TEST(nothing_behind_a_closed_gate_runs_until_it_opens) {
Stream st;
if (rad_gate_room(st.s) <= 0) SKIP("no gates on this backend");
DevBuf<uint8_t> src(4096, RAD_MEM_HOST_PINNED);
DevBuf<uint8_t> dst(4096, RAD_MEM_HOST_PINNED);
REQUIRE(src && dst);
@@ -1494,6 +1495,7 @@ TEST(a_dma_lists_mark_stays_out_of_the_pool_until_the_engine_has_read_it) {
* is refused with RAD_E_STATE instead of hanging, and works again once the gate is open. */
TEST(a_host_wait_on_a_gated_stream_is_refused_not_a_deadlock) {
Stream st;
if (rad_gate_room(st.s) <= 0) SKIP("no gates on this backend");
void* gate = nullptr;
REQUIRE_EQ(rad_stream_gate(st.s, &gate), RAD_OK);
CHECK_EQ(rad_stream_sync(st.s), RAD_E_STATE);
@@ -1538,6 +1540,7 @@ TEST(a_full_gated_queue_refuses_the_next_submission_instead_of_waiting) {
* with one it is not. Timing is the behaviour here, and the margins are an order of magnitude. */
TEST(events_behind_a_gate_leave_the_hosts_submission_time_out) {
Stream st;
if (rad_gate_room(st.s) <= 0) SKIP("no gates on this backend");
DevBuf<uint8_t> a(4096, RAD_MEM_DEVICE);
REQUIRE(a);
Event e0, e1;