[Mesa-dev] [PATCH 1/2] RFC i965: Bypass a couple of libraries for syscall on x84_64

Jason Ekstrand jason at jlekstrand.net
Mon Jun 19 16:41:13 UTC 2017


On Mon, Jun 19, 2017 at 7:43 AM, Chris Wilson <chris at chris-wilson.co.uk>
wrote:

> Quoting Eric Engestrom (2017-06-19 15:30:46)
> > On Monday, 2017-06-19 13:02:11 +0100, Chris Wilson wrote:
> > > Quoting Emil Velikov (2017-06-19 12:43:42)
> > > > Hi Chris,
> > > >
> > > > On 19 June 2017 at 12:32, Chris Wilson <chris at chris-wilson.co.uk>
> wrote:
> > > > > On linux/x86_64, calling into the kernel is just a single
> instruction
> > > > > with the parameters passed via registers. We can therefre
> shortcircuit a
> > > > > couple of library indirections around ioctl() which as much as the
> > > > > switch into the kernel itself. Aside from the PLT indirection,
> libc's
> > > > > ioctl() has a slight impedance mismatch with the kernel interface
> in
> > > > > that it converts the -errno return into -1 + errno, which we
> immediately
> > > > > convert back into -errno for ourselves!
> > > > >
> > > > Did you measure any performance difference with this patch/series?
> > > > If so, please include the numbers in the commit message.
> > >
> > > Realistically you are not going to observe any performance improvement.
> > > The only time when there is non-negligible time inside the
> drmIoct/ioctl
> > > library functions is when the client is doing a busy-spin waiting for
> > > results from the GPU. All this is doing is removing some junk from the
> > > profiler -- it looks impressive in perf, but since it was GPU bound in
> > > the first place making the busy-spinner faster is uneventful.
> > >
> > > Just a cosmetic improvement, but quite straightforward.
>

I think it's a bit hard to call replacing a standard library function with
inline assembly a "cosmetic improvement". :-)


> > > -Chris
> >
> > I'm confused, if this doesn't improve performances, why reimplement
> > drmIoctl() in Mesa? Or was the point that you made it `static inline`?
> > Should your assembly hunk be applied in drmIoctl() in libdrm, maybe?
>
> Because the profile was spending more time in drmIoctl() + __GI_ioctl()
> than
> in the kernel, which annoyed me. drmIoctl() still has the impedance
> mismatch, and is not used by anv.


Getting rid of the impedance mismatch in error handling seems like the only
good reason to do this.  I'll have to give it more thought before I have a
solid opinion on whether errno or assembly is worse.  I do like pulling the
anv_ioctl logic into some place common though.

At some point, I'd like to move the special-case for I915_GEM_SET_TILING to
the common helper so we can stop hand-rolling things just for that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170619/37cb3ee8/attachment.html>


More information about the mesa-dev mailing list