Date   

Re: Use of k_work_submit_to_user_queue() with CONFIG_USERSPACE

Boie, Andrew P
 

This is a bug. I’ll spend some time on this today and get a GH issue opened.

 

Andrew

 

From: devel@... <devel@...> On Behalf Of phil.erwin@...
Sent: Thursday, January 23, 2020 9:14 AM
To: devel@...
Subject: [Zephyr-devel] Use of k_work_submit_to_user_queue() with CONFIG_USERSPACE

 

I have a work Q that will run in user state and attempting to send work to it.  This results in intermittent failures.  The issue I see
in my current test is that I have taken an interrupt while _current is the idle task.  The idle task has no resource pool, so the
'temporary memory allocation' fails.  No work request is saved.

It seems wrong to me that this API is making an allocation based upon the current thread, and is usable from interrupt handlers.
Every thread in the system would need a resource pool to allocate from.

Am I missing something here?

Phil


/**
 * @brief Submit a work item to a user mode workqueue
 *
 * Submits a work item to a workqueue that runs in user mode. A temporary
 * memory allocation is made from the caller's resource pool which is freed
 * once the worker thread consumes the k_work item. The workqueue
 * thread must have memory access to the k_work item being submitted. The caller
 * must have permission granted on the work_q parameter's queue object.
 *
 * Otherwise this works the same as k_work_submit_to_queue().
 *
 * @note Can be called by ISRs.
 *
 * @param work_q Address of workqueue.
 * @param work Address of work item.
 *
 * @retval -EBUSY if the work item was already in some workqueue
 * @retval -ENOMEM if no memory for thread resource pool allocation
 * @retval 0 Success
 * @req K-WORK-001
 */
static inline int k_work_submit_to_user_queue(struct k_work_q *work_q,
                          struct k_work *work)
{
    int ret = -EBUSY;

    H


Re: is there any gudeline on how to run SMP mode kernel on X86 architecture?

Boie, Andrew P
 

The qemu_x86_64 target is configured to use two cores and SMP by default.

 

Regards,

Andrew

 

From: devel@... <devel@...> On Behalf Of "???
Sent: Thursday, January 23, 2020 3:36 AM
To: devel <devel@...>
Subject: [Zephyr-devel] is there any gudeline on how to run SMP mode kernel on X86 architecture?

 

 

Now SMP only supported on xtensa, arc and x86 arch, but it seems more diffculte to run on xtensa and arc becasue of no boards.

so anybody can tell me how to launch a smp run environment on x86 arch? thank you!

 

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 


Use of k_work_submit_to_user_queue() with CONFIG_USERSPACE

Phil Erwin Jr
 

I have a work Q that will run in user state and attempting to send work to it.  This results in intermittent failures.  The issue I see
in my current test is that I have taken an interrupt while _current is the idle task.  The idle task has no resource pool, so the
'temporary memory allocation' fails.  No work request is saved.

It seems wrong to me that this API is making an allocation based upon the current thread, and is usable from interrupt handlers.
Every thread in the system would need a resource pool to allocate from.

Am I missing something here?

Phil


/**
 * @brief Submit a work item to a user mode workqueue
 *
 * Submits a work item to a workqueue that runs in user mode. A temporary
 * memory allocation is made from the caller's resource pool which is freed
 * once the worker thread consumes the k_work item. The workqueue
 * thread must have memory access to the k_work item being submitted. The caller
 * must have permission granted on the work_q parameter's queue object.
 *
 * Otherwise this works the same as k_work_submit_to_queue().
 *
 * @note Can be called by ISRs.
 *
 * @param work_q Address of workqueue.
 * @param work Address of work item.
 *
 * @retval -EBUSY if the work item was already in some workqueue
 * @retval -ENOMEM if no memory for thread resource pool allocation
 * @retval 0 Success
 * @req K-WORK-001
 */
static inline int k_work_submit_to_user_queue(struct k_work_q *work_q,
                          struct k_work *work)
{
    int ret = -EBUSY;

    H


is there any gudeline on how to run SMP mode kernel on X86 architecture?

"曹子龙
 


Now SMP only supported on xtensa, arc and x86 arch, but it seems more diffculte to run on xtensa and arc becasue of no boards.
so anybody can tell me how to launch a smp run environment on x86 arch? thank you!

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 



Re: 回复:回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

Boie, Andrew P
 

Hi there,

 

Race conditions for SMP are still under investigation. We found one today where the same thread object was being scheduled on two cores. Additional eyes on this (or patches) are greatly valued, please feel free to join the discussion in https://github.com/zephyrproject-rtos/zephyr/issues/21317 where are are tracking these SMP issues.

 

Regards,

Andrew

 

From: devel@... <devel@...> On Behalf Of "???
Sent: Wednesday, January 22, 2020 9:54 PM
To: Williams, Jennifer M <jennifer.m.williams@...>; Ross, Andrew J <andrew.j.ross@...>; devel <devel@...>
Subject: 回复:回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

HI folks:

  

   i still belive there are race conditions exist.

 

in "do_swap" function, what would happen if others cpus pick up the "old" thread to run before  it do the actual context backup?

because if "is_spinlock" set to 1,  there are no others condition to prevent others cpus access the readyqueue,

how to deal with this?

 

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

------------------------------------------------------------------

发件人:Williams, Jennifer M <jennifer.m.williams@...>

发送时间:2020123(星期四) 02:43

收件人:曹子 <caozilong@...>; "Ross, Andrew J" <andrew.j.ross@...>; devel <devel@...>

主 题:RE: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

Hi

The PR mentioned below (https://github.com/zephyrproject-rtos/zephyr/pull/21903) was merged yesterday – please review the comments and code changes for more details on the fix. Can you please describe a bit more how your potential issue is not addressed by this PR?

 

Thank you,

Jen

 

From: devel@... <devel@...> On Behalf Of "???
Sent: Tuesday, January 21, 2020 10:31 PM
To: Ross, Andrew J <andrew.j.ross@...>; devel <devel@...>
Subject:
回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

Hi andy:

 

     so, this is turely a issue that i have illustrated in last emai? is that true?

so the mainline code still has this issue, right?

 

 thank you.

 

 

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

------------------------------------------------------------------

发件人:Andy Ross <andrew.j.ross@...>

发送时间:2020121(星期二) 22:45

收件人:曹子 <caozilong@...>; devel <devel@...>

主 题:Re: [Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

There is a fix for exactly this race this in https://github.com/zephyrproject-rtos/zephyr/pull/21903

On 1/21/2020 1:49 AM, "曹子 wrote:

HI folks:

     if from the call pass of z_swap, which with parameter,  

      do_swap(key.key, lock, 1);

    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 

which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that

"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?

 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,

 41                                         ¦ struct k_spinlock *lock,

 42                                         ¦ int is_spinlock)

 43 {                   

 44         ARG_UNUSED(lock);

 45         struct k_thread *new_thread, *old_thread;

 46                     

 47 #ifdef CONFIG_EXECUTION_BENCHMARKING

 48         extern void read_timer_start_of_swap(void);

 49         read_timer_start_of_swap();

 50 #endif              

 51                     

 52         old_thread = _current;

 53                     

 54         z_check_stack_sentinel();

 55                     

 56         if (is_spinlock) {

 57                 k_spin_release(lock);

 58         }           

 59                     

 60         new_thread = z_get_next_ready_thread();

 61                     

 62         if (new_thread != old_thread) {

 63                 sys_trace_thread_switched_out();

 64 #ifdef CONFIG_TIMESLICING

 65                 z_reset_time_slice();

 66 #endif              

 67                     

 68                 old_thread->swap_retval = -EAGAIN;

 69                     

 70 #ifdef CONFIG_SMP   

 71                 _current_cpu->swap_ok = 0;

 72                     

 73                 new_thread->base.cpu = arch_curr_cpu()->id;

 74                     

 75                 if (!is_spinlock) {

 76                         z_smp_release_global_lock(new_thread);

 77                 }   

 78 #endif              

 79                 _current = new_thread;

 80                 arch_switch(new_thread->switch_handle,

 81                         ¦   ¦&old_thread->switch_handle); 84         }          

 85         

 83                 sys_trace_thread_switched_in();

 84         }          

 85         

 86         if (is_spinlock) {

 87                 arch_irq_unlock(key);

 88         } else {   

 89                 irq_unlock(key);

 90         }

 91                    

 92         return _current->swap_retval;

 93 }

 94       

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

 

 


回复:回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

"曹子龙
 

hi :
would the "wait_for_switch(new_thread)" would aggravate the race condition not fix the race condition?
 
the old thread save state still cant guarantee to be saved before it pick up by other cpus to run ????


曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 


------------------------------------------------------------------
发件人:Williams, Jennifer M <jennifer.m.williams@...>
发送时间:2020年1月23日(星期四) 02:43
收件人:曹子龙 <caozilong@...>; "Ross, Andrew J" <andrew.j.ross@...>; devel <devel@...>
主 题:RE: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

Hi

The PR mentioned below (https://github.com/zephyrproject-rtos/zephyr/pull/21903) was merged yesterday – please review the comments and code changes for more details on the fix. Can you please describe a bit more how your potential issue is not addressed by this PR?

 

Thank you,

Jen

 

From: devel@... <devel@...> On Behalf Of "???
Sent: Tuesday, January 21, 2020 10:31 PM
To: Ross, Andrew J <andrew.j.ross@...>; devel <devel@...>
Subject: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

Hi andy:

 

     so, this is turely a issue that i have illustrated in last emai? is that true?

so the mainline code still has this issue, right?

 

 thank you.

 

 

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

------------------------------------------------------------------

发件人:Andy Ross <andrew.j.ross@...>

发送时间:2020121(星期二) 22:45

收件人:曹子 <caozilong@...>; devel <devel@...>

主 题:Re: [Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

There is a fix for exactly this race this in https://github.com/zephyrproject-rtos/zephyr/pull/21903

On 1/21/2020 1:49 AM, "曹子 wrote:

HI folks:

     if from the call pass of z_swap, which with parameter,  

      do_swap(key.key, lock, 1);

    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 

which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that

"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?

 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,

 41                                         ¦ struct k_spinlock *lock,

 42                                         ¦ int is_spinlock)

 43 {                   

 44         ARG_UNUSED(lock);

 45         struct k_thread *new_thread, *old_thread;

 46                     

 47 #ifdef CONFIG_EXECUTION_BENCHMARKING

 48         extern void read_timer_start_of_swap(void);

 49         read_timer_start_of_swap();

 50 #endif              

 51                     

 52         old_thread = _current;

 53                     

 54         z_check_stack_sentinel();

 55                     

 56         if (is_spinlock) {

 57                 k_spin_release(lock);

 58         }           

 59                     

 60         new_thread = z_get_next_ready_thread();

 61                     

 62         if (new_thread != old_thread) {

 63                 sys_trace_thread_switched_out();

 64 #ifdef CONFIG_TIMESLICING

 65                 z_reset_time_slice();

 66 #endif              

 67                     

 68                 old_thread->swap_retval = -EAGAIN;

 69                     

 70 #ifdef CONFIG_SMP   

 71                 _current_cpu->swap_ok = 0;

 72                     

 73                 new_thread->base.cpu = arch_curr_cpu()->id;

 74                     

 75                 if (!is_spinlock) {

 76                         z_smp_release_global_lock(new_thread);

 77                 }   

 78 #endif              

 79                 _current = new_thread;

 80                 arch_switch(new_thread->switch_handle,

 81                         ¦   ¦&old_thread->switch_handle); 84         }          

 85         

 83                 sys_trace_thread_switched_in();

 84         }          

 85         

 86         if (is_spinlock) {

 87                 arch_irq_unlock(key);

 88         } else {   

 89                 irq_unlock(key);

 90         }

 91                    

 92         return _current->swap_retval;

 93 }

 94       

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

 



回复:回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

"曹子龙
 

HI folks:
  
   i still belive there are race conditions exist.

in "do_swap" function, what would happen if others cpus pick up the "old" thread to run before  it do the actual context backup?
because if "is_spinlock" set to 1,  there are no others condition to prevent others cpus access the readyqueue,
how to deal with this?

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 


------------------------------------------------------------------
发件人:Williams, Jennifer M <jennifer.m.williams@...>
发送时间:2020年1月23日(星期四) 02:43
收件人:曹子龙 <caozilong@...>; "Ross, Andrew J" <andrew.j.ross@...>; devel <devel@...>
主 题:RE: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

Hi

The PR mentioned below (https://github.com/zephyrproject-rtos/zephyr/pull/21903) was merged yesterday – please review the comments and code changes for more details on the fix. Can you please describe a bit more how your potential issue is not addressed by this PR?

 

Thank you,

Jen

 

From: devel@... <devel@...> On Behalf Of "???
Sent: Tuesday, January 21, 2020 10:31 PM
To: Ross, Andrew J <andrew.j.ross@...>; devel <devel@...>
Subject: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

Hi andy:

 

     so, this is turely a issue that i have illustrated in last emai? is that true?

so the mainline code still has this issue, right?

 

 thank you.

 

 

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

------------------------------------------------------------------

发件人:Andy Ross <andrew.j.ross@...>

发送时间:2020121(星期二) 22:45

收件人:曹子 <caozilong@...>; devel <devel@...>

主 题:Re: [Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

There is a fix for exactly this race this in https://github.com/zephyrproject-rtos/zephyr/pull/21903

On 1/21/2020 1:49 AM, "曹子 wrote:

HI folks:

     if from the call pass of z_swap, which with parameter,  

      do_swap(key.key, lock, 1);

    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 

which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that

"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?

 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,

 41                                         ¦ struct k_spinlock *lock,

 42                                         ¦ int is_spinlock)

 43 {                   

 44         ARG_UNUSED(lock);

 45         struct k_thread *new_thread, *old_thread;

 46                     

 47 #ifdef CONFIG_EXECUTION_BENCHMARKING

 48         extern void read_timer_start_of_swap(void);

 49         read_timer_start_of_swap();

 50 #endif              

 51                     

 52         old_thread = _current;

 53                     

 54         z_check_stack_sentinel();

 55                     

 56         if (is_spinlock) {

 57                 k_spin_release(lock);

 58         }           

 59                     

 60         new_thread = z_get_next_ready_thread();

 61                     

 62         if (new_thread != old_thread) {

 63                 sys_trace_thread_switched_out();

 64 #ifdef CONFIG_TIMESLICING

 65                 z_reset_time_slice();

 66 #endif              

 67                     

 68                 old_thread->swap_retval = -EAGAIN;

 69                     

 70 #ifdef CONFIG_SMP   

 71                 _current_cpu->swap_ok = 0;

 72                     

 73                 new_thread->base.cpu = arch_curr_cpu()->id;

 74                     

 75                 if (!is_spinlock) {

 76                         z_smp_release_global_lock(new_thread);

 77                 }   

 78 #endif              

 79                 _current = new_thread;

 80                 arch_switch(new_thread->switch_handle,

 81                         ¦   ¦&old_thread->switch_handle); 84         }          

 85         

 83                 sys_trace_thread_switched_in();

 84         }          

 85         

 86         if (is_spinlock) {

 87                 arch_irq_unlock(key);

 88         } else {   

 89                 irq_unlock(key);

 90         }

 91                    

 92         return _current->swap_retval;

 93 }

 94       

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

 



Cancelled Event: Zephyr Project: Dev Meeting - Thursday, 23 January 2020 #cal-cancelled

devel@lists.zephyrproject.org Calendar <devel@...>
 

Cancelled: Zephyr Project: Dev Meeting

This event has been cancelled.

When:
Thursday, 23 January 2020
8:00am to 9:00am
(UTC-08:00) America/Los Angeles

Where:
https://zoom.us/j/993312203

Organizer: devel@...

Description:
Join Zoom Meeting
https://zoom.us/j/993312203

One tap mobile
+16699006833,,993312203# US (San Jose)
+16465588656,,993312203# US (New York)

Dial by your location
        +1 669 900 6833 US (San Jose)
        +1 646 558 8656 US (New York)
        +1 877 369 0926 US Toll-free
        +1 855 880 1246 US Toll-free
Meeting ID: 993 312 203
Find your local number: https://zoom.us/u/ankEMRagf


Re: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

Jennifer M Williams
 

Hi

The PR mentioned below (https://github.com/zephyrproject-rtos/zephyr/pull/21903) was merged yesterday – please review the comments and code changes for more details on the fix. Can you please describe a bit more how your potential issue is not addressed by this PR?

 

Thank you,

Jen

 

From: devel@... <devel@...> On Behalf Of "???
Sent: Tuesday, January 21, 2020 10:31 PM
To: Ross, Andrew J <andrew.j.ross@...>; devel <devel@...>
Subject: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

Hi andy:

 

     so, this is turely a issue that i have illustrated in last emai? is that true?

so the mainline code still has this issue, right?

 

 thank you.

 

 

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

------------------------------------------------------------------

发件人:Andy Ross <andrew.j.ross@...>

发送时间:2020121(星期二) 22:45

收件人:曹子 <caozilong@...>; devel <devel@...>

主 题:Re: [Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

 

There is a fix for exactly this race this in https://github.com/zephyrproject-rtos/zephyr/pull/21903

On 1/21/2020 1:49 AM, "曹子 wrote:

HI folks:

     if from the call pass of z_swap, which with parameter,  

      do_swap(key.key, lock, 1);

    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 

which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that

"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?

 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,

 41                                         ¦ struct k_spinlock *lock,

 42                                         ¦ int is_spinlock)

 43 {                   

 44         ARG_UNUSED(lock);

 45         struct k_thread *new_thread, *old_thread;

 46                     

 47 #ifdef CONFIG_EXECUTION_BENCHMARKING

 48         extern void read_timer_start_of_swap(void);

 49         read_timer_start_of_swap();

 50 #endif              

 51                     

 52         old_thread = _current;

 53                     

 54         z_check_stack_sentinel();

 55                     

 56         if (is_spinlock) {

 57                 k_spin_release(lock);

 58         }           

 59                     

 60         new_thread = z_get_next_ready_thread();

 61                     

 62         if (new_thread != old_thread) {

 63                 sys_trace_thread_switched_out();

 64 #ifdef CONFIG_TIMESLICING

 65                 z_reset_time_slice();

 66 #endif              

 67                     

 68                 old_thread->swap_retval = -EAGAIN;

 69                     

 70 #ifdef CONFIG_SMP   

 71                 _current_cpu->swap_ok = 0;

 72                     

 73                 new_thread->base.cpu = arch_curr_cpu()->id;

 74                     

 75                 if (!is_spinlock) {

 76                         z_smp_release_global_lock(new_thread);

 77                 }   

 78 #endif              

 79                 _current = new_thread;

 80                 arch_switch(new_thread->switch_handle,

 81                         ¦   ¦&old_thread->switch_handle); 84         }          

 85         

 83                 sys_trace_thread_switched_in();

 84         }          

 85         

 86         if (is_spinlock) {

 87                 arch_irq_unlock(key);

 88         } else {   

 89                 irq_unlock(key);

 90         }

 91                    

 92         return _current->swap_retval;

 93 }

 94       

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 

 

 


Re: 回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

Andy Ross
 

Actually, that PR merged a few hours ago, so code in master does not have this issue anymore.  But yes: it was real and visible in CI testing as a spurious failure in qemu_x86_64.

Andy

On 1/21/2020 10:31 PM, "曹子龙 wrote:
Hi andy:

     so, this is turely a issue that i have illustrated in last emai? is that true?
so the mainline code still has this issue, right?

 thank you.


曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 


------------------------------------------------------------------
发件人:Andy Ross <andrew.j.ross@...>
发送时间:2020年1月21日(星期二) 22:45
收件人:曹子龙 <caozilong@...>; devel <devel@...>
主 题:Re: [Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

There is a fix for exactly this race this in https://github.com/zephyrproject-rtos/zephyr/pull/21903

On 1/21/2020 1:49 AM, "曹子龙 wrote:
HI folks:
     if from the call pass of z_swap, which with parameter,  
      do_swap(key.key, lock, 1);
    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 
which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that
"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?
 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,
 41                                         ¦ struct k_spinlock *lock,
 42                                         ¦ int is_spinlock)
 43 {                   
 44         ARG_UNUSED(lock);
 45         struct k_thread *new_thread, *old_thread;
 46                     
 47 #ifdef CONFIG_EXECUTION_BENCHMARKING
 48         extern void read_timer_start_of_swap(void);
 49         read_timer_start_of_swap();
 50 #endif              
 51                     
 52         old_thread = _current;
 53                     
 54         z_check_stack_sentinel();
 55                     
 56         if (is_spinlock) {
 57                 k_spin_release(lock);
 58         }           
 59                     
 60         new_thread = z_get_next_ready_thread();
 61                     
 62         if (new_thread != old_thread) {
 63                 sys_trace_thread_switched_out();
 64 #ifdef CONFIG_TIMESLICING
 65                 z_reset_time_slice();
 66 #endif              
 67                     
 68                 old_thread->swap_retval = -EAGAIN;
 69                     
 70 #ifdef CONFIG_SMP   
 71                 _current_cpu->swap_ok = 0;
 72                     
 73                 new_thread->base.cpu = arch_curr_cpu()->id;
 74                     
 75                 if (!is_spinlock) {
 76                         z_smp_release_global_lock(new_thread);
 77                 }   
 78 #endif              
 79                 _current = new_thread;
 80                 arch_switch(new_thread->switch_handle,
 81                         ¦   ¦&old_thread->switch_handle); 84         }          
 85         
 83                 sys_trace_thread_switched_in();
 84         }          
 85         
 86         if (is_spinlock) {
 87                 arch_irq_unlock(key);
 88         } else {   
 89                 irq_unlock(key);
 90         }
 91                    
 92         return _current->swap_retval;
 93 }
 94       

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 




DAC driver API and STM32L0 implementation - RFC

Martin Jäger
 

Hello,

I submitted a PR for a DAC implementation that needs some further review + comments.

Anyone with knowledge about DAC peripheral features of different MCUs please have a look:

https://github.com/zephyrproject-rtos/zephyr/pull/21805

Thanks,

Martin


回复:[Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

"曹子龙
 

Hi andy:

     so, this is turely a issue that i have illustrated in last emai? is that true?
so the mainline code still has this issue, right?

 thank you.


曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 


------------------------------------------------------------------
发件人:Andy Ross <andrew.j.ross@...>
发送时间:2020年1月21日(星期二) 22:45
收件人:曹子龙 <caozilong@...>; devel <devel@...>
主 题:Re: [Zephyr-devel] Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

There is a fix for exactly this race this in https://github.com/zephyrproject-rtos/zephyr/pull/21903

On 1/21/2020 1:49 AM, "曹子龙 wrote:
HI folks:
     if from the call pass of z_swap, which with parameter,  
      do_swap(key.key, lock, 1);
    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 
which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that
"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?
 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,
 41                                         ¦ struct k_spinlock *lock,
 42                                         ¦ int is_spinlock)
 43 {                   
 44         ARG_UNUSED(lock);
 45         struct k_thread *new_thread, *old_thread;
 46                     
 47 #ifdef CONFIG_EXECUTION_BENCHMARKING
 48         extern void read_timer_start_of_swap(void);
 49         read_timer_start_of_swap();
 50 #endif              
 51                     
 52         old_thread = _current;
 53                     
 54         z_check_stack_sentinel();
 55                     
 56         if (is_spinlock) {
 57                 k_spin_release(lock);
 58         }           
 59                     
 60         new_thread = z_get_next_ready_thread();
 61                     
 62         if (new_thread != old_thread) {
 63                 sys_trace_thread_switched_out();
 64 #ifdef CONFIG_TIMESLICING
 65                 z_reset_time_slice();
 66 #endif              
 67                     
 68                 old_thread->swap_retval = -EAGAIN;
 69                     
 70 #ifdef CONFIG_SMP   
 71                 _current_cpu->swap_ok = 0;
 72                     
 73                 new_thread->base.cpu = arch_curr_cpu()->id;
 74                     
 75                 if (!is_spinlock) {
 76                         z_smp_release_global_lock(new_thread);
 77                 }   
 78 #endif              
 79                 _current = new_thread;
 80                 arch_switch(new_thread->switch_handle,
 81                         ¦   ¦&old_thread->switch_handle); 84         }          
 85         
 83                 sys_trace_thread_switched_in();
 84         }          
 85         
 86         if (is_spinlock) {
 87                 arch_irq_unlock(key);
 88         } else {   
 89                 irq_unlock(key);
 90         }
 91                    
 92         return _current->swap_retval;
 93 }
 94       

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 




Re: How to get BLE scan channel #ble

loquat3
 

OK
I was create a github issue.

thank you.


Upcoming Event: Zephyr Project: APIs - Tue, 01/21/2020 9:00am-10:00am, Please RSVP #cal-reminder

devel@lists.zephyrproject.org Calendar <devel@...>
 

Reminder: Zephyr Project: APIs

When: Tuesday, 21 January 2020, 9:00am to 10:00am, (GMT-08:00) America/Los Angeles

Where:https://zoom.us/j/177647878

An RSVP is requested. Click here to RSVP

Organizer: devel@...

Description: Join from PC, Mac, Linux, iOS or Android: https://zoom.us/j/177647878

Or iPhone one-tap :
    US: +16465588656,,177647878# or +16699006833,,177647878# 
Or Telephone:
    Dial(for higher quality, dial a number based on your current location): 
        US: +1 646 558 8656 or +1 669 900 6833 or +1 855 880 1246 (Toll Free) or +1 877 369 0926 (Toll Free)
    Meeting ID: 177 647 878
    International numbers available: https://zoom.us/zoomconference?m=ioAR9GK1OE5LkN1ojt-heTCl7yPcJrhY


 Live meeting minutes: https://docs.google.com/document/d/1lv-8B5QE2m4FjBcvfqAXFIgQfW5oz6306zJ7GIZIWCk/edit?usp=sharing


Re: How to get BLE scan channel #ble

Chettimada, Vinayak Kariappa
 

Hi biwa,

 

I am assuming that you wish to get the BLE radio channel number used in the scan window as part of the advertisement report like in the lines of RSSI.

But as this information is not part of standard Bluetooth HCI event, this will need to be in a form of proprietary event format (like HCI vendor specific extensions).

 

I request you to create a github issue to start a discussion to define public API and its interface to HCI controller.

 

Regards,

Vinayak

 

From: devel@... <devel@...> On Behalf Of biwa via Lists.Zephyrproject.Org
Sent: 24 December 2019 01:53
To: devel@...
Cc: devel@...
Subject: [Zephyr-devel] How to get BLE scan channel #ble

 

I want to get BLE scan recieve channel.
Please add recieve channel parameter for BLE scan callback.


Re: API meeting: agenda

Carles Cufi
 

Hi all,

I'd like to amend the agenda for today's meeting with the following PRs which have been waiting for resolution for a while:

- PR: Validate pin ordinals in wrapper functions
- https://github.com/zephyrproject-rtos/zephyr/pull/20115

- PR: Add discussion of terms that define API behavior
- https://github.com/zephyrproject-rtos/zephyr/pull/21678

Regards,

Carles

-----Original Message-----
From: devel@lists.zephyrproject.org <devel@lists.zephyrproject.org> On
Behalf Of Cufi, Carles via Lists.Zephyrproject.Org
Sent: 20 January 2020 18:05
To: devel@lists.zephyrproject.org; users@lists.zephyrproject.org
Cc: devel@lists.zephyrproject.org
Subject: [Zephyr-devel] API meeting: agenda

Hi all,

Tomorrow we will discuss an RFC that is ready to be merged, two items
that were raised in last week's TSC and we will check on progress with
the GPIO porting.

- RFC (ready to merge): on-off service request and release
- https://github.com/zephyrproject-rtos/zephyr/pull/21090

- Discussion: Stability documentation for APIs. Should it be documented
in Doxygen?

- Discussion: What exactly is subject to the API lifecycle deprecation
policies described in
https://docs.zephyrproject.org/latest/development_process/api_lifecycle.
html?
- Options:
- APIs only
- APIs, Kconfig options, DeviceTree format
- APIs, Kconfig options, DeviceTree format, subsystems, drivers,
boards and SoCs

- GPIO update (users)
- https://github.com/zephyrproject-rtos/zephyr/issues/20017

Additional items in the "Triage" column in the GitHub project may be
discussed if time permits.
If you want an item included in the meeting, please add it to the GitHub
project.

https://github.com/zephyrproject-rtos/zephyr/wiki/Zephyr-Committee-and-
Working-Group-Meetings#zephyr-api-discussion
https://github.com/zephyrproject-rtos/zephyr/projects/18
https://docs.google.com/document/d/1lv-
8B5QE2m4FjBcvfqAXFIgQfW5oz6306zJ7GIZIWCk/edit

Regards,

Carles


Re: What is the difference "z_reschedule_irqlock" and "z_reschedule“? why two implementations?

Andy Ross
 

Traditional locking in Zephyr is done with a single global "irq lock" (implemented on single processor systems with a straightforward interrupt mask).  SMP allows for finer grained spinlocks, which have different semantics (though when !SMP the implementation is the same).  It wasn't feasible to port the entirety of the Zephyr kernel to use the new scheme, though there are very few spots that need z_reschedule while holding a legacy lock (vs. just using an IPC primitive) and I'd expect this particular API to go away at some point in the future.


Andy


On 1/21/2020 12:28 AM, "曹子龙 wrote:
Hi folks:
    
why there are two implmentations of schedule?   What is the difference "z_reschedule_irqlock" and "z_reschedule“? why two implementations?

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 



Re: Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

Andy Ross
 

There is a fix for exactly this race this in https://github.com/zephyrproject-rtos/zephyr/pull/21903

On 1/21/2020 1:49 AM, "曹子龙 wrote:
HI folks:
     if from the call pass of z_swap, which with parameter,  
      do_swap(key.key, lock, 1);
    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 
which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that
"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?
 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,
 41                                         ¦ struct k_spinlock *lock,
 42                                         ¦ int is_spinlock)
 43 {                   
 44         ARG_UNUSED(lock);
 45         struct k_thread *new_thread, *old_thread;
 46                     
 47 #ifdef CONFIG_EXECUTION_BENCHMARKING
 48         extern void read_timer_start_of_swap(void);
 49         read_timer_start_of_swap();
 50 #endif              
 51                     
 52         old_thread = _current;
 53                     
 54         z_check_stack_sentinel();
 55                     
 56         if (is_spinlock) {
 57                 k_spin_release(lock);
 58         }           
 59                     
 60         new_thread = z_get_next_ready_thread();
 61                     
 62         if (new_thread != old_thread) {
 63                 sys_trace_thread_switched_out();
 64 #ifdef CONFIG_TIMESLICING
 65                 z_reset_time_slice();
 66 #endif              
 67                     
 68                 old_thread->swap_retval = -EAGAIN;
 69                     
 70 #ifdef CONFIG_SMP   
 71                 _current_cpu->swap_ok = 0;
 72                     
 73                 new_thread->base.cpu = arch_curr_cpu()->id;
 74                     
 75                 if (!is_spinlock) {
 76                         z_smp_release_global_lock(new_thread);
 77                 }   
 78 #endif              
 79                 _current = new_thread;
 80                 arch_switch(new_thread->switch_handle,
 81                         ¦   ¦&old_thread->switch_handle); 84         }          
 85         
 83                 sys_trace_thread_switched_in();
 84         }          
 85         
 86         if (is_spinlock) {
 87                 arch_irq_unlock(key);
 88         } else {   
 89                 irq_unlock(key);
 90         }
 91                    
 92         return _current->swap_retval;
 93 }
 94       

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 



Re: What is the difference "z_reschedule_irqlock" and "z_reschedule“? why two implementations?

pawel.dunaj@...
 


Is this a bug? how to guarantee the "atomic semantics access of readyqueue" in "do_swap" function during context switch in SMP mode?

"曹子龙
 

HI folks:
     if from the call pass of z_swap, which with parameter,  
      do_swap(key.key, lock, 1);
    because is_spinlock is 1, so the lock would be released before invoke the actual switch function "arch_switch", 
which means there are nothing procteced the readyqueue of the scheduler, during the moment, if other cpus access the readyqueue, there would be a chance that
"_current" task be selected by other cpus before the register  context do the actual backup. so did this a bug?
 40 static ALWAYS_INLINE unsigned int do_swap(unsigned int key,
 41                                         ¦ struct k_spinlock *lock,
 42                                         ¦ int is_spinlock)
 43 {                   
 44         ARG_UNUSED(lock);
 45         struct k_thread *new_thread, *old_thread;
 46                     
 47 #ifdef CONFIG_EXECUTION_BENCHMARKING
 48         extern void read_timer_start_of_swap(void);
 49         read_timer_start_of_swap();
 50 #endif              
 51                     
 52         old_thread = _current;
 53                     
 54         z_check_stack_sentinel();
 55                     
 56         if (is_spinlock) {
 57                 k_spin_release(lock);
 58         }           
 59                     
 60         new_thread = z_get_next_ready_thread();
 61                     
 62         if (new_thread != old_thread) {
 63                 sys_trace_thread_switched_out();
 64 #ifdef CONFIG_TIMESLICING
 65                 z_reset_time_slice();
 66 #endif              
 67                     
 68                 old_thread->swap_retval = -EAGAIN;
 69                     
 70 #ifdef CONFIG_SMP   
 71                 _current_cpu->swap_ok = 0;
 72                     
 73                 new_thread->base.cpu = arch_curr_cpu()->id;
 74                     
 75                 if (!is_spinlock) {
 76                         z_smp_release_global_lock(new_thread);
 77                 }   
 78 #endif              
 79                 _current = new_thread;
 80                 arch_switch(new_thread->switch_handle,
 81                         ¦   ¦&old_thread->switch_handle); 84         }          
 85         
 83                 sys_trace_thread_switched_in();
 84         }          
 85         
 86         if (is_spinlock) {
 87                 arch_irq_unlock(key);
 88         } else {   
 89                 irq_unlock(key);
 90         }
 91                    
 92         return _current->swap_retval;
 93 }
 94       

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 


1361 - 1380 of 8032