You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "pussuw (via GitHub)" <gi...@apache.org> on 2024/05/06 13:48:01 UTC

[I] syscall: syscall_wraps apply to kernel side symbols as well [nuttx]

pussuw opened a new issue, #12293:
URL: https://github.com/apache/nuttx/issues/12293

   System call wraps are used to support system call instrumentation (sched note). This feature is done by the linker, using the --wrap option for each symbol respectively, after the nuttx build is otherwise completed. This is a great feature for monitoring system calls from user space, but unfortunately it applies the same wrapping for kernel side symbols as well, so long as the symbol has the same name as the user side system call does.
   
   One example is the `nxsem_xxx` APIs. In fact, any API that has the nx- prefix does this.
   
   I'm applying the instrumentation for kernel side APIs is not intentional, and very likely I have contributed to this problem in: https://github.com/apache/nuttx/pull/11257 where sem_xxx APis were moved to user space.
   
   I'm not sure what to do about this, in my opinion moving the user space related parts of POSIX semaphores (cancel points, errno) into libc was the right call, and I had a plan to continue this with pthreads etc (no time to continue this work for now).
   
   This ticket is basically a placeholder for this issue, as well as an open forum for suggestions on how to fix it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] syscall: syscall_wraps apply to kernel side symbols as well [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on issue #12293:
URL: https://github.com/apache/nuttx/issues/12293#issuecomment-2096283213

   --wrap is only used in the flat build, for kernel/protected build the hook come from syscall.csv.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] syscall: syscall_wraps apply to kernel side symbols as well [nuttx]

Posted by "pussuw (via GitHub)" <gi...@apache.org>.
pussuw commented on issue #12293:
URL: https://github.com/apache/nuttx/issues/12293#issuecomment-2096324705

   When SCHED_INSTRUMENTATION_SYSCALL is enabled, --wrap is used to generate wrappers that encapsulate the system call itself into:
   
   ```
   void __wrap_syscall_xx(int nr, ...)
   {
     sched_note_syscall_enter(int nr, int argc, ...);
     result = __real_syscall_xx();
     sched_note_syscall_leave(int nr, uintptr_t result);
     return result;
   }
   ```
   This is done for every symbol in the syscall table, which includes nxsem_xx et al. The OS calls them directly and as they are now wrapped, they execute the same __wrap_sem_xx call. This is problematic, as it impacts performance as well as clutters the instrumentation with calls that are _not_ system calls from user space (which is what I want to instrument).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] syscall: syscall_wraps apply to kernel side symbols as well [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on issue #12293:
URL: https://github.com/apache/nuttx/issues/12293#issuecomment-2096564597

   Ok, I forget that only the initial version doesn't use --wrap. @YuuichiNakamura switch to --wrap to support the syscall instrumentation in flat build. One possible fix is moving --wrap from kernel bin to userspace libc.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org