答复: Re: Workqueue bug in v1.9.0 and v1.10.0, Requestreview for this patch.


leng.tong@...
 

hi

the function call relationship is      k_delayed_work_submit_to_queue     ->   k_delayed_work_cancel;


in k_delayed_work_submit_to_queue     

 (work->work_q == work_q)      k_work is resubmiited, calls  k_delayed_work_cancel  to  Cancel the submiited  work 


in  k_delayed_work_cancel(work);

        k_work_pending(&work->work)       calls k_queue_remove   to remove k_work form work_q


back to k_delayed_work_submit_to_queue       

work->work_q = work_q;

        k_work_submit_to_queue or _add_timeout


the   pending state of k_work  in k_delayed_work  doesn't   reset neither in k_delayed_work_cancel nor  k_delayed_work_submit_to_queue。so the  k_work_submit_to_queue will fail 


in zehpy 1.8,k_delayed_work_cancel  the earlier pending work  blocks resubmission 。  in zehpy 1.92, the pending work is removed  and the later one carries out。 so we meet this issue after updated  to 1.92

k_delayed_work_cancel  1.8

if (k_work_pending(&work->work)) {

irq_unlock(key);

return -EINPROGRESS;

}





原始邮件
发件人: <luiz.dentz@...>;
收件人:周欣0045002337;
抄送人: <zephyr-devel@...>;刘力凯0045001809;刘亚南0045000760;冷通0045003325;
日 期 :2017年12月19日 19:56
主 题 :Re: [Zephyr-devel] Workqueue bug in v1.9.0 and v1.10.0, Requestreview for this patch.
Hi,

k_delayed_work_cancel no longer uses the flags because it removes the
work from the queue, so either we have a bug in k_queue_remove which
would return success without removing the entry or you are ignoring
the -EINVAL return.


On Tue, Dec 19, 2017 at 1:42 AM,  <zhou.xin8@...> wrote:
> Hi
>
>
> In v1.9.0 and v1.10.0, when remove from the queue if already submitted,
> k_delayed_work_cancel() did not clear bit of work.flags.
>
> This will cause the queue already submitted can not be handled by queue
> manager.
>
>
> Certainly, we have tested and verified on our local side. Request review for
> our patch as below:
>
>
> zephyr-zephyr-v1.9.0\kernel\work_q.c
>
> zephyr-zephyr-v1.10.0\kernel\work_q.c
> Patch of Sanechips
>
> ===================================================================
>
> --- zephyr-zephyr-v1.9.0/kernel/work_q.c        (revision 65)
>
> +++ zephyr-zephyr-v1.9.0/kernel/work_q.c        (working copy)
>
> @@ -123,11 +123,17 @@
>
>         }
>
>
>         if (k_work_pending(&work->work)) {
>
> +
>
> +               /*zxic modify*/
>
> +               atomic_clear_bit(work->work.flags,K_WORK_STATE_PENDING);
>
> +
>
> +
>
>                 /* Remove from the queue if already submitted */
>
>                 if (!k_queue_remove(&work->work_q->queue, &work->work)) {
>
>                         irq_unlock(key);
>
>                         return -EINVAL;
>
>                 }
>
> +
>
>         } else {
>
>                 _abort_timeout(&work->timeout);
>
>         }
>
>
>
>
>
>
> 周欣 Zhou Xin
>
>
> 安全操作系统与驱动
> 解决方案一部/解决方案部/深圳市中兴微电子技术有限公司
>
>
> 南京市雨花台区紫荆花路68号中兴通讯南京研发中心4C
>
> 4C/F, ZTE R&D Center(NanJing), No.68 ZiJinghua Road,
>
> YuHuatai District, Nanjing, P.R.China, 210012
>
> T: 025-52870384
>
> M: +86 13770868539
>
> E: zhou.xin8@...
>
>
> _______________________________________________
> Zephyr-devel mailing list
> Zephyr-devel@...
> https://lists.zephyrproject.org/mailman/listinfo/zephyr-devel
>



-- 
Luiz Augusto von Dentz


Join devel@lists.zephyrproject.org to automatically receive all group messages.