** Description changed:

  [ Impact ]
  
- * ps is not reporting correct elapsed time in Noble.
+ ps is not reporting correct elapsed time in Noble LXD containers. 
+ Example of failure inside a Noble LXD container:
  
  root@test:~# ps -p 333 -o pid,stime,cmd,etime
-     PID STIME CMD                             ELAPSED
-     333 05:12 @dbus-daemon --system --add 441077219-06:12:48
+     PID STIME CMD                             ELAPSED
+     333 05:12 @dbus-daemon --system --add 441077219-06:12:48
  
- * This will lead to issues when the time is used in scripts
- automatically
+ This issue is caused by a timing conflict between the libproc2 library
+ (compiled from library/pids.c) and the container virtualization layer,
+ LXCFS.
+ 
+ To provide container isolation, LXCFS intercepts reads to
+ /proc/[pid]/stat and modifies the process start time to make it relative
+ to the container’s recent boot, which would be a very small number.
+ However, the libproc2 library still fetches the current system time
+ using internal metrics tied to the host kernel's original boot, which
+ would be a huge number.
+ 
+ When ps runs, it subtracts this tiny, container-isolated process start
+ time from the massive, host-wide current system time. Mixing these two
+ mismatched clock baselines forces an impossible calculation, resulting
+ in the wildly inaccurate elapsed time.
+ 
+ 
+ This has been reported and patched upstream already and released. The patch 
fixes the issue by changing the current system time calculation to leverage 
clock_gettime(CLOCK_BOOTTIME) instead of filesystem parsing metrics. Because 
CLOCK_BOOTTIME queries the kernel directly for the system's execution ticks 
since initialization, it bypasses the /proc virtualization file layer. Both the 
current timestamp and the process initialization timestamps are fetched from 
the exact same kernel time namespace context.
+ 
+ Patch for the fix -
+ 
https://git.launchpad.net/ubuntu/+source/procps/tree/debian/patches/library_use_clock_gettime
  
  [ Test Plan ]
+ 1. Create two LXD containers, one for Noble (24.04) and another for Questing 
(25.10) or any version after Noble, and run:
+     1.1 ps aux to fetch pids
+     1.2 ps -p <pid> -o pid,stime,cmd,etime
  
+ 2. Notice the incorrect etime in Noble, while the same works fine on the
+ newer release.
+ 
+ 3. Retrieve the patch, apply, and build the package to verify the fix on
+ the LXD Noble container.
  
  [ Where problems could occur ]
- 
+ Any custom scripts that were handled to explicitly work around the broken, 
overflowing etime strings might break post this release into Noble
  
  [ Other Info ]
+ This fix is already committed and live in subsequent Ubuntu releases after 
Noble. The current work is to track the backport into Noble

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2159938

Title:
  ps not reporting correct elapsed time

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/procps/+bug/2159938/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to