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/11/21 19:40:22 UTC
[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request, #7649: libc: Move the common implementation of up_testset to libc/machine
xiaoxiang781216 opened a new pull request, #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649
## Summary
## Impact
## Testing
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029697081
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
Sorry, that link does not redirect me to anything meaningful
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029475211
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
So why we can't keep up_irq_save?
--
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] masayuki2009 commented on a diff in pull request #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029995620
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
Review Comment:
@xiaoxiang781216
Can we test the above condition with existing defconfig?
--
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 closed pull request #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 closed pull request #7649: libc: Move the common implementation of up_testset to libc/machine
URL: https://github.com/apache/incubator-nuttx/pull/7649
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1028964692
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
@xiaoxiang781216 are you sure in this change? The first look makes me thinking that change from `up_irq_save` to `spin_lock_irqsave` will make a recursion.
--
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 pull request #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#issuecomment-1324082320
What about this code:
``` /* Loop until we successfully take the spinlock (i.e., until the previous
* state of the spinlock was SP_UNLOCKED).
* NOTE that the test/set operation is performed via boardctl() to avoid a
* variety of issues. An option might be to move the implementation of
* up_testset() to libs/libc/machine.
*/
do
{
#ifdef CONFIG_BUILD_FLAT
ret = up_testset(&lock->sp_lock) == SP_LOCKED ? 1 : 0;
#else
ret = boardctl(BOARDIOC_TESTSET, (uintptr_t)&lock->sp_lock);
#endif
}
while (ret == 1);
```
should it be modified now?
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#issuecomment-1324088534
Can't since up_testset stil can't be called from userspace in protected and kernel mode since up_irqsave require the privilege right.
--
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] masayuki2009 commented on a diff in pull request #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029995929
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
>@xiaoxiang781216 are you sure in this change? The first look makes me thinking that change from up_irq_save to spin_lock_irqsave will make a recursion.
I think so too.
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029695366
##########
include/nuttx/spinlock.h:
##########
@@ -105,28 +105,7 @@ typedef uint8_t spinlock_t;
*
****************************************************************************/
-#if defined(CONFIG_ARCH_HAVE_TESTSET)
spinlock_t up_testset(volatile FAR spinlock_t *lock);
Review Comment:
could you please fix a comment near `spin_islocked`? and modify to `/* bool spin_islocked(FAR spinlock_t *lock); */`
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029721843
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
Here:
<img width="359" alt="image" src="https://user-images.githubusercontent.com/18066964/203399052-02811b6a-492b-4256-8408-10da8a206337.png">
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029693935
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
just align with the code at:
https://github.com/apache/incubator-nuttx/pull/7649/files#diff-60c271175313a6344e1faeba2708393238fd3caf3cf282b3f247d9a88699cba9R67
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029000227
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
I mean `up_testset` -> `spin_lock_irqsave` -> `spin_lock` -> `up_testset`
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1030000239
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
Ok, let's keep it as inline function.
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029104512
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
This call chain only happen in SMP case, but SMP require arch provide up_testset implement(ARCH_HAVE_TESTSET):
https://github.com/apache/incubator-nuttx/blob/master/sched/Kconfig#L275
so, the implementation in here is only used for single core.
--
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029724379
##########
include/nuttx/spinlock.h:
##########
@@ -105,28 +105,7 @@ typedef uint8_t spinlock_t;
*
****************************************************************************/
-#if defined(CONFIG_ARCH_HAVE_TESTSET)
spinlock_t up_testset(volatile FAR spinlock_t *lock);
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 #7649: libc: Move the common implementation of up_testset to libc/machine
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7649:
URL: https://github.com/apache/incubator-nuttx/pull/7649#discussion_r1029773340
##########
libs/libc/machine/arch_atomic.c:
##########
@@ -733,3 +733,26 @@ SYNC_VAL_CMP_SWAP(4, uint32_t)
SYNC_VAL_CMP_SWAP(8, uint64_t)
#endif /* __clang__ */
+
+/****************************************************************************
+ * Name: up_testset
+ ****************************************************************************/
+
+#if defined(CONFIG_SPINLOCK) && !defined(CONFIG_ARCH_HAVE_TESTSET)
+spinlock_t up_testset(volatile FAR spinlock_t *lock)
+{
+ irqstate_t flags;
+ spinlock_t ret;
+
+ flags = spin_lock_irqsave(NULL);
Review Comment:
Yeah, those are atomic values, but spinlock itself relies at up_testest, so using spinlock inside seems to be odd at least to me.
I fully understand that spinlock can be implemented on top of atomic compare-and-swap, but this is not the case here. Also the macro for a single CPU system will end up into disabling of interrupts as it was in the code before this change.
@masayuki2009 what is your opinion here?
--
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