[igt-dev] [PATCH i-g-t v2] lib: Add GPU power measurement
Chris Wilson
chris at chris-wilson.co.uk
Tue Mar 26 10:06:25 UTC 2019
Quoting Tvrtko Ursulin (2019-03-26 09:52:05)
>
> On 26/03/2019 09:18, Chris Wilson wrote:
> > +static int rapl_parse(struct rapl *r)
> > +{
> > + locale_t locale, oldlocale;
> > + int dir;
> > +
> > + dir = open("/sys/devices/power", O_RDONLY);
> > + if (dir < 0)
> > + return -errno;
> > +
> > + /* Replace user environment with plain C to match kernel format */
> > + locale = newlocale(LC_ALL, "C", 0);
> > + oldlocale = uselocale(locale);
> > +
> > + memset(r, 0, sizeof(*r));
> > + igt_sysfs_scanf(dir, "type", "%"PRIu64, &r->type);
> > + igt_sysfs_scanf(dir, "events/energy-gpu", "event=%"PRIx64, &r->power);
> > + igt_sysfs_scanf(dir, "events/energy-gpu.scale", "%lf", &r->scale);
>
> Check return codes?
I was being lazy and hoping r->scale sorted that all out.
-Chris
More information about the igt-dev
mailing list