Skip to content

Commit

Permalink
FROMLIST: lib: vdso: add support for time
Browse files Browse the repository at this point in the history
(cherry pick from url https://patchwork.kernel.org/patch/10053549/)

Add time() vdso support to match up with existing support in the x86's
vdso.  Currently benefitting arm and arm64 which uses the common
vgettimeofday.c implementation.  On arm provides about a ~14 fold
improvement in speed over the straight syscall, and about a ~5 fold
improvement in speed over an alternate library implementation that
relies on the vdso call to gettimeofday to fulfill the request.

We can provide __vdso_time even if we can not provide a speed
enhanced __vdso_gettimeofday.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Bug: 63737556
Bug: 20045882
Change-Id: I0bb3c6bafe57f9ed69350e2dd54edaae58316e8f
Signed-off-by: khusika <khusikadhamar@gmail.com>
  • Loading branch information
Mark Salyzyn authored and khusika committed Oct 13, 2018
1 parent 663de7d commit e48d8c4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm/kernel/vdso.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static void __init patch_vdso(void *ehdr)
vdso_nullpatch_one(&einfo, "__vdso_gettimeofday");
vdso_nullpatch_one(&einfo, "__vdso_clock_gettime");
vdso_nullpatch_one(&einfo, "__vdso_clock_getres");
/* do not zero out __vdso_time, no cntvct_ok dependency */
}
}

Expand Down
1 change: 1 addition & 0 deletions arch/arm/vdso/vdso.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ VERSION
__vdso_clock_gettime;
__vdso_gettimeofday;
__vdso_clock_getres;
__vdso_time;
local: *;
};
}
1 change: 1 addition & 0 deletions arch/arm64/kernel/vdso/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ static __always_inline notrace u64 arch_vdso_read_counter(void)
#define __vdso_clock_gettime __kernel_clock_gettime
#define __vdso_gettimeofday __kernel_gettimeofday
#define __vdso_clock_getres __kernel_clock_getres
#define __vdso_time __kernel_time

#endif /* __VDSO_COMPILER_H */
1 change: 1 addition & 0 deletions arch/arm64/kernel/vdso/vdso.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ VERSION
__kernel_gettimeofday;
__kernel_clock_gettime;
__kernel_clock_getres;
__kernel_time;
local: *;
};
}
Expand Down
10 changes: 10 additions & 0 deletions lib/vdso/vgettimeofday.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,13 @@ int __vdso_clock_getres(clockid_t clock, struct timespec *res)

return 0;
}

notrace time_t __vdso_time(time_t *t)
{
const struct vdso_data *vd = __get_datapage();
time_t result = READ_ONCE(vd->xtime_coarse_sec);

if (t)
*t = result;
return result;
}

0 comments on commit e48d8c4

Please sign in to comment.