Quoting Prabhakaran, Krishna (2026-08-16 04:45:52)
> From: Krishna Prabhakaran <[email protected]>
> 
> When i915 needs to make an imported dma-buf coherent for GPU access on
> non-LLC platforms, or for objects that bypass LLC, it currently calls
> wbinvd_on_all_cpus(). get_pages() runs whenever an imported buffer is
> pinned, so this triggers a whole-cache write-back and invalidate,
> broadcast by IPI to every CPU, on every execbuf submission involving an
> imported dma-buf. That stalls the entire machine for milliseconds and
> starves latency-sensitive work on unrelated cores (e.g. USB isochronous
> audio serviced on the VMM's main thread).

No bug opened for issue, no exact hardware config described, no dmesg logs.

Also, if you import a new dma-buf too frequently, probably shouldn't do
that.

> Flush only the pages that actually need it instead:
> 
>  - If we imported one of our own dma-bufs, the backing object is
>    struct-page backed once migrated to SMEM, so flush it directly with
>    drm_clflush_sg(), exactly as we flush our other objects. This also
>    avoids re-entering the exporter through dma_buf_vmap(), which would
>    recurse into i915_gem_object_pin_map() on the source object we
>    already hold locked (and fails the igt_dmabuf_import_same_driver
>    selftest with -EBUSY).
> 
>  - For a foreign dma-buf the sg_table is not guaranteed to be backed by
>    struct pages, and the importer has no way to tell, so drm_clflush_sg()
>    cannot be used. vmap the buffer and flush that virtual range with
>    drm_clflush_virt_range() instead: x86 uses PIPT caches, so flushing
>    one virtual alias evicts the cache lines for every alias of the same
>    physical pages. The dma_resv lock required by dma_buf_vmap() is
>    already held here via the imported object.

You're literally echoing what code does or has in comments here. We can
see the code by looking at the code.

Please try to use less LLMs and use more of your own words for describing the
changes or writing comments.

Patch description could literally have been around two sentences about
reducing the amount of unnecessary flushing.

> Fall back to wbinvd only when the buffer cannot be vmapped or is backed
> by I/O memory, where there is no CPU-side range to clflush.
> 
> Fixes: a035154da45d ("drm/i915/dmabuf: add paranoid flush-on-acquire")

Definitely no Fixes tag for what is essentially an optimization.

Regards, Joonas

Reply via email to