Module Name: src
Committed By: martin
Date: Wed Sep 11 16:26:58 UTC 2024
Modified Files:
src/sys/kern [netbsd-10]: uipc_socket.c uipc_syscalls.c
Log Message:
Pull up following revision(s) (requested by rin in ticket #830):
sys/kern/uipc_socket.c: revision 1.304
sys/kern/uipc_syscalls.c: revision 1.207
Fix a ~16 year old perf regression: when creating a socket, add a reference
to the caller's credentials rather than copying them. On an 80486DX2/66 this
seems to ~halve the time taken to create a socket.
Fix a ~16 year old perf regression: when accepting a connection, add a
reference to the caller's credentials rather than copying them.
To generate a diff of this commit:
cvs rdiff -u -r1.302.4.2 -r1.302.4.3 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.206.4.1 -r1.206.4.2 src/sys/kern/uipc_syscalls.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.302.4.2 src/sys/kern/uipc_socket.c:1.302.4.3
--- src/sys/kern/uipc_socket.c:1.302.4.2 Sat Jul 20 14:37:05 2024
+++ src/sys/kern/uipc_socket.c Wed Sep 11 16:26:57 2024
@@ -1,7 +1,7 @@
-/* $NetBSD: uipc_socket.c,v 1.302.4.2 2024/07/20 14:37:05 martin Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.302.4.3 2024/09/11 16:26:57 martin Exp $ */
/*
- * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2002, 2007, 2008, 2009, 2023 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.302.4.2 2024/07/20 14:37:05 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.302.4.3 2024/09/11 16:26:57 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -560,7 +560,7 @@ socreate(int dom, struct socket **aso, i
sofree(so);
return error;
}
- so->so_cred = kauth_cred_dup(l->l_cred);
+ kauth_cred_hold(so->so_cred = l->l_cred);
sounlock(so);
*aso = so;
Index: src/sys/kern/uipc_syscalls.c
diff -u src/sys/kern/uipc_syscalls.c:1.206.4.1 src/sys/kern/uipc_syscalls.c:1.206.4.2
--- src/sys/kern/uipc_syscalls.c:1.206.4.1 Sun Feb 4 11:20:15 2024
+++ src/sys/kern/uipc_syscalls.c Wed Sep 11 16:26:57 2024
@@ -1,7 +1,7 @@
-/* $NetBSD: uipc_syscalls.c,v 1.206.4.1 2024/02/04 11:20:15 martin Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.206.4.2 2024/09/11 16:26:57 martin Exp $ */
/*-
- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2023 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.206.4.1 2024/02/04 11:20:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.206.4.2 2024/09/11 16:26:57 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_pipe.h"
@@ -244,7 +244,7 @@ do_sys_accept(struct lwp *l, int sock, s
else
so2->so_state &= ~SS_NBIO;
error = soaccept(so2, name);
- so2->so_cred = kauth_cred_dup(so->so_cred);
+ kauth_cred_hold(so2->so_cred = so->so_cred);
sounlock(so);
if (error) {
/* an error occurred, free the file descriptor and mbuf */
@@ -1675,7 +1675,7 @@ do_sys_peeloff(struct socket *head, void
so->so_state &= ~SS_NOFDREF;
so->so_state &= ~SS_ISCONNECTING;
so->so_head = NULL;
- so->so_cred = kauth_cred_dup(head->so_cred);
+ kauth_cred_hold(so->so_cred = head->so_cred);
nfp->f_socket = so;
nfp->f_flag = FREAD|FWRITE;
nfp->f_ops = &socketops;