Re: svn commit: r227956 - head/usr.bin/procstat
On Mon, 12 Dec 2011 14:07:56 -0500 John Baldwin wrote: JB On Saturday, December 10, 2011 3:26:46 am Mikolaj Golub wrote: Output example: PID COMM RLIMIT SOFT HARD 11949 zsh cputime1 sec infinity 11949 zsh filesizeinfinity infinity 11949 zsh datasize 524288 kB524288 kB 11949 zsh stacksize 65536 kB 65536 kB 11949 zsh coredumpsize 190734 MB190734 MB 11949 zsh memoryuse infinity infinity 11949 zsh memorylockedinfinity infinity 11949 zsh maxprocesses5547 5547 11949 zsh openfiles 1109511095 11949 zsh sbsize infinity infinity 11949 zsh vmemoryuse infinity infinity 11949 zsh pseudo-terminalsinfinity infinity 11949 zsh swapuse infinity infinity JB This looks great to me, thanks! Thanks, committed. -- Mikolaj Golub ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r227956 - head/usr.bin/procstat
On Thu, 08 Dec 2011 16:32:16 -0500 John Baldwin wrote: JB Hmm, I would stick as close to limits output as possible. I would JB consider duplicating the unit field in each of soft and hard, so you JB end up with something like this: JBPID COMMRLIMIT SOFT HARD JB 48798 zsh cputime 10 secs infinity secs JB 48798 zsh filesize infinity kbinfinity kb JB 48798 zsh datasize 524288 kb 524288 kb JB etc. Ok. JB (Things like 'openfiles' is simply more intuitive than 'nofile' (no JB file?, huh? oh, num open files.. (except not all users will make the JB last step there). Then why do we have so non-intuitive rlimit_ident names? It looks like they are used only in procfs_rlimit.c. Do procfs(5) users always make that last step with 'nofile'? :-) JB Well, I suspect it's best not to change the names in procfs in case JB there are existing binaries that parse the output of that file JB (unfortunately). Is it possible to change rlimit_ident names? Just to ones that are used by limit(1) or (if they look too long) to something like below: JB Hmm, I have no idea what other things might use rlimit_ident. Probably JB not many. (Also, for fun, note that the 'ulimit' and 'limit' built-in JB commands in sh and csh also have their own sets of names, fun!) I would JB maybe add a rlimit_names[] (just leave rlimit_ident alone), and give JB that the names from limits(1), and change both procstat and sh's JB ulimit' command to use those. Adding yet another rlimit names to the header file does not look so attractive for me as it was just using/reusing what we had :-). So I decided to hardcode the names in procstat_rlimit.c (see the attached patch). Output example: PID COMM RLIMIT SOFT HARD 11949 zsh cputime1 sec infinity 11949 zsh filesizeinfinity infinity 11949 zsh datasize 524288 kB524288 kB 11949 zsh stacksize 65536 kB 65536 kB 11949 zsh coredumpsize 190734 MB190734 MB 11949 zsh memoryuse infinity infinity 11949 zsh memorylockedinfinity infinity 11949 zsh maxprocesses5547 5547 11949 zsh openfiles 1109511095 11949 zsh sbsize infinity infinity 11949 zsh vmemoryuse infinity infinity 11949 zsh pseudo-terminalsinfinity infinity 11949 zsh swapuse infinity infinity -- Mikolaj Golub Index: usr.bin/procstat/procstat_rlimit.c === --- usr.bin/procstat/procstat_rlimit.c (revision 228285) +++ usr.bin/procstat/procstat_rlimit.c (working copy) @@ -28,7 +28,6 @@ #include sys/param.h #include sys/time.h -#define _RLIMIT_IDENT #include sys/resourcevar.h #include sys/sysctl.h #include sys/user.h @@ -36,6 +35,7 @@ #include err.h #include errno.h #include libprocstat.h +#include libutil.h #include limits.h #include stdio.h #include stdlib.h @@ -43,17 +43,60 @@ #include procstat.h +static struct { + const char *name; + const char *suffix; +} rlimit_param[13] = { + {cputime, sec}, + {filesize, B }, + {datasize, B }, + {stacksize,B }, + {coredumpsize, B }, + {memoryuse,B }, + {memorylocked, B }, + {maxprocesses,}, + {openfiles, }, + {sbsize, B }, + {vmemoryuse, B }, + {pseudo-terminals,}, + {swapuse, B }, +}; + +#if RLIM_NLIMITS 13 +#error Resource limits have grown. Add new entries to rlimit_param[]. +#endif + static struct rlimit rlimit[RLIM_NLIMITS]; +static +const char *humanize_rlimit(int indx, rlim_t limit) +{ + static char buf[14]; + int scale; + + if (limit == RLIM_INFINITY) + return infinity ; + + scale = humanize_number(buf, sizeof(buf) - 1, (int64_t)limit, + rlimit_param[indx].suffix, HN_AUTOSCALE | HN_GETSCALE, HN_DECIMAL); + (void)humanize_number(buf, sizeof(buf) - 1, (int64_t)limit, + rlimit_param[indx].suffix, HN_AUTOSCALE, HN_DECIMAL); + /* Pad with one space if there is no suffix prefix. */ + if (scale == 0) + sprintf(buf + strlen(buf), ); + return (buf); +} + void procstat_rlimit(struct kinfo_proc *kipp) { int error, i, name[4]; size_t len; - if (!hflag) - printf(%5s %-16s %-10s %12s %12s\n, PID, COMM, RLIMIT, - CURRENT, MAX); + if (!hflag) { + printf(%5s %-16s %-16s %16s %16s\n, + PID, COMM, RLIMIT, SOFT , HARD ); + } name[0] = CTL_KERN; name[1] = KERN_PROC; name[2] = KERN_PROC_RLIMIT; @@
Re: svn commit: r227956 - head/usr.bin/procstat
On 12/3/11 3:58 PM, Mikolaj Golub wrote: On Mon, 28 Nov 2011 13:30:11 -0500 John Baldwin wrote: JB On Thursday, November 24, 2011 3:54:06 pm Mikolaj Golub wrote: Author: trociny Date: Thu Nov 24 20:54:06 2011 New Revision: 227956 URL: http://svn.freebsd.org/changeset/base/227956 Log: usr.bin/procstat Add -l flag to display resource limits. PR:bin/161257 Reviewed by:kib MFC after:2 weeks JB Thanks for doing this! Did you consider making the procstat -l output use JB pretty output similar to the output of /usr/bin/limits? For example, JB using infinity instead of -1 and using humanize_number() for finite limits JB that are in units of bytes? I tried several variants, from one where for rlimit names rlimit_ident constants from sys/resource.h are used and units are printed as suffixes: PID COMM RLIMIT SOFT HARD 46150 zsh cpu 10S infinity 46150 zsh fsize infinity infinity 46150 zsh data 524288kB 524288kB 46150 zsh stack 65536kB65536kB 46150 zsh core 9765625kB 9765625kB 46150 zsh rssinfinity infinity 46150 zsh memlockinfinity infinity 46150 zsh nproc 5547 5547 46150 zsh nofile11095 11095 46150 zsh sbsize infinity infinity 46150 zsh vmem infinity infinity 46150 zsh npts infinity infinity 46150 zsh swap infinity infinity to one where rlimit names are the same as in limits(1) and units are printed in separate column: PID COMM RLIMIT SOFT HARD UNIT 48885 zsh cputime 10 infinity secs 48885 zsh filesize infinity infinity bytes 48885 zsh datasize524288k524288k bytes 48885 zsh stacksize65536k 65536k bytes 48885 zsh coredumpsize 95367M 95367M bytes 48885 zsh memoryuse infinity infinity bytes 48885 zsh memorylocked infinity infinity bytes 48885 zsh maxprocesses 5547 5547 48885 zsh openfiles 11095 11095 48885 zsh sbsize infinity infinity bytes 48885 zsh vmemoryuse infinity infinity bytes 48885 zsh pseudo-terminals infinity infinity 48885 zsh swapuseinfinity infinity bytes Personally I like the first variant as the most compact and the easiest to maintain but would be glad to learn what other think about this or may be have other suggestions. A couple other variations: PID COMM RLIMIT SOFT HARD UNIT 47062 zsh cpu 10 infinity secs 47062 zsh fsize infinity infinity bytes 47062 zsh data524288k524288k bytes 47062 zsh stack 67108864 67108864 bytes 47062 zsh core 9765625k 9765625k bytes 47062 zsh rssinfinity infinity bytes 47062 zsh memlockinfinity infinity bytes 47062 zsh nproc 5547 5547 47062 zsh nofile11095 11095 47062 zsh sbsize infinity infinity bytes 47062 zsh vmem infinity infinity bytes 47062 zsh npts infinity infinity 47062 zsh swap infinity infinity bytes PID COMM RLIMIT SOFT HARD UNIT 48798 zsh cputime 10 infinity secs 48798 zsh filesize infinity infinity bytes 48798 zsh datasize524288k524288k bytes 48798 zsh stacksize 65536k 65536k bytes 48798 zsh coredumpsize 95367M 95367M bytes 48798 zsh memoryuse infinity infinity bytes 48798 zsh memorylocked infinity infinity bytes 48798 zsh maxprocesses 5547 5547 48798 zsh openfiles 11095 11095 48798 zshsbsize infinity infinity bytes 48798 zshvmemoryuse infinity infinity bytes 48798 zsh pseudo-terminals infinity infinity 48798 zsh swapuse infinity infinity bytes Hmm, I would stick as close to limits output as possible. I would consider duplicating the unit field in each of soft and hard, so you end up with something like this: PID COMMRLIMIT SOFT HARD 48798 zsh cputime 10 secs
Re: svn commit: r227956 - head/usr.bin/procstat
On Thu, 08 Dec 2011 13:30:36 -0500 John Baldwin wrote: JB On 12/3/11 3:58 PM, Mikolaj Golub wrote: On Mon, 28 Nov 2011 13:30:11 -0500 John Baldwin wrote: JB On Thursday, November 24, 2011 3:54:06 pm Mikolaj Golub wrote: Author: trociny Date: Thu Nov 24 20:54:06 2011 New Revision: 227956 URL: http://svn.freebsd.org/changeset/base/227956 Log: usr.bin/procstat Add -l flag to display resource limits. PR:bin/161257 Reviewed by:kib MFC after:2 weeks JB Thanks for doing this! Did you consider making the procstat -l output use JB pretty output similar to the output of /usr/bin/limits? For example, JB using infinity instead of -1 and using humanize_number() for finite limits JB that are in units of bytes? I tried several variants, from one where for rlimit names rlimit_ident constants from sys/resource.h are used and units are printed as suffixes: PID COMM RLIMIT SOFT HARD 46150 zsh cpu 10S infinity 46150 zsh fsize infinity infinity 46150 zsh data 524288kB 524288kB 46150 zsh stack 65536kB65536kB 46150 zsh core 9765625kB 9765625kB 46150 zsh rssinfinity infinity 46150 zsh memlockinfinity infinity 46150 zsh nproc 5547 5547 46150 zsh nofile11095 11095 46150 zsh sbsize infinity infinity 46150 zsh vmem infinity infinity 46150 zsh npts infinity infinity 46150 zsh swap infinity infinity to one where rlimit names are the same as in limits(1) and units are printed in separate column: PID COMM RLIMIT SOFT HARD UNIT 48885 zsh cputime 10 infinity secs 48885 zsh filesize infinity infinity bytes 48885 zsh datasize524288k524288k bytes 48885 zsh stacksize65536k 65536k bytes 48885 zsh coredumpsize 95367M 95367M bytes 48885 zsh memoryuse infinity infinity bytes 48885 zsh memorylocked infinity infinity bytes 48885 zsh maxprocesses 5547 5547 48885 zsh openfiles 11095 11095 48885 zsh sbsize infinity infinity bytes 48885 zsh vmemoryuse infinity infinity bytes 48885 zsh pseudo-terminals infinity infinity 48885 zsh swapuseinfinity infinity bytes Personally I like the first variant as the most compact and the easiest to maintain but would be glad to learn what other think about this or may be have other suggestions. A couple other variations: PID COMM RLIMIT SOFT HARD UNIT 47062 zsh cpu 10 infinity secs 47062 zsh fsize infinity infinity bytes 47062 zsh data524288k524288k bytes 47062 zsh stack 67108864 67108864 bytes 47062 zsh core 9765625k 9765625k bytes 47062 zsh rssinfinity infinity bytes 47062 zsh memlockinfinity infinity bytes 47062 zsh nproc 5547 5547 47062 zsh nofile11095 11095 47062 zsh sbsize infinity infinity bytes 47062 zsh vmem infinity infinity bytes 47062 zsh npts infinity infinity 47062 zsh swap infinity infinity bytes PID COMM RLIMIT SOFT HARD UNIT 48798 zsh cputime 10 infinity secs 48798 zsh filesize infinity infinity bytes 48798 zsh datasize524288k524288k bytes 48798 zsh stacksize 65536k 65536k bytes 48798 zsh coredumpsize 95367M 95367M bytes 48798 zsh memoryuse infinity infinity bytes 48798 zsh memorylocked infinity infinity bytes 48798 zsh maxprocesses 5547 5547 48798 zsh openfiles 11095 11095 48798 zshsbsize infinity infinity bytes 48798 zshvmemoryuse infinity infinity bytes 48798 zsh pseudo-terminals infinity infinity 48798 zsh swapuse infinity infinity bytes JB Hmm, I would stick as
Re: svn commit: r227956 - head/usr.bin/procstat
On 12/8/11 3:53 PM, Mikolaj Golub wrote: On Thu, 08 Dec 2011 13:30:36 -0500 John Baldwin wrote: JB On 12/3/11 3:58 PM, Mikolaj Golub wrote: On Mon, 28 Nov 2011 13:30:11 -0500 John Baldwin wrote: JB On Thursday, November 24, 2011 3:54:06 pm Mikolaj Golub wrote: Author: trociny Date: Thu Nov 24 20:54:06 2011 New Revision: 227956 URL: http://svn.freebsd.org/changeset/base/227956 Log: usr.bin/procstat Add -l flag to display resource limits. PR:bin/161257 Reviewed by:kib MFC after:2 weeks JB Thanks for doing this! Did you consider making the procstat -l output use JB pretty output similar to the output of /usr/bin/limits? For example, JB using infinity instead of -1 and using humanize_number() for finite limits JB that are in units of bytes? I tried several variants, from one where for rlimit names rlimit_ident constants from sys/resource.h are used and units are printed as suffixes: PID COMM RLIMIT SOFT HARD 46150 zsh cpu 10S infinity 46150 zsh fsize infinity infinity 46150 zsh data 524288kB 524288kB 46150 zsh stack 65536kB65536kB 46150 zsh core 9765625kB 9765625kB 46150 zsh rssinfinity infinity 46150 zsh memlockinfinity infinity 46150 zsh nproc 5547 5547 46150 zsh nofile11095 11095 46150 zsh sbsize infinity infinity 46150 zsh vmem infinity infinity 46150 zsh npts infinity infinity 46150 zsh swap infinity infinity to one where rlimit names are the same as in limits(1) and units are printed in separate column: PID COMM RLIMIT SOFT HARD UNIT 48885 zsh cputime 10 infinity secs 48885 zsh filesize infinity infinity bytes 48885 zsh datasize524288k524288k bytes 48885 zsh stacksize65536k 65536k bytes 48885 zsh coredumpsize 95367M 95367M bytes 48885 zsh memoryuse infinity infinity bytes 48885 zsh memorylocked infinity infinity bytes 48885 zsh maxprocesses 5547 5547 48885 zsh openfiles 11095 11095 48885 zsh sbsize infinity infinity bytes 48885 zsh vmemoryuse infinity infinity bytes 48885 zsh pseudo-terminals infinity infinity 48885 zsh swapuseinfinity infinity bytes Personally I like the first variant as the most compact and the easiest to maintain but would be glad to learn what other think about this or may be have other suggestions. A couple other variations: PID COMM RLIMIT SOFT HARD UNIT 47062 zsh cpu 10 infinity secs 47062 zsh fsize infinity infinity bytes 47062 zsh data524288k524288k bytes 47062 zsh stack 67108864 67108864 bytes 47062 zsh core 9765625k 9765625k bytes 47062 zsh rssinfinity infinity bytes 47062 zsh memlockinfinity infinity bytes 47062 zsh nproc 5547 5547 47062 zsh nofile11095 11095 47062 zsh sbsize infinity infinity bytes 47062 zsh vmem infinity infinity bytes 47062 zsh npts infinity infinity 47062 zsh swap infinity infinity bytes PID COMM RLIMIT SOFT HARD UNIT 48798 zsh cputime 10 infinity secs 48798 zsh filesize infinity infinity bytes 48798 zsh datasize524288k524288k bytes 48798 zsh stacksize 65536k 65536k bytes 48798 zsh coredumpsize 95367M 95367M bytes 48798 zsh memoryuse infinity infinity bytes 48798 zsh memorylocked infinity infinity bytes 48798 zsh maxprocesses 5547 5547 48798 zsh openfiles 11095 11095 48798 zshsbsize infinity infinity bytes 48798 zsh
Re: svn commit: r227956 - head/usr.bin/procstat
On Mon, 28 Nov 2011 13:30:11 -0500 John Baldwin wrote: JB On Thursday, November 24, 2011 3:54:06 pm Mikolaj Golub wrote: Author: trociny Date: Thu Nov 24 20:54:06 2011 New Revision: 227956 URL: http://svn.freebsd.org/changeset/base/227956 Log: usr.bin/procstat Add -l flag to display resource limits. PR:bin/161257 Reviewed by:kib MFC after:2 weeks JB Thanks for doing this! Did you consider making the procstat -l output use JB pretty output similar to the output of /usr/bin/limits? For example, JB using infinity instead of -1 and using humanize_number() for finite limits JB that are in units of bytes? I tried several variants, from one where for rlimit names rlimit_ident constants from sys/resource.h are used and units are printed as suffixes: PID COMM RLIMIT SOFT HARD 46150 zsh cpu 10S infinity 46150 zsh fsize infinity infinity 46150 zsh data 524288kB 524288kB 46150 zsh stack 65536kB65536kB 46150 zsh core 9765625kB 9765625kB 46150 zsh rssinfinity infinity 46150 zsh memlockinfinity infinity 46150 zsh nproc 5547 5547 46150 zsh nofile11095 11095 46150 zsh sbsize infinity infinity 46150 zsh vmem infinity infinity 46150 zsh npts infinity infinity 46150 zsh swap infinity infinity to one where rlimit names are the same as in limits(1) and units are printed in separate column: PID COMM RLIMIT SOFT HARD UNIT 48885 zsh cputime 10 infinity secs 48885 zsh filesize infinity infinity bytes 48885 zsh datasize524288k524288k bytes 48885 zsh stacksize65536k 65536k bytes 48885 zsh coredumpsize 95367M 95367M bytes 48885 zsh memoryuse infinity infinity bytes 48885 zsh memorylocked infinity infinity bytes 48885 zsh maxprocesses 5547 5547 48885 zsh openfiles 11095 11095 48885 zsh sbsize infinity infinity bytes 48885 zsh vmemoryuse infinity infinity bytes 48885 zsh pseudo-terminals infinity infinity 48885 zsh swapuseinfinity infinity bytes Personally I like the first variant as the most compact and the easiest to maintain but would be glad to learn what other think about this or may be have other suggestions. A couple other variations: PID COMM RLIMIT SOFT HARD UNIT 47062 zsh cpu 10 infinity secs 47062 zsh fsize infinity infinity bytes 47062 zsh data524288k524288k bytes 47062 zsh stack 67108864 67108864 bytes 47062 zsh core 9765625k 9765625k bytes 47062 zsh rssinfinity infinity bytes 47062 zsh memlockinfinity infinity bytes 47062 zsh nproc 5547 5547 47062 zsh nofile11095 11095 47062 zsh sbsize infinity infinity bytes 47062 zsh vmem infinity infinity bytes 47062 zsh npts infinity infinity 47062 zsh swap infinity infinity bytes PID COMM RLIMIT SOFT HARD UNIT 48798 zsh cputime 10 infinity secs 48798 zsh filesize infinity infinity bytes 48798 zsh datasize524288k524288k bytes 48798 zsh stacksize 65536k 65536k bytes 48798 zsh coredumpsize 95367M 95367M bytes 48798 zsh memoryuse infinity infinity bytes 48798 zsh memorylocked infinity infinity bytes 48798 zsh maxprocesses 5547 5547 48798 zsh openfiles 11095 11095 48798 zshsbsize infinity infinity bytes 48798 zshvmemoryuse infinity infinity bytes 48798 zsh pseudo-terminals infinity infinity 48798 zsh swapuse infinity infinity bytes -- Mikolaj Golub ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to
Re: svn commit: r227956 - head/usr.bin/procstat
On Thursday, November 24, 2011 3:54:06 pm Mikolaj Golub wrote: Author: trociny Date: Thu Nov 24 20:54:06 2011 New Revision: 227956 URL: http://svn.freebsd.org/changeset/base/227956 Log: usr.bin/procstat Add -l flag to display resource limits. PR: bin/161257 Reviewed by:kib MFC after: 2 weeks Thanks for doing this! Did you consider making the procstat -l output use pretty output similar to the output of /usr/bin/limits? For example, using infinity instead of -1 and using humanize_number() for finite limits that are in units of bytes? -- John Baldwin ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r227956 - head/usr.bin/procstat
On Mon, 28 Nov 2011 13:30:11 -0500 John Baldwin wrote: JB On Thursday, November 24, 2011 3:54:06 pm Mikolaj Golub wrote: Author: trociny Date: Thu Nov 24 20:54:06 2011 New Revision: 227956 URL: http://svn.freebsd.org/changeset/base/227956 Log: usr.bin/procstat Add -l flag to display resource limits. PR:bin/161257 Reviewed by:kib MFC after:2 weeks JB Thanks for doing this! Did you consider making the procstat -l output use JB pretty output similar to the output of /usr/bin/limits? For example, JB using infinity instead of -1 and using humanize_number() for finite limits JB that are in units of bytes? Looks like a good idea. I used procfs output as a reference but limits(1) looks prettier :-). Will do. -- Mikolaj Golub ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org