-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lkl: let atomic ops outsourced #273
base: master
Are you sure you want to change the base?
Conversation
@@ -123,7 +123,7 @@ struct task_struct *__switch_to(struct task_struct *prev, | |||
} | |||
|
|||
if (_prev->dead) { | |||
__sync_fetch_and_sub(&threads_counter, 1); | |||
lkl__sync_fetch_and_sub((int *)&threads_counter, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its probably better to just convert threads_counter to long instead of casting here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
atomic_lock = lkl_ops->sem_alloc(1); | ||
return 0; | ||
} | ||
early_initcall(lkl_atomic_ops_init); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are missing the lock free.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. added cleanups.
@@ -0,0 +1,86 @@ | |||
#include <linux/kernel.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this to tools/lkl/lib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. I actually wanted to do it in toolks/lkl/lib but was reluctant to add new lkl_host_ops entries for various atomic ops. do you think it's nicer to do int host_ops or have better idea to do it in tools/lkl ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any nicer way to do it and we will need them anyway for SMP support. We may need a different set for SMP, but we can change that later.
This will allow us to reimplpement atomic ops with lock/touch/unlock way if underlying hosts don't support a particular atomic ops. Signed-off-by: Hajime Tazaki <[email protected]>
0865053
to
31e75dd
Compare
one thing that I wasn't sure is how to emulate |
about __sync_synchronize() : mutex_lock / mutex_unlock should do it. I forgot, but what platform is this that gcc doesn't support this builtins? |
don't understand what you described.. do you mean like this ?
|
Yes, or the mutex ops, if we have it for that host.
Hmm, I think you can get the buitins if you switch to using -mcpu=cortex-m4. Do you really need to support anything less then m4? |
Actually it looks that -march=armv7 is better, since it covers both MCUs and CPUs |
I'm currently using arm926ej-s cpu ( the atomic ops wrapper is useful for such situations if it is really needed. |
@@ -5,7 +5,7 @@ | |||
#include <asm/cpu.h> | |||
#include <asm/sched.h> | |||
|
|||
static volatile int threads_counter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is a bit outdated: need to update/rebase in advance to apply the latest lkl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the code changes to the latest release, so we can see if the patch works for the ARM 32bit platforms. Will let you know if it works or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thehajime The patch doesn't work for me right now.
After changing to lkl__sync_
functions, the __sync_synchronize
used in lib/virtio.c
becomes undefined once again. Then, I tried to change it to lkl__sync_synchronize
and compile, what I got is that there're two lkl__sync_synchronize
symbols in liblkl-hijack.so
:
00061454 l F .text 00000044 lkl__sync_synchronize
00000000 *UND* 00000000 lkl__sync_synchronize
The undefined symbol comes from lib/lkl-in.o
, the defined one comes from lib/lkl.o
. When running AR
to generate liblkl.a
based on lkl-in.o
and lkl.o
, the two symbols are joint together.
What should I do to get rid of it? I am not professional on GCC toolchain....
@@ -220,7 +220,7 @@ void threads_init(void) | |||
|
|||
void threads_cnt_dec(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No such one function is defined and used in the latest code base (a063e16).
This will allow us to reimplpement atomic ops with lock/touch/unlock way
if underlying hosts don't support a particular atomic ops.
Signed-off-by: Hajime Tazaki [email protected]
This change is