<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hi Rodrigo,<br>
    </p>
    <div class="moz-cite-prefix">On 6/26/2024 5:24 PM, Rodrigo Vivi
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:ZnwylM64-5HqQr4R@intel.com">
      <pre class="moz-quote-pre" wrap="">On Wed, Jun 26, 2024 at 04:33:18PM +0200, Nirmoy Das wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">We report object allocation failures to userspace with ENOMEM
so add __GFP_NOWARN to remove superfluous oom warnings.

Closes: <a class="moz-txt-link-freetext" href="https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4936">https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4936</a>
Cc: Andi Shyti <a class="moz-txt-link-rfc2396E" href="mailto:andi.shyti@linux.intel.com"><andi.shyti@linux.intel.com></a>
Signed-off-by: Nirmoy Das <a class="moz-txt-link-rfc2396E" href="mailto:nirmoy.das@intel.com"><nirmoy.das@intel.com></a>
---
 drivers/gpu/drm/i915/i915_scatterlist.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_scatterlist.c b/drivers/gpu/drm/i915/i915_scatterlist.c
index e93d2538f298..4d830740946d 100644
--- a/drivers/gpu/drm/i915/i915_scatterlist.c
+++ b/drivers/gpu/drm/i915/i915_scatterlist.c
@@ -90,7 +90,7 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
 
        GEM_BUG_ON(!max_segment);
 
-       rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL);
+       rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL | __GFP_NOWARN);
        if (!rsgt)
                return ERR_PTR(-ENOMEM);
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
is it really safe?
I don't believe we can guarantee a good fallback plan here if allocation fails.
__i915_refct_sgt_init
might end up in a null dereference, no?!</pre>
    </blockquote>
    <p>Kernel is now returning  <span style="white-space: pre-wrap">ENOMEM and also throwing a oom warning stack. With </span><span style="white-space: pre-wrap">__GFP_NOWARN</span></p>
    <p><span style="white-space: pre-wrap">the oom warning stack won't be  there in the dmesg but userspace will still get </span><span style="white-space: pre-wrap">ENOMEM as expected.</span></p>
    <p><span style="white-space: pre-wrap">Let me know if got your question correctly.</span></p>
    <p><span style="white-space: pre-wrap">
</span></p>
    <p><span style="white-space: pre-wrap">Regards,</span></p>
    <p><span style="white-space: pre-wrap">Nirmoy
</span></p>
    <p><span style="white-space: pre-wrap"> 
</span></p>
    <blockquote type="cite" cite="mid:ZnwylM64-5HqQr4R@intel.com">
      <pre class="moz-quote-pre" wrap="">

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap=""> 
@@ -104,7 +104,7 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
        }
 
        if (sg_alloc_table(st, DIV_ROUND_UP_ULL(node->size, segment_pages),
-                          GFP_KERNEL)) {
+                          GFP_KERNEL | __GFP_NOWARN)) {
                i915_refct_sgt_put(rsgt);
                return ERR_PTR(-ENOMEM);
        }
@@ -178,7 +178,7 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
        GEM_BUG_ON(list_empty(blocks));
        GEM_BUG_ON(!max_segment);
 
-       rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL);
+       rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL | __GFP_NOWARN);
        if (!rsgt)
                return ERR_PTR(-ENOMEM);
 
@@ -190,7 +190,7 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
                return ERR_PTR(-E2BIG);
        }
 
-       if (sg_alloc_table(st, PFN_UP(res->size), GFP_KERNEL)) {
+       if (sg_alloc_table(st, PFN_UP(res->size), GFP_KERNEL | __GFP_NOWARN)) {
                i915_refct_sgt_put(rsgt);
                return ERR_PTR(-ENOMEM);
        }
-- 
2.42.0

</pre>
      </blockquote>
    </blockquote>
  </body>
</html>