Commit Graph

2308 Commits

Author SHA1 Message Date
anjiahao 60aa08e365 procfsmeminfo:move heap name to last,avoid display misalignment
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-08 23:55:59 +08:00
buxiasen 9f2b08a91a memdump: add dump for the orphan nodes(neighbor of free node)
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:55:59 +08:00
buxiasen fd9a9f67cc memdump: add biggest allocated node dump
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:55:59 +08:00
buxiasen fd6634ecb5 mm/dump: make macro more common, fix help prompt
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:55:59 +08:00
xuxingliang 3a86098c9e fs: fix compile break
/home/neo/projects/vela/nuttx/fs/vfs/fs_dup2.c: In function 'file_dup3':
/home/neo/projects/vela/nuttx/fs/inode/inode.h:73:35: error: implicit declaration of function '_SCHED_GETTID' [-Werror=implicit-function-declaration]
   73 |           int n = sched_backtrace(_SCHED_GETTID(), \
      |                                   ^~~~~~~~~~~~~
/home/neo/projects/vela/nuttx/fs/vfs/fs_dup2.c:177:3: note: in expansion of macro 'FS_ADD_BACKTRACE'
  177 |   FS_ADD_BACKTRACE(filep2);

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-08 23:24:13 +08:00
fangxinyong d63056bd72 fs/semaphore: fix a minor issue with goto label
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2024-10-08 23:21:54 +08:00
chenrun1 d154755729 files_getlist:Handling the situation when tcb's grouplist is empty
Summary:
  When the device reboot through reboot_notify to notify the task fsync time, if there is a task in the exit process, there may be priority robbed off the phenomenon, and at this time the group->tg_filelist crefs has been 0, resulting in the ASSERT

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-08 22:29:29 +08:00
chenrun1 58044e3026 fs_open:Adjust the definition of the open path
Summary:
  Reference https://man7.org/linux/man-pages/man2/open.2.html
       EISDIR pathname refers to a directory and the access requested
              involved writing (that is, O_WRONLY or O_RDWR is set).

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-08 22:21:33 +08:00
anjiahao 6382b02d2b zipfs:zipfs not need mtd drivers
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-08 19:55:09 +08:00
Bowen Wang 064eb5fd35 rpmsg services: should release the tx buffer when rpmsg_send_nocopy failed
Otherwise, the tx buffer will be discarded and can no longer be obtained

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-08 18:26:39 +08:00
Bowen Wang 4df19fd6c5 rpmsgfs/rpmsgfs_client: init the priv->wait before register rpmsg callback
Should init the priv->wait before rpmsg_register_callback() because
rpmsgfs_ns_bound() may has been called before rpmsg_register_callback()
returned.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-08 09:00:12 +08:00
fangzhenwei 51623d1751 rpmsgfs: add tty fd ioctl(TCGETS/TCSETS) support
rpmsgfs client ioctl support TCDRN/TCFLSH/TCGETS/TCSETS

Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2024-10-08 09:00:12 +08:00
Bowen Wang 9b736c1c27 rpmsgfs_server: add error log for rpmsgfs server ept callback
Because the rpmsg_virtio will assert when endpoint callback return
error, so add more error log to the rpmsgfs server to help to locate
the root cause.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-08 09:00:12 +08:00
ligd 057e608bb8 rpmsgfs: remove memcpy in rpmsgfs open/close
improve the rpmsgfs performance

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-08 09:00:12 +08:00
Michal Lenc 531dbaf561 fs_close: provide inotify call for close
Close operation on file should lead to IN_CLOSE_WRITE or
IN_CLOSE_NOWRITE notifications. This commits adds the notification
support. Notifying on close is a little bit trickier as a lower layer
may not have the full file path after successful close and inode release.
Calling notification before close is not a solution since close might
not end successfully.

The solution is to obtain and buffer the path before calling close
and then pass the buffered path to the notify_close. This required the
change in notify_close function arguments: filep is no longer
required, path and oflags are passed instead.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-10-08 08:14:19 +08:00
Michal Lenc 939c10ea34 fs_truncate: provide inotify call for truncate
IN_MODIFY event should occur on file modification, which includes
truncate. This is consistent with the inotify usage on Linux.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-10-08 08:14:19 +08:00
Xiang Xiao f838987e44 fs/romfs: Call block_operations::close when romfs_bind fail
to avoid the resource leak

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-07 21:10:07 +08:00
Xiang Xiao 7c839d7a09 rptun: Remove include/nuttx/rptun/openamp.h
and use include/nuttx/rpmsg/rpmsg.h instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-07 00:44:28 +08:00
chenrun1 8f9857bf8c fs_lock:Check the nwaiter when deleting a bucket
Summary:
  Fixed the problem of releasing the bucket prematurely in multi-threaded flock scenarios.

A thread setlk
B thread setlk_wait
A thread releases lock but fails to determine if nwaiter causes the bucket to be released prematurely
post B thread causes crash due to heap use after free

https://github.com/apache/nuttx/issues/13821

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-05 21:09:46 +08:00
Michal Lenc f778660aca smartfs: return -ENOTTY if ioctl command is not found
The upper layer expects -ENOTTY is returned if ioctl command is not
found in file system specific implementation.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-10-05 20:52:31 +08:00
zhanghongyu bd83d2aca5 fs_lock: fix cmake build error
nuttx/fs/vfs/fs_lock.c:39:10: fatal error: sched/sched.h: No such file or directory
   39 | #include "sched/sched.h"
      |          ^~~~~~~~~~~~~~~

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-10-05 13:43:02 +08:00
zhengyu9 70a91289dd fs: fdcheck can't assert
while running fdcheck_test_common there should be assertion failed

Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
2024-10-03 14:22:55 +08:00
dongjiuzhu1 b2e69b86ad fs/inode: remove unnecessary return value for inode_addrefs
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-02 01:56:46 +08:00
dongjiuzhu1 09a9611ae9 fs/inode: using rwsem lock as inode_lock to avoid deadlock
Example:
When executing "df -h" on Core A to view mount information, this
process will traverse inode nodes, thereby holding the inode_lock.
Since the inode type of the mount point may be rpmsgfs, it will fetch statfs
information from another Core B.

Meanwhile, rcS on Core B needs to obtain file information from Core A,
which will be achieved by fetching stat information through rpmsgfs.
When this message arrives at Core A, a deadlock can occur between Core A's
rptun ap and nsh task.

However, both of these places involve read operations only, thus a reader-writer lock
can be utilized to prevent such a deadlock.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-02 01:56:46 +08:00
dongjiuzhu1 f9283c4e70 fs/vfs: fix compile break when enable PSEUDOFS_FILE
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-01 20:39:05 +08:00
xuxingliang 7044b10c88 task: use get_task_name where possible
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-01 20:38:06 +08:00
anjiahao ee07a269af fs/ioctl:add FIOC_XIPBASE to get file xip address
in tmpfs/romfs, we can get file real xip address to execute program

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-30 18:25:46 +08:00
buxiasen 2746aa0643 fs: fix dup not compatible with fdcheck & fdsan
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-09-30 16:53:51 +08:00
dongjiuzhu1 5b889b9270 fs/dup: remove template filep to optimize dup operation
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-30 16:53:51 +08:00
chenrun1 96206cbf9d fs/xxfs:Replace kmm with fs heap
Summary:
  1.Add configuration to allocate memory from the specified section
  2.Replace all memory operations (kmm_) in the vfs with
    fs_heap_. When FS_HEAPSIZE > 0, memory is requested for the file system by specifying a configured heap location. By default (i.e. FS_HEAPSIZE=0) fs_heap_ is equivalent to kmm_

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-30 16:30:56 +08:00
chenrun1 e0df067d3c accept4:move function from net to fs
Summary:
  Implementation in accept4 is special, the requested newsock is saved as filep->priv. This will cause sock_file_close to use fs_heap_free filep->priv during close. When fs_heap is configured, the released memory will not be on fs_heap, causing a crash.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-30 16:30:56 +08:00
dongjiuzhu1 4df9a3cb42 fs/mount: move mountpoint inode create after bind
This can avoid the issue of invalid inode access when bind is not yet
completed.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-30 10:30:16 +08:00
dongjiuzhu1 29e7b00c4e fs/epoll: add error log when epoll wait return failed
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-28 10:44:59 +08:00
dongjiuzhu1 580bdda624 fs/poll: ouput error log about poll failed
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-28 10:44:59 +08:00
dulibo1 3c866e8cfd procfs:fix cat dir cause crash
ap> cat pm
=================================================================
==30235==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf436edd9 at pc 0x03338a48 bp 0x9d1b6ca8 sp 0x9d1b6c98
READ of size 1 at 0xf436edd9 thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    #1 0x371af87 in pm_get_file_index power/pm/pm_procfs.c:174
    #2 0x371b066 in pm_open power/pm/pm_procfs.c:207
    #3 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    #4 0x359bce2 in file_vopen vfs/fs_open.c:240
    #5 0x359c431 in nx_vopen vfs/fs_open.c:312
    #6 0x359cb53 in open vfs/fs_open.c:465
    #7 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    #8 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    #9 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    #10 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    #11 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    #12 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    #13 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    #14 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    #15 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    #16 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    #17 0x323ec3f in nxtask_start task/task_start.c:134
    #18 0x33636ea in pre_start sim/sim_initialstate.c:52

ap> cat net
=================================================================
==30303==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4479a5a at pc 0x03338a48 bp 0x9d2b6ce8 sp 0x9d2b6cd8
READ of size 1 at 0xf4479a5a thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    #1 0x5395d62 in netprocfs_open procfs/net_procfs.c:215
    #2 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    #3 0x359bce2 in file_vopen vfs/fs_open.c:240
    #4 0x359c431 in nx_vopen vfs/fs_open.c:312
    #5 0x359cb53 in open vfs/fs_open.c:465
    #6 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    #7 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    #8 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    #9 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    #10 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    #11 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    #12 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    #13 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    #14 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    #15 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    #16 0x323ec3f in nxtask_start task/task_start.c:134
    #17 0x33636ea in pre_start sim/sim_initialstate.c:52

Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-09-27 23:19:57 +08:00
Michal Lenc 8639b1ca66 smartfs: add support for FIOC_FILEPATH ioctl
The FIOC_FILEPATH ioctl call is required if smartfs is to be used
together with inotify monitoring system. This implements the
call support to smartfs file system. The path to the file has to
be stored in smartfs_ofile_s structure during file open (and is freed
during close) as smartfs currently is not able to obtain the path
knowing only the file node. The full path is concatenated with the file
name and creates the full path needed for inotify to detect whether
the file is on the watchlist.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-09-27 10:28:37 +08:00
guoshichao 203944b724 fs_fcntl: fix the ret value not check error
add ret value check on file_seek function to compat with misra rule

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-09-27 00:20:53 +08:00
chenrun1 e86be98d14 fs_rammap:Check last fileseek restore fpos
Summary:
  When restoring rammap fpos, we check the return value to avoid potential problems caused by no error return if the restore fails.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-26 16:15:17 +08:00
zhangshoukui d68fab125e FS_RAMMAP depends on FS_REFCOUNT and remove useless macro
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-23 18:22:35 +08:00
zhangshoukui 7e97691452 Should call fs_putfilep put fs reference when call files_fget complete
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-23 18:22:35 +08:00
dongjiuzhu1 a2845faee3 fs/chmod/fchmod/lchmod: only set permissions by mode_t and ignore other bits
test case:

int main(void)
{
  struct stat buf;
  int ret;

  stat("test1.t", &buf);
  printf("test1.t st.mode:%x\n", buf.st_mode);
  stat("test.t", &buf);
  printf("test.t st.mode:%x\n", buf.st_mode);
  ret = chmod("test1.t", buf.st_mode);
  if (ret == 0)
    {
      stat("test1.t", &buf);
      printf("test1.t st.mode:%x\n", buf.st_mode);
    }

  return 0;
}

>>
test1.t st.mode:81b4
test.t st.mode:81fd
test1.t st.mode:81fd

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-23 14:57:37 +08:00
chenrun1 03f215b374 nuttx/atomic.h:fix Fixed the pragma of ATOMIC_VAR_INIT in clang
Error: vfs/fs_epoll.c:126:3: error: macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Werror,-Wdeprecated-pragma]
  ATOMIC_VAR_INIT(1),     /* i_crefs */
  ^
/Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/stdatomic.h:54:41: note: macro marked 'deprecated' here
                                        ^
1 error generated.
make[1]: *** [fs_epoll.o] Error 1
Error: socket/socket.c:78:3: error: macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Werror,-Wdeprecated-pragma]
  ATOMIC_VAR_INIT(1),     /* i_crefs */

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00
chenrun1 4cec713dbf fs_inode:Change the type of i_crefs to atomic_int
Summary:
  1.Modified the i_crefs from int16_t to atomic_int
  2.Modified the i_crefs add, delete, read, and initialize interfaces to atomic operations
The purpose of this change is to avoid deadlock in cross-core scenarios, where A Core blocks B Core’s request for a write operation to A Core when A Core requests a read operation to B Core.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00
wangjianyu3 b30f866f80 Thermal: Add procfs file nodes
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-09-23 08:57:29 +08:00
guoshichao f01a2c70fd greenhills: fix the enumerated type mixed using warning
CC:  obstack/lib_obstack_printf.c "mmap/fs_rammap.c", line 126: warning #188-D: enumerated type mixed with
          another type
    enum mm_map_type_e type = (uintptr_t)entry->priv.p & 3;
                              ^

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-09-19 14:08:07 +08:00
Shoukui Zhang 5d3d123272 BCH: Add readonly configuration for BCH devices
Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2024-09-19 03:53:20 +08:00
ligd 90dcd5edd3 critmonitor: add caller support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-19 03:16:14 +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
anjiahao 5952bc7392 fs_dup2:fix inode->i_crefs counting error
file_ioctl failed, but close success, inode need release

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-19 02:55:13 +08:00
zhangshoukui 3fb6b4c9ec fix mmap compile error.
mmap/fs_rammap.c:81:39: error: expected ‘)’ before ‘PRIdOFF’
   81 |       ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
      |                                       ^~~~~~~
mmap/fs_rammap.c:81:12: warning: spurious trailing ‘%’ in format [-Wformat=]
   81 |       ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
mmap/fs_rammap.c:81:37: note: format string is defined here
   81 |       ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
      |                                     ^
In file included from mmap/fs_rammap.c:30:
mmap/fs_rammap.c:98:51: error: expected ‘)’ before ‘PRIdOFF’
   98 |               ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",
      |                                                   ^~~~~~~
mmap/fs_rammap.c:98:20: warning: spurious trailing ‘%’ in format [-Wformat=]
   98 |               ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mmap/fs_rammap.c:98:49: note: format string is defined here
   98 |               ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",

Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-19 01:43:50 +08:00
chenrun1 250353240c rammap:Adjust the lower two bits to represent type
Summary:
  In rammap:
   1.0 - User
   2.1 - Kernel
   3.2 - XIP
  Therefore we need to use 2 bits to represent the type

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-19 01:43:50 +08:00
chenrun1 c9148fbb0a fs_msync:Fix crash caused under the anonymous mapping
Summary:
 Limitations of using fs putfile

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-19 01:43:50 +08:00
chenrun1 d04205aa3d fs/mmap/msync:support msync.
Summary:
  1.Added msync callback in struct mm_map_entry_s
  2.Added msync API in fs_msync.c
  3.Added static msync_rammap for rammap.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-19 01:43:50 +08:00
wanggang26 484600bd75 mmap: add xip mmap type support
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-19 01:43:50 +08:00
chao an 3cce16dd0c fs/dump: correct SCHED_DUMP_ON_EXIT to DUMP_ON_EXIT
1. correct SCHED_DUMP_ON_EXIT to DUMP_ON_EXIT
2. dump file list only if DUMP_ON_EXIT enabled

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-18 23:48:31 +08:00
zhangshoukui baa716a85d fs: Dump the list of files when the file description runs out
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-18 13:48:45 +08:00
Shoukui Zhang 175fcb799e add sched note for littlefs/romfs/rpmsgfs
Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2024-09-17 15:21:54 -03:00
simbit18 583f025422 Fix Kconfig style
Remove spaces from Kconfig files
Add TABs
Replace help => ---help---
2024-09-17 22:16:41 +08:00
YAMAMOTO Takashi a78622d7bf file_read: fix a bogus cast 2024-09-17 20:10:31 +08:00
zhangshoukui 13dd7bbfb3 Add reference count configuration
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-17 12:01:53 +08:00
zhangshoukui 0b084308ba Fix Multiple close fd when SMP enable
task1:
The refs is 0 but the inode has not been released
task2:
Executing files_duplist, get filep with refs is zero, but the inode has not yet released.

[    0.530600] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: backtrace:
[    0.530800] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x4045172>] backtrace_unwind+0x241/0x244
[    0.531200] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x4009150>] sched_backtrace+0x27/0x4c
[    0.531500] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x402f0fa>] sched_dumpstack+0x3d/0xa0
[    0.531700] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x4002c90>] _assert+0x1e3/0x564
[    0.532000] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x40221f6>] __assert+0x19/0x24
[    0.532200] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x41fe376>] tcp_stop_monitor+0x61/0x6c
[    0.532500] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x41fe19e>] tcp_close+0xad/0xdc
[    0.532700] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x41ecc18>] inet_close+0x7b/0x8c
[    0.533000] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x41ec374>] psock_close+0x27/0x70
[    0.533300] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x420b68e>] sock_file_close+0x15/0x3c
[    0.533500] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x4206704>] file_close+0x1f/0x80
[    0.533800] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x4205278>] files_duplist+0x39f/0x45c
[    0.534100] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x4000e3c>] group_setuptaskfiles+0x57/0xc0
[    0.534300] [CPU1] [ 6] [ ALERT] [ap] sched_dumpstack: [ 6] [<0x400bc6c>] nxtask_init+0x5b/0x13c

Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-17 12:01:53 +08:00
Xiang Xiao 744da99250 Fix vfs/fs_fstatfs.c:60:21: warning: variable 'inode' set but not used
60 |   FAR struct inode *inode;
      |                     ^~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-09-17 12:01:53 +08:00
Shoukui Zhang 43223124ec vfs/file: add reference counting to prevent accidental close during reading writing...
Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2024-09-17 12:01:53 +08:00
wanggang26 89e5ceb51e vfs:fix a type mismatch issue and a typo
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-16 11:24:56 -03:00
dongjiuzhu1 d2591380ae Revert "fs/mount and fs/romfs: Add support to mount a ROMFS volume using an MTD driver interface using the standard mount() operation."
This reverts commit 5708a1ac73.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 12:27:40 +08:00
dongjiuzhu1 ace2683492 fs/mount: add ftl proxy to mount block filesystem on mtd device
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 12:27:40 +08:00
Masayuki Ishikawa df298c186f Revert "build depend:Revert Make.dep intermediate ddc file"
This reverts commit ddc3119c4e.
2024-09-15 19:29:47 +08:00
anjiahao 63db77628e stack record: fix ps can't show stack used
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-15 10:25:48 +08:00
anjiahao 632b13fe03 stack recored:Fixed the problem of missing the 0th data in statistics
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-15 10:25:48 +08:00
wangjianyu3 1bb0f19fd5 fs/rename: Do not send notify if the same
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-09-15 10:11:42 +08:00
xuxin19 ddc3119c4e build depend:Revert Make.dep intermediate ddc file
Revert "Parallelize depend file generation"
This reverts commit d5b6ec450f.

parallel depend ddc does not significantly speed up compilation,
intermediately generated .ddc files can cause problems if compilation is interrupted unexpectedly

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-09-15 10:01:58 +08:00
ligd fab9369093 poll: fix thread_cancel() caused poll used after free
pthread 0          pthread1
fd 0
poll_setup
wait
                   cancel(thread 0)
                   fd 0 close
                   fd 0 notify (sem used after free)
poll_teardown

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-14 20:15:12 +08:00
ouyangxiangzhen 0451ead2c5 fs/mmap: Ensure anonymous pages are initialized to zero
According to the mmap(2) specification, anonymous pages should be initialized to zero unless the MAP_UNINITIALIZED is specified.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-13 09:10:21 +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
dongjiuzhu1 00e878e848 fs/inode: add reference to protect filelist of group
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-10 15:16:19 +08:00
zhanghongyu 420648b0c6 drivers/pipes: add fcntl(F_SETPIPE_SZ/F_GETPIPE_SZ) support
allows user programs to modify pipe size, but not larger than
CONFIG_DEV_PIPE_MAXSIZE

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-09-10 11:35:15 +08:00
Alexey Matveev f56b7b8c06 smartfs procfs: fix double declare g_smartfs_operations 2024-09-10 11:32:32 +08:00
dongjiuzhu1 43d0d95f81 fs/inode: using inode reference to indicate unlink and simply code
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-09 08:42:34 +08:00
dongjiuzhu1 c6815bba3b fs/mount: move inode_lock to before bind to avoid deadlock(nsh and rptun)
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-09 08:42:34 +08:00
dongjiuzhu1 2a8c023357 fs/inode: using orig_row to ensure correct free logic
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-09 01:24:08 +08:00
dongjiuzhu1 6542806248 fs/inode: fix assert when free error address
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-09 01:24:08 +08:00
Xiang Xiao 659448a9d8 fs/hostfs: Replace strcpy with memcpy
The strcpy function is dangerous because it does not check the length of the

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-09-06 12:27:55 +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
Saurav Pal fc31c61730 boards/sim: Defconfigs for nand and mnemofs
Adds nand and mnemofs sim configs.

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
2024-09-05 11:02:05 +08:00
chao an 39e873f269 sched/policy: move g_policy from data to rodata
Signed-off-by: chao an <anchao@lixiang.com>
2024-09-02 18:23:57 +08:00
Yanfeng Liu 32801d3047 fs/mq_open: revising comments
This contains minor revision on comments of `file_mq_open()`.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-08-31 12:04:17 -03:00
yinshengkai 263f8955da fs/procfs: Supports any number of thread displays
After the number of threads exceeds the array size, it will not be displayed.
Any number of threads can be displayed using dynamic adaptation

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-28 14:01:25 +08:00
Masayuki Ishikawa ec4d31515a fs: nfs: Fix nfsmount error
Summary:
- I noticed that nfsmount does not work due to the recent
  changes on sockaddr_storage alignment.
- This commit fixes this issue.

Impact:
- None

Testing:
- Tested with sabre-6quad:netnsh_smp (QEMU)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2024-08-27 21:57:18 +08:00
pengyinjie cbc9b98075 [FS]:Fixed spacing and typo issues in code comment descriptions
[Desc]:as title

Signed-off-by: pengyinjie <pengyinjie@xiaomi.com>
2024-08-27 21:52:56 +08:00
Petro Karashchenko 1528b8dcca nuttx: resolve various 'FAR' and 'CODE' issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-26 10:21:03 +08:00
yinshengkai 2cdfda149a mm: memory pressure support returns the maximum available memory
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
yinshengkai 49d1b4198f mm: add memory pressure notification support
Add mm_heap_free interface to pass remaining memory to memory pressure

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
yinshengkai f44a31c337 procfs: add memory pressure notification support
This is a memory monitoring interface implemented with reference to Linux's PSI (Pressure Stall Information),
which can send notifications when the system's remaining memory is below the threshold.

The following example code sets two different thresholds.
When the system memory is below 10MB, a notification is triggered.
When the system memory is below 20 MB, a notification (POLLPRI event) is triggered every 1s.

```
int main(int argc, FAR char *argv[])
{
  struct pollfd fds[2];
  int ret;

  if (argc == 2)
    {
      char *ptr = malloc(1024*1024*atoi(argv[1]));
      printf("Allocating %d MB\n", atoi(argv[1]));
      ptr[0] = 0;
      return 0;
    }

  fds[0].fd = open("/proc/pressure/memory", O_RDWR);
  fds[1].fd = open("/proc/pressure/memory", O_RDWR);
  fds[0].events = POLLPRI;
  fds[1].events = POLLPRI;

  dprintf(fds[0].fd, "%llu -1", 1024LLU*1024 * 10);
  dprintf(fds[1].fd, "%llu 1000000", 1024LLU*1024 * 20);

  while (1)
    {
      ret = poll(fds, 2, -1);
      if (ret > 0)
        {
          printf("Memory pressure: POLLPRI, %d\n", ret);
        }
    }

  return 0;
}
```

https://docs.kernel.org/accounting/psi.html
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
buxiasen 946ed96926 fs: add fs_heap, support shm/tmpfs/pseudofile with indepent heap
For some case, need large files from tmpfs or shmfs, will lead to high
pressure on memory fragments, add an optional fs_heap with independent
heap will benifit for memory fragments issue.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-08-25 22:12:37 +08:00
Petro Karashchenko d499ac9d58 nuttx: fix multiple 'FAR', 'CODE' and style issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
Petro Karashchenko d252b6229f nuttx: use sizeof instead of define or number in snprintf
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
pengyinjie 77205b353f [fs][shmfs]:Avoid an integer overflow
[Desc]:We need to check the parameter passed to the kmm_zalloc(size_t) function.
If it exceeds the limit of size_t, we need to return an error directly to avoid further errors.

Signed-off-by: pengyinjie <pengyinjie@xiaomi.com>
2024-08-24 20:33:59 +08:00
Saurav Pal 9d8b92c481 fs/mnemofs: Autoformat
Mnemofs autoformat feature

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
2024-08-23 18:31:04 -03:00
wangzhi16 bf957348ef [BugFix]Command "critmon" error
Command "critmon" has some format errors and information errors, such as:

PRE-EMPTION CALLER            CSECTION CALLER               RUN         TIME             PID   DESCRIPTION
1.679000000                   3.704000000
                         None None             0     CPU0 IDLE
0.002000000                   0.003000000
                         None None             1     CPU1 IDLE
0.000000000                   0.000000000
                         None None             2     CPU2 IDLE
0.000000000                   0.000000000
                         None None             3     CPU3 IDLE
0.001000000                   0.001000000
                         None None             4     hpwork
0.002000000                   0.006000000
                         None None             5     nsh_main
0.000000000                   0.000000000
                         None None             6     critmon

After bug fix:

PRE-EMPTION CALLER            CSECTION CALLER               RUN              TIME             PID   DESCRIPTION
None                          None                          ---------------- ---------------- ----  CPU 0
None                          None                          ---------------- ---------------- ----  CPU 1
None                          None                          ---------------- ---------------- ----  CPU 2
None                          None                          ---------------- ---------------- ----  CPU 3
None                          None                          0.238000000      6.982000000      0     CPU0 IDLE
None                          None                          0.461000000      13.089000000     1     CPU1 IDLE
None                          None                          0.000000000      0.000000000      2     CPU2 IDLE
None                          None                          0.000000000      0.000000000      3     CPU3 IDLE
None                          None                          0.000000000      0.001000000      4     hpwork
None                          None                          0.000000000      0.010000000      5     nsh_main
None                          None                          0.000000000      0.000000000      46    critmon

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2024-08-23 08:53:15 +08:00
Yongrong Wang f55270f15b rpmsgfs: fix out of bounds access caused by data transmission farmat
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-08-22 20:25:49 +08:00