Bug 702826

Summary: GNU time reports incorrect maximum RSS
Product: [Fedora] Fedora Reporter: Michael Chapman <redhat-bugzilla>
Component: timeAssignee: Petr Pisar <ppisar>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 14CC: ppisar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: http://lists.gnu.org/archive/html/bug-gnu-utils/2008-12/msg00043.html
Fixed In Version: time-1.7-38.fc13 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 703865 (view as bug list) Environment:
Last Closed: 2011-05-19 04:58:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
Do not incorrectly convert ru_maxrss none

Description Michael Chapman 2011-05-07 14:07:30 UTC
Description of problem:

GNU time can print out the maximum RSS usage of its subprocess. The ru_maxrss value returned by the wait4 syscall is in units of kilobytes, but GNU time incorrectly treats this as a number of pages, multiplying the value by 4 before displaying it.

Version-Release number of selected component (if applicable):

How reproducible: Always

Steps to Reproduce:
1. /usr/bin/time -f %M perl -e '"x" x 400 x 1024 x 1024'
Actual results: A bit over 1600000, indicating maximum RSS usage of 1.6 GB. This is not even possible on my system as it only has 1 GB of physical RAM.

Expected results: Approximately 400000, since Perl should only be allocating around 400 MB.

Additional info:

Applying strace to the above command, it is clear that time is multiplying the ru_maxrss value returned by wait4:

$ strace -ve wait4 /usr/bin/time -f %M perl -e '"x" x 400 x 1024 x 1024'
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, {ru_utime={0, 146977}, ru_stime={0, 676897}, ru_maxrss=411356, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=102901, ru_majflt=1, ru_nswap=0, ru_inblock=176, ru_oublock=0, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=1, ru_nivcsw=40}) = 7459
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=7459, si_status=0, si_utime=14, si_stime=68} (Child exited) ---

According to the getrusage(2) manpage:

  ru_maxrss (since Linux 2.6.32)
     This is the maximum resident set size used (in kilobytes). [...]

I've attached a simple patch that simply skips the "pages to kilobytes" conversion for this field.

Comment 1 Michael Chapman 2011-05-07 14:09:53 UTC
Created attachment 497533 [details]
Do not incorrectly convert ru_maxrss

Comment 2 Petr Pisar 2011-05-11 12:52:21 UTC
All Fedoras affected (time-1.7).

Comment 3 Petr Pisar 2011-05-11 13:44:39 UTC
Thank you for the report, fixed time version will be pushed into Fedoras soon.

Comment 4 Petr Pisar 2011-05-11 16:16:56 UTC
Fixed in time-1.7-39.fc16 for F16.

Comment 5 Fedora Update System 2011-05-11 16:27:09 UTC
time-1.7-39.fc15 has been submitted as an update for Fedora 15.

Comment 6 Fedora Update System 2011-05-11 16:28:01 UTC
time-1.7-38.fc14 has been submitted as an update for Fedora 14.

Comment 7 Fedora Update System 2011-05-11 16:28:16 UTC
time-1.7-38.fc13 has been submitted as an update for Fedora 13.

Comment 8 Fedora Update System 2011-05-13 23:02:07 UTC
Package time-1.7-38.fc14:
* should fix your issue,
* was pushed to the Fedora 14 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing time-1.7-38.fc14'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2011-05-19 04:58:41 UTC
time-1.7-39.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Fedora Update System 2011-05-25 02:28:19 UTC
time-1.7-38.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2011-05-25 02:53:48 UTC
time-1.7-38.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.