Skip to content

Commit 70ddceb

Browse files
committed
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.
1 parent bab0f11 commit 70ddceb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sys/kern/uipc_socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* $NetBSD: uipc_socket.c,v 1.303 2023/08/05 09:25:39 andvar Exp $ */
1+
/* $NetBSD: uipc_socket.c,v 1.304 2023/09/07 20:12:33 ad Exp $ */
22

33
/*
4-
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
4+
* Copyright (c) 2002, 2007, 2008, 2009, 2023 The NetBSD Foundation, Inc.
55
* All rights reserved.
66
*
77
* This code is derived from software contributed to The NetBSD Foundation
@@ -71,7 +71,7 @@
7171
*/
7272

7373
#include <sys/cdefs.h>
74-
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.303 2023/08/05 09:25:39 andvar Exp $");
74+
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.304 2023/09/07 20:12:33 ad Exp $");
7575

7676
#ifdef _KERNEL_OPT
7777
#include "opt_compat_netbsd.h"
@@ -559,7 +559,7 @@ socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l,
559559
sofree(so);
560560
return error;
561561
}
562-
so->so_cred = kauth_cred_dup(l->l_cred);
562+
kauth_cred_hold(so->so_cred = l->l_cred);
563563
sounlock(so);
564564

565565
*aso = so;

0 commit comments

Comments
 (0)