Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-16278

top fails to display processes for a specific user if sorting by memory with M

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • rhel-9.4
    • rhel-9.2.0
    • procps-ng
    • None
    • procps-ng-3.3.17-14.el9
    • sst_cs_plumbers
    • ssg_core_services
    • 25
    • 3
    • False
    • Hide

      None

      Show
      None
    • Yes
    • Bug Fix
    • Hide
      .The `top -u` command now displays at least one process when you sort the processes by memory

      Previously, when you executed the `top` command with the `-u _<user>_` parameter, where the `_user_` was different from the one running the command, all processes disappeared when the `M` key was pressed to sort the processes by memory. With this update, the `top` command displays at least one process when you sort the processes by memory.

      [NOTE]
      ====
      To preserve the position of the cursor, not all processes are displayed. You can scroll up through the results to display the remaining processes.
      ====
      Show
      .The `top -u` command now displays at least one process when you sort the processes by memory Previously, when you executed the `top` command with the `-u _<user>_` parameter, where the `_user_` was different from the one running the command, all processes disappeared when the `M` key was pressed to sort the processes by memory. With this update, the `top` command displays at least one process when you sort the processes by memory. [NOTE] ==== To preserve the position of the cursor, not all processes are displayed. You can scroll up through the results to display the remaining processes. ====
    • Done
    • All
    • None

      What were you trying to do that didn't work?

      1. top -u <username>

      press "M" to sort by memory usage

      Please provide the package NVR for which bug is seen:

      procps-ng-3.3.17-11.el9.x86_64

      How reproducible:

      Consistently even on a fresh install.

      Steps to reproduce

      There are multiple ways to reproduce this issue: 

      A: 

      1. I have a user "test" who currently has two ssh sessions which are each watching a log file. As the root user, I execute "top -u test":
        -------------------------------
      2. top -u test

      top - 11:34:11 up 15 days,  3:17,  4 users,  load average: 0.00, 0.00, 0.00
      Tasks: 111 total,   1 running, 110 sleeping,   0 stopped,   0 zombie
      %Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
      MiB Mem :   1766.2 total,   1111.2 free,    356.0 used,    446.8 buff/cache
      MiB Swap:      0.0 total,      0.0 free,      0.0 used.   1410.2 avail Mem 

          PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND 
        22696 test      20   0    8816   5564   3520 S   0.0   0.3   0:00.02 bash    
        22723 test      20   0    8684   5500   3540 S   0.0   0.3   0:00.01 bash    
        22744 test      20   0    6156   2820   2420 S   0.0   0.2   0:00.14 watch   
        22764 test      20   0    6156   2804   2408 S   0.0   0.2   0:00.13 watch   
      -------------------------------

      1. Pressing "M" results in no processes showing: 
        -------------------------------
        top - 11:35:00 up 15 days,  3:18,  4 users,  load average: 0.00, 0.00, 0.00
        Tasks: 111 total,   1 running, 110 sleeping,   0 stopped,   0 zombie
        %Cpu(s):  0.3 us,  0.7 sy,  0.0 ni, 98.3 id,  0.0 wa,  0.3 hi,  0.0 si,  0.3 st
        MiB Mem :   1766.2 total,   1111.2 free,    356.0 used,    446.8 buff/cache
        MiB Swap:      0.0 total,      0.0 free,      0.0 used.   1410.2 avail Mem 

          PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND 
      -------------------------------

      B: 

      1. This can also be reproduced by executing "top", then searching for a specific user and sorting with M. While the same test user is logged in with the same processes running in another console, I execute simply "top" as the root user, then press "u" and enter "test" to show only processes owned by the test user: 
        -------------------------------
        top - 11:37:06 up 15 days,  3:20,  4 users,  load average: 0.00, 0.00, 0.00
        Tasks: 111 total,   1 running, 110 sleeping,   0 stopped,   0 zombie
        %Cpu(s):  0.3 us,  0.7 sy,  0.0 ni, 98.7 id,  0.0 wa,  0.3 hi,  0.0 si,  0.0 st
        MiB Mem :   1766.2 total,   1111.2 free,    356.0 used,    446.8 buff/cache
        MiB Swap:      0.0 total,      0.0 free,      0.0 used.   1410.2 avail Mem 

          PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND 
        22764 test      20   0    6156   2804   2408 S   0.3   0.2   0:00.22 watch   
        22681 test      20   0   22360  14392  11244 S   0.0   0.8   0:00.15 systemd 
        22683 test      20   0  173456   7236      0 S   0.0   0.4   0:00.00 (sd-pa+ 
        22695 test      20   0   20612   7872   5712 S   0.0   0.4   0:00.15 sshd    
        22696 test      20   0    8816   5564   3520 S   0.0   0.3   0:00.02 bash    
        22722 test      20   0   20616   7912   5748 S   0.0   0.4   0:00.15 sshd    
        22723 test      20   0    8684   5500   3540 S   0.0   0.3   0:00.01 bash    
        22744 test      20   0    6156   2820   2420 S   0.0   0.2   0:00.21 watch 
      -------------------------------

      1. If I then press "M" to sort by memory, the processes disappear again: 
        -------------------------------
        top - 11:37:47 up 15 days,  3:21,  4 users,  load average: 0.00, 0.00, 0.00
        Tasks: 111 total,   1 running, 110 sleeping,   0 stopped,   0 zombie
        %Cpu(s):  0.0 us,  2.0 sy,  0.0 ni, 96.0 id,  0.0 wa,  2.0 hi,  0.0 si,  0.0 st
        MiB Mem :   1766.2 total,   1111.2 free,    356.0 used,    446.8 buff/cache
        MiB Swap:      0.0 total,      0.0 free,      0.0 used.   1410.2 avail Mem 

          PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND 
      -------------------------------

      Expected results

      Sorting a particular user's processes by memory should not cause top to fail. 

      Actual results

      Top stops showing processes if you limit the results to a specific user and then sort by memory. 

      Additional notes:

      If I run "top" as the test user, and then press "M", the processes are sorted by memory usage as expected and do not disappear. 

      Additionally, if "top" is executed by the root user and you sort with "M" first and then limit the processes to a single user with "u", the processes are still displayed and sorted by memory usage as expected.

            jrybar@redhat.com Jan Rybar
            rhn-support-lagordon Lark Gordon
            Jan Rybar Jan Rybar
            Karel Volný Karel Volný
            Mugdha Soni Mugdha Soni
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: