From owner-svn-src-stable-11@freebsd.org Wed Apr 18 18:45:05 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 034B7FA1B85; Wed, 18 Apr 2018 18:45:05 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A45FE7AC7B; Wed, 18 Apr 2018 18:45:04 +0000 (UTC) (envelope-from shurd@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 855A51EBB5; Wed, 18 Apr 2018 18:45:04 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3IIj4Yg037188; Wed, 18 Apr 2018 18:45:04 GMT (envelope-from shurd@FreeBSD.org) Received: (from shurd@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3IIj4fL037185; Wed, 18 Apr 2018 18:45:04 GMT (envelope-from shurd@FreeBSD.org) Message-Id: <201804181845.w3IIj4fL037185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: shurd set sender to shurd@FreeBSD.org using -f From: Stephen Hurd Date: Wed, 18 Apr 2018 18:45:04 +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: r332734 - in stable/11/sys: kern net X-SVN-Group: stable-11 X-SVN-Commit-Author: shurd X-SVN-Commit-Paths: in stable/11/sys: kern net X-SVN-Commit-Revision: 332734 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Apr 2018 18:45:05 -0000 Author: shurd Date: Wed Apr 18 18:45:04 2018 New Revision: 332734 URL: https://svnweb.freebsd.org/changeset/base/332734 Log: MFC r332388: Make BPF global lock an SX This allows NIC drivers to sleep on polling config operations. PR: 323477 Submitted by: Matthew Macy Reviewed by: shurd Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D14982 Modified: stable/11/sys/kern/subr_witness.c stable/11/sys/net/bpf.c stable/11/sys/net/bpfdesc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/subr_witness.c ============================================================================== --- stable/11/sys/kern/subr_witness.c Wed Apr 18 18:36:26 2018 (r332733) +++ stable/11/sys/kern/subr_witness.c Wed Apr 18 18:45:04 2018 (r332734) @@ -567,7 +567,7 @@ static struct witness_order_list_entry order_lists[] = /* * BPF */ - { "bpf global lock", &lock_class_mtx_sleep }, + { "bpf global lock", &lock_class_sx }, { "bpf interface lock", &lock_class_rw }, { "bpf cdev lock", &lock_class_mtx_sleep }, { NULL, NULL }, Modified: stable/11/sys/net/bpf.c ============================================================================== --- stable/11/sys/net/bpf.c Wed Apr 18 18:36:26 2018 (r332733) +++ stable/11/sys/net/bpf.c Wed Apr 18 18:45:04 2018 (r332734) @@ -157,6 +157,9 @@ struct bpf_dltlist32 { #define BIOCSETFNR32 _IOW('B', 130, struct bpf_program32) #endif +#define BPF_LOCK() sx_xlock(&bpf_sx) +#define BPF_UNLOCK() sx_xunlock(&bpf_sx) +#define BPF_LOCK_ASSERT() sx_assert(&bpf_sx, SA_XLOCKED) /* * bpf_iflist is a list of BPF interface structures, each corresponding to a * specific DLT. The same network interface might have several BPF interface @@ -164,7 +167,7 @@ struct bpf_dltlist32 { * frames, ethernet frames, etc). */ static LIST_HEAD(, bpf_if) bpf_iflist, bpf_freelist; -static struct mtx bpf_mtx; /* bpf global lock */ +static struct sx bpf_sx; /* bpf global lock */ static int bpf_bpfd_cnt; static void bpf_attachd(struct bpf_d *, struct bpf_if *); @@ -2800,7 +2803,7 @@ bpf_drvinit(void *unused) { struct cdev *dev; - mtx_init(&bpf_mtx, "bpf global lock", NULL, MTX_DEF); + sx_init(&bpf_sx, "bpf global lock"); LIST_INIT(&bpf_iflist); LIST_INIT(&bpf_freelist); Modified: stable/11/sys/net/bpfdesc.h ============================================================================== --- stable/11/sys/net/bpfdesc.h Wed Apr 18 18:36:26 2018 (r332733) +++ stable/11/sys/net/bpfdesc.h Wed Apr 18 18:45:04 2018 (r332734) @@ -115,9 +115,6 @@ struct bpf_d { #define BPF_PID_REFRESH(bd, td) (bd)->bd_pid = (td)->td_proc->p_pid #define BPF_PID_REFRESH_CUR(bd) (bd)->bd_pid = curthread->td_proc->p_pid -#define BPF_LOCK() mtx_lock(&bpf_mtx) -#define BPF_UNLOCK() mtx_unlock(&bpf_mtx) -#define BPF_LOCK_ASSERT() mtx_assert(&bpf_mtx, MA_OWNED) /* * External representation of the bpf descriptor */