summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket2.c
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2000-09-05 22:11:13 +0000
committertruckman <truckman@FreeBSD.org>2000-09-05 22:11:13 +0000
commit0575d8a3f9479a36221dabd7a8ba8c2dfdf8d4dc (patch)
tree8c7e5bf5d0e9e0c6cb7fd6854e645d80831d7971 /sys/kern/uipc_socket2.c
parentf91fd40feebbd40ce508814370c744e8d33c5b12 (diff)
downloadFreeBSD-src-0575d8a3f9479a36221dabd7a8ba8c2dfdf8d4dc.zip
FreeBSD-src-0575d8a3f9479a36221dabd7a8ba8c2dfdf8d4dc.tar.gz
Remove uidinfo hash table lookup and maintenance out of chgproccnt() and
chgsbsize(), which are called rather frequently and may be called from an interrupt context in the case of chgsbsize(). Instead, do the hash table lookup and maintenance when credentials are changed, which is a lot less frequent. Add pointers to the uidinfo structures to the ucred and pcred structures for fast access. Pass a pointer to the credential to chgproccnt() and chgsbsize() instead of passing the uid. Add a reference count to the uidinfo structure and use it to decide when to free the structure rather than freeing the structure when the resource consumption drops to zero. Move the resource tracking code from kern_proc.c to kern_resource.c. Move some duplicate code sequences in kern_prot.c to separate helper functions. Change KASSERTs in this code to unconditional tests and calls to panic().
Diffstat (limited to 'sys/kern/uipc_socket2.c')
-rw-r--r--sys/kern/uipc_socket2.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index 8016436..4ed67e5 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -427,7 +427,7 @@ sbreserve(sb, cc, so, p)
*/
if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES))
return (0);
- if (!chgsbsize(so->so_cred->cr_uid, &sb->sb_hiwat, cc,
+ if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc,
p ? p->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) {
return (0);
}
@@ -447,7 +447,8 @@ sbrelease(sb, so)
{
sbflush(sb);
- (void)chgsbsize(so->so_cred->cr_uid, &sb->sb_hiwat, 0, RLIM_INFINITY);
+ (void)chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, 0,
+ RLIM_INFINITY);
sb->sb_mbmax = 0;
}
OpenPOWER on IntegriCloud