Hi, Kazu
Thank you for the comment.
On Fri, Mar 17, 2023 at 9:02 AM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com> wrote:
Hi Lianbo,

On 2023/03/15 18:07, Lianbo Jiang wrote:
> The help/man page of the "vm" command suggests that the "-M" option
> accepts the mm_struct address as a valid argument. However, the "vm
> -M" option always prints the virtual memory data of the current
> task, regardless of its arguments.

I think that it's the intended behavior, isn't it?

          -M mm  if the mm_struct address has been removed from the task_struct
                 of an exiting task, the virtual memory data cannot be displayed.
                 However, if the address can be determined from the kernel stack,
                 it can be entered manually in order to try to resurrect the
                 virtual memory data of the task.

 
They are not the same issues.

For the live debugging, take the sshd as an example:

Without the patch:
crash> ps |grep sshd
     1159       1   3  ffff9915858a9980  IN   0.1    15820     9020  sshd
    51573    1159   2  ffff991572868000  IN   0.1    18916    11168  sshd
    51595   51573   2  ffff991575026600  IN   0.0    18784     6892  sshd
crash> vm -M ffff991572868000
PID: 51727    TASK: ffff9914465cb300  CPU: 0    COMMAND: "crash"   <------not a correct result
       MM               PGD          RSS    TOTAL_VM
ffff991572665f00  ffff99158565e000  448808k  2426788k
      VMA           START       END     FLAGS FILE
ffff991574e20a18     400000     4de000 8000071 /home/crash/crash
ffff991574e20ab0     4de000     a85000 8000075 /home/crash/crash
ffff991574e20260     a85000     e0f000 8000071 /home/crash/crash
ffff991574e204c0     e0f000     e10000 8100071 /home/crash/crash
ffff991443987980     e10000     e37000 8100073 /home/crash/crash
ffff991574e20720     e37000    1105000 8100073
ffff9914439877b8    21ab000    a178000 8100073
ffff991573b4b5f0 7f4304174000 7f4310000000 8100073
ffff9914d387e098 7f4310000000 7f431006c000 8200073
...


With the patch:
crash> ps |grep sshd
     1159       1   3  ffff9915858a9980  IN   0.1    15820     9020  sshd
    51573    1159   2  ffff991572868000  IN   0.1    18916    11168  sshd
    51595   51573   2  ffff991575026600  IN   0.0    18784     6892  sshd
crash> vm -M ffff991572868000
PID: 51573    TASK: ffff991572868000  CPU: 2    COMMAND: "sshd" <---an expected result
       MM               PGD          RSS    TOTAL_VM
ffff991449816900  ffff991442d68000  11168k   18916k
      VMA           START       END     FLAGS FILE
ffff991445df8da8 556020069000 556020075000 8000071 /usr/sbin/sshd
ffff991445df8390 556020075000 556020102000 8000075 /usr/sbin/sshd
ffff991445df87b8 556020102000 55602014c000 8000071 /usr/sbin/sshd
ffff991445df8850 55602014c000 556020150000 8100071 /usr/sbin/sshd
ffff99144a5efd10 556020150000 556020151000 8100073 /usr/sbin/sshd
ffff991445df82f8 556020151000 556020155000 8100073
ffff99157750fe40 556020753000 556020838000 8100073
ffff99158602d688 7ff090f6c000 7ff090f73000 8000071 /usr/lib64/libnss_systemd.so.2
...

Another example with an invalid argument:
Without the patch:
crash> vm -M 0xdeadbeef
PID: 51944    TASK: ffff99148c036600  CPU: 2    COMMAND: "crash"
       MM               PGD          RSS    TOTAL_VM
ffff9915745e8000  ffff9915728c4000  448684k  2426788k
      VMA           START       END     FLAGS FILE
ffff9914c07547b8     400000     4de000 8000071 /home/crash/crash
ffff9914c0754688     4de000     a85000 8000075 /home/crash/crash
ffff9914c0754ed8     a85000     e0f000 8000071 /home/crash/crash
ffff9914c0754c78     e0f000     e10000 8100071 /home/crash/crash
ffff99158554f1c8     e10000     e37000 8100073 /home/crash/crash
ffff9914c07544c0     e37000    1105000 8100073
ffff99158554f098    2b3f000    ab0c000 8100073
ffff9915490871c8 7fde73358000 7fde74321000 8100073
ffff9914c0426260 7fde76b50000 7fde84000000 8100073
...

With the patch:
crash> vm -M 0xdeadbeef
vm: invalid task or pid value: 0xdeadbeef

Hope this helps.

Thanks
Lianbo