diff options
author | 2020-04-10 07:36:52 +0000 | |
---|---|---|
committer | 2020-04-10 07:36:52 +0000 | |
commit | a779fb881b023ed4a852450f47731cd6b417dff2 (patch) | |
tree | 8b9a98d74f13b35af68e631a21e5bbde4887fc1c | |
parent | Update ARG_MAX bytes count (diff) | |
download | wireguard-openbsd-a779fb881b023ed4a852450f47731cd6b417dff2.tar.xz wireguard-openbsd-a779fb881b023ed4a852450f47731cd6b417dff2.zip |
Place the 64bit key on the stack instead of malloc(9)in' it in pppx_if_find().
Removing a malloc(9) with M_WAITOK reduces possible context switches which
helps when dealing with parallelism issues.
From Vitaliy Makkoveev.
-rw-r--r-- | sys/net/if_pppx.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 1a35fce70bc..7f03cb515f9 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.82 2020/04/07 13:27:52 visa Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.83 2020/04/10 07:36:52 mpi Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -643,20 +643,20 @@ pppx_if_next_unit(void) struct pppx_if * pppx_if_find(struct pppx_dev *pxd, int session_id, int protocol) { - struct pppx_if *s, *p; - s = malloc(sizeof(*s), M_DEVBUF, M_WAITOK | M_ZERO); + struct pppx_if_key key; + struct pppx_if *pxi; - s->pxi_key.pxik_session_id = session_id; - s->pxi_key.pxik_protocol = protocol; + memset(&key, 0, sizeof(key)); + key.pxik_session_id = session_id; + key.pxik_protocol = protocol; rw_enter_read(&pppx_ifs_lk); - p = RBT_FIND(pppx_ifs, &pppx_ifs, s); - if (p && p->pxi_ready == 0) - p = NULL; + pxi = RBT_FIND(pppx_ifs, &pppx_ifs, (struct pppx_if *)&key); + if (pxi && pxi->pxi_ready == 0) + pxi = NULL; rw_exit_read(&pppx_ifs_lk); - free(s, M_DEVBUF, sizeof(*s)); - return (p); + return pxi; } int |