From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Michael Ellerman <mpe@ellerman.id.au>,
Santosh Sivaraj <santosh@fossix.org>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
Segher Boessenkool <segher.boessenkool@nl.ibm.com>
Subject: Re: [PATCH] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE
Date: Fri, 21 Jul 2017 07:17:39 +1000 [thread overview]
Message-ID: <1500585459.10674.8.camel@kernel.crashing.org> (raw)
In-Reply-To: <87bmofgsbh.fsf@concordia.ellerman.id.au>
On Thu, 2017-07-20 at 23:18 +1000, Michael Ellerman wrote:
> Santosh Sivaraj <santosh@fossix.org> writes:
>
> > Current vDSO64 implementation does not have support for coarse
> > clocks (CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME_COARSE), for which it falls
> > back to system call. Below is a benchmark of the difference in execution
> > time with and without vDSO support.
>
> Hi Santosh,
>
> Great patch! Always good to see asm replaced with C.
Yeah ewll ... when C becomes some kind of weird glorifed asm like
below, I don't see much of a point ;-)
> > diff --git a/arch/powerpc/kernel/vdso64/gettime.c b/arch/powerpc/kernel/vdso64/gettime.c
> > new file mode 100644
> > index 0000000..01f411f
> > --- /dev/null
> > +++ b/arch/powerpc/kernel/vdso64/gettime.c
> > @@ -0,0 +1,162 @@
>
> ...
> > +static notrace int gettime_syscall_fallback(clockid_t clk_id,
> > + struct timespec *tp)
> > +{
> > + register clockid_t id asm("r3") = clk_id;
> > + register struct timespec *t asm("r4") = tp;
> > + register int nr asm("r0") = __NR_clock_gettime;
> > + register int ret asm("r3");
>
> I guess this works. I've always been a bit nervous about register
> variables TBH.
Does it really work ? That really makes me nervous too, I woudn't do
this without a strong ack from a toolchain person... Segher ?
> > + asm volatile("sc"
> > + : "=r" (ret)
> > + : "r"(nr), "r"(id), "r"(t)
> > + : "memory");
>
> Not sure we need the memory clobber?
>
> It can clobber more registers than that though.
>
> See: Documentation/powerpc/syscall64-abi.txt
>
> > diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > index 3820213..1258009 100644
> > --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
> > +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
> > @@ -51,85 +53,21 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
>
> ...
> > + stwu r1,-112(r1)
> > + .cfi_register lr,r6
> > + std r6,24(r1)
> > + bl V_LOCAL_FUNC(kernel_clock_gettime)
> > crclr cr0*4+so
>
> Clearing CR0[SO] says that the syscall always succeeded.
>
> What happens if you call this with a completely bogus clock id?
>
> I think the solution is probably to do the syscall fallback in asm, and
> everything else in C.
>
> cheers
next prev parent reply other threads:[~2017-07-20 21:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 9:58 [PATCH] powerpc/vdso64: Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE Santosh Sivaraj
2017-07-20 13:18 ` Michael Ellerman
2017-07-20 21:17 ` Benjamin Herrenschmidt [this message]
2017-07-20 22:03 ` Segher Boessenkool
2017-07-21 3:05 ` Anton Blanchard
2017-07-21 4:40 ` Santosh Sivaraj
2017-07-21 6:05 ` Benjamin Herrenschmidt
2017-07-21 9:09 ` [PATCH v2] " Santosh Sivaraj
2017-07-25 6:56 ` [PATCH v3] " Santosh Sivaraj
2017-07-25 10:07 ` Benjamin Herrenschmidt
2017-07-25 13:47 ` Santosh Sivaraj
2017-07-26 2:02 ` Benjamin Herrenschmidt
2017-08-11 8:23 ` [PATCH] " Santosh Sivaraj
2017-07-22 19:29 ` kbuild test robot
2017-07-23 15:12 ` kbuild test robot
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=1500585459.10674.8.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=santosh@fossix.org \
--cc=segher.boessenkool@nl.ibm.com \
--cc=srikar@linux.vnet.ibm.com \
/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).