nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

mempool:change sq to dq,free to head, alloc form tail

Open anjiahao1 opened this issue 1 year ago • 6 comments

Summary

Mempool:Change single queue to double queue and add more checks

Impact

mempool

Testing

sim with mm_testing & mempool

add santiy check for used after free Using a double linked queue can allow the free memory to be malloced out in the end. Use tools (Kasan) as much as possible to check the memory stampede problem without causing speed reduction or memory usage.

anjiahao1 avatar Dec 08 '23 07:12 anjiahao1

@anjiahao1 please add a little bit more information in the commit log message. Please explain the main motivation of this modification.

acassis avatar Dec 09 '23 00:12 acassis

@xiaoxiang781216 @anjiahao1 @davids5 @raiden00pl @patacongo is there some alternative to avoid declaring these functions inside a function? I'm afraid it is not C89 compatible.

acassis avatar Dec 11 '23 14:12 acassis

@xiaoxiang781216 @anjiahao1 @davids5 @raiden00pl @patacongo is there some alternative to avoid declaring these functions inside a function? I'm afraid it is not C89 compatible.

What do you mean "function inside a function"? The violation I can find is inline. I would say that it's very bad idea to disallow the using of inline.

xiaoxiang781216 avatar Dec 11 '23 16:12 xiaoxiang781216

@xiaoxiang781216 @anjiahao1 @davids5 @raiden00pl @patacongo is there some alternative to avoid declaring these functions inside a function? I'm afraid it is not C89 compatible.

What do you mean "function inside a function"? The violation I can find is inline. I would say that it's very bad idea to disallow the using of inline.

That:

  dq_for_every(queue, entry)
    {
      count++;
    }

I don't see it usually in the source code, I don't know exactly what is it. I only found that dq_for_every() inside this python script: tools/gdb/lists.py

What is it? What is it used for?

acassis avatar Dec 11 '23 20:12 acassis

dq_for_every is a new macro added in this patch: image just simply forward to sq_for_every macro which expand to a for loop.

xiaoxiang781216 avatar Dec 12 '23 01:12 xiaoxiang781216

dq_for_every is a new macro added in this patch: image just simply forward to sq_for_every macro which expand to a for loop.

Ok, now I got the idea, of each run in this loop it will run the code inside "{ }", in this case count++.

acassis avatar Dec 12 '23 13:12 acassis