[Toybox] [PATCH] ps: drop dependency on Android's libprocessgroup.
enh
enh at google.com
Mon Aug 26 15:01:38 PDT 2024
On Mon, Aug 26, 2024 at 11:14 AM T.J. Mercier <tjmercier at google.com> wrote:
>
> On Fri, Aug 23, 2024 at 3:52 PM enh <enh at google.com> wrote:
> >
> > This dependency keeps getting hairier and hairier (json!) and the
> > current system for policy scheduling is actually quite different from
> > the original anyway.
> > ---
> > lib/portability.h | 14 --------------
> > toys/posix/ps.c | 33 ++++++++++++++++++++++++++++-----
> > 2 files changed, 28 insertions(+), 19 deletions(-)
>
> Hi,
>
> I assume this mailing list is supposed to be Content-Type: text/plain?
(i don't think anybody cares that much.)
> > + else if (!strcmp(s, "system-background")) strcpy(tb->pcy, " ");
>
> Is this empty for compatibility with the existing output?
correct. i kind of hate that there's a field that _deliberately_ isn't
parseable, but if our current argument is "we shouldn't just _remove_
this because someone's probably using it for something", it makes
sense to have the same output.
> system_server is a "fun" case but I think this new toybox code should
> still report the same info. It has threads in different cgroups (all
> under the same pid of course):
> husky:/dev/cpuset/system-background # cat cgroup.procs | xargs ps -o
> pid,pcy,comm,cmd
> PID PCY COMM CMD
> 492 logd logd
> 493 lmkd lmkd
> 503 hwservicemanager hwservicemanage
> 504 vndservicemanager vndservicemanag
> 574 android.hardware.composer.+ binder:574_3
> 727 tombstoned tombstoned
> 976 android.hardware.sensors-s+ binder:976_3
> 985 fg app_process64 system_server
> 1475 storaged storaged
> 1483 dmd dmd
> 1581 gatekeeperd gatekeeperd
> 1637 logcat logcat
>
> husky:/dev/cpuset/system-background # cat /proc/985/cgroup
> 3:cpuset:/foreground
> 2:cpu:/
> 1:blkio:/
> 0::/uid_1000/pid_985
>
> husky:/ # grep cpuset /proc/`pidof system_server`/task/*/cgroup
> /proc/985/task/1028/cgroup:3:cpuset:/foreground
> /proc/985/task/1029/cgroup:3:cpuset:/foreground
> /proc/985/task/1031/cgroup:3:cpuset:/foreground
> /proc/985/task/1032/cgroup:3:cpuset:/foreground
> /proc/985/task/1033/cgroup:3:cpuset:/foreground
> /proc/985/task/1034/cgroup:3:cpuset:/foreground
> /proc/985/task/1035/cgroup:3:cpuset:/foreground
> /proc/985/task/1036/cgroup:3:cpuset:/foreground
> /proc/985/task/1037/cgroup:3:cpuset:/foreground
> /proc/985/task/1038/cgroup:3:cpuset:/foreground
> /proc/985/task/1049/cgroup:3:cpuset:/foreground
> /proc/985/task/1050/cgroup:3:cpuset:/foreground
> /proc/985/task/1051/cgroup:3:cpuset:/foreground
> /proc/985/task/1052/cgroup:3:cpuset:/foreground
> /proc/985/task/1053/cgroup:3:cpuset:/foreground
> /proc/985/task/1054/cgroup:3:cpuset:/foreground
> /proc/985/task/1055/cgroup:3:cpuset:/top-app
> /proc/985/task/1056/cgroup:3:cpuset:/top-app
> /proc/985/task/1057/cgroup:3:cpuset:/top-app
> /proc/985/task/1058/cgroup:3:cpuset:/foreground
> /proc/985/task/1074/cgroup:3:cpuset:/system-background
> /proc/985/task/1075/cgroup:3:cpuset:/foreground
> /proc/985/task/1083/cgroup:3:cpuset:/foreground
> /proc/985/task/1084/cgroup:3:cpuset:/foreground
> /proc/985/task/1089/cgroup:3:cpuset:/foreground
> /proc/985/task/1090/cgroup:3:cpuset:/foreground
> /proc/985/task/1092/cgroup:3:cpuset:/foreground
> /proc/985/task/1094/cgroup:3:cpuset:/foreground
> /proc/985/task/1095/cgroup:3:cpuset:/foreground
> /proc/985/task/1096/cgroup:3:cpuset:/foreground
> /proc/985/task/1097/cgroup:3:cpuset:/foreground
> /proc/985/task/1101/cgroup:3:cpuset:/foreground
> /proc/985/task/1104/cgroup:3:cpuset:/foreground
> /proc/985/task/1106/cgroup:3:cpuset:/foreground
> /proc/985/task/1107/cgroup:3:cpuset:/foreground
> /proc/985/task/1108/cgroup:3:cpuset:/foreground
> /proc/985/task/1109/cgroup:3:cpuset:/foreground
> /proc/985/task/1110/cgroup:3:cpuset:/foreground
> /proc/985/task/1111/cgroup:3:cpuset:/foreground
> /proc/985/task/1112/cgroup:3:cpuset:/foreground
> /proc/985/task/1113/cgroup:3:cpuset:/foreground
> /proc/985/task/1114/cgroup:3:cpuset:/foreground
> /proc/985/task/1115/cgroup:3:cpuset:/foreground
> /proc/985/task/1117/cgroup:3:cpuset:/foreground
> /proc/985/task/1124/cgroup:3:cpuset:/foreground
> /proc/985/task/1126/cgroup:3:cpuset:/foreground
> /proc/985/task/1127/cgroup:3:cpuset:/foreground
> /proc/985/task/1131/cgroup:3:cpuset:/foreground
> /proc/985/task/1615/cgroup:3:cpuset:/foreground
> /proc/985/task/1617/cgroup:3:cpuset:/foreground
> /proc/985/task/1621/cgroup:3:cpuset:/foreground
> /proc/985/task/1659/cgroup:3:cpuset:/foreground
> /proc/985/task/1660/cgroup:3:cpuset:/foreground
> /proc/985/task/1661/cgroup:3:cpuset:/foreground
> /proc/985/task/1662/cgroup:3:cpuset:/foreground
> /proc/985/task/1663/cgroup:3:cpuset:/foreground
> /proc/985/task/1664/cgroup:3:cpuset:/foreground
> /proc/985/task/1665/cgroup:3:cpuset:/foreground
> /proc/985/task/1668/cgroup:3:cpuset:/foreground
> /proc/985/task/1669/cgroup:3:cpuset:/foreground
> /proc/985/task/1672/cgroup:3:cpuset:/system-background
> /proc/985/task/1673/cgroup:3:cpuset:/foreground
> /proc/985/task/1674/cgroup:3:cpuset:/foreground
> /proc/985/task/1675/cgroup:3:cpuset:/foreground
> /proc/985/task/1676/cgroup:3:cpuset:/foreground
> /proc/985/task/1677/cgroup:3:cpuset:/foreground
> /proc/985/task/1678/cgroup:3:cpuset:/foreground
> /proc/985/task/1854/cgroup:3:cpuset:/foreground
> /proc/985/task/1855/cgroup:3:cpuset:/foreground
> /proc/985/task/1859/cgroup:3:cpuset:/foreground
> /proc/985/task/1860/cgroup:3:cpuset:/foreground
> /proc/985/task/1871/cgroup:3:cpuset:/foreground
> /proc/985/task/1872/cgroup:3:cpuset:/top-app
> /proc/985/task/1873/cgroup:3:cpuset:/top-app
> /proc/985/task/1883/cgroup:3:cpuset:/foreground
> /proc/985/task/1886/cgroup:3:cpuset:/foreground
> /proc/985/task/1887/cgroup:3:cpuset:/foreground
> /proc/985/task/1888/cgroup:3:cpuset:/foreground
> /proc/985/task/1889/cgroup:3:cpuset:/foreground
> /proc/985/task/1890/cgroup:3:cpuset:/foreground
> /proc/985/task/1897/cgroup:3:cpuset:/foreground
> /proc/985/task/1898/cgroup:3:cpuset:/foreground
> /proc/985/task/1900/cgroup:3:cpuset:/foreground
> /proc/985/task/1905/cgroup:3:cpuset:/foreground
> /proc/985/task/1906/cgroup:3:cpuset:/foreground
> /proc/985/task/1911/cgroup:3:cpuset:/foreground
> /proc/985/task/1913/cgroup:3:cpuset:/foreground
> /proc/985/task/1922/cgroup:3:cpuset:/foreground
> /proc/985/task/1930/cgroup:3:cpuset:/foreground
> /proc/985/task/1933/cgroup:3:cpuset:/foreground
> /proc/985/task/1941/cgroup:3:cpuset:/foreground
> /proc/985/task/1959/cgroup:3:cpuset:/foreground
> /proc/985/task/1964/cgroup:3:cpuset:/foreground
> /proc/985/task/1966/cgroup:3:cpuset:/foreground
> /proc/985/task/1967/cgroup:3:cpuset:/foreground
> /proc/985/task/1968/cgroup:3:cpuset:/foreground
> /proc/985/task/1969/cgroup:3:cpuset:/foreground
> /proc/985/task/1971/cgroup:3:cpuset:/foreground
> /proc/985/task/1972/cgroup:3:cpuset:/foreground
> /proc/985/task/1978/cgroup:3:cpuset:/foreground
> /proc/985/task/1979/cgroup:3:cpuset:/foreground
> /proc/985/task/1980/cgroup:3:cpuset:/foreground
> /proc/985/task/1981/cgroup:3:cpuset:/foreground
> /proc/985/task/1984/cgroup:3:cpuset:/foreground
> /proc/985/task/1985/cgroup:3:cpuset:/foreground
> /proc/985/task/1986/cgroup:3:cpuset:/foreground
> /proc/985/task/1989/cgroup:3:cpuset:/foreground
> /proc/985/task/1990/cgroup:3:cpuset:/foreground
> /proc/985/task/1991/cgroup:3:cpuset:/foreground
> /proc/985/task/1992/cgroup:3:cpuset:/foreground
> /proc/985/task/1993/cgroup:3:cpuset:/foreground
> /proc/985/task/1994/cgroup:3:cpuset:/foreground
> /proc/985/task/1997/cgroup:3:cpuset:/foreground
> /proc/985/task/1998/cgroup:3:cpuset:/foreground
> /proc/985/task/2000/cgroup:3:cpuset:/foreground
> /proc/985/task/2001/cgroup:3:cpuset:/foreground
> /proc/985/task/2002/cgroup:3:cpuset:/foreground
> /proc/985/task/2003/cgroup:3:cpuset:/foreground
> /proc/985/task/2005/cgroup:3:cpuset:/foreground
> /proc/985/task/2006/cgroup:3:cpuset:/foreground
> /proc/985/task/2007/cgroup:3:cpuset:/foreground
> /proc/985/task/2010/cgroup:3:cpuset:/foreground
> /proc/985/task/2011/cgroup:3:cpuset:/foreground
> /proc/985/task/2012/cgroup:3:cpuset:/foreground
> /proc/985/task/2013/cgroup:3:cpuset:/foreground
> /proc/985/task/2014/cgroup:3:cpuset:/foreground
> /proc/985/task/2015/cgroup:3:cpuset:/foreground
> /proc/985/task/2018/cgroup:3:cpuset:/foreground
> /proc/985/task/2019/cgroup:3:cpuset:/foreground
> /proc/985/task/2020/cgroup:3:cpuset:/foreground
> /proc/985/task/2021/cgroup:3:cpuset:/foreground
> /proc/985/task/2024/cgroup:3:cpuset:/foreground
> /proc/985/task/2025/cgroup:3:cpuset:/foreground
> /proc/985/task/2026/cgroup:3:cpuset:/foreground
> /proc/985/task/2028/cgroup:3:cpuset:/foreground
> /proc/985/task/2029/cgroup:3:cpuset:/foreground
> /proc/985/task/2030/cgroup:3:cpuset:/foreground
> /proc/985/task/2031/cgroup:3:cpuset:/foreground
> /proc/985/task/2033/cgroup:3:cpuset:/foreground
> /proc/985/task/2038/cgroup:3:cpuset:/foreground
> /proc/985/task/2039/cgroup:3:cpuset:/foreground
> /proc/985/task/2041/cgroup:3:cpuset:/foreground
> /proc/985/task/2042/cgroup:3:cpuset:/foreground
> /proc/985/task/2045/cgroup:3:cpuset:/foreground
> /proc/985/task/2046/cgroup:3:cpuset:/foreground
> /proc/985/task/2047/cgroup:3:cpuset:/foreground
> /proc/985/task/2048/cgroup:3:cpuset:/foreground
> /proc/985/task/2050/cgroup:3:cpuset:/foreground
> /proc/985/task/2051/cgroup:3:cpuset:/foreground
> /proc/985/task/2052/cgroup:3:cpuset:/foreground
> /proc/985/task/2053/cgroup:3:cpuset:/foreground
> /proc/985/task/2054/cgroup:3:cpuset:/foreground
> /proc/985/task/2056/cgroup:3:cpuset:/foreground
> /proc/985/task/2060/cgroup:3:cpuset:/foreground
> /proc/985/task/2062/cgroup:3:cpuset:/foreground
> /proc/985/task/2066/cgroup:3:cpuset:/foreground
> /proc/985/task/2069/cgroup:3:cpuset:/system-background
> /proc/985/task/2075/cgroup:3:cpuset:/foreground
> /proc/985/task/2076/cgroup:3:cpuset:/foreground
> /proc/985/task/2077/cgroup:3:cpuset:/foreground
> /proc/985/task/2078/cgroup:3:cpuset:/foreground
> /proc/985/task/2082/cgroup:3:cpuset:/foreground
> /proc/985/task/2086/cgroup:3:cpuset:/foreground
> /proc/985/task/2089/cgroup:3:cpuset:/foreground
> /proc/985/task/2113/cgroup:3:cpuset:/foreground
> /proc/985/task/2126/cgroup:3:cpuset:/foreground
> /proc/985/task/2127/cgroup:3:cpuset:/foreground
> /proc/985/task/2173/cgroup:3:cpuset:/foreground
> /proc/985/task/2183/cgroup:3:cpuset:/foreground
> /proc/985/task/2211/cgroup:3:cpuset:/system-background
> /proc/985/task/2232/cgroup:3:cpuset:/foreground
> /proc/985/task/2247/cgroup:3:cpuset:/foreground
> /proc/985/task/2248/cgroup:3:cpuset:/foreground
> /proc/985/task/2414/cgroup:3:cpuset:/foreground
> /proc/985/task/2417/cgroup:3:cpuset:/foreground
> /proc/985/task/2419/cgroup:3:cpuset:/foreground
> /proc/985/task/2421/cgroup:3:cpuset:/foreground
> /proc/985/task/2422/cgroup:3:cpuset:/foreground
> /proc/985/task/2423/cgroup:3:cpuset:/foreground
> /proc/985/task/2425/cgroup:3:cpuset:/foreground
> /proc/985/task/2426/cgroup:3:cpuset:/foreground
> /proc/985/task/2428/cgroup:3:cpuset:/foreground
> /proc/985/task/2471/cgroup:3:cpuset:/foreground
> /proc/985/task/2527/cgroup:3:cpuset:/top-app
> /proc/985/task/2563/cgroup:3:cpuset:/foreground
> /proc/985/task/2565/cgroup:3:cpuset:/foreground
> /proc/985/task/2567/cgroup:3:cpuset:/foreground
> /proc/985/task/2568/cgroup:3:cpuset:/foreground
> /proc/985/task/2569/cgroup:3:cpuset:/foreground
> /proc/985/task/2571/cgroup:3:cpuset:/foreground
> /proc/985/task/2799/cgroup:3:cpuset:/foreground
> /proc/985/task/2856/cgroup:3:cpuset:/top-app
> /proc/985/task/2860/cgroup:3:cpuset:/top-app
> /proc/985/task/2864/cgroup:3:cpuset:/foreground
> /proc/985/task/2865/cgroup:3:cpuset:/foreground
> /proc/985/task/2882/cgroup:3:cpuset:/foreground
> /proc/985/task/2883/cgroup:3:cpuset:/foreground
> /proc/985/task/2884/cgroup:3:cpuset:/foreground
> /proc/985/task/2885/cgroup:3:cpuset:/foreground
> /proc/985/task/2886/cgroup:3:cpuset:/foreground
> /proc/985/task/2887/cgroup:3:cpuset:/foreground
> /proc/985/task/2888/cgroup:3:cpuset:/foreground
> /proc/985/task/2889/cgroup:3:cpuset:/foreground
> /proc/985/task/2890/cgroup:3:cpuset:/foreground
> /proc/985/task/2905/cgroup:3:cpuset:/foreground
> /proc/985/task/2989/cgroup:3:cpuset:/foreground
> /proc/985/task/3013/cgroup:3:cpuset:/foreground
> /proc/985/task/3018/cgroup:3:cpuset:/foreground
> /proc/985/task/3020/cgroup:3:cpuset:/foreground
> /proc/985/task/3022/cgroup:3:cpuset:/foreground
> /proc/985/task/3063/cgroup:3:cpuset:/foreground
> /proc/985/task/3071/cgroup:3:cpuset:/foreground
> /proc/985/task/3112/cgroup:3:cpuset:/foreground
> /proc/985/task/3113/cgroup:3:cpuset:/foreground
> /proc/985/task/3116/cgroup:3:cpuset:/foreground
> /proc/985/task/3200/cgroup:3:cpuset:/foreground
> /proc/985/task/3220/cgroup:3:cpuset:/foreground
> /proc/985/task/3223/cgroup:3:cpuset:/foreground
> /proc/985/task/3224/cgroup:3:cpuset:/foreground
> /proc/985/task/3225/cgroup:3:cpuset:/foreground
> /proc/985/task/3226/cgroup:3:cpuset:/foreground
> /proc/985/task/3229/cgroup:3:cpuset:/foreground
> /proc/985/task/3230/cgroup:3:cpuset:/foreground
> /proc/985/task/3280/cgroup:3:cpuset:/foreground
> /proc/985/task/3293/cgroup:3:cpuset:/foreground
> /proc/985/task/3294/cgroup:3:cpuset:/foreground
> /proc/985/task/3649/cgroup:3:cpuset:/foreground
> /proc/985/task/3708/cgroup:3:cpuset:/foreground
> /proc/985/task/3737/cgroup:3:cpuset:/foreground
> /proc/985/task/3835/cgroup:3:cpuset:/foreground
> /proc/985/task/3836/cgroup:3:cpuset:/foreground
> /proc/985/task/3840/cgroup:3:cpuset:/foreground
> /proc/985/task/3841/cgroup:3:cpuset:/foreground
> /proc/985/task/4828/cgroup:3:cpuset:/foreground
> /proc/985/task/4838/cgroup:3:cpuset:/foreground
> /proc/985/task/4977/cgroup:3:cpuset:/foreground
> /proc/985/task/5188/cgroup:3:cpuset:/foreground
> /proc/985/task/5765/cgroup:3:cpuset:/foreground
> /proc/985/task/5988/cgroup:3:cpuset:/foreground
> /proc/985/task/5998/cgroup:3:cpuset:/foreground
> /proc/985/task/7793/cgroup:3:cpuset:/foreground
> /proc/985/task/7995/cgroup:3:cpuset:/foreground
> /proc/985/task/985/cgroup:3:cpuset:/foreground
>
>
> > + if ((s = strstr(line, ":cpuset:/"))) {
>
> So this ignores the old schedtune case from get_sched_policy, however
> I think that's ok because schedtune is an out of tree driver only in
> Android 4.19 kernels which are EOL in 4 months at the end of this
> December.
(i have no idea what any of this means. i didn't do anything about
"schedtune" because you didn't tell me anything about "schedtune" :-)
)
> > + else if (!strcmp(s, "foreground-window")) strcpy(tb->pcy, "wi");
>
> I think this should be "foreground_window". Underscore instead of
> hyphen for that one. Maybe we should fix that one on our side since
> it's unlike all the others, and not actually in use yet.
oops, yeah. i should have copy & pasted rather than just having the
other code open in another window.
new patch attached.
> > else strcpy(tb->pcy, "?");
>
> Should this be two ?s to maintain the column width?
there's a %2s where these actually come out. my only concern was that
the "-" ("missing") case was distinct from the "?" ("unknown") case.
> This solution will work as long as Android continues to use cpuset v1.
> A v2 upgrade should happen at some point, but it's not clear when.
> New policy names and abbreviations will have to be manually synced
> with this if any are added (which should be rare):
> https://cs.android.com/android/platform/superproject/main/+/main:system/core/rootdir/init.rc;l=360?q=mkdir.*%2Fdev%2Fcpuset
long term i think we should try to work out how to get away from the
two-letter nonsense. but that's a problem for another year. right now
i just want to get away from these dependencies without regression
(which should make rob happy too, since he always wants to build with
the NDK rather than as part of the OS).
> Best,
> T.J. from the Android team
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ps-drop-dependency-on-Android-s-libprocessgroup.patch
Type: text/x-patch
Size: 4427 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20240826/76da0c8c/attachment-0001.bin>
More information about the Toybox
mailing list