Subject: kern/26210: ps(1) cannot show msgrcv per-process statistics since 10 years ago :)
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <mmondor@gmail.com>
List: netbsd-bugs
Date: 07/08/2004 23:04:50
>Number:         26210
>Category:       kern
>Synopsis:       ps(1) cannot show msgrcv per-process statistics since 10 years ago :)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 08 23:05:01 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Mondor
>Release:        NetBSD 2.0_BETA
>Organization:
>Environment:
NetBSD ginseng.xisop 2.0_BETA NetBSD 2.0_BETA (GINSENG) #0: Sat Jun 26 09:56:57 EDT 2004  root@ginseng.xisop:/home/src/sys/arch/i386/compile/GINSENG i386

>Description:
Code seems to be annotated by mycroft, 10 years ago, code from soreceive() in src/sys/kern/uipc_socket.c which prevents received packets accounting and thus ps(1) from showing any results for msgrcv.

sosend() uses code which works for the msgsnd part, and testing could show for me that the system works well when soreceive() is using the same method (even if we eventually want to change that port for better MP code, I assume that it's why XXX is used at those locations. But, it works for now.
>How-To-Repeat:
ps -axo pid,msgrcv,msgsnd

Note that 0 is displayed for all processes for msgrcv.
>Fix:
Apply the following diff

--- uipc_socket.c       1.97.2.1
+++ uipc_socket.c
@@ -924,12 +924,14 @@
 soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
        struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
 {
+       struct proc     *p;
        struct mbuf     *m, **mp;
        int             flags, len, error, s, offset, moff, type, orig_resid;
        struct protosw  *pr;
        struct mbuf     *nextrecord;
        int             mbuf_removed = 0;
 
+       p = curproc;            /* XXX */
        pr = so->so_proto;
        mp = mp0;
        type = 0;
@@ -1040,9 +1042,11 @@
         * While we process the initial mbufs containing address and control
         * info, we save a copy of m->m_nextpkt into nextrecord.
         */
-#ifdef notyet /* XXXX */
+#ifdef notyet /* XXX */
        if (uio->uio_procp)
                uio->uio_procp->p_stats->p_ru.ru_msgrcv++;
+#else
+       p->p_stats->p_ru.ru_msgrcv++;
 #endif
        KASSERT(m == so->so_rcv.sb_mb);
        SBLASTRECORDCHK(&so->so_rcv, "soreceive 1");

>Release-Note:
>Audit-Trail:
>Unformatted: