summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-10-28rtems: Add new clock manager directivestimecounter-2021Sebastian Huber
Update #4527.
2021-10-28score: Add _Timecounter_Set_NTP_update_second()Sebastian Huber
Allow the installation of an NTP update second handler which may be used by an NTP service. Update #2348.
2021-10-28score: Optimize timehand updates for non-SMPSebastian Huber
In uniprocessor configurations, the timehand updates are done with interrupts disabled. So, it is impossible to observe a generation number of zero.
2021-10-28score: Port large time delta support to RTEMSSebastian Huber
2021-10-28score: Initialize timehand generation to UINT_MAXSebastian Huber
This leads to a timehand generation overflow right at the system start and helps to get code coverage in test programs.
2021-10-28kern_tc.c: Scaling/large delta recalculationSebastian Huber
This change is a slight performance optimization for systems with a slow 64-bit division. The th->th_scale and th->th_large_delta values only depend on the timecounter frequency and the th->th_adjustment. The timecounter frequency of a timehand only changes when a new timecounter is activated for the timehand. The th->th_adjustment is only changed by the NTP second update. The NTP second update is not done for every call of tc_windup(). Move the code block to recalculate the scaling factor and the large delta of a timehand to the new helper function recalculate_scaling_factor_and_large_delta(). Call recalculate_scaling_factor_and_large_delta() when a new timecounter is activated and a NTP second update occurred.
2021-10-28Remove "All Rights Reserved" fromEd Maste
FreeBSD Foundation sys/ copyrights These ones were unambiguous cases where the Foundation was the only listed copyright holder (in the associated license block). Sponsored by: The FreeBSD Foundation
2021-10-28kern: clarify boot timeWarner Losh
In FreeBSD, the current time is computed from uptime + boottime. Uptime is a continuous, smooth function that's monotonically increasing. To effect changes to the current time, boottime is adjusted. boottime is mutable and shouldn't be cached against future need. Document the current implementation, with the caveat that we may stop stepping boottime on resume in the future and will step uptime instead (noted in the commit message, but not in the code). Sponsored by: Netflix Reviewed by: phk, rpokala Differential Revision: https://reviews.freebsd.org/D30116
2021-10-28Make kern.timecounter.hardware tunableKonstantin Belousov
Noted and reviewed by: kevans MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D29122
2021-10-28Add ddb 'show timecounter' command.Konstantin Belousov
MFC after: 1 week Sponsored by: The FreeBSD Foundation
2021-10-28Changes that improve DTrace FBT reliabilityRobert Watson
on freebsd/arm64: - Implement a dtrace_getnanouptime(), matching the existing dtrace_getnanotime(), to avoid DTrace calling out to a potentially instrumentable function. (These should probably both be under KDTRACE_HOOKS. Also, it's not clear to me that they are correct implementations for the DTrace thread time functions they are used in .. fixes for another commit.) - Don't allow FBT to instrument functions involved in EL1 exception handling that are involved in FBT trap processing: handle_el1h_sync() and do_el1h_sync(). - Don't allow FBT to instrument DDB and KDB functions, as that makes it rather harder to debug FBT problems. Prior to these changes, use of FBT on FreeBSD/arm64 rapidly led to kernel panics due to recursion in DTrace. Reliable FBT on FreeBSD/arm64 is reliant on another change from @andrew to have the aarch64 instrumentor more carefully check that instructions it replaces are against the stack pointer, which can otherwise lead to memory corruption. That change remains under review. MFC after: 2 weeks Reviewed by: andrew, kp, markj (earlier version), jrtc27 (earlier version) Differential revision: https://reviews.freebsd.org/D27766
2021-10-28Remove double-calls to tc_get_timecount()Konstantin Belousov
to warm timecounters. It seems that second call does not add any useful state change for all implemented timecounters. Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 3 weeks
2021-10-28Mark more nodes as CTLFLAG_MPSAFEPawel Biernacki
or CTLFLAG_NEEDGIANT (17 of many) r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718
2021-10-28Consolidate read code for timecountersKonstantin Belousov
and fix possible overflow in bintime()/binuptime(). The algorithm to read the consistent snapshot of current timehand is repeated in each accessor, including the details proper rollup detection and synchronization with the writer. In fact there are only two different kind of readers: one for bintime()/binuptime() which has to do the in-place calculation, and another kind which fetches some member from struct timehand. Extract the logic into type-checked macros, GETTHBINTIME() for bintime calculation, and GETTHMEMBER() for safe read of a structure' member. This way, the synchronization is only written in bintime_off() and getthmember(). In bintime_off(), use overflow-safe calculation of th_scale * delta(timecounter). In tc_windup, pre-calculate the min delta value which overflows and require slow algorithm, into the new timehands th_large_delta member. This part with overflow fix was written by Bruce Evans. Reported by: Mark Millard <marklmi@yahoo.com> (the overflow issue) Tested by: pho Discussed with: emaste Sponsored by: The FreeBSD Foundation (kib) MFC after: 3 weeks
2021-10-28Remove duplicated empty lines from kern/*.cMateusz Guzik
No functional changes.
2021-10-28Initialize timehands linkage much earlier.Konstantin Belousov
Reported and tested by: trasz Sponsored by: The FreeBSD Foundation MFC after: 1 week
2021-10-28Make timehands count selectable at boottime.Konstantin Belousov
Tested by: O'Connor, Daniel <darius@dons.net.au> Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21563 This patch was modified by Sebastian Huber <sebastian.huber@embedded-brains.de> to adjust it for RTEMS. See comment in the patch.
2021-10-28Instead of using an incomplete list of platformsOlivier Houchard
that uses 64bits time_t in 32bits mode, special case amd64, as i386 is the only arch that still uses 32bits time_t.
2021-10-28Create a new macro for static DPCPU data.Andrew Turner
On arm64 (and possible other architectures) we are unable to use static DPCPU data in kernel modules. This is because the compiler will generate PC-relative accesses, however the runtime-linker expects to be able to relocate these. In preparation to fix this create two macros depending on if the data is global or static. Reviewed by: bz, emaste, markj Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D16140
2021-10-28tc: bcopy -> memcpyMateusz Guzik
2021-10-28Move most of the contents of opt_compat.hBrooks Davis
to opt_global.h. opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941
2021-10-28score: Remove FreeBSD identifierSebastian Huber
2021-10-28Use atomic_load(9) to read ppsinfo sequence numbers.Konstantin Belousov
In this case volatile qualifiers enusre that a compiler does not optimize the accesses out. Reviewed by: alc, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D13534
2021-10-28SPDX: use the Beerware identifier.Pedro F. Giffuni
2021-10-28score: Introduce CPU budget operationsSebastian Huber
This patch set replaces the CPU budget algorithm enumeration with a set of CPU budget operations which implement a particular CPU budget algorithm. This helps to hide the CPU budget algorithm implementation details from the general thread handling. The CPU budget callouts are turned into CPU budget operations. This slightly reduces the size of the thread control block. All schedulers used the default scheduler tick implementation. The tick scheduler operation is removed and the CPU budget operations are directly used in _Watchdog_Tick() if the executing thread uses a CPU budget algorithm. This is performance improvement for all threads which do not use a CPU budget algorithm (default behaviour).
2021-10-27score: Fix SMP EDF priority group orderingSebastian Huber
The SMP EDF scheduler supports one-to-one and one-to-all thread to processor affinities. The one-to-one thread to processor affinity introduces a constraint on the ordering of threads. The implementation uses one ready queue for threads which have a one-to-all affinity and one for each one-to-one affinity group. To order threads across the ready queues, a generation number is used. However, the approach to update the generation number each time a thread is inserted into a ready queue was wrong. The generation number needs to be updated only in the enqueue and enqueue scheduled operations where an insert priority is available. The scheduled chain needs to take the generation number into account. An example scenario which shows the bug is this. Let T be a high priority task affine to processor X. Let A be a lower priority task affine to processor X. Let B be a lower priority task with no affinity to a particular processor which executes on processor Y. Let B be in the same priority group than A and after A. Let T set the affinity to all processors. Now A (higher priority relative to B) should execute on X and T (high priority) should execute on Y. Close #4534.
2021-10-27score: Add node to insert to Chain_Node_orderSebastian Huber
This allows to use additional members of the nodes for comparision. Update #4534.
2021-10-27score: Rework idle handling in SMP schedulersSebastian Huber
This patch fixes an issue with the idle thread handling in the SMP scheduler framework used for the MrsP locking protocol. The approach to use a simple chain of unused idle threads is broken for schedulers which support thread to processor affinity. The reason is that the thread to processor affinity introduces another ordering indicator which may under certain conditions lead to a reordering of idle threads in the scheduled chain. This reordering is not propagated to the chain of unused idle threads. This could lead to use an idle thread for a sticky scheduler node which is already in use. This locks up the system in infinite loops in the thread context switch procedure. To fix this, the SMP scheduler implementations must now provide callbacks to get and release an unused idle thread. Update #4531.
2021-10-27score: Add SMP scheduler make/clean stickySebastian Huber
This patch fixes the following broken behaviour: While a thread is scheduled on a helping scheduler, while it does not own a MrsP semaphore, if it obtains a MrsP semaphore, then no scheduler node using an idle thread and the ceiling priority of the semaphore is unblocked for the home scheduler. This could lead to priority inversion issues and is not in line with the MrsP protocol. Introduce two new scheduler operations which are only enabled if RTEMS_SMP is defined. The operations are used to make the scheduler node of the home scheduler sticky and to clean the sticky property. This helps to keep the sticky handing out of the frequently used priority update operation. Close #4532.
2021-10-27score: Add SMP scheduler idle exchange callbackSebastian Huber
Update #4531.
2021-10-27score: Optimize SMP EDF move to ready operationSebastian Huber
If a node is moved from the scheduled chain to the ready queue, then we know that it is the highest priority ready node. So, it can be prepended to the ready queue without doing any comparisons. Update #4531.
2021-10-27score: Rework affine ready queue handlingSebastian Huber
Rework the handling of the affine ready queue for the EDF SMP scheduler. Do the queue handling in the node insert, move, and extract operations. Remove the queue handling from _Scheduler_EDF_SMP_Allocate_processor(). Update #4531.
2021-10-25score: Use extract from scheduled callbacksSebastian Huber
Use the extract from scheduled callback provided by the scheduler implementation in the SMP scheduler framework. Update #4531.
2021-10-25score: Remove return value from enqueue scheduledSebastian Huber
The return value was unused. Remove it. Update #4531.
2021-10-25score: Scheduler insert after moveSebastian Huber
Insert nodes after moving the second node to reduce the items in the data structure for the insert operation. This also avoids having two nodes for the same processor inserted into the scheduled chain. Update #4531.
2021-10-25score: Add missing idle thread exchangesSebastian Huber
Update #4531.
2021-10-25score: Add missing idle thread releasesSebastian Huber
Update #4531.
2021-10-25score: Simplify _Scheduler_Exchange_idle_thread()Sebastian Huber
Remove superfluous idle parameter.
2021-10-25score: Change _Scheduler_Try_to_schedule_node()Sebastian Huber
Add the victim node as parameter instead of the idle thread.
2021-10-25score: Not set CPU in _Scheduler_Use_idle_thread()Sebastian Huber
Do not set the CPU of the idle thread in _Scheduler_Use_idle_thread(). This helps to use _Scheduler_Try_to_schedule_node() under more general conditions in the future, for example in case the owner and user of a node are not the same.
2021-10-25score: Rename _Scheduler_Set_idle_thread()Sebastian Huber
Rename _Scheduler_Set_idle_thread() in _Scheduler_Node_set_idle_user() and move it to <rtems/score/schedulernodeimpl.h>.
2021-10-25score: Add red-black tree append/prependSebastian Huber
2021-10-25sptests/sp69: Remove test caseSebastian Huber
This error condition no longer exists. Update #4528.
2021-10-25score: Move code block to separate functionSebastian Huber
Move a code block to the new function _Thread_Scheduler_withdraw_nodes() to ease code review.
2021-10-25score: Do not shadow lock_context local variableSebastian Huber
2021-10-25rtems: rtems_rate_monotonic_get_status()Sebastian Huber
Mention that resetting the processor usage time of tasks has no impact on the period status and statistics. Remove no longer relevant RTEMS_NOT_DEFINED error status. Update #4528.
2021-10-25rtems: Regenerate for IDLE task allocator optionSebastian Huber
Update #4524.
2021-10-25score: Fix typoSebastian Huber
2021-10-25rtems: Fix rate monotonic statisticsSebastian Huber
The rate monotonic period statistics were affected by rtems_cpu_usage_reset(). The logic to detect and work around a CPU usage reset was broken. The Thread_Contol::cpu_time_used is changed to contain the processor time used throughout the entire lifetime of the thread. The new member Thread_Contol::cpu_time_used_at_last_reset is added to contain the processor time used at the time of the last reset through rtems_cpu_usage_reset(). This decouples the resets of the CPU usage and the rate monotonic period statistics. Update #4528.
2021-10-25score: Optimize default idle task stack allocatorSebastian Huber
Update #4524.