[Intel-gfx] [PATCH] drm/i915: Expose a debugfs to acquire the BKL^Wstruct_mutex

Chris Wilson chris at chris-wilson.co.uk
Tue Aug 15 23:40:55 UTC 2017


To demonstrate how pervasive an issue our BKL is, aka struct_mutex,
provide a debugfs file whose sole purpose is to hold the struct_mutex.
To make matters worse, it does not even partake in the backoff required
for resets, so the likely event of holding the file open will be to
wedge the driver. Hopefully, this should prove instrumental in the
crusade to eradicate the BKL and transition to fine-grained locking and
much smoother multi-client behaviour.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Antonio Argenziano <antonio.argenziano at intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 329fb3649dc3..0af11dcca160 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -4709,6 +4709,27 @@ static const struct file_operations i915_forcewake_fops = {
 	.release = i915_forcewake_release,
 };
 
+static int BKL_struct_mutex_open(struct inode *inode, struct file *file)
+{
+	struct drm_i915_private *i915 = inode->i_private;
+
+	return mutex_lock_interruptible(&i915->drm.struct_mutex);
+}
+
+static int BKL_struct_mutex_release(struct inode *inode, struct file *file)
+{
+	struct drm_i915_private *i915 = inode->i_private;
+
+	mutex_unlock(&i915->drm.struct_mutex);
+	return 0;
+}
+
+static const struct file_operations BKL_struct_mutex_fops = {
+	.owner = THIS_MODULE,
+	.open = BKL_struct_mutex_open,
+	.release = BKL_struct_mutex_release,
+};
+
 static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data)
 {
 	struct drm_i915_private *dev_priv = m->private;
@@ -4879,6 +4900,12 @@ int i915_debugfs_register(struct drm_i915_private *dev_priv)
 	if (!ent)
 		return -ENOMEM;
 
+	ent = debugfs_create_file("BKL_struct_mutex", S_IRUSR,
+				  minor->debugfs_root, to_i915(minor->dev),
+				  &BKL_struct_mutex_fops);
+	if (!ent)
+		return -ENOMEM;
+
 	ret = intel_pipe_crc_create(minor);
 	if (ret)
 		return ret;
-- 
2.13.3



More information about the Intel-gfx mailing list