git: e964da141523 - main - LinuxKPI: Add ktime_get_raw_fast_ns() to linux/ktime.h

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Sun, 24 Dec 2023 08:23:06 UTC
The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=e964da141523e1eec2322082936cdb20ba0cf4a7

commit e964da141523e1eec2322082936cdb20ba0cf4a7
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2023-12-24 08:19:59 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2023-12-24 08:19:59 +0000

    LinuxKPI: Add ktime_get_raw_fast_ns() to linux/ktime.h
    
    It is implemented like ktime_get_raw_ns() function but uses less
    precise getnanouptime() call.
    
    Sponsored by:   Serenity Cyber Security, LLC
    Reviewed by:    manu, bz
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D42804
---
 sys/compat/linuxkpi/common/include/linux/ktime.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/ktime.h b/sys/compat/linuxkpi/common/include/linux/ktime.h
index ae270d2ebd06..b13c7182bc61 100644
--- a/sys/compat/linuxkpi/common/include/linux/ktime.h
+++ b/sys/compat/linuxkpi/common/include/linux/ktime.h
@@ -262,4 +262,13 @@ ktime_get_raw_ns(void)
 	return (ktime_to_ns(timespec_to_ktime(ts)));
 }
 
+static inline uint64_t
+ktime_get_raw_fast_ns(void)
+{
+	struct timespec ts;
+
+	getnanouptime(&ts);
+	return (ktime_to_ns(timespec_to_ktime(ts)));
+}
+
 #endif /* _LINUXKPI_LINUX_KTIME_H */