Thread (21 messages) 21 messages, 5 authors, 1d ago

Re: [RFC PATCH net-next 08/13] drm/amdkfd: add GPU instruction emitter and disassembler

From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-07-20 20:53:32
Also in: amd-gfx, bpf, dri-devel, linux-hardening, linux-kselftest, linux-media, linux-rdma, lkml, llvm

On Mon, Jul 20, 2026 at 10:05:33PM +0200, Natalie Vock wrote:
On 7/19/26 19:58, Taehee Yoo wrote:
quoted
Add the AMD GCN (gfx9/gfx10) instruction encoder used to build the GPU
shaders that knod dispatches, plus a matching disassembler used for
debugging the generated code.
Is it really necessary to have a full-on compiler and disassembler in the
kernel driver? This patch is massive and I'm wondering how much benefit it
really provides. Is there really no way to move GPU compilation out of the
kernel, one way or another? Could you get acceptable perf with a static
shader that interprets BPF programs at runtime? Such a shader can be
compiled beforehand and just embedded into the kernel - there's prior art
there with the CWSR trap handler in amdkfd.

In case you really, really need to compile the BPF to native ISA, could you
still have userspace take care of that in one way or another?
There was a long and painful discussion about P4, and offloading it to
hardware. The proponents of that wanted to do the compilation stage in
user space to produce a binary blob, but it was hard to prove that the
P4 passed to the kernel for software processing, and the binary blob
passed to the hardware actually where the same. It opened up the path
for closed source P4 where the kernel never got to see the actual P4
code. So it was not really offload, but kernel bypass.

So having a compiler in the kernel is probably the correct way to go,
if you want to be friendly to open source.

The other option is to get the GPU to do the compilation itself, so
you pass BPF byte codes to the GPU and it generates its own native
code. I've no idea if that is possible, but clang can target OpenMP,
so maybe it is possible to move this compiler into the GPU?

      Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help