You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/15 08:54:02 UTC
[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request, #6618: Optimize syslog_write performance
xiaoxiang781216 opened a new pull request, #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618
## Summary
- arch: Add up_nputs function to handle the non '\0' string correctly
- drivers/syslog: Call up_puts instead up_putc one by one
- syslog: Remove the lock from syslog_default_write
## Impact
syslog_write
## Testing
Pass CI
--
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
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922207174
##########
drivers/syslog/syslog_channel.c:
##########
@@ -217,16 +217,7 @@ static ssize_t syslog_default_write(FAR struct syslog_channel_s *channel,
FAR const char *buffer, size_t buflen)
{
#if defined(CONFIG_ARCH_LOWPUTC)
- static sem_t sem = SEM_INITIALIZER(1);
- size_t nwritten;
-
- nxsem_wait(&sem);
Review Comment:
We found that calling syslog inside signal handler may happen the dead lock, so it look better to let up_nputs decide how to protect the concurrent access.
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922121584
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ }
+ else
+ {
+ while (len-- > 0)
Review Comment:
```suggestion
while (*str && len-- > 0)
```
##########
drivers/syslog/syslog_channel.c:
##########
@@ -217,16 +217,7 @@ static ssize_t syslog_default_write(FAR struct syslog_channel_s *channel,
FAR const char *buffer, size_t buflen)
{
#if defined(CONFIG_ARCH_LOWPUTC)
- static sem_t sem = SEM_INITIALIZER(1);
- size_t nwritten;
-
- nxsem_wait(&sem);
Review Comment:
why the lock is removed? will it not lead to messed up output in multi-tasking syslog usage?
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922676875
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
Yes, but in your changes you assume that string might not be null-terminated, so both `*str` and `len > 0` are performed. According to the description that you pointed the WRITE0 is: `Writes a null-terminated string to the debug channel.`, so the ARM debug interface might become broken.
I mean that if we know that string is null-terminated then `len > 0` check may be omitted in the default implementation of `up_nputs`.
--
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
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922674819
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
SEMI_SYSLOG_WRITE0 is defined by ARM, we can't change it as we want to:
https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst#sys-write0-0x04
since the PC tool will stop working.
--
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
[GitHub] [incubator-nuttx] pkarashchenko merged pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922483616
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
Should we equip `SEMI_SYSLOG_WRITE0` with additional parameter `len`?
--
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
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922195106
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ }
+ else
+ {
+ while (len-- > 0)
Review Comment:
Done.
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922676875
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
Yes, but in your changes you assume that string might not be null-terminated, so both `str` and `len > 0` are performed. According to the description that you pointed the WRITE0 is: `Writes a null-terminated string to the debug channel.`, so the ARM debug interface might become broken.
I mean that if we know that string is null-terminated then `len > 0` check may be omitted in the default implementation of `up_nputs`.
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922677247
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
I see... Only `~0` is for WRITE0 call and means that string is null-terminated.
So indeed, my previous comment about `*str` check in else was wrong. In the else case we know the exact length, so `*str` can be omited
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922677247
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
I see... Only `~0` is for WRITE0 call and means that string is null-terminated.
So indeed, my previous comment about `*str` check in else was wrong. In the else case we know the exact length, so `*str` can be omitted.
Let's move to the previous variant and remove redundant check in the else case
--
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
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#issuecomment-1185589820
> What is the exact improvement? I see that loop has been moved from one place to other, so is removal of a semaphore improving performance?
Since up_nputs can be replaced by chip vendor, they can provide the new implementation of up_nputs to gain the better performance.
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922675982
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
Understood
--
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
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6618: Optimize syslog_write performance
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6618:
URL: https://github.com/apache/incubator-nuttx/pull/6618#discussion_r922689879
##########
arch/arm/src/common/arm_semi_syslog.c:
##########
@@ -54,15 +52,25 @@ int up_putc(int ch)
}
/****************************************************************************
- * Name: up_puts
+ * Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/
-void up_puts(const char *str)
+void up_nputs(const char *str, size_t len)
{
- smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
+ if (len == ~((size_t)0))
+ {
+ smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
Review Comment:
Yes, done.
--
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