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

+4 -1
View File
@@ -8,7 +8,9 @@
*
* O_DIRECT requires the file offset, transfer length and buffer address to be block-aligned.
* rad_dev_alloc memory is (host.cpp) and .rad pads movement units to RAD_ALIGN_UNIT
* (rad_format.h), so every mover read takes the unbounced path. The bounce is for other callers.
* (rad_format.h), so every mover read takes the unbounced path. The bounce is for other callers,
* and for pinned memory O_DIRECT cannot target (EFAULT: a GPU driver's own mapping, such as the
* SYCL backend's malloc_host), which is bounced whole.
*/
#pragma once
#include <atomic>
@@ -63,6 +65,7 @@ public:
private:
int bounce_ready();
int bounce_read(void* dst, int64_t off, int64_t bytes);
int fd_ = -1;
bool direct_ = false;