diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2021-02-26 08:31:24 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2021-02-26 08:31:24 +0000 |
commit | 8e708be9563b091ca15ac0e58923c2dc1254013f (patch) | |
tree | 948147592492879bb5204b8e1d6f0a5284657711 | |
parent | 59f0f9f05e10d154da580c53e963dd2e4f55f1a5 (diff) |
only store the current time on address table entries if it changes.
this avoids unecessary writes to memory. it helps a little bit with
a single nettq, but we get a lot more of a boost in pps when running
concurrently.
thanks to hrvoje for testing.
-rw-r--r-- | sys/net/if_etherbridge.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/if_etherbridge.c b/sys/net/if_etherbridge.c index 451781a9908..d3488029d36 100644 --- a/sys/net/if_etherbridge.c +++ b/sys/net/if_etherbridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_etherbridge.c,v 1.4 2021/02/26 01:28:51 dlg Exp $ */ +/* $OpenBSD: if_etherbridge.c,v 1.5 2021/02/26 08:31:23 dlg Exp $ */ /* * Copyright (c) 2018, 2021 David Gwynne <dlg@openbsd.org> @@ -299,10 +299,12 @@ etherbridge_map(struct etherbridge *eb, void *port, uint64_t eba) unsigned int num; void *nport; int new = 0; + time_t now; if (ETH64_IS_MULTICAST(eba) || ETH64_IS_ANYADDR(eba)) return; + now = getuptime(); ebl = etherbridge_list(eb, eba); smr_read_enter(); @@ -310,7 +312,8 @@ etherbridge_map(struct etherbridge *eb, void *port, uint64_t eba) if (oebe == NULL) new = 1; else { - oebe->ebe_age = getuptime(); + if (oebe->ebe_age != now) + oebe->ebe_age = now; /* does this entry need to be replaced? */ if (oebe->ebe_type == EBE_DYNAMIC && @@ -345,7 +348,7 @@ etherbridge_map(struct etherbridge *eb, void *port, uint64_t eba) nebe->ebe_addr = eba; nebe->ebe_port = nport; nebe->ebe_type = EBE_DYNAMIC; - nebe->ebe_age = getuptime(); + nebe->ebe_age = now; mtx_enter(&eb->eb_lock); num = eb->eb_num + (oebe == NULL); |