The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Chris Wilson <chris@chris-wilson.co.uk>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: drivers/gpu/drm/i915/gem/i915_gem_throttle.c:59 i915_gem_throttle_ioctl() error: double locked 'ctx->engines_mutex' (orig line 59)
Date: Mon, 16 Nov 2020 13:08:38 +0300	[thread overview]
Message-ID: <20201116100837.GA29398@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   0062442ecfef0d82cd69e3e600d5006357f8d8e4
commit: 27a5dcfe73f4b696b3de8c23a560199bb1c193a4 drm/i915/gem: Remove disordered per-file request list for throttling
config: i386-randconfig-m021-20201115 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/i915/gem/i915_gem_throttle.c:59 i915_gem_throttle_ioctl() error: double locked 'ctx->engines_mutex' (orig line 59)

vim +59 drivers/gpu/drm/i915/gem/i915_gem_throttle.c

    35  int
    36  i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
    37                          struct drm_file *file)
    38  {
    39          const unsigned long recent_enough = jiffies - DRM_I915_THROTTLE_JIFFIES;
    40          struct drm_i915_file_private *file_priv = file->driver_priv;
    41          struct i915_gem_context *ctx;
    42          unsigned long idx;
    43          long ret;
    44  
    45          /* ABI: return -EIO if already wedged */
    46          ret = intel_gt_terminally_wedged(&to_i915(dev)->gt);
    47          if (ret)
    48                  return ret;
    49  
    50          rcu_read_lock();
    51          xa_for_each(&file_priv->context_xa, idx, ctx) {
    52                  struct i915_gem_engines_iter it;
    53                  struct intel_context *ce;
    54  
    55                  if (!kref_get_unless_zero(&ctx->ref))
    56                          continue;
    57                  rcu_read_unlock();
    58  
    59                  for_each_gem_engine(ce,
    60                                      i915_gem_context_lock_engines(ctx),
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I don't understand why this takes the lock every iteration through the
loop

    61                                      it) {
    62                          struct i915_request *rq, *target = NULL;
    63  
    64                          if (!ce->timeline)
    65                                  continue;
    66  
    67                          mutex_lock(&ce->timeline->mutex);
    68                          list_for_each_entry_reverse(rq,
    69                                                      &ce->timeline->requests,
    70                                                      link) {
    71                                  if (i915_request_completed(rq))
    72                                          break;
    73  
    74                                  if (time_after(rq->emitted_jiffies,
    75                                                 recent_enough))
    76                                          continue;
    77  
    78                                  target = i915_request_get(rq);
    79                                  break;
    80                          }
    81                          mutex_unlock(&ce->timeline->mutex);
    82                          if (!target)
    83                                  continue;
    84  
    85                          ret = i915_request_wait(target,
    86                                                  I915_WAIT_INTERRUPTIBLE,
    87                                                  MAX_SCHEDULE_TIMEOUT);
    88                          i915_request_put(target);
    89                          if (ret < 0)
    90                                  break;
    91                  }
    92                  i915_gem_context_unlock_engines(ctx);

But only unlocks the last element

    93                  i915_gem_context_put(ctx);
    94  
    95                  rcu_read_lock();
    96          }
    97          rcu_read_unlock();
    98  
    99          return ret < 0 ? ret : 0;
   100  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 45384 bytes --]

             reply	other threads:[~2020-11-16 10:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 10:08 Dan Carpenter [this message]
2020-11-16 10:15 ` drivers/gpu/drm/i915/gem/i915_gem_throttle.c:59 i915_gem_throttle_ioctl() error: double locked 'ctx->engines_mutex' (orig line 59) Chris Wilson
2020-11-16 10:44   ` Dan Carpenter

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=20201116100837.GA29398@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=tvrtko.ursulin@intel.com \
    /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