- Remove the redundant holder, as nxsem now manages hoder TID
- Remove DEBUGASSERTIONS which are managed in nxsem
- Remove the "reset" handling logic, as it is now managed in nxsem
- Inline the simplest functions
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This enables the mutex fast path for nxsem_wait, nxsem_trywait and nxsem_post also when
the priority inheritance is enabled.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This puts the mutex support fully inside nxsem, allowing
locking the mutex and setting the holder with single atomic
operation.
This enables fast mutex locking from userspace, avoiding taking
critical_sections, which may be heavy in SMP and cleanup
of nxmutex library in the future.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
For the watchdog list and the workqueue list, we wonder whether the list head has changed after the insertion. In the original implementation, we have to access the list->next field and compare the result to the currently inserted node. In this commit, we mark the list head before the insertion and comparing the current traversed node with the list head we marked, which can avoid accessing the list->next and is more cache-friendly.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit refactors the logic of workqueue processing delayed and periodic work, and changes the timer to be set in `work_thread`. The improvements of this change are as follows:
- Fixed the memory reuse problem of the original periodic workqueue implementation.
- By removing the `wdog_s` structure in the `work_s` structure, the memory overhead of each `work_s` structure is reduced by about 30 bytes.
- Set the timer for each workqueue instead of each work, which improves system performance.
- Simplified the workqueue cancel logic.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
In NuttX, the dq and the list are two different implementations of the double-linked list. Comparing to the dq, the list implementation has less branch conditions such as checking whether the head or tail is NULL. In theory and practice, the list is more friendly to the CPU pipeline. This commit changed the dq to the list in the wqueue implementation.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
struct work_s
{
union
{
struct
{
struct dq_entry_s dq; /* Implements a double linked list */
clock_t qtime; /* Time work queued */
} s;
struct wdog_s timer; /* Delay expiry timer */
struct wdog_period_s ptimer; /* Period expiry timer */
} u;
worker_t worker; /* Work callback */
FAR void *arg; /* Callback argument */
FAR struct kwork_wqueue_s *wq; /* Work queue */
};
work_cancel() should determine whether the current work is
in the timer or has already entered the queue.
This judgment is indispensable because the structure is a union.
Whether it is interpreted as a timer or as a dq needs to be determined.
But this judgment seriously depends on the order of struct wdog_s and
struct dq_entry_s, once someone change the order of any, there is a bug.
So we decide remove the union, to improve the robustness.
For the work_s structure size will grow bigger, then we will provide a
another optimization patch
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
When compiling lib_backtrace.c after set CONFIG_LIBC_BACKTRACE_BUFFSIZE,
there will be compilation error warnings. This is because spin_unlock_irqrestore
incorrectly used pool->lock during unlocking, which has been corrected to bp->lock.
Signed-off-by: Baichuan Rong <rongbaichuan1027@163.com>
POSIX states "If the maskpri argument is 0, the current log mask is
not modified." The current implementation in NuttX doesn't
respect this and thus is in a clear violation with a strict POSIX
compliance rule in The Inviolable Principles of NuttX.
This commit therefore changes the behavior to the expected one. Passing
argument 0 doesn't change the current log mask, but just returns the
old one. Completely disabling logging at runtime is thus not possible,
but you may set the highest priority LOG_EMERG only to disable most of
the messages. Default can still be set to no logging with
CONFIG_SYSLOG_DEFAULT_MASK configuration option.
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This reverts commit 300992203ac0a14602c8cf744ec87d5525fe4dfb to
fix a problem with `esp32-devkitc:blewifi`, which fails to boot up
if `CONFIG_DEBUG_ASSERTIONS=y`.
Introduced by https://github.com/apache/nuttx/pull/16176 with the
following description:
> The DEBUGASSERTS in nxsem_wait and nxsem_trywait are
non-functional, they don't check anything. These were broken in
previous commits.
The above statements are not valid. Originally, there was no
problem calling `nxsem_trywait` from the interrupt and the
`DEBUGASSERT` simply checked a corner case: if ran from the
interrupt context, the current (interrupted) task may be the idle
task. This case is allowed only if called from an interrupt and
that's what the original commit checks with:
```
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
up_interrupt_context());
```
The DEBUGASSERTS in nxsem_wait and nxsem_trywait were non-functional, they
didn't check anything.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Renaming "modlib" to "libelf" is more in line with the implementation content,
which makes it easier for individual developers to understand the capabilities of this module.
CONFIG_LIBC_MODLIB -> CONFIG_LIBC_ELF
Signed-off-by: chao an <anchao.archer@bytedance.com>
There is no need for a gettid() syscall, as the thread ID is stable through
the life of the process. It is safe to put a copy of TID to TLS. This way
a user processes can access TID quickly via its own stack, instead of
having to use an expensive syscall.
Signed-off-by: Ville Juven <ville.juven@unikie.com>
We should not access semaphore internals directly outside sched/semaphore.
Just read it via the NXSEM_COUNT macro provided.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Optimize crc32 standard(poly:0x04C11DB7) and crc32
castagnoli(poly:0x1EDC6F41) with arm crc32 extension instructions.
For example, crc32 standard caculates(lookup crc32 table) 1812 bytes data,
reduced the time from 118 us to 14 us through optimization.
Performance improved ~700%
Signed-off-by: Jinliang Li <lijinliang1@lixiang.com>
This avoids unnecessary syscalls in memory protected builds, when mutex
lock/unlock can be done with only atomic counter access
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Add an option to completely disable syslog() and replace it with an empty functions.
This option can be useful for small systems when we don't have any logging support,
but compiler is not able to remove useless code.
This way the final image also won't contain the strings that are present in
syslog() calls when compiler optimization is enabled (for example from /boards
where syslog is often used instead of debug macros).
Signed-off-by: raiden00pl <raiden00@railab.me>
CXX: libcxx/libcxx/src/random.cpp In file included from nuttx/include/libcxx/__filesystem/filesystem_error.h:15,
from nuttx/include/libcxx/__filesystem/directory_entry.h:20,
from nuttx/include/libcxx/filesystem:539,
from nuttx/include/libcxx/fstream:192,
from libcxx/libcxx/src/ios.instantiations.cpp:10:
nuttx/include/libcxx/__filesystem/path.h: In instantiation of 'std::__1::__fs::filesystem::path::_EnableIfPathable<_Source> std::__1::__fs::filesystem::path::append(const _Source&) [with _Source = std::__1::basic_string<char>]':
nuttx/include/libcxx/__filesystem/path.h:623:30: error: use of built-in trait '__remove_pointer(typename std::__1::decay<_Tp>::type)' in function signature; use library traits instead
623 | _EnableIfPathable<_Source> append(const _Source& __src) {
| ^~~~~~
Pick the change from llvm-project:
https://github.com/llvm/llvm-project/pull/92663
Signed-off-by: chao an <anchao.archer@bytedance.com>
Addrenv is changed to the newly created process' one in the beginning of
modlib_bind, and needs to be changed always when returning from the function;
also in error cases.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
1. fix https://github.com/apache/nuttx/issues/14774.
Change the defconfig of libcxxtest and select libcxxabi by default to
fix sim:libcxxtest build in macOS CI can't find cxxabi.h.
2. fix https://github.com/apache/nuttx/issues/15491.
libcxxabi cannot be used with uclibc, so when compiling macos sim, libcxxabi cannot be selected by default in Kconfig.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
GDB release 16.2 recently to fix the incompatibility issue with LLDB.
For us, the only change is stub must report it support feature 'binary-upload' before GDB will use this feature.
For more information, find bug report and discussion in https://sourceware.org/bugzilla/show_bug.cgi?id=32593
Use GDB 16.2, now it works with binary upload.
```
[remote] Sending packet: $x39c,4#a7
[remote] Received Ack
[remote] Packet received: b\000\203
```
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
According to https://pubs.opengroup.org/onlinepubs/9799919799/, the
expected behavior for the wcstombs() function is that it should
convert the wide-character codes stoping conversion either when a
character sequence exceeds the limit of n total bytes or if a null
byte is stored. In the first case, the null-terminated value should
not be appended to the dst buffer.
Currently, no null-terminator is appended to the dst buffer, even
when it's expected to be appended, generating erroneous output.
Read/write special data like 0x2a2a2a2a will trigger this issue.
The current GDB implementation has this flaw. GDB processes the RLE
decoding before espaping the data, make it impossible to repeate special
characters.
The details can be seen in GDB source code remote.c
remote_target::read_frame function.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
As armv7-a addrenv layout is not in line with other archs, we need
align it with others by defining ARCH_DATA_RESERVE_SIZE as same as
MM_PGSIZE for now to keep gnu-elf.ld.in unified.
Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
Summary:
- Replace direct use of `fence.i` instruction with `__ISB()` macro for instruction synchronization
- This change improves portability while maintaining the same functionality
Impact:
- No functional changes - both `fence.i` and `__ISB()` ensure instruction
synchronization on RISC-V
- Makes the code more maintainable by using the architecture abstraction
layer
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>