freebsd-nq/sys/netinet/in_debug.c
Matt Macy d7c5a620e2 ifnet: Replace if_addr_lock rwlock with epoch + mutex
Run on LLNW canaries and tested by pho@

gallatin:
Using a 14-core, 28-HTT single socket E5-2697 v3 with a 40GbE MLX5
based ConnectX 4-LX NIC, I see an almost 12% improvement in received
packet rate, and a larger improvement in bytes delivered all the way
to userspace.

When the host receiving 64 streams of netperf -H $DUT -t UDP_STREAM -- -m 1,
I see, using nstat -I mce0 1 before the patch:

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
4.98   0.00   4.42   0.00 4235592     33   83.80 4720653 2149771   1235 247.32
4.73   0.00   4.20   0.00 4025260     33   82.99 4724900 2139833   1204 247.32
4.72   0.00   4.20   0.00 4035252     33   82.14 4719162 2132023   1264 247.32
4.71   0.00   4.21   0.00 4073206     33   83.68 4744973 2123317   1347 247.32
4.72   0.00   4.21   0.00 4061118     33   80.82 4713615 2188091   1490 247.32
4.72   0.00   4.21   0.00 4051675     33   85.29 4727399 2109011   1205 247.32
4.73   0.00   4.21   0.00 4039056     33   84.65 4724735 2102603   1053 247.32

After the patch

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
5.43   0.00   4.20   0.00 3313143     33   84.96 5434214 1900162   2656 245.51
5.43   0.00   4.20   0.00 3308527     33   85.24 5439695 1809382   2521 245.51
5.42   0.00   4.19   0.00 3316778     33   87.54 5416028 1805835   2256 245.51
5.42   0.00   4.19   0.00 3317673     33   90.44 5426044 1763056   2332 245.51
5.42   0.00   4.19   0.00 3314839     33   88.11 5435732 1792218   2499 245.52
5.44   0.00   4.19   0.00 3293228     33   91.84 5426301 1668597   2121 245.52

Similarly, netperf reports 230Mb/s before the patch, and 270Mb/s after the patch

Reviewed by:	gallatin
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D15366
2018-05-18 20:13:34 +00:00

118 lines
3.5 KiB
C

/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2010 Bjoern A. Zeeb <bz@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/socket.h>
#ifdef DDB
#include <ddb/ddb.h>
#endif
#include <net/if.h>
#include <net/if_var.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#ifdef DDB
static void
in_show_sockaddr_in(struct sockaddr_in *sin)
{
#define SIN_DB_RPINTF(f, e) db_printf("\t %s = " f "\n", #e, sin->e);
db_printf("\tsockaddr_in = %p\n", sin);
SIN_DB_RPINTF("%u", sin_len);
SIN_DB_RPINTF("%u", sin_family);
SIN_DB_RPINTF("%u", sin_port);
SIN_DB_RPINTF("0x%08x", sin_addr.s_addr);
db_printf("\t %s = %02x%02x%02x%02x%02x%02x%02x%02x\n",
"sin_zero[8]",
sin->sin_zero[0], sin->sin_zero[1],
sin->sin_zero[2], sin->sin_zero[3],
sin->sin_zero[4], sin->sin_zero[5],
sin->sin_zero[6], sin->sin_zero[7]);
#undef SIN_DB_RPINTF
}
DB_SHOW_COMMAND(sin, db_show_sin)
{
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)addr;
if (sin == NULL) {
/* usage: No need to confess if you didn't sin. */
db_printf("usage: show sin <struct sockaddr_in *>\n");
return;
}
in_show_sockaddr_in(sin);
}
static void
in_show_in_ifaddr(struct in_ifaddr *ia)
{
#define IA_DB_RPINTF(f, e) db_printf("\t %s = " f "\n", #e, ia->e);
#define IA_DB_RPINTF_PTR(f, e) db_printf("\t %s = " f "\n", #e, &ia->e);
#define IA_DB_RPINTF_DPTR(f, e) db_printf("\t *%s = " f "\n", #e, *ia->e);
db_printf("\tin_ifaddr = %p\n", ia);
IA_DB_RPINTF_PTR("%p", ia_ifa);
IA_DB_RPINTF("0x%08lx", ia_subnet);
IA_DB_RPINTF("0x%08lx", ia_subnetmask);
IA_DB_RPINTF("%p", ia_hash.le_next);
IA_DB_RPINTF("%p", ia_hash.le_prev);
IA_DB_RPINTF_DPTR("%p", ia_hash.le_prev);
IA_DB_RPINTF("%p", ia_link.stqe_next);
IA_DB_RPINTF_PTR("%p", ia_addr);
IA_DB_RPINTF_PTR("%p", ia_dstaddr);
IA_DB_RPINTF_PTR("%p", ia_sockmask);
#undef IA_DB_RPINTF_DPTR
#undef IA_DB_RPINTF_PTR
#undef IA_DB_RPINTF
}
DB_SHOW_COMMAND(in_ifaddr, db_show_in_ifaddr)
{
struct in_ifaddr *ia;
ia = (struct in_ifaddr *)addr;
if (ia == NULL) {
db_printf("usage: show in_ifaddr <struct in_ifaddr *>\n");
return;
}
in_show_in_ifaddr(ia);
}
#endif