Subject: Re: curproc removal (NFS, ...)
To: None <tech-kern@NetBSD.org>
From: Jonathan Stone <jonathan@dsg.stanford.edu>
List: tech-kern
Date: 06/06/2004 14:10:28
In message <E1BX3MD-0000qj-00@smeg.dsg.stanford.edu>,
Jonathan Stone writes:
>>>How about KASSERT(uio->uio_segflag == UIO_USERSPACE), for externalize
>>>ops in soreceive()?
Aside from the ugliness of the XXXX, this looks about right.
Also, consider the XXXX as declaring intent to remove the "#ifdef notdef"
around the `if (p) p->p_statsp_ru->ru_msgrcv++', and to do so "soon".
At which time the
`if (mp0) p = NULL;'
will also die. (If we do splice(2) or sendfile(2) using kconts to do
soreceive() into an mbuf-chain pointer, from a softint-like context,
we really should account the recieve()s against the process issuing
the splice() or sendfile() syscall. And the only way to do that is to
set uio->uio_procp to that process' struct proc *.)
Thanks again, to Yamamoto-san, Matt Thomas, and others who offered
feedback and suggested improvements to these ongoing changes.
Index: uipc_socket.c
===================================================================
RCS file: /cvsroot/src/sys/kern/uipc_socket.c,v
retrieving revision 1.103
diff -u -r1.103 uipc_socket.c
--- uipc_socket.c 25 May 2004 04:30:32 -0000 1.103
+++ uipc_socket.c 6 Jun 2004 20:56:34 -0000
@@ -925,7 +925,9 @@
*
* The caller may receive the data as a single mbuf chain by supplying
* an mbuf **mp0 for use in returning the chain. The uio is then used
- * only for the count in uio_resid.
+ * only for the count in uio_resid. (If non-NULL, the struct proc *
+ * in uio_procp may also be used in this case, for p_stats->p_ru accounting
+ * of receive operations, but this is not yet implemented.)
*/
int
soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
@@ -943,6 +945,10 @@
type = 0;
orig_resid = uio->uio_resid;
p = uio->uio_procp;
+#ifndef notyet /* XXXX; see p->p_stats_>p_ru.ru_msgrcv++ below */
+ if (mp0)
+ p = NULL;
+#endif
if (paddr)
*paddr = 0;
@@ -1092,6 +1098,7 @@
mbuf_removed = 1;
if (controlp) {
struct domain *dom = pr->pr_domain;
+ KASSERT(p != NULL);
if (dom->dom_externalize && p &&
mtod(m, struct cmsghdr *)->cmsg_type ==
SCM_RIGHTS)