public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: obitton@habana.ai
Cc: Oded Gabbay <ogabbay@kernel.org>, kernel-janitors@vger.kernel.org
Subject: [bug report] habanalabs: replace GFP_ATOMIC with GFP_KERNEL
Date: Fri, 13 Aug 2021 15:38:24 +0300	[thread overview]
Message-ID: <20210813123824.GA6307@kili> (raw)

Hello Ofir Bitton,

The patch d5eb8373b2ce: "habanalabs: replace GFP_ATOMIC with
GFP_KERNEL" from Feb 14, 2021, leads to the following
Smatch static checker warning:

	drivers/misc/habanalabs/common/command_buffer.c:318 hl_cb_create()
	warn: sleeping in atomic context

drivers/misc/habanalabs/common/command_buffer.c
    311 		if (rc)
    312 			goto release_cb;
    313 	}
    314 
    315 	spin_lock(&mgr->cb_lock);
                          ^^^^^^^^^^^^^
    316 	rc = idr_alloc(&mgr->cb_handles, cb, 1, 0, GFP_ATOMIC);
    317 	if (rc < 0)
--> 318 		rc = idr_alloc(&mgr->cb_handles, cb, 1, 0, GFP_KERNEL);
                                                                   ^^^^^^^^^^
This falls back to GFP_KERNEL if GFP_ATOMIC fails.  I don't understand
that.  If it's at all a performance improvement to call idr_alloc() with
ATOMIC first, then the correct thing to do is to fix idr_alloc() instead
of working around it in the caller.

    319 	spin_unlock(&mgr->cb_lock);
    320 

The other warning is also idr_alloc() but holding a different spin lock.

	drivers/misc/habanalabs/common/memory.c:126 alloc_device_memory()
	warn: sleeping in atomic context

   124  
   125          spin_lock(&vm->idr_lock);
                ^^^^^^^^^^^^^^^^^^^^^^^^
   126          handle = idr_alloc(&vm->phys_pg_pack_handles, phys_pg_pack, 1, 0,
   127                                  GFP_KERNEL);
                                        ^^^^^^^^^^
   128          spin_unlock(&vm->idr_lock);
   129  
   130          if (handle < 0) {
   131                  dev_err(hdev->dev, "Failed to get handle for page\n");
   132                  rc = -EFAULT;
   133                  goto idr_err;
   134          }

regards,
dan carpenter

             reply	other threads:[~2021-08-13 12:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 12:38 Dan Carpenter [this message]
2021-08-14 19:50 ` [bug report] habanalabs: replace GFP_ATOMIC with GFP_KERNEL Ofir Bitton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210813123824.GA6307@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=obitton@habana.ai \
    --cc=ogabbay@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox