Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmds] Add process name to meminfo display #1610

Merged
merged 1 commit into from
Jun 12, 2023
Merged

[cmds] Add process name to meminfo display #1610

merged 1 commit into from
Jun 12, 2023

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Jun 12, 2023

Requested by @tyama501 in #1366 (comment).

New display looks like this:

# meminfo 
  HEAP   TYPE  SIZE    SEG   TYPE    SIZE  CNT  NAME
  c9de   SEG     16   253f   BUF    65008    1  
  c9fa   INT      6
  ca0c   INT      6
  ca1e   INT      6
  ca30   BUFH  5000
  ddc4   SEG     16   351e   CSEG    7056    1  /bin/init 
  dde0   INT      6
  ddf2   TTY   1024
  e1fe   TTY     80
  e25a   SEG     16   36d7   DSEG    5824    1  /bin/init 
  e276   SEG     16   3843   free   11648    0  
  e292   SEG     16   5688   DSEG   15392    1  meminfo 
  e2ae   SEG     16   3b1b   CSEG    5408    1  /bin/getty 
  e2ca   TTY     80
  e326   TTY     80
  e382   SEG     16   3c6d   DSEG    3088    1  /bin/getty 
  e39e   SEG     16   3d2e   CSEG    3872    1  meminfo 
  e3ba   SEG     16   3e20   free    6256    0  
  e3d6   SEG     16   3fa7   CSEG   43952    1  -/bin/sh 
  e3f2   SEG     16   4a62   DSEG   24880    1  -/bin/sh 
  e40e   SEG     16   5075   free   24880    0  
  e42a   SEG     16   5a4a   free  284512    0  
  e446   free  7098
  Heap/free   13870/ 7098 Total mem  501776
  Memory usage  490KB total,  170KB used,  320KB free

@tyama501
Copy link
Contributor

Wow! Great, thank you.

@ghaerr ghaerr merged commit e17e08e into ghaerr:master Jun 12, 2023
@tyama501
Copy link
Contributor

For PC-98, it seems that "taskinfo: Bad address" occurs and no NAMEs.
Do I need to modify something?

image

Thank you.

@ghaerr
Copy link
Owner Author

ghaerr commented Jun 16, 2023

Hello @tyama501,

For PC-98, it seems that "taskinfo: Bad address" occurs and no NAMEs.

Geez. The meminfo program is reading the kernel task[] array as a whole in order to more quickly access the structure. That read is failing because the PC-98 KSTACK_BYTES value is larger in struct task_struct in include/sched.h. Thus, the meminfo program will need to be compiled specially for PC-98 with CONFIG_ARCH_PC98 set.

I am assuming you're using a pre-built image from the Github CI. If you build the system on your own, meminfo should work. Adding the following line in elks-root/build.sh should fix the CI issue:

# Build PC-98 kernel, some user land files and image
if [ "$1" = "auto" ]; then
    echo "Building PC-98 image..."
    cp pc98-1232.config .config
    make kclean || clean_exit 9
    rm elkscmd/sys_utils/clock.o
    rm elkscmd/basic/*.o
    rm elkscmd/sys_utils/ps.o
    rm elkscmd/sys_utils/meminfo.o  <--- ADD THIS LINE
    rm elkscmd/nano-X/*/*.o
    make -j1 || clean_exit 10
fi

Can you try building ELKS on your own, to see whether meminfo then works? If so, I can submit a PR for the above fix to CI.

Thank you!

@tyama501
Copy link
Contributor

Thank you @ghaerr ,

Well, I have built my own image after make clean...

@ghaerr
Copy link
Owner Author

ghaerr commented Jun 17, 2023

Ok, I see now. It needs the above change, as well as below. My original enhancement was trying to read in far too much data, and it wrapped around 16-bits. Please test the following and let me know if it works, and I'll post a PR:

--- a/elkscmd/sys_utils/meminfo.c
+++ b/elkscmd/sys_utils/meminfo.c
@@ -187,7 +187,7 @@ int main(int argc, char **argv)
           perror("meminfo");
         return 1;
     }
-    if (!memread(fd, taskoff, ds, &task_table, MAX_TASKS*sizeof(task_table))) {
+    if (!memread(fd, taskoff, ds, &task_table, sizeof(task_table))) {
         perror("taskinfo");
     }
        dump_heap(fd);

@tyama501
Copy link
Contributor

Thank you!
It worked.

image

@ghaerr ghaerr deleted the meminfo branch August 3, 2023 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants