19 Nov, 2020

1 commit

  • A porting error in commit 0ae8088521d9 ("ANDROID: uid_cputime: Adds
    accounting for the cputimes per uid.") caused
    /proc/uid_cputime/show_uid_stat to report times in milliseconds
    instead of microseconds. Restore the expected behavior.

    Bug: 133273154
    Bug: 146339763
    Signed-off-by: Ed Savage-Jones
    Signed-off-by: Connor O'Brien
    Change-Id: I203919d1d44b300dab91810b16626a6950b063f8
    (cherry picked from commit 305d5c197508b80a8dec0ab506de309e5d85fd26)

    Connor O'Brien
     

25 Jun, 2020

1 commit


25 Apr, 2020

1 commit


07 Mar, 2020

1 commit


08 Feb, 2020

1 commit


15 Nov, 2019

1 commit

  • When a thread is being killed process_notifier() is called to record
    the final accounting of the thread. But after that uid_cputime_show()
    and add_uid_io_stats() can be called before the dying thread is
    removed from the parent's thread_group resulting in double accounting.

    This can cause the user and system time for a given UID to move
    backwards in /proc/uid_cputime/show_uid_stat. That gives negative delta
    times in KernelCpuUidUserSysTimeReader.readDeltaImpl() and it logs
    an error:

    "Negative user/sys time delta for UID=..."

    One consequence of which was incorrectly calculated power consumptions
    in BatteryStats.

    With this change we avoid the double accounting by ignoring the thread
    if it has the PF_EXITING flag set.

    Bug: 144366911

    Change-Id: I6b929e8f558cd81ce1c00481c8b550d24877aa2c
    Signed-off-by: Rickard Möller

    Rickard Möller
     

04 May, 2019

4 commits

  • Add /proc/uid_time_in_state showing per uid/frequency/cluster
    times. Allow uid removal through /proc/uid_cputime/remove_uid_range.

    Signed-off-by: Connor O'Brien
    Bug: 72339335
    Bug: 127641090
    Test: Read /proc/uid_time_in_state
    Change-Id: I20ba3546a27c25b7e7991e2a86986e158aafa58c

    Connor O'Brien
     
  • This adds a counter to the taskstats extended accounting fields, which
    tracks the number of times fsync is called, and then plumbs it through
    to the uid_sys_stats driver.

    Bug: 120442023
    Change-Id: I6c138de5b2332eea70f57e098134d1d141247b3f
    Signed-off-by: Jin Qian
    [AmitP: Refactored changes to align with changes from upstream commit
    9a07000400c8 ("sched/headers: Move CONFIG_TASK_XACCT bits from to ")]
    Signed-off-by: Amit Pundir
    [tkjos: Needed for storaged fsync accounting ("storaged --uid" and
    "storaged --task").]
    [astrachan: This is modifying a userspace interface and should probably
    be reworked]
    Signed-off-by: Alistair Strachan

    Jin Qian
     
  • IO usages are accounted in foreground and background buckets.
    For each uid, io usage is calculated in two steps.

    delta = current total of all uid tasks - previus total
    current bucket += delta

    Bucket is determined by current uid stat. Userspace writes to
    /proc/uid_procstat/set when uid stat is updated.

    /proc/uid_io/stats shows IO usage in this format.

    Bug: 34198239
    Bug: 120442023
    Change-Id: Ib8bebda53e7a56f45ea3eb0ec9a3153d44188102
    Signed-off-by: Jin Qian
    [connoro: Used by storaged.]
    [astrachan: Note: this version does not track fsync syscalls; this is
    implemented in a follow up due to the fact it depends on
    modifications to the task_xacct feature.]
    [astrachan: Folded in the following changes:
    e003a91d8f42 ("ANDROID: uid_sys_stats: allow writing same state")
    89b984bf2efd ("ANDROID: uid_sys_stats: fix negative write bytes.")
    bb5ee21cc4dd ("ANDROID: uid_sys_stats: change to use rt_mutex")
    9297d5a160c7 ("ANDROID: uid_sys_stats: reduce update_io_stats overhead")
    89402d07fe91 ("ANDROID: uid_sys_stats: defer io stats calulation for dead tasks")
    6dc5d8173a8c ("ANDROID: uid_sys_stats: check previous uid_entry before call find_or_register_uid")
    0ca2ece8f7ec ("ANDROID: uid_sys_stats: log task io with a debug flag")
    c9c096ef0e67 ("ANDROID: uid_sys_stats: Copy task_struct comm field to bigger buffer")]
    Signed-off-by: Alistair Strachan

    Jin Qian
     
  • Adds proc files /proc/uid_cputime/show_uid_stat and
    /proc/uid_cputime/remove_uid_range.

    show_uid_stat lists the total utime and stime for the active as well as
    terminated processes for each of the uids.

    Writing a range of uids to remove_uid_range will delete the accounting
    for all the uids within that range.

    Bug: 120442023
    Change-Id: I21d9210379da730b33ddc1a0ea663c8c9d2ac15b
    Signed-off-by: Jin Qian
    [AmitP: Refactored the original patch because upstream commit
    605dc2b31a2a ("tsacct: Convert obsolete cputime type to nsecs")
    made cputime_t type obsolete, so use u64 nanoseconds directly instead.
    Also folded following android-4.9 changes into this patch
    48a9906c0fd8 ("ANDROID: proc: uid_cputime: create uids from kuids")
    453ac31cab34 ("ANDROID: proc: uid_cputime: fix show_uid_stat permission")]
    Signed-off-by: Amit Pundir
    [connoro: Used by batterystats.]
    [astrachan: Folded in the file/kconfig rename and the following changes:
    da3687fbc393 ("ANDROID: uid_cputime: fix cputime overflow")
    71e3eb512d00 ("ANDROID: uid_cputime: Iterates over all the threads instead of processes.")
    c65f0080c300 ("ANDROID: uid_cputime: Check for the range while removing range of UIDs.")
    c8212458e3a5 ("ANDROID: uid_sys_stats: fix access of task_uid(task)")
    bb5ee21cc4dd ("ANDROID: uid_sys_stats: change to use rt_mutex")
    6dc5d8173a8c ("ANDROID: uid_sys_stats: check previous uid_entry before call find_or_register_uid")
    82b9872b3894 ("ANDROID: uid_sys_stats: Replace tasklist lock with RCU in uid_cputime_show")]
    Signed-off-by: Alistair Strachan

    Jin Qian