Re: [osv-dev] Using PERCPU in application or module

2020-06-02 Thread Wonsup Yoon
Oh, it is not a OSv-specific problem. It is because constructor function called before class initialization. 2020년 6월 2일 화요일 오후 11시 54분 26초 UTC+9, Wonsup Yoon 님의 말: > > I tested the dynamic_percpu and it seems mostly works fine. > > However, I found using dynamic_percpu in a constructor function

Re: [osv-dev] Using PERCPU in application or module

2020-06-02 Thread Wonsup Yoon
I tested the dynamic_percpu and it seems mostly works fine. However, I found using dynamic_percpu in a constructor function leads to general protection fault. ex) #include #include #include #include #include #include struct counter { int x = 0; void inc(){ x += 1; } int get(){ return

Re: [osv-dev] Using PERCPU in application or module

2020-05-26 Thread Wonsup Yoon
Great! OSV_ELF_MLOCK_OBJECT seems very useful. Thanks. 2020년 5월 26일 화요일 오후 4시 25분 57초 UTC+9, Nadav Har'El 님의 말: > > On Tue, May 26, 2020 at 9:41 AM Wonsup Yoon > wrote: > >> Actually, I used preempt_lock to prevent data races. >> If two concurrent threads in a core access same per-cpu variabl

Re: [osv-dev] Using PERCPU in application or module

2020-05-26 Thread Nadav Har'El
On Tue, May 26, 2020 at 9:41 AM Wonsup Yoon wrote: > Actually, I used preempt_lock to prevent data races. > If two concurrent threads in a core access same per-cpu variable, I think > we still need preempt lock. > This is true - if you have two threads in the same core that access the same per-c

Re: [osv-dev] Using PERCPU in application or module

2020-05-25 Thread Wonsup Yoon
Actually, I used preempt_lock to prevent data races. If two concurrent threads in a core access same per-cpu variable, I think we still need preempt lock. example) counter's initial value: 0 CPU 0 Thread AA_local = counter + 1 (A_local = 1) Th

Re: [osv-dev] Using PERCPU in application or module

2020-05-25 Thread Nadav Har'El
On Tue, May 26, 2020 at 4:22 AM Wonsup Yoon wrote: > Thank you for the response. > > Yes, dynamic_percpu is perfect for my purpose. > > However, I encountered another issue. > > If I use dynamic_percpu with preempt-lock (I think it is very common > pattern), it abort due to assertion failed. > It

Re: [osv-dev] Using PERCPU in application or module

2020-05-25 Thread Wonsup Yoon
Thank you for the response. Yes, dynamic_percpu is perfect for my purpose. However, I encountered another issue. If I use dynamic_percpu with preempt-lock (I think it is very common pattern), it abort due to assertion failed. It seems lazy binding prevents preemption lock. So, I had to add -fno

Re: [osv-dev] Using PERCPU in application or module

2020-05-24 Thread Nadav Har'El
On Sat, May 23, 2020 at 6:35 PM Wonsup Yoon wrote: > Hi, > > I'm trying to use PERCPU macro in application or module. > Hi, The PERCPU macro does not support this. What it does is to add information about this variable in a special section of the executable (".percpu"), then arch/x64/loader.ld

[osv-dev] Using PERCPU in application or module

2020-05-23 Thread Wonsup Yoon
Hi, I'm trying to use PERCPU macro in application or module. I tried using cpu::notifier, but it seems a_init is not called. class A { public: A() { printf("init: %p\n", this); } void test() { printf("test: %d\n", x); } int x = 123; }; PERCPU(A *, a); static sched::cpu::notifier a_init([]() { *