<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 25, 2019 at 4:29 PM Chris Wilson <<a href="mailto:chris@chris-wilson.co.uk">chris@chris-wilson.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Quoting Jason Ekstrand (2019-10-25 19:22:04)<br>
> On Thu, Oct 24, 2019 at 6:40 AM Chris Wilson <<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a>> wrote:<br>
> <br>
> Our existing behaviour is to allow contexts and their GPU requests to<br>
> persist past the point of closure until the requests are complete. This<br>
> allows clients to operate in a 'fire-and-forget' manner where they can<br>
> setup a rendering pipeline and hand it over to the display server and<br>
> immediately exiting. As the rendering pipeline is kept alive until<br>
> completion, the display server (or other consumer) can use the results<br>
> in the future and present them to the user.<br>
> <br>
> However, not all clients want this persistent behaviour and would prefer<br>
> that the contexts are cleaned up immediately upon closure. This ensures<br>
> that when clients are run without hangchecking, any GPU hang is<br>
> terminated with the process and does not continue to hog resources.<br>
> <br>
> By defining a context property to allow clients to control persistence<br>
> explicitly, we can remove the blanket advice to disable hangchecking<br>
> that seems to be far too prevalent.<br>
> <br>
> <br>
> Just to be clear, when you say "disable hangchecking" do you mean disabling it<br>
> for all processes via a kernel parameter at boot time or a sysfs entry or<br>
> similar? Or is there some mechanism whereby a context can request no hang<br>
> checking?<br>
<br>
They are being told to use the module parameter i915.enable_hangcheck=0<br>
to globally disable hangchecking. This is what we are trying to wean<br>
them off, and yet still allow indefinitely long kernels. The softer<br>
hangcheck is focused on if you block scheduling or preemption of higher<br>
priority work, then you are forcibly removed from the GPU. However, even<br>
that is too much for some workloads, where they really do expect to<br>
permanently hog the GPU. (All I can say is that they better be dedicated<br>
systems because if you demand interactivity on top of disabling<br>
preemption...)<br></blockquote><div><br></div><div>Ok, thinking out loud here (no need for you to respond): Why should we take this approach? It seems like there are several other ways we could solve this:</div><div><br></div><div> 1. Have a per-context flag (that's what we did here)</div><div> 2. Have a per-execbuf flag for "don't allow this execbuf to outlive the process".</div><div> 3. Have a DRM_IOCTL_I915_KILL_CONTEXT which lets the client manually kill the context</div><div><br></div><div>Option 2 seems like a lot more work in i915 and it doesn't seem that advantageous. Most drivers are going to either want their batches to outlive them or not; they aren't going to be making that decision on a per-batch basis.</div><div><br></div><div>Option 3 would work for some cases but it doesn't let the kernel terminate work if the client is killed unexpectedly by, for instance a segfault. The client could try to insert a crash handler but calling a DRM ioctl from a crash handler sounds like a bad plan. On the other hand, the client can just as easily implement 3 by setting the new context flag and then calling GEM_CONTEXT_DESTROY.</div><div><br></div><div>With that, I think I'm convinced that a context param is the best way to do this. We may even consider using it in Vulkan when running headless to let us kill stuff quicker. We aren't seeing any long-running Vulkan compute workloads yet but they may be coming.</div><div><br></div><div>Acked-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></div><div><br></div><div><br></div><div>One more question: Does this bit fully support being turned on and off or is it a set-once? I ask because how I'd likely go about doing this in Vulkan would be to set it on context create and then unset it the moment we see a buffer shared with the outside world.</div><div><br></div><div>--Jason<br></div></div></div>