Module Name: src Committed By: ad Date: Thu Sep 7 20:12:33 UTC 2023
Modified Files: src/sys/kern: uipc_socket.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.303 -r1.304 src/sys/kern/uipc_socket.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.303 src/sys/kern/uipc_socket.c:1.304 --- src/sys/kern/uipc_socket.c:1.303 Sat Aug 5 09:25:39 2023 +++ src/sys/kern/uipc_socket.c Thu Sep 7 20:12:33 2023 @@ -1,7 +1,7 @@ -/* $NetBSD: uipc_socket.c,v 1.303 2023/08/05 09:25:39 andvar Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.304 2023/09/07 20:12:33 ad 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.303 2023/08/05 09:25:39 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.304 2023/09/07 20:12:33 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -559,7 +559,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;