Commit Graph

28 Commits

Author SHA1 Message Date
yinshengkai 4685175617 sched: fix the inaccurate cpuload statistics issue
Non-fixed clock source will lead to inaccurate cpuload statistics

before:
5     5 253 RR       Task      - Waiting  Signal    0000000000000000 0002000 0000624  31.2%   2.5% cpuload -p 50
6     6 253 RR       Task      - Waiting  Signal    0000000000000000 0002000 0000624  31.2%   0.7% cpuload -p 10
7     7 253 RR       Task      - Waiting  Signal    0000000000000000 0002000 0000624  31.2%   2.2% cpuload -p 20
after:
5     5 253 RR       Task      - Waiting  Signal    0000000000000000 0002000 0000624  31.2%  50.8% cpuload -p 50
6     6 253 RR       Task      - Waiting  Signal    0000000000000000 0002000 0000624  31.2%  10.8% cpuload -p 10
7     7 253 RR       Task      - Waiting  Signal    0000000000000000 0002000 0000624  31.2%  20.0% cpuload -p 20
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-11 11:04:47 +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
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
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
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
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
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
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
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
Alin Jerpelea dee641828f sched: nxstyle fixes
nxstyle fixes to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Alin Jerpelea 8935ac4cc3 sched: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Xiang Xiao f337cc1380 sched/clock/ timekeeping: Use clock_basetime() to initialize g_clock_wall_time to get the best initial RTC value and initialize g_clock_last_counter too since the hardware may not start counting from zero. 2018-11-12 07:00:41 -06:00
Xiang Xiao 46bd8798c5 ched/clock/: Remove g_monotonic_basetime and g_clock_monotonic_time since we don't need ensure monotonic time start from zero as state here: http://pubs.opengroup.org/onlinepubs/009696899/functions/clock_getres.html 2018-11-12 06:50:37 -06:00
Xiang Xiao 71ad1993f2 Move clock_timespec_[add|subtract] to include/nuttx/clock.h 2018-08-27 06:04:04 -06:00
Gregory Nutt 8fdbb1e0a4 Elimate use of the non-standard type systime_t and replace it the equivalent, standard type clock_t
Squashed commit of the following:

    sched:  Rename all use of system_t to clock_t.
    syscall:  Rename all use of system_t to clock_t.
    net:  Rename all use of system_t to clock_t.
    libs:  Rename all use of system_t to clock_t.
    fs:  Rename all use of system_t to clock_t.
    drivers:  Rename all use of system_t to clock_t.
    arch:  Rename all use of system_t to clock_t.
    include:  Remove definition of systime_t; rename all use of system_t to clock_t.
2018-06-16 12:16:13 -06:00
Jussi Kivilinna c57d49f420 clock: Add new type ssystime_t for relative 64-bit ticks, change ticks<->time conversion functions to use ssystime_t 2017-04-21 08:51:31 -06:00
Jussi Kivilinna 325ba1a803 clock: add clock_resynchronize and use subseconds RTC
Add clock_resynchronize for better synchronization of CLOCK_REALTIME and CLOCK_MONOTONIC to match RTC after resume from low-power state.

Add up_rtc_getdatetime_with_subseconds under CONFIG_ARCH_HAVE_RTC_SUBSECONDS to allow initializing (and resynchronizing) system clock with subseconds accuracy RTC.
2017-04-21 08:45:57 -06:00
Gregory Nutt 3404b3cb4a sched/: Review and correct some stylistic inconsistencies 2016-08-07 08:32:11 -06:00
Gregory Nutt 246773faa7 Rename CONFIG_SCHED_TIMEKEEPING to CONFIG_CLOCK_TIMEKEEPING. That is a better compartmentalized name. 2016-07-11 06:54:02 -06:00
Max Neklyudov 8db29071da timekeeping: initial implementation 2016-07-10 16:14:25 -06:00
Gregory Nutt cb9e27c3b0 Standardize naming used for public data and function groupings 2015-10-02 16:30:35 -06:00
Gregory Nutt 99664b7811 Sporadic scheduler: Add logic to collection the partial timer expiration when a sporadic thread is suspended in tickless mode 2015-07-26 15:03:47 -06:00
Gregory Nutt 8d43a6bdcd Fix build error with CONFIG_SYSTEM_TIME64 2014-10-03 10:20:46 -06:00
Gregory Nutt c19659d7d2 Fixes to clock bias logic. Remove vestiges of g_tickbias; apply bias instead to g_basetime 2014-09-10 16:36:25 -06:00
Gregory Nutt fc7bd31e07 last change alters semantics of __HAVE_KERNEL_GLOBALS 2014-08-30 14:44:48 -06:00
Gregory Nutt 9ab67dce75 In some configurations, g_system_tmer must be extern'ed as a private variable 2014-08-28 17:00:03 -06:00
Gregory Nutt d4b56eb3cc Move clock functions from sched/ to sched/clock 2014-08-08 14:43:02 -06:00