<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 8, 2017 at 12:24 AM, Iago Toral <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, 2017-03-07 at 10:31 +0200, Pohjolainen, Topi wrote:<br>
> On Tue, Mar 07, 2017 at 08:15:45AM +0100, Iago Toral Quiroga wrote:<br>
> ><br>
> > There are a number of work-in-progress CTS tests that check OOM<br>
> > handling<br>
> > and raised a number of issues that this series addresses.<br>
> ><br>
> > Particularly noteworthy is the case of command buffer recording:<br>
> > since the<br>
> > various vkCmd*() functions do not return errors, it is expected<br>
> > that drivers survive until vkEndCommanBuffer() and report any<br>
> > errors<br>
> > at that point. This requires that we are particularly careful with<br>
> > out of<br>
> > memory scenarios, since we need to make sure that vkCmd*() commands<br>
> > do not<br>
> > attempt to access memory that we have failed to allocate in a<br>
> > previous step.<br>
> > We achieve this by tracking errors generated during command buffer<br>
> > recording<br>
> > into the command buffer object and, generally, avoiding to execute<br>
> > new<br>
> > vkCmd*() functions if the command buffer recording has generated an<br>
> > error<br>
> > before. In general, I tried to  only guard execution of vkCmd*()<br>
> > commands that<br>
> > the tests showed needed to be guarded since most of the vkCmd*()<br>
> > commands are<br>
> > safe to execute in any scenario.<br>
> ><br>
> > This series fixes all the issues raised with the new tests and a<br>
> > few more that<br>
> > I found by inspection but I am sure we could do better in more<br>
> > places.<br>
> > It is a first step though and the tests are still in development.<br>
> ><br>
> > Iago Toral Quiroga (16):<br>
> >   blorp: handle out of memory in blorp_emitn()<br>
> >   blorp: handle out of memory without crashing in various batch<br>
> >     emissions<br>
> These two go sort of half way - blorp_exec() still ignores the return<br>
> values of blorp_emit_vertex_buffers() and<br>
> blorp_emit_vertex_elements().<br>
> Neither does blorp_emit_depth_stencil_<wbr>state() returning zero make<br>
> blorp_exec() to take any further action. <br>
<br>
</div></div>Right, I focused on avoiding the crashes only because there are a lot<br>
of other places where we do the same thing. Specifically, the<br>
blorp_emit() macro that we use all over the place, suffers from this<br>
same issue: it prevents the crash by avoiding the loop body to execute<br>
if we failed to allocate memory, but it does nothing to report the<br>
allocation failure back to its callers, so I figured it would not make<br>
sense to do something different for blorp_emitn().<br>
<br>
I am fine with being more robust here and try to address the problem<br>
more thoroughly if you think it makes sense, but if we are going to do<br>
that, then I think we would need to look beyond this macro and do a lot<br>
more changes. Do you want me to work on that?<br></blockquote><div><br></div><div>I'm not sure what you mean.  If blorp_emit calls blorp_emit_dwords which calls anv_batch_emit_dwords which handles OOM by setting anv_batch::status to VK_OUT_OF_DEVICE_MEMORY and returning NULL, then that should take care of almost everything.  We would also need anv_cmd_buffer_alloc_dynamic_state and anv_cmd_buffer_alloc_blorp_binding_table to do the right thing.  I really don't think this will require massive BLORP changes.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In any case, even if we agree on doing this, since these patches put<br>
blorp_emitn() at the same level as blorp_emit() and they solve some<br>
problems, would it be okay to land this series first and tackle that in<br>
a second series?<br>
<span class="HOEnZb"><font color="#888888"><br>
Iago<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> ><br>
> >   anv: don't crash if we fail to grow the reloc list<br>
> >   anv: handle out of memory situations in anv_batch_emit_dwords()<br>
> >   anv: do not try to ref/unref NULL shaders<br>
> >   anv/blorp: return early if we failed to create the shader binary<br>
> >   anv/cmd_buffer: return a VkResult in cmd_buffer_setup_attachments<br>
> >   anv/cmd_buffer: track error scenarios during command buffer<br>
> > recording<br>
> >   anv: handle out of memory scenarios in anv_batch_emit_batch()<br>
> >   anv/cmd_buffer: handle out of memory during vkCmdPushConstants<br>
> >   anv: handle out of memory situations during queue submissions<br>
> >   anv: ensure that we don't ever try to adjust relocations more<br>
> > than<br>
> >     once<br>
> >   anv/cmd_buffer: skip vkCmdDraw*() on broken command buffers<br>
> >   anv/cmd_buffer: skip vkCmdDispatch() on broken command buffers<br>
> >   anv/cmd_buffer: skip vkCmdExecuteCommands() on broken command<br>
> > buffers<br>
> >   anv/cmd_buffer: handle out of device memory during binding table<br>
> >     emission<br>
> ><br>
> >  src/intel/blorp/blorp_genX_<wbr>exec.h  | 25 ++++++++++-----<br>
> >  src/intel/vulkan/anv_batch_<wbr>chain.c | 45 +++++++++++++++++++-------<br>
> > -<br>
> >  src/intel/vulkan/anv_blorp.c <wbr>      |  3 ++<br>
> >  src/intel/vulkan/anv_cmd_<wbr>buffer.c  | 21 +++++++++++--<br>
> >  src/intel/vulkan/anv_private.<wbr>h     | 19 ++++++++++++<br>
> >  src/intel/vulkan/genX_cmd_<wbr>buffer.c | 63<br>
> > ++++++++++++++++++++++++++++++<wbr>++------<br>
> >  6 files changed, 142 insertions(+), 34 deletions(-)<br>
> ><br>
</div></div></blockquote></div><br></div></div>