Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1286136

Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on the slow path

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on the slow path
Date 2015-12-08 02:20 +0100
Message-ID <qDf6G-40S-5@gated-at.bofh.it> (permalink)
References <qDbZ7-1Mo-3@gated-at.bofh.it> <qDbZ9-1Mo-37@gated-at.bofh.it> <qDeNj-3D4-3@gated-at.bofh.it> <qDeNj-3D4-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Dec 7, 2015 at 4:54 PM, Brian Gerst <brgerst@gmail.com> wrote:
> On Mon, Dec 7, 2015 at 7:50 PM, Brian Gerst <brgerst@gmail.com> wrote:
>> On Mon, Dec 7, 2015 at 4:51 PM, Andy Lutomirski <luto@kernel.org> wrote:
>>> 64-bit syscalls currently have an optimization in which they are
>>> called with partial pt_regs.  A small handful require full pt_regs.
>>>
>>> In the 32-bit and compat cases, I cleaned this up by forcing full
>>> pt_regs for all syscalls.  The performance hit doesn't really matter.
>>>
>>> I want to clean up the 64-bit case as well, but I don't want to hurt
>>> fast path performance.  To do that, I want to force the syscalls
>>> that use pt_regs onto the slow path.  This will enable us to make
>>> slow path syscalls be real ABI-compliant C functions.
>>>
>>> Use the new syscall entry qualification machinery for this.
>>> stub_clone is now stub_clone/ptregs.
>>>
>>> The next patch will eliminate the stubs, and we'll just have
>>> sys_clone/ptregs.
>
> [Resend after gmail web interface fail]
>
> I've got an idea on how to do this without the duplicate syscall table.
>
> ptregs_foo:
>     leaq sys_foo(%rip), %rax
>     jmp stub_ptregs_64
>
> stub_ptregs_64:
>     testl $TS_EXTRAREGS, <current->ti_status>
>     jnz 1f
>     SAVE_EXTRA_REGS
>     call *%rax
>     RESTORE_EXTRA_REGS
>     ret
> 1:
>     call *%rax
>     ret
>
> This makes sure that the extra regs don't get saved a second time if
> coming in from the slow path, but preserves the fast path if not
> tracing.

I think there's value in having the entries in the table be genuine C
ABI-compliant function pointers.  In your example, it only barely
works -- you can call them from C only if you have TS_EXTRAREGS set
appropriately -- -otherwise you crash and burn.  That will break the
rest of the series.

We could adjust it a bit and check whether we're in C land (by
checking rsp for ts) and jump into the slow path if we aren't, but I'm
not sure this is a huge win.  It does save some rodata space by
avoiding duplicating the table.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on the slow path Andy Lutomirski <luto@kernel.org> - 2015-12-07 23:00 +0100
  Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Brian Gerst <brgerst@gmail.com> - 2015-12-08 02:00 +0100
    Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Andy Lutomirski <luto@amacapital.net> - 2015-12-08 02:20 +0100
      Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Brian Gerst <brgerst@gmail.com> - 2015-12-08 14:10 +0100
        Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Ingo Molnar <mingo@kernel.org> - 2015-12-08 20:00 +0100
          Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Andy Lutomirski <luto@amacapital.net> - 2015-12-08 23:00 +0100
  Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Brian Gerst <brgerst@gmail.com> - 2015-12-08 02:00 +0100
  Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Brian Gerst <brgerst@gmail.com> - 2015-12-09 05:50 +0100
    Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Andy Lutomirski <luto@amacapital.net> - 2015-12-09 06:50 +0100
      Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Andy Lutomirski <luto@amacapital.net> - 2015-12-09 07:30 +0100
        Re: [PATCH 07/12] x86/entry/64: Always run ptregs-using syscalls on  the slow path Brian Gerst <brgerst@gmail.com> - 2015-12-09 14:00 +0100
        [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Brian Gerst <brgerst@gmail.com> - 2015-12-09 14:10 +0100
          Re: [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Andy Lutomirski <luto@amacapital.net> - 2015-12-09 20:00 +0100
            Re: [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Brian Gerst <brgerst@gmail.com> - 2015-12-09 22:10 +0100
              Re: [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Andy Lutomirski <luto@amacapital.net> - 2015-12-09 22:20 +0100
                Re: [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Andy Lutomirski <luto@amacapital.net> - 2015-12-10 01:00 +0100
                Re: [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Brian Gerst <brgerst@gmail.com> - 2015-12-10 06:50 +0100
                Re: [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Andy Lutomirski <luto@amacapital.net> - 2015-12-10 07:00 +0100
          [PATCH] x86/entry/64: Remove duplicate syscall table for fast path Andy Lutomirski <luto@kernel.org> - 2015-12-09 20:40 +0100

csiph-web