From owner-svn-src-all@freebsd.org Mon Apr 17 09:34:11 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E72E3D3F1E8; Mon, 17 Apr 2017 09:34:11 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A4F5BDEF; Mon, 17 Apr 2017 09:34:11 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3H9YAbf021517; Mon, 17 Apr 2017 09:34:10 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3H9Y9ni021507; Mon, 17 Apr 2017 09:34:09 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201704170934.v3H9Y9ni021507@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 17 Apr 2017 09:34:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317042 - in stable/11/sys: net netpfil/ipfw X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Apr 2017 09:34:12 -0000 Author: ae Date: Mon Apr 17 09:34:09 2017 New Revision: 317042 URL: https://svnweb.freebsd.org/changeset/base/317042 Log: MFC r316461: Remove "IPFW static rules" rmlock. Make PFIL's lock global and use it for this purpose. This reduces the number of locks needed to acquire for each packet. Obtained from: Yandex LLC Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D10154 Modified: stable/11/sys/net/pfil.c stable/11/sys/net/pfil.h stable/11/sys/netpfil/ipfw/ip_fw2.c stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c stable/11/sys/netpfil/ipfw/ip_fw_iface.c stable/11/sys/netpfil/ipfw/ip_fw_nat.c stable/11/sys/netpfil/ipfw/ip_fw_private.h stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c stable/11/sys/netpfil/ipfw/ip_fw_table.c stable/11/sys/netpfil/ipfw/ip_fw_table_value.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/pfil.c ============================================================================== --- stable/11/sys/net/pfil.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/net/pfil.c Mon Apr 17 09:34:09 2017 (r317042) @@ -61,7 +61,6 @@ LIST_HEAD(pfilheadhead, pfil_head); VNET_DEFINE(struct pfilheadhead, pfil_head_list); #define V_pfil_head_list VNET(pfil_head_list) VNET_DEFINE(struct rmlock, pfil_lock); -#define V_pfil_lock VNET(pfil_lock) #define PFIL_LOCK_INIT_REAL(l, t) \ rm_init_flags(l, "PFil " t " rmlock", RM_RECURSE) Modified: stable/11/sys/net/pfil.h ============================================================================== --- stable/11/sys/net/pfil.h Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/net/pfil.h Mon Apr 17 09:34:09 2017 (r317042) @@ -38,6 +38,7 @@ #include #include #include +#include struct mbuf; struct ifnet; @@ -94,6 +95,9 @@ struct pfil_head { LIST_ENTRY(pfil_head) ph_list; }; +VNET_DECLARE(struct rmlock, pfil_lock); +#define V_pfil_lock VNET(pfil_lock) + /* Public functions for pfil hook management by packet filters. */ struct pfil_head *pfil_head_get(int, u_long); int pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *); Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw2.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw2.c Mon Apr 17 09:34:09 2017 (r317042) @@ -992,7 +992,6 @@ ipfw_chk(struct ip_fw_args *args) int is_ipv4 = 0; int done = 0; /* flag to exit the outer loop */ - IPFW_RLOCK_TRACKER; if (m->m_flags & M_SKIP_FIREWALL || (! V_ipfw_vnet_ready)) return (IP_FW_PASS); /* accept */ Modified: stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c Mon Apr 17 09:34:09 2017 (r317042) @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include /* for ETHERTYPE_IP */ #include #include +#include #include #include Modified: stable/11/sys/netpfil/ipfw/ip_fw_iface.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_iface.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw_iface.c Mon Apr 17 09:34:09 2017 (r317042) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: stable/11/sys/netpfil/ipfw/ip_fw_nat.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_nat.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw_nat.c Mon Apr 17 09:34:09 2017 (r317042) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include Modified: stable/11/sys/netpfil/ipfw/ip_fw_private.h ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_private.h Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw_private.h Mon Apr 17 09:34:09 2017 (r317042) @@ -272,8 +272,6 @@ struct ip_fw_chain { void **srvstate; /* runtime service mappings */ #if defined( __linux__ ) || defined( _WIN32 ) spinlock_t rwmtx; -#else - struct rmlock rwmtx; #endif int static_len; /* total len of static rules (v0) */ uint32_t gencnt; /* NAT generation count */ @@ -414,25 +412,23 @@ struct ipfw_ifc { #define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) #else /* FreeBSD */ #define IPFW_LOCK_INIT(_chain) do { \ - rm_init_flags(&(_chain)->rwmtx, "IPFW static rules", RM_RECURSE); \ rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \ } while (0) #define IPFW_LOCK_DESTROY(_chain) do { \ - rm_destroy(&(_chain)->rwmtx); \ rw_destroy(&(_chain)->uh_lock); \ } while (0) -#define IPFW_RLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_RLOCKED) -#define IPFW_WLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_WLOCKED) +#define IPFW_RLOCK_ASSERT(_chain) rm_assert(&V_pfil_lock, RA_RLOCKED) +#define IPFW_WLOCK_ASSERT(_chain) rm_assert(&V_pfil_lock, RA_WLOCKED) #define IPFW_RLOCK_TRACKER struct rm_priotracker _tracker -#define IPFW_RLOCK(p) rm_rlock(&(p)->rwmtx, &_tracker) -#define IPFW_RUNLOCK(p) rm_runlock(&(p)->rwmtx, &_tracker) -#define IPFW_WLOCK(p) rm_wlock(&(p)->rwmtx) -#define IPFW_WUNLOCK(p) rm_wunlock(&(p)->rwmtx) -#define IPFW_PF_RLOCK(p) IPFW_RLOCK(p) -#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) +#define IPFW_RLOCK(p) rm_rlock(&V_pfil_lock, &_tracker) +#define IPFW_RUNLOCK(p) rm_runlock(&V_pfil_lock, &_tracker) +#define IPFW_WLOCK(p) rm_wlock(&V_pfil_lock) +#define IPFW_WUNLOCK(p) rm_wunlock(&V_pfil_lock) +#define IPFW_PF_RLOCK(p) +#define IPFW_PF_RUNLOCK(p) #endif #define IPFW_UH_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_RLOCKED) Modified: stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Mon Apr 17 09:34:09 2017 (r317042) @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: stable/11/sys/netpfil/ipfw/ip_fw_table.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_table.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw_table.c Mon Apr 17 09:34:09 2017 (r317042) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* ip_fw.h requires IFNAMSIZ */ +#include #include #include /* struct ipfw_rule_ref */ Modified: stable/11/sys/netpfil/ipfw/ip_fw_table_value.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_table_value.c Mon Apr 17 09:00:20 2017 (r317041) +++ stable/11/sys/netpfil/ipfw/ip_fw_table_value.c Mon Apr 17 09:34:09 2017 (r317042) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* ip_fw.h requires IFNAMSIZ */ +#include #include #include /* struct ipfw_rule_ref */