From owner-freebsd-net@FreeBSD.ORG Fri Jan 13 12:55:32 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A934106564A; Fri, 13 Jan 2012 12:55:32 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 313378FC1C; Fri, 13 Jan 2012 12:55:31 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q0DCRpEx098358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 13 Jan 2012 14:27:51 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q0DCRp0i091394; Fri, 13 Jan 2012 14:27:51 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q0DCRnHi091393; Fri, 13 Jan 2012 14:27:49 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 13 Jan 2012 14:27:49 +0200 From: Kostik Belousov To: Julian Elischer Message-ID: <20120113122749.GG31224@deviant.kiev.zoral.com.ua> References: <201201121404.q0CE4ItN066102@lurza.secnetix.de> <4F0FD2E3.1060607@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="l7ZAGG5ZGPl0OWqn" Content-Disposition: inline In-Reply-To: <4F0FD2E3.1060607@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, "Paul A. Procacci" , Oliver Fromme , Oliver Fromme , freebsd-net@freebsd.org Subject: Re: Processes' FIBs X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 12:55:32 -0000 --l7ZAGG5ZGPl0OWqn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 12, 2012 at 10:44:51PM -0800, Julian Elischer wrote: > On 1/12/12 6:04 AM, Oliver Fromme wrote: > >Bjoern A. Zeeb wrote: > > > On 11. Jan 2012, at 15:06 , Oliver Fromme wrote: > > > > I'm currently looking at the source code of ps, but adding > > > > a field for the FIB isn't as trivial as I thought because > > > > ps only sees struct kinfo_proc (via sysctl kern.proc.*) > > > > which doesn't contain the FIB. procstat does the same. > > > > > > > > I'm currently trying to write a patch that copies p_fibnum > > > > from struct proc to struct kinfo_proc (just like p_nice, > > > > for example). Does that make sense? If so, does the patch > > > > below look reasonable? (I've made it on a stable/8 system, > > > > but it should apply to 9 and 10, too.) > > > > > > I am not sure it makes too much sense in ps. It might make sense in > > > sockstat maybe? > > > >Well, every process has a default FIB number (p_fibnum in > >struct proc). It is a property of the process, just like > >the nice value for example. So I think it makes sense for > >ps to be able to display it if the user asks for it. This > >is the piece of information that I need. > > > >On the other hand, sockstat displays open sockets only. > >Of course, an internet socket has a FIB number associated > >with it, too, so sockstat could display it. But that > >would be a completely different piece of information, > >and it wouldn't solve the actual problem that I'm currently > >facing. > > >=20 > I hadn't considered that a process would want to see the fib of another. > but of course it makes sense. > I see no problem the the attached patch except that it doesn't fix the=20 > man page for ps and setfib(2) or setfib(8) (or is it 1?) >=20 > etc. > if there are no objections, I can add this when it has been polished.. The patch misses compat32 bits and breaks compat32 ps/top. >=20 > >Best regards > > Oliver > > > >--- ./sys/sys/user.h.orig 2011-07-12 14:23:54.000000000 +0200 > >+++ ./sys/sys/user.h 2012-01-11 15:35:50.000000000 +0100 > >@@ -83,7 +83,7 @@ > > * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c = and > > * function kvm_proclist in lib/libkvm/kvm_proc.c . > > */ > >-#define KI_NSPARE_INT 9 > >+#define KI_NSPARE_INT 8 > > #define KI_NSPARE_LONG 12 > > #define KI_NSPARE_PTR 6 > > > >@@ -177,6 +177,7 @@ > > */ > > char ki_sparestrings[68]; /* spare string space */ > > int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */ > >+ int ki_fibnum; /* Default FIB number */ > > u_int ki_cr_flags; /* Credential flags */ > > int ki_jid; /* Process jail ID */ > > int ki_numthreads; /* XXXKSE number of threads in total=20 > > */ > >--- ./sys/kern/kern_proc.c.orig 2011-07-12 14:19:26.000000000 +0200 > >+++ ./sys/kern/kern_proc.c 2012-01-11 15:36:22.000000000 +0100 > >@@ -775,6 +775,7 @@ > > kp->ki_swtime =3D (ticks - p->p_swtick) / hz; > > kp->ki_pid =3D p->p_pid; > > kp->ki_nice =3D p->p_nice; > >+ kp->ki_fibnum =3D p->p_fibnum; > > PROC_SLOCK(p); > > rufetch(p,&kp->ki_rusage); > > kp->ki_runtime =3D cputick2usec(p->p_rux.rux_runtime); > >--- ./bin/ps/keyword.c.orig 2011-07-12 13:42:48.000000000 +0200 > >+++ ./bin/ps/keyword.c 2012-01-11 15:44:27.000000000 +0100 > >@@ -90,6 +90,7 @@ > > NULL, 0}, > > {"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL,=20 > > 0}, > > {"f", "F", NULL, 0, kvar, NULL, 8, KOFF(ki_flag), INT, "x", 0}, > >+ {"fib", "FIB", NULL, 0, kvar, NULL, 2, KOFF(ki_fibnum), INT, "d", 0}, > > {"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, > > {"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, > > {"inblk", "INBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), LONG, > >_______________________________________________ > >freebsd-hackers@freebsd.org mailing list > >http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > >To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.or= g" > > >=20 > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" --l7ZAGG5ZGPl0OWqn Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk8QI0UACgkQC3+MBN1Mb4iZIQCeJMmMRc1xlEKG9AqVZ5Z3g7b2 htsAn1sIrSGYbjpROJhvpknVM7mUoiEx =uZA+ -----END PGP SIGNATURE----- --l7ZAGG5ZGPl0OWqn--