From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 20 00:50:02 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8BE87FB5 for ; Tue, 20 Aug 2013 00:50:02 +0000 (UTC) (envelope-from torek@torek.net) Received: from elf.torek.net (50-73-42-1-utah.hfc.comcastbusiness.net [50.73.42.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5FEAF2377 for ; Tue, 20 Aug 2013 00:50:01 +0000 (UTC) Received: from elf.torek.net (localhost [127.0.0.1]) by elf.torek.net (8.14.5/8.14.5) with ESMTP id r7K0ntT4012366; Mon, 19 Aug 2013 18:49:55 -0600 (MDT) (envelope-from torek@torek.net) Message-Id: <201308200049.r7K0ntT4012366@elf.torek.net> From: Chris Torek To: Konstantin Belousov Subject: Re: ps_strings In-reply-to: Your message of "Mon, 19 Aug 2013 10:44:52 +0300." <20130819074452.GW4972@kib.kiev.ua> Date: Mon, 19 Aug 2013 18:49:55 -0600 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (elf.torek.net [127.0.0.1]); Mon, 19 Aug 2013 18:49:55 -0600 (MDT) Cc: freebsd-hackers@freebsd.org, Carlos Jacobo Puga Medina X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Aug 2013 00:50:02 -0000 >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