From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 11/15] drm/i915: debugfs entries for scheduler params
Date: Fri, 18 Nov 2011 18:24:28 -0800 [thread overview]
Message-ID: <1321669472-8045-12-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1321669472-8045-1-git-send-email-ben@bwidawsk.net>
Using the i915 client list we can easily read and set the various
parameters.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/gpu/drm/i915/i915_debugfs.c | 138 +++++++++++++++++++++++++++++++++++
1 files changed, 138 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 59b9f22..790875d 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1543,6 +1543,136 @@ static const struct file_operations i915_cache_sharing_fops = {
.llseek = default_llseek,
};
+static ssize_t
+i915_sched_read(struct file *filp,
+ char __user *ubuf,
+ size_t max,
+ loff_t *ppos)
+{
+ struct drm_device *dev = filp->private_data;
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ struct drm_i915_file_private *temp;
+ unsigned high, low;
+ size_t len = 0;
+ char *buf, *buf2;
+ struct {
+ pid_t pid;
+ int outstanding;
+ int forced;
+ int high;
+ int low;
+ } requests[20];
+ int entries, entry_size, i = 0, ret = 0;
+
+ if (!i915_scheduler)
+ return 0;
+
+ ret = mutex_lock_interruptible(&dev->struct_mutex);
+ if (ret)
+ return ret;
+
+ high = dev_priv->scheduler.high_watermark;
+ low = dev_priv->scheduler.low_watermark;
+ list_for_each_entry(temp, &dev_priv->i915_client_list, client_link) {
+ struct drm_file *file = temp->drm_file;
+ requests[i].pid = file->pid;
+ spin_lock(&temp->lock);
+ requests[i].outstanding = temp->outstanding_requests;
+ requests[i].forced = temp->forced_throttles;
+ spin_unlock(&temp->lock);
+ i++;
+ }
+ mutex_unlock(&dev->struct_mutex);
+
+ entries = i;
+
+ entry_size = strlen("pid 123456 = XXXX outstanding (XXXXXX forced)\n") + 1;
+ buf2 = drm_malloc_ab(entries, entry_size);
+ memset(buf2, 0, entries * entry_size);
+ for(i = 0; i < entries; i++) {
+ len += sprintf(buf2 + len,
+ "pid %06d = %06d outstanding (%06d forced)\n",
+ requests[i].pid, requests[i].outstanding,
+ requests[i].forced);
+ }
+
+ buf = kasprintf(GFP_KERNEL, "%s\n"
+ "Scheduler = %s\n"
+ "High watermark = %d buffers\n"
+ "Low watermark = %d buffers\n",
+ buf2, "fair", high, low);
+
+ len = strlen(buf);
+
+ ret = simple_read_from_buffer(ubuf, max, ppos, buf, len);
+
+ drm_free_large(buf2);
+ kfree(buf);
+ return ret;
+}
+
+static ssize_t
+i915_sched_write(struct file *filp,
+ const char __user *ubuf,
+ size_t cnt,
+ loff_t *ppos)
+{
+ struct drm_device *dev = filp->private_data;
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ char *buf, *ptr;
+ uint32_t high, low;
+ int ret;
+
+ buf = drm_malloc_ab(cnt + 1, 1);
+ if (!buf)
+ return -E2BIG;
+
+ ret = copy_from_user(buf, ubuf, cnt);
+ if (ret)
+ goto out;
+
+ ret = mutex_lock_interruptible(&dev->struct_mutex);
+ if (ret)
+ return ret;
+
+ low = dev_priv->scheduler.low_watermark;
+ high = dev_priv->scheduler.high_watermark;
+
+ buf[cnt] = 0;
+ ptr = buf;
+
+ while ((ptr != NULL) && *ptr != 0) {
+ if (!strncmp(ptr, "high=", 5))
+ high = simple_strtoul(ptr + 5, NULL, 0);
+ if (!strncmp(ptr, "low=", 4))
+ low = simple_strtoul(ptr + 4, NULL, 0);
+ ptr = strchr(ptr, ',');
+ if (ptr != NULL)
+ ptr += strspn(ptr, ", \t\n");
+ }
+
+ if (high != dev_priv->scheduler.high_watermark ||
+ low != dev_priv->scheduler.low_watermark) {
+ DRM_INFO("new high = %d\n", high);
+ DRM_INFO("new low = %d\n", low);
+ dev_priv->scheduler.high_watermark = high;
+ dev_priv->scheduler.low_watermark = low;
+ }
+
+ mutex_unlock(&dev->struct_mutex);
+out:
+ drm_free_large(buf);
+ return cnt;
+}
+
+static const struct file_operations i915_scheduler_fops = {
+ .owner = THIS_MODULE,
+ .open = i915_debugfs_common_open,
+ .read = i915_sched_read,
+ .write = i915_sched_write,
+};
+
+
/* As the drm_debugfs_init() routines are called before dev->dev_private is
* allocated we need to hook into the minor for release. */
static int
@@ -1712,6 +1842,12 @@ int i915_debugfs_init(struct drm_minor *minor)
if (ret)
return ret;
+ ret = i915_debugfs_create(minor->debugfs_root, minor,
+ "i915_scheduler",
+ &i915_scheduler_fops);
+ if (ret)
+ return ret;
+
return drm_debugfs_create_files(i915_debugfs_list,
I915_DEBUGFS_ENTRIES,
minor->debugfs_root, minor);
@@ -1729,6 +1865,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor)
1, minor);
drm_debugfs_remove_files((struct drm_info_list *) &i915_cache_sharing_fops,
1, minor);
+ drm_debugfs_remove_files((struct drm_info_list *) &i915_scheduler_fops,
+ 1, minor);
}
#endif /* CONFIG_DEBUG_FS */
--
1.7.7.3
next prev parent reply other threads:[~2011-11-19 2:25 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-19 2:24 [PATCH 00/15] [RFC] Forced throttling/scheduling Ben Widawsky
2011-11-19 2:24 ` [PATCH 01/15] drm/i915: refactor debugfs open function Ben Widawsky
2011-11-20 18:50 ` Kenneth Graunke
2011-11-19 2:24 ` [PATCH 02/15] drm/i915: refactor debugfs create functions Ben Widawsky
2011-11-19 2:24 ` [PATCH 03/15] drm/i915: relative_constants_mode race fix Ben Widawsky
2011-11-23 22:30 ` Ben Widawsky
2011-11-19 2:24 ` [PATCH 04/15] drm/i915: drop lock support for i915_wait_request Ben Widawsky
2011-11-19 2:24 ` [PATCH 05/15] drm/i915: remove mm structure from file_priv Ben Widawsky
2011-11-19 2:24 ` [PATCH 06/15] drm/i915: Keep track of drm_file in file_priv Ben Widawsky
2011-11-19 2:24 ` [PATCH 07/15] drm/i915: Keep track of request counts Ben Widawsky
2011-11-19 2:24 ` [PATCH 08/15] drm/i915: fairness Ben Widawsky
2011-11-19 2:24 ` [PATCH 09/15] drm/i915: Keep track of open i915 clients Ben Widawsky
2011-11-19 2:24 ` [PATCH 10/15] drm/i915: debugfs entry for " Ben Widawsky
2011-11-19 2:24 ` Ben Widawsky [this message]
2011-11-19 2:24 ` [PATCH 12/15] drm/i915: infrastructure to support scheduler types Ben Widawsky
2011-11-19 2:24 ` [PATCH 13/15] drm/i915: get/set scheduler type from debugfs Ben Widawsky
2011-11-19 2:24 ` [PATCH 14/15] drm/i915: Implement batch scheduler Ben Widawsky
2011-11-19 2:24 ` [PATCH 15/15] drm/i915: Add handling for batch parameters in debugfs Ben Widawsky
2011-11-29 14:30 ` [PATCH 00/15] [RFC] Forced throttling/scheduling Eugeni Dodonov
2012-04-02 18:28 ` Ben Widawsky
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=1321669472-8045-12-git-send-email-ben@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.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;
as well as URLs for NNTP newsgroup(s).