Skip to content

Commit 4b1b7f8

Browse files
Pavel TatashinKAGA-KOKO
authored andcommitted
timekeeping: Default boot time offset to local_clock()
read_persistent_wall_and_boot_offset() is called during boot to read both the persistent clock and also return the offset between the boot time and the value of persistent clock. Change the default boot_offset from zero to local_clock() so architectures, that do not have a dedicated boot_clock but have early sched_clock(), such as SPARCv9, x86, and possibly more will benefit from this change by getting a better and more consistent estimate of the boot time without need for an arch specific implementation. Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: steven.sistare@oracle.com Cc: daniel.m.jordan@oracle.com Cc: linux@armlinux.org.uk Cc: schwidefsky@de.ibm.com Cc: heiko.carstens@de.ibm.com Cc: john.stultz@linaro.org Cc: sboyd@codeaurora.org Cc: hpa@zytor.com Cc: douly.fnst@cn.fujitsu.com Cc: peterz@infradead.org Cc: prarit@redhat.com Cc: feng.tang@intel.com Cc: pmladek@suse.com Cc: gnomes@lxorguk.ukuu.org.uk Cc: linux-s390@vger.kernel.org Cc: boris.ostrovsky@oracle.com Cc: jgross@suse.com Cc: pbonzini@redhat.com Link: https://lkml.kernel.org/r/20180719205545.16512-17-pasha.tatashin@oracle.com
1 parent 3eca993 commit 4b1b7f8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kernel/time/timekeeping.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,14 +1503,17 @@ void __weak read_persistent_clock64(struct timespec64 *ts64)
15031503
* Weak dummy function for arches that do not yet support it.
15041504
* wall_time - current time as returned by persistent clock
15051505
* boot_offset - offset that is defined as wall_time - boot_time
1506-
* default to 0.
1506+
* The default function calculates offset based on the current value of
1507+
* local_clock(). This way architectures that support sched_clock() but don't
1508+
* support dedicated boot time clock will provide the best estimate of the
1509+
* boot time.
15071510
*/
15081511
void __weak __init
15091512
read_persistent_wall_and_boot_offset(struct timespec64 *wall_time,
15101513
struct timespec64 *boot_offset)
15111514
{
15121515
read_persistent_clock64(wall_time);
1513-
*boot_offset = (struct timespec64){0};
1516+
*boot_offset = ns_to_timespec64(local_clock());
15141517
}
15151518

15161519
/* Flag for if timekeeping_resume() has injected sleeptime */

0 commit comments

Comments
 (0)