[PATCHv8,02/34] lib/vdso: make do_hres and do_coarse as __always_inline

Submitted by Thomas Gleixner on Jan. 10, 2020, 12:02 p.m.

Details

Message ID 875zhja59q.fsf@nanos.tec.linutronix.de
State New
Series "kernel: Introduce Time Namespace"
Headers show

Commit Message

Thomas Gleixner Jan. 10, 2020, 12:02 p.m.
Vincenzo Frascino <vincenzo.frascino@arm.com> writes:
> On 1/10/20 11:42 AM, Thomas Gleixner wrote:
>>>> +» » /*·goto·allows·to·avoid·extra·inlining·of·do_hres.·*/
>>>> +» » goto·out_hres;
>>>
>>> What is the performance impact of "goto out_hres"?
>> 
>> On x86 it's invisible at least in my limited testing.
>
> On arm64 as well based on mine as well. Shall we keep the code more readable
> here (without goto)?

The delta patch below makes it readable again and also avoids the double
inlining. Quick testing shows no difference.

Thanks,

        tglx

8<---------------

Patch hide | download patch | download mbox

--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -98,17 +98,15 @@  static __maybe_unused int
 	msk = 1U << clock;
 	if (likely(msk & VDSO_HRES)) {
 		vd = &vd[CS_HRES_COARSE];
-out_hres:
-		return do_hres(vd, clock, ts);
 	} else if (msk & VDSO_COARSE) {
 		do_coarse(&vd[CS_HRES_COARSE], clock, ts);
 		return 0;
 	} else if (msk & VDSO_RAW) {
 		vd = &vd[CS_RAW];
-		/* This goto avoids extra inlining of do_hres. */
-		goto out_hres;
+	} else {
+		return -1;
 	}
-	return -1;
+	return do_hres(vd, clock, ts);
 }
 
 static __maybe_unused int

Comments

Vincenzo Frascino Jan. 10, 2020, 12:18 p.m.
On 1/10/20 12:02 PM, Thomas Gleixner wrote:
> Vincenzo Frascino <vincenzo.frascino@arm.com> writes:
>> On 1/10/20 11:42 AM, Thomas Gleixner wrote:
>>>>> +» » /*·goto·allows·to·avoid·extra·inlining·of·do_hres.·*/
>>>>> +» » goto·out_hres;
>>>>
>>>> What is the performance impact of "goto out_hres"?
>>>
>>> On x86 it's invisible at least in my limited testing.
>>
>> On arm64 as well based on mine as well. Shall we keep the code more readable
>> here (without goto)?
> 
> The delta patch below makes it readable again and also avoids the double
> inlining. Quick testing shows no difference.
>

I tested it on arm64 and it does not show any difference as well.
I vote for it :)

> Thanks,
> 
>         tglx
> 
> 8<---------------
> --- a/lib/vdso/gettimeofday.c
> +++ b/lib/vdso/gettimeofday.c
> @@ -98,17 +98,15 @@ static __maybe_unused int
>  	msk = 1U << clock;
>  	if (likely(msk & VDSO_HRES)) {
>  		vd = &vd[CS_HRES_COARSE];
> -out_hres:
> -		return do_hres(vd, clock, ts);
>  	} else if (msk & VDSO_COARSE) {
>  		do_coarse(&vd[CS_HRES_COARSE], clock, ts);
>  		return 0;
>  	} else if (msk & VDSO_RAW) {
>  		vd = &vd[CS_RAW];
> -		/* This goto avoids extra inlining of do_hres. */
> -		goto out_hres;
> +	} else {
> +		return -1;
>  	}
> -	return -1;
> +	return do_hres(vd, clock, ts);
>  }
>  
>  static __maybe_unused int
>
Andrei Vagin Jan. 13, 2020, 5:27 a.m.
On Fri, Jan 10, 2020 at 4:02 AM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> Vincenzo Frascino <vincenzo.frascino@arm.com> writes:
> > On 1/10/20 11:42 AM, Thomas Gleixner wrote:
> >>>> +» » /*·goto·allows·to·avoid·extra·inlining·of·do_hres.·*/
> >>>> +» » goto·out_hres;
> >>>
> >>> What is the performance impact of "goto out_hres"?
> >>
> >> On x86 it's invisible at least in my limited testing.
> >
> > On arm64 as well based on mine as well. Shall we keep the code more readable
> > here (without goto)?
>
> The delta patch below makes it readable again and also avoids the double
> inlining. Quick testing shows no difference.

My tests show no difference too and the code looks more readable. Thanks!

>
> Thanks,
>
>         tglx