Commit Graph

143 Commits

Author SHA1 Message Date
ligd 92f8f9b8f8 clock: correct compile failed
LD: nuttx.elf
ld: /home/ligd/platform/mainline/nuttx/staging/libsched.a(mq_sndinternal.o): in function `wd_start_realtime':
/home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274: undefined reference to `clock_realtime2absticks'
/home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274:(.text+0xad): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `clock_realtime2absticks'
ld: /home/ligd/platform/mainline/nuttx/staging/libsched.a(mq_rcvinternal.o): in function `wd_start_realtime':
/home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274: undefined reference to `clock_realtime2absticks'
/home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274:(.text+0xad): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `clock_realtime2absticks'
make[1]: *** [Makefile:128: nuttx.elf] Error 1
make: *** [tools/Unix.mk:551: nuttx.elf] Error 2

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-29 18:18:01 +08:00
yinshengkai e28b311b78 Make each function of SCHED_CRITMONITOR independent
There will be a large performance loss after SCHED_CRITMONITOR is enabled.
By isolating thread running time-related functions, CPU load can be run with less overhead.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-09-19 03:16:14 +08:00
ligd 578ecef975 wdog: add new API wd_start_realtime() support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 12:15:14 +08:00
ligd fae6a00e02 clock: refactor clock_systime_timespec() & clock_systime_ticks()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd 76e807560e clock: take clock_abstime2ticks() as MACRO
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd 07a4233d1d clock: refactor clock_gettime clock_settime
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd 6a2c03732f clock: Replace all ts and tick conversion functions
Using the ts/tick conversion functions provided in clock.h

Do this caused we want speed up the time calculation, so change:
clock_time2ticks, clock_ticks2time, clock_timespec_add,
clock_timespec_compare, clock_timespec_subtract... to MACRO

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd a10c46d02e clock: use clock_timespec_add/subtract to optimize code
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
liaoao 45d6b5f8f2 clock: remove cast
Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd f2a77bbcea clock: take clock_timespec_compare/add/subtract() as MACRO
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
Alin Jerpelea eb9030c891 sched: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-12 01:10:14 +08:00
hujun5 198630a809 sched: use this_task replace nxsched_self
reason:
We can reduce a function call to improve performance.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-05 09:33:50 -03:00
chao an ec08031e4b sched/group: change type of task group member to single queue
Change the type of task group member to single list chain to
avoid accessing the memory allocator to improve the performance

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-07 12:39:29 +08:00
Petteri Aimonen 1825f9534c adjtime: Rewrite implementation to work for RTC and tickless kernel
Previous adjtime() implementation was limited to adjusting system
timer tick period. This commit reimplements the internals to use
a kernel watchdog timer. Platform-independent part of the code now
works also for adjusting hires RTC and tickless timer rate.

User code facing API is unchanged. Architecture code API has changed:
up_adj_timer_period() is replaced by up_adjtime().

Other improvements:

- Support query of remaining adjustment by passing NULL to first
  argument of adjtime(). This matches Linux behavior.

- Improve resolution available for architecture driver, previously
  limited to 1 microsecond per tick. Now 1 nanosecond per second.
2023-11-14 19:47:40 -08:00
chao an 87d6084f31 sched: fix the minor style issue
and remove the unused return value

Signed-off-by: chao an <anchao@xiaomi.com>
2023-10-25 15:46:45 +08:00
yinshengkai ddb87d3b86 clock: replace all up_perf_xx with perf_xx
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-02 16:11:43 +02:00
yinshengkai b99820744c timer: handle perf count overflow
clock_getcycle always returns an incremented cycle value
If the hardware does not support perf event it will use arch_alarm's up_perf_gettime

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-10-02 16:11:43 +02:00
Petteri Aimonen 0611f39cdc adjtime(): Improve configuration and math
1) Previously adjustments less than 1 microsecond per tick would be
   completely ignored. Now they are applied over a shorter period at
   a rate of 1 us per tick.

2) Previously CLOCK_ADJTIME_PERIOD was in units of 1/100th of second.
   Change to milliseconds to be more generally useful unit.
   Change setting name to CLOCK_ADJTIME_PERIOD_MS to make the unit change
   easier to notice.

3) Previously CLOCK_ADJTIME_SLEWLIMIT was in percentage.
   Most clock crystals have better accuracy than 1%, so the minimum slew
   rate was excessive. Change to CLOCK_ADJTIME_SLEWLIMIT_PPM with setting
   value in parts per million.

4) No need to use floating point math in clock_adjtime.c.
2023-09-29 13:03:10 +08:00
zhuanglin 13ee3f8117 sched/clock Add special handling for TCB null pointer cases
Adding a judgment in the code that null return values are not referenced for dereference

Signed-off-by: zhuanglin <zhuanglin@xiaomi.com>
2023-09-22 08:46:50 +08:00
Xu Xingliang 3cd5e20f74 sched: return 0 from clock_systime_ticks if failed
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2023-09-19 16:17:08 +08:00
xuxin19 d93d377257 cmake:complete missing changes during cmake reforming for sched
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-09-08 21:20:16 +03:00
yinshengkai 8fa4f2d61d add the startup process tracepoint
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-19 21:50:08 +08:00
chao an de7132c697 cmake/sched: fix build break based on mainline
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-10 13:26:21 +08:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Petro Karashchenko 0370aa9988 sched/clock: add missing FAR
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-07 17:39:39 -03:00
Petro Karashchenko b8d3e32bdf sched/clock: move clock_getcpuclockid() and clock_getres() to libc
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-07 17:39:39 -03:00
guoshichao 67ec447513 sched/clock/clock_getcpuclockid: fix code format, remove space
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-05 13:03:06 +08:00
guoshichao bc084a8505 sched/clock/clock_getcpuclockid: add clock_getcpuclockid implementation
1. the implementation can pass the full
ltp/open_posix_testsuite/clock_getcpuclockid testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getcpuclockid.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-05 00:32:11 +08:00
guoshichao 42f8308423 sched/clock/clock_getres: add two CPUTIME_ID res support
1. make the clock_getres can pass the
ltp/open_posix_testsuite/clock_getres 7-1, 8-1 two cases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-03 23:11:00 +03:00
Xiang Xiao 7f80b4aeba clock: Move the content of include/nuttx/time.h to include/nuttx/clock.h
and remove include/nuttx/time.h to reduce the nuttx specific header files

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-26 19:14:08 +03:00
Michal Lenc 360e938fa6 sched: add support for adjtime() interface
This commit adds Linux like adjtime() interface that is used to correct
the system time clock if it varies from real value. The adjustment is
done by slight adjustment of clock period and therefore the adjustment
is without time jumps (both forward and backwards)

The implementation is enabled by CONFIG_CLOCK_ADJTIME and separated from
CONFIG_CLOCK_TIMEKEEPING functions. Options CONFIG_CLOCK_ADJTIME_SLEWLIMIT
and CONFIG_CLOCK_ADJTIME_PERIOD can be used to control the adjustment
speed.

Interfaces up_get_timer_period() and up_adj_timer_period() has to be
defined by architecture level support.

This is not a POSIX interface but derives from 4.3BSD, System V.
It is also supported for Linux compatibility.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-04-25 14:37:50 -03:00
chenrun1 d60dee4a65 sched/clock_gettime:Remove output log
Calling syslog to print logs in clock_gettime will cause the system to have recursive output, i.e., clock_gettime->sinfo->syslog->clock_gettime, with the consequences of stack overflow or non-stop log output.
2023-03-25 01:43:01 +02:00
zhangyuan21 8512ca74b1 clock: adjust clock function to support tick
When CONFIG_SCHED_TICKLESS_TICK_ARGUMENT enabled, we can
use up_timer_gettick to get ticks for better performance.
2022-11-01 21:54:20 +08:00
zhangyuan21 750007ded9 sched: use tick count for sched timer expiration 2022-10-12 11:55:46 +08:00
Xiang Xiao e38248ee08 Return -EINVAL for the internal API
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-30 17:54:56 +02:00
Xiang Xiao 764540267e sched/clock: Rename g_system_timer to g_system_ticks
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-27 17:45:44 -03:00
Xiang Xiao 1b04bfae20 sched: Remove the unnecessary weak_function
because not all compiler support the weak attribute, and
many features are either always used or guarded by config.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-30 09:42:24 +02:00
chao.an e5b3d52486 clock/settime: minor fix compile warning
clock/clock_settime.c: In function ‘clock_settime’:
clock/clock_settime.c:120:45: warning: passing argument 1 of ‘clock_timekeeping_set_wall_time’
                              discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  120 |       ret = clock_timekeeping_set_wall_time(tp);
      |                                             ^~
In file included from clock/clock_settime.c:37:
sched/clock/clock_timekeeping.h:40:58: note: expected ‘struct timespec *’
                                       but argument is of type ‘const struct timespec *’
   40 | int clock_timekeeping_set_wall_time(FAR struct timespec *ts);
      |

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-10 20:44:21 +03:00
Xiang Xiao f1ed349dd9 sched/clock: Remove CLOCK_MONOTONIC option from Kconfig
here is the reason:
1.clock_systime_timespec(core function) always exist regardless the setting
2.CLOCK_MONOTONIC is a foundamental clock type required by many places

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-23 01:21:26 +08:00
ligd cb502a869c clock: update clock_synchronize() to support with time
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-18 22:48:15 +08:00
ligd 0a51f13ca5 rpmsg_rtc: merge the rpmsg_rtc_init to same place
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-18 22:48:15 +08:00
Jukka Laitinen c79d2067c7 Move timespec calculations from sched into libc/sched
Allow using these functions also outside sched, where systick
related calculations are performed

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-04 13:19:01 -05:00
Peter Bee 8a47dd95c9 sched/clock: add nsec range check in clock_settime
MIRTOS-109

Return error when tv_nsec <0 or >=1000 million.

Change-Id: Iddbbcda163cb402551f619efb7486f6798859d57
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-07-09 14:19:03 -03:00
Xiang Xiao ae9b5fd306 Replace mktime with timegm in rtc and fs driver
since kernel component should use UTC instead local time

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Icf939e1ab0af8e577105f539d2553bc67b3b3d10
2021-06-23 13:43:32 -03:00
Xiang Xiao 5b2a17b892 Include assert.h in necessary place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-08 13:06:08 -07:00
Xiang Xiao 2e54df0f35 Don't include assert.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
Alin Jerpelea c0ed011874 sched: update licenses to Apache
Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-05-25 08:46:53 -05:00
Xiang Xiao 001e7c3e76 sched: Don't include nuttx/sched.h inside sched.h
But let nuttx/sched.h include sched.h instead to
avoid expose nuttx kernel API to userspace.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-05-24 12:11:53 +09:00
Anthony Merlino 9c8c2b0db2 Separate CLOCK_TIMEKEEPING and SCHED_TICKLESS. 2021-04-13 11:42:31 -05:00
Gustavo Henrique Nihei 76acb32e29 Fix typos reported by codespell 2021-02-25 11:31:49 -08:00