Date: Mon, 19 Aug 2013 18:49:55 -0600 From: Chris Torek <torek@torek.net> To: Konstantin Belousov <kostikbel@gmail.com> Cc: freebsd-hackers@freebsd.org, Carlos Jacobo Puga Medina <cjpugmed@gmail.com> Subject: Re: ps_strings Message-ID: <201308200049.r7K0ntT4012366@elf.torek.net> In-Reply-To: Your message of "Mon, 19 Aug 2013 10:44:52 %2B0300." <20130819074452.GW4972@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
>Yes, p_args caches the arguments, but not always. Right now, kernel >does not cache arguments if the string is longer than 256 bytes. Look >for ps_arg_cache_limit in kern_exec.c. > >setproctitle() always informs the kernel with sysctl and sets the >pointers in ps_strings. kern.proc.args sysctl first tries the p_args, >and falls back to reading ps_strings and following the pointers if >p_args is NULL. Ah, that's what I get for scanning through years of updates too fast. :-) This seems a bit of a "worst of both worlds": there's now some extra kernel code for poking through the ps_strings and the pointer-vectors (this code is no longer in libkvm at all -- that was where I looked first and found the sysctl), for the "no p_args" case. It seems like perhaps there could just be a sysctl to return the ps_strings address, and leave the "follow argv pointers" code in libkvm, if there is to be code for that. (The kernel saves a bit of time for the presumably-usual "p_args not NULL" case, and finding the location of the ps_strings structure when it *is* used is automatically correct. So that part is a straight-up improvement, at least.) Not that big a deal either way, but it does seem as though there should be documentation for ps_strings. Chris
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308200049.r7K0ntT4012366>