You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "yf13 (via GitHub)" <gi...@apache.org> on 2024/08/01 04:19:37 UTC

[PR] rocfs/meminfo: free delaylist for PROTECTED [nuttx]

yf13 opened a new pull request, #12817:
URL: https://github.com/apache/nuttx/pull/12817

   ## Summary
   
   Currently on PROTECTED targets, used Umem aren't timely reclaimed. For example, the `used` number for `Umem` before and after running `hello` app are different, feeling like a leakage.
   
   This triggers a `free_delaylist()` operation upon `free` command so that the information shown matches real situation and `used` number for `Umem` is the same before and after running `hello` app.
   
   ## Impacts
   
   `used` number for `Umem` in output of `free` command for PROTECTED targets.
   
   ## Testing
   
   - local checks with PROTECTED targets
   - CI checking
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#discussion_r1699764284


##########
fs/procfs/fs_procfsmeminfo.c:
##########
@@ -314,6 +317,17 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
           buffer    += copysize;
           buflen    -= copysize;
 
+#ifdef CONFIG_BUILD_PROTECTED
+          /* Trigger free_delaylist operation once */
+
+          ptr = mm_malloc(entry->heap, 0);

Review Comment:
   Why not change `free_delaylist()` to public function?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2264362526

   @anchao, I see your points. My feeling is that delaylist is there to avoid too early reclamations, and the `free` command time feels like a deadline to report real situation. The issue feels more like "when is the best reclamation time" for us. Please feel free to teach if you have more ideas in mind.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#discussion_r1699658051


##########
fs/procfs/fs_procfsmeminfo.c:
##########
@@ -314,6 +317,17 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
           buffer    += copysize;
           buflen    -= copysize;
 
+#ifdef CONFIG_BUILD_PROTECTED
+          /* Trigger free_delaylist operation once */

Review Comment:
   let's add more comment here



##########
fs/procfs/fs_procfsmeminfo.c:
##########
@@ -314,6 +317,17 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
           buffer    += copysize;
           buflen    -= copysize;
 
+#ifdef CONFIG_BUILD_PROTECTED
+          /* Trigger free_delaylist operation once */
+
+          ptr = mm_malloc(entry->heap, 0);

Review Comment:
   merge line 283 here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#discussion_r1701791910


##########
fs/procfs/fs_procfsmeminfo.c:
##########
@@ -314,6 +314,14 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
           buffer    += copysize;
           buflen    -= copysize;
 
+#ifdef CONFIG_BUILD_PROTECTED

Review Comment:
   let' remove the check



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2264534936

   @anchao, thanks for further explanations.
   I sent an update with `void mm_free_delaylist(heap)` interface added. It can simplify `proc/meminfo` side as you suggested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2262717029

   @pussuw, thanks for sharing more background.
   
   @pkarashchenko and xiaoxiang781216, thanks for the in-place comments, I've sent an update.
   
   @anchao, Maybe API refactoring can be a separate topic?
   
   I found most recent k230 issues can reproduce with QEMU. Instead of relying on real device based checks, I am wondering our CI checkers can check selected configs with  `free` check before and after `ostest`?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2264359250

   @anchao, I see your points. My feeling is that delaylist is there to avoid too early reclamations, and the `free` command time feels like a deadline to report real situation. The issue feels more like "when is the best reclamation time" for us. Please feel free to teach if you have a solution in mind.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist before reporting [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #12817:
URL: https://github.com/apache/nuttx/pull/12817


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2264282748

   
   > @anchao, Maybe API refactoring can be a separate topic? my purpose was just to see more real information from `free` command.
   
   Inaccurate free data is a minor issue, It does not have any impact on OS functionality, I think we should solve the issue with a more perfect solution rather than applying a lot of strange patches.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2264397298

   @yf13 Perhaps I didn't express clearly. What I mean is to replace the malloc/free with mm_free_delaylist:
   
   ```
   #ifdef CONFIG_BUILD_PROTECTED
             /* Trigger reclamation of delay list otherwise they will be
              * counted as used, which often confuses people like memory
              * leakages. see pull/12817 for more information.
              */
             
             mm_free_delaylist(entry->heap, ture);
   #endif
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2262719008

   @pussuw, thanks for sharing more background.
   
   @pkarashchenko and @xiaoxiang781216, thanks for the in-place comments, I've sent an update.
   
   @anchao, Maybe API refactoring can be a separate topic? my purpose was just to see more real information from `free` command.
   
   I found most recent k230 issues can reproduce with QEMU. Instead of relying on real device based checks, I am wondering our CI checkers can check selected configs with  `free` check before and after `ostest`?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] rocfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#discussion_r1699385400


##########
fs/procfs/fs_procfsmeminfo.c:
##########
@@ -279,6 +279,9 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
   size_t copysize;
   size_t totalsize;
   off_t offset;
+#ifdef CONFIG_BUILD_PROTECTED
+  void *ptr;

Review Comment:
   ```suggestion
     FAR void *ptr;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "pussuw (via GitHub)" <gi...@apache.org>.
pussuw commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2262263672

   The issue seems familiar, I reported a similar issue before: https://github.com/apache/nuttx/issues/11115
   
   Even though it is SMP related, the problem with the freelist is that it is opportunistically freed, which leads to situations like this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2264544015

   @yf13 I'm wondering if it would be more appropriate to use the posix or linux api, eg `malloc_trim()`?
   https://man7.org/linux/man-pages/man3/malloc_trim.3.html
   
   @xiaoxiang781216 What do you think?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] procfs/meminfo: free delaylist for PROTECTED [nuttx]

Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on PR #12817:
URL: https://github.com/apache/nuttx/pull/12817#issuecomment-2264998015

   It seems that `malloc_trim()` is for userspace to adjust its user heap size. Our problem here is more like a kernel internal house-keeper function.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org