From: Ben Widawsky <ben@bwidawsk.net>
To: Chad Versace <chad.versace@linux.intel.com>
Cc: Intel GFX <intel-gfx@lists.freedesktop.org>,
Bryan Bell <bryan.j.bell@intel.com>
Subject: Re: [PATCH 1/2] intel_get_llc_size: Small tool to query LLC size
Date: Fri, 12 Jul 2013 10:49:57 -0700 [thread overview]
Message-ID: <20130712174957.GD15384@bwidawsk.net> (raw)
In-Reply-To: <51E03F67.6030002@linux.intel.com>
On Fri, Jul 12, 2013 at 10:39:51AM -0700, Chad Versace wrote:
> On 07/11/2013 11:53 AM, Ben Widawsky wrote:
> >v2: Use the new param
> >
> >CC: Chad Versace <chad.versace@linux.intel.com>
> >CC: Bryan Bell <bryan.j.bell@intel.com>
> >Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> >---
> > tools/Makefile.am | 1 +
> > tools/intel_get_llc_size.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 59 insertions(+)
> > create mode 100644 tools/intel_get_llc_size.c
> >
> >diff --git a/tools/Makefile.am b/tools/Makefile.am
> >index 2519169..a064b65 100644
> >--- a/tools/Makefile.am
> >+++ b/tools/Makefile.am
> >@@ -9,6 +9,7 @@ bin_PROGRAMS = \
> > intel_bios_dumper \
> > intel_bios_reader \
> > intel_error_decode \
> >+ intel_get_llc_size \
> > intel_gpu_top \
> > intel_gpu_time \
> > intel_gtt \
> >diff --git a/tools/intel_get_llc_size.c b/tools/intel_get_llc_size.c
> >new file mode 100644
> >index 0000000..498e252
> >--- /dev/null
> >+++ b/tools/intel_get_llc_size.c
> >@@ -0,0 +1,58 @@
> >+/*
> >+ * Copyright © 2013 Intel Corporation
> >+ *
> >+ * Permission is hereby granted, free of charge, to any person obtaining a
> >+ * copy of this software and associated documentation files (the "Software"),
> >+ * to deal in the Software without restriction, including without limitation
> >+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> >+ * and/or sell copies of the Software, and to permit persons to whom the
> >+ * Software is furnished to do so, subject to the following conditions:
> >+ *
> >+ * The above copyright notice and this permission notice (including the next
> >+ * paragraph) shall be included in all copies or substantial portions of the
> >+ * Software.
> >+ *
> >+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> >+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> >+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> >+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> >+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> >+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> >+ * DEALINGS IN THE SOFTWARE.
> >+ *
> >+ */
> >+
> >+#include <sys/ioctl.h>
> >+#include "drmtest.h"
> >+#include "i915_drm.h"
> >+
> >+#define LOCAL__I915_PARAM_LLC_SIZE 27
> >+static int get_llc_size(int fd)
> >+{
> >+ struct drm_i915_getparam gp;
> >+ int size;
> >+
> >+ gp.param = LOCAL__I915_PARAM_LLC_SIZE;
> >+ gp.value = &size;
> >+
> >+ if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
> >+ return 0;
> >+
> >+ return size;
> >+}
> >+
> >+int main(int argc, char **argv)
> >+{
> >+ int size, fd = drm_open_any();
> >+
> >+ size = get_llc_size(fd);
> >+
> >+ if (size == 0)
> >+ fprintf(stdout, "Doesn't have LLC\n");
> >+ else if (size == 1)
> >+ fprintf(stdout, "Kernel is too old to determine LLC size\n");
> >+ else
> >+ fprintf(stdout, "LLC size = %dK\n", size>>10);
>
> This if-tree looks wrong. If the kernel doesn't know about I915_PARAM_LLC_SIZE,
> the ioctl returns -1, and get_llc_size() returns 0, and the if-tree prints the
> wrong error.
>
> How about making get_llc_size() return -1 on error? Or am I missing something here?
>
Looks like the tool needed updating after the last param change and I
missed it. It should have been correct before (though in the case of no
HAS_LLC param it was also bad). Your suggestion is the right thing to do.
If Daniel decides to merge the kernel patch, I will fix this.
>
> >+
> >+ return 0;
> >+}
> >
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2013-07-12 17:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-10 2:58 [PATCH] drm/i915: Expose LLC size to user space Ben Widawsky
2013-07-10 2:58 ` [PATCH] intel_get_llc_size: Small tool to query LLC size Ben Widawsky
2013-07-10 6:34 ` Daniel Vetter
2013-07-10 16:58 ` Ben Widawsky
2013-07-10 17:15 ` Daniel Vetter
2013-07-10 17:24 ` Ben Widawsky
2013-07-10 17:45 ` Daniel Vetter
2013-07-10 8:59 ` [PATCH] drm/i915: Expose LLC size to user space Chris Wilson
2013-07-10 16:40 ` Ben Widawsky
2013-07-10 17:11 ` Ben Widawsky
2013-07-10 17:40 ` Chris Wilson
2013-07-10 17:46 ` Ben Widawsky
2013-07-10 18:00 ` Chris Wilson
2013-07-10 18:44 ` Ben Widawsky
2013-07-10 17:00 ` Bell, Bryan J
2013-07-11 0:16 ` Chad Versace
2013-07-11 5:06 ` Ben Widawsky
2013-07-11 18:52 ` [PATCH] [v2] " Ben Widawsky
2013-07-11 18:53 ` [PATCH 1/2] intel_get_llc_size: Small tool to query LLC size Ben Widawsky
2013-07-11 18:53 ` [PATCH 2/2] tests: Basic tools tester Ben Widawsky
2013-07-12 17:39 ` [PATCH 1/2] intel_get_llc_size: Small tool to query LLC size Chad Versace
2013-07-12 17:49 ` Ben Widawsky [this message]
2013-07-11 20:46 ` [PATCH] [v2] drm/i915: Expose LLC size to user space Chris Wilson
2013-07-12 17:38 ` Chad Versace
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=20130712174957.GD15384@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=bryan.j.bell@intel.com \
--cc=chad.versace@linux.intel.com \
--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