Re: Request review for re-alloc patch @k_mem_pool_alloc()


Boie, Andrew P
 

Can you please send this as a pull request in github?

An explanation of what the race is in the commit message will helpful to reviewers.

http://docs.zephyrproject.org/contribute/contribute_guidelines.html

 

Andrew

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of zhou.xin8@...
Sent: Wednesday, December 20, 2017 12:26 AM
To: zephyr-devel@...
Cc: liu.yanan1@...; leng.tong@...
Subject: [Zephyr-devel] Request review for re-alloc patch @k_mem_pool_alloc()

 

Hi

 

k_mem_pool_alloc()

When race condition failure (-EAGAIN), need to try re-alloc.

We have verified this patch on Zephyr OS v1.9.0.

 

Index: kernel/mempool.c

===================================================================

--- kernel/mempool.c    (revision 70)

+++ kernel/mempool.c    (working copy)

@@ -300,6 +300,11 @@

        while (1) {

                ret = pool_alloc(p, block, size);

 

+               /* [Sanechips] When race condition causes failure, re_alloc. */

+               if (ret == -EAGAIN) {

+                       continue;

+               }

+

                if (ret == 0 || timeout == K_NO_WAIT ||

                    ret == -EAGAIN || (ret && ret != -ENOMEM)) {

                        return ret;

 

 

 

周欣 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@...

 

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