From owner-svn-src-user@FreeBSD.ORG Sun May 17 00:01:57 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E44C106566B; Sun, 17 May 2009 00:01:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4D8C58FC1A; Sun, 17 May 2009 00:01:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4H01vWm008178; Sun, 17 May 2009 00:01:57 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4H01vhc008177; Sun, 17 May 2009 00:01:57 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905170001.n4H01vhc008177@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 00:01:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192236 - user/kmacy/ZFS_MFC/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 00:01:57 -0000 Author: kmacy Date: Sun May 17 00:01:57 2009 New Revision: 192236 URL: http://svn.freebsd.org/changeset/base/192236 Log: enable adaptive sx Modified: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Modified: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Sat May 16 23:57:47 2009 (r192235) +++ user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Sun May 17 00:01:57 2009 (r192236) @@ -76,6 +76,7 @@ options WITNESS_SKIPSPIN options DEBUG options KDB options DDB +options ADAPTIVE_SX # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel From owner-svn-src-user@FreeBSD.ORG Sun May 17 01:32:47 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6942106564A; Sun, 17 May 2009 01:32:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B46818FC26; Sun, 17 May 2009 01:32:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4H1Wl7L010035; Sun, 17 May 2009 01:32:47 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4H1Wl4p010034; Sun, 17 May 2009 01:32:47 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905170132.n4H1Wl4p010034@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 01:32:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192238 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 01:32:48 -0000 Author: kmacy Date: Sun May 17 01:32:47 2009 New Revision: 192238 URL: http://svn.freebsd.org/changeset/base/192238 Log: generalize assert as savestart implies savename Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sun May 17 01:31:28 2009 (r192237) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sun May 17 01:32:47 2009 (r192238) @@ -4253,8 +4253,8 @@ zfs_freebsd_rename(ap) vnode_t *tvp = ap->a_tvp; int error; - ASSERT(ap->a_fcnp->cn_flags & SAVENAME); - ASSERT(ap->a_tcnp->cn_flags & SAVENAME); + ASSERT(ap->a_fcnp->cn_flags & (SAVENAME|SAVESTART)); + ASSERT(ap->a_tcnp->cn_flags & (SAVENAME|SAVESTART)); error = zfs_rename(fdvp, ap->a_fcnp->cn_nameptr, tdvp, ap->a_tcnp->cn_nameptr, ap->a_fcnp->cn_cred, NULL, 0); From owner-svn-src-user@FreeBSD.ORG Sun May 17 04:05:27 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 580DD106564A; Sun, 17 May 2009 04:05:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 451538FC08; Sun, 17 May 2009 04:05:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4H45R37013414; Sun, 17 May 2009 04:05:27 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4H45R0Q013413; Sun, 17 May 2009 04:05:27 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905170405.n4H45R0Q013413@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 04:05:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192241 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 04:05:27 -0000 Author: kmacy Date: Sun May 17 04:05:27 2009 New Revision: 192241 URL: http://svn.freebsd.org/changeset/base/192241 Log: set createtxg prop name PR: bin/130105 Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c Sun May 17 04:04:25 2009 (r192240) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c Sun May 17 04:05:27 2009 (r192241) @@ -297,7 +297,7 @@ zfs_prop_init(void) /* hidden properties */ register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER, - PROP_READONLY, ZFS_TYPE_DATASET, NULL); + PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG"); register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_SNAPSHOT, NULL); register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, From owner-svn-src-user@FreeBSD.ORG Sun May 17 05:55:14 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48C4D106567B; Sun, 17 May 2009 05:55:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3680A8FC16; Sun, 17 May 2009 05:55:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4H5tETr015629; Sun, 17 May 2009 05:55:14 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4H5tET0015628; Sun, 17 May 2009 05:55:14 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905170555.n4H5tET0015628@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 05:55:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192244 - user/kmacy/ZFS_MFC/usr.sbin/bsnmpd/modules/snmp_hostres X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 05:55:14 -0000 Author: kmacy Date: Sun May 17 05:55:13 2009 New Revision: 192244 URL: http://svn.freebsd.org/changeset/base/192244 Log: add zfs oid Modified: user/kmacy/ZFS_MFC/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Modified: user/kmacy/ZFS_MFC/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c ============================================================================== --- user/kmacy/ZFS_MFC/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Sun May 17 05:54:25 2009 (r192243) +++ user/kmacy/ZFS_MFC/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Sun May 17 05:55:13 2009 (r192244) @@ -131,6 +131,7 @@ static const struct { const struct asn_oid *oid; /* the OID to return */ } fs_type_map[] = { { "ufs", &OIDX_hrFSBerkeleyFFS_c }, + { "zfs", &OIDX_hrFSOther_c }, { "cd9660", &OIDX_hrFSiso9660_c }, { "nfs", &OIDX_hrFSNFS_c }, { "ext2fs", &OIDX_hrFSLinuxExt2_c }, From owner-svn-src-user@FreeBSD.ORG Sun May 17 17:49:57 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3D94106566B; Sun, 17 May 2009 17:49:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 951678FC17; Sun, 17 May 2009 17:49:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HHnv2p035488; Sun, 17 May 2009 17:49:57 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HHnvg4035487; Sun, 17 May 2009 17:49:57 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905171749.n4HHnvg4035487@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 17:49:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192253 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 17:49:58 -0000 Author: kmacy Date: Sun May 17 17:49:57 2009 New Revision: 192253 URL: http://svn.freebsd.org/changeset/base/192253 Log: enable forced unmount Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sun May 17 16:17:48 2009 (r192252) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sun May 17 17:49:57 2009 (r192253) @@ -974,9 +974,10 @@ zfs_umount(vfs_t *vfsp, int fflag, kthre int ret; if (fflag & MS_FORCE) { + /* TODO: Force unmount is not well implemented yet, so deny it. */ - ZFS_LOG(0, "Force unmount is not supported, removing FORCE flag."); - fflag &= ~MS_FORCE; + ZFS_LOG(0, "Force unmount is experimental - report any problems."); + } ret = secpolicy_fs_unmount(cr, vfsp); From owner-svn-src-user@FreeBSD.ORG Sun May 17 17:52:36 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21BBA106564A; Sun, 17 May 2009 17:52:36 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 13AE58FC0C; Sun, 17 May 2009 17:52:36 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HHqZSx035580; Sun, 17 May 2009 17:52:35 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HHqZ2N035579; Sun, 17 May 2009 17:52:35 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905171752.n4HHqZ2N035579@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 17:52:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192254 - user/kmacy/ZFS_MFC/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 17:52:36 -0000 Author: kmacy Date: Sun May 17 17:52:35 2009 New Revision: 192254 URL: http://svn.freebsd.org/changeset/base/192254 Log: add ALT_BREAK_TO_DEBUGGER Modified: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Modified: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Sun May 17 17:49:57 2009 (r192253) +++ user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Sun May 17 17:52:35 2009 (r192254) @@ -76,6 +76,7 @@ options WITNESS_SKIPSPIN options DEBUG options KDB options DDB +options ALT_BREAK_TO_DEBUGGER options ADAPTIVE_SX # Make an SMP-capable kernel by default From owner-svn-src-user@FreeBSD.ORG Sun May 17 20:16:38 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB25E1065680; Sun, 17 May 2009 20:16:38 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D5AE8FC1E; Sun, 17 May 2009 20:16:38 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HKGcEV038541; Sun, 17 May 2009 20:16:38 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HKGctP038538; Sun, 17 May 2009 20:16:38 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172016.n4HKGctP038538@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 20:16:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192259 - in user/kmacy/ZFS_MFC: cddl/contrib/opensolaris/lib/libzpool/common/sys sys/cddl/compat/opensolaris/sys sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 20:16:39 -0000 Author: kmacy Date: Sun May 17 20:16:38 2009 New Revision: 192259 URL: http://svn.freebsd.org/changeset/base/192259 Log: define compat shim for M_ZERO Modified: user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/kmem.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h ============================================================================== --- user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Sun May 17 19:51:08 2009 (r192258) +++ user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Sun May 17 20:16:38 2009 (r192259) @@ -301,6 +301,7 @@ extern void cv_broadcast(kcondvar_t *cv) */ #define KM_SLEEP UMEM_NOFAIL #define KM_PUSHPAGE KM_SLEEP +#define KM_ZERO 0 #define KM_NOSLEEP UMEM_DEFAULT #define KMC_NODEBUG UMC_NODEBUG #define kmem_alloc(_s, _f) umem_alloc(_s, _f) Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/kmem.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/kmem.h Sun May 17 19:51:08 2009 (r192258) +++ user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/kmem.h Sun May 17 20:16:38 2009 (r192259) @@ -40,6 +40,7 @@ #define KM_SLEEP M_WAITOK #define KM_PUSHPAGE M_WAITOK #define KM_NOSLEEP M_NOWAIT +#define KM_ZERO M_ZERO #define KMC_NODEBUG 0 typedef struct kmem_cache { Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sun May 17 19:51:08 2009 (r192258) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sun May 17 20:16:38 2009 (r192259) @@ -2965,7 +2965,7 @@ arc_release(arc_buf_t *buf, void *tag) mutex_exit(hash_lock); - nhdr = kmem_cache_alloc(hdr_cache, KM_PUSHPAGE|M_ZERO); + nhdr = kmem_cache_alloc(hdr_cache, (KM_PUSHPAGE|KM_ZERO)); nhdr->b_size = blksz; nhdr->b_spa = spa; nhdr->b_type = type; From owner-svn-src-user@FreeBSD.ORG Sun May 17 22:17:47 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5815106566B; Sun, 17 May 2009 22:17:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3B568FC08; Sun, 17 May 2009 22:17:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HMHlOH041192; Sun, 17 May 2009 22:17:47 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HMHl0N041191; Sun, 17 May 2009 22:17:47 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172217.n4HMHl0N041191@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 22:17:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192266 - user/kmacy/ZFS_MFC/sys/compat/pecoff X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 22:17:48 -0000 Author: kmacy Date: Sun May 17 22:17:47 2009 New Revision: 192266 URL: http://svn.freebsd.org/changeset/base/192266 Log: include fcntl.h for namei change Modified: user/kmacy/ZFS_MFC/sys/compat/pecoff/imgact_pecoff.c Modified: user/kmacy/ZFS_MFC/sys/compat/pecoff/imgact_pecoff.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/compat/pecoff/imgact_pecoff.c Sun May 17 21:28:37 2009 (r192265) +++ user/kmacy/ZFS_MFC/sys/compat/pecoff/imgact_pecoff.c Sun May 17 22:17:47 2009 (r192266) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include From owner-svn-src-user@FreeBSD.ORG Sun May 17 22:46:24 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C3CD1065676; Sun, 17 May 2009 22:46:24 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D0D338FC1D; Sun, 17 May 2009 22:46:23 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HMkN8i041873; Sun, 17 May 2009 22:46:23 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HMkNTt041872; Sun, 17 May 2009 22:46:23 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172246.n4HMkNTt041872@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 22:46:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192267 - user/kmacy/releng_7_2_zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 22:46:24 -0000 Author: kmacy Date: Sun May 17 22:46:23 2009 New Revision: 192267 URL: http://svn.freebsd.org/changeset/base/192267 Log: create dedicated 7.2 branch with zfs v13 Added: user/kmacy/releng_7_2_zfs/ - copied from r192266, releng/7.2/ From owner-svn-src-user@FreeBSD.ORG Sun May 17 23:14:27 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FA28106564A; Sun, 17 May 2009 23:14:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D95A8FC08; Sun, 17 May 2009 23:14:27 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HNEQRp042421; Sun, 17 May 2009 23:14:26 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNEQ7o042420; Sun, 17 May 2009 23:14:26 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172314.n4HNEQ7o042420@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 23:14:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192268 - user/kmacy/ZFS_MFC/sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 23:14:27 -0000 Author: kmacy Date: Sun May 17 23:14:26 2009 New Revision: 192268 URL: http://svn.freebsd.org/changeset/base/192268 Log: nothing references ni_dirfd remove to avoid breaking the ABI Modified: user/kmacy/ZFS_MFC/sys/sys/namei.h Modified: user/kmacy/ZFS_MFC/sys/sys/namei.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/sys/namei.h Sun May 17 22:46:23 2009 (r192267) +++ user/kmacy/ZFS_MFC/sys/sys/namei.h Sun May 17 23:14:26 2009 (r192268) @@ -69,7 +69,7 @@ struct nameidata { struct vnode *ni_startdir; /* starting directory */ struct vnode *ni_rootdir; /* logical root directory */ struct vnode *ni_topdir; /* logical top directory */ - int ni_dirfd; /* starting directory for *at functions */ /* + * Results: returned from/manipulated by lookup */ struct vnode *ni_vp; /* vnode of result */ @@ -86,6 +86,9 @@ struct nameidata { * through the VOP interface. */ struct componentname ni_cnd; +#ifdef notyet + int ni_dirfd; /* starting directory for *at functions */ /* +#endif }; }; #ifdef _KERNEL @@ -168,9 +171,11 @@ NDINIT_ALL(struct nameidata *ndp, ndp->ni_cnd.cn_flags = flags; ndp->ni_segflg = segflg; ndp->ni_dirp = namep; - ndp->ni_dirfd = dirfd; ndp->ni_startdir = startdir; ndp->ni_cnd.cn_thread = td; +#ifdef notyet + ndp->ni_dirfd = dirfd; +#endif } #define NDF_NO_DVP_RELE 0x00000001 From owner-svn-src-user@FreeBSD.ORG Sun May 17 23:17:57 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D5EC106566B; Sun, 17 May 2009 23:17:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B9568FC12; Sun, 17 May 2009 23:17:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HNHumk042522; Sun, 17 May 2009 23:17:56 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNHub8042521; Sun, 17 May 2009 23:17:56 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172317.n4HNHub8042521@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 23:17:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192269 - user/kmacy/ZFS_MFC/sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 23:17:57 -0000 Author: kmacy Date: Sun May 17 23:17:56 2009 New Revision: 192269 URL: http://svn.freebsd.org/changeset/base/192269 Log: fix comments Modified: user/kmacy/ZFS_MFC/sys/sys/namei.h Modified: user/kmacy/ZFS_MFC/sys/sys/namei.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/sys/namei.h Sun May 17 23:14:26 2009 (r192268) +++ user/kmacy/ZFS_MFC/sys/sys/namei.h Sun May 17 23:17:56 2009 (r192269) @@ -70,6 +70,7 @@ struct nameidata { struct vnode *ni_rootdir; /* logical root directory */ struct vnode *ni_topdir; /* logical top directory */ + /* * Results: returned from/manipulated by lookup */ struct vnode *ni_vp; /* vnode of result */ @@ -87,8 +88,8 @@ struct nameidata { */ struct componentname ni_cnd; #ifdef notyet - int ni_dirfd; /* starting directory for *at functions */ /* -#endif }; + int ni_dirfd; /* starting directory for *at functions */ +#endif }; #ifdef _KERNEL From owner-svn-src-user@FreeBSD.ORG Sun May 17 23:30:14 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E99C1065673; Sun, 17 May 2009 23:30:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27F9A8FC1A; Sun, 17 May 2009 23:30:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HNUEUw042833; Sun, 17 May 2009 23:30:14 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNUDgU042829; Sun, 17 May 2009 23:30:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172330.n4HNUDgU042829@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 23:30:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192271 - in user/kmacy/releng_7_2_zfs/sys: amd64/conf amd64/include boot/i386/zfsboot boot/zfs cddl/boot cddl/boot/zfs cddl/compat/opensolaris/kern cddl/compat/opensolaris/rpc cddl/com... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 23:30:14 -0000 Author: kmacy Date: Sun May 17 23:30:13 2009 New Revision: 192271 URL: http://svn.freebsd.org/changeset/base/192271 Log: MFC sys portion of update v13 Added: user/kmacy/releng_7_2_zfs/sys/amd64/conf/GENERIC_MINUS user/kmacy/releng_7_2_zfs/sys/boot/i386/zfsboot/ user/kmacy/releng_7_2_zfs/sys/boot/i386/zfsboot/zfsboot.c user/kmacy/releng_7_2_zfs/sys/boot/zfs/ user/kmacy/releng_7_2_zfs/sys/boot/zfs/zfsimpl.c user/kmacy/releng_7_2_zfs/sys/cddl/boot/ user/kmacy/releng_7_2_zfs/sys/cddl/boot/zfs/ user/kmacy/releng_7_2_zfs/sys/cddl/boot/zfs/README user/kmacy/releng_7_2_zfs/sys/cddl/boot/zfs/fletcher.c user/kmacy/releng_7_2_zfs/sys/cddl/boot/zfs/lzjb.c user/kmacy/releng_7_2_zfs/sys/cddl/boot/zfs/sha256.c user/kmacy/releng_7_2_zfs/sys/cddl/boot/zfs/zfsimpl.h user/kmacy/releng_7_2_zfs/sys/cddl/boot/zfs/zfssubr.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/file.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/kidmap.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/pathname.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/refstr.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/sid.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/sig.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/unicode/ user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/unicode/u8_textprep.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_comutil.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_comutil.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zprop_common.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg2.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scrub.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scrub2.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_deleg.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/rrwlock.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_boot.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_fuid.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid2.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_array.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_mem.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/acl_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/extdirent.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/idmap.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/ user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep_data.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c user/kmacy/releng_7_2_zfs/sys/kern/kern_osd.c user/kmacy/releng_7_2_zfs/sys/kern/kern_rmlock.c user/kmacy/releng_7_2_zfs/sys/libkern/memmove.c user/kmacy/releng_7_2_zfs/sys/sys/_rmlock.h user/kmacy/releng_7_2_zfs/sys/sys/osd.h user/kmacy/releng_7_2_zfs/sys/sys/rmlock.h Deleted: user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/acl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/amd64/atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/i386/atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/ia64/atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/atomic/sparc64/atomic.S user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr_array.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr_mem.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/vfs.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/zmod/crc32.c Modified: user/kmacy/releng_7_2_zfs/sys/amd64/include/vmparam.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/rpc/xdr.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/atomic.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/cpuvar.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/cred.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/dnlc.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/kmem.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/lock.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/misc.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/mntent.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/mutex.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/param.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/policy.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/proc.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/rwlock.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/sunddi.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/sysmacros.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/time.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/types.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/uio.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/vfs.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/vnode.h user/kmacy/releng_7_2_zfs/sys/cddl/compat/opensolaris/sys/zone.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/acl/acl_common.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/acl/acl_common.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/avl/avl.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/Makefile.files user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bplist.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/bplist.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_traverse.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_pool.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_prop.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_synctask.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/txg.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/txg_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/uberblock_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/unique.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_disk.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_leaf.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_acl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_dir.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/unique.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_byteswap.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/os/callb.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/os/list.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/os/taskq.c user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/avl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/byteorder.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/callb.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/cpuvar.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/cred.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/dkio.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/dklabel.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/fm/fs/zfs.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/fm/protocol.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/fm/util.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/gfs.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/list.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/nvpair.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/processor.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/synch.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h user/kmacy/releng_7_2_zfs/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.c user/kmacy/releng_7_2_zfs/sys/compat/linprocfs/linprocfs.c user/kmacy/releng_7_2_zfs/sys/compat/pecoff/imgact_pecoff.c user/kmacy/releng_7_2_zfs/sys/conf/files user/kmacy/releng_7_2_zfs/sys/fs/coda/coda_vfsops.c user/kmacy/releng_7_2_zfs/sys/fs/msdosfs/msdosfs_vfsops.c user/kmacy/releng_7_2_zfs/sys/fs/nullfs/null_vfsops.c user/kmacy/releng_7_2_zfs/sys/fs/unionfs/union_vfsops.c user/kmacy/releng_7_2_zfs/sys/kern/kern_environment.c user/kmacy/releng_7_2_zfs/sys/kern/kern_fork.c user/kmacy/releng_7_2_zfs/sys/kern/kern_jail.c user/kmacy/releng_7_2_zfs/sys/kern/kern_kse.c user/kmacy/releng_7_2_zfs/sys/kern/kern_malloc.c user/kmacy/releng_7_2_zfs/sys/kern/kern_proc.c user/kmacy/releng_7_2_zfs/sys/kern/kern_thr.c user/kmacy/releng_7_2_zfs/sys/kern/kern_thread.c user/kmacy/releng_7_2_zfs/sys/kern/subr_lock.c user/kmacy/releng_7_2_zfs/sys/kern/subr_pcpu.c user/kmacy/releng_7_2_zfs/sys/kern/subr_witness.c user/kmacy/releng_7_2_zfs/sys/kern/vfs_acl.c user/kmacy/releng_7_2_zfs/sys/kern/vfs_extattr.c user/kmacy/releng_7_2_zfs/sys/kern/vfs_lookup.c user/kmacy/releng_7_2_zfs/sys/kern/vfs_mount.c user/kmacy/releng_7_2_zfs/sys/kern/vfs_subr.c user/kmacy/releng_7_2_zfs/sys/modules/opensolaris/Makefile user/kmacy/releng_7_2_zfs/sys/modules/zfs/Makefile user/kmacy/releng_7_2_zfs/sys/security/mac/mac_syscalls.c user/kmacy/releng_7_2_zfs/sys/sys/_types.h user/kmacy/releng_7_2_zfs/sys/sys/conf.h user/kmacy/releng_7_2_zfs/sys/sys/fcntl.h user/kmacy/releng_7_2_zfs/sys/sys/jail.h user/kmacy/releng_7_2_zfs/sys/sys/kernel.h user/kmacy/releng_7_2_zfs/sys/sys/lock.h user/kmacy/releng_7_2_zfs/sys/sys/mount.h user/kmacy/releng_7_2_zfs/sys/sys/namei.h user/kmacy/releng_7_2_zfs/sys/sys/pcpu.h user/kmacy/releng_7_2_zfs/sys/sys/proc.h user/kmacy/releng_7_2_zfs/sys/sys/sysctl.h user/kmacy/releng_7_2_zfs/sys/sys/systm.h user/kmacy/releng_7_2_zfs/sys/sys/types.h user/kmacy/releng_7_2_zfs/sys/sys/vnode.h user/kmacy/releng_7_2_zfs/sys/ufs/ffs/ffs_snapshot.c user/kmacy/releng_7_2_zfs/sys/vm/vm_kern.h Added: user/kmacy/releng_7_2_zfs/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_zfs/sys/amd64/conf/GENERIC_MINUS Sun May 17 23:30:13 2009 (r192271) @@ -0,0 +1,322 @@ +# +# GENERIC -- Generic kernel configuration file for FreeBSD/amd64 +# +# For more information on this file, please read the handbook section on +# Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC 191034 2009-04-14 00:35:56Z jfv $ + +cpu HAMMER +ident GENERIC + +# To statically compile in device wiring instead of /boot/device.hints +#hints "GENERIC.hints" # Default places to look for devices. + +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +makeoptions MODULES_OVERRIDE="opensolaris zfs" + +options SCHED_ULE # ULE scheduler +options PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options SCTP # Stream Control Transmission Protocol +options FFS # Berkeley Fast Filesystem +options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options UFS_GJOURNAL # Enable gjournal-based UFS journaling +options MD_ROOT # MD is a potential root device +options NFSCLIENT # Network Filesystem Client +options NFSSERVER # Network Filesystem Server +options NFSLOCKD # Network Lock Manager +options NFS_ROOT # NFS usable as /, requires NFSCLIENT +options MSDOSFS # MSDOS Filesystem +options CD9660 # ISO 9660 Filesystem +options PROCFS # Process filesystem (requires PSEUDOFS) +options PSEUDOFS # Pseudo-filesystem framework +options GEOM_PART_GPT # GUID Partition Tables. +options GEOM_LABEL # Provides labelization +options COMPAT_43TTY # BSD 4.3 TTY compat [KEEP THIS!] +options COMPAT_IA32 # Compatible with i386 binaries +options COMPAT_FREEBSD4 # Compatible with FreeBSD4 +options COMPAT_FREEBSD5 # Compatible with FreeBSD5 +options COMPAT_FREEBSD6 # Compatible with FreeBSD6 +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +options KTRACE # ktrace(1) support +options STACK # stack(9) support +options SYSVSHM # SYSV-style shared memory +options SYSVMSG # SYSV-style message queues +options SYSVSEM # SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options KBD_INSTALL_CDEV # install a CDEV entry in /dev +options ADAPTIVE_GIANT # Giant mutex is adaptive. +options STOP_NMI # Stop CPUS using NMI instead of IPI +options AUDIT # Security event auditing +#options KDTRACE_FRAME # Ensure frames are compiled in +#options KDTRACE_HOOKS # Kernel DTrace hooks + + +options INVARIANTS +options INVARIANT_SUPPORT + +options WITNESS +options WITNESS_SKIPSPIN +options DEBUG +options KDB +options DDB +options ALT_BREAK_TO_DEBUGGER +options ADAPTIVE_SX + +# Make an SMP-capable kernel by default +options SMP # Symmetric MultiProcessor Kernel + +# CPU frequency control +device cpufreq + +# Bus support. +device acpi +device pci + +# Floppy drives +device fdc + +# ATA and ATAPI devices +device ata +device atadisk # ATA disk drives +device ataraid # ATA RAID drives +device atapicd # ATAPI CDROM drives +device atapifd # ATAPI floppy drives +device atapist # ATAPI tape drives +options ATA_STATIC_ID # Static device numbering + +# SCSI Controllers +device ahc # AHA2940 and onboard AIC7xxx devices +options AHC_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~128k to driver. +device ahd # AHA39320/29320 and onboard AIC79xx devices +options AHD_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~215k to driver. +device amd # AMD 53C974 (Tekram DC-390(T)) +device hptiop # Highpoint RocketRaid 3xxx series +device isp # Qlogic family +#device ispfw # Firmware for QLogic HBAs- normally a module +device mpt # LSI-Logic MPT-Fusion +#device ncr # NCR/Symbios Logic +device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') +device trm # Tekram DC395U/UW/F DC315U adapters + +device adv # Advansys SCSI adapters +device adw # Advansys wide SCSI adapters +device aic # Adaptec 15[012]x SCSI adapters, AIC-6[23]60. +device bt # Buslogic/Mylex MultiMaster SCSI adapters + + +# SCSI peripherals +device scbus # SCSI bus (required for SCSI) +device ch # SCSI media changers +device da # Direct Access (disks) +device sa # Sequential Access (tape etc) +device cd # CD +device pass # Passthrough device (direct SCSI access) +device ses # SCSI Environmental Services (and SAF-TE) + +# RAID controllers interfaced to the SCSI subsystem +device amr # AMI MegaRAID +device arcmsr # Areca SATA II RAID +device ciss # Compaq Smart RAID 5* +device dpt # DPT Smartcache III, IV - See NOTES for options +device hptmv # Highpoint RocketRAID 182x +device hptrr # Highpoint RocketRAID 17xx, 22xx, 23xx, 25xx +device iir # Intel Integrated RAID +device ips # IBM (Adaptec) ServeRAID +device mly # Mylex AcceleRAID/eXtremeRAID +device twa # 3ware 9000 series PATA/SATA RAID + +# RAID controllers +device aac # Adaptec FSA RAID +device aacp # SCSI passthrough for aac (requires CAM) +device ida # Compaq Smart RAID +device mfi # LSI MegaRAID SAS +device mlx # Mylex DAC960 family +#XXX pointer/int warnings +#device pst # Promise Supertrak SX6000 +device twe # 3ware ATA RAID + +# atkbdc0 controls both the keyboard and the PS/2 mouse +device atkbdc # AT keyboard controller +device atkbd # AT keyboard +device psm # PS/2 mouse + +device kbdmux # keyboard multiplexer + +device vga # VGA video card driver + +device splash # Splash screen and screen saver support + +# syscons is the default console driver, resembling an SCO console +device sc + +device agp # support several AGP chipsets + +# PCCARD (PCMCIA) support +# PCMCIA and cardbus bridge support +device cbb # cardbus (yenta) bridge +device pccard # PC Card (16-bit) bus +device cardbus # CardBus (32-bit) bus + +# Serial (COM) ports +device sio # 8250, 16[45]50 based serial ports +device uart # Generic UART driver + +# Parallel port +device ppc +device ppbus # Parallel port bus (required) +device lpt # Printer +device plip # TCP/IP over parallel +device ppi # Parallel port interface device +#device vpo # Requires scbus and da + +# If you've got a "dumb" serial or parallel PCI card that is +# supported by the puc(4) glue driver, uncomment the following +# line to enable it (connects to sio, uart and/or ppc drivers): +#device puc + +# PCI Ethernet NICs. +device de # DEC/Intel DC21x4x (``Tulip'') +device em # Intel PRO/1000 Gigabit Ethernet Family +device igb # Intel PRO/1000 PCIE Server Gigabit Family +device ixgbe # Intel PRO/10GbE PCIE Ethernet Family +device le # AMD Am7900 LANCE and Am79C9xx PCnet +device txp # 3Com 3cR990 (``Typhoon'') +device vx # 3Com 3c590, 3c595 (``Vortex'') + +# PCI Ethernet NICs that use the common MII bus controller code. +# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! +device miibus # MII bus support +device age # Attansic/Atheros L1 Gigabit Ethernet +device ale # Atheros AR8121/AR8113/AR8114 Ethernet +device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet +device bfe # Broadcom BCM440x 10/100 Ethernet +device bge # Broadcom BCM570xx Gigabit Ethernet +device dc # DEC/Intel 21143 and various workalikes +device et # Agere ET1310 10/100/Gigabit Ethernet +device fxp # Intel EtherExpress PRO/100B (82557, 82558) +device jme # JMicron JMC250 Gigabit/JMC260 Fast Ethernet +device lge # Level 1 LXT1001 gigabit Ethernet +device msk # Marvell/SysKonnect Yukon II Gigabit Ethernet +device nfe # nVidia nForce MCP on-board Ethernet +device nge # NatSemi DP83820 gigabit Ethernet +#device nve # nVidia nForce MCP on-board Ethernet Networking +device pcn # AMD Am79C97x PCI 10/100 (precedence over 'le') +device re # RealTek 8139C+/8169/8169S/8110S +device rl # RealTek 8129/8139 +device sf # Adaptec AIC-6915 (``Starfire'') +device sis # Silicon Integrated Systems SiS 900/SiS 7016 +device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet +device ste # Sundance ST201 (D-Link DFE-550TX) +device ti # Alteon Networks Tigon I/II gigabit Ethernet +device tl # Texas Instruments ThunderLAN +device tx # SMC EtherPower II (83c170 ``EPIC'') +device vge # VIA VT612x gigabit Ethernet +device vr # VIA Rhine, Rhine II +device wb # Winbond W89C840F +device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') + +# ISA Ethernet NICs. pccard NICs included. +device cs # Crystal Semiconductor CS89x0 NIC +# 'device ed' requires 'device miibus' +device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards +device ex # Intel EtherExpress Pro/10 and Pro/10+ +device ep # Etherlink III based cards +device fe # Fujitsu MB8696x based cards +device sn # SMC's 9000 series of Ethernet chips +device xe # Xircom pccard Ethernet + +# Wireless NIC cards +device wlan # 802.11 support +device wlan_wep # 802.11 WEP support +device wlan_ccmp # 802.11 CCMP support +device wlan_tkip # 802.11 TKIP support +device wlan_amrr # AMRR transmit rate control algorithm +device wlan_scan_ap # 802.11 AP mode scanning +device wlan_scan_sta # 802.11 STA mode scanning +device an # Aironet 4500/4800 802.11 wireless NICs. +device ath # Atheros pci/cardbus NIC's +device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors +device ath_rate_sample # SampleRate tx rate control for ath +device awi # BayStack 660 and others +device ral # Ralink Technology RT2500 wireless NICs. +device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. + +# Pseudo devices. +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device sl # Kernel SLIP +device ppp # Kernel PPP +device tun # Packet tunnel. +device pty # Pseudo-ttys (telnet etc) +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device faith # IPv6-to-IPv4 relaying (translation) +device firmware # firmware assist module + +# The `bpf' device enables the Berkeley Packet Filter. +# Be aware of the administrative consequences of enabling this! +# Note that 'bpf' is required for DHCP. +device bpf # Berkeley packet filter + +# USB support +device uhci # UHCI PCI->USB interface +device ohci # OHCI PCI->USB interface +device ehci # EHCI PCI->USB interface (USB 2.0) +device usb # USB Bus (required) +#device udbp # USB Double Bulk Pipe devices +device ugen # Generic +device uhid # "Human Interface Devices" +device ukbd # Keyboard +device ulpt # Printer +device umass # Disks/Mass storage - Requires scbus and da +device ums # Mouse +device ural # Ralink Technology RT2500USB wireless NICs +device urio # Diamond Rio 500 MP3 player +device uscanner # Scanners +# USB Serial devices +device ucom # Generic com ttys +device uark # Technologies ARK3116 based serial adapters +device ubsa # Belkin F5U103 and compatible serial adapters +device ubser # BWCT console serial adapters +device uftdi # For FTDI usb serial adapters +device uipaq # Some WinCE based devices +device uplcom # Prolific PL-2303 serial adapters +device uslcom # SI Labs CP2101/CP2102 serial adapters +device uvisor # Visor and Palm devices +device uvscom # USB serial support for DDI pocket's PHS +# USB Ethernet, requires miibus +device aue # ADMtek USB Ethernet +device axe # ASIX Electronics USB Ethernet +device cdce # Generic USB over Ethernet +device cue # CATC USB Ethernet +device kue # Kawasaki LSI USB Ethernet +device rue # RealTek RTL8150 USB Ethernet + +# FireWire support +device firewire # FireWire bus code +device sbp # SCSI over FireWire (Requires scbus and da) +device fwe # Ethernet over FireWire (non-standard!) +device fwip # IP over FireWire (RFC 2734,3146) +device dcons # Dumb console driver +device dcons_crom # Configuration ROM for dcons Modified: user/kmacy/releng_7_2_zfs/sys/amd64/include/vmparam.h ============================================================================== --- user/kmacy/releng_7_2_zfs/sys/amd64/include/vmparam.h Sun May 17 23:25:53 2009 (r192270) +++ user/kmacy/releng_7_2_zfs/sys/amd64/include/vmparam.h Sun May 17 23:30:13 2009 (r192271) @@ -154,8 +154,7 @@ * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot) * 0xffff804020101000 - 0xfffffeffffffffff unused * 0xffffff0000000000 - 0xffffff7fffffffff 512GB direct map mappings - * 0xffffff8000000000 - 0xfffffffe7fffffff unused (506GB) - * 0xfffffffe80000000 - 0xffffffffffffffff 6GB kernel map + * 0xffffff8000000000 - 0xffffffffffffffff 512GB kernel map * * Within the kernel map: * @@ -163,7 +162,7 @@ */ #define VM_MAX_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG-1, NPDEPG-1, NPTEPG-1) -#define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG-6, 0, 0) +#define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG-512, 0, 0) #define DMAP_MIN_ADDRESS KVADDR(DMPML4I, 0, 0, 0) #define DMAP_MAX_ADDRESS KVADDR(DMPML4I+1, 0, 0, 0) Added: user/kmacy/releng_7_2_zfs/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_zfs/sys/boot/i386/zfsboot/zfsboot.c Sun May 17 23:30:13 2009 (r192271) @@ -0,0 +1,1057 @@ +/*- + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#ifdef GPT +#include +#endif +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +#ifndef GPT +#include "zfsboot.h" +#endif +#include "lib.h" + +#define IO_KEYBOARD 1 +#define IO_SERIAL 2 + +#define SECOND 18 /* Circa that many ticks in a second. */ + +#define RBX_ASKNAME 0x0 /* -a */ +#define RBX_SINGLE 0x1 /* -s */ +/* 0x2 is reserved for log2(RB_NOSYNC). */ +/* 0x3 is reserved for log2(RB_HALT). */ +/* 0x4 is reserved for log2(RB_INITNAME). */ +#define RBX_DFLTROOT 0x5 /* -r */ +#define RBX_KDB 0x6 /* -d */ +/* 0x7 is reserved for log2(RB_RDONLY). */ +/* 0x8 is reserved for log2(RB_DUMP). */ +/* 0x9 is reserved for log2(RB_MINIROOT). */ +#define RBX_CONFIG 0xa /* -c */ +#define RBX_VERBOSE 0xb /* -v */ +#define RBX_SERIAL 0xc /* -h */ +#define RBX_CDROM 0xd /* -C */ +/* 0xe is reserved for log2(RB_POWEROFF). */ +#define RBX_GDB 0xf /* -g */ +#define RBX_MUTE 0x10 /* -m */ +/* 0x11 is reserved for log2(RB_SELFTEST). */ +/* 0x12 is reserved for boot programs. */ +/* 0x13 is reserved for boot programs. */ +#define RBX_PAUSE 0x14 /* -p */ +#define RBX_QUIET 0x15 /* -q */ +#define RBX_NOINTR 0x1c /* -n */ +/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */ +#define RBX_DUAL 0x1d /* -D */ +/* 0x1f is reserved for log2(RB_BOOTINFO). */ + +/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */ +#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \ + OPT_SET(RBX_DFLTROOT) | OPT_SET(RBX_KDB ) | \ + OPT_SET(RBX_CONFIG) | OPT_SET(RBX_VERBOSE) | \ + OPT_SET(RBX_SERIAL) | OPT_SET(RBX_CDROM) | \ + OPT_SET(RBX_GDB ) | OPT_SET(RBX_MUTE) | \ + OPT_SET(RBX_PAUSE) | OPT_SET(RBX_DUAL)) + +/* Hint to loader that we came from ZFS */ +#define KARGS_FLAGS_ZFS 0x4 + +#define PATH_CONFIG "/boot.config" +#define PATH_BOOT3 "/boot/loader" +#define PATH_KERNEL "/boot/kernel/kernel" + +#define ARGS 0x900 +#define NOPT 14 +#define NDEV 3 +#define MEM_BASE 0x12 +#define MEM_EXT 0x15 +#define V86_CY(x) ((x) & 1) +#define V86_ZR(x) ((x) & 0x40) + +#define DRV_HARD 0x80 +#define DRV_MASK 0x7f + +#define TYPE_AD 0 +#define TYPE_DA 1 +#define TYPE_MAXHARD TYPE_DA +#define TYPE_FD 2 + +#define OPT_SET(opt) (1 << (opt)) +#define OPT_CHECK(opt) ((opts) & OPT_SET(opt)) + +extern uint32_t _end; + +#ifdef GPT +static const uuid_t freebsd_zfs_uuid = GPT_ENT_TYPE_FREEBSD_ZFS; +#endif +static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ +static const unsigned char flags[NOPT] = { + RBX_DUAL, + RBX_SERIAL, + RBX_ASKNAME, + RBX_CDROM, + RBX_CONFIG, + RBX_KDB, + RBX_GDB, + RBX_MUTE, + RBX_NOINTR, + RBX_PAUSE, + RBX_QUIET, + RBX_DFLTROOT, + RBX_SINGLE, + RBX_VERBOSE +}; + +static const char *const dev_nm[NDEV] = {"ad", "da", "fd"}; +static const unsigned char dev_maj[NDEV] = {30, 4, 2}; + +struct dsk { + unsigned drive; + unsigned type; + unsigned unit; + unsigned slice; + unsigned part; + unsigned start; + int init; +}; +static char cmd[512]; +static char kname[1024]; +static uint32_t opts; +static int comspeed = SIOSPD; +static struct bootinfo bootinfo; +static uint32_t bootdev; +static uint8_t ioctrl = IO_KEYBOARD; + +/* Buffers that must not span a 64k boundary. */ +#define READ_BUF_SIZE 8192 +struct dmadat { + char rdbuf[READ_BUF_SIZE]; /* for reading large things */ + char secbuf[READ_BUF_SIZE]; /* for MBR/disklabel */ +}; +static struct dmadat *dmadat; + +void exit(int); +static void load(void); +static int parse(void); +static void printf(const char *,...); +static void putchar(int); +static uint32_t memsize(void); +static int drvread(struct dsk *, void *, unsigned, unsigned); +static int keyhit(unsigned); +static int xputc(int); +static int xgetc(int); +static int getc(int); + +static void memcpy(void *, const void *, int); +static void +memcpy(void *dst, const void *src, int len) +{ + const char *s = src; + char *d = dst; + + while (len--) + *d++ = *s++; +} + +static void +strcpy(char *dst, const char *src) +{ + while (*src) + *dst++ = *src++; + *dst++ = 0; +} + +static void +strcat(char *dst, const char *src) +{ + while (*dst) + dst++; + while (*src) + *dst++ = *src++; + *dst++ = 0; +} + +static int +strcmp(const char *s1, const char *s2) +{ + for (; *s1 == *s2 && *s1; s1++, s2++); + return (unsigned char)*s1 - (unsigned char)*s2; +} + +static const char * +strchr(const char *s, char ch) +{ + for (; *s; s++) + if (*s == ch) + return s; + return 0; +} + +static int +memcmp(const void *p1, const void *p2, size_t n) +{ + const char *s1 = (const char *) p1; + const char *s2 = (const char *) p2; + for (; n > 0 && *s1 == *s2; s1++, s2++, n--); + if (n) + return (unsigned char)*s1 - (unsigned char)*s2; + else + return 0; +} + +static void +memset(void *p, char val, size_t n) +{ + char *s = (char *) p; + while (n--) + *s++ = val; +} + +static void * +malloc(size_t n) +{ + static char *heap_next; + static char *heap_end; + + if (!heap_next) { + heap_next = (char *) dmadat + sizeof(*dmadat); + heap_end = (char *) (640*1024); + } + + char *p = heap_next; + if (p + n > heap_end) { + printf("malloc failure\n"); + for (;;) + ; + return 0; + } + heap_next += n; + return p; +} + +static size_t +strlen(const char *s) +{ + size_t len = 0; + while (*s++) + len++; + return len; +} + +static char * +strdup(const char *s) +{ + char *p = malloc(strlen(s) + 1); + strcpy(p, s); + return p; +} + +#include "zfsimpl.c" + +/* + * Read from a dnode (which must be from a ZPL filesystem). + */ +static int +zfs_read(spa_t *spa, const dnode_phys_t *dnode, off_t *offp, void *start, size_t size) +{ + const znode_phys_t *zp = (const znode_phys_t *) dnode->dn_bonus; + size_t n; + int rc; + + n = size; + if (*offp + n > zp->zp_size) + n = zp->zp_size - *offp; + + rc = dnode_read(spa, dnode, *offp, start, n); + if (rc) + return (-1); + *offp += n; + + return (n); +} + +/* + * Current ZFS pool + */ +spa_t *spa; + +/* + * A wrapper for dskread that doesn't have to worry about whether the + * buffer pointer crosses a 64k boundary. + */ +static int +vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) +{ + char *p; + unsigned int lba, nb; + struct dsk *dsk = (struct dsk *) priv; + + if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1))) + return -1; + + p = buf; + lba = off / DEV_BSIZE; + while (bytes > 0) { + nb = bytes / DEV_BSIZE; + if (nb > READ_BUF_SIZE / DEV_BSIZE) + nb = READ_BUF_SIZE / DEV_BSIZE; + if (drvread(dsk, dmadat->rdbuf, lba, nb)) + return -1; + memcpy(p, dmadat->rdbuf, nb * DEV_BSIZE); + p += nb * DEV_BSIZE; + lba += nb; + bytes -= nb * DEV_BSIZE; + } + + return 0; +} + +static int +xfsread(const dnode_phys_t *dnode, off_t *offp, void *buf, size_t nbyte) +{ + if ((size_t)zfs_read(spa, dnode, offp, buf, nbyte) != nbyte) { + printf("Invalid %s\n", "format"); + return -1; + } + return 0; +} + +static inline uint32_t +memsize(void) +{ + v86.addr = MEM_EXT; + v86.eax = 0x8800; + v86int(); + return v86.eax; +} + +static inline void +getstr(void) +{ + char *s; + int c; + + s = cmd; + for (;;) { + switch (c = xgetc(0)) { + case 0: + break; + case '\177': + case '\b': + if (s > cmd) { + s--; + printf("\b \b"); + } + break; + case '\n': + case '\r': + *s = 0; + return; + default: + if (s - cmd < sizeof(cmd) - 1) + *s++ = c; + putchar(c); + } + } +} + +static inline void +putc(int c) +{ + v86.addr = 0x10; + v86.eax = 0xe00 | (c & 0xff); + v86.ebx = 0x7; + v86int(); +} + +/* + * Try to detect a device supported by the legacy int13 BIOS + */ +static int +int13probe(int drive) +{ + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x800; + v86.edx = drive; + v86int(); + + if (!(v86.efl & 0x1) && /* carry clear */ + ((v86.edx & 0xff) != (drive & DRV_MASK))) { /* unit # OK */ + if ((v86.ecx & 0x3f) == 0) { /* absurd sector size */ + return(0); /* skip device */ + } + return (1); + } + return(0); +} + +/* + * We call this when we find a ZFS vdev - ZFS consumes the dsk + * structure so we must make a new one. + */ +static struct dsk * +copy_dsk(struct dsk *dsk) +{ + struct dsk *newdsk; + + newdsk = malloc(sizeof(struct dsk)); + *newdsk = *dsk; + return (newdsk); +} + +static void +probe_drive(struct dsk *dsk, spa_t **spap) +{ +#ifdef GPT + struct gpt_hdr hdr; + struct gpt_ent *ent; + daddr_t slba, elba; + unsigned part, entries_per_sec; +#endif + struct dos_partition *dp; + char *sec; + unsigned i; + + /* + * If we find a vdev on the whole disk, stop here. Otherwise dig + * out the MBR and probe each slice in turn for a vdev. + */ + if (vdev_probe(vdev_read, dsk, spap) == 0) + return; + + sec = dmadat->secbuf; + dsk->start = 0; + +#ifdef GPT + /* + * First check for GPT. + */ + if (drvread(dsk, sec, 1, 1)) { + return; + } + memcpy(&hdr, sec, sizeof(hdr)); + if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) != 0 || + hdr.hdr_lba_self != 1 || hdr.hdr_revision < 0x00010000 || + hdr.hdr_entsz < sizeof(*ent) || DEV_BSIZE % hdr.hdr_entsz != 0) { + goto trymbr; + } + + /* + * Probe all GPT partitions for the presense of ZFS pools. We + * return the spa_t for the first we find (if requested). This + * will have the effect of booting from the first pool on the + * disk. + */ + entries_per_sec = DEV_BSIZE / hdr.hdr_entsz; + slba = hdr.hdr_lba_table; + elba = slba + hdr.hdr_entries / entries_per_sec; + while (slba < elba) { + if (drvread(dsk, sec, slba, 1)) + return; + for (part = 0; part < entries_per_sec; part++) { + ent = (struct gpt_ent *)(sec + part * hdr.hdr_entsz); + if (memcmp(&ent->ent_type, &freebsd_zfs_uuid, + sizeof(uuid_t)) == 0) { + dsk->start = ent->ent_lba_start; + if (vdev_probe(vdev_read, dsk, spap) == 0) { + /* + * We record the first pool we find (we will try + * to boot from that one). + */ + spap = 0; + + /* + * This slice had a vdev. We need a new dsk + * structure now since the vdev now owns this one. + */ + dsk = copy_dsk(dsk); + } + break; + } + } + slba++; + } + return; +trymbr: +#endif + + if (drvread(dsk, sec, DOSBBSECTOR, 1)) + return; + dp = (void *)(sec + DOSPARTOFF); + + for (i = 0; i < NDOSPART; i++) { + if (!dp[i].dp_typ) + continue; + dsk->start = dp[i].dp_start; + if (vdev_probe(vdev_read, dsk, spap) == 0) { + /* + * We record the first pool we find (we will try to boot + * from that one. + */ + spap = 0; + + /* + * This slice had a vdev. We need a new dsk structure now + * since the vdev now owns this one. + */ + dsk = copy_dsk(dsk); + } + } +} + +int +main(void) +{ + int autoboot, i; + dnode_phys_t dn; + off_t off; + struct dsk *dsk; + + dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); + v86.ctl = V86_FLAGS; + + dsk = malloc(sizeof(struct dsk)); + dsk->drive = *(uint8_t *)PTOV(ARGS); + dsk->type = dsk->drive & DRV_HARD ? TYPE_AD : TYPE_FD; + dsk->unit = dsk->drive & DRV_MASK; + dsk->slice = *(uint8_t *)PTOV(ARGS + 1) + 1; + dsk->part = 0; + dsk->start = 0; + dsk->init = 0; + + bootinfo.bi_version = BOOTINFO_VERSION; + bootinfo.bi_size = sizeof(bootinfo); + bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */ + bootinfo.bi_extmem = memsize(); + bootinfo.bi_memsizes_valid++; + bootinfo.bi_bios_dev = dsk->drive; + + bootdev = MAKEBOOTDEV(dev_maj[dsk->type], + dsk->slice, dsk->unit, dsk->part), + + /* Process configuration file */ + + autoboot = 1; + + zfs_init(); + + /* + * Probe the boot drive first - we will try to boot from whatever + * pool we find on that drive. + */ + probe_drive(dsk, &spa); + + /* + * Probe the rest of the drives that the bios knows about. This + * will find any other available pools and it may fill in missing + * vdevs for the boot pool. + */ + for (i = 0; i < 128; i++) { + if ((i | DRV_HARD) == *(uint8_t *)PTOV(ARGS)) + continue; + + if (!int13probe(i | DRV_HARD)) + break; + + dsk = malloc(sizeof(struct dsk)); + dsk->drive = i | DRV_HARD; + dsk->type = dsk->drive & TYPE_AD; + dsk->unit = i; + dsk->slice = 0; + dsk->part = 0; + dsk->start = 0; + dsk->init = 0; + probe_drive(dsk, 0); + } + + /* + * If we didn't find a pool on the boot drive, default to the + * first pool we found, if any. + */ + if (!spa) { + spa = STAILQ_FIRST(&zfs_pools); + if (!spa) { + printf("No ZFS pools located, can't boot\n"); + for (;;) + ; + } + } + + zfs_mount_pool(spa); + + if (zfs_lookup(spa, PATH_CONFIG, &dn) == 0) { + off = 0; + xfsread(&dn, &off, cmd, sizeof(cmd)); + } + + if (*cmd) { + if (parse()) + autoboot = 0; + if (!OPT_CHECK(RBX_QUIET)) + printf("%s: %s", PATH_CONFIG, cmd); + /* Do not process this command twice */ + *cmd = 0; + } + + /* + * Try to exec stage 3 boot loader. If interrupted by a keypress, + * or in case of failure, try to load a kernel directly instead. + */ + + if (autoboot && !*kname) { + memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3)); + if (!keyhit(3*SECOND)) { + load(); + memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL)); + } + } + + /* Present the user with the boot2 prompt. */ + + for (;;) { + if (!autoboot || !OPT_CHECK(RBX_QUIET)) + printf("\nFreeBSD/i386 boot\n" + "Default: %s:%s\n" + "boot: ", + spa->spa_name, kname); + if (ioctrl & IO_SERIAL) + sio_flush(); + if (!autoboot || keyhit(5*SECOND)) + getstr(); + else if (!autoboot || !OPT_CHECK(RBX_QUIET)) + putchar('\n'); + autoboot = 0; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sun May 17 23:31:58 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 821641065672; Sun, 17 May 2009 23:31:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B47A8FC16; Sun, 17 May 2009 23:31:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HNVwVi042915; Sun, 17 May 2009 23:31:58 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNVwEo042905; Sun, 17 May 2009 23:31:58 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172331.n4HNVwEo042905@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 23:31:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192272 - in user/kmacy/releng_7_2_zfs/cddl: . compat/opensolaris/include compat/opensolaris/misc contrib/opensolaris/cmd/zdb contrib/opensolaris/cmd/zfs contrib/opensolaris/cmd/zinject... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 23:31:58 -0000 Author: kmacy Date: Sun May 17 23:31:57 2009 New Revision: 192272 URL: http://svn.freebsd.org/changeset/base/192272 Log: MFC user bits from v13 Added: user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/include/libshare.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zinject/ user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zinject/translate.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zinject/zinject.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zinject/zinject.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c user/kmacy/releng_7_2_zfs/cddl/usr.bin/zinject/ user/kmacy/releng_7_2_zfs/cddl/usr.bin/zinject/Makefile Modified: user/kmacy/releng_7_2_zfs/cddl/Makefile.inc user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/include/mnttab.h user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/deviceid.c user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/mnttab.c user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zmount.c user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zone.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.8 user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb_il.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zfs/zfs.8 user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zpool/zpool.8 user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zpool/zpool_util.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/ztest/ztest.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/head/assert.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/head/libintl.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/head/synch.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/head/thread.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libuutil/common/libuutil.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libuutil/common/libuutil_common.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libuutil/common/uu_alloc.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libuutil/common/uu_avl.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libuutil/common/uu_dprintf.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libuutil/common/uu_list.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_graph.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/lib/libzpool/common/util.c user/kmacy/releng_7_2_zfs/cddl/lib/Makefile user/kmacy/releng_7_2_zfs/cddl/lib/libnvpair/Makefile user/kmacy/releng_7_2_zfs/cddl/lib/libzfs/Makefile user/kmacy/releng_7_2_zfs/cddl/lib/libzpool/Makefile user/kmacy/releng_7_2_zfs/cddl/sbin/zpool/Makefile user/kmacy/releng_7_2_zfs/cddl/usr.bin/Makefile user/kmacy/releng_7_2_zfs/cddl/usr.bin/ztest/Makefile user/kmacy/releng_7_2_zfs/cddl/usr.sbin/Makefile user/kmacy/releng_7_2_zfs/cddl/usr.sbin/zdb/Makefile Modified: user/kmacy/releng_7_2_zfs/cddl/Makefile.inc ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/Makefile.inc Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/Makefile.inc Sun May 17 23:31:57 2009 (r192272) @@ -6,3 +6,5 @@ OPENSOLARIS_SYS_DISTDIR= ${.CURDIR}/../. IGNORE_PRAGMA= YES CFLAGS+= -DNEED_SOLARIS_BOOLEAN + +CSTD?= gnu89 Added: user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/include/libshare.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/include/libshare.h Sun May 17 23:31:57 2009 (r192272) @@ -0,0 +1,144 @@ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ Modified: user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/include/mnttab.h ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/include/mnttab.h Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/include/mnttab.h Sun May 17 23:31:57 2009 (r192272) @@ -9,6 +9,8 @@ #define MNTTAB _PATH_DEVNULL #define MNT_LINE_MAX 1024 +#define umount2(p, f) unmount(p, f) + struct mnttab { char *mnt_special; char *mnt_mountp; Modified: user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/deviceid.c ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/deviceid.c Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/deviceid.c Sun May 17 23:31:57 2009 (r192272) @@ -94,11 +94,7 @@ int devid_get(int fd, ddi_devid_t *retdevid) { - if (ioctl(fd, DIOCGIDENT, retdevid->devid) == -1) - return (errno); - if (retdevid->devid[0] == '\0') - return (ENOENT); - return (0); + return (ENOENT); } int Modified: user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/mnttab.c ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/mnttab.c Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/mnttab.c Sun May 17 23:31:57 2009 (r192272) @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include static char * mntopt(char **p) Modified: user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zmount.c ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zmount.c Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zmount.c Sun May 17 23:31:57 2009 (r192272) @@ -35,9 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include -#include +#include static void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, @@ -86,7 +87,7 @@ zmount(const char *spec, const char *dir assert(optlen > 0); optstr = strdup(optptr); - assert(optptr != NULL); + assert(optstr != NULL); iov = NULL; iovlen = 0; Modified: user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zone.c ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zone.c Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/compat/opensolaris/misc/zone.c Sun May 17 23:31:57 2009 (r192272) @@ -32,7 +32,7 @@ #include #include -int +zoneid_t getzoneid(void) { size_t size; @@ -42,5 +42,5 @@ getzoneid(void) size = sizeof(jailid); if (sysctlbyname("security.jail.jailed", &jailid, &size, NULL, 0) == -1) assert(!"No security.jail.jailed sysctl!"); - return (jailid); + return ((zoneid_t)jailid); } Modified: user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.8 ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Sun May 17 23:31:57 2009 (r192272) @@ -28,13 +28,18 @@ zdb \- ZFS debugger .fi .SH DESCRIPTION +.sp .LP The \fBzdb\fR command is used by support engineers to diagnose failures and gather statistics. Since the \fBZFS\fR file system is always consistent on disk and is self-repairing, \fBzdb\fR should only be run under the direction by a support engineer. +.sp .LP If no arguments are specified, \fBzdb\fR, performs basic consistency checks on the pool and associated datasets, and report any problems detected. +.sp .LP Any options supported by this command are internal to Sun and subject to change at any time. .SH EXIT STATUS + +.sp .LP The following exit values are returned: .sp @@ -71,6 +76,9 @@ Invalid command line options were specif .RE .SH ATTRIBUTES + +.sp + .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -89,5 +97,6 @@ Interface StabilityUnstable .TE .SH SEE ALSO +.sp .LP \fBzfs\fR(1M), \fBzpool\fR(1M), \fBattributes\fR(5) Modified: user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.c Sun May 17 23:30:13 2009 (r192271) +++ user/kmacy/releng_7_2_zfs/cddl/contrib/opensolaris/cmd/zdb/zdb.c Sun May 17 23:31:57 2009 (r192272) @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -51,6 +49,10 @@ #include #include #include +#include +#undef ZFS_MAXNAMELEN +#undef verify +#include const char cmdname[] = "zdb"; uint8_t dump_opt[256]; @@ -62,6 +64,9 @@ uint64_t *zopt_object = NULL; int zopt_objects = 0; int zdb_advance = ADVANCE_PRE; zbookmark_t zdb_noread = { 0, 0, ZB_NO_LEVEL, 0 }; +libzfs_handle_t *g_zfs; +boolean_t zdb_sig_user_data = B_TRUE; +int zdb_sig_cksumalg = ZIO_CHECKSUM_SHA256; /* * These libumem hooks provide a reasonable set of defaults for the allocator's @@ -83,12 +88,15 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-udibcsvLU] [-O order] [-B os:obj:level:blkid] " + "Usage: %s [-udibcsvL] [-U cachefile_path] [-O order] " + "[-B os:obj:level:blkid] [-S user:cksumalg] " "dataset [object...]\n" " %s -C [pool]\n" " %s -l dev\n" - " %s -R vdev:offset:size:flags\n", - cmdname, cmdname, cmdname, cmdname); + " %s -R pool:vdev:offset:size:flags\n" + " %s [-p path_to_vdev_dir]\n" + " %s -e pool | GUID | devid ...\n", + cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); (void) fprintf(stderr, " -u uberblock\n"); (void) fprintf(stderr, " -d datasets\n"); @@ -97,16 +105,22 @@ usage(void) (void) fprintf(stderr, " -b block statistics\n"); (void) fprintf(stderr, " -c checksum all data blocks\n"); (void) fprintf(stderr, " -s report stats on zdb's I/O\n"); + (void) fprintf(stderr, " -S : -- " + "dump blkptr signatures\n"); (void) fprintf(stderr, " -v verbose (applies to all others)\n"); (void) fprintf(stderr, " -l dump label contents\n"); (void) fprintf(stderr, " -L live pool (allows some errors)\n"); (void) fprintf(stderr, " -O [!] " "visitation order\n"); - (void) fprintf(stderr, " -U use zpool.cache in /tmp\n"); + (void) fprintf(stderr, " -U cachefile_path -- use alternate " + "cachefile\n"); (void) fprintf(stderr, " -B objset:object:level:blkid -- " "simulate bad block\n"); - (void) fprintf(stderr, " -R read and display block from a" + (void) fprintf(stderr, " -R read and display block from a " "device\n"); + (void) fprintf(stderr, " -e Pool is exported/destroyed/" + "has altroot\n"); + (void) fprintf(stderr, " -p (use with -e)\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); @@ -367,6 +381,44 @@ dump_zap(objset_t *os, uint64_t object, zap_cursor_fini(&zc); } +/*ARGSUSED*/ +static void +dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size) +{ + zap_cursor_t zc; + zap_attribute_t attr; + const char *typenames[] = { + /* 0 */ "not specified", + /* 1 */ "FIFO", + /* 2 */ "Character Device", + /* 3 */ "3 (invalid)", + /* 4 */ "Directory", + /* 5 */ "5 (invalid)", + /* 6 */ "Block Device", + /* 7 */ "7 (invalid)", + /* 8 */ "Regular File", + /* 9 */ "9 (invalid)", + /* 10 */ "Symbolic Link", + /* 11 */ "11 (invalid)", + /* 12 */ "Socket", + /* 13 */ "Door", + /* 14 */ "Event Port", + /* 15 */ "15 (invalid)", + }; + + dump_zap_stats(os, object); + (void) printf("\n"); + + for (zap_cursor_init(&zc, os, object); + zap_cursor_retrieve(&zc, &attr) == 0; + zap_cursor_advance(&zc)) { + (void) printf("\t\t%s = %lld (type: %s)\n", + attr.za_name, ZFS_DIRENT_OBJ(attr.za_first_integer), + typenames[ZFS_DIRENT_TYPE(attr.za_first_integer)]); + } + zap_cursor_fini(&zc); +} + static void dump_spacemap(objset_t *os, space_map_obj_t *smo, space_map_t *sm) { @@ -456,10 +508,7 @@ dump_metaslabs(spa_t *spa) for (c = 0; c < rvd->vdev_children; c++) { vd = rvd->vdev_child[c]; - spa_config_enter(spa, RW_READER, FTAG); - (void) printf("\n vdev %llu = %s\n\n", - (u_longlong_t)vd->vdev_id, vdev_description(vd)); - spa_config_exit(spa, FTAG); + (void) printf("\n vdev %llu\n\n", (u_longlong_t)vd->vdev_id); if (dump_opt['d'] <= 5) { (void) printf("\t%10s %10s %5s\n", @@ -477,7 +526,6 @@ static void dump_dtl(vdev_t *vd, int indent) { avl_tree_t *t = &vd->vdev_dtl_map.sm_root; - spa_t *spa = vd->vdev_spa; space_seg_t *ss; vdev_t *pvd; int c; @@ -485,9 +533,10 @@ dump_dtl(vdev_t *vd, int indent) if (indent == 0) (void) printf("\nDirty time logs:\n\n"); - spa_config_enter(spa, RW_READER, FTAG); - (void) printf("\t%*s%s\n", indent, "", vdev_description(vd)); - spa_config_exit(spa, FTAG); + (void) printf("\t%*s%s\n", indent, "", + vd->vdev_path ? vd->vdev_path : + vd->vdev_parent ? vd->vdev_ops->vdev_op_type : + spa_name(vd->vdev_spa)); for (ss = avl_first(t); ss; ss = AVL_NEXT(t, ss)) { /* @@ -670,36 +719,49 @@ dump_dsl_dir(objset_t *os, uint64_t obje { dsl_dir_phys_t *dd = data; time_t crtime; - char used[6], compressed[6], uncompressed[6], quota[6], resv[6]; + char nice[6]; if (dd == NULL) return; - ASSERT(size == sizeof (*dd)); + ASSERT3U(size, >=, sizeof (dsl_dir_phys_t)); crtime = dd->dd_creation_time; - nicenum(dd->dd_used_bytes, used); - nicenum(dd->dd_compressed_bytes, compressed); - nicenum(dd->dd_uncompressed_bytes, uncompressed); - nicenum(dd->dd_quota, quota); - nicenum(dd->dd_reserved, resv); - (void) printf("\t\tcreation_time = %s", ctime(&crtime)); (void) printf("\t\thead_dataset_obj = %llu\n", (u_longlong_t)dd->dd_head_dataset_obj); (void) printf("\t\tparent_dir_obj = %llu\n", (u_longlong_t)dd->dd_parent_obj); - (void) printf("\t\tclone_parent_obj = %llu\n", - (u_longlong_t)dd->dd_clone_parent_obj); + (void) printf("\t\torigin_obj = %llu\n", + (u_longlong_t)dd->dd_origin_obj); (void) printf("\t\tchild_dir_zapobj = %llu\n", (u_longlong_t)dd->dd_child_dir_zapobj); - (void) printf("\t\tused_bytes = %s\n", used); - (void) printf("\t\tcompressed_bytes = %s\n", compressed); - (void) printf("\t\tuncompressed_bytes = %s\n", uncompressed); - (void) printf("\t\tquota = %s\n", quota); - (void) printf("\t\treserved = %s\n", resv); + nicenum(dd->dd_used_bytes, nice); + (void) printf("\t\tused_bytes = %s\n", nice); + nicenum(dd->dd_compressed_bytes, nice); + (void) printf("\t\tcompressed_bytes = %s\n", nice); + nicenum(dd->dd_uncompressed_bytes, nice); + (void) printf("\t\tuncompressed_bytes = %s\n", nice); + nicenum(dd->dd_quota, nice); + (void) printf("\t\tquota = %s\n", nice); + nicenum(dd->dd_reserved, nice); + (void) printf("\t\treserved = %s\n", nice); (void) printf("\t\tprops_zapobj = %llu\n", (u_longlong_t)dd->dd_props_zapobj); + (void) printf("\t\tdeleg_zapobj = %llu\n", + (u_longlong_t)dd->dd_deleg_zapobj); + (void) printf("\t\tflags = %llx\n", + (u_longlong_t)dd->dd_flags); + +#define DO(which) \ + nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \ + (void) printf("\t\tused_breakdown[" #which "] = %s\n", nice) + DO(HEAD); + DO(SNAP); + DO(CHILD); + DO(CHILD_RSRV); + DO(REFRSRV); +#undef DO } /*ARGSUSED*/ @@ -722,7 +784,7 @@ dump_dsl_dataset(objset_t *os, uint64_t nicenum(ds->ds_unique_bytes, unique); sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, &ds->ds_bp); - (void) printf("\t\tdataset_obj = %llu\n", + (void) printf("\t\tdir_obj = %llu\n", (u_longlong_t)ds->ds_dir_obj); (void) printf("\t\tprev_snap_obj = %llu\n", (u_longlong_t)ds->ds_prev_snap_obj); @@ -749,6 +811,10 @@ dump_dsl_dataset(objset_t *os, uint64_t (u_longlong_t)ds->ds_guid); (void) printf("\t\tflags = %llx\n", (u_longlong_t)ds->ds_flags); + (void) printf("\t\tnext_clones_obj = %llu\n", + (u_longlong_t)ds->ds_next_clones_obj); + (void) printf("\t\tprops_obj = %llu\n", + (u_longlong_t)ds->ds_props_obj); (void) printf("\t\tbp = %s\n", blkbuf); } @@ -765,9 +831,11 @@ dump_bplist(objset_t *mos, uint64_t obje if (dump_opt['d'] < 3) return; + mutex_init(&bpl.bpl_lock, NULL, MUTEX_DEFAULT, NULL); VERIFY(0 == bplist_open(&bpl, mos, object)); if (bplist_empty(&bpl)) { bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); return; } @@ -785,6 +853,7 @@ dump_bplist(objset_t *mos, uint64_t obje if (dump_opt['d'] < 5) { bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); return; } @@ -800,6 +869,65 @@ dump_bplist(objset_t *mos, uint64_t obje } bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); +} + +static avl_tree_t idx_tree; +static avl_tree_t domain_tree; +static boolean_t fuid_table_loaded; + +static void +fuid_table_destroy() +{ + if (fuid_table_loaded) { + zfs_fuid_table_destroy(&idx_tree, &domain_tree); + fuid_table_loaded = B_FALSE; + } +} + +/* + * print uid or gid information. + * For normal POSIX id just the id is printed in decimal format. + * For CIFS files with FUID the fuid is printed in hex followed by + * the doman-rid string. + */ +static void +print_idstr(uint64_t id, const char *id_type) +{ + if (FUID_INDEX(id)) { + char *domain; + + domain = zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id)); + (void) printf("\t%s %llx [%s-%d]\n", id_type, + (u_longlong_t)id, domain, (int)FUID_RID(id)); + } else { + (void) printf("\t%s %llu\n", id_type, (u_longlong_t)id); + } + +} + +static void +dump_uidgid(objset_t *os, znode_phys_t *zp) +{ + uint32_t uid_idx, gid_idx; + + uid_idx = FUID_INDEX(zp->zp_uid); + gid_idx = FUID_INDEX(zp->zp_gid); + + /* Load domain table, if not already loaded */ + if (!fuid_table_loaded && (uid_idx || gid_idx)) { + uint64_t fuid_obj; + + /* first find the fuid object. It lives in the master node */ + VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES, + 8, 1, &fuid_obj) == 0); + (void) zfs_fuid_table_load(os, fuid_obj, + &idx_tree, &domain_tree); + fuid_table_loaded = B_TRUE; + } + + print_idstr(zp->zp_uid, "uid"); + print_idstr(zp->zp_gid, "gid"); } /*ARGSUSED*/ @@ -830,6 +958,7 @@ dump_znode(objset_t *os, uint64_t object z_ctime = (time_t)zp->zp_ctime[0]; (void) printf("\tpath %s\n", path); + dump_uidgid(os, zp); (void) printf("\tatime %s", ctime(&z_atime)); (void) printf("\tmtime %s", ctime(&z_mtime)); (void) printf("\tctime %s", ctime(&z_ctime)); @@ -874,9 +1003,9 @@ static object_viewer_t *object_viewer[DM dump_zap, /* DSL props */ dump_dsl_dataset, /* DSL dataset */ dump_znode, /* ZFS znode */ - dump_acl, /* ZFS ACL */ + dump_acl, /* ZFS V0 ACL */ dump_uint8, /* ZFS plain file */ - dump_zap, /* ZFS directory */ + dump_zpldir, /* ZFS directory */ dump_zap, /* ZFS master node */ dump_zap, /* ZFS delete queue */ dump_uint8, /* zvol object */ @@ -888,6 +1017,13 @@ static object_viewer_t *object_viewer[DM dump_uint8, /* SPA history */ dump_uint64, /* SPA history offsets */ dump_zap, /* Pool properties */ + dump_zap, /* DSL permissions */ + dump_acl, /* ZFS ACL */ + dump_uint8, /* ZFS SYSACL */ + dump_none, /* FUID nvlist */ + dump_packed_nvlist, /* FUID nvlist size */ + dump_zap, /* DSL dataset next clones */ + dump_zap, /* DSL scrub queue */ }; static void @@ -930,13 +1066,15 @@ dump_object(objset_t *os, uint64_t objec aux[0] = '\0'; - if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) + if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) { (void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)", zio_checksum_table[doi.doi_checksum].ci_name); + } - if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) + if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) { (void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)", zio_compress_table[doi.doi_compress].ci_name); + } (void) printf("%10lld %3u %5s %5s %5s %5s %s%s\n", (u_longlong_t)object, doi.doi_indirection, iblk, dblk, lsize, @@ -972,13 +1110,13 @@ dump_object(objset_t *os, uint64_t objec } for (;;) { - error = dnode_next_offset(dn, B_FALSE, &start, minlvl, - blkfill, 0); + error = dnode_next_offset(dn, + 0, &start, minlvl, blkfill, 0); if (error) break; end = start; - error = dnode_next_offset(dn, B_TRUE, &end, minlvl, - blkfill, 0); + error = dnode_next_offset(dn, + DNODE_FIND_HOLE, &end, minlvl, blkfill, 0); nicenum(end - start, segsize); (void) printf("\t\tsegment [%016llx, %016llx)" " size %5s\n", (u_longlong_t)start, @@ -996,7 +1134,6 @@ dump_object(objset_t *os, uint64_t objec static char *objset_types[DMU_OST_NUMTYPES] = { "NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" }; -/*ARGSUSED*/ static void dump_dir(objset_t *os) { @@ -1019,8 +1156,8 @@ dump_dir(objset_t *os) if (dds.dds_type == DMU_OST_META) { dds.dds_creation_txg = TXG_INITIAL; usedobjs = os->os->os_rootbp->blk_fill; - refdbytes = - os->os->os_spa->spa_dsl_pool->dp_mos_dir->dd_used_bytes; + refdbytes = os->os->os_spa->spa_dsl_pool-> + dp_mos_dir->dd_phys->dd_used_bytes; } else { dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch); } @@ -1054,6 +1191,9 @@ dump_dir(objset_t *os) if (verbosity < 2) return; + if (os->os->os_rootbp->blk_birth == 0) + return; + if (zopt_objects != 0) { for (i = 0; i < zopt_objects; i++) dump_object(os, zopt_object[i], verbosity, @@ -1115,6 +1255,52 @@ dump_config(const char *pool) } static void +dump_cachefile(const char *cachefile) +{ + int fd; + struct stat64 statbuf; + char *buf; + nvlist_t *config; + + if ((fd = open64(cachefile, O_RDONLY)) < 0) { + (void) printf("cannot open '%s': %s\n", cachefile, + strerror(errno)); + exit(1); + } + + if (fstat64(fd, &statbuf) != 0) { + (void) printf("failed to stat '%s': %s\n", cachefile, + strerror(errno)); + exit(1); + } + + if ((buf = malloc(statbuf.st_size)) == NULL) { + (void) fprintf(stderr, "failed to allocate %llu bytes\n", + (u_longlong_t)statbuf.st_size); + exit(1); + } + + if (read(fd, buf, statbuf.st_size) != statbuf.st_size) { + (void) fprintf(stderr, "failed to read %llu bytes\n", + (u_longlong_t)statbuf.st_size); + exit(1); + } + + (void) close(fd); + + if (nvlist_unpack(buf, statbuf.st_size, &config, 0) != 0) { + (void) fprintf(stderr, "failed to unpack nvlist\n"); + exit(1); + } + + free(buf); + + dump_nvlist(config, 0); + + nvlist_free(config); +} + +static void dump_label(const char *dev) { int fd; @@ -1178,170 +1364,84 @@ dump_one_dir(char *dsname, void *arg) objset_t *os; error = dmu_objset_open(dsname, DMU_OST_ANY, - DS_MODE_STANDARD | DS_MODE_READONLY, &os); + DS_MODE_USER | DS_MODE_READONLY, &os); if (error) { (void) printf("Could not open %s\n", dsname); return (0); } dump_dir(os); dmu_objset_close(os); + fuid_table_destroy(); return (0); } static void -zdb_space_map_load(spa_t *spa) +zdb_leak(space_map_t *sm, uint64_t start, uint64_t size) { - vdev_t *rvd = spa->spa_root_vdev; - vdev_t *vd; - int c, m, error; + vdev_t *vd = sm->sm_ppd; - for (c = 0; c < rvd->vdev_children; c++) { - vd = rvd->vdev_child[c]; - for (m = 0; m < vd->vdev_ms_count; m++) { - metaslab_t *msp = vd->vdev_ms[m]; - mutex_enter(&msp->ms_lock); - error = space_map_load(&msp->ms_allocmap[0], NULL, - SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset); - mutex_exit(&msp->ms_lock); - if (error) - fatal("%s bad space map #%d, error %d", - spa->spa_name, c, error); - } - } + (void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n", + (u_longlong_t)vd->vdev_id, (u_longlong_t)start, (u_longlong_t)size); } -static int -zdb_space_map_claim(spa_t *spa, blkptr_t *bp, zbookmark_t *zb) +/* ARGSUSED */ +static void +zdb_space_map_load(space_map_t *sm) { - dva_t *dva = bp->blk_dva; - vdev_t *vd; - metaslab_t *msp; - space_map_t *allocmap, *freemap; - int error; - int d; - blkptr_t blk = *bp; - - for (d = 0; d < BP_GET_NDVAS(bp); d++) { - uint64_t vdev = DVA_GET_VDEV(&dva[d]); - uint64_t offset = DVA_GET_OFFSET(&dva[d]); - uint64_t size = DVA_GET_ASIZE(&dva[d]); - - if ((vd = vdev_lookup_top(spa, vdev)) == NULL) - return (ENXIO); - - if ((offset >> vd->vdev_ms_shift) >= vd->vdev_ms_count) - return (ENXIO); - - msp = vd->vdev_ms[offset >> vd->vdev_ms_shift]; - allocmap = &msp->ms_allocmap[0]; - freemap = &msp->ms_freemap[0]; - - /* Prepare our copy of the bp in case we need to read GBHs */ - if (DVA_GET_GANG(&dva[d])) { - size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); - DVA_SET_ASIZE(&blk.blk_dva[d], size); - DVA_SET_GANG(&blk.blk_dva[d], 0); - } - - mutex_enter(&msp->ms_lock); - if (space_map_contains(freemap, offset, size)) { - mutex_exit(&msp->ms_lock); - return (EAGAIN); /* allocated more than once */ - } - - if (!space_map_contains(allocmap, offset, size)) { - mutex_exit(&msp->ms_lock); - return (ESTALE); /* not allocated at all */ - } - - space_map_remove(allocmap, offset, size); - space_map_add(freemap, offset, size); - - mutex_exit(&msp->ms_lock); - } - - if (BP_IS_GANG(bp)) { - zio_gbh_phys_t gbh; - int g; - - /* LINTED - compile time assert */ - ASSERT(sizeof (zio_gbh_phys_t) == SPA_GANGBLOCKSIZE); - - BP_SET_CHECKSUM(&blk, ZIO_CHECKSUM_GANG_HEADER); - BP_SET_PSIZE(&blk, SPA_GANGBLOCKSIZE); - BP_SET_LSIZE(&blk, SPA_GANGBLOCKSIZE); - BP_SET_COMPRESS(&blk, ZIO_COMPRESS_OFF); - error = zio_wait(zio_read(NULL, spa, &blk, &gbh, - SPA_GANGBLOCKSIZE, NULL, NULL, ZIO_PRIORITY_SYNC_READ, - ZIO_FLAG_CANFAIL | ZIO_FLAG_CONFIG_HELD, zb)); - if (error) - return (error); - if (BP_SHOULD_BYTESWAP(&blk)) - byteswap_uint64_array(&gbh, SPA_GANGBLOCKSIZE); - for (g = 0; g < SPA_GBH_NBLKPTRS; g++) { - if (BP_IS_HOLE(&gbh.zg_blkptr[g])) - break; - error = zdb_space_map_claim(spa, &gbh.zg_blkptr[g], zb); - if (error) - return (error); - } - } - - return (0); } static void -zdb_leak(space_map_t *sm, uint64_t start, uint64_t size) +zdb_space_map_unload(space_map_t *sm) { - metaslab_t *msp; - - /* LINTED */ - msp = (metaslab_t *)((char *)sm - offsetof(metaslab_t, ms_allocmap[0])); + space_map_vacate(sm, zdb_leak, sm); +} - (void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n", - (u_longlong_t)msp->ms_group->mg_vd->vdev_id, - (u_longlong_t)start, - (u_longlong_t)size); +/* ARGSUSED */ +static void +zdb_space_map_claim(space_map_t *sm, uint64_t start, uint64_t size) +{ } +static space_map_ops_t zdb_space_map_ops = { + zdb_space_map_load, + zdb_space_map_unload, + NULL, /* alloc */ + zdb_space_map_claim, + NULL /* free */ +}; + static void -zdb_space_map_unload(spa_t *spa) +zdb_leak_init(spa_t *spa) { vdev_t *rvd = spa->spa_root_vdev; - vdev_t *vd; - int c, m; - for (c = 0; c < rvd->vdev_children; c++) { - vd = rvd->vdev_child[c]; - for (m = 0; m < vd->vdev_ms_count; m++) { + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *vd = rvd->vdev_child[c]; + for (int m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); - space_map_vacate(&msp->ms_allocmap[0], zdb_leak, - &msp->ms_allocmap[0]); - space_map_unload(&msp->ms_allocmap[0]); - space_map_vacate(&msp->ms_freemap[0], NULL, NULL); + VERIFY(space_map_load(&msp->ms_map, &zdb_space_map_ops, + SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset) == 0); + msp->ms_map.sm_ppd = vd; mutex_exit(&msp->ms_lock); } } } static void -zdb_refresh_ubsync(spa_t *spa) +zdb_leak_fini(spa_t *spa) { - uberblock_t ub = { 0 }; vdev_t *rvd = spa->spa_root_vdev; - zio_t *zio; - - /* - * Reload the uberblock. - */ - zio = zio_root(spa, NULL, NULL, - ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE); - vdev_uberblock_load(zio, rvd, &ub); - (void) zio_wait(zio); - if (ub.ub_txg != 0) - spa->spa_ubsync = ub; + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *vd = rvd->vdev_child[c]; + for (int m = 0; m < vd->vdev_ms_count; m++) { + metaslab_t *msp = vd->vdev_ms[m]; + mutex_enter(&msp->ms_lock); + space_map_unload(&msp->ms_map); + mutex_exit(&msp->ms_lock); + } + } } /* @@ -1371,9 +1471,7 @@ typedef struct zdb_cb { static void zdb_count_block(spa_t *spa, zdb_cb_t *zcb, blkptr_t *bp, int type) { - int i, error; - - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL; int t = (i & 1) ? type : DMU_OT_TOTAL; zdb_blkstats_t *zb = &zcb->zcb_type[l][t]; @@ -1384,21 +1482,34 @@ zdb_count_block(spa_t *spa, zdb_cb_t *zc zb->zb_count++; } - if (dump_opt['L']) - return; + if (dump_opt['S']) { + boolean_t print_sig; - error = zdb_space_map_claim(spa, bp, &zcb->zcb_cache->bc_bookmark); - - if (error == 0) - return; + print_sig = !zdb_sig_user_data || (BP_GET_LEVEL(bp) == 0 && + BP_GET_TYPE(bp) == DMU_OT_PLAIN_FILE_CONTENTS); - if (error == EAGAIN) - (void) fatal("double-allocation, bp=%p", bp); + if (BP_GET_CHECKSUM(bp) < zdb_sig_cksumalg) + print_sig = B_FALSE; - if (error == ESTALE) - (void) fatal("reference to freed block, bp=%p", bp); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sun May 17 23:32:24 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1BA81065710; Sun, 17 May 2009 23:32:24 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B3A418FC1C; Sun, 17 May 2009 23:32:24 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HNWOEe042957; Sun, 17 May 2009 23:32:24 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNWOph042956; Sun, 17 May 2009 23:32:24 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172332.n4HNWOph042956@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 23:32:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192273 - user/kmacy/releng_7_2_zfs/usr.sbin/bsnmpd/modules/snmp_hostres X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 23:32:25 -0000 Author: kmacy Date: Sun May 17 23:32:24 2009 New Revision: 192273 URL: http://svn.freebsd.org/changeset/base/192273 Log: add zfs oid Modified: user/kmacy/releng_7_2_zfs/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Modified: user/kmacy/releng_7_2_zfs/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c ============================================================================== --- user/kmacy/releng_7_2_zfs/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Sun May 17 23:31:57 2009 (r192272) +++ user/kmacy/releng_7_2_zfs/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Sun May 17 23:32:24 2009 (r192273) @@ -131,6 +131,7 @@ static const struct { const struct asn_oid *oid; /* the OID to return */ } fs_type_map[] = { { "ufs", &OIDX_hrFSBerkeleyFFS_c }, + { "zfs", &OIDX_hrFSOther_c }, { "cd9660", &OIDX_hrFSiso9660_c }, { "nfs", &OIDX_hrFSNFS_c }, { "ext2fs", &OIDX_hrFSLinuxExt2_c }, From owner-svn-src-user@FreeBSD.ORG Sun May 17 23:42:39 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A628F106564A; Sun, 17 May 2009 23:42:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8F5998FC14; Sun, 17 May 2009 23:42:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HNgd6v043229; Sun, 17 May 2009 23:42:39 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNgdwj043219; Sun, 17 May 2009 23:42:39 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172342.n4HNgdwj043219@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 23:42:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192275 - in user/kmacy/releng_7_2_fast_net: cddl cddl/compat/opensolaris/include cddl/compat/opensolaris/misc cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zfs cddl/con... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 23:42:39 -0000 Author: kmacy Date: Sun May 17 23:42:38 2009 New Revision: 192275 URL: http://svn.freebsd.org/changeset/base/192275 Log: MFC updated ZFS Added: user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/include/libshare.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zinject/ user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zinject/translate.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zinject/zinject.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zinject/zinject.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c user/kmacy/releng_7_2_fast_net/cddl/usr.bin/zinject/ user/kmacy/releng_7_2_fast_net/cddl/usr.bin/zinject/Makefile user/kmacy/releng_7_2_fast_net/sys/amd64/conf/GENERIC_MINUS user/kmacy/releng_7_2_fast_net/sys/boot/i386/zfsboot/ user/kmacy/releng_7_2_fast_net/sys/boot/i386/zfsboot/zfsboot.c user/kmacy/releng_7_2_fast_net/sys/boot/zfs/ user/kmacy/releng_7_2_fast_net/sys/boot/zfs/zfsimpl.c user/kmacy/releng_7_2_fast_net/sys/cddl/boot/ user/kmacy/releng_7_2_fast_net/sys/cddl/boot/zfs/ user/kmacy/releng_7_2_fast_net/sys/cddl/boot/zfs/README user/kmacy/releng_7_2_fast_net/sys/cddl/boot/zfs/fletcher.c user/kmacy/releng_7_2_fast_net/sys/cddl/boot/zfs/lzjb.c user/kmacy/releng_7_2_fast_net/sys/cddl/boot/zfs/sha256.c user/kmacy/releng_7_2_fast_net/sys/cddl/boot/zfs/zfsimpl.h user/kmacy/releng_7_2_fast_net/sys/cddl/boot/zfs/zfssubr.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/file.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/kidmap.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/pathname.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/refstr.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/sid.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/sig.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/unicode/ user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/unicode/u8_textprep.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_comutil.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_comutil.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zprop_common.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg2.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scrub.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scrub2.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_deleg.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/rrwlock.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_boot.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_fuid.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid2.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_array.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_mem.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/acl_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/extdirent.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/idmap.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/ user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep_data.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_osd.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_rmlock.c user/kmacy/releng_7_2_fast_net/sys/libkern/memmove.c user/kmacy/releng_7_2_fast_net/sys/sys/_rmlock.h user/kmacy/releng_7_2_fast_net/sys/sys/osd.h user/kmacy/releng_7_2_fast_net/sys/sys/rmlock.h Deleted: user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/acl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/amd64/atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/i386/atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/ia64/atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/atomic/sparc64/atomic.S user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr_array.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr_mem.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/vfs.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/zmod/crc32.c Modified: user/kmacy/releng_7_2_fast_net/cddl/Makefile.inc user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/include/mnttab.h user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/deviceid.c user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/mnttab.c user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zmount.c user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zone.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.8 user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb_il.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zfs/zfs.8 user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zpool/zpool.8 user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zpool/zpool_util.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/ztest/ztest.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/head/assert.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/head/libintl.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/head/synch.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/head/thread.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libuutil/common/libuutil.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libuutil/common/libuutil_common.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libuutil/common/uu_alloc.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libuutil/common/uu_avl.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libuutil/common/uu_dprintf.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libuutil/common/uu_list.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_graph.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/lib/libzpool/common/util.c user/kmacy/releng_7_2_fast_net/cddl/lib/Makefile user/kmacy/releng_7_2_fast_net/cddl/lib/libnvpair/Makefile user/kmacy/releng_7_2_fast_net/cddl/lib/libzfs/Makefile user/kmacy/releng_7_2_fast_net/cddl/lib/libzpool/Makefile user/kmacy/releng_7_2_fast_net/cddl/sbin/zpool/Makefile user/kmacy/releng_7_2_fast_net/cddl/usr.bin/Makefile user/kmacy/releng_7_2_fast_net/cddl/usr.bin/ztest/Makefile user/kmacy/releng_7_2_fast_net/cddl/usr.sbin/Makefile user/kmacy/releng_7_2_fast_net/cddl/usr.sbin/zdb/Makefile user/kmacy/releng_7_2_fast_net/sys/amd64/include/vmparam.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/rpc/xdr.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/atomic.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/cpuvar.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/cred.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/dnlc.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/kmem.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/lock.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/misc.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/mntent.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/mutex.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/param.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/policy.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/proc.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/rwlock.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/sunddi.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/sysmacros.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/time.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/types.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/uio.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/vfs.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/vnode.h user/kmacy/releng_7_2_fast_net/sys/cddl/compat/opensolaris/sys/zone.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/acl/acl_common.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/acl/acl_common.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/avl/avl.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/Makefile.files user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bplist.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/bplist.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_traverse.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_pool.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_prop.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_synctask.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/txg.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/txg_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/uberblock_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/unique.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_disk.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_leaf.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_acl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_dir.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/unique.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_byteswap.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/os/callb.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/os/list.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/os/taskq.c user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/avl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/byteorder.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/callb.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/cpuvar.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/cred.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/dkio.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/dklabel.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/fm/fs/zfs.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/fm/protocol.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/fm/util.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/gfs.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/list.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/nvpair.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/processor.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/synch.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h user/kmacy/releng_7_2_fast_net/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.c user/kmacy/releng_7_2_fast_net/sys/compat/linprocfs/linprocfs.c user/kmacy/releng_7_2_fast_net/sys/compat/pecoff/imgact_pecoff.c user/kmacy/releng_7_2_fast_net/sys/conf/files user/kmacy/releng_7_2_fast_net/sys/fs/coda/coda_vfsops.c user/kmacy/releng_7_2_fast_net/sys/fs/msdosfs/msdosfs_vfsops.c user/kmacy/releng_7_2_fast_net/sys/fs/nullfs/null_vfsops.c user/kmacy/releng_7_2_fast_net/sys/fs/unionfs/union_vfsops.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_environment.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_fork.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_jail.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_kse.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_malloc.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_proc.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_thr.c user/kmacy/releng_7_2_fast_net/sys/kern/kern_thread.c user/kmacy/releng_7_2_fast_net/sys/kern/subr_lock.c user/kmacy/releng_7_2_fast_net/sys/kern/subr_pcpu.c user/kmacy/releng_7_2_fast_net/sys/kern/subr_witness.c user/kmacy/releng_7_2_fast_net/sys/kern/vfs_acl.c user/kmacy/releng_7_2_fast_net/sys/kern/vfs_extattr.c user/kmacy/releng_7_2_fast_net/sys/kern/vfs_lookup.c user/kmacy/releng_7_2_fast_net/sys/kern/vfs_mount.c user/kmacy/releng_7_2_fast_net/sys/kern/vfs_subr.c user/kmacy/releng_7_2_fast_net/sys/modules/opensolaris/Makefile user/kmacy/releng_7_2_fast_net/sys/modules/zfs/Makefile user/kmacy/releng_7_2_fast_net/sys/security/mac/mac_syscalls.c user/kmacy/releng_7_2_fast_net/sys/sys/_types.h user/kmacy/releng_7_2_fast_net/sys/sys/conf.h user/kmacy/releng_7_2_fast_net/sys/sys/fcntl.h user/kmacy/releng_7_2_fast_net/sys/sys/jail.h user/kmacy/releng_7_2_fast_net/sys/sys/kernel.h user/kmacy/releng_7_2_fast_net/sys/sys/lock.h user/kmacy/releng_7_2_fast_net/sys/sys/mount.h user/kmacy/releng_7_2_fast_net/sys/sys/namei.h user/kmacy/releng_7_2_fast_net/sys/sys/pcpu.h user/kmacy/releng_7_2_fast_net/sys/sys/proc.h user/kmacy/releng_7_2_fast_net/sys/sys/sysctl.h user/kmacy/releng_7_2_fast_net/sys/sys/systm.h user/kmacy/releng_7_2_fast_net/sys/sys/types.h user/kmacy/releng_7_2_fast_net/sys/sys/vnode.h user/kmacy/releng_7_2_fast_net/sys/ufs/ffs/ffs_snapshot.c user/kmacy/releng_7_2_fast_net/sys/vm/vm_kern.h user/kmacy/releng_7_2_fast_net/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Modified: user/kmacy/releng_7_2_fast_net/cddl/Makefile.inc ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/Makefile.inc Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/Makefile.inc Sun May 17 23:42:38 2009 (r192275) @@ -6,3 +6,5 @@ OPENSOLARIS_SYS_DISTDIR= ${.CURDIR}/../. IGNORE_PRAGMA= YES CFLAGS+= -DNEED_SOLARIS_BOOLEAN + +CSTD?= gnu89 Added: user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/include/libshare.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/include/libshare.h Sun May 17 23:42:38 2009 (r192275) @@ -0,0 +1,144 @@ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ Modified: user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/include/mnttab.h ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/include/mnttab.h Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/include/mnttab.h Sun May 17 23:42:38 2009 (r192275) @@ -9,6 +9,8 @@ #define MNTTAB _PATH_DEVNULL #define MNT_LINE_MAX 1024 +#define umount2(p, f) unmount(p, f) + struct mnttab { char *mnt_special; char *mnt_mountp; Modified: user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/deviceid.c ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/deviceid.c Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/deviceid.c Sun May 17 23:42:38 2009 (r192275) @@ -94,11 +94,7 @@ int devid_get(int fd, ddi_devid_t *retdevid) { - if (ioctl(fd, DIOCGIDENT, retdevid->devid) == -1) - return (errno); - if (retdevid->devid[0] == '\0') - return (ENOENT); - return (0); + return (ENOENT); } int Modified: user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/mnttab.c ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/mnttab.c Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/mnttab.c Sun May 17 23:42:38 2009 (r192275) @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include static char * mntopt(char **p) Modified: user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zmount.c ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zmount.c Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zmount.c Sun May 17 23:42:38 2009 (r192275) @@ -35,9 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include -#include +#include static void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, @@ -86,7 +87,7 @@ zmount(const char *spec, const char *dir assert(optlen > 0); optstr = strdup(optptr); - assert(optptr != NULL); + assert(optstr != NULL); iov = NULL; iovlen = 0; Modified: user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zone.c ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zone.c Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/compat/opensolaris/misc/zone.c Sun May 17 23:42:38 2009 (r192275) @@ -32,7 +32,7 @@ #include #include -int +zoneid_t getzoneid(void) { size_t size; @@ -42,5 +42,5 @@ getzoneid(void) size = sizeof(jailid); if (sysctlbyname("security.jail.jailed", &jailid, &size, NULL, 0) == -1) assert(!"No security.jail.jailed sysctl!"); - return (jailid); + return ((zoneid_t)jailid); } Modified: user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.8 ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Sun May 17 23:42:38 2009 (r192275) @@ -28,13 +28,18 @@ zdb \- ZFS debugger .fi .SH DESCRIPTION +.sp .LP The \fBzdb\fR command is used by support engineers to diagnose failures and gather statistics. Since the \fBZFS\fR file system is always consistent on disk and is self-repairing, \fBzdb\fR should only be run under the direction by a support engineer. +.sp .LP If no arguments are specified, \fBzdb\fR, performs basic consistency checks on the pool and associated datasets, and report any problems detected. +.sp .LP Any options supported by this command are internal to Sun and subject to change at any time. .SH EXIT STATUS + +.sp .LP The following exit values are returned: .sp @@ -71,6 +76,9 @@ Invalid command line options were specif .RE .SH ATTRIBUTES + +.sp + .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -89,5 +97,6 @@ Interface StabilityUnstable .TE .SH SEE ALSO +.sp .LP \fBzfs\fR(1M), \fBzpool\fR(1M), \fBattributes\fR(5) Modified: user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.c Sun May 17 23:40:59 2009 (r192274) +++ user/kmacy/releng_7_2_fast_net/cddl/contrib/opensolaris/cmd/zdb/zdb.c Sun May 17 23:42:38 2009 (r192275) @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -51,6 +49,10 @@ #include #include #include +#include +#undef ZFS_MAXNAMELEN +#undef verify +#include const char cmdname[] = "zdb"; uint8_t dump_opt[256]; @@ -62,6 +64,9 @@ uint64_t *zopt_object = NULL; int zopt_objects = 0; int zdb_advance = ADVANCE_PRE; zbookmark_t zdb_noread = { 0, 0, ZB_NO_LEVEL, 0 }; +libzfs_handle_t *g_zfs; +boolean_t zdb_sig_user_data = B_TRUE; +int zdb_sig_cksumalg = ZIO_CHECKSUM_SHA256; /* * These libumem hooks provide a reasonable set of defaults for the allocator's @@ -83,12 +88,15 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-udibcsvLU] [-O order] [-B os:obj:level:blkid] " + "Usage: %s [-udibcsvL] [-U cachefile_path] [-O order] " + "[-B os:obj:level:blkid] [-S user:cksumalg] " "dataset [object...]\n" " %s -C [pool]\n" " %s -l dev\n" - " %s -R vdev:offset:size:flags\n", - cmdname, cmdname, cmdname, cmdname); + " %s -R pool:vdev:offset:size:flags\n" + " %s [-p path_to_vdev_dir]\n" + " %s -e pool | GUID | devid ...\n", + cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); (void) fprintf(stderr, " -u uberblock\n"); (void) fprintf(stderr, " -d datasets\n"); @@ -97,16 +105,22 @@ usage(void) (void) fprintf(stderr, " -b block statistics\n"); (void) fprintf(stderr, " -c checksum all data blocks\n"); (void) fprintf(stderr, " -s report stats on zdb's I/O\n"); + (void) fprintf(stderr, " -S : -- " + "dump blkptr signatures\n"); (void) fprintf(stderr, " -v verbose (applies to all others)\n"); (void) fprintf(stderr, " -l dump label contents\n"); (void) fprintf(stderr, " -L live pool (allows some errors)\n"); (void) fprintf(stderr, " -O [!] " "visitation order\n"); - (void) fprintf(stderr, " -U use zpool.cache in /tmp\n"); + (void) fprintf(stderr, " -U cachefile_path -- use alternate " + "cachefile\n"); (void) fprintf(stderr, " -B objset:object:level:blkid -- " "simulate bad block\n"); - (void) fprintf(stderr, " -R read and display block from a" + (void) fprintf(stderr, " -R read and display block from a " "device\n"); + (void) fprintf(stderr, " -e Pool is exported/destroyed/" + "has altroot\n"); + (void) fprintf(stderr, " -p (use with -e)\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); @@ -367,6 +381,44 @@ dump_zap(objset_t *os, uint64_t object, zap_cursor_fini(&zc); } +/*ARGSUSED*/ +static void +dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size) +{ + zap_cursor_t zc; + zap_attribute_t attr; + const char *typenames[] = { + /* 0 */ "not specified", + /* 1 */ "FIFO", + /* 2 */ "Character Device", + /* 3 */ "3 (invalid)", + /* 4 */ "Directory", + /* 5 */ "5 (invalid)", + /* 6 */ "Block Device", + /* 7 */ "7 (invalid)", + /* 8 */ "Regular File", + /* 9 */ "9 (invalid)", + /* 10 */ "Symbolic Link", + /* 11 */ "11 (invalid)", + /* 12 */ "Socket", + /* 13 */ "Door", + /* 14 */ "Event Port", + /* 15 */ "15 (invalid)", + }; + + dump_zap_stats(os, object); + (void) printf("\n"); + + for (zap_cursor_init(&zc, os, object); + zap_cursor_retrieve(&zc, &attr) == 0; + zap_cursor_advance(&zc)) { + (void) printf("\t\t%s = %lld (type: %s)\n", + attr.za_name, ZFS_DIRENT_OBJ(attr.za_first_integer), + typenames[ZFS_DIRENT_TYPE(attr.za_first_integer)]); + } + zap_cursor_fini(&zc); +} + static void dump_spacemap(objset_t *os, space_map_obj_t *smo, space_map_t *sm) { @@ -456,10 +508,7 @@ dump_metaslabs(spa_t *spa) for (c = 0; c < rvd->vdev_children; c++) { vd = rvd->vdev_child[c]; - spa_config_enter(spa, RW_READER, FTAG); - (void) printf("\n vdev %llu = %s\n\n", - (u_longlong_t)vd->vdev_id, vdev_description(vd)); - spa_config_exit(spa, FTAG); + (void) printf("\n vdev %llu\n\n", (u_longlong_t)vd->vdev_id); if (dump_opt['d'] <= 5) { (void) printf("\t%10s %10s %5s\n", @@ -477,7 +526,6 @@ static void dump_dtl(vdev_t *vd, int indent) { avl_tree_t *t = &vd->vdev_dtl_map.sm_root; - spa_t *spa = vd->vdev_spa; space_seg_t *ss; vdev_t *pvd; int c; @@ -485,9 +533,10 @@ dump_dtl(vdev_t *vd, int indent) if (indent == 0) (void) printf("\nDirty time logs:\n\n"); - spa_config_enter(spa, RW_READER, FTAG); - (void) printf("\t%*s%s\n", indent, "", vdev_description(vd)); - spa_config_exit(spa, FTAG); + (void) printf("\t%*s%s\n", indent, "", + vd->vdev_path ? vd->vdev_path : + vd->vdev_parent ? vd->vdev_ops->vdev_op_type : + spa_name(vd->vdev_spa)); for (ss = avl_first(t); ss; ss = AVL_NEXT(t, ss)) { /* @@ -670,36 +719,49 @@ dump_dsl_dir(objset_t *os, uint64_t obje { dsl_dir_phys_t *dd = data; time_t crtime; - char used[6], compressed[6], uncompressed[6], quota[6], resv[6]; + char nice[6]; if (dd == NULL) return; - ASSERT(size == sizeof (*dd)); + ASSERT3U(size, >=, sizeof (dsl_dir_phys_t)); crtime = dd->dd_creation_time; - nicenum(dd->dd_used_bytes, used); - nicenum(dd->dd_compressed_bytes, compressed); - nicenum(dd->dd_uncompressed_bytes, uncompressed); - nicenum(dd->dd_quota, quota); - nicenum(dd->dd_reserved, resv); - (void) printf("\t\tcreation_time = %s", ctime(&crtime)); (void) printf("\t\thead_dataset_obj = %llu\n", (u_longlong_t)dd->dd_head_dataset_obj); (void) printf("\t\tparent_dir_obj = %llu\n", (u_longlong_t)dd->dd_parent_obj); - (void) printf("\t\tclone_parent_obj = %llu\n", - (u_longlong_t)dd->dd_clone_parent_obj); + (void) printf("\t\torigin_obj = %llu\n", + (u_longlong_t)dd->dd_origin_obj); (void) printf("\t\tchild_dir_zapobj = %llu\n", (u_longlong_t)dd->dd_child_dir_zapobj); - (void) printf("\t\tused_bytes = %s\n", used); - (void) printf("\t\tcompressed_bytes = %s\n", compressed); - (void) printf("\t\tuncompressed_bytes = %s\n", uncompressed); - (void) printf("\t\tquota = %s\n", quota); - (void) printf("\t\treserved = %s\n", resv); + nicenum(dd->dd_used_bytes, nice); + (void) printf("\t\tused_bytes = %s\n", nice); + nicenum(dd->dd_compressed_bytes, nice); + (void) printf("\t\tcompressed_bytes = %s\n", nice); + nicenum(dd->dd_uncompressed_bytes, nice); + (void) printf("\t\tuncompressed_bytes = %s\n", nice); + nicenum(dd->dd_quota, nice); + (void) printf("\t\tquota = %s\n", nice); + nicenum(dd->dd_reserved, nice); + (void) printf("\t\treserved = %s\n", nice); (void) printf("\t\tprops_zapobj = %llu\n", (u_longlong_t)dd->dd_props_zapobj); + (void) printf("\t\tdeleg_zapobj = %llu\n", + (u_longlong_t)dd->dd_deleg_zapobj); + (void) printf("\t\tflags = %llx\n", + (u_longlong_t)dd->dd_flags); + +#define DO(which) \ + nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \ + (void) printf("\t\tused_breakdown[" #which "] = %s\n", nice) + DO(HEAD); + DO(SNAP); + DO(CHILD); + DO(CHILD_RSRV); + DO(REFRSRV); +#undef DO } /*ARGSUSED*/ @@ -722,7 +784,7 @@ dump_dsl_dataset(objset_t *os, uint64_t nicenum(ds->ds_unique_bytes, unique); sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, &ds->ds_bp); - (void) printf("\t\tdataset_obj = %llu\n", + (void) printf("\t\tdir_obj = %llu\n", (u_longlong_t)ds->ds_dir_obj); (void) printf("\t\tprev_snap_obj = %llu\n", (u_longlong_t)ds->ds_prev_snap_obj); @@ -749,6 +811,10 @@ dump_dsl_dataset(objset_t *os, uint64_t (u_longlong_t)ds->ds_guid); (void) printf("\t\tflags = %llx\n", (u_longlong_t)ds->ds_flags); + (void) printf("\t\tnext_clones_obj = %llu\n", + (u_longlong_t)ds->ds_next_clones_obj); + (void) printf("\t\tprops_obj = %llu\n", + (u_longlong_t)ds->ds_props_obj); (void) printf("\t\tbp = %s\n", blkbuf); } @@ -765,9 +831,11 @@ dump_bplist(objset_t *mos, uint64_t obje if (dump_opt['d'] < 3) return; + mutex_init(&bpl.bpl_lock, NULL, MUTEX_DEFAULT, NULL); VERIFY(0 == bplist_open(&bpl, mos, object)); if (bplist_empty(&bpl)) { bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); return; } @@ -785,6 +853,7 @@ dump_bplist(objset_t *mos, uint64_t obje if (dump_opt['d'] < 5) { bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); return; } @@ -800,6 +869,65 @@ dump_bplist(objset_t *mos, uint64_t obje } bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); +} + +static avl_tree_t idx_tree; +static avl_tree_t domain_tree; +static boolean_t fuid_table_loaded; + +static void +fuid_table_destroy() +{ + if (fuid_table_loaded) { + zfs_fuid_table_destroy(&idx_tree, &domain_tree); + fuid_table_loaded = B_FALSE; + } +} + +/* + * print uid or gid information. + * For normal POSIX id just the id is printed in decimal format. + * For CIFS files with FUID the fuid is printed in hex followed by + * the doman-rid string. + */ +static void +print_idstr(uint64_t id, const char *id_type) +{ + if (FUID_INDEX(id)) { + char *domain; + + domain = zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id)); + (void) printf("\t%s %llx [%s-%d]\n", id_type, + (u_longlong_t)id, domain, (int)FUID_RID(id)); + } else { + (void) printf("\t%s %llu\n", id_type, (u_longlong_t)id); + } + +} + +static void +dump_uidgid(objset_t *os, znode_phys_t *zp) +{ + uint32_t uid_idx, gid_idx; + + uid_idx = FUID_INDEX(zp->zp_uid); + gid_idx = FUID_INDEX(zp->zp_gid); + + /* Load domain table, if not already loaded */ + if (!fuid_table_loaded && (uid_idx || gid_idx)) { + uint64_t fuid_obj; + + /* first find the fuid object. It lives in the master node */ + VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES, + 8, 1, &fuid_obj) == 0); + (void) zfs_fuid_table_load(os, fuid_obj, + &idx_tree, &domain_tree); + fuid_table_loaded = B_TRUE; + } + + print_idstr(zp->zp_uid, "uid"); + print_idstr(zp->zp_gid, "gid"); } /*ARGSUSED*/ @@ -830,6 +958,7 @@ dump_znode(objset_t *os, uint64_t object z_ctime = (time_t)zp->zp_ctime[0]; (void) printf("\tpath %s\n", path); + dump_uidgid(os, zp); (void) printf("\tatime %s", ctime(&z_atime)); (void) printf("\tmtime %s", ctime(&z_mtime)); (void) printf("\tctime %s", ctime(&z_ctime)); @@ -874,9 +1003,9 @@ static object_viewer_t *object_viewer[DM dump_zap, /* DSL props */ dump_dsl_dataset, /* DSL dataset */ dump_znode, /* ZFS znode */ - dump_acl, /* ZFS ACL */ + dump_acl, /* ZFS V0 ACL */ dump_uint8, /* ZFS plain file */ - dump_zap, /* ZFS directory */ + dump_zpldir, /* ZFS directory */ dump_zap, /* ZFS master node */ dump_zap, /* ZFS delete queue */ dump_uint8, /* zvol object */ @@ -888,6 +1017,13 @@ static object_viewer_t *object_viewer[DM dump_uint8, /* SPA history */ dump_uint64, /* SPA history offsets */ dump_zap, /* Pool properties */ + dump_zap, /* DSL permissions */ + dump_acl, /* ZFS ACL */ + dump_uint8, /* ZFS SYSACL */ + dump_none, /* FUID nvlist */ + dump_packed_nvlist, /* FUID nvlist size */ + dump_zap, /* DSL dataset next clones */ + dump_zap, /* DSL scrub queue */ }; static void @@ -930,13 +1066,15 @@ dump_object(objset_t *os, uint64_t objec aux[0] = '\0'; - if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) + if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) { (void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)", zio_checksum_table[doi.doi_checksum].ci_name); + } - if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) + if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) { (void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)", zio_compress_table[doi.doi_compress].ci_name); + } (void) printf("%10lld %3u %5s %5s %5s %5s %s%s\n", (u_longlong_t)object, doi.doi_indirection, iblk, dblk, lsize, @@ -972,13 +1110,13 @@ dump_object(objset_t *os, uint64_t objec } for (;;) { - error = dnode_next_offset(dn, B_FALSE, &start, minlvl, - blkfill, 0); + error = dnode_next_offset(dn, + 0, &start, minlvl, blkfill, 0); if (error) break; end = start; - error = dnode_next_offset(dn, B_TRUE, &end, minlvl, - blkfill, 0); + error = dnode_next_offset(dn, + DNODE_FIND_HOLE, &end, minlvl, blkfill, 0); nicenum(end - start, segsize); (void) printf("\t\tsegment [%016llx, %016llx)" " size %5s\n", (u_longlong_t)start, @@ -996,7 +1134,6 @@ dump_object(objset_t *os, uint64_t objec static char *objset_types[DMU_OST_NUMTYPES] = { "NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" }; -/*ARGSUSED*/ static void dump_dir(objset_t *os) { @@ -1019,8 +1156,8 @@ dump_dir(objset_t *os) if (dds.dds_type == DMU_OST_META) { dds.dds_creation_txg = TXG_INITIAL; usedobjs = os->os->os_rootbp->blk_fill; - refdbytes = - os->os->os_spa->spa_dsl_pool->dp_mos_dir->dd_used_bytes; + refdbytes = os->os->os_spa->spa_dsl_pool-> + dp_mos_dir->dd_phys->dd_used_bytes; } else { dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch); } @@ -1054,6 +1191,9 @@ dump_dir(objset_t *os) if (verbosity < 2) return; + if (os->os->os_rootbp->blk_birth == 0) + return; + if (zopt_objects != 0) { for (i = 0; i < zopt_objects; i++) dump_object(os, zopt_object[i], verbosity, @@ -1115,6 +1255,52 @@ dump_config(const char *pool) } static void +dump_cachefile(const char *cachefile) +{ + int fd; + struct stat64 statbuf; + char *buf; + nvlist_t *config; + + if ((fd = open64(cachefile, O_RDONLY)) < 0) { + (void) printf("cannot open '%s': %s\n", cachefile, + strerror(errno)); + exit(1); + } + + if (fstat64(fd, &statbuf) != 0) { + (void) printf("failed to stat '%s': %s\n", cachefile, + strerror(errno)); + exit(1); + } + + if ((buf = malloc(statbuf.st_size)) == NULL) { + (void) fprintf(stderr, "failed to allocate %llu bytes\n", + (u_longlong_t)statbuf.st_size); + exit(1); + } + + if (read(fd, buf, statbuf.st_size) != statbuf.st_size) { + (void) fprintf(stderr, "failed to read %llu bytes\n", + (u_longlong_t)statbuf.st_size); + exit(1); + } + + (void) close(fd); + + if (nvlist_unpack(buf, statbuf.st_size, &config, 0) != 0) { + (void) fprintf(stderr, "failed to unpack nvlist\n"); + exit(1); + } + + free(buf); + + dump_nvlist(config, 0); + + nvlist_free(config); +} + +static void dump_label(const char *dev) { int fd; @@ -1178,170 +1364,84 @@ dump_one_dir(char *dsname, void *arg) objset_t *os; error = dmu_objset_open(dsname, DMU_OST_ANY, - DS_MODE_STANDARD | DS_MODE_READONLY, &os); + DS_MODE_USER | DS_MODE_READONLY, &os); if (error) { (void) printf("Could not open %s\n", dsname); return (0); } dump_dir(os); dmu_objset_close(os); + fuid_table_destroy(); return (0); } static void -zdb_space_map_load(spa_t *spa) +zdb_leak(space_map_t *sm, uint64_t start, uint64_t size) { - vdev_t *rvd = spa->spa_root_vdev; - vdev_t *vd; - int c, m, error; + vdev_t *vd = sm->sm_ppd; - for (c = 0; c < rvd->vdev_children; c++) { - vd = rvd->vdev_child[c]; - for (m = 0; m < vd->vdev_ms_count; m++) { - metaslab_t *msp = vd->vdev_ms[m]; - mutex_enter(&msp->ms_lock); - error = space_map_load(&msp->ms_allocmap[0], NULL, - SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset); - mutex_exit(&msp->ms_lock); - if (error) - fatal("%s bad space map #%d, error %d", - spa->spa_name, c, error); - } - } + (void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n", + (u_longlong_t)vd->vdev_id, (u_longlong_t)start, (u_longlong_t)size); } -static int -zdb_space_map_claim(spa_t *spa, blkptr_t *bp, zbookmark_t *zb) +/* ARGSUSED */ +static void +zdb_space_map_load(space_map_t *sm) { - dva_t *dva = bp->blk_dva; - vdev_t *vd; - metaslab_t *msp; - space_map_t *allocmap, *freemap; - int error; - int d; - blkptr_t blk = *bp; - - for (d = 0; d < BP_GET_NDVAS(bp); d++) { - uint64_t vdev = DVA_GET_VDEV(&dva[d]); - uint64_t offset = DVA_GET_OFFSET(&dva[d]); - uint64_t size = DVA_GET_ASIZE(&dva[d]); - - if ((vd = vdev_lookup_top(spa, vdev)) == NULL) - return (ENXIO); - - if ((offset >> vd->vdev_ms_shift) >= vd->vdev_ms_count) - return (ENXIO); - - msp = vd->vdev_ms[offset >> vd->vdev_ms_shift]; - allocmap = &msp->ms_allocmap[0]; - freemap = &msp->ms_freemap[0]; - - /* Prepare our copy of the bp in case we need to read GBHs */ - if (DVA_GET_GANG(&dva[d])) { - size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); - DVA_SET_ASIZE(&blk.blk_dva[d], size); - DVA_SET_GANG(&blk.blk_dva[d], 0); - } - - mutex_enter(&msp->ms_lock); - if (space_map_contains(freemap, offset, size)) { - mutex_exit(&msp->ms_lock); - return (EAGAIN); /* allocated more than once */ - } - - if (!space_map_contains(allocmap, offset, size)) { - mutex_exit(&msp->ms_lock); - return (ESTALE); /* not allocated at all */ - } - - space_map_remove(allocmap, offset, size); - space_map_add(freemap, offset, size); - - mutex_exit(&msp->ms_lock); - } - - if (BP_IS_GANG(bp)) { - zio_gbh_phys_t gbh; - int g; - - /* LINTED - compile time assert */ - ASSERT(sizeof (zio_gbh_phys_t) == SPA_GANGBLOCKSIZE); - - BP_SET_CHECKSUM(&blk, ZIO_CHECKSUM_GANG_HEADER); - BP_SET_PSIZE(&blk, SPA_GANGBLOCKSIZE); - BP_SET_LSIZE(&blk, SPA_GANGBLOCKSIZE); - BP_SET_COMPRESS(&blk, ZIO_COMPRESS_OFF); - error = zio_wait(zio_read(NULL, spa, &blk, &gbh, - SPA_GANGBLOCKSIZE, NULL, NULL, ZIO_PRIORITY_SYNC_READ, - ZIO_FLAG_CANFAIL | ZIO_FLAG_CONFIG_HELD, zb)); - if (error) - return (error); - if (BP_SHOULD_BYTESWAP(&blk)) - byteswap_uint64_array(&gbh, SPA_GANGBLOCKSIZE); - for (g = 0; g < SPA_GBH_NBLKPTRS; g++) { - if (BP_IS_HOLE(&gbh.zg_blkptr[g])) - break; - error = zdb_space_map_claim(spa, &gbh.zg_blkptr[g], zb); - if (error) - return (error); - } - } - - return (0); } static void -zdb_leak(space_map_t *sm, uint64_t start, uint64_t size) +zdb_space_map_unload(space_map_t *sm) { - metaslab_t *msp; - - /* LINTED */ - msp = (metaslab_t *)((char *)sm - offsetof(metaslab_t, ms_allocmap[0])); + space_map_vacate(sm, zdb_leak, sm); +} - (void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n", - (u_longlong_t)msp->ms_group->mg_vd->vdev_id, - (u_longlong_t)start, - (u_longlong_t)size); +/* ARGSUSED */ +static void +zdb_space_map_claim(space_map_t *sm, uint64_t start, uint64_t size) +{ } +static space_map_ops_t zdb_space_map_ops = { + zdb_space_map_load, + zdb_space_map_unload, + NULL, /* alloc */ + zdb_space_map_claim, + NULL /* free */ +}; + static void -zdb_space_map_unload(spa_t *spa) +zdb_leak_init(spa_t *spa) { vdev_t *rvd = spa->spa_root_vdev; - vdev_t *vd; - int c, m; - for (c = 0; c < rvd->vdev_children; c++) { - vd = rvd->vdev_child[c]; - for (m = 0; m < vd->vdev_ms_count; m++) { + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *vd = rvd->vdev_child[c]; + for (int m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); - space_map_vacate(&msp->ms_allocmap[0], zdb_leak, - &msp->ms_allocmap[0]); - space_map_unload(&msp->ms_allocmap[0]); - space_map_vacate(&msp->ms_freemap[0], NULL, NULL); + VERIFY(space_map_load(&msp->ms_map, &zdb_space_map_ops, + SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset) == 0); + msp->ms_map.sm_ppd = vd; mutex_exit(&msp->ms_lock); } } } static void -zdb_refresh_ubsync(spa_t *spa) +zdb_leak_fini(spa_t *spa) { - uberblock_t ub = { 0 }; vdev_t *rvd = spa->spa_root_vdev; - zio_t *zio; - - /* - * Reload the uberblock. - */ - zio = zio_root(spa, NULL, NULL, - ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE); - vdev_uberblock_load(zio, rvd, &ub); - (void) zio_wait(zio); - if (ub.ub_txg != 0) - spa->spa_ubsync = ub; + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *vd = rvd->vdev_child[c]; + for (int m = 0; m < vd->vdev_ms_count; m++) { + metaslab_t *msp = vd->vdev_ms[m]; + mutex_enter(&msp->ms_lock); + space_map_unload(&msp->ms_map); + mutex_exit(&msp->ms_lock); + } + } } /* @@ -1371,9 +1471,7 @@ typedef struct zdb_cb { static void zdb_count_block(spa_t *spa, zdb_cb_t *zcb, blkptr_t *bp, int type) { - int i, error; - - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL; int t = (i & 1) ? type : DMU_OT_TOTAL; zdb_blkstats_t *zb = &zcb->zcb_type[l][t]; @@ -1384,21 +1482,34 @@ zdb_count_block(spa_t *spa, zdb_cb_t *zc zb->zb_count++; } - if (dump_opt['L']) - return; + if (dump_opt['S']) { + boolean_t print_sig; - error = zdb_space_map_claim(spa, bp, &zcb->zcb_cache->bc_bookmark); - - if (error == 0) - return; + print_sig = !zdb_sig_user_data || (BP_GET_LEVEL(bp) == 0 && + BP_GET_TYPE(bp) == DMU_OT_PLAIN_FILE_CONTENTS); - if (error == EAGAIN) - (void) fatal("double-allocation, bp=%p", bp); + if (BP_GET_CHECKSUM(bp) < zdb_sig_cksumalg) + print_sig = B_FALSE; - if (error == ESTALE) - (void) fatal("reference to freed block, bp=%p", bp); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sun May 17 23:44:11 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77CD21065674; Sun, 17 May 2009 23:44:11 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B7828FC1F; Sun, 17 May 2009 23:44:11 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4HNiBND043305; Sun, 17 May 2009 23:44:11 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNiBlW043304; Sun, 17 May 2009 23:44:11 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905172344.n4HNiBlW043304@svn.freebsd.org> From: Kip Macy Date: Sun, 17 May 2009 23:44:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192276 - in user/kmacy: releng_7_2_fast_net releng_7_2_fcs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 23:44:11 -0000 Author: kmacy Date: Sun May 17 23:44:10 2009 New Revision: 192276 URL: http://svn.freebsd.org/changeset/base/192276 Log: rename branch to fcs for "fast content server" Added: user/kmacy/releng_7_2_fcs/ - copied from r192275, user/kmacy/releng_7_2_fast_net/ Deleted: user/kmacy/releng_7_2_fast_net/ From owner-svn-src-user@FreeBSD.ORG Mon May 18 02:40:12 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3314C106564A; Mon, 18 May 2009 02:40:12 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D28A8FC08; Mon, 18 May 2009 02:40:12 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4I2eC8i046799; Mon, 18 May 2009 02:40:12 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4I2eB39046786; Mon, 18 May 2009 02:40:11 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905180240.n4I2eB39046786@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 02:40:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192283 - in user/kmacy/releng_7_2_fcs: sbin/ifconfig sbin/route sys/amd64/amd64 sys/amd64/conf sys/amd64/include sys/arm/include sys/conf sys/dev/bce sys/dev/cxgb sys/dev/cxgb/common s... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 02:40:12 -0000 Author: kmacy Date: Mon May 18 02:40:11 2009 New Revision: 192283 URL: http://svn.freebsd.org/changeset/base/192283 Log: merge fast_net backport Added: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/t3c_protocol_sram.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/t3c_tp_eeprom.h user/kmacy/releng_7_2_fcs/sys/kern/kern_vimage.c user/kmacy/releng_7_2_fcs/sys/kern/subr_bufring.c user/kmacy/releng_7_2_fcs/sys/net/bpf_buffer.c user/kmacy/releng_7_2_fcs/sys/net/bpf_buffer.h user/kmacy/releng_7_2_fcs/sys/net/bpf_zerocopy.c user/kmacy/releng_7_2_fcs/sys/net/bpf_zerocopy.h user/kmacy/releng_7_2_fcs/sys/net/if_llatbl.c user/kmacy/releng_7_2_fcs/sys/net/if_llatbl.h user/kmacy/releng_7_2_fcs/sys/net/radix_mpath.c user/kmacy/releng_7_2_fcs/sys/net/radix_mpath.h user/kmacy/releng_7_2_fcs/sys/net/vnet.h user/kmacy/releng_7_2_fcs/sys/netinet/accf_dns.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_hostcache.h user/kmacy/releng_7_2_fcs/sys/netinet/vinet.h user/kmacy/releng_7_2_fcs/sys/netinet6/vinet6.h user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h user/kmacy/releng_7_2_fcs/sys/sys/vimage.h user/kmacy/releng_7_2_fcs/usr.sbin/ifmcstat/printb.c Modified: user/kmacy/releng_7_2_fcs/sbin/ifconfig/ifconfig.c user/kmacy/releng_7_2_fcs/sbin/route/route.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC user/kmacy/releng_7_2_fcs/sys/amd64/include/atomic.h user/kmacy/releng_7_2_fcs/sys/arm/include/atomic.h user/kmacy/releng_7_2_fcs/sys/conf/files user/kmacy/releng_7_2_fcs/sys/conf/kern.pre.mk user/kmacy/releng_7_2_fcs/sys/conf/options user/kmacy/releng_7_2_fcs/sys/dev/bce/if_bcereg.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_ael1002.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_common.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_mc5.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_mv88e1xxx.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_t3_cpl.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_t3_hw.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_tn1010.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_vsc7323.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_vsc8211.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_xgmac.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_adapter.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_config.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_include.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_ioctl.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_main.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_offload.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_offload.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_osdep.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_t3fw.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_t3fw.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/cxgb_support.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/uipc_mvec.c user/kmacy/releng_7_2_fcs/sys/dev/e1000/e1000_80003es2lan.h user/kmacy/releng_7_2_fcs/sys/dev/e1000/e1000_phy.h user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.c user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.h user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_igb.c user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_igb.h user/kmacy/releng_7_2_fcs/sys/dev/firewire/firewirereg.h user/kmacy/releng_7_2_fcs/sys/dev/fxp/if_fxp.c user/kmacy/releng_7_2_fcs/sys/dev/mii/acphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/amphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/atphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/bmtphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/brgphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/ciphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/e1000phy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/exphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/gentbi.c user/kmacy/releng_7_2_fcs/sys/dev/mii/icsphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/inphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/ip1000phy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/jmphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/lxtphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/mii.c user/kmacy/releng_7_2_fcs/sys/dev/mii/mii_physubr.c user/kmacy/releng_7_2_fcs/sys/dev/mii/mlphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/nsgphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/nsphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/nsphyter.c user/kmacy/releng_7_2_fcs/sys/dev/mii/pnaphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/qsphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/rgephy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/rlphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/ruephy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/tdkphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/tlphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/truephy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/ukphy.c user/kmacy/releng_7_2_fcs/sys/dev/mii/xmphy.c user/kmacy/releng_7_2_fcs/sys/dev/mxge/eth_z8e.h user/kmacy/releng_7_2_fcs/sys/dev/mxge/ethp_z8e.h user/kmacy/releng_7_2_fcs/sys/dev/mxge/if_mxge.c user/kmacy/releng_7_2_fcs/sys/dev/mxge/if_mxge_var.h user/kmacy/releng_7_2_fcs/sys/dev/mxge/mxge_lro.c user/kmacy/releng_7_2_fcs/sys/dev/mxge/mxge_mcp.h user/kmacy/releng_7_2_fcs/sys/dev/mxge/rss_eth_z8e.h user/kmacy/releng_7_2_fcs/sys/dev/mxge/rss_ethp_z8e.h user/kmacy/releng_7_2_fcs/sys/dev/nfe/if_nfe.c user/kmacy/releng_7_2_fcs/sys/dev/usb/udbp.c user/kmacy/releng_7_2_fcs/sys/dev/usb/usb_ethersubr.c user/kmacy/releng_7_2_fcs/sys/i386/conf/DEFAULTS user/kmacy/releng_7_2_fcs/sys/i386/include/atomic.h user/kmacy/releng_7_2_fcs/sys/ia64/include/atomic.h user/kmacy/releng_7_2_fcs/sys/kern/kern_jail.c user/kmacy/releng_7_2_fcs/sys/kern/kern_mib.c user/kmacy/releng_7_2_fcs/sys/kern/kern_uuid.c user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c user/kmacy/releng_7_2_fcs/sys/kern/sys_socket.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_debug.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_domain.c user/kmacy/releng_7_2_fcs/sys/kern/vfs_export.c user/kmacy/releng_7_2_fcs/sys/modules/cxgb/Makefile user/kmacy/releng_7_2_fcs/sys/modules/cxgb/cxgb/Makefile user/kmacy/releng_7_2_fcs/sys/modules/cxgb/cxgb_t3fw/Makefile user/kmacy/releng_7_2_fcs/sys/net/bpf.c user/kmacy/releng_7_2_fcs/sys/net/bpf.h user/kmacy/releng_7_2_fcs/sys/net/bpf_filter.c user/kmacy/releng_7_2_fcs/sys/net/bpfdesc.h user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c user/kmacy/releng_7_2_fcs/sys/net/bridgestp.h user/kmacy/releng_7_2_fcs/sys/net/bsd_comp.c user/kmacy/releng_7_2_fcs/sys/net/ethernet.h user/kmacy/releng_7_2_fcs/sys/net/ieee8023ad_lacp.c user/kmacy/releng_7_2_fcs/sys/net/if.c user/kmacy/releng_7_2_fcs/sys/net/if.h user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_atmsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_bridge.c user/kmacy/releng_7_2_fcs/sys/net/if_clone.c user/kmacy/releng_7_2_fcs/sys/net/if_clone.h user/kmacy/releng_7_2_fcs/sys/net/if_disc.c user/kmacy/releng_7_2_fcs/sys/net/if_ef.c user/kmacy/releng_7_2_fcs/sys/net/if_enc.c user/kmacy/releng_7_2_fcs/sys/net/if_ethersubr.c user/kmacy/releng_7_2_fcs/sys/net/if_faith.c user/kmacy/releng_7_2_fcs/sys/net/if_fddisubr.c user/kmacy/releng_7_2_fcs/sys/net/if_fwsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_gif.c user/kmacy/releng_7_2_fcs/sys/net/if_gif.h user/kmacy/releng_7_2_fcs/sys/net/if_gre.c user/kmacy/releng_7_2_fcs/sys/net/if_iso88025subr.c user/kmacy/releng_7_2_fcs/sys/net/if_lagg.c user/kmacy/releng_7_2_fcs/sys/net/if_loop.c user/kmacy/releng_7_2_fcs/sys/net/if_media.h user/kmacy/releng_7_2_fcs/sys/net/if_mib.c user/kmacy/releng_7_2_fcs/sys/net/if_ppp.c user/kmacy/releng_7_2_fcs/sys/net/if_sl.c user/kmacy/releng_7_2_fcs/sys/net/if_spppsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_stf.c user/kmacy/releng_7_2_fcs/sys/net/if_tap.c user/kmacy/releng_7_2_fcs/sys/net/if_tun.c user/kmacy/releng_7_2_fcs/sys/net/if_var.h user/kmacy/releng_7_2_fcs/sys/net/if_vlan.c user/kmacy/releng_7_2_fcs/sys/net/netisr.c user/kmacy/releng_7_2_fcs/sys/net/netisr.h user/kmacy/releng_7_2_fcs/sys/net/pfil.c user/kmacy/releng_7_2_fcs/sys/net/pfil.h user/kmacy/releng_7_2_fcs/sys/net/ppp_deflate.c user/kmacy/releng_7_2_fcs/sys/net/radix.c user/kmacy/releng_7_2_fcs/sys/net/radix.h user/kmacy/releng_7_2_fcs/sys/net/raw_cb.c user/kmacy/releng_7_2_fcs/sys/net/raw_cb.h user/kmacy/releng_7_2_fcs/sys/net/raw_usrreq.c user/kmacy/releng_7_2_fcs/sys/net/route.c user/kmacy/releng_7_2_fcs/sys/net/route.h user/kmacy/releng_7_2_fcs/sys/net/rtsock.c user/kmacy/releng_7_2_fcs/sys/netinet/icmp6.h user/kmacy/releng_7_2_fcs/sys/netinet/icmp_var.h user/kmacy/releng_7_2_fcs/sys/netinet/if_atm.c user/kmacy/releng_7_2_fcs/sys/netinet/if_ether.c user/kmacy/releng_7_2_fcs/sys/netinet/if_ether.h user/kmacy/releng_7_2_fcs/sys/netinet/igmp.c user/kmacy/releng_7_2_fcs/sys/netinet/igmp.h user/kmacy/releng_7_2_fcs/sys/netinet/in.c user/kmacy/releng_7_2_fcs/sys/netinet/in.h user/kmacy/releng_7_2_fcs/sys/netinet/in_gif.c user/kmacy/releng_7_2_fcs/sys/netinet/in_mcast.c user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.c user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h user/kmacy/releng_7_2_fcs/sys/netinet/in_proto.c user/kmacy/releng_7_2_fcs/sys/netinet/in_rmx.c user/kmacy/releng_7_2_fcs/sys/netinet/in_var.h user/kmacy/releng_7_2_fcs/sys/netinet/ip.h user/kmacy/releng_7_2_fcs/sys/netinet/ip6.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_carp.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_divert.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_dummynet.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_dummynet.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_fastfwd.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_fw.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_fw2.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_fw_nat.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_fw_pfil.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_gre.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_icmp.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_icmp.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_id.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_input.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_ipsec.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_mroute.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_options.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_options.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_var.h user/kmacy/releng_7_2_fcs/sys/netinet/raw_ip.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_auth.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_bsd_addr.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_constants.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_crc32.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_crc32.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_header.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_indata.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_input.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_os_bsd.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_output.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_output.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_pcb.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_pcb.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_structs.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_sysctl.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_uio.h user/kmacy/releng_7_2_fcs/sys/netinet/sctp_usrreq.c user/kmacy/releng_7_2_fcs/sys/netinet/sctputil.c user/kmacy/releng_7_2_fcs/sys/netinet/sctputil.h user/kmacy/releng_7_2_fcs/sys/netinet/tcp_hostcache.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_input.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_lro.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_offload.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_offload.h user/kmacy/releng_7_2_fcs/sys/netinet/tcp_output.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_reass.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_sack.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_subr.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_syncache.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_syncache.h user/kmacy/releng_7_2_fcs/sys/netinet/tcp_timer.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_timewait.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_usrreq.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_var.h user/kmacy/releng_7_2_fcs/sys/netinet/toedev.h user/kmacy/releng_7_2_fcs/sys/netinet/udp_usrreq.c user/kmacy/releng_7_2_fcs/sys/netinet/udp_var.h user/kmacy/releng_7_2_fcs/sys/netinet6/dest6.c user/kmacy/releng_7_2_fcs/sys/netinet6/frag6.c user/kmacy/releng_7_2_fcs/sys/netinet6/icmp6.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6_gif.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6_ifattach.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6_pcb.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6_proto.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6_rmx.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6_src.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6_var.h user/kmacy/releng_7_2_fcs/sys/netinet6/ip6_forward.c user/kmacy/releng_7_2_fcs/sys/netinet6/ip6_input.c user/kmacy/releng_7_2_fcs/sys/netinet6/ip6_ipsec.c user/kmacy/releng_7_2_fcs/sys/netinet6/ip6_mroute.c user/kmacy/releng_7_2_fcs/sys/netinet6/ip6_output.c user/kmacy/releng_7_2_fcs/sys/netinet6/ip6_var.h user/kmacy/releng_7_2_fcs/sys/netinet6/ip6protosw.h user/kmacy/releng_7_2_fcs/sys/netinet6/mld6.c user/kmacy/releng_7_2_fcs/sys/netinet6/nd6.c user/kmacy/releng_7_2_fcs/sys/netinet6/nd6.h user/kmacy/releng_7_2_fcs/sys/netinet6/nd6_nbr.c user/kmacy/releng_7_2_fcs/sys/netinet6/nd6_rtr.c user/kmacy/releng_7_2_fcs/sys/netinet6/raw_ip6.c user/kmacy/releng_7_2_fcs/sys/netinet6/raw_ip6.h user/kmacy/releng_7_2_fcs/sys/netinet6/route6.c user/kmacy/releng_7_2_fcs/sys/netinet6/scope6.c user/kmacy/releng_7_2_fcs/sys/netinet6/sctp6_usrreq.c user/kmacy/releng_7_2_fcs/sys/netinet6/tcp6_var.h user/kmacy/releng_7_2_fcs/sys/netinet6/udp6_usrreq.c user/kmacy/releng_7_2_fcs/sys/nfs4client/nfs4_vfsops.c user/kmacy/releng_7_2_fcs/sys/nfs4client/nfs4_vnops.c user/kmacy/releng_7_2_fcs/sys/nfsclient/nfs_diskless.c user/kmacy/releng_7_2_fcs/sys/nfsclient/nfs_vfsops.c user/kmacy/releng_7_2_fcs/sys/nfsclient/nfs_vnops.c user/kmacy/releng_7_2_fcs/sys/nfsserver/nfs_syscalls.c user/kmacy/releng_7_2_fcs/sys/powerpc/include/atomic.h user/kmacy/releng_7_2_fcs/sys/sparc64/include/atomic.h user/kmacy/releng_7_2_fcs/sys/sun4v/include/atomic.h user/kmacy/releng_7_2_fcs/sys/sys/conf.h user/kmacy/releng_7_2_fcs/sys/sys/kernel.h user/kmacy/releng_7_2_fcs/sys/sys/lock.h user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h user/kmacy/releng_7_2_fcs/sys/sys/pcpu.h user/kmacy/releng_7_2_fcs/sys/sys/protosw.h user/kmacy/releng_7_2_fcs/sys/sys/sysctl.h user/kmacy/releng_7_2_fcs/sys/vm/vm_page.c user/kmacy/releng_7_2_fcs/usr.bin/netstat/inet6.c user/kmacy/releng_7_2_fcs/usr.bin/netstat/route.c user/kmacy/releng_7_2_fcs/usr.sbin/ndp/ndp.c user/kmacy/releng_7_2_fcs/usr.sbin/ppp/route.c user/kmacy/releng_7_2_fcs/usr.sbin/route6d/route6d.c Modified: user/kmacy/releng_7_2_fcs/sbin/ifconfig/ifconfig.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sbin/ifconfig/ifconfig.c Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sbin/ifconfig/ifconfig.c Mon May 18 02:40:11 2009 (r192283) @@ -392,14 +392,21 @@ cmd_register(struct cmd *p) } static const struct cmd * -cmd_lookup(const char *name) +cmd_lookup(const char *name, int iscreate) { #define N(a) (sizeof(a)/sizeof(a[0])) const struct cmd *p; for (p = cmds; p != NULL; p = p->c_next) - if (strcmp(name, p->c_name) == 0) - return p; + if (strcmp(name, p->c_name) == 0) { + if (iscreate) { + if (p->c_iscloneop) + return p; + } else { + if (!p->c_iscloneop) + return p; + } + } return NULL; #undef N } @@ -437,6 +444,7 @@ static int ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp) { const struct afswtch *afp, *nafp; + const struct cmd *p; struct callback *cb; int s; @@ -453,9 +461,38 @@ top: err(1, "socket(family %u,SOCK_DGRAM", ifr.ifr_addr.sa_family); while (argc > 0) { - const struct cmd *p; - - p = cmd_lookup(*argv); + p = cmd_lookup(*argv, iscreate); + if (iscreate && p == NULL) { + /* + * Push the clone create callback so the new + * device is created and can be used for any + * remaining arguments. + */ + cb = callbacks; + if (cb == NULL) + errx(1, "internal error, no callback"); + callbacks = cb->cb_next; + cb->cb_func(s, cb->cb_arg); + iscreate = 0; + /* + * Handle any address family spec that + * immediately follows and potentially + * recreate the socket. + */ + nafp = af_getbyname(*argv); + if (nafp != NULL) { + argc--, argv++; + if (nafp != afp) { + close(s); + afp = nafp; + goto top; + } + } + /* + * Look for a normal parameter. + */ + continue; + } if (p == NULL) { /* * Not a recognized command, choose between setting @@ -464,33 +501,6 @@ top: p = (setaddr ? &setifdstaddr_cmd : &setifaddr_cmd); } if (p->c_u.c_func || p->c_u.c_func2) { - if (iscreate && !p->c_iscloneop) { - /* - * Push the clone create callback so the new - * device is created and can be used for any - * remaining arguments. - */ - cb = callbacks; - if (cb == NULL) - errx(1, "internal error, no callback"); - callbacks = cb->cb_next; - cb->cb_func(s, cb->cb_arg); - iscreate = 0; - /* - * Handle any address family spec that - * immediately follows and potentially - * recreate the socket. - */ - nafp = af_getbyname(*argv); - if (nafp != NULL) { - argc--, argv++; - if (nafp != afp) { - close(s); - afp = nafp; - goto top; - } - } - } if (p->c_parameter == NEXTARG) { if (argv[1] == NULL) errx(1, "'%s' requires argument", @@ -688,13 +698,13 @@ setifflags(const char *vname, int value, struct ifreq my_ifr; int flags; - bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq)); + memset(&my_ifr, 0, sizeof(my_ifr)); + (void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name)); if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) { Perror("ioctl (SIOCGIFFLAGS)"); exit(1); } - strncpy(my_ifr.ifr_name, name, sizeof (my_ifr.ifr_name)); flags = (my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16); if (value < 0) { @@ -777,7 +787,8 @@ setifname(const char *val, int dummy __u #define IFCAPBITS \ "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \ -"\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" +"\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \ +"\21VLAN_HWFILTER" /* * Print the status of the interface. If an address family was Modified: user/kmacy/releng_7_2_fcs/sbin/route/route.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sbin/route/route.c Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sbin/route/route.c Mon May 18 02:40:11 2009 (r192283) @@ -605,9 +605,6 @@ newroute(argc, argv) case K_NOSTATIC: flags &= ~RTF_STATIC; break; - case K_LLINFO: - flags |= RTF_LLINFO; - break; case K_LOCK: locking = 1; break; @@ -632,9 +629,6 @@ newroute(argc, argv) case K_PROXY: proxy = 1; break; - case K_CLONING: - flags |= RTF_CLONING; - break; case K_XRESOLVE: flags |= RTF_XRESOLVE; break; Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c Mon May 18 02:40:11 2009 (r192283) @@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS Mon May 18 02:40:11 2009 (r192283) @@ -21,3 +21,4 @@ options GEOM_MBR # KSE support went from being default to a kernel option options KSE +options VIMAGE_GLOBALS Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Mon May 18 02:40:11 2009 (r192283) @@ -25,12 +25,13 @@ ident GENERIC #hints "GENERIC.hints" # Default places to look for devices. makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +makeoptions MODULES_OVERRIDE="mxge zlib geom opensolaris zfs cxgb fxp nfe" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols -options SCTP # Stream Control Transmission Protocol +#options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists @@ -65,6 +66,11 @@ options STOP_NMI # Stop CPUS using NMI options AUDIT # Security event auditing #options KDTRACE_FRAME # Ensure frames are compiled in #options KDTRACE_HOOKS # Kernel DTrace hooks +#options INVARIANTS # Enable calls of extra sanity checking +#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS # Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed + # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel @@ -171,7 +177,6 @@ device uart # Generic UART driver device ppc device ppbus # Parallel port bus (required) device lpt # Printer -device plip # TCP/IP over parallel device ppi # Parallel port interface device #device vpo # Requires scbus and da @@ -181,80 +186,19 @@ device ppi # Parallel port interface d #device puc # PCI Ethernet NICs. -device de # DEC/Intel DC21x4x (``Tulip'') device em # Intel PRO/1000 Gigabit Ethernet Family device igb # Intel PRO/1000 PCIE Server Gigabit Family -device ixgbe # Intel PRO/10GbE PCIE Ethernet Family -device le # AMD Am7900 LANCE and Am79C9xx PCnet -device txp # 3Com 3cR990 (``Typhoon'') -device vx # 3Com 3c590, 3c595 (``Vortex'') - # PCI Ethernet NICs that use the common MII bus controller code. # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! -device miibus # MII bus support -device age # Attansic/Atheros L1 Gigabit Ethernet -device ale # Atheros AR8121/AR8113/AR8114 Ethernet -device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet -device bfe # Broadcom BCM440x 10/100 Ethernet -device bge # Broadcom BCM570xx Gigabit Ethernet -device dc # DEC/Intel 21143 and various workalikes -device et # Agere ET1310 10/100/Gigabit Ethernet -device fxp # Intel EtherExpress PRO/100B (82557, 82558) -device jme # JMicron JMC250 Gigabit/JMC260 Fast Ethernet -device lge # Level 1 LXT1001 gigabit Ethernet -device msk # Marvell/SysKonnect Yukon II Gigabit Ethernet -device nfe # nVidia nForce MCP on-board Ethernet -device nge # NatSemi DP83820 gigabit Ethernet -#device nve # nVidia nForce MCP on-board Ethernet Networking -device pcn # AMD Am79C97x PCI 10/100 (precedence over 'le') -device re # RealTek 8139C+/8169/8169S/8110S -device rl # RealTek 8129/8139 -device sf # Adaptec AIC-6915 (``Starfire'') -device sis # Silicon Integrated Systems SiS 900/SiS 7016 -device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet -device ste # Sundance ST201 (D-Link DFE-550TX) -device ti # Alteon Networks Tigon I/II gigabit Ethernet -device tl # Texas Instruments ThunderLAN -device tx # SMC EtherPower II (83c170 ``EPIC'') -device vge # VIA VT612x gigabit Ethernet -device vr # VIA Rhine, Rhine II -device wb # Winbond W89C840F -device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') - -# ISA Ethernet NICs. pccard NICs included. -device cs # Crystal Semiconductor CS89x0 NIC -# 'device ed' requires 'device miibus' -device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards -device ex # Intel EtherExpress Pro/10 and Pro/10+ -device ep # Etherlink III based cards -device fe # Fujitsu MB8696x based cards -device sn # SMC's 9000 series of Ethernet chips -device xe # Xircom pccard Ethernet - -# Wireless NIC cards -device wlan # 802.11 support -device wlan_wep # 802.11 WEP support -device wlan_ccmp # 802.11 CCMP support -device wlan_tkip # 802.11 TKIP support -device wlan_amrr # AMRR transmit rate control algorithm -device wlan_scan_ap # 802.11 AP mode scanning -device wlan_scan_sta # 802.11 STA mode scanning -device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's -device ath_hal # Atheros HAL (Hardware Access Layer) -options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors -device ath_rate_sample # SampleRate tx rate control for ath -device awi # BayStack 660 and others -device ral # Ralink Technology RT2500 wireless NICs. -device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. +#device miibus # MII bus support # Pseudo devices. device loop # Network loopback device random # Entropy device device ether # Ethernet support -device sl # Kernel SLIP -device ppp # Kernel PPP -device tun # Packet tunnel. +#device sl # Kernel SLIP +#device ppp # Kernel PPP +#device tun # Packet tunnel. device pty # Pseudo-ttys (telnet etc) device md # Memory "disks" device gif # IPv6 and IPv4 tunneling @@ -267,43 +211,38 @@ device firmware # firmware assist modul device bpf # Berkeley packet filter # USB support -device uhci # UHCI PCI->USB interface -device ohci # OHCI PCI->USB interface -device ehci # EHCI PCI->USB interface (USB 2.0) -device usb # USB Bus (required) +#device uhci # UHCI PCI->USB interface +#device ohci # OHCI PCI->USB interface +#device ehci # EHCI PCI->USB interface (USB 2.0) +#device usb # USB Bus (required) #device udbp # USB Double Bulk Pipe devices -device ugen # Generic -device uhid # "Human Interface Devices" -device ukbd # Keyboard -device ulpt # Printer -device umass # Disks/Mass storage - Requires scbus and da -device ums # Mouse -device ural # Ralink Technology RT2500USB wireless NICs -device urio # Diamond Rio 500 MP3 player -device uscanner # Scanners +#device ugen # Generic +#device uhid # "Human Interface Devices" +#device ukbd # Keyboard +#device ulpt # Printer +#device umass # Disks/Mass storage - Requires scbus and da +#device ums # Mouse +#device ural # Ralink Technology RT2500USB wireless NICs +#device urio # Diamond Rio 500 MP3 player +#device uscanner # Scanners # USB Serial devices -device ucom # Generic com ttys -device uark # Technologies ARK3116 based serial adapters -device ubsa # Belkin F5U103 and compatible serial adapters -device ubser # BWCT console serial adapters -device uftdi # For FTDI usb serial adapters -device uipaq # Some WinCE based devices -device uplcom # Prolific PL-2303 serial adapters -device uslcom # SI Labs CP2101/CP2102 serial adapters -device uvisor # Visor and Palm devices -device uvscom # USB serial support for DDI pocket's PHS -# USB Ethernet, requires miibus -device aue # ADMtek USB Ethernet -device axe # ASIX Electronics USB Ethernet -device cdce # Generic USB over Ethernet -device cue # CATC USB Ethernet -device kue # Kawasaki LSI USB Ethernet -device rue # RealTek RTL8150 USB Ethernet +#device ucom # Generic com ttys +#device uark # Technologies ARK3116 based serial adapters +#device ubsa # Belkin F5U103 and compatible serial adapters +#device ubser # BWCT console serial adapters +#device uftdi # For FTDI usb serial adapters +#device uipaq # Some WinCE based devices +#device uplcom # Prolific PL-2303 serial adapters +#device uslcom # SI Labs CP2101/CP2102 serial adapters +#device uvisor # Visor and Palm devices +#device uvscom # USB serial support for DDI pocket's PHS + # FireWire support -device firewire # FireWire bus code -device sbp # SCSI over FireWire (Requires scbus and da) -device fwe # Ethernet over FireWire (non-standard!) -device fwip # IP over FireWire (RFC 2734,3146) -device dcons # Dumb console driver -device dcons_crom # Configuration ROM for dcons +#device firewire # FireWire bus code +#device sbp # SCSI over FireWire (Requires scbus and da) +#device fwe # Ethernet over FireWire (non-standard!) +#device fwip # IP over FireWire (RFC 2734,3146) +#device dcons # Dumb console driver +#device dcons_crom # Configuration ROM for dcons + Modified: user/kmacy/releng_7_2_fcs/sys/amd64/include/atomic.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/include/atomic.h Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/amd64/include/atomic.h Mon May 18 02:40:11 2009 (r192283) @@ -32,6 +32,10 @@ #error this file needs sys/cdefs.h as a prerequisite #endif +#define mb() __asm__ __volatile__ ("mfence;": : :"memory") +#define wmb() __asm__ __volatile__ ("sfence;": : :"memory") +#define rmb() __asm__ __volatile__ ("lfence;": : :"memory") + /* * Various simple operations on memory, each of which is atomic in the * presence of interrupts and multiple processors. Modified: user/kmacy/releng_7_2_fcs/sys/arm/include/atomic.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/arm/include/atomic.h Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/arm/include/atomic.h Mon May 18 02:40:11 2009 (r192283) @@ -45,6 +45,10 @@ #include +#define mb() +#define wmb() +#define rmb() + #ifndef I32_bit #define I32_bit (1 << 7) /* IRQ disable */ #endif Modified: user/kmacy/releng_7_2_fcs/sys/conf/files ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/files Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/conf/files Mon May 18 02:40:11 2009 (r192283) @@ -679,21 +679,36 @@ dev/cpufreq/ichss.c optional cpufreq dev/cs/if_cs.c optional cs dev/cs/if_cs_isa.c optional cs isa dev/cs/if_cs_pccard.c optional cs pccard -dev/cxgb/cxgb_main.c optional cxgb pci -dev/cxgb/cxgb_offload.c optional cxgb pci -dev/cxgb/cxgb_sge.c optional cxgb pci -dev/cxgb/cxgb_multiq.c optional cxgb pci -dev/cxgb/common/cxgb_mc5.c optional cxgb pci -dev/cxgb/common/cxgb_vsc7323.c optional cxgb pci -dev/cxgb/common/cxgb_vsc8211.c optional cxgb pci -dev/cxgb/common/cxgb_ael1002.c optional cxgb pci -dev/cxgb/common/cxgb_mv88e1xxx.c optional cxgb pci -dev/cxgb/common/cxgb_xgmac.c optional cxgb pci -dev/cxgb/common/cxgb_t3_hw.c optional cxgb pci -dev/cxgb/common/cxgb_tn1010.c optional cxgb pci -dev/cxgb/sys/uipc_mvec.c optional cxgb pci -dev/cxgb/sys/cxgb_support.c optional cxgb pci -dev/cxgb/cxgb_t3fw.c optional cxgb cxgb_t3fw +dev/cxgb/cxgb_main.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/cxgb_offload.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/cxgb_sge.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/cxgb_multiq.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_mc5.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_vsc7323.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_vsc8211.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_ael1002.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_mv88e1xxx.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_xgmac.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_t3_hw.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/common/cxgb_tn1010.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/sys/uipc_mvec.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/sys/cxgb_support.c optional cxgb pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" +dev/cxgb/cxgb_t3fw.c optional cxgb cxgb_t3fw \ + compile-with "${NORMAL_C} -I$S/dev/cxgb" dev/cy/cy.c optional cy dev/cy/cy_isa.c optional cy isa dev/cy/cy_pci.c optional cy pci @@ -1645,6 +1660,7 @@ kern/kern_time.c standard kern/kern_timeout.c standard kern/kern_umtx.c standard kern/kern_uuid.c standard +kern/kern_vimage.c standard kern/kern_xxx.c standard kern/link_elf.c standard kern/linker_if.m standard @@ -1659,6 +1675,7 @@ kern/subr_acl_posix1e.c standard kern/subr_autoconf.c standard kern/subr_blist.c standard kern/subr_bus.c standard +kern/subr_bufring.c standard kern/subr_clock.c standard kern/subr_devstat.c standard kern/subr_disk.c standard @@ -1683,6 +1700,7 @@ kern/subr_rman.c standard kern/subr_rtc.c optional genclock kern/subr_sbuf.c standard kern/subr_scanf.c standard +kern/kern_rmlock.c standard kern/kern_sdt.c optional kdtrace_hooks kern/subr_sleepqueue.c standard kern/subr_smp.c standard @@ -1782,8 +1800,10 @@ libkern/strtoul.c standard libkern/strtouq.c standard libkern/strvalid.c standard net/bpf.c standard +net/bpf_buffer.c optional bpf net/bpf_jitter.c optional bpf_jitter net/bpf_filter.c optional bpf | netgraph_bpf +net/bpf_zerocopy.c optional bpf net/bridgestp.c optional bridge | if_bridge net/bsd_comp.c optional ppp_bsdcomp net/ieee8023ad_lacp.c optional lagg @@ -1806,6 +1826,7 @@ net/if_gre.c optional gre net/if_iso88025subr.c optional token net/if_lagg.c optional lagg net/if_loop.c optional loop +net/if_llatbl.c standard net/if_media.c standard net/if_mib.c standard net/if_ppp.c optional ppp @@ -1823,6 +1844,7 @@ net/ppp_deflate.c optional ppp_deflate net/ppp_tty.c optional ppp net/pfil.c optional ether | inet net/radix.c standard +net/radix_mpath.c standard net/raw_cb.c standard net/raw_usrreq.c standard net/route.c standard Modified: user/kmacy/releng_7_2_fcs/sys/conf/kern.pre.mk ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/kern.pre.mk Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/conf/kern.pre.mk Mon May 18 02:40:11 2009 (r192283) @@ -74,6 +74,9 @@ INCLUDES+= -I$S/contrib/ngatm # .. and the same for twa INCLUDES+= -I$S/dev/twa +# .. and the same for cxgb +INCLUDES+= -I$S/dev/cxgb + # ... and XFS INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs Modified: user/kmacy/releng_7_2_fcs/sys/conf/options ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/options Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/conf/options Mon May 18 02:40:11 2009 (r192283) @@ -373,6 +373,7 @@ IPSEC opt_ipsec.h IPSEC_DEBUG opt_ipsec.h IPSEC_FILTERTUNNEL opt_ipsec.h IPDIVERT +MBUF_PROFILING DUMMYNET opt_ipdn.h IPFILTER opt_ipfilter.h IPFILTER_LOG opt_ipfilter.h @@ -395,6 +396,7 @@ NETATALK opt_atalk.h PPP_BSDCOMP opt_ppp.h PPP_DEFLATE opt_ppp.h PPP_FILTER opt_ppp.h +RADIX_MPATH opt_mpath.h SLIP_IFF_OPTS opt_slip.h TCPDEBUG TCP_SIGNATURE opt_inet.h @@ -770,3 +772,7 @@ XFS # Interrupt filtering INTR_FILTER opt_global.h + +# Virtualize the network stack +VIMAGE opt_global.h +VIMAGE_GLOBALS opt_global.h Modified: user/kmacy/releng_7_2_fcs/sys/dev/bce/if_bcereg.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/bce/if_bcereg.h Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/dev/bce/if_bcereg.h Mon May 18 02:40:11 2009 (r192283) @@ -557,6 +557,8 @@ #endif /* BCE_DEBUG */ + +#if __FreeBSD_version < 701101 #if defined(__i386__) || defined(__amd64__) #define mb() __asm volatile("mfence" ::: "memory") #define wmb() __asm volatile("sfence" ::: "memory") @@ -566,6 +568,7 @@ #define rmb() #define wmb() #endif +#endif /****************************************************************************/ /* Device identification definitions. */ Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_ael1002.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_ael1002.c Mon May 18 02:25:45 2009 (r192282) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/common/cxgb_ael1002.c Mon May 18 02:40:11 2009 (r192283) @@ -1,6 +1,6 @@ /************************************************************************** -Copyright (c) 2007-2008, Chelsio Inc. +Copyright (c) 2007-2009, Chelsio Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,11 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. #include __FBSDID("$FreeBSD$"); -#ifdef CONFIG_DEFINED #include -#else -#include -#endif #undef msleep #define msleep t3_os_sleep @@ -64,7 +60,17 @@ enum { enum { edc_none, edc_sr, edc_twinax }; /* PHY module I2C device address */ -#define MODULE_DEV_ADDR 0xa0 +enum { + MODULE_DEV_ADDR = 0xa0, + SFF_DEV_ADDR = 0xa2, +}; + +/* PHY transceiver type */ +enum { + phy_transtype_unknown = 0, + phy_transtype_sfp = 3, + phy_transtype_xfp = 6, +}; #define AEL2005_MODDET_IRQ 4 @@ -75,6 +81,8 @@ struct reg_val { unsigned short set_bits; }; +static int get_module_type(struct cphy *phy); + static int set_phy_regs(struct cphy *phy, const struct reg_val *rv) { int err; @@ -100,6 +108,110 @@ static void ael100x_txon(struct cphy *ph msleep(30); } +static int ael_i2c_rd(struct cphy *phy, int dev_addr, int word_addr) +{ + int i, err; + unsigned int stat, data; + + err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL, + (dev_addr << 8) | (1 << 8) | word_addr); + if (err) + return err; + + for (i = 0; i < 200; i++) { + msleep(1); + err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat); + if (err) + return err; + if ((stat & 3) == 1) { + err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA, + &data); + if (err) + return err; + return data >> 8; + } + } + CH_WARN(phy->adapter, "PHY %u I2C read of addr %u timed out\n", + phy->addr, word_addr); + return -ETIMEDOUT; +} + +static int ael_i2c_wr(struct cphy *phy, int dev_addr, int word_addr, int data) +{ + int i, err; + unsigned int stat; + + err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA, data); + if (err) + return err; + + err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL, + (dev_addr << 8) | word_addr); + if (err) + return err; + + for (i = 0; i < 200; i++) { + msleep(1); + err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat); + if (err) + return err; + if ((stat & 3) == 1) + return 0; + } + CH_WARN(phy->adapter, "PHY %u I2C Write of addr %u timed out\n", + phy->addr, word_addr); + return -ETIMEDOUT; +} + +static int get_phytrans_type(struct cphy *phy) +{ + int v; + + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 0); + if (v < 0) + return phy_transtype_unknown; + + return v; +} + +static int ael_laser_down(struct cphy *phy, int enable) +{ + int v, dev_addr; + + v = get_phytrans_type(phy); + if (v < 0) + return v; + + if (v == phy_transtype_sfp) { + /* Check SFF Soft TX disable is supported */ + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 93); + if (v < 0) + return v; + + v &= 0x40; + if (!v) + return v; + + dev_addr = SFF_DEV_ADDR; + } else if (v == phy_transtype_xfp) + dev_addr = MODULE_DEV_ADDR; + else + return v; + + v = ael_i2c_rd(phy, dev_addr, 110); + if (v < 0) + return v; + + if (enable) + v |= 0x40; + else + v &= ~0x40; + + v = ael_i2c_wr(phy, dev_addr, 110, v); + + return v; +} + static int ael1002_power_down(struct cphy *phy, int enable) { int err; @@ -111,6 +223,18 @@ static int ael1002_power_down(struct cph return err; } +static int ael1002_get_module_type(struct cphy *phy, int delay_ms) +{ + int v; + + if (delay_ms) + msleep(delay_ms); + + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 0); + + return v == -ETIMEDOUT ? phy_modtype_none : get_module_type(phy); +} + static int ael1002_reset(struct cphy *phy, int wait) { int err; @@ -123,6 +247,11 @@ static int ael1002_reset(struct cphy *ph (err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL1002_LB_EN, 0, 1 << 5))) return err; + + err = ael1002_get_module_type(phy, 300); + if (err >= 0) + phy->modtype = err; + return 0; } @@ -186,40 +315,55 @@ static struct cphy_ops ael1002_ops = { int t3_ael1002_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, const struct mdio_ops *mdio_ops) { + int err; + cphy_init(phy, adapter, phy_addr, &ael1002_ops, mdio_ops, SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE, "10GBASE-R"); ael100x_txon(phy); + ael_laser_down(phy, 0); + + err = ael1002_get_module_type(phy, 0); + if (err >= 0) + phy->modtype = err; + return 0; } static int ael1006_reset(struct cphy *phy, int wait) { - u32 gpio_out; - t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); - /* Hack to reset the phy correctly */ - /* Read out the current value */ - gpio_out = t3_read_reg(phy->adapter, A_T3DBG_GPIO_EN); - /* Reset the phy */ - gpio_out &= ~F_GPIO6_OUT_VAL; - t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); + int err; + + err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); + if (err) + return err; + + t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN, + F_GPIO6_OUT_VAL, 0); + msleep(125); - /* Take the phy out of reset */ - gpio_out |= F_GPIO6_OUT_VAL; - t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); + + t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN, + F_GPIO6_OUT_VAL, F_GPIO6_OUT_VAL); + msleep(125); - t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); - /* Phy loopback work around for ael1006 */ - /* Soft reset phy by toggling loopback */ - msleep(125); - /* Put phy into local loopback */ - t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 0, 1); - msleep(125); - /* Take phy out of local loopback */ - t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 1, 0); + err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); + if (err) + return err; - return 0; + msleep(125); + + err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 1, 1); + if (err) + return err; + + msleep(125); + + err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 1, 0); + + return err; + } static int ael1006_power_down(struct cphy *phy, int enable) @@ -959,81 +1103,71 @@ static int ael2005_setup_twinax_edc(stru return err; } -static int ael2005_i2c_rd(struct cphy *phy, int dev_addr, int word_addr) -{ - int i, err; - unsigned int stat, data; - - err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL, - (dev_addr << 8) | (1 << 8) | word_addr); - if (err) - return err; - - for (i = 0; i < 5; i++) { - msleep(1); - err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat); - if (err) - return err; - if ((stat & 3) == 1) { - err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA, - &data); - if (err) - return err; - return data >> 8; - } - } - CH_WARN(phy->adapter, "PHY %u I2C read of addr %u timed out\n", - phy->addr, word_addr); - return -ETIMEDOUT; -} - -static int get_module_type(struct cphy *phy, int delay_ms) +static int get_module_type(struct cphy *phy) { int v; - unsigned int stat; - v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, &stat); - if (v) - return v; + v = get_phytrans_type(phy); + if (v == phy_transtype_sfp) { + /* SFP: see SFF-8472 for below */ - if (stat & (1 << 8)) /* module absent */ - return phy_modtype_none; + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 3); + if (v < 0) + return v; - if (delay_ms) - msleep(delay_ms); + if (v == 0x1) + return phy_modtype_twinax; + if (v == 0x10) + return phy_modtype_sr; + if (v == 0x20) + return phy_modtype_lr; + if (v == 0x40) + return phy_modtype_lrm; - /* see SFF-8472 for below */ - v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 3); - if (v < 0) - return v; + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 6); + if (v < 0) + return v; + if (v != 4) + return phy_modtype_unknown; - if (v == 0x10) - return phy_modtype_sr; - if (v == 0x20) - return phy_modtype_lr; - if (v == 0x40) - return phy_modtype_lrm; + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 10); + if (v < 0) + return v; - v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 6); - if (v < 0) - return v; - if (v != 4) - goto unknown; + if (v & 0x80) { + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 0x12); + if (v < 0) + return v; + return v > 10 ? phy_modtype_twinax_long : + phy_modtype_twinax; + } + } else if (v == phy_transtype_xfp) { + /* XFP: See INF-8077i for details. */ - v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 10); - if (v < 0) - return v; + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 127); + if (v < 0) + return v; - if (v & 0x80) { - v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 0x12); + if (v != 1) { + /* XXX: set page select to table 1 yourself */ + return phy_modtype_unknown; + } + + v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 131); if (v < 0) return v; - return v > 10 ? phy_modtype_twinax_long : phy_modtype_twinax; + if (v == 0x10) + return phy_modtype_lrm; + if (v == 0x40) + return phy_modtype_lr; + if (v == 0x80) + return phy_modtype_sr; } -unknown: + return phy_modtype_unknown; } + static int ael2005_intr_enable(struct cphy *phy) { int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x200); @@ -1052,6 +1186,24 @@ static int ael2005_intr_clear(struct cph return err ? err : t3_phy_lasi_intr_clear(phy); } +static int ael2005_get_module_type(struct cphy *phy, int delay_ms) +{ + int v; + unsigned int stat; + + v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, &stat); + if (v) + return v; + + if (stat & (1 << 8)) /* module absent */ + return phy_modtype_none; + + if (delay_ms) + msleep(delay_ms); + + return get_module_type(phy); +} + static int ael2005_reset(struct cphy *phy, int wait) { static struct reg_val regs0[] = { @@ -1088,7 +1240,7 @@ static int ael2005_reset(struct cphy *ph msleep(50); - err = get_module_type(phy, 0); + err = ael2005_get_module_type(phy, 0); if (err < 0) return err; phy->modtype = (u8)err; @@ -1126,7 +1278,7 @@ static int ael2005_intr_handler(struct c return ret; /* modules have max 300 ms init time after hot plug */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon May 18 05:47:58 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA874106566C; Mon, 18 May 2009 05:47:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA6CF8FC13; Mon, 18 May 2009 05:47:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4I5lwAj051008; Mon, 18 May 2009 05:47:58 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4I5lwsO051007; Mon, 18 May 2009 05:47:58 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905180547.n4I5lwsO051007@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 05:47:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192287 - user/kmacy/releng_7_2_fcs/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 05:47:59 -0000 Author: kmacy Date: Mon May 18 05:47:58 2009 New Revision: 192287 URL: http://svn.freebsd.org/changeset/base/192287 Log: add local changes Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Mon May 18 04:56:37 2009 (r192286) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Mon May 18 05:47:58 2009 (r192287) @@ -25,7 +25,7 @@ ident GENERIC #hints "GENERIC.hints" # Default places to look for devices. makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions MODULES_OVERRIDE="mxge zlib geom opensolaris zfs cxgb fxp nfe" +makeoptions MODULES_OVERRIDE="mxge zlib geom opensolaris zfs cxgb fxp nfe hwpmc" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption @@ -246,3 +246,9 @@ device bpf # Berkeley packet filter #device dcons # Dumb console driver #device dcons_crom # Configuration ROM for dcons +options DDB +options KDB +options ALT_BREAK_TO_DEBUGGER +options ADAPTIVE_SX +options HWPMC_HOOKS + From owner-svn-src-user@FreeBSD.ORG Mon May 18 06:20:39 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 724A21065676; Mon, 18 May 2009 06:20:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5DBFA8FC08; Mon, 18 May 2009 06:20:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4I6KdWZ051960; Mon, 18 May 2009 06:20:39 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4I6Kb2D051920; Mon, 18 May 2009 06:20:37 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905180620.n4I6Kb2D051920@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 06:20:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192293 - in user/kmacy/releng_7_2_fcs: sbin/route sys/contrib/ipfilter/netinet sys/contrib/pf/net sys/dev/iicbus sys/dev/lmc sys/dev/ppbus sys/kern sys/net sys/net80211 sys/netgraph sy... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 06:20:39 -0000 Author: kmacy Date: Mon May 18 06:20:37 2009 New Revision: 192293 URL: http://svn.freebsd.org/changeset/base/192293 Log: merge HEAD updates 191028 - use a shared lock for reads - remove stale comment 191033 - update bufring for ALTQ 191080 Extend route command: - add show as alias for get - add weights to allow mpath to do more than equal cost - add sticky / nostick to disable / re-enable per-connection load balancing This adds a field to rt_metrics_lite so network bits of world will need to be re-built. 191117 add an llentry to struct route{_in6} to allow it to be passed around with the rtentry 191120 make LLTABLE visible to netinet 191126 191148 Change if_output to take a struct route as its fourth argument in order to allow passing a cached struct llentry * down to L2 Modified: user/kmacy/releng_7_2_fcs/sbin/route/keywords user/kmacy/releng_7_2_fcs/sbin/route/route.c user/kmacy/releng_7_2_fcs/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pflog.c user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pfsync.c user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/pf.c user/kmacy/releng_7_2_fcs/sys/dev/iicbus/if_ic.c user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.c user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.h user/kmacy/releng_7_2_fcs/sys/dev/ppbus/if_plip.c user/kmacy/releng_7_2_fcs/sys/kern/vfs_vnops.c user/kmacy/releng_7_2_fcs/sys/net/ethernet.h user/kmacy/releng_7_2_fcs/sys/net/if_arc.h user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_atm.h user/kmacy/releng_7_2_fcs/sys/net/if_atmsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_disc.c user/kmacy/releng_7_2_fcs/sys/net/if_enc.c user/kmacy/releng_7_2_fcs/sys/net/if_ethersubr.c user/kmacy/releng_7_2_fcs/sys/net/if_faith.c user/kmacy/releng_7_2_fcs/sys/net/if_fddisubr.c user/kmacy/releng_7_2_fcs/sys/net/if_fwsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_gif.c user/kmacy/releng_7_2_fcs/sys/net/if_gif.h user/kmacy/releng_7_2_fcs/sys/net/if_gre.c user/kmacy/releng_7_2_fcs/sys/net/if_iso88025subr.c user/kmacy/releng_7_2_fcs/sys/net/if_lagg.c user/kmacy/releng_7_2_fcs/sys/net/if_lagg.h user/kmacy/releng_7_2_fcs/sys/net/if_loop.c user/kmacy/releng_7_2_fcs/sys/net/if_spppsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_stf.c user/kmacy/releng_7_2_fcs/sys/net/if_tun.c user/kmacy/releng_7_2_fcs/sys/net/if_var.h user/kmacy/releng_7_2_fcs/sys/net/iso88025.h user/kmacy/releng_7_2_fcs/sys/net/radix_mpath.c user/kmacy/releng_7_2_fcs/sys/net/route.c user/kmacy/releng_7_2_fcs/sys/net/route.h user/kmacy/releng_7_2_fcs/sys/net/rtsock.c user/kmacy/releng_7_2_fcs/sys/net80211/ieee80211.c user/kmacy/releng_7_2_fcs/sys/net80211/ieee80211_output.c user/kmacy/releng_7_2_fcs/sys/net80211/ieee80211_proto.h user/kmacy/releng_7_2_fcs/sys/net80211/ieee80211_var.h user/kmacy/releng_7_2_fcs/sys/netgraph/ng_fec.c user/kmacy/releng_7_2_fcs/sys/netgraph/ng_iface.c user/kmacy/releng_7_2_fcs/sys/netinet/if_ether.c user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h user/kmacy/releng_7_2_fcs/sys/netinet/in_var.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_carp.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_fastfwd.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_structs.h user/kmacy/releng_7_2_fcs/sys/netinet6/in6.h user/kmacy/releng_7_2_fcs/sys/netinet6/nd6.c user/kmacy/releng_7_2_fcs/sys/netinet6/nd6.h user/kmacy/releng_7_2_fcs/sys/netipx/ipx_outputfl.c Modified: user/kmacy/releng_7_2_fcs/sbin/route/keywords ============================================================================== --- user/kmacy/releng_7_2_fcs/sbin/route/keywords Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sbin/route/keywords Mon May 18 06:20:37 2009 (r192293) @@ -33,6 +33,7 @@ mtu net netmask nostatic +nostick osi prefixlen proto1 @@ -44,8 +45,11 @@ rtt rttvar sa sendpipe +show ssthresh static +sticky +weight x25 xns xresolve Modified: user/kmacy/releng_7_2_fcs/sbin/route/route.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sbin/route/route.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sbin/route/route.c Mon May 18 06:20:37 2009 (r192293) @@ -169,6 +169,7 @@ main(argc, argv) if (*argv) switch (keyword(*argv)) { case K_GET: + case K_SHOW: uid = 0; /* FALLTHROUGH */ @@ -548,6 +549,7 @@ set_metric(value, key) caseof(K_SSTHRESH, RTV_SSTHRESH, rmx_ssthresh); caseof(K_RTT, RTV_RTT, rmx_rtt); caseof(K_RTTVAR, RTV_RTTVAR, rmx_rttvar); + caseof(K_WEIGHT, RTV_WEIGHT, rmx_weight); } rtm_inits |= flag; if (lockrest || locking) @@ -571,8 +573,9 @@ newroute(argc, argv) errx(EX_NOPERM, "must be root to alter routing table"); } cmd = argv[0]; - if (*cmd != 'g') + if (*cmd != 'g' && *cmd != 's') shutdown(s, SHUT_RD); /* Don't want to read back our messages */ + while (--argc > 0) { if (**(++argv)== '-') { switch (key = keyword(1 + *argv)) { @@ -635,6 +638,12 @@ newroute(argc, argv) case K_STATIC: flags |= RTF_STATIC; break; + case K_STICKY: + flags |= RTF_STICKY; + break; + case K_NOSTICK: + flags &= ~RTF_STICKY; + break; case K_IFA: if (!--argc) usage((char *)NULL); @@ -688,6 +697,7 @@ newroute(argc, argv) case K_SSTHRESH: case K_RTT: case K_RTTVAR: + case K_WEIGHT: if (!--argc) usage((char *)NULL); set_metric(*++argv, key); @@ -741,7 +751,7 @@ newroute(argc, argv) } else break; } - if (*cmd == 'g') + if (*cmd == 'g' || *cmd == 's') exit(ret != 0); if (!qflag) { oerrno = errno; @@ -1191,7 +1201,7 @@ rtmsg(cmd, flags) cmd = RTM_ADD; else if (cmd == 'c') cmd = RTM_CHANGE; - else if (cmd == 'g') { + else if (cmd == 'g' || cmd == 's') { cmd = RTM_GET; if (so_ifp.sa.sa_family == 0) { so_ifp.sa.sa_family = AF_LINK; @@ -1295,13 +1305,13 @@ char *msgtypes[] = { }; char metricnames[] = -"\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount" +"\011weight\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire" "\1mtu"; char routeflags[] = -"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT" -"\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016" -"\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3\024CHAINDELETE" -"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST"; +"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" +"\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE" +"\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3" +"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\035STICKY"; char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP" "\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1" @@ -1464,14 +1474,13 @@ print_getmsg(rtm, msglen) #define msec(u) (((u) + 500) / 1000) /* usec to msec */ (void) printf("\n%s\n", "\ - recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire"); + recvpipe sendpipe ssthresh rtt,msec mtu weight expire"); printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rtt), lock(RTT)); - printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rttvar), lock(RTTVAR)); - printf("%8ld%c ", rtm->rtm_rmx.rmx_hopcount, lock(HOPCOUNT)); printf("%8ld%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); + printf("%8ld%c ", rtm->rtm_rmx.rmx_weight, lock(WEIGHT)); if (rtm->rtm_rmx.rmx_expire) rtm->rtm_rmx.rmx_expire -= time(0); printf("%8ld%c\n", rtm->rtm_rmx.rmx_expire, lock(EXPIRE)); Modified: user/kmacy/releng_7_2_fcs/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Mon May 18 06:20:37 2009 (r192293) @@ -1034,7 +1034,7 @@ frdest_t *fdp; if (!ip->ip_sum) ip->ip_sum = in_cksum(m, hlen); error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, - ro->ro_rt); + ro); goto done; } /* @@ -1115,7 +1115,7 @@ sendorfree: m->m_act = 0; if (error == 0) error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, ro->ro_rt); + (struct sockaddr *)dst, ro); else FREE_MB_T(m); } Modified: user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pflog.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pflog.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pflog.c Mon May 18 06:20:37 2009 (r192293) @@ -113,7 +113,7 @@ __FBSDID("$FreeBSD$"); void pflogattach(int); int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); int pflogioctl(struct ifnet *, u_long, caddr_t); void pflogstart(struct ifnet *); #ifdef __FreeBSD__ @@ -287,7 +287,7 @@ pflogstart(struct ifnet *ifp) int pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { m_freem(m); return (0); Modified: user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pfsync.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pfsync.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/if_pfsync.c Mon May 18 06:20:37 2009 (r192293) @@ -152,7 +152,7 @@ int pfsync_insert_net_state(struct pfsyn void pfsync_update_net_tdb(struct pfsync_tdb *); #endif int pfsyncoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); int pfsyncioctl(struct ifnet *, u_long, caddr_t); void pfsyncstart(struct ifnet *); @@ -1083,7 +1083,7 @@ done: int pfsyncoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { m_freem(m); return (0); Modified: user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/pf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/pf.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/contrib/pf/net/pf.c Mon May 18 06:20:37 2009 (r192293) @@ -6234,7 +6234,7 @@ pf_route(struct mbuf **m, struct pf_rule } } PF_UNLOCK(); - error = (*ifp->if_output)(ifp, m0, sintosa(dst), ro->ro_rt); + error = (*ifp->if_output)(ifp, m0, sintosa(dst), ro); PF_LOCK(); goto done; } Modified: user/kmacy/releng_7_2_fcs/sys/dev/iicbus/if_ic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/iicbus/if_ic.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/dev/iicbus/if_ic.c Mon May 18 06:20:37 2009 (r192293) @@ -92,7 +92,7 @@ static int icattach(device_t); static int icioctl(struct ifnet *, u_long, caddr_t); static int icoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void icintr(device_t, int, char *); @@ -341,7 +341,7 @@ icintr(device_t dev, int event, char *pt */ static int icoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit); device_t parent = device_get_parent(icdev); Modified: user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.c Mon May 18 06:20:37 2009 (r192293) @@ -114,6 +114,7 @@ # include # include # include +# include # include # include # include @@ -4583,7 +4584,7 @@ lmc_ifnet_start(struct ifnet *ifp) /* Called from a syscall (user context; no spinlocks). */ static int lmc_raw_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt) + struct sockaddr *dst, struct route *ro) { softc_t *sc = IFP2SC(ifp); int error = 0; Modified: user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/dev/lmc/if_lmc.h Mon May 18 06:20:37 2009 (r192293) @@ -1595,7 +1595,7 @@ static int lmc_raw_ioctl(struct ifnet *, static int lmc_ifnet_ioctl(struct ifnet *, u_long, caddr_t); static void lmc_ifnet_start(struct ifnet *); static int lmc_raw_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); static void lmc_ifnet_watchdog(struct ifnet *); # ifdef __OpenBSD__ static int ifmedia_change(struct ifnet *); Modified: user/kmacy/releng_7_2_fcs/sys/dev/ppbus/if_plip.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/ppbus/if_plip.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/dev/ppbus/if_plip.c Mon May 18 06:20:37 2009 (r192293) @@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -168,7 +169,7 @@ static u_char *ctxmith; static int lpinittables(void); static int lpioctl(struct ifnet *, u_long, caddr_t); static int lpoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void lp_intr(void *); #define DEVTOSOFTC(dev) \ @@ -603,8 +604,8 @@ lpoutbyte (u_char byte, int spin, device } static int -lpoutput (struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt) +lpoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, + struct route *ro) { device_t dev = UNITODEVICE(ifp->if_dunit); device_t ppbus = device_get_parent(dev); Modified: user/kmacy/releng_7_2_fcs/sys/kern/vfs_vnops.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/vfs_vnops.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/kern/vfs_vnops.c Mon May 18 06:20:37 2009 (r192293) @@ -363,14 +363,8 @@ vn_rdwr(rw, vp, base, len, offset, segfl != 0) return (error); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); - } else { - /* - * XXX This should be LK_SHARED but I don't trust VFS - * enough to leave it like that until it has been - * reviewed further. - */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); - } + } else + vn_lock(vp, LK_SHARED | LK_RETRY, td); } ASSERT_VOP_LOCKED(vp, "IO_NODELOCKED with no vp lock held"); Modified: user/kmacy/releng_7_2_fcs/sys/net/ethernet.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/ethernet.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/ethernet.h Mon May 18 06:20:37 2009 (r192293) @@ -365,7 +365,7 @@ struct ether_addr { struct ifnet; struct mbuf; -struct rtentry; +struct route; struct sockaddr; struct bpf_if; @@ -376,7 +376,7 @@ extern void ether_ifattach(struct ifnet extern void ether_ifdetach(struct ifnet *); extern int ether_ioctl(struct ifnet *, u_long, caddr_t); extern int ether_output(struct ifnet *, - struct mbuf *, struct sockaddr *, struct rtentry *); + struct mbuf *, struct sockaddr *, struct route *); extern int ether_output_frame(struct ifnet *, struct mbuf *); extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, Modified: user/kmacy/releng_7_2_fcs/sys/net/if_arc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_arc.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_arc.h Mon May 18 06:20:37 2009 (r192293) @@ -133,7 +133,7 @@ void arc_storelladdr(struct ifnet *, u_i int arc_isphds(u_int8_t); void arc_input(struct ifnet *, struct mbuf *); int arc_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); int arc_ioctl(struct ifnet *, int, caddr_t); void arc_frag_init(struct ifnet *); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c Mon May 18 06:20:37 2009 (r192293) @@ -102,7 +102,7 @@ u_int8_t arcbroadcastaddr = 0; */ int arc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt0) + struct route *ro) { struct arc_header *ah; int error; @@ -129,7 +129,8 @@ arc_output(struct ifnet *ifp, struct mbu else if (ifp->if_flags & IFF_NOARP) adst = ntohl(SIN(dst)->sin_addr.s_addr) & 0xFF; else { - error = arpresolve(ifp, rt0, m, dst, &adst, &lle); + error = arpresolve(ifp, ro ? ro->ro_rt : NULL, + m, dst, &adst, &lle); if (error) return (error == EWOULDBLOCK ? 0 : error); } Modified: user/kmacy/releng_7_2_fcs/sys/net/if_atm.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_atm.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_atm.h Mon May 18 06:20:37 2009 (r192293) @@ -293,7 +293,7 @@ void atm_ifdetach(struct ifnet *); void atm_input(struct ifnet *, struct atm_pseudohdr *, struct mbuf *, void *); int atm_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int, struct mtx *, int); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_atmsubr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_atmsubr.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_atmsubr.c Mon May 18 06:20:37 2009 (r192293) @@ -113,17 +113,17 @@ MALLOC_DEFINE(M_IFATM, "ifatm", "atm int * "ifp" = ATM interface to output to * "m0" = the packet to output * "dst" = the sockaddr to send to (either IP addr, or raw VPI/VCI) - * "rt0" = the route to use + * "ro" = the route to use * returns: error code [0 == ok] * * note: special semantic: if (dst == NULL) then we assume "m" already * has an atm_pseudohdr on it and just send it directly. * [for native mode ATM output] if dst is null, then - * rt0 must also be NULL. + * ro->ro_rt must also be NULL. */ int atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, - struct rtentry *rt0) + struct route *ro) { u_int16_t etype = 0; /* if using LLC/SNAP */ int error = 0, sz; @@ -157,7 +157,7 @@ atm_output(struct ifnet *ifp, struct mbu etype = ETHERTYPE_IPV6; else etype = ETHERTYPE_IP; - if (!atmresolve(rt0, m, dst, &atmdst)) { + if (!atmresolve(ro->ro_rt, m, dst, &atmdst)) { m = NULL; /* XXX: atmresolve already free'd it */ senderr(EHOSTUNREACH); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_disc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_disc.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_disc.c Mon May 18 06:20:37 2009 (r192293) @@ -66,7 +66,7 @@ struct disc_softc { }; static int discoutput(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); static void discrtrequest(int, struct rtentry *, struct rt_addrinfo *); static int discioctl(struct ifnet *, u_long, caddr_t); static int disc_clone_create(struct if_clone *, int, caddr_t); @@ -156,7 +156,7 @@ DECLARE_MODULE(if_disc, disc_mod, SI_SUB static int discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { u_int32_t af; Modified: user/kmacy/releng_7_2_fcs/sys/net/if_enc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_enc.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_enc.c Mon May 18 06:20:37 2009 (r192293) @@ -85,7 +85,7 @@ struct enc_softc { static int enc_ioctl(struct ifnet *, u_long, caddr_t); static int enc_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); + struct sockaddr *dst, struct route *ro); static int enc_clone_create(struct if_clone *, int, caddr_t); static void enc_clone_destroy(struct ifnet *); @@ -185,7 +185,7 @@ DECLARE_MODULE(enc, enc_mod, SI_SUB_PROT static int enc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { m_freem(m); return (0); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_ethersubr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_ethersubr.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_ethersubr.c Mon May 18 06:20:37 2009 (r192293) @@ -163,17 +163,22 @@ static int ether_ipfw; */ int ether_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { short type; - int error, hdrcmplt = 0; + int error = 0, hdrcmplt = 0; u_char esrc[ETHER_ADDR_LEN], edst[ETHER_ADDR_LEN]; struct llentry *lle = NULL; + struct rtentry *rt0 = NULL; struct ether_header *eh; struct pf_mtag *t; int loop_copy = 1; int hlen; /* link layer header length */ + if (ro != NULL) { + lle = ro->ro_lle; + rt0 = ro->ro_rt; + } #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) @@ -191,7 +196,10 @@ ether_output(struct ifnet *ifp, struct m switch (dst->sa_family) { #ifdef INET case AF_INET: - error = arpresolve(ifp, rt0, m, dst, edst, &lle); + if (lle != NULL && (lle->la_flags & LLE_VALID)) + memcpy(edst, &lle->ll_addr.mac16, sizeof(edst)); + else + error = arpresolve(ifp, rt0, m, dst, edst, &lle); if (error) return (error == EWOULDBLOCK ? 0 : error); type = htons(ETHERTYPE_IP); @@ -226,7 +234,10 @@ ether_output(struct ifnet *ifp, struct m #endif #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, &lle); + if (lle != NULL && (lle->la_flags & LLE_VALID)) + memcpy(edst, &lle->ll_addr.mac16, sizeof(edst)); + else + error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, &lle); if (error) return error; type = htons(ETHERTYPE_IPV6); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_faith.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_faith.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_faith.c Mon May 18 06:20:37 2009 (r192293) @@ -89,7 +89,7 @@ struct faith_softc { static int faithioctl(struct ifnet *, u_long, caddr_t); int faithoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void faithrtrequest(int, struct rtentry *, struct rt_addrinfo *); #ifdef INET6 static int faithprefix(struct in6_addr *); @@ -189,17 +189,20 @@ faith_clone_destroy(ifp) } int -faithoutput(ifp, m, dst, rt) +faithoutput(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt; + struct route *ro; { int isr; u_int32_t af; + struct rtentry *rt = NULL; M_ASSERTPKTHDR(m); + if (ro != NULL) + rt = ro->ro_rt; /* BPF writes need to be handled specially. */ if (dst->sa_family == AF_UNSPEC) { bcopy(dst->sa_data, &af, sizeof(af)); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_fddisubr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_fddisubr.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_fddisubr.c Mon May 18 06:20:37 2009 (r192293) @@ -98,7 +98,7 @@ static const u_char fddibroadcastaddr[FD static int fddi_resolvemulti(struct ifnet *, struct sockaddr **, struct sockaddr *); static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void fddi_input(struct ifnet *ifp, struct mbuf *m); #define senderr(e) do { error = (e); goto bad; } while (0) @@ -111,18 +111,21 @@ static void fddi_input(struct ifnet *ifp * Assumes that ifp is actually pointer to arpcom structure. */ static int -fddi_output(ifp, m, dst, rt0) +fddi_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt0; + struct route *ro; { u_int16_t type; int loop_copy = 0, error = 0, hdrcmplt = 0; u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN]; struct fddi_header *fh; struct llentry *lle; + struct rtentry *rt0 = NULL; + if (ro != NULL) + rt0 = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) Modified: user/kmacy/releng_7_2_fcs/sys/net/if_fwsubr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_fwsubr.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_fwsubr.c Mon May 18 06:20:37 2009 (r192293) @@ -77,7 +77,7 @@ struct fw_hwaddr firewire_broadcastaddr static int firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt0) + struct route *ro) { struct fw_com *fc = IFP2FWC(ifp); int error, type; @@ -138,7 +138,7 @@ firewire_output(struct ifnet *ifp, struc * doesn't fit into the arp model. */ if (unicast) { - error = arpresolve(ifp, rt0, m, dst, (u_char *) destfw, &lle); + error = arpresolve(ifp, ro ? ro->ro_rt : NULL, m, dst, (u_char *) destfw, &lle); if (error) return (error == EWOULDBLOCK ? 0 : error); } Modified: user/kmacy/releng_7_2_fcs/sys/net/if_gif.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_gif.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_gif.c Mon May 18 06:20:37 2009 (r192293) @@ -388,11 +388,11 @@ gif_start(struct ifnet *ifp) } int -gif_output(ifp, m, dst, rt) +gif_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt; /* added in net2 */ + struct route *ro; { INIT_VNET_GIF(ifp->if_vnet); struct gif_softc *sc = ifp->if_softc; Modified: user/kmacy/releng_7_2_fcs/sys/net/if_gif.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_gif.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_gif.h Mon May 18 06:20:37 2009 (r192293) @@ -106,7 +106,7 @@ struct etherip_header { /* Prototypes */ void gif_input(struct mbuf *, int, struct ifnet *); int gif_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); int gif_ioctl(struct ifnet *, u_long, caddr_t); int gif_set_tunnel(struct ifnet *, struct sockaddr *, struct sockaddr *); void gif_delete_tunnel(struct ifnet *); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_gre.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_gre.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_gre.c Mon May 18 06:20:37 2009 (r192293) @@ -110,7 +110,7 @@ static int gre_clone_create(struct if_cl static void gre_clone_destroy(struct ifnet *); static int gre_ioctl(struct ifnet *, u_long, caddr_t); static int gre_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *rt); + struct route *ro); IFC_SIMPLE_DECLARE(gre, 0); @@ -240,7 +240,7 @@ gre_clone_destroy(ifp) */ static int gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { #ifdef INET6 INIT_VNET_INET(ifp->if_vnet); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_iso88025subr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_iso88025subr.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_iso88025subr.c Mon May 18 06:20:37 2009 (r192293) @@ -232,11 +232,11 @@ iso88025_ioctl(struct ifnet *ifp, int co * ISO88025 encapsulation */ int -iso88025_output(ifp, m, dst, rt0) +iso88025_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt0; + struct route *ro; { u_int16_t snap_type = 0; int loop_copy = 0, error = 0, rif_len = 0; @@ -245,6 +245,10 @@ iso88025_output(ifp, m, dst, rt0) struct iso88025_header gen_th; struct sockaddr_dl *sdl = NULL; struct llentry *lle; + struct rtentry *rt0 = NULL; + + if (ro != NULL) + rt0 = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_lagg.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_lagg.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_lagg.c Mon May 18 06:20:37 2009 (r192293) @@ -93,7 +93,7 @@ static void lagg_linkstate(struct lagg_s static void lagg_port_state(struct ifnet *, int); static int lagg_port_ioctl(struct ifnet *, u_long, caddr_t); static int lagg_port_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); static void lagg_port_ifdetach(void *arg __unused, struct ifnet *); static int lagg_port_checkstacking(struct lagg_softc *); static void lagg_port2req(struct lagg_port *, struct lagg_reqport *); @@ -676,7 +676,7 @@ fallback: static int lagg_port_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { struct lagg_port *lp = ifp->if_lagg; struct ether_header *eh; @@ -696,7 +696,7 @@ lagg_port_output(struct ifnet *ifp, stru */ switch (ntohs(type)) { case ETHERTYPE_PAE: /* EAPOL PAE/802.1x */ - return ((*lp->lp_output)(ifp, m, dst, rt0)); + return ((*lp->lp_output)(ifp, m, dst, ro)); } /* drop any other frames */ Modified: user/kmacy/releng_7_2_fcs/sys/net/if_lagg.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_lagg.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_lagg.h Mon May 18 06:20:37 2009 (r192293) @@ -218,7 +218,7 @@ struct lagg_port { /* Redirected callbacks */ int (*lp_ioctl)(struct ifnet *, u_long, caddr_t); int (*lp_output)(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); SLIST_ENTRY(lagg_port) lp_entries; }; Modified: user/kmacy/releng_7_2_fcs/sys/net/if_loop.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_loop.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_loop.c Mon May 18 06:20:37 2009 (r192293) @@ -98,7 +98,7 @@ int loioctl(struct ifnet *, u_long, caddr_t); static void lortrequest(int, struct rtentry *, struct rt_addrinfo *); int looutput(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); + struct sockaddr *dst, struct route *ro); static int lo_clone_create(struct if_clone *, int, caddr_t); static void lo_clone_destroy(struct ifnet *); @@ -178,15 +178,18 @@ DECLARE_MODULE(loop, loop_mod, SI_SUB_PR int looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { u_int32_t af; + struct rtentry *rt = NULL; #ifdef MAC int error; #endif M_ASSERTPKTHDR(m); /* check if we have the packet header */ + if (ro != NULL) + rt = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) { Modified: user/kmacy/releng_7_2_fcs/sys/net/if_spppsubr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_spppsubr.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_spppsubr.c Mon May 18 06:20:37 2009 (r192293) @@ -263,7 +263,7 @@ static const u_short interactive_ports[8 int debug = ifp->if_flags & IFF_DEBUG static int sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); + struct sockaddr *dst, struct route *ro); static void sppp_cisco_send(struct sppp *sp, int type, long par1, long par2); static void sppp_cisco_input(struct sppp *sp, struct mbuf *m); @@ -786,7 +786,7 @@ sppp_ifstart(struct ifnet *ifp) */ static int sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt) + struct sockaddr *dst, struct route *ro) { struct sppp *sp = IFP2SP(ifp); struct ppp_header *h; Modified: user/kmacy/releng_7_2_fcs/sys/net/if_stf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_stf.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_stf.c Mon May 18 06:20:37 2009 (r192293) @@ -178,7 +178,7 @@ static int stfmodevent(module_t, int, vo static int stf_encapcheck(const struct mbuf *, int, int, void *); static struct in6_ifaddr *stf_getsrcifa6(struct ifnet *); static int stf_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static int isrfc1918addr(struct in_addr *); static int stf_checkaddr4(struct stf_softc *, struct in_addr *, struct ifnet *); @@ -403,11 +403,11 @@ stf_getsrcifa6(ifp) } static int -stf_output(ifp, m, dst, rt) +stf_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt; + struct route *ro; { struct stf_softc *sc; struct sockaddr_in6 *dst6; Modified: user/kmacy/releng_7_2_fcs/sys/net/if_tun.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_tun.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_tun.c Mon May 18 06:20:37 2009 (r192293) @@ -129,7 +129,7 @@ static int tunifioctl(struct ifnet *, u_ static int tuninit(struct ifnet *); static int tunmodevent(module_t, int, void *); static int tunoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *rt); + struct route *ro); static void tunstart(struct ifnet *); static int tun_clone_create(struct if_clone *, int, caddr_t); @@ -591,7 +591,7 @@ tunoutput( struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { struct tun_softc *tp = ifp->if_softc; u_short cached_tun_flags; Modified: user/kmacy/releng_7_2_fcs/sys/net/if_var.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_var.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/if_var.h Mon May 18 06:20:37 2009 (r192293) @@ -70,6 +70,7 @@ struct socket; struct ether_header; struct carp_if; struct ifvlantrunk; +struct route; #endif #include /* get TAILQ macros */ @@ -149,7 +150,7 @@ struct ifnet { /* procedure handles */ int (*if_output) /* output routine (enqueue) */ (struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); void (*if_input) /* input routine (from h/w driver) */ (struct ifnet *, struct mbuf *); void (*if_start) /* initiate output routine */ @@ -571,6 +572,12 @@ drbr_enqueue(struct ifnet *ifp, struct b int len = m->m_pkthdr.len; int mflags = m->m_flags; +#ifdef ALTQ + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_ENQUEUE(&ifp->if_snd, m, error); + return (error); + } +#endif if ((error = buf_ring_enqueue(br, m)) == ENOBUFS) { br->br_drops++; _IF_DROP(&ifp->if_snd); @@ -591,8 +598,31 @@ drbr_free(struct buf_ring *br, struct ma buf_ring_free(br, type); } + +static __inline struct mbuf * +drbr_dequeue(struct ifnet *ifp, struct buf_ring *br) +{ +#ifdef ALTQ + struct mbuf *m; + + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + return (m); + } #endif + return (buf_ring_dequeue_sc(br)); +} +static __inline int +drbr_empty(struct ifnet *ifp, struct buf_ring *br) +{ +#ifdef ALTQ + if (ALTQ_IS_ENABLED(&ifp->if_snd)) + return (IFQ_DRV_IS_EMPTY(&ifp->if_snd)); +#endif + return (buf_ring_empty(br)); +} +#endif /* * 72 was chosen below because it is the size of a TCP/IP * header (40) + the minimum mss (32). Modified: user/kmacy/releng_7_2_fcs/sys/net/iso88025.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/iso88025.h Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/iso88025.h Mon May 18 06:20:37 2009 (r192293) @@ -166,7 +166,7 @@ void iso88025_ifattach (struct ifnet *, void iso88025_ifdetach (struct ifnet *, int); int iso88025_ioctl (struct ifnet *, int , caddr_t ); int iso88025_output (struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); void iso88025_input (struct ifnet *, struct mbuf *); #endif Modified: user/kmacy/releng_7_2_fcs/sys/net/radix_mpath.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/radix_mpath.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/radix_mpath.c Mon May 18 06:20:37 2009 (r192293) @@ -77,15 +77,18 @@ rn_mpath_next(struct radix_node *rn) return NULL; } -u_int32_t +uint32_t rn_mpath_count(struct radix_node *rn) { - u_int32_t i; - - i = 1; - while ((rn = rn_mpath_next(rn)) != NULL) - i++; - return i; + uint32_t i = 0; + struct rtentry *rt; + + while (rn != NULL) { + rt = (struct rtentry *)rn; + i += rt->rt_rmx.rmx_weight; + rn = rn_mpath_next(rn); + } + return (i); } struct rtentry * @@ -256,10 +259,12 @@ different: } void -rtalloc_mpath_fib(struct route *ro, u_int32_t hash, u_int fibnum) +rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum) { struct radix_node *rn0, *rn; u_int32_t n; + struct rtentry *rt; + int64_t weight; /* * XXX we don't attempt to lookup cached route again; what should @@ -284,25 +289,31 @@ rtalloc_mpath_fib(struct route *ro, u_in /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ hash += hashjitter; hash %= n; - while (hash-- > 0 && rn) { + for (weight = abs((int32_t)hash), rt = ro->ro_rt; + weight >= rt->rt_rmx.rmx_weight && rn; + weight -= rt->rt_rmx.rmx_weight) { + /* stay within the multipath routes */ if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) break; rn = rn->rn_dupedkey; + rt = (struct rtentry *)rn; } - /* XXX try filling rt_gwroute and avoid unreachable gw */ - /* if gw selection fails, use the first match (default) */ + /* gw selection has failed - there must be only zero weight routes */ if (!rn) { RT_UNLOCK(ro->ro_rt); + ro->ro_rt = NULL; return; } - - RTFREE_LOCKED(ro->ro_rt); - ro->ro_rt = (struct rtentry *)rn; - RT_LOCK(ro->ro_rt); - RT_ADDREF(ro->ro_rt); + if (ro->ro_rt != rt) { + RTFREE_LOCKED(ro->ro_rt); + ro->ro_rt = (struct rtentry *)rn; + RT_LOCK(ro->ro_rt); + RT_ADDREF(ro->ro_rt); + + } RT_UNLOCK(ro->ro_rt); } Modified: user/kmacy/releng_7_2_fcs/sys/net/route.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/route.c Mon May 18 06:19:17 2009 (r192292) +++ user/kmacy/releng_7_2_fcs/sys/net/route.c Mon May 18 06:20:37 2009 (r192293) @@ -803,6 +803,103 @@ bad: return (error); } +#ifdef RADIX_MPATH +static int +rn_mpath_update(int req, struct rt_addrinfo *info, + struct radix_node_head *rnh, struct rtentry **ret_nrt) +{ + /* + * if we got multipath routes, we require users to specify + * a matching RTAX_GATEWAY. + */ + struct rtentry *rt, *rto = NULL; + register struct radix_node *rn; + int error = 0; + + rn = rnh->rnh_matchaddr(dst, rnh); + if (rn == NULL) + return (ESRCH); + rto = rt = RNTORT(rn); + rt = rt_mpath_matchgate(rt, gateway); + if (rt == NULL) + return (ESRCH); + /* + * this is the first entry in the chain + */ + if (rto == rt) { + rn = rn_mpath_next((struct radix_node *)rt); + /* + * there is another entry, now it's active + */ + if (rn) { + rto = RNTORT(rn); + RT_LOCK(rto); + rto->rt_flags |= RTF_UP; + RT_UNLOCK(rto); + } else if (rt->rt_flags & RTF_GATEWAY) { + /* + * For gateway routes, we need to + * make sure that we we are deleting + * the correct gateway. + * rt_mpath_matchgate() does not + * check the case when there is only + * one route in the chain. + */ + if (gateway && + (rt->rt_gateway->sa_len != gateway->sa_len || + memcmp(rt->rt_gateway, gateway, gateway->sa_len))) + error = ESRCH; + goto done; + } + /* + * use the normal delete code to remove + * the first entry + */ + if (req != RTM_DELETE) + goto nondelete; + + error = ENOENT; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon May 18 06:46:35 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84051106564A; Mon, 18 May 2009 06:46:35 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 714A98FC1A; Mon, 18 May 2009 06:46:35 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4I6kZKP052573; Mon, 18 May 2009 06:46:35 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4I6kYrv052564; Mon, 18 May 2009 06:46:34 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905180646.n4I6kYrv052564@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 06:46:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192295 - in user/kmacy/releng_7_2_fcs/sys: amd64/conf conf dev/e1000 i386/conf net netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 06:46:35 -0000 Author: kmacy Date: Mon May 18 06:46:34 2009 New Revision: 192295 URL: http://svn.freebsd.org/changeset/base/192295 Log: Import changes from HEAD 191038 191154 add utility routine for updating an struct llentry * 191158 191159 191160 191161 191162 191221 191255 191257 191258 191259 191324 191440 191441 191442 191603 191611 191612 Added: user/kmacy/releng_7_2_fcs/sys/net/flowtable.c user/kmacy/releng_7_2_fcs/sys/net/flowtable.h Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS user/kmacy/releng_7_2_fcs/sys/conf/NOTES user/kmacy/releng_7_2_fcs/sys/conf/files user/kmacy/releng_7_2_fcs/sys/conf/options user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.c user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.h user/kmacy/releng_7_2_fcs/sys/i386/conf/DEFAULTS user/kmacy/releng_7_2_fcs/sys/net/if.c user/kmacy/releng_7_2_fcs/sys/net/if_bridge.c user/kmacy/releng_7_2_fcs/sys/net/if_llatbl.c user/kmacy/releng_7_2_fcs/sys/net/if_llatbl.h user/kmacy/releng_7_2_fcs/sys/net/if_var.h user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_input.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c user/kmacy/releng_7_2_fcs/sys/netinet/vinet.h Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS Mon May 18 06:32:38 2009 (r192294) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/DEFAULTS Mon May 18 06:46:34 2009 (r192295) @@ -16,9 +16,9 @@ device io # I/O device device uart_ns8250 # Default partitioning schemes -options GEOM_BSD -options GEOM_MBR - -# KSE support went from being default to a kernel option -options KSE options VIMAGE_GLOBALS +options GEOM_PART_BSD +options GEOM_PART_MBR + +options FLOWTABLE + Modified: user/kmacy/releng_7_2_fcs/sys/conf/NOTES ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/NOTES Mon May 18 06:32:38 2009 (r192294) +++ user/kmacy/releng_7_2_fcs/sys/conf/NOTES Mon May 18 06:46:34 2009 (r192295) @@ -549,6 +549,9 @@ options LIBMCHAIN # libalias library, performing NAT options LIBALIAS +# flowtable cache +options FLOWTABLE + # # SCTP is a NEW transport protocol defined by # RFC2960 updated by RFC3309 and RFC3758.. and Modified: user/kmacy/releng_7_2_fcs/sys/conf/files ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/files Mon May 18 06:32:38 2009 (r192294) +++ user/kmacy/releng_7_2_fcs/sys/conf/files Mon May 18 06:46:34 2009 (r192295) @@ -1806,6 +1806,7 @@ net/bpf_filter.c optional bpf | netgrap net/bpf_zerocopy.c optional bpf net/bridgestp.c optional bridge | if_bridge net/bsd_comp.c optional ppp_bsdcomp +net/flowtable.c optional flowtable net/ieee8023ad_lacp.c optional lagg net/if.c standard net/if_arcsubr.c optional arcnet Modified: user/kmacy/releng_7_2_fcs/sys/conf/options ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/options Mon May 18 06:32:38 2009 (r192294) +++ user/kmacy/releng_7_2_fcs/sys/conf/options Mon May 18 06:46:34 2009 (r192295) @@ -405,6 +405,7 @@ VLAN_ARRAY opt_vlan.h XBONEHACK KRPC NFSLOCKD +FLOWTABLE opt_route.h # # SCTP Modified: user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.c Mon May 18 06:32:38 2009 (r192294) +++ user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.c Mon May 18 06:46:34 2009 (r192295) @@ -893,6 +893,7 @@ em_detach(device_t dev) if_free(ifp); drbr_free(adapter->br, M_DEVBUF); + drbr_free(adapter->br, M_DEVBUF); em_free_transmit_structures(adapter); em_free_receive_structures(adapter); @@ -987,7 +988,7 @@ em_resume(device_t dev) * the packet is requeued. **********************************************************************/ -#ifdef IFNET_MULTIQUEUE +#ifdef IFNET_BUF_RING static int em_transmit_locked(struct ifnet *ifp, struct mbuf *m) { @@ -1000,68 +1001,63 @@ em_transmit_locked(struct ifnet *ifp, st || (!adapter->link_active)) { error = drbr_enqueue(ifp, adapter->br, m); return (error); - } - - if (buf_ring_empty(adapter->br) && + } else if (ADAPTER_RING_EMPTY(adapter) && (adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD)) { if (em_xmit(adapter, &m)) { - if (m && (error = drbr_enqueue(ifp, adapter->br, m)) != 0) { + if (m && (error = drbr_enqueue(ifp, adapter->br, m)) != 0) return (error); - } - } else{ - /* Send a copy of the frame to the BPF listener */ + } else { + /* + * We've bypassed the buf ring so we need to update + * ifp directly + */ + drbr_stats_update(ifp, m->m_pkthdr.len, m->m_flags); + /* + ** Send a copy of the frame to the BPF + ** listener and set the watchdog on. + */ ETHER_BPF_MTAP(ifp, m); } } else if ((error = drbr_enqueue(ifp, adapter->br, m)) != 0) return (error); - if (!buf_ring_empty(adapter->br)) + if (!ADAPTER_RING_EMPTY(adapter)) em_start_locked(ifp); return (0); } -static void -em_start_locked(struct ifnet *ifp) +static int +em_transmit(struct ifnet *ifp, struct mbuf *m) { - struct adapter *adapter = ifp->if_softc; - struct mbuf *m_head; - - EM_TX_LOCK_ASSERT(adapter); - - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING) - return; - if (!adapter->link_active) - return; - - while ((adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD) - && (!buf_ring_empty(adapter->br))) { + + struct adapter *adapter = ifp->if_softc; + int error = 0; - m_head = buf_ring_dequeue_sc(adapter->br); - if (m_head == NULL) - break; - /* - * Encapsulation can modify our pointer, and or make it - * NULL on failure. In that event, we can't requeue. - */ - if (em_xmit(adapter, &m_head)) { - if (m_head == NULL) - break; - break; - } + if(EM_TX_TRYLOCK(adapter)) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + error = em_transmit_locked(ifp, m); + EM_TX_UNLOCK(adapter); + } else + error = drbr_enqueue(ifp, adapter->br, m); - /* Send a copy of the frame to the BPF listener */ - ETHER_BPF_MTAP(ifp, m_head); + return (error); +} - /* Set timeout in case hardware has problems transmitting. */ - adapter->watchdog_timer = EM_TX_TIMEOUT; - } - if ((adapter->num_tx_desc_avail <= EM_TX_OP_THRESHOLD)) - ifp->if_drv_flags |= IFF_DRV_OACTIVE; +static void +em_qflush(struct ifnet *ifp) +{ + struct mbuf *m; + struct adapter *adapter = (struct adapter *)ifp->if_softc; + EM_TX_LOCK(adapter); + while ((m = buf_ring_dequeue_sc(adapter->br)) != NULL) + m_freem(m); + if_qflush(ifp); + EM_TX_UNLOCK(adapter); } -#else +#endif + static void em_start_locked(struct ifnet *ifp) { @@ -1076,9 +1072,10 @@ em_start_locked(struct ifnet *ifp) if (!adapter->link_active) return; - while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { + while ((adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD) + && (!ADAPTER_RING_EMPTY(adapter))) { - IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); + m_head = em_dequeue(ifp, adapter->br); if (m_head == NULL) break; /* @@ -1088,8 +1085,10 @@ em_start_locked(struct ifnet *ifp) if (em_xmit(adapter, &m_head)) { if (m_head == NULL) break; +#ifndef IFNET_BUF_RING ifp->if_drv_flags |= IFF_DRV_OACTIVE; IFQ_DRV_PREPEND(&ifp->if_snd, m_head); +#endif break; } @@ -1099,8 +1098,10 @@ em_start_locked(struct ifnet *ifp) /* Set timeout in case hardware has problems transmitting. */ adapter->watchdog_timer = EM_TX_TIMEOUT; } + if ((adapter->num_tx_desc_avail <= EM_TX_OP_THRESHOLD)) + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + } -#endif static void em_start(struct ifnet *ifp) @@ -1113,23 +1114,6 @@ em_start(struct ifnet *ifp) EM_TX_UNLOCK(adapter); } -static int -em_transmit(struct ifnet *ifp, struct mbuf *m) -{ - - struct adapter *adapter = ifp->if_softc; - int error = 0; - - if(EM_TX_TRYLOCK(adapter)) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - error = em_transmit_locked(ifp, m); - EM_TX_UNLOCK(adapter); - } else - error = drbr_enqueue(ifp, adapter->br, m); - - return (error); -} - /********************************************************************* * Ioctl entry point * @@ -1693,11 +1677,7 @@ em_poll(struct ifnet *ifp, enum poll_cmd EM_TX_LOCK(adapter); em_txeof(adapter); -#ifdef IFNET_MULTIQUEUE - if (!buf_ring_empty(adapter->br)) -#else - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) -#endif + if (!ADAPTER_RING_EMPTY(adapter)) em_start_locked(ifp); EM_TX_UNLOCK(adapter); } @@ -1767,13 +1747,7 @@ em_intr(void *arg) if (ifp->if_drv_flags & IFF_DRV_RUNNING && -#ifdef IFNET_MULTIQUEUE - !buf_ring_empty(adapter->br) -#else - !IFQ_DRV_IS_EMPTY(&ifp->if_snd) -#endif - ) - + !ADAPTER_RING_EMPTY(adapter)) em_start(ifp); } @@ -1812,11 +1786,7 @@ em_handle_rxtx(void *context, int pendin EM_TX_LOCK(adapter); em_txeof(adapter); -#ifdef IFNET_MULTIQUEUE - if (!buf_ring_empty(adapter->br)) -#else - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) -#endif + if (!ADAPTER_RING_EMPTY(adapter)) em_start_locked(ifp); EM_TX_UNLOCK(adapter); } @@ -1824,43 +1794,6 @@ em_handle_rxtx(void *context, int pendin em_enable_intr(adapter); } -static void -em_handle_rx(void *context, int pending) -{ - struct adapter *adapter = context; - struct ifnet *ifp = adapter->ifp; - - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && - (em_rxeof(adapter, adapter->rx_process_limit) != 0)) - taskqueue_enqueue(adapter->tq, &adapter->rx_task); - -} - -static void -em_handle_tx(void *context, int pending) -{ - struct adapter *adapter = context; - struct ifnet *ifp = adapter->ifp; - - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { -#ifdef IFNET_MULTIQUEUE - if (!EM_TX_TRYLOCK(adapter)) - return; -#else - EM_TX_LOCK(adapter); -#endif - - em_txeof(adapter); -#ifdef IFNET_MULTIQUEUE - if (!buf_ring_empty(adapter->br)) -#else - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) -#endif - em_start_locked(ifp); - EM_TX_UNLOCK(adapter); - } -} - /********************************************************************* * * Fast Legacy/MSI Combined Interrupt Service routine @@ -1989,6 +1922,35 @@ em_msix_link(void *arg) EM_MSIX_LINK | E1000_IMS_LSC); return; } + +static void +em_handle_rx(void *context, int pending) +{ + struct adapter *adapter = context; + struct ifnet *ifp = adapter->ifp; + + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && + (em_rxeof(adapter, adapter->rx_process_limit) != 0)) + taskqueue_enqueue(adapter->tq, &adapter->rx_task); + +} + +static void +em_handle_tx(void *context, int pending) +{ + struct adapter *adapter = context; + struct ifnet *ifp = adapter->ifp; + + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (!EM_TX_TRYLOCK(adapter)) + return; + + em_txeof(adapter); + if (!ADAPTER_RING_EMPTY(adapter)) + em_start_locked(ifp); + EM_TX_UNLOCK(adapter); + } +} #endif /* EM_FAST_IRQ */ /********************************************************************* @@ -2646,6 +2608,8 @@ em_local_timer(void *arg) EM_CORE_LOCK_ASSERT(adapter); taskqueue_enqueue(adapter->tq, &adapter->rxtx_task); + taskqueue_enqueue(adapter->tq, + &adapter->rxtx_task); em_update_link_status(adapter); em_update_stats_counters(adapter); @@ -2990,6 +2954,11 @@ em_allocate_msix(struct adapter *adapter */ TASK_INIT(&adapter->rx_task, 0, em_handle_rx, adapter); TASK_INIT(&adapter->tx_task, 0, em_handle_tx, adapter); + /* + * Handle compatibility for msi case for deferral due to + * trylock failure + */ + TASK_INIT(&adapter->rxtx_task, 0, em_handle_tx, adapter); TASK_INIT(&adapter->link_task, 0, em_handle_link, adapter); adapter->tq = taskqueue_create_fast("em_taskq", M_NOWAIT, taskqueue_thread_enqueue, &adapter->tq); @@ -3244,6 +3213,11 @@ em_setup_interface(device_t dev, struct adapter->br = buf_ring_alloc(2048, M_DEVBUF, M_WAITOK, &adapter->tx_mtx); #endif +#ifdef IFNET_BUF_RING + ifp->if_transmit = em_transmit; + ifp->if_qflush = em_qflush; + adapter->br = buf_ring_alloc(2048, M_DEVBUF, M_WAITOK, &adapter->tx_mtx); +#endif if (adapter->hw.mac.type >= e1000_82543) { int version_cap; #if __FreeBSD_version < 700000 Modified: user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.h Mon May 18 06:32:38 2009 (r192294) +++ user/kmacy/releng_7_2_fcs/sys/dev/e1000/if_em.h Mon May 18 06:46:34 2009 (r192295) @@ -36,7 +36,7 @@ #ifndef _EM_H_DEFINED_ #define _EM_H_DEFINED_ -#define IFNET_MULTIQUEUE +#define IFNET_BUF_RING /* Tunables */ /* @@ -302,8 +302,10 @@ struct em_dma_alloc { /* Our adapter structure */ struct adapter { struct ifnet *ifp; -#ifdef IFNET_MULTIQUEUE +#ifdef IFNET_BUF_RING struct buf_ring *br; +#else + void *br; #endif struct e1000_hw hw; @@ -494,4 +496,27 @@ typedef struct _DESCRIPTOR_PAIR #define EM_CORE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->core_mtx, MA_OWNED) #define EM_TX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->tx_mtx, MA_OWNED) +#ifdef IFNET_BUF_RING +#define ADAPTER_RING_EMPTY(adapter) drbr_empty((adapter)->ifp, (adapter)->br) +#define em_dequeue drbr_dequeue + +#else +#define ADAPTER_RING_EMPTY(adapter) IFQ_DRV_IS_EMPTY(&((adapter)->ifp->if_snd)) +#define drbr_free(br, type) +static __inline struct mbuf * +em_dequeue(struct ifnet *ifp, struct buf_ring *br) +{ + struct mbuf *m; + + IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + return (m); +} +#ifdef BUF_RING_UNDEFINED + +struct buf_ring { +}; + +#endif +#endif + #endif /* _EM_H_DEFINED_ */ Modified: user/kmacy/releng_7_2_fcs/sys/i386/conf/DEFAULTS ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/conf/DEFAULTS Mon May 18 06:32:38 2009 (r192294) +++ user/kmacy/releng_7_2_fcs/sys/i386/conf/DEFAULTS Mon May 18 06:46:34 2009 (r192295) @@ -23,6 +23,9 @@ device uart_ns8250 options GEOM_BSD options GEOM_MBR -# KSE support went from being default to a kernel option -options KSE options VIMAGE_GLOBALS +# enable support for native hardware +options NATIVE +device atpic + +options FLOWTABLE Added: user/kmacy/releng_7_2_fcs/sys/net/flowtable.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_fcs/sys/net/flowtable.c Mon May 18 06:46:34 2009 (r192295) @@ -0,0 +1,1076 @@ +/************************************************************************** + +Copyright (c) 2008-2009, BitGravity Inc. +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. Neither the name of the BitGravity Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 "opt_route.h" +#include "opt_mpath.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Taken from http://burtleburtle.net/bob/c/lookup3.c + */ + +#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) + +/* +------------------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. + +This is reversible, so any information in (a,b,c) before mix() is +still in (a,b,c) after mix(). + +If four pairs of (a,b,c) inputs are run through mix(), or through +mix() in reverse, there are at least 32 bits of the output that +are sometimes the same for one pair and different for another pair. +This was tested for: +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that +satisfy this are + 4 6 8 16 19 4 + 9 15 3 18 27 15 + 14 9 3 7 17 3 +Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing +for "differ" defined as + with a one-bit base and a two-bit delta. I +used http://burtleburtle.net/bob/hash/avalanche.html to choose +the operations, constants, and arrangements of the variables. + +This does not achieve avalanche. There are input bits of (a,b,c) +that fail to affect some output bits of (a,b,c), especially of a. The +most thoroughly mixed value is c, but it doesn't really even achieve +avalanche in c. + +This allows some parallelism. Read-after-writes are good at doubling +the number of bits affected, so the goal of mixing pulls in the opposite +direction as the goal of parallelism. I did what I could. Rotates +seem to cost as much as shifts on every machine I could lay my hands +on, and rotates are much kinder to the top and bottom bits, so I used +rotates. +------------------------------------------------------------------------------- +*/ +#define mix(a,b,c) \ +{ \ + a -= c; a ^= rot(c, 4); c += b; \ + b -= a; b ^= rot(a, 6); a += c; \ + c -= b; c ^= rot(b, 8); b += a; \ + a -= c; a ^= rot(c,16); c += b; \ + b -= a; b ^= rot(a,19); a += c; \ + c -= b; c ^= rot(b, 4); b += a; \ +} + +/* +------------------------------------------------------------------------------- +final -- final mixing of 3 32-bit values (a,b,c) into c + +Pairs of (a,b,c) values differing in only a few bits will usually +produce values of c that look totally different. This was tested for +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +These constants passed: + 14 11 25 16 4 14 24 + 12 14 25 16 4 14 24 +and these came close: + 4 8 15 26 3 22 24 + 10 8 15 26 3 22 24 + 11 8 15 26 3 22 24 +------------------------------------------------------------------------------- +*/ +#define final(a,b,c) \ +{ \ + c ^= b; c -= rot(b,14); \ + a ^= c; a -= rot(c,11); \ + b ^= a; b -= rot(a,25); \ + c ^= b; c -= rot(b,16); \ + a ^= c; a -= rot(c,4); \ + b ^= a; b -= rot(a,14); \ + c ^= b; c -= rot(b,24); \ +} + +/* +-------------------------------------------------------------------- + This works on all machines. To be useful, it requires + -- that the key be an array of uint32_t's, and + -- that the length be the number of uint32_t's in the key + + The function hashword() is identical to hashlittle() on little-endian + machines, and identical to hashbig() on big-endian machines, + except that the length has to be measured in uint32_ts rather than in + bytes. hashlittle() is more complicated than hashword() only because + hashlittle() has to dance around fitting the key bytes into registers. +-------------------------------------------------------------------- +*/ +static uint32_t hashword( +const uint32_t *k, /* the key, an array of uint32_t values */ +size_t length, /* the length of the key, in uint32_ts */ +uint32_t initval) /* the previous hash, or an arbitrary value */ +{ + uint32_t a,b,c; + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + (((uint32_t)length)<<2) + initval; + + /*------------------------------------------------- handle most of the key */ + while (length > 3) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 3; + k += 3; + } + + /*------------------------------------------- handle the last 3 uint32_t's */ + switch(length) /* all the case statements fall through */ + { + case 3 : c+=k[2]; + case 2 : b+=k[1]; + case 1 : a+=k[0]; + final(a,b,c); + case 0: /* case 0: nothing left to add */ + break; + } + /*------------------------------------------------------ report the result */ + return c; +} + + +struct ipv4_tuple { + uint16_t ip_sport; /* source port */ + uint16_t ip_dport; /* destination port */ + in_addr_t ip_saddr; /* source address */ + in_addr_t ip_daddr; /* destination address */ +}; + +union ipv4_flow { + struct ipv4_tuple ipf_ipt; + uint32_t ipf_key[3]; +}; + +struct ipv6_tuple { + uint16_t ip_sport; /* source port */ + uint16_t ip_dport; /* destination port */ + struct in6_addr ip_saddr; /* source address */ + struct in6_addr ip_daddr; /* destination address */ +}; + +union ipv6_flow { + struct ipv6_tuple ipf_ipt; + uint32_t ipf_key[9]; +}; + +struct flentry { + volatile uint32_t f_fhash; /* hash flowing forward */ + uint16_t f_flags; /* flow flags */ + uint8_t f_pad; /* alignment */ + uint8_t f_proto; /* protocol */ + uint32_t f_uptime; /* uptime at last access */ + struct flentry *f_next; /* pointer to collision entry */ + volatile struct rtentry *f_rt; /* rtentry for flow */ + volatile struct llentry *f_lle; /* llentry for flow */ +}; + +struct flentry_v4 { + struct flentry fl_entry; + union ipv4_flow fl_flow; +}; + +struct flentry_v6 { + struct flentry fl_entry; + union ipv6_flow fl_flow; +}; + +#define fl_fhash fl_entry.fl_fhash +#define fl_flags fl_entry.fl_flags +#define fl_proto fl_entry.fl_proto +#define fl_uptime fl_entry.fl_uptime +#define fl_rt fl_entry.fl_rt +#define fl_lle fl_entry.fl_lle + +#define SECS_PER_HOUR 3600 +#define SECS_PER_DAY (24*SECS_PER_HOUR) + +#define SYN_IDLE 300 +#define UDP_IDLE 300 +#define FIN_WAIT_IDLE 600 +#define TCP_IDLE SECS_PER_DAY + + +typedef void fl_lock_t(struct flowtable *, uint32_t); +typedef void fl_rtalloc_t(struct route *, uint32_t, u_int); + +union flentryp { + struct flentry **global; + struct flentry **pcpu[MAXCPU]; +}; + +struct flowtable { + int ft_size; + int ft_lock_count; + uint32_t ft_flags; + uint32_t ft_collisions; + uint32_t ft_allocated; + uint32_t ft_misses; + uint64_t ft_hits; + + uint32_t ft_udp_idle; + uint32_t ft_fin_wait_idle; + uint32_t ft_syn_idle; + uint32_t ft_tcp_idle; + + fl_lock_t *ft_lock; + fl_lock_t *ft_unlock; + fl_rtalloc_t *ft_rtalloc; + struct mtx *ft_locks; + + + union flentryp ft_table; + bitstr_t *ft_masks[MAXCPU]; + bitstr_t *ft_tmpmask; + struct flowtable *ft_next; +}; + +static struct proc *flowcleanerproc; +static struct flowtable *flow_list_head; +static uint32_t hashjitter; +static uma_zone_t ipv4_zone; +static uma_zone_t ipv6_zone; + +/* + * TODO: + * - Make flowtable stats per-cpu, aggregated at sysctl call time, + * to avoid extra cache evictions caused by incrementing a shared + * counter + * - add IPv6 support to flow lookup + * - add sysctls to resize && flush flow tables + * - Add per flowtable sysctls for statistics and configuring timeouts + * - add saturation counter to rtentry to support per-packet load-balancing + * add flag to indicate round-robin flow, add list lookup from head + for flows + * - add sysctl / device node / syscall to support exporting and importing + * of flows with flag to indicate that a flow was imported so should + * not be considered for auto-cleaning + * - support explicit connection state (currently only ad-hoc for DSR) + */ +SYSCTL_NODE(_net_inet, OID_AUTO, flowtable, CTLFLAG_RD, NULL, "flowtable"); +int flowtable_enable = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, enable, CTLFLAG_RW, + &flowtable_enable, 0, "enable flowtable caching."); +static int flowtable_hits = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, hits, CTLFLAG_RD, + &flowtable_hits, 0, "# flowtable hits."); +static int flowtable_lookups = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, lookups, CTLFLAG_RD, + &flowtable_lookups, 0, "# flowtable lookups."); +static int flowtable_misses = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, misses, CTLFLAG_RD, + &flowtable_misses, 0, "#flowtable misses."); +static int flowtable_frees = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, frees, CTLFLAG_RD, + &flowtable_frees, 0, "#flows freed."); +static int flowtable_free_checks = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, free_checks, CTLFLAG_RD, + &flowtable_free_checks, 0, "#flows free checks."); +static int flowtable_max_depth = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, max_depth, CTLFLAG_RD, + &flowtable_max_depth, 0, "max collision list length."); +static int flowtable_collisions = 0; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, collisions, CTLFLAG_RD, + &flowtable_collisions, 0, "#flowtable collisions."); + +/* + * XXX This does not end up updating timeouts at runtime + * and only reflects the value for the last table added :-/ + */ +static int flowtable_syn_expire = SYN_IDLE; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, syn_expire, CTLFLAG_RW, + &flowtable_syn_expire, 0, "seconds after which to remove syn allocated flow."); +static int flowtable_udp_expire = UDP_IDLE; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, udp_expire, CTLFLAG_RW, + &flowtable_udp_expire, 0, "seconds after which to remove flow allocated to UDP."); +static int flowtable_fin_wait_expire = FIN_WAIT_IDLE; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, fin_wait_expire, CTLFLAG_RW, + &flowtable_fin_wait_expire, 0, "seconds after which to remove a flow in FIN_WAIT."); +static int flowtable_tcp_expire = TCP_IDLE; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, tcp_expire, CTLFLAG_RW, + &flowtable_tcp_expire, 0, "seconds after which to remove flow allocated to a TCP connection."); + + +/* + * Maximum number of flows that can be allocated of a given type. + * + * The table is allocated at boot time (for the pure caching case + * there is no reason why this could not be changed at runtime) + * and thus (currently) needs to be set with a tunable. + */ +static int nmbflows = 4096; + +static int +sysctl_nmbflows(SYSCTL_HANDLER_ARGS) +{ + int error, newnmbflows; + + newnmbflows = nmbflows; + error = sysctl_handle_int(oidp, &newnmbflows, 0, req); + if (error == 0 && req->newptr) { + if (newnmbflows > nmbflows) { + nmbflows = newnmbflows; + uma_zone_set_max(ipv4_zone, nmbflows); + uma_zone_set_max(ipv6_zone, nmbflows); + } else + error = EINVAL; + } + return (error); +} +SYSCTL_PROC(_net_inet_flowtable, OID_AUTO, nmbflows, CTLTYPE_INT|CTLFLAG_RW, + &nmbflows, 0, sysctl_nmbflows, "IU", "Maximum number of flows allowed"); + +#ifndef RADIX_MPATH +static void +in_rtalloc_ign_wrapper(struct route *ro, uint32_t hash, u_int fib) +{ + + in_rtalloc_ign(ro, 0, fib); +} +#endif + +static void +flowtable_global_lock(struct flowtable *table, uint32_t hash) +{ + int lock_index = (hash)&(table->ft_lock_count - 1); + + mtx_lock(&table->ft_locks[lock_index]); +} + +static void +flowtable_global_unlock(struct flowtable *table, uint32_t hash) +{ + int lock_index = (hash)&(table->ft_lock_count - 1); + + mtx_unlock(&table->ft_locks[lock_index]); +} + +static void +flowtable_pcpu_lock(struct flowtable *table, uint32_t hash) +{ + + critical_enter(); +} + +static void +flowtable_pcpu_unlock(struct flowtable *table, uint32_t hash) +{ + + mb(); + critical_exit(); +} + +#define FL_ENTRY_INDEX(table, hash)((hash) % (table)->ft_size) +#define FL_ENTRY(table, hash) *flowtable_entry((table), (hash)) +#define FL_ENTRY_LOCK(table, hash) (table)->ft_lock((table), (hash)) +#define FL_ENTRY_UNLOCK(table, hash) (table)->ft_unlock((table), (hash)) + +#define FL_STALE (1<<8) +#define FL_IPV6 (1<<9) + +static uint32_t +ipv4_flow_lookup_hash_internal(struct mbuf *m, struct route *ro, + uint32_t *key, uint16_t *flags, uint8_t *protop) +{ + uint16_t sport = 0, dport = 0; + struct ip *ip = NULL; + uint8_t proto = 0; + int iphlen; + uint32_t hash; + struct sockaddr_in *sin; + struct tcphdr *th; + struct udphdr *uh; + struct sctphdr *sh; + + if (flowtable_enable == 0) + return (0); + + key[1] = key[0] = 0; + sin = (struct sockaddr_in *)&ro->ro_dst; + if (m != NULL) { + ip = mtod(m, struct ip *); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_addr = ip->ip_dst; + } else + *flags &= ~FL_HASH_PORTS; + + key[2] = sin->sin_addr.s_addr; + + if ((*flags & FL_HASH_PORTS) == 0) + goto skipports; + + proto = ip->ip_p; + iphlen = ip->ip_hl << 2; /* XXX options? */ + key[1] = ip->ip_src.s_addr; + + switch (proto) { + case IPPROTO_TCP: + th = (struct tcphdr *)((caddr_t)ip + iphlen); + sport = ntohs(th->th_sport); + dport = ntohs(th->th_dport); + *flags |= th->th_flags; + if (*flags & TH_RST) + *flags |= FL_STALE; + break; + case IPPROTO_UDP: + uh = (struct udphdr *)((caddr_t)ip + iphlen); + sport = uh->uh_sport; + dport = uh->uh_dport; + break; + case IPPROTO_SCTP: + sh = (struct sctphdr *)((caddr_t)ip + iphlen); + sport = sh->src_port; + dport = sh->dest_port; + break; + default: + if (*flags & FL_HASH_PORTS) + goto noop; + /* no port - hence not a protocol we care about */ + break;; + + } + *protop = proto; + + /* + * If this is a transmit route cache then + * hash all flows to a given destination to + * the same bucket + */ + if ((*flags & FL_HASH_PORTS) == 0) + proto = sport = dport = 0; + + ((uint16_t *)key)[0] = sport; + ((uint16_t *)key)[1] = dport; + +skipports: + hash = hashword(key, 3, hashjitter + proto); + if (m != NULL && (m->m_flags & M_FLOWID) == 0) { + m->m_flags |= M_FLOWID; + m->m_pkthdr.flowid = hash; + } + + return (hash); +noop: + *protop = proto; + return (0); +} + +static bitstr_t * +flowtable_mask(struct flowtable *ft) +{ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon May 18 06:54:53 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D87F1065670; Mon, 18 May 2009 06:54:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B30D8FC14; Mon, 18 May 2009 06:54:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4I6srfJ052897; Mon, 18 May 2009 06:54:53 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4I6srca052889; Mon, 18 May 2009 06:54:53 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905180654.n4I6srca052889@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 06:54:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192296 - in user/kmacy/releng_7_2_fcs/sys: dev/cxgb net netinet netinet6 sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 06:54:54 -0000 Author: kmacy Date: Mon May 18 06:54:53 2009 New Revision: 192296 URL: http://svn.freebsd.org/changeset/base/192296 Log: merge fixes 191605 191606 191607 191608 191609 191610 191899 192009 192011 192085 192282 Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c user/kmacy/releng_7_2_fcs/sys/net/flowtable.c user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c user/kmacy/releng_7_2_fcs/sys/net/if_ef.c user/kmacy/releng_7_2_fcs/sys/netinet/in.c user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c Mon May 18 06:54:53 2009 (r192296) @@ -135,29 +135,6 @@ cxgb_pcpu_enqueue_packet_(struct sge_qse return (err); } -int -cxgb_pcpu_enqueue_packet(struct ifnet *ifp, struct mbuf *m) -{ - struct port_info *pi = ifp->if_softc; - struct sge_qset *qs; - int err = 0, qidx; -#ifdef IFNET_MULTIQUEUE - int32_t calc_cookie; - - calc_cookie = m->m_pkthdr.flowid; - qidx = cxgb_pcpu_cookie_to_qidx(pi, calc_cookie); -#else - qidx = 0; -#endif - qs = &pi->adapter->sge.qs[qidx]; - if (ALTQ_IS_ENABLED(&ifp->if_snd)) { - IFQ_ENQUEUE(qs->txq[0].txq_ifq, m, err); - } else { - err = cxgb_pcpu_enqueue_packet_(qs, m); - } - return (err); -} - static int cxgb_dequeue_packet(struct sge_txq *txq, struct mbuf **m_vec) { @@ -166,20 +143,7 @@ cxgb_dequeue_packet(struct sge_txq *txq, int count, size, coalesced; struct adapter *sc; -#ifndef IFNET_MULTIQUEUE - struct port_info *pi = txq->port; - - mtx_assert(&txq->lock, MA_OWNED); - if (txq->immpkt != NULL) - panic("immediate packet set"); - - IFQ_DRV_DEQUEUE(&pi->ifp->if_snd, m); - if (m == NULL) - return (0); - - m_vec[0] = m; - return (1); -#endif +#ifdef ALTQ if (ALTQ_IS_ENABLED(txq->txq_ifq)) { IFQ_DRV_DEQUEUE(txq->txq_ifq, m); if (m == NULL) @@ -188,7 +152,7 @@ cxgb_dequeue_packet(struct sge_txq *txq, m_vec[0] = m; return (1); } - +#endif mtx_assert(&txq->lock, MA_OWNED); coalesced = count = size = 0; qs = txq_to_qset(txq, TXQ_ETH); @@ -332,20 +296,14 @@ cxgb_pcpu_start_(struct sge_qset *qs, st } stopped = isset(&qs->txq_stopped, TXQ_ETH); - flush = (( -#ifdef IFNET_MULTIQUEUE - !buf_ring_empty(txq->txq_mr) -#else - !IFQ_DRV_IS_EMPTY(&pi->ifp->if_snd) -#endif + flush = ((!drbr_empty(pi->ifp, txq->txq_mr) && !stopped) || txq->immpkt); max_desc = tx_flush ? TX_ETH_Q_SIZE : TX_START_MAX_DESC; err = flush ? cxgb_tx(qs, max_desc) : 0; if ((tx_flush && flush && err == 0) && - (!buf_ring_empty(txq->txq_mr) || - !IFQ_DRV_IS_EMPTY(&pi->ifp->if_snd))) { + !drbr_empty(pi->ifp, txq->txq_mr)) { struct thread *td = curthread; if (++i > 1) { @@ -408,9 +366,6 @@ cxgb_start(struct ifnet *ifp) if (!p->link_config.link_ok) return; - if (IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - return; - cxgb_pcpu_transmit(ifp, NULL); } Modified: user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c Mon May 18 06:54:53 2009 (r192296) @@ -98,7 +98,6 @@ static void bstp_decode_bpdu(struct bstp struct bstp_config_unit *); static void bstp_send_bpdu(struct bstp_state *, struct bstp_port *, struct bstp_cbpdu *); -static void bstp_enqueue(struct ifnet *, struct mbuf *); static int bstp_pdu_flags(struct bstp_port *); static void bstp_received_stp(struct bstp_state *, struct bstp_port *, struct mbuf **, struct bstp_tbpdu *); @@ -262,7 +261,7 @@ bstp_transmit_tcn(struct bstp_state *bs, memcpy(mtod(m, caddr_t) + sizeof(*eh), &bpdu, sizeof(bpdu)); bp->bp_txcount++; - bstp_enqueue(ifp, m); + ifp->if_transmit(ifp, m); } static void @@ -391,18 +390,7 @@ bstp_send_bpdu(struct bstp_state *bs, st m->m_len = m->m_pkthdr.len; bp->bp_txcount++; - bstp_enqueue(ifp, m); -} - -static void -bstp_enqueue(struct ifnet *dst_ifp, struct mbuf *m) -{ - int err = 0; - - IFQ_ENQUEUE(&dst_ifp->if_snd, m, err); - - if ((dst_ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) - (*dst_ifp->if_start)(dst_ifp); + ifp->if_transmit(ifp, m); } static int Modified: user/kmacy/releng_7_2_fcs/sys/net/flowtable.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/flowtable.c Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/net/flowtable.c Mon May 18 06:54:53 2009 (r192296) @@ -438,7 +438,6 @@ static void flowtable_pcpu_unlock(struct flowtable *table, uint32_t hash) { - mb(); critical_exit(); } Modified: user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c Mon May 18 06:54:53 2009 (r192296) @@ -237,7 +237,7 @@ arc_output(struct ifnet *ifp, struct mbu BPF_MTAP(ifp, m); - IFQ_HANDOFF(ifp, m, error); + error = ifp->if_transmit(ifp, m); return (error); Modified: user/kmacy/releng_7_2_fcs/sys/net/if_ef.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if_ef.c Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/net/if_ef.c Mon May 18 06:54:53 2009 (r192296) @@ -222,7 +222,7 @@ ef_start(struct ifnet *ifp) if (m == 0) break; BPF_MTAP(ifp, m); - IFQ_HANDOFF(p, m, error); + error = p->if_transmit(p, m); if (error) { ifp->if_oerrors++; continue; Modified: user/kmacy/releng_7_2_fcs/sys/netinet/in.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/in.c Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/netinet/in.c Mon May 18 06:54:53 2009 (r192296) @@ -45,13 +45,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include +#include #include #include #include +#include #include #include @@ -728,6 +731,9 @@ in_ifinit(struct ifnet *ifp, struct in_i INIT_VNET_INET(ifp->if_vnet); register u_long i = ntohl(sin->sin_addr.s_addr); struct sockaddr_in oldaddr; + struct rtentry *rt = NULL; + struct rt_addrinfo info; + static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; int s = splimp(), flags = RTF_UP, error = 0; oldaddr = ia->ia_addr; @@ -816,6 +822,32 @@ in_ifinit(struct ifnet *ifp, struct in_i if ((error = in_addprefix(ia, flags)) != 0) return (error); + if (ia->ia_addr.sin_addr.s_addr == INADDR_ANY) + return (0); + + /* + * add a loopback route to self + */ + if (!(ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) { + bzero(&info, sizeof(info)); + info.rti_ifp = V_loif; + info.rti_flags = ia->ia_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = (struct sockaddr *)&ia->ia_addr; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl; + error = rtrequest1_fib(RTM_ADD, &info, &rt, 0); + + if (error == 0 && rt != NULL) { + RT_LOCK(rt); + ((struct sockaddr_dl *)rt->rt_gateway)->sdl_type = + rt->rt_ifp->if_type; + ((struct sockaddr_dl *)rt->rt_gateway)->sdl_index = + rt->rt_ifp->if_index; + RT_REMREF(rt); + RT_UNLOCK(rt); + } else if (error != 0) + log(LOG_INFO, "in_ifinit: insertion failed\n"); + } + return (error); } @@ -895,10 +927,29 @@ in_scrubprefix(struct in_ifaddr *target) struct in_ifaddr *ia; struct in_addr prefix, mask, p; int error; + struct rt_addrinfo info; + struct sockaddr_dl null_sdl; if ((target->ia_flags & IFA_ROUTE) == 0) return (0); + if ((target->ia_addr.sin_addr.s_addr != INADDR_ANY) && + !(target->ia_ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) { + bzero(&null_sdl, sizeof(null_sdl)); + null_sdl.sdl_len = sizeof(null_sdl); + null_sdl.sdl_family = AF_LINK; + null_sdl.sdl_type = V_loif->if_type; + null_sdl.sdl_index = V_loif->if_index; + bzero(&info, sizeof(info)); + info.rti_flags = target->ia_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = (struct sockaddr *)&target->ia_addr; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl; + error = rtrequest1_fib(RTM_DELETE, &info, NULL, 0); + + if (error != 0) + log(LOG_INFO, "in_scrubprefix: deletion failed\n"); + } + if (rtinitflags(target)) prefix = target->ia_dstaddr.sin_addr; else { @@ -1027,7 +1078,6 @@ in_ifdetach(struct ifnet *ifp) in_purgemaddrs(ifp); } -#include #include #include Modified: user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c Mon May 18 06:54:53 2009 (r192296) @@ -1148,6 +1148,28 @@ in6_purgeaddr(struct ifaddr *ifa) struct ifnet *ifp = ifa->ifa_ifp; struct in6_ifaddr *ia = (struct in6_ifaddr *) ifa; struct in6_multi_mship *imm; + struct sockaddr_in6 mltaddr, mltmask; + struct rtentry rt0; + struct sockaddr_dl gateway; + struct sockaddr_in6 mask, addr; + int plen, error; + struct rtentry *rt; + struct ifaddr *ifa0, *nifa; + + /* + * find another IPv6 address as the gateway for the + * link-local and node-local all-nodes multicast + * address routes + */ + TAILQ_FOREACH_SAFE(ifa0, &ifp->if_addrhead, ifa_link, nifa) { + if ((ifa0->ifa_addr->sa_family != AF_INET6) || + memcmp(&satosin6(ifa0->ifa_addr)->sin6_addr, + &ia->ia_addr.sin6_addr, + sizeof(struct in6_addr)) == 0) + continue; + else + break; + } /* stop DAD processing */ nd6_dad_stop(ifa); @@ -1156,7 +1178,25 @@ in6_purgeaddr(struct ifaddr *ifa) lla_lookup(LLTABLE6(ifp), (LLE_DELETE | LLE_IFADDR), (struct sockaddr *)&ia->ia_addr); IF_AFDATA_UNLOCK(ifp); - + + /* + * initialize for rtmsg generation + */ + bzero(&gateway, sizeof(gateway)); + gateway.sdl_len = sizeof(gateway); + gateway.sdl_family = AF_LINK; + gateway.sdl_nlen = 0; + gateway.sdl_alen = ifp->if_addrlen; + /* */ + bzero(&rt0, sizeof(rt0)); + rt0.rt_gateway = (struct sockaddr *)&gateway; + memcpy(&mask, &ia->ia_prefixmask, sizeof(ia->ia_prefixmask)); + memcpy(&addr, &ia->ia_addr, sizeof(ia->ia_addr)); + rt_mask(&rt0) = (struct sockaddr *)&mask; + rt_key(&rt0) = (struct sockaddr *)&addr; + rt0.rt_flags = RTF_HOST | RTF_STATIC; + rt_newaddrmsg(RTM_DELETE, ifa, 0, &rt0); + /* * leave from multicast groups we have joined for the interface */ @@ -1165,6 +1205,139 @@ in6_purgeaddr(struct ifaddr *ifa) in6_leavegroup(imm); } + /* + * remove the link-local all-nodes address + */ + bzero(&mltmask, sizeof(mltmask)); + mltmask.sin6_len = sizeof(struct sockaddr_in6); + mltmask.sin6_family = AF_INET6; + mltmask.sin6_addr = in6mask32; + + bzero(&mltaddr, sizeof(mltaddr)); + mltaddr.sin6_len = sizeof(struct sockaddr_in6); + mltaddr.sin6_family = AF_INET6; + mltaddr.sin6_addr = in6addr_linklocal_allnodes; + + if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != + 0) + goto cleanup; + + rt = rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL); + if (rt != NULL && rt->rt_gateway != NULL && + (memcmp(&satosin6(rt->rt_gateway)->sin6_addr, + &ia->ia_addr.sin6_addr, + sizeof(ia->ia_addr.sin6_addr)) == 0)) { + /* + * if no more IPv6 address exists on this interface + * then remove the multicast address route + */ + if (ifa0 == NULL) { + memcpy(&mltaddr.sin6_addr, &satosin6(rt_key(rt))->sin6_addr, + sizeof(mltaddr.sin6_addr)); + RTFREE_LOCKED(rt); + error = rtrequest(RTM_DELETE, (struct sockaddr *)&mltaddr, + (struct sockaddr *)&ia->ia_addr, + (struct sockaddr *)&mltmask, RTF_UP, + (struct rtentry **)0); + if (error) + log(LOG_INFO, "in6_purgeaddr: link-local all-nodes" + "multicast address deletion error\n"); + } else { + /* + * replace the gateway of the route + */ + struct sockaddr_in6 sa; + + bzero(&sa, sizeof(sa)); + sa.sin6_len = sizeof(struct sockaddr_in6); + sa.sin6_family = AF_INET6; + memcpy(&sa.sin6_addr, &satosin6(ifa0->ifa_addr)->sin6_addr, + sizeof(sa.sin6_addr)); + in6_setscope(&sa.sin6_addr, ifa0->ifa_ifp, NULL); + memcpy(rt->rt_gateway, &sa, sizeof(sa)); + RTFREE_LOCKED(rt); + } + } else { + if (rt != NULL) + RTFREE_LOCKED(rt); + } + + /* + * remove the node-local all-nodes address + */ + mltaddr.sin6_addr = in6addr_nodelocal_allnodes; + if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != + 0) + goto cleanup; + + rt = rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL); + if (rt != NULL && rt->rt_gateway != NULL && + (memcmp(&satosin6(rt->rt_gateway)->sin6_addr, + &ia->ia_addr.sin6_addr, + sizeof(ia->ia_addr.sin6_addr)) == 0)) { + /* + * if no more IPv6 address exists on this interface + * then remove the multicast address route + */ + if (ifa0 == NULL) { + memcpy(&mltaddr.sin6_addr, &satosin6(rt_key(rt))->sin6_addr, + sizeof(mltaddr.sin6_addr)); + + RTFREE_LOCKED(rt); + error = rtrequest(RTM_DELETE, (struct sockaddr *)&mltaddr, + (struct sockaddr *)&ia->ia_addr, + (struct sockaddr *)&mltmask, RTF_UP, + (struct rtentry **)0); + + if (error) + log(LOG_INFO, "in6_purgeaddr: node-local all-nodes" + "multicast address deletion error\n"); + } else { + /* + * replace the gateway of the route + */ + struct sockaddr_in6 sa; + + bzero(&sa, sizeof(sa)); + sa.sin6_len = sizeof(struct sockaddr_in6); + sa.sin6_family = AF_INET6; + memcpy(&sa.sin6_addr, &satosin6(ifa0->ifa_addr)->sin6_addr, + sizeof(sa.sin6_addr)); + in6_setscope(&sa.sin6_addr, ifa0->ifa_ifp, NULL); + memcpy(rt->rt_gateway, &sa, sizeof(sa)); + RTFREE_LOCKED(rt); + } + } else { + if (rt != NULL) + RTFREE_LOCKED(rt); + } + +cleanup: + + plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL); /* XXX */ + if ((ia->ia_flags & IFA_ROUTE) && plen == 128) { + int error; + struct sockaddr *dstaddr; + + /* + * use the interface address if configuring an + * interface address with a /128 prefix len + */ + if (ia->ia_dstaddr.sin6_family == AF_INET6) + dstaddr = (struct sockaddr *)&ia->ia_dstaddr; + else + dstaddr = (struct sockaddr *)&ia->ia_addr; + + error = rtrequest(RTM_DELETE, + (struct sockaddr *)dstaddr, + (struct sockaddr *)&ia->ia_addr, + (struct sockaddr *)&ia->ia_prefixmask, + ia->ia_flags | RTF_HOST, NULL); + if (error != 0) + return; + ia->ia_flags &= ~IFA_ROUTE; + } + in6_unlink_ifa(ia, ifp); } @@ -1565,6 +1738,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 /* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */ if (newhost) { struct llentry *ln; + struct rtentry rt; + struct sockaddr_dl gateway; + struct sockaddr_in6 mask, addr; IF_AFDATA_LOCK(ifp); ia->ia_ifa.ifa_rtrequest = NULL; @@ -1578,8 +1754,27 @@ in6_ifinit(struct ifnet *ifp, struct in6 if (ln != NULL) { ln->la_expire = 0; /* for IPv6 this means permanent */ ln->ln_state = ND6_LLINFO_REACHABLE; + /* + * initialize for rtmsg generation + */ + bzero(&gateway, sizeof(gateway)); + gateway.sdl_len = sizeof(gateway); + gateway.sdl_family = AF_LINK; + gateway.sdl_nlen = 0; + gateway.sdl_alen = 6; + memcpy(gateway.sdl_data, &ln->ll_addr.mac_aligned, sizeof(ln->ll_addr)); + /* */ LLE_WUNLOCK(ln); } + + bzero(&rt, sizeof(rt)); + rt.rt_gateway = (struct sockaddr *)&gateway; + memcpy(&mask, &ia->ia_prefixmask, sizeof(ia->ia_prefixmask)); + memcpy(&addr, &ia->ia_addr, sizeof(ia->ia_addr)); + rt_mask(&rt) = (struct sockaddr *)&mask; + rt_key(&rt) = (struct sockaddr *)&addr; + rt.rt_flags = RTF_UP | RTF_HOST | RTF_STATIC; + rt_newaddrmsg(RTM_ADD, &ia->ia_ifa, 0, &rt); } return (error); Modified: user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h Mon May 18 06:46:34 2009 (r192295) +++ user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h Mon May 18 06:54:53 2009 (r192296) @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright (c) 2007,2008 Kip Macy kmacy@freebsd.org + * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,7 +69,10 @@ struct buf_ring { void *br_ring[0]; }; - +/* + * multi-producer safe lock-free ring buffer enqueue + * + */ static __inline int buf_ring_enqueue(struct buf_ring *br, void *buf) { @@ -169,8 +172,9 @@ buf_ring_dequeue_mc(struct buf_ring *br) } /* - * Single-Consumer dequeue for uses where dequeue - * is protected by a lock + * single-consumer dequeue + * use where dequeue is protected by a lock + * e.g. a network driver's tx queue lock */ static __inline void * buf_ring_dequeue_sc(struct buf_ring *br) @@ -208,6 +212,11 @@ buf_ring_dequeue_sc(struct buf_ring *br) return (buf); } +/* + * return a pointer to the first entry in the ring + * without modifying it, or NULL if the ring is empty + * race-prone if not protected by a lock + */ static __inline void * buf_ring_peek(struct buf_ring *br) { From owner-svn-src-user@FreeBSD.ORG Mon May 18 17:14:49 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86B791065677; Mon, 18 May 2009 17:14:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A3B08FC23; Mon, 18 May 2009 17:14:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IHEnf8068476; Mon, 18 May 2009 17:14:49 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IHEnI5068473; Mon, 18 May 2009 17:14:49 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181714.n4IHEnI5068473@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 17:14:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192312 - in user/kmacy/releng_7_2_fcs/sys: amd64/conf conf kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 17:14:49 -0000 Author: kmacy Date: Mon May 18 17:14:48 2009 New Revision: 192312 URL: http://svn.freebsd.org/changeset/base/192312 Log: make adaptive spinning on SX the default Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC user/kmacy/releng_7_2_fcs/sys/conf/options user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Mon May 18 17:14:23 2009 (r192311) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Mon May 18 17:14:48 2009 (r192312) @@ -249,6 +249,5 @@ device bpf # Berkeley packet filter options DDB options KDB options ALT_BREAK_TO_DEBUGGER -options ADAPTIVE_SX options HWPMC_HOOKS Modified: user/kmacy/releng_7_2_fcs/sys/conf/options ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/options Mon May 18 17:14:23 2009 (r192311) +++ user/kmacy/releng_7_2_fcs/sys/conf/options Mon May 18 17:14:48 2009 (r192312) @@ -62,7 +62,6 @@ NO_SYSCTL_DESCR opt_global.h # Miscellaneous options. ADAPTIVE_GIANT opt_adaptive_mutexes.h -ADAPTIVE_SX ALQ AUDIT opt_global.h CODA_COMPAT_5 opt_coda.h @@ -134,6 +133,7 @@ MPROF_BUFFERS opt_mprof.h MPROF_HASH_SIZE opt_mprof.h NO_ADAPTIVE_MUTEXES opt_adaptive_mutexes.h NO_ADAPTIVE_RWLOCKS +NO_ADAPTIVE_SX opt_adaptive_sx.h NSWBUF_MIN opt_swap.h MBUF_PACKET_ZONE_DISABLE opt_global.h PANIC_REBOOT_WAIT_TIME opt_panic.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c Mon May 18 17:14:23 2009 (r192311) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c Mon May 18 17:14:48 2009 (r192312) @@ -51,6 +51,10 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(SMP) && !defined(NO_ADAPTIVE_SX) +#define ADAPTIVE_SX +#endif + #ifdef ADAPTIVE_SX #include #endif @@ -59,10 +63,6 @@ __FBSDID("$FreeBSD$"); #include #endif -#if !defined(SMP) && defined(ADAPTIVE_SX) -#error "You must have SMP to enable the ADAPTIVE_SX option" -#endif - CTASSERT(((SX_ADAPTIVESPIN | SX_RECURSE) & LO_CLASSFLAGS) == (SX_ADAPTIVESPIN | SX_RECURSE)); From owner-svn-src-user@FreeBSD.ORG Mon May 18 17:37:28 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22B64106567B; Mon, 18 May 2009 17:37:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1022A8FC16; Mon, 18 May 2009 17:37:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IHbR7T069570; Mon, 18 May 2009 17:37:27 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IHbR71069566; Mon, 18 May 2009 17:37:27 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181737.n4IHbR71069566@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 17:37:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192315 - user/kmacy/releng_7_2_fcs/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 17:37:28 -0000 Author: kmacy Date: Mon May 18 17:37:27 2009 New Revision: 192315 URL: http://svn.freebsd.org/changeset/base/192315 Log: merge rt+lle caching support Modified: user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.c user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_usrreq.c Modified: user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.c Mon May 18 17:20:24 2009 (r192314) +++ user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.c Mon May 18 17:37:27 2009 (r192315) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -498,6 +499,76 @@ in_pcbbind_setup(struct inpcb *inp, stru return (0); } +void +in_pcbrtalloc(struct inpcb *inp, in_addr_t faddr, struct route *sro) +{ + struct sockaddr_in *sin; + struct sockaddr *dst; + struct llentry *la; + struct rtentry *rt; + struct ifnet *ifp; + int flags = LLE_EXCLUSIVE; + struct route iproute; + + INP_WLOCK_ASSERT(inp); + if (sro == NULL) + sro = &iproute; + + bzero(sro, sizeof(*sro)); + sin = (struct sockaddr_in *)&sro->ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(struct sockaddr_in); + sin->sin_addr.s_addr = faddr; + /* + * If route is known our src addr is taken from the i/f, + * else punt. + * + * Find out route to destination. + */ + if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0) { +#ifdef RADIX_MPATH + rtalloc_mpath_fib(sro, ntohl(faddr->s_addr), + inp->inp_inc.inc_fibnum); +#else + in_rtalloc_ign(sro, 0, inp->inp_inc.inc_fibnum); +#endif + } + + rt = sro->ro_rt; + if (rt == NULL) + return; + + inp->inp_rt = rt; + inp->inp_flags2 |= INP_RT_VALID; + + if (rt->rt_ifp == NULL) + return; + + ifp = rt->rt_ifp; + dst = &sro->ro_dst; + if (rt->rt_flags & RTF_GATEWAY) + dst = rt->rt_gateway; + + IF_AFDATA_RLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), flags, dst); + IF_AFDATA_RUNLOCK(ifp); + if ((la == NULL) && + (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { + flags |= (LLE_CREATE | LLE_EXCLUSIVE); + IF_AFDATA_WLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), flags, dst); + IF_AFDATA_WUNLOCK(ifp); + } + if (la == NULL) + return; + + LLE_ADDREF(la); + LLE_WUNLOCK(la); + + inp->inp_lle = la; + inp->inp_flags2 |= INP_LLE_VALID; +} + /* * Connect from a socket to a specified address. * Both address and port must be specified in argument sin. @@ -533,6 +604,7 @@ in_pcbconnect(struct inpcb *inp, struct } } + in_pcbrtalloc(inp, faddr, NULL); /* Commit the remaining changes. */ inp->inp_lport = lport; inp->inp_laddr.s_addr = laddr; @@ -871,6 +943,17 @@ in_pcbdisconnect(struct inpcb *inp) INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo); INP_WLOCK_ASSERT(inp); + if (inp->inp_flags2 & INP_RT_VALID) { + inp->inp_flags2 &= ~INP_RT_VALID; + RTFREE(inp->inp_rt); + inp->inp_rt = NULL; + } + if (inp->inp_flags2 & INP_LLE_VALID) { + inp->inp_flags2 &= ~INP_LLE_VALID; + LLE_FREE(inp->inp_lle); + inp->inp_lle = NULL; + } + inp->inp_faddr.s_addr = INADDR_ANY; inp->inp_fport = 0; in_pcbrehash(inp); @@ -908,6 +991,17 @@ in_pcbfree_internal(struct inpcb *inp) INP_INFO_WLOCK_ASSERT(ipi); INP_WLOCK_ASSERT(inp); + if (inp->inp_flags2 & INP_RT_VALID) { + inp->inp_flags2 &= ~INP_RT_VALID; + RTFREE(inp->inp_rt); + inp->inp_rt = NULL; + } + if (inp->inp_flags2 & INP_LLE_VALID) { + inp->inp_flags2 &= ~INP_LLE_VALID; + LLE_FREE(inp->inp_lle); + inp->inp_lle = NULL; + } + #ifdef IPSEC if (inp->inp_sp != NULL) ipsec_delete_pcbpolicy(inp); Modified: user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h Mon May 18 17:20:24 2009 (r192314) +++ user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h Mon May 18 17:37:27 2009 (r192315) @@ -500,6 +500,7 @@ void in_pcbdisconnect(struct inpcb *); void in_pcbdrop(struct inpcb *); void in_pcbfree(struct inpcb *); int in_pcbinshash(struct inpcb *); +void in_pcbrtalloc(struct inpcb *inp, in_addr_t faddr, struct route *sro); struct inpcb * in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short, int, struct ucred *); Modified: user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c Mon May 18 17:20:24 2009 (r192314) +++ user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c Mon May 18 17:37:27 2009 (r192315) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -137,11 +138,13 @@ ip_output(struct mbuf *m, struct mbuf *o int mtu; int len, error = 0; int nortfree = 0; + int neednewroute = 0, neednewlle = 0; struct sockaddr_in *dst = NULL; /* keep compiler happy */ struct in_ifaddr *ia = NULL; int isbroadcast, sw_csum; struct route iproute; struct in_addr odst; + struct sockaddr_in *sin; #ifdef IPFIREWALL_FORWARD struct m_tag *fwd_tag = NULL; #endif @@ -201,7 +204,7 @@ again: if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || dst->sin_family != AF_INET || dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { - if (!nortfree) + if (!nortfree && (inp == NULL || (ro->ro_rt != inp->inp_rt))) RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)NULL; } @@ -406,6 +409,22 @@ again: if (ia != NULL) { ip->ip_src = IA_SIN(ia)->sin_addr; } + if ((ro == &iproute) && (inp->inp_flags2 & INP_RT_VALID)) { + if (inp->inp_rt->rt_flags & RTF_UP) { + sin = (struct sockaddr_in *)&ro->ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(struct sockaddr_in); + sin->sin_addr.s_addr = inp->inp_faddr.s_addr; + ro->ro_rt = inp->inp_rt; + } else + neednewroute = 1; + } + if ((ro == &iproute) && (inp->inp_flags2 & INP_LLE_VALID)) { + if (inp->inp_lle->la_flags & LLE_VALID) { + ro->ro_lle = inp->inp_lle; + } else + neednewlle = 1; + } } /* @@ -642,7 +661,45 @@ passout: done: if (ro == &iproute && ro->ro_rt && !nortfree) { - RTFREE(ro->ro_rt); + int wlocked = 0; + struct llentry *la; + + if (neednewlle || neednewroute) { + wlocked = INP_WLOCKED(inp); + if (!wlocked && INP_TRY_UPGRADE(inp) == 0) + return (error); + } + + if ((nortfree == 0) && + (inp == NULL || (inp->inp_vflag & INP_RT_VALID) == 0)) + RTFREE(ro->ro_rt); + else if (neednewroute && ro->ro_rt != inp->inp_rt) { + RTFREE(inp->inp_rt); + inp->inp_rt = ro->ro_rt; + } + if (neednewlle) { + IF_AFDATA_RLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), LLE_EXCLUSIVE, + (struct sockaddr *)dst); + IF_AFDATA_RUNLOCK(ifp); + if ((la == NULL) && + (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { + IF_AFDATA_WLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), + (LLE_CREATE | LLE_EXCLUSIVE), + (struct sockaddr *)dst); + IF_AFDATA_WUNLOCK(ifp); + } + if (la != NULL && (inp->inp_lle != la)) { + LLE_FREE(inp->inp_lle); + LLE_ADDREF(la); + LLE_WUNLOCK(la); + inp->inp_lle = la; + } else if (la != NULL) + LLE_WUNLOCK(la); + } + if ((neednewlle || neednewroute) && !wlocked) + INP_DOWNGRADE(inp); } return (error); bad: Modified: user/kmacy/releng_7_2_fcs/sys/netinet/tcp_usrreq.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/tcp_usrreq.c Mon May 18 17:20:24 2009 (r192314) +++ user/kmacy/releng_7_2_fcs/sys/netinet/tcp_usrreq.c Mon May 18 17:37:27 2009 (r192315) @@ -1104,6 +1104,7 @@ tcp_connect(struct tcpcb *tp, struct soc inp->inp_laddr = laddr; in_pcbrehash(inp); + in_pcbrtalloc(inp, inp->inp_faddr.s_addr, NULL); /* * Compute window scaling to request: * Scale to fit into sweet spot. See tcp_syncache.c. From owner-svn-src-user@FreeBSD.ORG Mon May 18 17:42:26 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55BDA106564A; Mon, 18 May 2009 17:42:26 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 449E88FC16; Mon, 18 May 2009 17:42:26 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IHgQUH069811; Mon, 18 May 2009 17:42:26 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IHgQTf069810; Mon, 18 May 2009 17:42:26 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181742.n4IHgQTf069810@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 17:42:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192317 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 17:42:26 -0000 Author: kmacy Date: Mon May 18 17:42:25 2009 New Revision: 192317 URL: http://svn.freebsd.org/changeset/base/192317 Log: make lock shared on read for sendfile Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Mon May 18 17:39:12 2009 (r192316) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Mon May 18 17:42:25 2009 (r192317) @@ -1823,7 +1823,7 @@ kern_sendfile(struct thread *td, struct if ((error = fgetvp_read(td, uap->fd, &vp)) != 0) goto out; vfslocked = VFS_LOCK_GIANT(vp->v_mount); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); if (vp->v_type == VREG) { obj = vp->v_object; if (obj != NULL) { From owner-svn-src-user@FreeBSD.ORG Mon May 18 17:57:34 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9D17106566C; Mon, 18 May 2009 17:57:34 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8E3B18FC0C; Mon, 18 May 2009 17:57:34 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IHvYAU070184; Mon, 18 May 2009 17:57:34 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IHvYL2070181; Mon, 18 May 2009 17:57:34 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181757.n4IHvYL2070181@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 17:57:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192319 - user/kmacy/releng_7_2_fcs/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 17:57:35 -0000 Author: kmacy Date: Mon May 18 17:57:33 2009 New Revision: 192319 URL: http://svn.freebsd.org/changeset/base/192319 Log: glue in flowid Modified: user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c user/kmacy/releng_7_2_fcs/sys/netinet/tcp_input.c Modified: user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h Mon May 18 17:48:46 2009 (r192318) +++ user/kmacy/releng_7_2_fcs/sys/netinet/in_pcb.h Mon May 18 17:57:33 2009 (r192319) @@ -168,7 +168,7 @@ struct inpcb { u_char inp_ip_ttl; /* (i) time to live proto */ u_char inp_ip_p; /* (c) protocol proto */ u_char inp_ip_minttl; /* (i) minimum TTL or drop */ - uint32_t inp_ispare1; /* (x) connection id / queue id */ + uint32_t inp_flowid; /* (x) connection id / queue id */ u_int inp_refcount; /* (i) refcount */ void *inp_pspare[2]; /* (x) rtentry / general use */ Modified: user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c Mon May 18 17:48:46 2009 (r192318) +++ user/kmacy/releng_7_2_fcs/sys/netinet/ip_output.c Mon May 18 17:57:33 2009 (r192319) @@ -158,6 +158,10 @@ ip_output(struct mbuf *m, struct mbuf *o if (inp != NULL) { M_SETFIB(m, inp->inp_inc.inc_fibnum); INP_LOCK_ASSERT(inp); + if (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { + m->m_pkthdr.flowid = inp->inp_flowid; + m->m_flags |= M_FLOWID; + } } if ((ro == &iproute) && (ro->ro_rt == NULL) && (ro->ro_lle == NULL)) { if (flowtable_lookup(ip_ft, m, ro) == 0) Modified: user/kmacy/releng_7_2_fcs/sys/netinet/tcp_input.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/tcp_input.c Mon May 18 17:48:46 2009 (r192318) +++ user/kmacy/releng_7_2_fcs/sys/netinet/tcp_input.c Mon May 18 17:57:33 2009 (r192319) @@ -595,7 +595,14 @@ findpcb: goto dropwithreset; } INP_WLOCK(inp); - + if (!(inp->inp_flags & INP_HW_FLOWID) + && (m->m_flags & M_FLOWID) + && ((inp->inp_socket == NULL) + || !(inp->inp_socket->so_options & SO_ACCEPTCONN))) { + inp->inp_flags |= INP_HW_FLOWID; + inp->inp_flags &= ~INP_SW_FLOWID; + inp->inp_flowid = m->m_pkthdr.flowid; + } #ifdef IPSEC #ifdef INET6 if (isipv6 && ipsec6_in_reject(m, inp)) { From owner-svn-src-user@FreeBSD.ORG Mon May 18 18:34:03 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AEEEE106566B; Mon, 18 May 2009 18:34:03 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9CAD58FC20; Mon, 18 May 2009 18:34:03 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IIY36b071077; Mon, 18 May 2009 18:34:03 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IIY3Jp071075; Mon, 18 May 2009 18:34:03 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181834.n4IIY3Jp071075@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 18:34:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192322 - in user/kmacy/releng_7_2_fcs/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 18:34:03 -0000 Author: kmacy Date: Mon May 18 18:34:03 2009 New Revision: 192322 URL: http://svn.freebsd.org/changeset/base/192322 Log: Merge dependent callout changes 171053 172025 172184 173760 173842 176013 Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c user/kmacy/releng_7_2_fcs/sys/sys/callout.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 18:12:45 2009 (r192321) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 18:34:03 2009 (r192322) @@ -55,9 +55,9 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_dept static int avg_gcalls; SYSCTL_INT(_debug, OID_AUTO, to_avg_gcalls, CTLFLAG_RD, &avg_gcalls, 0, "Average number of Giant callouts made per softclock call. Units = 1/1000"); -static int avg_mtxcalls; -SYSCTL_INT(_debug, OID_AUTO, to_avg_mtxcalls, CTLFLAG_RD, &avg_mtxcalls, 0, - "Average number of mtx callouts made per softclock call. Units = 1/1000"); +static int avg_lockcalls; +SYSCTL_INT(_debug, OID_AUTO, to_avg_lockcalls, CTLFLAG_RD, &avg_lockcalls, 0, + "Average number of lock callouts made per softclock call. Units = 1/1000"); static int avg_mpcalls; SYSCTL_INT(_debug, OID_AUTO, to_avg_mpcalls, CTLFLAG_RD, &avg_mpcalls, 0, "Average number of MP callouts made per softclock call. Units = 1/1000"); @@ -82,12 +82,12 @@ static struct callout *nextsoftcheck; /* * If curr_callout is non-NULL, threads waiting in * callout_drain() will be woken up as soon as the * relevant callout completes. - * curr_cancelled - Changing to 1 with both callout_lock and c_mtx held + * curr_cancelled - Changing to 1 with both callout_lock and c_lock held * guarantees that the current callout will not run. * The softclock() function sets this to 0 before it - * drops callout_lock to acquire c_mtx, and it calls + * drops callout_lock to acquire c_lock, and it calls * the handler only if curr_cancelled is still 0 after - * c_mtx is successfully acquired. + * c_lock is successfully acquired. * callout_wait - If a thread is waiting in callout_drain(), then * callout_wait is nonzero. Set only when * curr_callout is non-NULL. @@ -170,7 +170,7 @@ softclock(void *dummy) int steps; /* #steps since we last allowed interrupts */ int depth; int mpcalls; - int mtxcalls; + int lockcalls; int gcalls; #ifdef DIAGNOSTIC struct bintime bt1, bt2; @@ -184,7 +184,7 @@ softclock(void *dummy) #endif /* MAX_SOFTCLOCK_STEPS */ mpcalls = 0; - mtxcalls = 0; + lockcalls = 0; gcalls = 0; depth = 0; steps = 0; @@ -215,14 +215,19 @@ softclock(void *dummy) } else { void (*c_func)(void *); void *c_arg; - struct mtx *c_mtx; - int c_flags; + struct lock_class *class; + struct lock_object *c_lock; + int c_flags, sharedlock; nextsoftcheck = TAILQ_NEXT(c, c_links.tqe); TAILQ_REMOVE(bucket, c, c_links.tqe); + class = (c->c_lock != NULL) ? + LOCK_CLASS(c->c_lock) : NULL; + sharedlock = (c->c_flags & CALLOUT_SHAREDLOCK) ? + 0 : 1; + c_lock = c->c_lock; c_func = c->c_func; c_arg = c->c_arg; - c_mtx = c->c_mtx; c_flags = c->c_flags; if (c->c_flags & CALLOUT_LOCAL_ALLOC) { c->c_func = NULL; @@ -237,27 +242,27 @@ softclock(void *dummy) } curr_cancelled = 0; mtx_unlock_spin(&callout_lock); - if (c_mtx != NULL) { - mtx_lock(c_mtx); + if (c_lock != NULL) { + class->lc_lock(c_lock, sharedlock); /* * The callout may have been cancelled * while we switched locks. */ if (curr_cancelled) { - mtx_unlock(c_mtx); + class->lc_unlock(c_lock); goto skip; } /* The callout cannot be stopped now. */ curr_cancelled = 1; - if (c_mtx == &Giant) { + if (c_lock == &Giant.lock_object) { gcalls++; CTR3(KTR_CALLOUT, "callout %p func %p arg %p", c, c_func, c_arg); } else { - mtxcalls++; - CTR3(KTR_CALLOUT, "callout mtx" + lockcalls++; + CTR3(KTR_CALLOUT, "callout lock" " %p func %p arg %p", c, c_func, c_arg); } @@ -292,7 +297,7 @@ softclock(void *dummy) #endif CTR1(KTR_CALLOUT, "callout %p finished", c); if ((c_flags & CALLOUT_RETURNUNLOCKED) == 0) - mtx_unlock(c_mtx); + class->lc_unlock(c_lock); skip: mtx_lock_spin(&callout_lock); curr_callout = NULL; @@ -313,7 +318,7 @@ softclock(void *dummy) } avg_depth += (depth * 1000 - avg_depth) >> 8; avg_mpcalls += (mpcalls * 1000 - avg_mpcalls) >> 8; - avg_mtxcalls += (mtxcalls * 1000 - avg_mtxcalls) >> 8; + avg_lockcalls += (lockcalls * 1000 - avg_lockcalls) >> 8; avg_gcalls += (gcalls * 1000 - avg_gcalls) >> 8; nextsoftcheck = NULL; mtx_unlock_spin(&callout_lock); @@ -412,19 +417,14 @@ callout_reset(c, to_ticks, ftn, arg) { int cancelled = 0; -#ifdef notyet /* Some callers of timeout() do not hold Giant. */ - if (c->c_mtx != NULL) - mtx_assert(c->c_mtx, MA_OWNED); -#endif - mtx_lock_spin(&callout_lock); if (c == curr_callout) { /* * We're being asked to reschedule a callout which is - * currently in progress. If there is a mutex then we + * currently in progress. If there is a lock then we * can cancel the callout if it has not really started. */ - if (c->c_mtx != NULL && !curr_cancelled) + if (c->c_lock != NULL && !curr_cancelled) cancelled = curr_cancelled = 1; if (callout_wait) { /* @@ -483,18 +483,23 @@ _callout_stop_safe(c, safe) struct callout *c; int safe; { - int use_mtx, sq_locked; + struct lock_class *class; + int use_lock, sq_locked; - if (!safe && c->c_mtx != NULL) { -#ifdef notyet /* Some callers do not hold Giant for Giant-locked callouts. */ - mtx_assert(c->c_mtx, MA_OWNED); - use_mtx = 1; -#else - use_mtx = mtx_owned(c->c_mtx); -#endif - } else { - use_mtx = 0; - } + /* + * Some old subsystems don't hold Giant while running a callout_stop(), + * so just discard this check for the moment. + */ + if (!safe && c->c_lock != NULL) { + if (c->c_lock == &Giant.lock_object) + use_lock = mtx_owned(&Giant); + else { + use_lock = 1; + class = LOCK_CLASS(c->c_lock); + class->lc_assert(c->c_lock, LA_XLOCKED); + } + } else + use_lock = 0; sq_locked = 0; again: @@ -566,12 +571,12 @@ again: PICKUP_GIANT(); mtx_lock_spin(&callout_lock); } - } else if (use_mtx && !curr_cancelled) { + } else if (use_lock && !curr_cancelled) { /* - * The current callout is waiting for it's - * mutex which we hold. Cancel the callout + * The current callout is waiting for its + * lock which we hold. Cancel the callout * and return. After our caller drops the - * mutex, the callout will be skipped in + * lock, the callout will be skipped in * softclock(). */ curr_cancelled = 1; @@ -615,28 +620,30 @@ callout_init(c, mpsafe) { bzero(c, sizeof *c); if (mpsafe) { - c->c_mtx = NULL; + c->c_lock = NULL; c->c_flags = CALLOUT_RETURNUNLOCKED; } else { - c->c_mtx = &Giant; + c->c_lock = &Giant.lock_object; c->c_flags = 0; } } void -callout_init_mtx(c, mtx, flags) +_callout_init_lock(c, lock, flags) struct callout *c; - struct mtx *mtx; + struct lock_object *lock; int flags; { bzero(c, sizeof *c); - c->c_mtx = mtx; - KASSERT((flags & ~(CALLOUT_RETURNUNLOCKED)) == 0, - ("callout_init_mtx: bad flags %d", flags)); - /* CALLOUT_RETURNUNLOCKED makes no sense without a mutex. */ - KASSERT(mtx != NULL || (flags & CALLOUT_RETURNUNLOCKED) == 0, - ("callout_init_mtx: CALLOUT_RETURNUNLOCKED with no mutex")); - c->c_flags = flags & (CALLOUT_RETURNUNLOCKED); + c->c_lock = lock; + KASSERT((flags & ~(CALLOUT_RETURNUNLOCKED | CALLOUT_SHAREDLOCK)) == 0, + ("callout_init_lock: bad flags %d", flags)); + KASSERT(lock != NULL || (flags & CALLOUT_RETURNUNLOCKED) == 0, + ("callout_init_lock: CALLOUT_RETURNUNLOCKED with no lock")); + KASSERT(lock == NULL || !(LOCK_CLASS(lock)->lc_flags & + (LC_SPINLOCK | LC_SLEEPABLE)), ("%s: invalid lock class", + __func__)); + c->c_flags = flags & (CALLOUT_RETURNUNLOCKED | CALLOUT_SHAREDLOCK); } #ifdef APM_FIXUP_CALLTODO Modified: user/kmacy/releng_7_2_fcs/sys/sys/callout.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/callout.h Mon May 18 18:12:45 2009 (r192321) +++ user/kmacy/releng_7_2_fcs/sys/sys/callout.h Mon May 18 18:34:03 2009 (r192322) @@ -40,7 +40,7 @@ #include -struct mtx; +struct lock_object; SLIST_HEAD(callout_list, callout); TAILQ_HEAD(callout_tailq, callout); @@ -53,7 +53,7 @@ struct callout { int c_time; /* ticks to the event */ void *c_arg; /* function argument */ void (*c_func)(void *); /* function to call */ - struct mtx *c_mtx; /* mutex to lock */ + struct lock_object *c_lock; /* lock to handle */ int c_flags; /* state of this entry */ }; @@ -62,6 +62,7 @@ struct callout { #define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */ #define CALLOUT_MPSAFE 0x0008 /* callout handler is mp safe */ #define CALLOUT_RETURNUNLOCKED 0x0010 /* handler returns with mtx unlocked */ +#define CALLOUT_SHAREDLOCK 0x0020 /* callout lock held in shared mode */ struct callout_handle { struct callout *callout; @@ -79,7 +80,13 @@ extern struct mtx callout_lock; #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) #define callout_drain(c) _callout_stop_safe(c, 1) void callout_init(struct callout *, int); -void callout_init_mtx(struct callout *, struct mtx *, int); +void _callout_init_lock(struct callout *, struct lock_object *, int); +#define callout_init_mtx(c, mtx, flags) \ + _callout_init_lock((c), ((mtx) != NULL) ? &(mtx)->lock_object : \ + NULL, (flags)) +#define callout_init_rw(c, rw, flags) \ + _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \ + NULL, (flags)) #define callout_pending(c) ((c)->c_flags & CALLOUT_PENDING) int callout_reset(struct callout *, int, void (*)(void *), void *); #define callout_stop(c) _callout_stop_safe(c, 0) From owner-svn-src-user@FreeBSD.ORG Mon May 18 18:50:39 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 702471065674; Mon, 18 May 2009 18:50:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D4948FC19; Mon, 18 May 2009 18:50:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IIodCs071536; Mon, 18 May 2009 18:50:39 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IIocGh071522; Mon, 18 May 2009 18:50:38 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181850.n4IIocGh071522@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 18:50:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192325 - in user/kmacy/releng_7_2_fcs/sys: kern sys vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 18:50:39 -0000 Author: kmacy Date: Mon May 18 18:50:38 2009 New Revision: 192325 URL: http://svn.freebsd.org/changeset/base/192325 Log: merge 177085 - Pass the priority argument from *sleep() into sleepq and down into sched_sleep(). This removes extra thread_lock() acquisition and allows the scheduler to decide what to do with the static boost. - Change the priority arguments to cv_* to match sleepq/msleep/etc. where 0 means no priority change. Catch -1 in cv_broadcastpri() and convert it to 0 for now. - Set a flag when sleeping in a way that is compatible with swapping since direct priority comparisons are meaningless now. - Add a sysctl to ule, kern.sched.static_boost, that defaults to on which controls the boost behavior. Turning it off gives better performance in some workloads but needs more investigation. - While we're modifying sleepq, change signal and broadcast to both return with the lock held as the lock was held on enter. Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c user/kmacy/releng_7_2_fcs/sys/sys/condvar.h user/kmacy/releng_7_2_fcs/sys/sys/proc.h user/kmacy/releng_7_2_fcs/sys/sys/sched.h user/kmacy/releng_7_2_fcs/sys/sys/sleepqueue.h user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c Mon May 18 18:50:38 2009 (r192325) @@ -134,7 +134,7 @@ _cv_wait(struct cv *cvp, struct lock_obj if (class->lc_flags & LC_SLEEPABLE) sleepq_lock(cvp); } - sleepq_wait(cvp); + sleepq_wait(cvp, 0); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -191,7 +191,7 @@ _cv_wait_unlock(struct cv *cvp, struct l class->lc_unlock(lock); if (class->lc_flags & LC_SLEEPABLE) sleepq_lock(cvp); - sleepq_wait(cvp); + sleepq_wait(cvp, 0); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -252,7 +252,7 @@ _cv_wait_sig(struct cv *cvp, struct lock if (class->lc_flags & LC_SLEEPABLE) sleepq_lock(cvp); } - rval = sleepq_wait_sig(cvp); + rval = sleepq_wait_sig(cvp, 0); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -317,7 +317,7 @@ _cv_timedwait(struct cv *cvp, struct loc if (class->lc_flags & LC_SLEEPABLE) sleepq_lock(cvp); } - rval = sleepq_timedwait(cvp); + rval = sleepq_timedwait(cvp, 0); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -386,7 +386,7 @@ _cv_timedwait_sig(struct cv *cvp, struct if (class->lc_flags & LC_SLEEPABLE) sleepq_lock(cvp); } - rval = sleepq_timedwait_sig(cvp); + rval = sleepq_timedwait_sig(cvp, 0); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -433,13 +433,19 @@ cv_broadcastpri(struct cv *cvp, int pri) { int wakeup_swapper; + /* + * XXX sleepq_broadcast pri argument changed from -1 meaning + * no pri to 0 meaning no pri. + */ + if (pri == -1) + pri = 0; wakeup_swapper = 0; sleepq_lock(cvp); if (cvp->cv_waiters > 0) { cvp->cv_waiters = 0; wakeup_swapper = sleepq_broadcast(cvp, SLEEPQ_CONDVAR, pri, 0); - } else - sleepq_release(cvp); + } + sleepq_release(cvp); if (wakeup_swapper) kick_proc0(); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c Mon May 18 18:50:38 2009 (r192325) @@ -402,8 +402,7 @@ _sx_downgrade(struct sx *sx, const char if (x & SX_LOCK_SHARED_WAITERS) wakeup_swapper = sleepq_broadcast(&sx->lock_object, SLEEPQ_SX, -1, SQ_SHARED_QUEUE); - else - sleepq_release(&sx->lock_object); + sleepq_release(&sx->lock_object); LOCK_LOG_LOCK("XDOWNGRADE", &sx->lock_object, 0, 0, file, line); @@ -557,9 +556,9 @@ _sx_xlock_hard(struct sx *sx, uintptr_t SLEEPQ_SX | ((opts & SX_INTERRUPTIBLE) ? SLEEPQ_INTERRUPTIBLE : 0), SQ_EXCLUSIVE_QUEUE); if (!(opts & SX_INTERRUPTIBLE)) - sleepq_wait(&sx->lock_object); + sleepq_wait(&sx->lock_object, 0); else - error = sleepq_wait_sig(&sx->lock_object); + error = sleepq_wait_sig(&sx->lock_object, 0); if (error) { if (LOCK_LOG_TEST(&sx->lock_object, 0)) @@ -630,6 +629,7 @@ _sx_xunlock_hard(struct sx *sx, uintptr_ atomic_store_rel_ptr(&sx->sx_lock, x); wakeup_swapper = sleepq_broadcast(&sx->lock_object, SLEEPQ_SX, -1, queue); + sleepq_release(&sx->lock_object); if (wakeup_swapper) kick_proc0(); } @@ -779,9 +779,9 @@ _sx_slock_hard(struct sx *sx, int opts, SLEEPQ_SX | ((opts & SX_INTERRUPTIBLE) ? SLEEPQ_INTERRUPTIBLE : 0), SQ_SHARED_QUEUE); if (!(opts & SX_INTERRUPTIBLE)) - sleepq_wait(&sx->lock_object); + sleepq_wait(&sx->lock_object, 0); else - error = sleepq_wait_sig(&sx->lock_object); + error = sleepq_wait_sig(&sx->lock_object, 0); if (error) { if (LOCK_LOG_TEST(&sx->lock_object, 0)) @@ -879,6 +879,7 @@ _sx_sunlock_hard(struct sx *sx, const ch "exclusive queue", __func__, sx); wakeup_swapper = sleepq_broadcast(&sx->lock_object, SLEEPQ_SX, -1, SQ_EXCLUSIVE_QUEUE); + sleepq_release(&sx->lock_object); if (wakeup_swapper) kick_proc0(); break; Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Mon May 18 18:50:38 2009 (r192325) @@ -161,6 +161,7 @@ _sleep(void *ident, struct lock_object * return (0); } catch = priority & PCATCH; + pri = priority & PRIMASK; rval = 0; /* @@ -209,25 +210,14 @@ _sleep(void *ident, struct lock_object * lock_state = class->lc_unlock(lock); sleepq_lock(ident); } - - /* - * Adjust this thread's priority, if necessary. - */ - pri = priority & PRIMASK; - if (pri != 0 && pri != td->td_priority) { - thread_lock(td); - sched_prio(td, pri); - thread_unlock(td); - } - if (timo && catch) - rval = sleepq_timedwait_sig(ident); + rval = sleepq_timedwait_sig(ident, pri); else if (timo) - rval = sleepq_timedwait(ident); + rval = sleepq_timedwait(ident, pri); else if (catch) - rval = sleepq_wait_sig(ident); + rval = sleepq_wait_sig(ident, pri); else { - sleepq_wait(ident); + sleepq_wait(ident, pri); rval = 0; } #ifdef KTRACE @@ -305,9 +295,9 @@ msleep_spin(void *ident, struct mtx *mtx sleepq_lock(ident); #endif if (timo) - rval = sleepq_timedwait(ident); + rval = sleepq_timedwait(ident, 0); else { - sleepq_wait(ident); + sleepq_wait(ident, 0); rval = 0; } #ifdef KTRACE Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Mon May 18 18:50:38 2009 (r192325) @@ -898,8 +898,8 @@ thread_suspend_switch(struct thread *td) p->p_suspcount++; PROC_UNLOCK(p); thread_lock(td); - sched_sleep(td); TD_SET_SUSPENDED(td); + sched_sleep(td, 0); PROC_SUNLOCK(p); DROP_GIANT(); mi_switch(SW_VOL, NULL); @@ -918,8 +918,8 @@ thread_suspend_one(struct thread *td) THREAD_LOCK_ASSERT(td, MA_OWNED); KASSERT(!TD_IS_SUSPENDED(td), ("already suspended")); p->p_suspcount++; - sched_sleep(td); TD_SET_SUSPENDED(td); + sched_sleep(td, 0); } int Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 18:50:38 2009 (r192325) @@ -496,7 +496,9 @@ _callout_stop_safe(c, safe) else { use_lock = 1; class = LOCK_CLASS(c->c_lock); +#ifdef notyet class->lc_assert(c->c_lock, LA_XLOCKED); +#endif } } else use_lock = 0; @@ -564,7 +566,7 @@ again: sleepq_add(&callout_wait, &callout_lock.lock_object, "codrain", SLEEPQ_SLEEP, 0); - sleepq_wait(&callout_wait); + sleepq_wait(&callout_wait, 0); sq_locked = 0; /* Reacquire locks previously released. */ Modified: user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c Mon May 18 18:50:38 2009 (r192325) @@ -813,12 +813,16 @@ sched_unlend_user_prio(struct thread *td } void -sched_sleep(struct thread *td) +sched_sleep(struct thread *td, int pri) { THREAD_LOCK_ASSERT(td, MA_OWNED); td->td_slptick = ticks; td->td_sched->ts_slptime = 0; + if (pri) + sched_prio(td, pri); + if (TD_IS_SUSPENDED(td) || pri <= PSOCK) + td->td_flags |= TDF_CANSWAP; } void @@ -946,6 +950,7 @@ sched_wakeup(struct thread *td) THREAD_LOCK_ASSERT(td, MA_OWNED); ts = td->td_sched; + td->td_flags &= ~TDF_CANSWAP; if (ts->ts_slptime > 1) { updatepri(td); resetpriority(td); Modified: user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c Mon May 18 18:50:38 2009 (r192325) @@ -195,6 +195,7 @@ static int preempt_thresh = PRI_MIN_KERN #else static int preempt_thresh = 0; #endif +static int static_boost = 1; /* * tdq - per processor runqs and statistics. All fields are protected by the @@ -1985,12 +1986,16 @@ sched_nice(struct proc *p, int nice) * Record the sleep time for the interactivity scorer. */ void -sched_sleep(struct thread *td) +sched_sleep(struct thread *td, int prio) { THREAD_LOCK_ASSERT(td, MA_OWNED); td->td_slptick = ticks; + if (TD_IS_SUSPENDED(td) || prio <= PSOCK) + td->td_flags |= TDF_CANSWAP; + if (static_boost && prio) + sched_prio(td, prio); } /* @@ -2005,6 +2010,7 @@ sched_wakeup(struct thread *td) THREAD_LOCK_ASSERT(td, MA_OWNED); ts = td->td_sched; + td->td_flags &= ~TDF_CANSWAP; /* * If we slept for more than a tick update our interactivity and * priority. @@ -2746,6 +2752,8 @@ SYSCTL_INT(_kern_sched, OID_AUTO, intera "Interactivity score threshold"); SYSCTL_INT(_kern_sched, OID_AUTO, preempt_thresh, CTLFLAG_RW, &preempt_thresh, 0,"Min priority for preemption, lower priorities have greater precedence"); +SYSCTL_INT(_kern_sched, OID_AUTO, static_boost, CTLFLAG_RW, &static_boost, + 0,"Controls whether static kernel priorities are assigned to sleeping threads."); #ifdef SMP SYSCTL_INT(_kern_sched, OID_AUTO, pick_pri, CTLFLAG_RW, &pick_pri, 0, "Pick the target cpu based on priority rather than load."); Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c Mon May 18 18:50:38 2009 (r192325) @@ -149,7 +149,7 @@ static uma_zone_t sleepq_zone; /* * Prototypes for non-exported routines. */ -static int sleepq_catch_signals(void *wchan); +static int sleepq_catch_signals(void *wchan, int pri); static int sleepq_check_signals(void); static int sleepq_check_timeout(void); #ifdef INVARIANTS @@ -158,7 +158,7 @@ static void sleepq_dtor(void *mem, int s static int sleepq_init(void *mem, int size, int flags); static int sleepq_resume_thread(struct sleepqueue *sq, struct thread *td, int pri); -static void sleepq_switch(void *wchan); +static void sleepq_switch(void *wchan, int pri); static void sleepq_timeout(void *arg); /* @@ -367,7 +367,7 @@ sleepq_set_timeout(void *wchan, int timo * may have transitioned from the sleepq lock to a run lock. */ static int -sleepq_catch_signals(void *wchan) +sleepq_catch_signals(void *wchan, int pri) { struct sleepqueue_chain *sc; struct sleepqueue *sq; @@ -414,7 +414,7 @@ sleepq_catch_signals(void *wchan) PROC_SUNLOCK(p); if (ret == 0) { if (!(td->td_flags & TDF_INTERRUPT)) { - sleepq_switch(wchan); + sleepq_switch(wchan, pri); return (0); } /* KSE threads tried unblocking us. */ @@ -447,7 +447,7 @@ sleepq_catch_signals(void *wchan) * Returns with thread lock. */ static void -sleepq_switch(void *wchan) +sleepq_switch(void *wchan, int pri) { struct sleepqueue_chain *sc; struct sleepqueue *sq; @@ -488,10 +488,9 @@ sleepq_switch(void *wchan) return; } - thread_lock_set(td, &sc->sc_lock); - MPASS(td->td_sleepqueue == NULL); - sched_sleep(td); + sched_sleep(td, pri); + thread_lock_set(td, &sc->sc_lock); TD_SET_SLEEPING(td); SCHED_STAT_INC(switch_sleepq); mi_switch(SW_VOL, NULL); @@ -570,14 +569,14 @@ sleepq_check_signals(void) * Block the current thread until it is awakened from its sleep queue. */ void -sleepq_wait(void *wchan) +sleepq_wait(void *wchan, int pri) { struct thread *td; td = curthread; MPASS(!(td->td_flags & TDF_SINTR)); thread_lock(td); - sleepq_switch(wchan); + sleepq_switch(wchan, pri); thread_unlock(td); } @@ -586,12 +585,12 @@ sleepq_wait(void *wchan) * or it is interrupted by a signal. */ int -sleepq_wait_sig(void *wchan) +sleepq_wait_sig(void *wchan, int pri) { int rcatch; int rval; - rcatch = sleepq_catch_signals(wchan); + rcatch = sleepq_catch_signals(wchan, pri); rval = sleepq_check_signals(); thread_unlock(curthread); if (rcatch) @@ -604,7 +603,7 @@ sleepq_wait_sig(void *wchan) * or it times out while waiting. */ int -sleepq_timedwait(void *wchan) +sleepq_timedwait(void *wchan, int pri) { struct thread *td; int rval; @@ -612,7 +611,7 @@ sleepq_timedwait(void *wchan) td = curthread; MPASS(!(td->td_flags & TDF_SINTR)); thread_lock(td); - sleepq_switch(wchan); + sleepq_switch(wchan, pri); rval = sleepq_check_timeout(); thread_unlock(td); @@ -624,11 +623,11 @@ sleepq_timedwait(void *wchan) * it is interrupted by a signal, or it times out waiting to be awakened. */ int -sleepq_timedwait_sig(void *wchan) +sleepq_timedwait_sig(void *wchan, int pri) { int rcatch, rvalt, rvals; - rcatch = sleepq_catch_signals(wchan); + rcatch = sleepq_catch_signals(wchan, pri); rvalt = sleepq_check_timeout(); rvals = sleepq_check_signals(); thread_unlock(curthread); @@ -692,8 +691,8 @@ sleepq_resume_thread(struct sleepqueue * TD_CLR_SLEEPING(td); /* Adjust priority if requested. */ - MPASS(pri == -1 || (pri >= PRI_MIN && pri <= PRI_MAX)); - if (pri != -1 && td->td_priority > pri) + MPASS(pri == 0 || (pri >= PRI_MIN && pri <= PRI_MAX)); + if (pri != 0 && td->td_priority > pri) sched_prio(td, pri); return (setrunnable(td)); } @@ -782,10 +781,8 @@ sleepq_broadcast(void *wchan, int flags, KASSERT(wchan != NULL, ("%s: invalid NULL wait channel", __func__)); MPASS((queue >= 0) && (queue < NR_SLEEPQS)); sq = sleepq_lookup(wchan); - if (sq == NULL) { - sleepq_release(wchan); + if (sq == NULL) return (0); - } KASSERT(sq->sq_type == (flags & SLEEPQ_TYPE), ("%s: mismatch between sleep/wakeup and cv_*", __func__)); @@ -797,7 +794,6 @@ sleepq_broadcast(void *wchan, int flags, wakeup_swapper = 1; thread_unlock(td); } - sleepq_release(wchan); return (wakeup_swapper); } Modified: user/kmacy/releng_7_2_fcs/sys/sys/condvar.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/condvar.h Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/sys/condvar.h Mon May 18 18:50:38 2009 (r192325) @@ -72,7 +72,7 @@ void cv_broadcastpri(struct cv *cvp, int #define cv_timedwait_sig(cvp, lock, timo) \ _cv_timedwait_sig((cvp), &(lock)->lock_object, (timo)) -#define cv_broadcast(cvp) cv_broadcastpri(cvp, -1) +#define cv_broadcast(cvp) cv_broadcastpri(cvp, 0) #define cv_wmesg(cvp) ((cvp)->cv_description) Modified: user/kmacy/releng_7_2_fcs/sys/sys/proc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/proc.h Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/sys/proc.h Mon May 18 18:50:38 2009 (r192325) @@ -329,7 +329,7 @@ do { \ #define TDF_SINTR 0x00000008 /* Sleep is interruptible. */ #define TDF_TIMEOUT 0x00000010 /* Timing out during sleep. */ #define TDF_IDLETD 0x00000020 /* This is a per-CPU idle thread. */ -#define TDF_SELECT 0x00000040 /* Selecting; wakeup/waiting danger. */ +#define TDF_SELECT 0x00000040 /* Thread can be swapped. */ #define TDF_SLEEPABORT 0x00000080 /* sleepq_abort was called. */ #define TDF_UNUSEDx100 0x00000100 /* --available-- */ #define TDF_UBORROWING 0x00000200 /* Thread is borrowing user pri. */ @@ -346,7 +346,7 @@ do { \ #define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ #define TDF_DBSUSPEND 0x00200000 /* Thread is suspended by debugger */ #define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */ -#define TDF_UNUSED23 0x00800000 /* --available-- */ +#define TDF_CANSWAP 0x00800000 /* --available-- */ #define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */ #define TDF_SCHED1 0x02000000 /* Reserved for scheduler private use */ #define TDF_SCHED2 0x04000000 /* Reserved for scheduler private use */ @@ -778,7 +778,7 @@ MALLOC_DECLARE(M_ZOMBIE); } while (0) /* Check whether a thread is safe to be swapped out. */ -#define thread_safetoswapout(td) (TD_IS_SLEEPING(td) || TD_IS_SUSPENDED(td)) +#define thread_safetoswapout(td) ((td)->td_flags & TDF_CANSWAP) /* Control whether or not it is safe for curthread to sleep. */ #define THREAD_NO_SLEEPING() do { \ Modified: user/kmacy/releng_7_2_fcs/sys/sys/sched.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/sched.h Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/sys/sched.h Mon May 18 18:50:38 2009 (r192325) @@ -100,7 +100,7 @@ void sched_lend_prio(struct thread *td, void sched_lend_user_prio(struct thread *td, u_char pri); fixpt_t sched_pctcpu(struct thread *td); void sched_prio(struct thread *td, u_char prio); -void sched_sleep(struct thread *td); +void sched_sleep(struct thread *td, int prio); void sched_switch(struct thread *td, struct thread *newtd, int flags); void sched_throw(struct thread *td); void sched_unlend_prio(struct thread *td, u_char prio); Modified: user/kmacy/releng_7_2_fcs/sys/sys/sleepqueue.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/sleepqueue.h Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/sys/sleepqueue.h Mon May 18 18:50:38 2009 (r192325) @@ -102,10 +102,10 @@ void sleepq_release(void *wchan); void sleepq_remove(struct thread *td, void *wchan); int sleepq_signal(void *wchan, int flags, int pri, int queue); void sleepq_set_timeout(void *wchan, int timo); -int sleepq_timedwait(void *wchan); -int sleepq_timedwait_sig(void *wchan); -void sleepq_wait(void *wchan); -int sleepq_wait_sig(void *wchan); +int sleepq_timedwait(void *wchan, int pri); +int sleepq_timedwait_sig(void *wchan, int pri); +void sleepq_wait(void *wchan, int pri); +int sleepq_wait_sig(void *wchan, int pri); #endif /* _KERNEL */ #endif /* !_SYS_SLEEPQUEUE_H_ */ Modified: user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c Mon May 18 18:50:38 2009 (r192325) @@ -885,8 +885,7 @@ retry: * This could be refined to support * swapping out a thread. */ - if ((td->td_priority) < PSOCK || - !thread_safetoswapout(td)) { + if (!thread_safetoswapout(td)) { thread_unlock(td); goto nextproc; } Modified: user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c Mon May 18 18:44:54 2009 (r192324) +++ user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c Mon May 18 18:50:38 2009 (r192325) @@ -96,7 +96,6 @@ SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CT static int vmtotal(SYSCTL_HANDLER_ARGS) { -/* XXXKSE almost completely broken */ struct proc *p; struct vmtotal total; vm_map_entry_t entry; @@ -139,25 +138,16 @@ vmtotal(SYSCTL_HANDLER_ARGS) break; default: FOREACH_THREAD_IN_PROC(p, td) { - /* Need new statistics XXX */ thread_lock(td); switch (td->td_state) { case TDS_INHIBITED: - /* - * XXX stats no longer synchronized. - */ - if (TD_ON_LOCK(td) || - (td->td_inhibitors == - TDI_SWAPPED)) { + if (TD_IS_SWAPPED(td)) total.t_sw++; - } else if (TD_IS_SLEEPING(td) || - TD_AWAITING_INTR(td) || - TD_IS_SUSPENDED(td)) { - if (td->td_priority <= PZERO) - total.t_dw++; - else - total.t_sl++; - } + else if (TD_IS_SLEEPING(td) && + td->td_priority <= PZERO) + total.t_dw++; + else + total.t_sl++; break; case TDS_CAN_RUN: From owner-svn-src-user@FreeBSD.ORG Mon May 18 18:54:44 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15799106564A; Mon, 18 May 2009 18:54:44 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 030A28FC1C; Mon, 18 May 2009 18:54:44 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IIshE7071707; Mon, 18 May 2009 18:54:43 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IIsha8071703; Mon, 18 May 2009 18:54:43 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181854.n4IIsha8071703@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 18:54:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192326 - in user/kmacy/releng_7_2_fcs/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 18:54:44 -0000 Author: kmacy Date: Mon May 18 18:54:43 2009 New Revision: 192326 URL: http://svn.freebsd.org/changeset/base/192326 Log: 177491 Fix a race where timeout/untimeout could cause crashes for Giant locked code. The bug: There exists a race condition for timeout/untimeout(9) due to the way that the softclock thread dequeues timeouts. The softclock thread sets the c_func and c_arg of the callout to NULL while holding the callout lock but not Giant. It then drops the callout lock and acquires Giant. It is at this point where untimeout(9) on another cpu/thread could be called. Since c_arg and c_func are cleared, untimeout(9) does not touch the callout and returns as if the callout is canceled. The softclock then tries to acquire Giant and likely blocks due to the other cpu/thread holding it. The other cpu/thread then likely deallocates the backing store that c_arg points to and finishes working and hence drops Giant. Softclock resumes and acquires giant and calls the function with the now free'd c_arg and we have corruption/crash. The fix: We need to track curr_callout even for timeout(9) (LOCAL_ALLOC) callouts. We need to free the callout after the softclock processes it to deal with the race here. 177859 Implement per-cpu callout threads, wheels, and locks. - Move callout thread creation from kern_intr.c to kern_timeout.c - Call callout_tick() on every processor via hardclock_cpu() rather than inspecting callout internal details in kern_clock.c. - Remove callout implementation details from callout.h - Package up all of the global variables into a per-cpu callout structure. - Start one thread per-cpu. Threads are not strictly bound. They prefer to execute on the native cpu but may migrate temporarily if interrupts are starving callout processing. - Run all callouts by default in the thread for cpu0 to maintain current ordering and concurrency guarantees. Many consumers may not properly handle concurrent execution. - The new callout_reset_on() api allows specifying a particular cpu to execute the callout on. This may migrate a callout to a new cpu. callout_reset() schedules on the last assigned cpu while callout_reset_curcpu() schedules on the current cpu. 177949 - Correct a major error introduced in the per-cpu timeout commit. Sleep and wakeup require the same wait channel to function properly. Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c user/kmacy/releng_7_2_fcs/sys/kern/kern_intr.c user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c user/kmacy/releng_7_2_fcs/sys/sys/callout.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c Mon May 18 18:50:38 2009 (r192325) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c Mon May 18 18:54:43 2009 (r192326) @@ -292,6 +292,7 @@ hardclock_cpu(int usermode) if (PMC_CPU_HAS_SAMPLES(PCPU_GET(cpuid))) PMC_CALL_HOOK_UNLOCKED(curthread, PMC_FN_DO_SAMPLES, NULL); #endif + callout_tick(); } /* @@ -300,10 +301,9 @@ hardclock_cpu(int usermode) void hardclock(int usermode, uintfptr_t pc) { - int need_softclock = 0; + atomic_add_int((volatile int *)&ticks, 1); hardclock_cpu(usermode); - tc_ticktock(); /* * If no separate statistics clock is available, run it from here. @@ -314,30 +314,9 @@ hardclock(int usermode, uintfptr_t pc) profclock(usermode, pc); statclock(usermode); } - #ifdef DEVICE_POLLING hardclock_device_poll(); /* this is very short and quick */ #endif /* DEVICE_POLLING */ - - /* - * Process callouts at a very low cpu priority, so we don't keep the - * relatively high clock interrupt priority any longer than necessary. - */ - mtx_lock_spin_flags(&callout_lock, MTX_QUIET); - ticks++; - if (!TAILQ_EMPTY(&callwheel[ticks & callwheelmask])) { - need_softclock = 1; - } else if (softticks + 1 == ticks) - ++softticks; - mtx_unlock_spin_flags(&callout_lock, MTX_QUIET); - - /* - * swi_sched acquires the thread lock, so we don't want to call it - * with callout_lock held; incorrect locking order. - */ - if (need_softclock) - swi_sched(softclock_ih, 0); - #ifdef SW_WATCHDOG if (watchdog_enabled > 0 && --watchdog_ticks <= 0) watchdog_fire(); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_intr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_intr.c Mon May 18 18:50:38 2009 (r192325) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_intr.c Mon May 18 18:54:43 2009 (r192326) @@ -79,7 +79,6 @@ struct intr_entropy { struct intr_event *clk_intr_event; struct intr_event *tty_intr_event; -void *softclock_ih; void *vm_ih; static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads"); @@ -957,9 +956,18 @@ swi_add(struct intr_event **eventp, cons if (eventp != NULL) *eventp = ie; } - return (intr_event_add_handler(ie, name, NULL, handler, arg, - (pri * RQ_PPQ) + PI_SOFT, flags, cookiep)); - /* XXKSE.. think of a better way to get separate queues */ + error = intr_event_add_handler(ie, name, NULL, handler, arg, + (pri * RQ_PPQ) + PI_SOFT, flags, cookiep); + if (error) + return (error); + if (pri == SWI_CLOCK) { + struct proc *p; + p = ie->ie_thread->it_thread->td_proc; + PROC_LOCK(p); + p->p_flag |= P_NOLOAD; + PROC_UNLOCK(p); + } + return (0); } /* @@ -1591,17 +1599,9 @@ DB_SHOW_COMMAND(intr, db_show_intr) static void start_softintr(void *dummy) { - struct proc *p; - if (swi_add(&clk_intr_event, "clock", softclock, NULL, SWI_CLOCK, - INTR_MPSAFE, &softclock_ih) || - swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, INTR_MPSAFE, &vm_ih)) - panic("died while creating standard software ithreads"); - - p = clk_intr_event->ie_thread->it_thread->td_proc; - PROC_LOCK(p); - p->p_flag |= P_NOLOAD; - PROC_UNLOCK(p); + if (swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, INTR_MPSAFE, &vm_ih)) + panic("died while creating vm swi ithread"); } SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, NULL); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 18:50:38 2009 (r192325) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 18:54:43 2009 (r192326) @@ -39,15 +39,19 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include #include #include #include +#include #include #include #include #include +#include static int avg_depth; SYSCTL_INT(_debug, OID_AUTO, to_avg_depth, CTLFLAG_RD, &avg_depth, 0, @@ -65,36 +69,53 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpca * TODO: * allocate more timeout table slots when table overflows. */ - -/* Exported to machdep.c and/or kern_clock.c. */ -struct callout *callout; -struct callout_list callfree; int callwheelsize, callwheelbits, callwheelmask; -struct callout_tailq *callwheel; -int softticks; /* Like ticks, but for softclock(). */ -struct mtx callout_lock; -static struct callout *nextsoftcheck; /* Next callout to be checked. */ +struct callout_cpu { + struct mtx cc_lock; + struct callout *cc_callout; + struct callout_tailq *cc_callwheel; + struct callout_list cc_callfree; + struct callout *cc_next; + struct callout *cc_curr; + void *cc_cookie; + int cc_softticks; + int cc_cancel; + int cc_waiting; +}; + +#ifdef SMP +struct callout_cpu cc_cpu[MAXCPU]; +#define CC_CPU(cpu) (&cc_cpu[(cpu)]) +#define CC_SELF() CC_CPU(PCPU_GET(cpuid)) +#else +struct callout_cpu cc_cpu; +#define CC_CPU(cpu) &cc_cpu +#define CC_SELF() &cc_cpu +#endif +#define CC_LOCK(cc) mtx_lock_spin(&(cc)->cc_lock) +#define CC_UNLOCK(cc) mtx_unlock_spin(&(cc)->cc_lock) + +static int timeout_cpu; + +MALLOC_DEFINE(M_CALLOUT, "callout", "Callout datastructures"); /** - * Locked by callout_lock: - * curr_callout - If a callout is in progress, it is curr_callout. + * Locked by cc_lock: + * cc_curr - If a callout is in progress, it is curr_callout. * If curr_callout is non-NULL, threads waiting in - * callout_drain() will be woken up as soon as the + * callout_drain() will be woken up as soon as the * relevant callout completes. - * curr_cancelled - Changing to 1 with both callout_lock and c_lock held + * cc_cancel - Changing to 1 with both callout_lock and c_lock held * guarantees that the current callout will not run. * The softclock() function sets this to 0 before it * drops callout_lock to acquire c_lock, and it calls * the handler only if curr_cancelled is still 0 after * c_lock is successfully acquired. - * callout_wait - If a thread is waiting in callout_drain(), then + * cc_waiting - If a thread is waiting in callout_drain(), then * callout_wait is nonzero. Set only when * curr_callout is non-NULL. */ -static struct callout *curr_callout; -static int curr_cancelled; -static int callout_wait; /* * kern_timeout_callwheel_alloc() - kernel low level callwheel initialization @@ -105,6 +126,10 @@ static int callout_wait; caddr_t kern_timeout_callwheel_alloc(caddr_t v) { + struct callout_cpu *cc; + + timeout_cpu = PCPU_GET(cpuid); + cc = CC_CPU(timeout_cpu); /* * Calculate callout wheel size */ @@ -114,13 +139,34 @@ kern_timeout_callwheel_alloc(caddr_t v) ; callwheelmask = callwheelsize - 1; - callout = (struct callout *)v; - v = (caddr_t)(callout + ncallout); - callwheel = (struct callout_tailq *)v; - v = (caddr_t)(callwheel + callwheelsize); + cc->cc_callout = (struct callout *)v; + v = (caddr_t)(cc->cc_callout + ncallout); + cc->cc_callwheel = (struct callout_tailq *)v; + v = (caddr_t)(cc->cc_callwheel + callwheelsize); return(v); } +static void +callout_cpu_init(struct callout_cpu *cc) +{ + struct callout *c; + int i; + + mtx_init(&cc->cc_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE); + SLIST_INIT(&cc->cc_callfree); + for (i = 0; i < callwheelsize; i++) { + TAILQ_INIT(&cc->cc_callwheel[i]); + } + if (cc->cc_callout == NULL) + return; + for (i = 0; i < ncallout; i++) { + c = &cc->cc_callout[i]; + callout_init(c, 0); + c->c_flags = CALLOUT_LOCAL_ALLOC; + SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); + } +} + /* * kern_timeout_callwheel_init() - initialize previously reserved callwheel * space. @@ -131,18 +177,88 @@ kern_timeout_callwheel_alloc(caddr_t v) void kern_timeout_callwheel_init(void) { - int i; + callout_cpu_init(CC_CPU(timeout_cpu)); +} - SLIST_INIT(&callfree); - for (i = 0; i < ncallout; i++) { - callout_init(&callout[i], 0); - callout[i].c_flags = CALLOUT_LOCAL_ALLOC; - SLIST_INSERT_HEAD(&callfree, &callout[i], c_links.sle); +/* + * Start standard softclock thread. + */ +void *softclock_ih; + +static void +start_softclock(void *dummy) +{ + struct callout_cpu *cc; +#ifdef SMP + int cpu; +#endif + + cc = CC_CPU(timeout_cpu); + if (swi_add(&clk_intr_event, "clock", softclock, cc, SWI_CLOCK, + INTR_MPSAFE, &softclock_ih)) + panic("died while creating standard software ithreads"); + cc->cc_cookie = softclock_ih; +#ifdef SMP + for (cpu = 0; cpu <= mp_maxid; cpu++) { + if (cpu == timeout_cpu) + continue; + if (CPU_ABSENT(cpu)) + continue; + cc = CC_CPU(cpu); + if (swi_add(NULL, "clock", softclock, cc, SWI_CLOCK, + INTR_MPSAFE, &cc->cc_cookie)) + panic("died while creating standard software ithreads"); + cc->cc_callout = NULL; /* Only cpu0 handles timeout(). */ + cc->cc_callwheel = malloc( + sizeof(struct callout_tailq) * callwheelsize, M_CALLOUT, + M_WAITOK); + callout_cpu_init(cc); } - for (i = 0; i < callwheelsize; i++) { - TAILQ_INIT(&callwheel[i]); +#endif +} + +SYSINIT(start_softclock, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softclock, NULL); + +void +callout_tick(void) +{ + int need_softclock = 0; + struct callout_cpu *cc; + + /* + * Process callouts at a very low cpu priority, so we don't keep the + * relatively high clock interrupt priority any longer than necessary. + */ + cc = CC_SELF(); + mtx_lock_spin_flags(&cc->cc_lock, MTX_QUIET); + if (!TAILQ_EMPTY(&cc->cc_callwheel[ticks & callwheelmask])) { + need_softclock = 1; + } else if (cc->cc_softticks + 1 == ticks) + ++cc->cc_softticks; + mtx_unlock_spin_flags(&cc->cc_lock, MTX_QUIET); + /* + * swi_sched acquires the thread lock, so we don't want to call it + * with cc_lock held; incorrect locking order. + */ + if (need_softclock) + swi_sched(cc->cc_cookie, 0); +} + +static struct callout_cpu * +callout_lock(struct callout *c) +{ + struct callout_cpu *cc; + int cpu; + + for (;;) { + cpu = c->c_cpu; + cc = CC_CPU(cpu); + CC_LOCK(cc); + if (cpu == c->c_cpu) + break; + CC_UNLOCK(cc); } - mtx_init(&callout_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE); + return (cc); } /* @@ -162,8 +278,9 @@ kern_timeout_callwheel_init(void) * Run periodic events from timeout queue. */ void -softclock(void *dummy) +softclock(void *arg) { + struct callout_cpu *cc; struct callout *c; struct callout_tailq *bucket; int curticks; @@ -188,15 +305,16 @@ softclock(void *dummy) gcalls = 0; depth = 0; steps = 0; - mtx_lock_spin(&callout_lock); - while (softticks != ticks) { - softticks++; + cc = (struct callout_cpu *)arg; + CC_LOCK(cc); + while (cc->cc_softticks != ticks) { + cc->cc_softticks++; /* - * softticks may be modified by hard clock, so cache + * cc_softticks may be modified by hard clock, so cache * it while we work on a given bucket. */ - curticks = softticks; - bucket = &callwheel[curticks & callwheelmask]; + curticks = cc->cc_softticks; + bucket = &cc->cc_callwheel[curticks & callwheelmask]; c = TAILQ_FIRST(bucket); while (c) { depth++; @@ -204,12 +322,12 @@ softclock(void *dummy) c = TAILQ_NEXT(c, c_links.tqe); ++steps; if (steps >= MAX_SOFTCLOCK_STEPS) { - nextsoftcheck = c; + cc->cc_next = c; /* Give interrupts a chance. */ - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); ; /* nothing */ - mtx_lock_spin(&callout_lock); - c = nextsoftcheck; + CC_LOCK(cc); + c = cc->cc_next; steps = 0; } } else { @@ -219,7 +337,7 @@ softclock(void *dummy) struct lock_object *c_lock; int c_flags, sharedlock; - nextsoftcheck = TAILQ_NEXT(c, c_links.tqe); + cc->cc_next = TAILQ_NEXT(c, c_links.tqe); TAILQ_REMOVE(bucket, c, c_links.tqe); class = (c->c_lock != NULL) ? LOCK_CLASS(c->c_lock) : NULL; @@ -230,30 +348,26 @@ softclock(void *dummy) c_arg = c->c_arg; c_flags = c->c_flags; if (c->c_flags & CALLOUT_LOCAL_ALLOC) { - c->c_func = NULL; c->c_flags = CALLOUT_LOCAL_ALLOC; - SLIST_INSERT_HEAD(&callfree, c, - c_links.sle); - curr_callout = NULL; } else { c->c_flags = (c->c_flags & ~CALLOUT_PENDING); - curr_callout = c; } - curr_cancelled = 0; - mtx_unlock_spin(&callout_lock); + cc->cc_curr = c; + cc->cc_cancel = 0; + CC_UNLOCK(cc); if (c_lock != NULL) { class->lc_lock(c_lock, sharedlock); /* * The callout may have been cancelled * while we switched locks. */ - if (curr_cancelled) { + if (cc->cc_cancel) { class->lc_unlock(c_lock); goto skip; } /* The callout cannot be stopped now. */ - curr_cancelled = 1; + cc->cc_cancel = 1; if (c_lock == &Giant.lock_object) { gcalls++; @@ -299,20 +413,38 @@ softclock(void *dummy) if ((c_flags & CALLOUT_RETURNUNLOCKED) == 0) class->lc_unlock(c_lock); skip: - mtx_lock_spin(&callout_lock); - curr_callout = NULL; - if (callout_wait) { + CC_LOCK(cc); + /* + * If the current callout is locally + * allocated (from timeout(9)) + * then put it on the freelist. + * + * Note: we need to check the cached + * copy of c_flags because if it was not + * local, then it's not safe to deref the + * callout pointer. + */ + if (c_flags & CALLOUT_LOCAL_ALLOC) { + KASSERT(c->c_flags == + CALLOUT_LOCAL_ALLOC, + ("corrupted callout")); + c->c_func = NULL; + SLIST_INSERT_HEAD(&cc->cc_callfree, c, + c_links.sle); + } + cc->cc_curr = NULL; + if (cc->cc_waiting) { /* * There is someone waiting * for the callout to complete. */ - callout_wait = 0; - mtx_unlock_spin(&callout_lock); - wakeup(&callout_wait); - mtx_lock_spin(&callout_lock); + cc->cc_waiting = 0; + CC_UNLOCK(cc); + wakeup(&cc->cc_waiting); + CC_LOCK(cc); } steps = 0; - c = nextsoftcheck; + c = cc->cc_next; } } } @@ -320,8 +452,8 @@ softclock(void *dummy) avg_mpcalls += (mpcalls * 1000 - avg_mpcalls) >> 8; avg_lockcalls += (lockcalls * 1000 - avg_lockcalls) >> 8; avg_gcalls += (gcalls * 1000 - avg_gcalls) >> 8; - nextsoftcheck = NULL; - mtx_unlock_spin(&callout_lock); + cc->cc_next = NULL; + CC_UNLOCK(cc); } /* @@ -346,22 +478,22 @@ timeout(ftn, arg, to_ticks) void *arg; int to_ticks; { + struct callout_cpu *cc; struct callout *new; struct callout_handle handle; - mtx_lock_spin(&callout_lock); - + cc = CC_CPU(timeout_cpu); + CC_LOCK(cc); /* Fill in the next free callout structure. */ - new = SLIST_FIRST(&callfree); + new = SLIST_FIRST(&cc->cc_callfree); if (new == NULL) /* XXX Attempt to malloc first */ panic("timeout table full"); - SLIST_REMOVE_HEAD(&callfree, c_links.sle); - + SLIST_REMOVE_HEAD(&cc->cc_callfree, c_links.sle); callout_reset(new, to_ticks, ftn, arg); - handle.callout = new; - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); + return (handle); } @@ -371,6 +503,7 @@ untimeout(ftn, arg, handle) void *arg; struct callout_handle handle; { + struct callout_cpu *cc; /* * Check for a handle that was initialized @@ -380,10 +513,10 @@ untimeout(ftn, arg, handle) if (handle.callout == NULL) return; - mtx_lock_spin(&callout_lock); + cc = callout_lock(handle.callout); if (handle.callout->c_func == ftn && handle.callout->c_arg == arg) callout_stop(handle.callout); - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); } void @@ -409,24 +542,29 @@ callout_handle_init(struct callout_handl * callout_deactivate() - marks the callout as having been serviced */ int -callout_reset(c, to_ticks, ftn, arg) - struct callout *c; - int to_ticks; - void (*ftn)(void *); - void *arg; +callout_reset_on(struct callout *c, int to_ticks, void (*ftn)(void *), + void *arg, int cpu) { + struct callout_cpu *cc; int cancelled = 0; - mtx_lock_spin(&callout_lock); - if (c == curr_callout) { + /* + * Don't allow migration of pre-allocated callouts lest they + * become unbalanced. + */ + if (c->c_flags & CALLOUT_LOCAL_ALLOC) + cpu = c->c_cpu; +retry: + cc = callout_lock(c); + if (cc->cc_curr == c) { /* * We're being asked to reschedule a callout which is * currently in progress. If there is a lock then we * can cancel the callout if it has not really started. */ - if (c->c_lock != NULL && !curr_cancelled) - cancelled = curr_cancelled = 1; - if (callout_wait) { + if (c->c_lock != NULL && !cc->cc_cancel) + cancelled = cc->cc_cancel = 1; + if (cc->cc_waiting) { /* * Someone has called callout_drain to kill this * callout. Don't reschedule. @@ -434,34 +572,30 @@ callout_reset(c, to_ticks, ftn, arg) CTR4(KTR_CALLOUT, "%s %p func %p arg %p", cancelled ? "cancelled" : "failed to cancel", c, c->c_func, c->c_arg); - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); return (cancelled); } } if (c->c_flags & CALLOUT_PENDING) { - if (nextsoftcheck == c) { - nextsoftcheck = TAILQ_NEXT(c, c_links.tqe); + if (cc->cc_next == c) { + cc->cc_next = TAILQ_NEXT(c, c_links.tqe); } - TAILQ_REMOVE(&callwheel[c->c_time & callwheelmask], c, + TAILQ_REMOVE(&cc->cc_callwheel[c->c_time & callwheelmask], c, c_links.tqe); cancelled = 1; - - /* - * Part of the normal "stop a pending callout" process - * is to clear the CALLOUT_ACTIVE and CALLOUT_PENDING - * flags. We're not going to bother doing that here, - * because we're going to be setting those flags ten lines - * after this point, and we're holding callout_lock - * between now and then. - */ + c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING); } - /* - * We could unlock callout_lock here and lock it again before the - * TAILQ_INSERT_TAIL, but there's no point since doing this setup - * doesn't take much time. + * If the lock must migrate we have to check the state again as + * we can't hold both the new and old locks simultaneously. */ + if (c->c_cpu != cpu) { + c->c_cpu = cpu; + CC_UNLOCK(cc); + goto retry; + } + if (to_ticks <= 0) to_ticks = 1; @@ -469,11 +603,11 @@ callout_reset(c, to_ticks, ftn, arg) c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING); c->c_func = ftn; c->c_time = ticks + to_ticks; - TAILQ_INSERT_TAIL(&callwheel[c->c_time & callwheelmask], + TAILQ_INSERT_TAIL(&cc->cc_callwheel[c->c_time & callwheelmask], c, c_links.tqe); CTR5(KTR_CALLOUT, "%sscheduled %p func %p arg %p in %d", cancelled ? "re" : "", c, c->c_func, c->c_arg, to_ticks); - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); return (cancelled); } @@ -483,6 +617,7 @@ _callout_stop_safe(c, safe) struct callout *c; int safe; { + struct callout_cpu *cc; struct lock_class *class; int use_lock, sq_locked; @@ -505,7 +640,7 @@ _callout_stop_safe(c, safe) sq_locked = 0; again: - mtx_lock_spin(&callout_lock); + cc = callout_lock(c); /* * If the callout isn't pending, it's not on the queue, so * don't attempt to remove it from the queue. We can try to @@ -518,12 +653,12 @@ again: * If it wasn't on the queue and it isn't the current * callout, then we can't stop it, so just bail. */ - if (c != curr_callout) { + if (cc->cc_curr != c) { CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); if (sq_locked) - sleepq_release(&callout_wait); + sleepq_release(&cc->cc_waiting); return (0); } @@ -534,19 +669,19 @@ again: * just wait for the current invocation to * finish. */ - while (c == curr_callout) { + while (cc->cc_curr == c) { /* * Use direct calls to sleepqueue interface * instead of cv/msleep in order to avoid - * a LOR between callout_lock and sleepqueue + * a LOR between cc_lock and sleepqueue * chain spinlocks. This piece of code * emulates a msleep_spin() call actually. * * If we already have the sleepqueue chain * locked, then we can safely block. If we * don't already have it locked, however, - * we have to drop the callout_lock to lock + * we have to drop the cc_lock to lock * it. This opens several races, so we * restart at the beginning once we have * both locks. If nothing has changed, then @@ -554,26 +689,25 @@ again: * set. */ if (!sq_locked) { - mtx_unlock_spin(&callout_lock); - sleepq_lock(&callout_wait); + CC_UNLOCK(cc); + sleepq_lock(&cc->cc_waiting); sq_locked = 1; goto again; } - - callout_wait = 1; + cc->cc_waiting = 1; DROP_GIANT(); - mtx_unlock_spin(&callout_lock); - sleepq_add(&callout_wait, - &callout_lock.lock_object, "codrain", + CC_UNLOCK(cc); + sleepq_add(&cc->cc_waiting, + &cc->cc_lock.lock_object, "codrain", SLEEPQ_SLEEP, 0); - sleepq_wait(&callout_wait, 0); + sleepq_wait(&cc->cc_waiting, 0); sq_locked = 0; /* Reacquire locks previously released. */ PICKUP_GIANT(); - mtx_lock_spin(&callout_lock); + CC_LOCK(cc); } - } else if (use_lock && !curr_cancelled) { + } else if (use_lock && !cc->cc_cancel) { /* * The current callout is waiting for its * lock which we hold. Cancel the callout @@ -581,37 +715,38 @@ again: * lock, the callout will be skipped in * softclock(). */ - curr_cancelled = 1; + cc->cc_cancel = 1; CTR3(KTR_CALLOUT, "cancelled %p func %p arg %p", c, c->c_func, c->c_arg); - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); KASSERT(!sq_locked, ("sleepqueue chain locked")); return (1); } CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); KASSERT(!sq_locked, ("sleepqueue chain still locked")); return (0); } if (sq_locked) - sleepq_release(&callout_wait); + sleepq_release(&cc->cc_waiting); c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING); - if (nextsoftcheck == c) { - nextsoftcheck = TAILQ_NEXT(c, c_links.tqe); + if (cc->cc_next == c) { + cc->cc_next = TAILQ_NEXT(c, c_links.tqe); } - TAILQ_REMOVE(&callwheel[c->c_time & callwheelmask], c, c_links.tqe); + TAILQ_REMOVE(&cc->cc_callwheel[c->c_time & callwheelmask], c, + c_links.tqe); CTR3(KTR_CALLOUT, "cancelled %p func %p arg %p", c, c->c_func, c->c_arg); if (c->c_flags & CALLOUT_LOCAL_ALLOC) { c->c_func = NULL; - SLIST_INSERT_HEAD(&callfree, c, c_links.sle); + SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); } - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); return (1); } @@ -628,6 +763,7 @@ callout_init(c, mpsafe) c->c_lock = &Giant.lock_object; c->c_flags = 0; } + c->c_cpu = timeout_cpu; } void @@ -646,6 +782,7 @@ _callout_init_lock(c, lock, flags) (LC_SPINLOCK | LC_SLEEPABLE)), ("%s: invalid lock class", __func__)); c->c_flags = flags & (CALLOUT_RETURNUNLOCKED | CALLOUT_SHAREDLOCK); + c->c_cpu = timeout_cpu; } #ifdef APM_FIXUP_CALLTODO @@ -697,7 +834,7 @@ adjust_timeout_calltodo(time_change) */ /* don't collide with softclock() */ - mtx_lock_spin(&callout_lock); + CC_LOCK(cc); for (p = calltodo.c_next; p != NULL; p = p->c_next) { p->c_time -= delta_ticks; @@ -708,7 +845,7 @@ adjust_timeout_calltodo(time_change) /* take back the ticks the timer didn't use (p->c_time <= 0) */ delta_ticks = -p->c_time; } - mtx_unlock_spin(&callout_lock); + CC_UNLOCK(cc); return; } Modified: user/kmacy/releng_7_2_fcs/sys/sys/callout.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/callout.h Mon May 18 18:50:38 2009 (r192325) +++ user/kmacy/releng_7_2_fcs/sys/sys/callout.h Mon May 18 18:54:43 2009 (r192326) @@ -52,9 +52,10 @@ struct callout { } c_links; int c_time; /* ticks to the event */ void *c_arg; /* function argument */ - void (*c_func)(void *); /* function to call */ + void (*c_func)(void *); /* function to call */ struct lock_object *c_lock; /* lock to handle */ int c_flags; /* state of this entry */ + volatile int c_cpu; /* CPU we're scheduled on */ }; #define CALLOUT_LOCAL_ALLOC 0x0001 /* was allocated from callfree */ @@ -69,12 +70,7 @@ struct callout_handle { }; #ifdef _KERNEL -extern struct callout_list callfree; -extern struct callout *callout; extern int ncallout; -extern struct callout_tailq *callwheel; -extern int callwheelsize, callwheelbits, callwheelmask, softticks; -extern struct mtx callout_lock; #define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) @@ -88,9 +84,15 @@ void _callout_init_lock(struct callout * _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \ NULL, (flags)) #define callout_pending(c) ((c)->c_flags & CALLOUT_PENDING) -int callout_reset(struct callout *, int, void (*)(void *), void *); +int callout_reset_on(struct callout *, int, void (*)(void *), void *, int); +#define callout_reset(c, on_tick, fn, arg) \ + callout_reset_on((c), (on_tick), (fn), (arg), (c)->c_cpu) +#define callout_reset_curcpu(c, on_tick, fn, arg) \ + callout_reset_on((c), (on_tick), (fn), (arg), PCPU_GET(cpuid)) #define callout_stop(c) _callout_stop_safe(c, 0) int _callout_stop_safe(struct callout *, int); +void callout_tick(void); + #endif From owner-svn-src-user@FreeBSD.ORG Mon May 18 19:01:32 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD5CA1065670; Mon, 18 May 2009 19:01:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB8A28FC1C; Mon, 18 May 2009 19:01:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IJ1Wec071932; Mon, 18 May 2009 19:01:32 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IJ1WBs071930; Mon, 18 May 2009 19:01:32 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181901.n4IJ1WBs071930@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 19:01:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192327 - in user/kmacy/releng_7_2_fcs/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 19:01:33 -0000 Author: kmacy Date: Mon May 18 19:01:32 2009 New Revision: 192327 URL: http://svn.freebsd.org/changeset/base/192327 Log: 180608: Fix a race which could result in some timeout buckets being skipped. - When a tick occurs on a cpu, iterate from cs_softticks until ticks. The per-cpu tick processing happens asynchronously with the actual adjustment of the 'ticks' variable. Sometimes the results may be visible before the local call and sometimes after. Previously this could cause a one tick window where we didn't evaluate the bucket. - In softclock fetch curticks before incrementing cc_softticks so we don't skip insertions which were made for the current time. Sponsored by: Nokia 181191 add callout_schedule; besides being useful it also improves compatibility with other systems Reviewed by: ed, battlez 184385 After a machine has been up for a bit more than 20 days with HZ=1000, "ticks" goes negative. This breaks the signed comparison in softclock. This causes sleep() to never wake up, tcp to stop, etc etc. This is bad(TM). Use the SEQ_LT() method from tcp's sequence number comparisons. Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c user/kmacy/releng_7_2_fcs/sys/sys/callout.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 18:54:43 2009 (r192326) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_timeout.c Mon May 18 19:01:32 2009 (r192327) @@ -222,19 +222,24 @@ SYSINIT(start_softclock, SI_SUB_SOFTINTR void callout_tick(void) { - int need_softclock = 0; struct callout_cpu *cc; + int need_softclock; + int bucket; /* * Process callouts at a very low cpu priority, so we don't keep the * relatively high clock interrupt priority any longer than necessary. */ + need_softclock = 0; cc = CC_SELF(); mtx_lock_spin_flags(&cc->cc_lock, MTX_QUIET); - if (!TAILQ_EMPTY(&cc->cc_callwheel[ticks & callwheelmask])) { - need_softclock = 1; - } else if (cc->cc_softticks + 1 == ticks) - ++cc->cc_softticks; + for (; (cc->cc_softticks - ticks) < 0; cc->cc_softticks++) { + bucket = cc->cc_softticks & callwheelmask; + if (!TAILQ_EMPTY(&cc->cc_callwheel[bucket])) { + need_softclock = 1; + break; + } + } mtx_unlock_spin_flags(&cc->cc_lock, MTX_QUIET); /* * swi_sched acquires the thread lock, so we don't want to call it @@ -308,12 +313,12 @@ softclock(void *arg) cc = (struct callout_cpu *)arg; CC_LOCK(cc); while (cc->cc_softticks != ticks) { - cc->cc_softticks++; /* * cc_softticks may be modified by hard clock, so cache * it while we work on a given bucket. */ curticks = cc->cc_softticks; + cc->cc_softticks++; bucket = &cc->cc_callwheel[curticks & callwheelmask]; c = TAILQ_FIRST(bucket); while (c) { @@ -612,6 +617,21 @@ retry: return (cancelled); } +/* + * Common idioms that can be optimized in the future. + */ +int +callout_schedule_on(struct callout *c, int to_ticks, int cpu) +{ + return callout_reset_on(c, to_ticks, c->c_func, c->c_arg, cpu); +} + +int +callout_schedule(struct callout *c, int to_ticks) +{ + return callout_reset_on(c, to_ticks, c->c_func, c->c_arg, c->c_cpu); +} + int _callout_stop_safe(c, safe) struct callout *c; Modified: user/kmacy/releng_7_2_fcs/sys/sys/callout.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/callout.h Mon May 18 18:54:43 2009 (r192326) +++ user/kmacy/releng_7_2_fcs/sys/sys/callout.h Mon May 18 19:01:32 2009 (r192327) @@ -89,6 +89,10 @@ int callout_reset_on(struct callout *, i callout_reset_on((c), (on_tick), (fn), (arg), (c)->c_cpu) #define callout_reset_curcpu(c, on_tick, fn, arg) \ callout_reset_on((c), (on_tick), (fn), (arg), PCPU_GET(cpuid)) +int callout_schedule(struct callout *, int); +int callout_schedule_on(struct callout *, int, int); +#define callout_schedule_curcpu(c, on_tick) \ + callout_schedule_on((c), (on_tick), PCPU_GET(cpuid)) #define callout_stop(c) _callout_stop_safe(c, 0) int _callout_stop_safe(struct callout *, int); void callout_tick(void); From owner-svn-src-user@FreeBSD.ORG Mon May 18 19:08:00 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C25B31065677; Mon, 18 May 2009 19:08:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1F6948FC19; Mon, 18 May 2009 19:07:59 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IJ7xmo072110; Mon, 18 May 2009 19:07:59 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IJ7xG5072109; Mon, 18 May 2009 19:07:59 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181907.n4IJ7xG5072109@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 19:07:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192329 - user/kmacy/releng_7_2_fcs/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 19:08:01 -0000 Author: kmacy Date: Mon May 18 19:07:58 2009 New Revision: 192329 URL: http://svn.freebsd.org/changeset/base/192329 Log: use per-cpu callouts for tcp timers Modified: user/kmacy/releng_7_2_fcs/sys/netinet/tcp_timer.c Modified: user/kmacy/releng_7_2_fcs/sys/netinet/tcp_timer.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netinet/tcp_timer.c Mon May 18 19:02:55 2009 (r192328) +++ user/kmacy/releng_7_2_fcs/sys/netinet/tcp_timer.c Mon May 18 19:07:58 2009 (r192329) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -119,6 +120,8 @@ int tcp_maxpersistidle; /* max idle time in persist */ int tcp_maxidle; +#define INP_CPU(inp) min(curcpu, ((inp)->inp_flowid % mp_maxid)) + /* * Tcp protocol timeout routine called every 500 ms. * Updates timestamps used for TCP @@ -256,8 +259,8 @@ tcp_timer_2msl(void *xtp) } else { if (tp->t_state != TCPS_TIME_WAIT && (ticks - tp->t_rcvtime) <= tcp_maxidle) - callout_reset(&tp->t_timers->tt_2msl, tcp_keepintvl, - tcp_timer_2msl, tp); + callout_reset_on(&tp->t_timers->tt_2msl, tcp_keepintvl, + tcp_timer_2msl, tp, INP_CPU(inp)); else tp = tcp_close(tp); } @@ -341,9 +344,9 @@ tcp_timer_keep(void *xtp) tp->rcv_nxt, tp->snd_una - 1, 0); free(t_template, M_TEMP); } - callout_reset(&tp->t_timers->tt_keep, tcp_keepintvl, tcp_timer_keep, tp); + callout_reset_on(&tp->t_timers->tt_keep, tcp_keepintvl, tcp_timer_keep, tp, INP_CPU(inp)); } else - callout_reset(&tp->t_timers->tt_keep, tcp_keepidle, tcp_timer_keep, tp); + callout_reset_on(&tp->t_timers->tt_keep, tcp_keepidle, tcp_timer_keep, tp, INP_CPU(inp)); #ifdef TCPDEBUG if (inp->inp_socket->so_options & SO_DEBUG) @@ -448,15 +451,13 @@ tcp_timer_rexmt(void * xtp) CURVNET_SET(tp->t_vnet); INIT_VNET_INET(tp->t_vnet); int rexmt; - int headlocked; struct inpcb *inp; #ifdef TCPDEBUG int ostate; ostate = tp->t_state; #endif - INP_INFO_WLOCK(&V_tcbinfo); - headlocked = 1; + INP_INFO_RLOCK(&V_tcbinfo); inp = tp->t_inpcb; /* * XXXRW: While this assert is in fact correct, bugs in the tcpcb @@ -467,7 +468,7 @@ tcp_timer_rexmt(void * xtp) */ if (inp == NULL) { tcp_timer_race++; - INP_INFO_WUNLOCK(&V_tcbinfo); + INP_INFO_RUNLOCK(&V_tcbinfo); CURVNET_RESTORE(); return; } @@ -475,7 +476,7 @@ tcp_timer_rexmt(void * xtp) if ((inp->inp_flags & INP_DROPPED) || callout_pending(&tp->t_timers->tt_rexmt) || !callout_active(&tp->t_timers->tt_rexmt)) { INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_tcbinfo); + INP_INFO_RUNLOCK(&V_tcbinfo); CURVNET_RESTORE(); return; } @@ -489,12 +490,22 @@ tcp_timer_rexmt(void * xtp) if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) { tp->t_rxtshift = TCP_MAXRXTSHIFT; V_tcpstat.tcps_timeoutdrop++; + in_pcbref(inp); + INP_INFO_RUNLOCK(&V_tcbinfo); + INP_WUNLOCK(inp); + INP_INFO_WLOCK(&V_tcbinfo); + INP_WLOCK(inp); + if (in_pcbrele(inp)) { + INP_INFO_WUNLOCK(&V_tcbinfo); + CURVNET_RESTORE(); + return; + } tp = tcp_drop(tp, tp->t_softerror ? tp->t_softerror : ETIMEDOUT); + INP_INFO_WUNLOCK(&V_tcbinfo); goto out; } - INP_INFO_WUNLOCK(&V_tcbinfo); - headlocked = 0; + INP_INFO_RUNLOCK(&V_tcbinfo); if (tp->t_rxtshift == 1) { /* * first retransmit; record ssthresh and cwnd so they can @@ -599,8 +610,6 @@ out: #endif if (tp != NULL) INP_WUNLOCK(inp); - if (headlocked) - INP_INFO_WUNLOCK(&V_tcbinfo); CURVNET_RESTORE(); } @@ -609,6 +618,8 @@ tcp_timer_activate(struct tcpcb *tp, int { struct callout *t_callout; void *f_callout; + struct inpcb *inp = tp->t_inpcb; + int cpu = INP_CPU(inp); switch (timer_type) { case TT_DELACK: @@ -637,7 +648,7 @@ tcp_timer_activate(struct tcpcb *tp, int if (delta == 0) { callout_stop(t_callout); } else { - callout_reset(t_callout, delta, f_callout, tp); + callout_reset_on(t_callout, delta, f_callout, tp, cpu); } } From owner-svn-src-user@FreeBSD.ORG Mon May 18 19:26:25 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AFD1C106564A; Mon, 18 May 2009 19:26:25 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9F1C78FC1A; Mon, 18 May 2009 19:26:25 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IJQPRE072474; Mon, 18 May 2009 19:26:25 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IJQPYf072473; Mon, 18 May 2009 19:26:25 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181926.n4IJQPYf072473@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 19:26:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192330 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 19:26:25 -0000 Author: kmacy Date: Mon May 18 19:26:25 2009 New Revision: 192330 URL: http://svn.freebsd.org/changeset/base/192330 Log: release sleepq in wakeup Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Mon May 18 19:07:58 2009 (r192329) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Mon May 18 19:26:25 2009 (r192330) @@ -334,6 +334,7 @@ wakeup(void *ident) sleepq_lock(ident); wakeup_swapper = sleepq_broadcast(ident, SLEEPQ_SLEEP, -1, 0); + sleepq_release(ident); if (wakeup_swapper) kick_proc0(); } From owner-svn-src-user@FreeBSD.ORG Mon May 18 19:47:55 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CFCE10656CD; Mon, 18 May 2009 19:47:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 39E908FC23; Mon, 18 May 2009 19:47:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IJlt9v072930; Mon, 18 May 2009 19:47:55 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IJltxt072926; Mon, 18 May 2009 19:47:55 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181947.n4IJltxt072926@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 19:47:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192332 - in user/kmacy/releng_7_2_fcs/sys: dev/hwpmc kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 19:47:55 -0000 Author: kmacy Date: Mon May 18 19:47:54 2009 New Revision: 192332 URL: http://svn.freebsd.org/changeset/base/192332 Log: merge hwpmc fix and new witness 180794 - Provide kernelname as the name for process with P_KTHREAD set as otherwise their textvp is NULL. 181695 Introduce some WITNESS improvements: - Speedup the lock orderings lookup modifying the witness graph from a linked tree to a matrix. A table lookup caches the lock orderings in order to make a O(1) access for them. Any witness object has an unique index withing this lookup cache table. - Reduce the lock contention on w_mtx acquiring it only when the LOR actually happens and not in a sane case. In order to do this don't totally flush lock lists (per-CPU spinlocks list and per-thread sleeplocks list) but check for ll_count anytime we need to have to verify allocations sanity. - Introduce the function witness_thread_exit() in the witness namespace which should verify a thread doesn't hold any witness occurrence why exiting. - Rename the sysctl debug.witness.graphs into debug.witness.fullgraph and add debug.witness.badstacks which prints out stacks for LOR revealed. This is implemented using the stack(9) support, which makes WITNESS to be dependent by the STACK option or by the DDB (including STACK) option. - Fix style(9) for src/sys/kern/subr_witness.c The hash table approach has been developed by Ilya Maykov on the behalf of Isilon Systems which kindly released the patch. Jeff Roberson, ported the patch to -CURRENT and fixed w_mtx contention, on the behalf of Nokia. Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c user/kmacy/releng_7_2_fcs/sys/sys/lock.h Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c Mon May 18 19:33:59 2009 (r192331) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c Mon May 18 19:47:54 2009 (r192332) @@ -952,7 +952,11 @@ pmc_attach_one_process(struct proc *p, s /* issue an attach event to a configured log file */ if (pm->pm_owner->po_flags & PMC_PO_OWNS_LOGFILE) { pmc_getfilename(p->p_textvp, &fullpath, &freepath); - pmclog_process_pmcattach(pm, p->p_pid, fullpath); + if (p->p_flag & P_KTHREAD) { + fullpath = kernelname; + freepath = NULL; + } else + pmclog_process_pmcattach(pm, p->p_pid, fullpath); if (freepath) FREE(freepath, M_TEMP); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Mon May 18 19:33:59 2009 (r192331) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Mon May 18 19:47:54 2009 (r192332) @@ -26,6 +26,8 @@ * DAMAGE. */ +#include "opt_witness.h" + #include __FBSDID("$FreeBSD$"); @@ -502,6 +504,9 @@ thread_exit(void) ruxagg(&p->p_rux, td); PROC_SUNLOCK(p); td->td_state = TDS_INACTIVE; +#ifdef WITNESS + witness_thread_exit(td); +#endif CTR1(KTR_PROC, "thread_exit: cpu_throw() thread %p", td); sched_throw(td); panic("I'm a teapot!"); Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c Mon May 18 19:33:59 2009 (r192331) +++ user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c Mon May 18 19:47:54 2009 (r192332) @@ -1,5 +1,8 @@ /*- - * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved. + * Copyright (c) 2008 Isilon Systems, Inc. + * Copyright (c) 2008 Ilya Maykov + * Copyright (c) 1998 Berkeley Software Design, Inc. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -86,6 +89,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" #include "opt_hwpmc_hooks.h" +#include "opt_stack.h" #include "opt_witness.h" #include @@ -98,13 +102,20 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#ifdef DDB #include +#endif #include +#if !defined(DDB) && !defined(STACK) +#error "DDB or STACK options are required for WITNESS" +#endif + /* Note that these traces do not work with KTR_ALQ. */ #if 0 #define KTR_WITNESS KTR_SUBSYS @@ -119,95 +130,250 @@ __FBSDID("$FreeBSD$"); /* Define this to check for blessed mutexes */ #undef BLESSING -#define WITNESS_COUNT 1024 -#define WITNESS_CHILDCOUNT (WITNESS_COUNT * 4) +#define WITNESS_COUNT 1024 +#define WITNESS_CHILDCOUNT (WITNESS_COUNT * 4) +#define WITNESS_HASH_SIZE 251 /* Prime, gives load factor < 2 */ +#define WITNESS_PENDLIST 512 + +/* Allocate 256 KB of stack data space */ +#define WITNESS_LO_DATA_COUNT 2048 + +/* Prime, gives load factor of ~2 at full load */ +#define WITNESS_LO_HASH_SIZE 1021 + /* - * XXX: This is somewhat bogus, as we assume here that at most 1024 threads - * will hold LOCK_NCHILDREN * 2 locks. We handle failure ok, and we should + * XXX: This is somewhat bogus, as we assume here that at most 2048 threads + * will hold LOCK_NCHILDREN locks. We handle failure ok, and we should * probably be safe for the most part, but it's still a SWAG. */ -#define LOCK_CHILDCOUNT (MAXCPU + 1024) * 2 +#define LOCK_NCHILDREN 5 +#define LOCK_CHILDCOUNT 2048 -#define WITNESS_NCHILDREN 6 +#define MAX_W_NAME 64 -struct witness_child_list_entry; +#define BADSTACK_SBUF_SIZE (256 * WITNESS_COUNT) +#define CYCLEGRAPH_SBUF_SIZE 8192 +#define FULLGRAPH_SBUF_SIZE 32768 -struct witness { - const char *w_name; - struct lock_class *w_class; - STAILQ_ENTRY(witness) w_list; /* List of all witnesses. */ - STAILQ_ENTRY(witness) w_typelist; /* Witnesses of a type. */ - struct witness_child_list_entry *w_children; /* Great evilness... */ - const char *w_file; - int w_line; - u_int w_level; - u_int w_refcount; - u_char w_Giant_squawked:1; - u_char w_other_squawked:1; - u_char w_same_squawked:1; - u_char w_displayed:1; +/* + * These flags go in the witness relationship matrix and describe the + * relationship between any two struct witness objects. + */ +#define WITNESS_UNRELATED 0x00 /* No lock order relation. */ +#define WITNESS_PARENT 0x01 /* Parent, aka direct ancestor. */ +#define WITNESS_ANCESTOR 0x02 /* Direct or indirect ancestor. */ +#define WITNESS_CHILD 0x04 /* Child, aka direct descendant. */ +#define WITNESS_DESCENDANT 0x08 /* Direct or indirect descendant. */ +#define WITNESS_ANCESTOR_MASK (WITNESS_PARENT | WITNESS_ANCESTOR) +#define WITNESS_DESCENDANT_MASK (WITNESS_CHILD | WITNESS_DESCENDANT) +#define WITNESS_RELATED_MASK \ + (WITNESS_ANCESTOR_MASK | WITNESS_DESCENDANT_MASK) +#define WITNESS_REVERSAL 0x10 /* A lock order reversal has been + * observed. */ +#define WITNESS_RESERVED1 0x20 /* Unused flag, reserved. */ +#define WITNESS_RESERVED2 0x40 /* Unused flag, reserved. */ +#define WITNESS_LOCK_ORDER_KNOWN 0x80 /* This lock order is known. */ + +/* Descendant to ancestor flags */ +#define WITNESS_DTOA(x) (((x) & WITNESS_RELATED_MASK) >> 2) + +/* Ancestor to descendant flags */ +#define WITNESS_ATOD(x) (((x) & WITNESS_RELATED_MASK) << 2) + +#define WITNESS_INDEX_ASSERT(i) \ + MPASS((i) > 0 && (i) <= w_max_used_index && (i) < WITNESS_COUNT) + +MALLOC_DEFINE(M_WITNESS, "Witness", "Witness"); + +/* + * Lock instances. A lock instance is the data associated with a lock while + * it is held by witness. For example, a lock instance will hold the + * recursion count of a lock. Lock instances are held in lists. Spin locks + * are held in a per-cpu list while sleep locks are held in per-thread list. + */ +struct lock_instance { + struct lock_object *li_lock; + const char *li_file; + int li_line; + u_int li_flags; }; -struct witness_child_list_entry { - struct witness_child_list_entry *wcl_next; - struct witness *wcl_children[WITNESS_NCHILDREN]; - u_int wcl_count; +/* + * A simple list type used to build the list of locks held by a thread + * or CPU. We can't simply embed the list in struct lock_object since a + * lock may be held by more than one thread if it is a shared lock. Locks + * are added to the head of the list, so we fill up each list entry from + * "the back" logically. To ease some of the arithmetic, we actually fill + * in each list entry the normal way (children[0] then children[1], etc.) but + * when we traverse the list we read children[count-1] as the first entry + * down to children[0] as the final entry. + */ +struct lock_list_entry { + struct lock_list_entry *ll_next; + struct lock_instance ll_children[LOCK_NCHILDREN]; + u_int ll_count; +}; + +/* + * The main witness structure. One of these per named lock type in the system + * (for example, "vnode interlock"). + */ +struct witness { + char w_name[MAX_W_NAME]; + uint32_t w_index; /* Index in the relationship matrix */ + struct lock_class *w_class; + STAILQ_ENTRY(witness) w_list; /* List of all witnesses. */ + STAILQ_ENTRY(witness) w_typelist; /* Witnesses of a type. */ + struct witness *w_hash_next; /* Linked list in hash buckets. */ + const char *w_file; /* File where last acquired */ + uint32_t w_line; /* Line where last acquired */ + uint32_t w_refcount; + uint16_t w_num_ancestors; /* direct/indirect + * ancestor count */ + uint16_t w_num_descendants; /* direct/indirect + * descendant count */ + int16_t w_ddb_level; + int w_displayed:1; + int w_reversed:1; }; STAILQ_HEAD(witness_list, witness); +/* + * The witness hash table. Keys are witness names (const char *), elements are + * witness objects (struct witness *). + */ +struct witness_hash { + struct witness *wh_array[WITNESS_HASH_SIZE]; + uint32_t wh_size; + uint32_t wh_count; +}; + +/* + * Key type for the lock order data hash table. + */ +struct witness_lock_order_key { + uint16_t from; + uint16_t to; +}; + +struct witness_lock_order_data { + struct stack wlod_stack; + struct witness_lock_order_key wlod_key; + struct witness_lock_order_data *wlod_next; +}; + +/* + * The witness lock order data hash table. Keys are witness index tuples + * (struct witness_lock_order_key), elements are lock order data objects + * (struct witness_lock_order_data). + */ +struct witness_lock_order_hash { + struct witness_lock_order_data *wloh_array[WITNESS_LO_HASH_SIZE]; + u_int wloh_size; + u_int wloh_count; +}; + #ifdef BLESSING struct witness_blessed { - const char *b_lock1; - const char *b_lock2; + const char *b_lock1; + const char *b_lock2; }; #endif struct witness_order_list_entry { - const char *w_name; - struct lock_class *w_class; + const char *w_name; + struct lock_class *w_class; }; +/* + * Returns 0 if one of the locks is a spin lock and the other is not. + * Returns 1 otherwise. + */ +static __inline int +witness_lock_type_equal(struct witness *w1, struct witness *w2) +{ + + return ((w1->w_class->lc_flags & (LC_SLEEPLOCK | LC_SPINLOCK)) == + (w2->w_class->lc_flags & (LC_SLEEPLOCK | LC_SPINLOCK))); +} + +static __inline int +witness_lock_order_key_empty(const struct witness_lock_order_key *key) +{ + + return (key->from == 0 && key->to == 0); +} + +static __inline int +witness_lock_order_key_equal(const struct witness_lock_order_key *a, + const struct witness_lock_order_key *b) +{ + + return (a->from == b->from && a->to == b->to); +} + +static int _isitmyx(struct witness *w1, struct witness *w2, int rmask, + const char *fname); +#ifdef KDB +static void _witness_debugger(int cond, const char *msg); +#endif +static void adopt(struct witness *parent, struct witness *child); #ifdef BLESSING static int blessed(struct witness *, struct witness *); #endif static int depart(struct witness *w); -static struct witness *enroll(const char *description, - struct lock_class *lock_class); -static int insertchild(struct witness *parent, struct witness *child); +static struct witness *enroll(const char *description, + struct lock_class *lock_class); +static struct lock_instance *find_instance(struct lock_list_entry *list, + struct lock_object *lock); static int isitmychild(struct witness *parent, struct witness *child); static int isitmydescendant(struct witness *parent, struct witness *child); -static int itismychild(struct witness *parent, struct witness *child); -static void removechild(struct witness *parent, struct witness *child); +static void itismychild(struct witness *parent, struct witness *child); +static int sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS); static int sysctl_debug_witness_watch(SYSCTL_HANDLER_ARGS); -static const char *fixup_filename(const char *file); -static struct witness *witness_get(void); +static int sysctl_debug_witness_fullgraph(SYSCTL_HANDLER_ARGS); +static void witness_add_fullgraph(struct sbuf *sb, struct witness *parent); +#ifdef DDB +static void witness_ddb_compute_levels(void); +static void witness_ddb_display(void(*)(const char *fmt, ...)); +static void witness_ddb_display_descendants(void(*)(const char *fmt, ...), + struct witness *, int indent); +static void witness_ddb_display_list(void(*prnt)(const char *fmt, ...), + struct witness_list *list); +static void witness_ddb_level_descendants(struct witness *parent, int l); +static void witness_ddb_list(struct thread *td); +#endif static void witness_free(struct witness *m); -static struct witness_child_list_entry *witness_child_get(void); -static void witness_child_free(struct witness_child_list_entry *wcl); -static struct lock_list_entry *witness_lock_list_get(void); +static struct witness *witness_get(void); +static uint32_t witness_hash_djb2(const uint8_t *key, uint32_t size); +static struct witness *witness_hash_get(const char *key); +static void witness_hash_put(struct witness *w); +static void witness_init_hash_tables(void); +static void witness_increment_graph_generation(void); static void witness_lock_list_free(struct lock_list_entry *lle); -static struct lock_instance *find_instance(struct lock_list_entry *lock_list, - struct lock_object *lock); +static struct lock_list_entry *witness_lock_list_get(void); +static int witness_lock_order_add(struct witness *parent, + struct witness *child); +static int witness_lock_order_check(struct witness *parent, + struct witness *child); +static struct witness_lock_order_data *witness_lock_order_get( + struct witness *parent, + struct witness *child); static void witness_list_lock(struct lock_instance *instance); -#ifdef DDB -static void witness_leveldescendents(struct witness *parent, int level); -static void witness_levelall(void); -static void witness_displaydescendants(void(*)(const char *fmt, ...), - struct witness *, int indent); -static void witness_display_list(void(*prnt)(const char *fmt, ...), - struct witness_list *list); -static void witness_display(void(*)(const char *fmt, ...)); -static void witness_list(struct thread *td); + +#ifdef KDB +#define witness_debugger(c) _witness_debugger(c, __func__) +#else +#define witness_debugger(c) #endif SYSCTL_NODE(_debug, OID_AUTO, witness, CTLFLAG_RW, 0, "Witness Locking"); /* - * If set to 0, witness is disabled. If set to a non-zero value, witness - * performs full lock order checking for all locks. At runtime, this - * value may be set to 0 to turn off witness. witness is not allowed be - * turned on once it is turned off, however. + * If set to 0, witness is disabled. Otherwise witness performs full lock order + * checking for all locks. At runtime, witness is allowed to be turned off. + * witness is not allowed be turned on once it is turned off, however. */ static int witness_watch = 1; TUNABLE_INT("debug.witness.watch", &witness_watch); @@ -216,7 +382,7 @@ SYSCTL_PROC(_debug_witness, OID_AUTO, wa #ifdef KDB /* - * When KDB is enabled and witness_kdb is set to 1, it will cause the system + * When KDB is enabled and witness_kdb is 1, it will cause the system * to drop into kdebug() when: * - a lock hierarchy violation occurs * - locks are held when going to sleep. @@ -230,7 +396,7 @@ TUNABLE_INT("debug.witness.kdb", &witnes SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RW, &witness_kdb, 0, ""); /* - * When KDB is enabled and witness_trace is set to 1, it will cause the system + * When KDB is enabled and witness_trace is 1, it will cause the system * to print a stack trace: * - a lock hierarchy violation occurs * - locks are held when going to sleep. @@ -246,30 +412,54 @@ int witness_skipspin = 1; int witness_skipspin = 0; #endif TUNABLE_INT("debug.witness.skipspin", &witness_skipspin); -SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, - &witness_skipspin, 0, ""); +SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, + 0, ""); + +/* + * Call this to print out the relations between locks. + */ +SYSCTL_PROC(_debug_witness, OID_AUTO, fullgraph, CTLTYPE_STRING | CTLFLAG_RD, + NULL, 0, sysctl_debug_witness_fullgraph, "A", "Show locks relation graphs"); + +/* + * Call this to print out the witness faulty stacks. + */ +SYSCTL_PROC(_debug_witness, OID_AUTO, badstacks, CTLTYPE_STRING | CTLFLAG_RD, + NULL, 0, sysctl_debug_witness_badstacks, "A", "Show bad witness stacks"); static struct mtx w_mtx; + +/* w_list */ static struct witness_list w_free = STAILQ_HEAD_INITIALIZER(w_free); static struct witness_list w_all = STAILQ_HEAD_INITIALIZER(w_all); + +/* w_typelist */ static struct witness_list w_spin = STAILQ_HEAD_INITIALIZER(w_spin); static struct witness_list w_sleep = STAILQ_HEAD_INITIALIZER(w_sleep); -static struct witness_child_list_entry *w_child_free = NULL; + +/* lock list */ static struct lock_list_entry *w_lock_list_free = NULL; -static int w_free_cnt, w_spin_cnt, w_sleep_cnt, w_child_free_cnt, w_child_cnt; +static int w_free_cnt, w_spin_cnt, w_sleep_cnt; SYSCTL_INT(_debug_witness, OID_AUTO, free_cnt, CTLFLAG_RD, &w_free_cnt, 0, ""); SYSCTL_INT(_debug_witness, OID_AUTO, spin_cnt, CTLFLAG_RD, &w_spin_cnt, 0, ""); SYSCTL_INT(_debug_witness, OID_AUTO, sleep_cnt, CTLFLAG_RD, &w_sleep_cnt, 0, ""); -SYSCTL_INT(_debug_witness, OID_AUTO, child_free_cnt, CTLFLAG_RD, - &w_child_free_cnt, 0, ""); -SYSCTL_INT(_debug_witness, OID_AUTO, child_cnt, CTLFLAG_RD, &w_child_cnt, 0, - ""); -static struct witness w_data[WITNESS_COUNT]; -static struct witness_child_list_entry w_childdata[WITNESS_CHILDCOUNT]; +static struct witness *w_data; +static uint8_t w_rmatrix[WITNESS_COUNT+1][WITNESS_COUNT+1]; static struct lock_list_entry w_locklistdata[LOCK_CHILDCOUNT]; +static struct witness_hash w_hash; /* The witness hash table. */ + +/* The lock order data hash */ +static struct witness_lock_order_data w_lodata[WITNESS_LO_DATA_COUNT]; +static struct witness_lock_order_data *w_lofree = NULL; +static struct witness_lock_order_hash w_lohash; +static int w_max_used_index = 0; +static unsigned int w_generation = 0; +static const char *w_notrunning = "Witness not running, witness_watch == 0\n"; +static const char *w_stillcold = "Witness is still cold\n"; + static struct witness_order_list_entry order_lists[] = { /* @@ -522,6 +712,10 @@ witness_initialize(void *dummy __unused) struct witness *w, *w1; int i; + MALLOC(w_data, struct witness *, + sizeof (struct witness) * WITNESS_COUNT, M_WITNESS, + M_NOWAIT | M_ZERO); + /* * We have to release Giant before initializing its witness * structure so that WITNESS doesn't get confused. @@ -532,12 +726,25 @@ witness_initialize(void *dummy __unused) CTR1(KTR_WITNESS, "%s: initializing witness", __func__); mtx_init(&w_mtx, "witness lock", NULL, MTX_SPIN | MTX_QUIET | MTX_NOWITNESS | MTX_NOPROFILE); - for (i = 0; i < WITNESS_COUNT; i++) - witness_free(&w_data[i]); - for (i = 0; i < WITNESS_CHILDCOUNT; i++) - witness_child_free(&w_childdata[i]); + for (i = WITNESS_COUNT - 1; i >= 0; i--) { + w = &w_data[i]; + memset(w, 0, sizeof(*w)); + w_data[i].w_index = i; /* Witness index never changes. */ + witness_free(w); + } + KASSERT(STAILQ_FIRST(&w_free)->w_index == 0, + ("%s: Invalid list of free witness objects", __func__)); + + /* Witness with index 0 is not used to aid in debugging. */ + STAILQ_REMOVE_HEAD(&w_free, w_list); + w_free_cnt--; + + memset(w_rmatrix, 0, + (sizeof(**w_rmatrix) * (WITNESS_COUNT+1) * (WITNESS_COUNT+1))); + for (i = 0; i < LOCK_CHILDCOUNT; i++) witness_lock_list_free(&w_locklistdata[i]); + witness_init_hash_tables(); /* First add in all the specified order lists. */ for (order = order_lists; order->w_name != NULL; order++) { @@ -550,8 +757,7 @@ witness_initialize(void *dummy __unused) if (w1 == NULL) continue; w1->w_file = "order list"; - if (!itismychild(w, w1)) - panic("Not enough memory for static orders!"); + itismychild(w, w1); w = w1; } } @@ -575,23 +781,6 @@ witness_initialize(void *dummy __unused) SYSINIT(witness_init, SI_SUB_WITNESS, SI_ORDER_FIRST, witness_initialize, NULL); -static int -sysctl_debug_witness_watch(SYSCTL_HANDLER_ARGS) -{ - int error, value; - - value = witness_watch; - error = sysctl_handle_int(oidp, &value, 0, req); - if (error != 0 || req->newptr == NULL) - return (error); - if (value == witness_watch) - return (0); - if (value != 0) - return (EINVAL); - witness_watch = 0; - return (0); -} - void witness_init(struct lock_object *lock) { @@ -636,25 +825,23 @@ witness_destroy(struct lock_object *lock struct witness *w; class = LOCK_CLASS(lock); + if (witness_cold) panic("lock (%s) %s destroyed while witness_cold", class->lc_name, lock->lo_name); /* XXX: need to verify that no one holds the lock */ - if ((lock->lo_flags & (LO_WITNESS | LO_ENROLLPEND)) == LO_WITNESS && - lock->lo_witness != NULL) { - w = lock->lo_witness; - mtx_lock_spin(&w_mtx); - MPASS(w->w_refcount > 0); - w->w_refcount--; + if ((lock->lo_flags & LO_WITNESS) == 0 || lock->lo_witness == NULL) + return; + w = lock->lo_witness; - /* - * Lock is already released if we have an allocation failure - * and depart() fails. - */ - if (w->w_refcount != 0 || depart(w)) - mtx_unlock_spin(&w_mtx); - } + mtx_lock_spin(&w_mtx); + MPASS(w->w_refcount > 0); + w->w_refcount--; + + if (w->w_refcount == 0) + depart(w); + mtx_unlock_spin(&w_mtx); /* * If this lock is destroyed before witness is up and running, @@ -668,127 +855,114 @@ witness_destroy(struct lock_object *lock #ifdef DDB static void -witness_levelall (void) +witness_ddb_compute_levels(void) { - struct witness_list *list; - struct witness *w, *w1; + struct witness *w; /* * First clear all levels. */ - STAILQ_FOREACH(w, &w_all, w_list) { - w->w_level = 0; - } + STAILQ_FOREACH(w, &w_all, w_list) + w->w_ddb_level = -1; /* - * Look for locks with no parent and level all their descendants. + * Look for locks with no parents and level all their descendants. */ STAILQ_FOREACH(w, &w_all, w_list) { - /* - * This is just an optimization, technically we could get - * away just walking the all list each time. - */ - if (w->w_class->lc_flags & LC_SLEEPLOCK) - list = &w_sleep; - else - list = &w_spin; - STAILQ_FOREACH(w1, list, w_typelist) { - if (isitmychild(w1, w)) - goto skip; - } - witness_leveldescendents(w, 0); - skip: - ; /* silence GCC 3.x */ + + /* If the witness has ancestors (is not a root), skip it. */ + if (w->w_num_ancestors > 0) + continue; + witness_ddb_level_descendants(w, 0); } } static void -witness_leveldescendents(struct witness *parent, int level) +witness_ddb_level_descendants(struct witness *w, int l) { - struct witness_child_list_entry *wcl; int i; - if (parent->w_level < level) - parent->w_level = level; - level++; - for (wcl = parent->w_children; wcl != NULL; wcl = wcl->wcl_next) - for (i = 0; i < wcl->wcl_count; i++) - witness_leveldescendents(wcl->wcl_children[i], level); + if (w->w_ddb_level >= l) + return; + + w->w_ddb_level = l; + l++; + + for (i = 1; i <= w_max_used_index; i++) { + if (w_rmatrix[w->w_index][i] & WITNESS_PARENT) + witness_ddb_level_descendants(&w_data[i], l); + } } static void -witness_displaydescendants(void(*prnt)(const char *fmt, ...), - struct witness *parent, int indent) +witness_ddb_display_descendants(void(*prnt)(const char *fmt, ...), + struct witness *w, int indent) { - struct witness_child_list_entry *wcl; - int i, level; + int i; - level = parent->w_level; - prnt("%-2d", level); - for (i = 0; i < indent; i++) - prnt(" "); - if (parent->w_refcount > 0) - prnt("%s", parent->w_name); + for (i = 0; i < indent; i++) + prnt(" "); + prnt("%s (type: %s, depth: %d, active refs: %d)", + w->w_name, w->w_class->lc_name, + w->w_ddb_level, w->w_refcount); + if (w->w_displayed) { + prnt(" -- (already displayed)\n"); + return; + } + w->w_displayed = 1; + if (w->w_file != NULL && w->w_line != 0) + prnt(" -- last acquired @ %s:%d\n", w->w_file, + w->w_line); else - prnt("(dead)"); - if (parent->w_displayed) { - prnt(" -- (already displayed)\n"); - return; - } - parent->w_displayed = 1; - if (parent->w_refcount > 0) { - if (parent->w_file != NULL) - prnt(" -- last acquired @ %s:%d", parent->w_file, - parent->w_line); - } - prnt("\n"); - for (wcl = parent->w_children; wcl != NULL; wcl = wcl->wcl_next) - for (i = 0; i < wcl->wcl_count; i++) - witness_displaydescendants(prnt, - wcl->wcl_children[i], indent + 1); + prnt(" -- never acquired\n"); + indent++; + WITNESS_INDEX_ASSERT(w->w_index); + for (i = 1; i <= w_max_used_index; i++) { + if (w_rmatrix[w->w_index][i] & WITNESS_PARENT) + witness_ddb_display_descendants(prnt, &w_data[i], + indent); + } } static void -witness_display_list(void(*prnt)(const char *fmt, ...), - struct witness_list *list) +witness_ddb_display_list(void(*prnt)(const char *fmt, ...), + struct witness_list *list) { struct witness *w; STAILQ_FOREACH(w, list, w_typelist) { - if (w->w_file == NULL || w->w_level > 0) + if (w->w_file == NULL || w->w_ddb_level > 0) continue; - /* - * This lock has no anscestors, display its descendants. - */ - witness_displaydescendants(prnt, w, 0); + + /* This lock has no anscestors - display its descendants. */ + witness_ddb_display_descendants(prnt, w, 0); } } static void -witness_display(void(*prnt)(const char *fmt, ...)) +witness_ddb_display(void(*prnt)(const char *fmt, ...)) { struct witness *w; - KASSERT(!witness_cold, ("%s: witness_cold", __func__)); - witness_levelall(); + KASSERT(witness_cold == 0, ("%s: witness_cold", __func__)); + witness_ddb_compute_levels(); /* Clear all the displayed flags. */ - STAILQ_FOREACH(w, &w_all, w_list) { + STAILQ_FOREACH(w, &w_all, w_list) w->w_displayed = 0; - } /* * First, handle sleep locks which have been acquired at least * once. */ prnt("Sleep locks:\n"); - witness_display_list(prnt, &w_sleep); + witness_ddb_display_list(prnt, &w_sleep); /* * Now do spin locks which have been acquired at least once. */ prnt("\nSpin locks:\n"); - witness_display_list(prnt, &w_spin); + witness_ddb_display_list(prnt, &w_spin); /* * Finally, any locks which have not been acquired yet. @@ -797,7 +971,8 @@ witness_display(void(*prnt)(const char * STAILQ_FOREACH(w, &w_all, w_list) { if (w->w_file != NULL || w->w_refcount == 0) continue; - prnt("%s\n", w->w_name); + prnt("%s (type: %s, depth: %d)\n", w->w_name, + w->w_class->lc_name, w->w_ddb_level); } } #endif /* DDB */ @@ -826,7 +1001,7 @@ witness_defineorder(struct lock_object * lock2->lo_witness == NULL) return (EINVAL); - MPASS(!mtx_owned(&w_mtx)); + mtx_assert(&w_mtx, MA_NOTOWNED); mtx_lock_spin(&w_mtx); /* @@ -841,8 +1016,7 @@ witness_defineorder(struct lock_object * /* Try to add the new order. */ CTR3(KTR_WITNESS, "%s: adding %s as a child of %s", __func__, lock2->lo_type, lock1->lo_type); - if (!itismychild(lock1->lo_witness, lock2->lo_witness)) - return (ENOMEM); + itismychild(lock1->lo_witness, lock2->lo_witness); mtx_unlock_spin(&w_mtx); return (0); } @@ -862,23 +1036,13 @@ witness_checkorder(struct lock_object *l panicstr != NULL) return; - /* - * Try locks do not block if they fail to acquire the lock, thus - * there is no danger of deadlocks or of switching while holding a - * spin lock if we acquire a lock via a try operation. This - * function shouldn't even be called for try locks, so panic if - * that happens. - */ - if (flags & LOP_TRYLOCK) - panic("%s should not be called for try lock operations", - __func__); - w = lock->lo_witness; class = LOCK_CLASS(lock); td = curthread; file = fixup_filename(file); if (class->lc_flags & LC_SLEEPLOCK) { + /* * Since spin locks include a critical section, this check * implicitly enforces a lock order of all sleep locks before @@ -896,6 +1060,7 @@ witness_checkorder(struct lock_object *l return; lock_list = &td->td_sleeplocks; } else { + /* * If this is the first lock, just return as no order * checking is needed. We check this in both if clauses @@ -910,6 +1075,10 @@ witness_checkorder(struct lock_object *l lock_list = PCPU_PTR(spinlocks); } + /* Empty list? */ + if ((*lock_list)->ll_count == 0) + return; + /* * Check to see if we are recursing on a lock we already own. If * so, make sure that we don't mismatch exclusive and shared lock @@ -937,11 +1106,12 @@ witness_checkorder(struct lock_object *l } /* - * Try locks do not block if they fail to acquire the lock, thus - * there is no danger of deadlocks or of switching while holding a - * spin lock if we acquire a lock via a try operation. + * Try to perform most checks without a lock. If this succeeds we + * can skip acquiring the lock and return success. */ - if (flags & LOP_TRYLOCK) + lock1 = &(*lock_list)->ll_children[(*lock_list)->ll_count - 1]; + w1 = lock1->li_lock->lo_witness; + if (witness_lock_order_check(w1, w)) return; /* @@ -949,35 +1119,35 @@ witness_checkorder(struct lock_object *l * have to check for this on the last lock we just acquired. Any * other cases will be caught as lock order violations. */ - lock1 = &(*lock_list)->ll_children[(*lock_list)->ll_count - 1]; - w1 = lock1->li_lock->lo_witness; + mtx_lock_spin(&w_mtx); + witness_lock_order_add(w1, w); if (w1 == w) { - if (w->w_same_squawked || (lock->lo_flags & LO_DUPOK) || - (flags & LOP_DUPOK)) - return; - w->w_same_squawked = 1; + i = w->w_index; + if (!(lock->lo_flags & LO_DUPOK) && !(flags & LOP_DUPOK) && + !(w_rmatrix[i][i] & WITNESS_REVERSAL)) { + w_rmatrix[i][i] |= WITNESS_REVERSAL; + w->w_reversed = 1; + mtx_unlock_spin(&w_mtx); printf("acquiring duplicate lock of same type: \"%s\"\n", - lock->lo_type); - printf(" 1st %s @ %s:%d\n", lock1->li_lock->lo_name, - lock1->li_file, lock1->li_line); - printf(" 2nd %s @ %s:%d\n", lock->lo_name, file, line); -#ifdef KDB - goto debugger; -#else + w->w_name); + printf(" 1st %s @ %s:%d\n", lock1->li_lock->lo_name, + lock1->li_file, lock1->li_line); + printf(" 2nd %s @ %s:%d\n", lock->lo_name, file, line); + witness_debugger(1); + } else + mtx_unlock_spin(&w_mtx); return; -#endif } - MPASS(!mtx_owned(&w_mtx)); - mtx_lock_spin(&w_mtx); + mtx_assert(&w_mtx, MA_OWNED); + /* * If we know that the the lock we are acquiring comes after * the lock we most recently acquired in the lock order tree, * then there is no need for any further checks. */ - if (isitmychild(w1, w)) { - mtx_unlock_spin(&w_mtx); - return; - } + if (isitmychild(w1, w)) + goto out; + for (j = 0, lle = *lock_list; lle != NULL; lle = lle->ll_next) { for (i = lle->ll_count - 1; i >= 0; i--, j++) { @@ -994,6 +1164,7 @@ witness_checkorder(struct lock_object *l ("lock missing witness structure")); continue; } + /* * If we are locking Giant and this is a sleepable * lock, then skip it. @@ -1001,6 +1172,7 @@ witness_checkorder(struct lock_object *l if ((lock1->li_lock->lo_flags & LO_SLEEPABLE) != 0 && lock == &Giant.lock_object) continue; + /* * If we are locking a sleepable lock and this lock * is Giant, then skip it. @@ -1008,6 +1180,7 @@ witness_checkorder(struct lock_object *l if ((lock->lo_flags & LO_SLEEPABLE) != 0 && lock1->li_lock == &Giant.lock_object) continue; + /* * If we are locking a sleepable lock and this lock * isn't sleepable, we want to treat it as a lock @@ -1017,6 +1190,7 @@ witness_checkorder(struct lock_object *l if (((lock->lo_flags & LO_SLEEPABLE) != 0 && (lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0)) goto reversal; + /* * If we are locking Giant and this is a non-sleepable * lock, then treat it as a reversal. @@ -1024,37 +1198,40 @@ witness_checkorder(struct lock_object *l if ((lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0 && lock == &Giant.lock_object) goto reversal; + /* * Check the lock order hierarchy for a reveresal. */ if (!isitmydescendant(w, w1)) continue; reversal: + /* * We have a lock order violation, check to see if it * is allowed or has already been yelled about. */ - mtx_unlock_spin(&w_mtx); #ifdef BLESSING + /* * If the lock order is blessed, just bail. We don't * look for other lock order violations though, which * may be a bug. */ if (blessed(w, w1)) - return; + goto out; #endif - if (lock1->li_lock == &Giant.lock_object) { - if (w1->w_Giant_squawked) - return; - else - w1->w_Giant_squawked = 1; - } else { - if (w1->w_other_squawked) - return; - else - w1->w_other_squawked = 1; - } + + /* Bail if this violation is known */ + if (w_rmatrix[w1->w_index][w->w_index] & WITNESS_REVERSAL) + goto out; + + /* Record this as a violation */ + w_rmatrix[w1->w_index][w->w_index] |= WITNESS_REVERSAL; + w_rmatrix[w->w_index][w1->w_index] |= WITNESS_REVERSAL; + w->w_reversed = w1->w_reversed = 1; + witness_increment_graph_generation(); + mtx_unlock_spin(&w_mtx); + /* * Ok, yell about it. */ @@ -1068,6 +1245,7 @@ witness_checkorder(struct lock_object *l "lock order reversal: (Giant after non-sleepable)\n"); else printf("lock order reversal:\n"); + /* *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon May 18 19:50:18 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E5551065689; Mon, 18 May 2009 19:50:18 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5B6D58FC13; Mon, 18 May 2009 19:50:18 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IJoIkQ073017; Mon, 18 May 2009 19:50:18 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IJoIwm073013; Mon, 18 May 2009 19:50:18 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181950.n4IJoIwm073013@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 19:50:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192333 - in user/kmacy/releng_7_2_fcs/sys: kern vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 19:50:19 -0000 Author: kmacy Date: Mon May 18 19:50:18 2009 New Revision: 192333 URL: http://svn.freebsd.org/changeset/base/192333 Log: merge 187681 - Make the keg abstraction more complete. Permit a zone to have multiple backend kegs so it may source compatible memory from multiple backends. This is useful for cases such as NUMA or different layouts for the same memory type. - Provide a new api for adding new backend kegs to secondary zones. - Provide a new flag for adjusting the layout of zones to stagger allocations better across cache lines. Sponsored by: Nokia Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_malloc.c user/kmacy/releng_7_2_fcs/sys/vm/uma.h user/kmacy/releng_7_2_fcs/sys/vm/uma_core.c user/kmacy/releng_7_2_fcs/sys/vm/uma_dbg.c user/kmacy/releng_7_2_fcs/sys/vm/uma_int.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_malloc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_malloc.c Mon May 18 19:47:54 2009 (r192332) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_malloc.c Mon May 18 19:50:18 2009 (r192333) @@ -329,7 +329,6 @@ malloc(unsigned long size, struct malloc int indx; caddr_t va; uma_zone_t zone; - uma_keg_t keg; #if defined(DIAGNOSTIC) || defined(DEBUG_REDZONE) unsigned long osize = size; #endif @@ -378,18 +377,16 @@ malloc(unsigned long size, struct malloc size = (size & ~KMEM_ZMASK) + KMEM_ZBASE; indx = kmemsize[size >> KMEM_ZSHIFT]; zone = kmemzones[indx].kz_zone; - keg = zone->uz_keg; #ifdef MALLOC_PROFILE krequests[size >> KMEM_ZSHIFT]++; #endif va = uma_zalloc(zone, flags); if (va != NULL) - size = keg->uk_size; + size = zone->uz_size; malloc_type_zone_allocated(mtp, va == NULL ? 0 : size, indx); } else { size = roundup(size, PAGE_SIZE); zone = NULL; - keg = NULL; va = uma_large_malloc(size, flags); malloc_type_allocated(mtp, va == NULL ? 0 : size); } Modified: user/kmacy/releng_7_2_fcs/sys/vm/uma.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/vm/uma.h Mon May 18 19:47:54 2009 (r192332) +++ user/kmacy/releng_7_2_fcs/sys/vm/uma.h Mon May 18 19:50:18 2009 (r192333) @@ -204,6 +204,17 @@ uma_zone_t uma_zsecond_create(char *name uma_init zinit, uma_fini zfini, uma_zone_t master); /* + * Add a second master to a secondary zone. This provides multiple data + * backends for objects with the same size. Both masters must have + * compatible allocation flags. Presently, UMA_ZONE_MALLOC type zones are + * the only supported. + * + * Returns: + * Error on failure, 0 on success. + */ +int uma_zsecond_add(uma_zone_t zone, uma_zone_t master); + +/* * Definitions for uma_zcreate flags * * These flags share space with UMA_ZFLAGs in uma_int.h. Be careful not to @@ -229,6 +240,22 @@ uma_zone_t uma_zsecond_create(char *name #define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */ #define UMA_ZONE_REFCNT 0x0400 /* Allocate refcnts in slabs */ #define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets */ +#define UMA_ZONE_CACHESPREAD 0x1000 /* + * Spread memory start locations across + * all possible cache lines. May + * require many virtually contiguous + * backend pages and can fail early. + */ +#define UMA_ZONE_VTOSLAB 0x2000 /* Zone uses vtoslab for lookup. */ + +/* + * These flags are shared between the keg and zone. In zones wishing to add + * new kegs these flags must be compatible. Some are determined based on + * physical parameters of the request and may not be provided by the consumer. + */ +#define UMA_ZONE_INHERIT \ + (UMA_ZONE_OFFPAGE | UMA_ZONE_MALLOC | UMA_ZONE_HASH | \ + UMA_ZONE_REFCNT | UMA_ZONE_VTOSLAB) /* Definitions for align */ #define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */ Modified: user/kmacy/releng_7_2_fcs/sys/vm/uma_core.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/vm/uma_core.c Mon May 18 19:47:54 2009 (r192332) +++ user/kmacy/releng_7_2_fcs/sys/vm/uma_core.c Mon May 18 19:50:18 2009 (r192333) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002, 2003, 2004, 2005 Jeffrey Roberson + * Copyright (c) 2002-2005, 2009 Jeffrey Roberson * Copyright (c) 2004, 2005 Bosko Milekic * Copyright (c) 2004-2006 Robert N. M. Watson * All rights reserved. @@ -112,7 +112,7 @@ static uma_zone_t slabrefzone; /* With r static uma_zone_t hashzone; /* The boot-time adjusted value for cache line alignment. */ -static int uma_align_cache = 16 - 1; +static int uma_align_cache = 64 - 1; static MALLOC_DEFINE(M_UMAHASH, "UMAHash", "UMA Hash Buckets"); @@ -212,7 +212,7 @@ static void *obj_alloc(uma_zone_t, int, static void *page_alloc(uma_zone_t, int, u_int8_t *, int); static void *startup_alloc(uma_zone_t, int, u_int8_t *, int); static void page_free(void *, int, u_int8_t); -static uma_slab_t slab_zalloc(uma_zone_t, int); +static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int); static void cache_drain(uma_zone_t); static void bucket_drain(uma_zone_t, uma_bucket_t); static void bucket_cache_drain(uma_zone_t zone); @@ -221,8 +221,8 @@ static void keg_dtor(void *, int, void * static int zone_ctor(void *, int, void *, int); static void zone_dtor(void *, int, void *); static int zero_init(void *, int, int); -static void zone_small_init(uma_zone_t zone); -static void zone_large_init(uma_zone_t zone); +static void keg_small_init(uma_keg_t keg); +static void keg_large_init(uma_keg_t keg); static void zone_foreach(void (*zfunc)(uma_zone_t)); static void zone_timeout(uma_zone_t zone); static int hash_alloc(struct uma_hash *); @@ -230,19 +230,22 @@ static int hash_expand(struct uma_hash * static void hash_free(struct uma_hash *hash); static void uma_timeout(void *); static void uma_startup3(void); -static void *uma_zalloc_internal(uma_zone_t, void *, int); -static void uma_zfree_internal(uma_zone_t, void *, void *, enum zfreeskip, +static void *zone_alloc_item(uma_zone_t, void *, int); +static void zone_free_item(uma_zone_t, void *, void *, enum zfreeskip, int); static void bucket_enable(void); static void bucket_init(void); static uma_bucket_t bucket_alloc(int, int); static void bucket_free(uma_bucket_t); static void bucket_zone_drain(void); -static int uma_zalloc_bucket(uma_zone_t zone, int flags); -static uma_slab_t uma_zone_slab(uma_zone_t zone, int flags); -static void *uma_slab_alloc(uma_zone_t zone, uma_slab_t slab); -static uma_zone_t uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, +static int zone_alloc_bucket(uma_zone_t zone, int flags); +static uma_slab_t zone_fetch_slab(uma_zone_t zone, uma_keg_t last, int flags); +static uma_slab_t zone_fetch_slab_multi(uma_zone_t zone, uma_keg_t last, int flags); +static void *slab_alloc_item(uma_zone_t zone, uma_slab_t slab); +static uma_keg_t uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, uma_fini fini, int align, u_int32_t flags); +static inline void zone_relock(uma_zone_t zone, uma_keg_t keg); +static inline void keg_relock(uma_keg_t keg, uma_zone_t zone); void uma_print_zone(uma_zone_t); void uma_print_stats(void); @@ -291,7 +294,8 @@ bucket_init(void) size = roundup(sizeof(struct uma_bucket), sizeof(void *)); size += sizeof(void *) * ubz->ubz_entries; ubz->ubz_zone = uma_zcreate(ubz->ubz_name, size, - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZFLAG_INTERNAL); + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, + UMA_ZFLAG_INTERNAL | UMA_ZFLAG_BUCKET); for (; i <= ubz->ubz_entries; i += (1 << BUCKET_SHIFT)) bucket_size[i >> BUCKET_SHIFT] = j; } @@ -326,7 +330,7 @@ bucket_alloc(int entries, int bflags) return (NULL); ubz = bucket_zone_lookup(entries); - bucket = uma_zalloc_internal(ubz->ubz_zone, NULL, bflags); + bucket = zone_alloc_item(ubz->ubz_zone, NULL, bflags); if (bucket) { #ifdef INVARIANTS bzero(bucket->ub_bucket, sizeof(void *) * ubz->ubz_entries); @@ -344,7 +348,7 @@ bucket_free(uma_bucket_t bucket) struct uma_bucket_zone *ubz; ubz = bucket_zone_lookup(bucket->ub_entries); - uma_zfree_internal(ubz->ubz_zone, bucket, NULL, SKIP_NONE, + zone_free_item(ubz->ubz_zone, bucket, NULL, SKIP_NONE, ZFREE_STATFREE); } @@ -357,6 +361,21 @@ bucket_zone_drain(void) zone_drain(ubz->ubz_zone); } +static inline uma_keg_t +zone_first_keg(uma_zone_t zone) +{ + + return (LIST_FIRST(&zone->uz_kegs)->kl_keg); +} + +static void +zone_foreach_keg(uma_zone_t zone, void (*kegfn)(uma_keg_t)) +{ + uma_klink_t klink; + + LIST_FOREACH(klink, &zone->uz_kegs, kl_link) + kegfn(klink->kl_keg); +} /* * Routine called by timeout which is used to fire off some time interval @@ -382,29 +401,20 @@ uma_timeout(void *unused) * Routine to perform timeout driven calculations. This expands the * hashes and does per cpu statistics aggregation. * - * Arguments: - * zone The zone to operate on - * - * Returns: - * Nothing + * Returns nothing. */ static void -zone_timeout(uma_zone_t zone) +keg_timeout(uma_keg_t keg) { - uma_keg_t keg; - u_int64_t alloc; - - keg = zone->uz_keg; - alloc = 0; + KEG_LOCK(keg); /* - * Expand the zone hash table. + * Expand the keg hash table. * * This is done if the number of slabs is larger than the hash size. * What I'm trying to do here is completely reduce collisions. This * may be a little aggressive. Should I allow for two collisions max? */ - ZONE_LOCK(zone); if (keg->uk_flags & UMA_ZONE_HASH && keg->uk_pages / keg->uk_ppera >= keg->uk_hash.uh_hashsize) { struct uma_hash newhash; @@ -413,14 +423,14 @@ zone_timeout(uma_zone_t zone) /* * This is so involved because allocating and freeing - * while the zone lock is held will lead to deadlock. + * while the keg lock is held will lead to deadlock. * I have to do everything in stages and check for * races. */ newhash = keg->uk_hash; - ZONE_UNLOCK(zone); + KEG_UNLOCK(keg); ret = hash_alloc(&newhash); - ZONE_LOCK(zone); + KEG_LOCK(keg); if (ret) { if (hash_expand(&keg->uk_hash, &newhash)) { oldhash = keg->uk_hash; @@ -428,12 +438,19 @@ zone_timeout(uma_zone_t zone) } else oldhash = newhash; - ZONE_UNLOCK(zone); + KEG_UNLOCK(keg); hash_free(&oldhash); - ZONE_LOCK(zone); + KEG_LOCK(keg); } } - ZONE_UNLOCK(zone); + KEG_UNLOCK(keg); +} + +static void +zone_timeout(uma_zone_t zone) +{ + + zone_foreach_keg(zone, &keg_timeout); } /* @@ -462,7 +479,7 @@ hash_alloc(struct uma_hash *hash) M_UMAHASH, M_NOWAIT); } else { alloc = sizeof(hash->uh_slab_hash[0]) * UMA_HASH_SIZE_INIT; - hash->uh_slab_hash = uma_zalloc_internal(hashzone, NULL, + hash->uh_slab_hash = zone_alloc_item(hashzone, NULL, M_WAITOK); hash->uh_hashsize = UMA_HASH_SIZE_INIT; } @@ -535,7 +552,7 @@ hash_free(struct uma_hash *hash) if (hash->uh_slab_hash == NULL) return; if (hash->uh_hashsize == UMA_HASH_SIZE_INIT) - uma_zfree_internal(hashzone, + zone_free_item(hashzone, hash->uh_slab_hash, NULL, SKIP_NONE, ZFREE_STATFREE); else free(hash->uh_slab_hash, M_UMAHASH); @@ -555,20 +572,11 @@ hash_free(struct uma_hash *hash) static void bucket_drain(uma_zone_t zone, uma_bucket_t bucket) { - uma_slab_t slab; - int mzone; void *item; if (bucket == NULL) return; - slab = NULL; - mzone = 0; - - /* We have to lookup the slab again for malloc.. */ - if (zone->uz_keg->uk_flags & UMA_ZONE_MALLOC) - mzone = 1; - while (bucket->ub_cnt > 0) { bucket->ub_cnt--; item = bucket->ub_bucket[bucket->ub_cnt]; @@ -577,15 +585,7 @@ bucket_drain(uma_zone_t zone, uma_bucket KASSERT(item != NULL, ("bucket_drain: botched ptr, item is NULL")); #endif - /* - * This is extremely inefficient. The slab pointer was passed - * to uma_zfree_arg, but we lost it because the buckets don't - * hold them. This will go away when free() gets a size passed - * to it. - */ - if (mzone) - slab = vtoslab((vm_offset_t)item & (~UMA_SLAB_MASK)); - uma_zfree_internal(zone, item, slab, SKIP_DTOR, 0); + zone_free_item(zone, item, NULL, SKIP_DTOR, 0); } } @@ -665,42 +665,32 @@ bucket_cache_drain(uma_zone_t zone) } /* - * Frees pages from a zone back to the system. This is done on demand from + * Frees pages from a keg back to the system. This is done on demand from * the pageout daemon. * - * Arguments: - * zone The zone to free pages from - * all Should we drain all items? - * - * Returns: - * Nothing. + * Returns nothing. */ -void -zone_drain(uma_zone_t zone) +static void +keg_drain(uma_keg_t keg) { struct slabhead freeslabs = { 0 }; - uma_keg_t keg; uma_slab_t slab; uma_slab_t n; u_int8_t flags; u_int8_t *mem; int i; - keg = zone->uz_keg; - /* - * We don't want to take pages from statically allocated zones at this + * We don't want to take pages from statically allocated kegs at this * time */ if (keg->uk_flags & UMA_ZONE_NOFREE || keg->uk_freef == NULL) return; - ZONE_LOCK(zone); - #ifdef UMA_DEBUG - printf("%s free items: %u\n", zone->uz_name, keg->uk_free); + printf("%s free items: %u\n", keg->uk_name, keg->uk_free); #endif - bucket_cache_drain(zone); + KEG_LOCK(keg); if (keg->uk_free == 0) goto finished; @@ -726,7 +716,7 @@ zone_drain(uma_zone_t zone) slab = n; } finished: - ZONE_UNLOCK(zone); + KEG_UNLOCK(keg); while ((slab = SLIST_FIRST(&freeslabs)) != NULL) { SLIST_REMOVE(&freeslabs, slab, uma_slab, us_hlink); @@ -738,8 +728,7 @@ finished: flags = slab->us_flags; mem = slab->us_data; - if ((keg->uk_flags & UMA_ZONE_MALLOC) || - (keg->uk_flags & UMA_ZONE_REFCNT)) { + if (keg->uk_flags & UMA_ZONE_VTOSLAB) { vm_object_t obj; if (flags & UMA_SLAB_KMEM) @@ -753,21 +742,61 @@ finished: obj); } if (keg->uk_flags & UMA_ZONE_OFFPAGE) - uma_zfree_internal(keg->uk_slabzone, slab, NULL, + zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE, ZFREE_STATFREE); #ifdef UMA_DEBUG printf("%s: Returning %d bytes.\n", - zone->uz_name, UMA_SLAB_SIZE * keg->uk_ppera); + keg->uk_name, UMA_SLAB_SIZE * keg->uk_ppera); #endif keg->uk_freef(mem, UMA_SLAB_SIZE * keg->uk_ppera, flags); } } +static void +zone_drain_wait(uma_zone_t zone, int waitok) +{ + + /* + * Set draining to interlock with zone_dtor() so we can release our + * locks as we go. Only dtor() should do a WAITOK call since it + * is the only call that knows the structure will still be available + * when it wakes up. + */ + ZONE_LOCK(zone); + while (zone->uz_flags & UMA_ZFLAG_DRAINING) { + if (waitok == M_NOWAIT) + goto out; + mtx_unlock(&uma_mtx); + msleep(zone, zone->uz_lock, PVM, "zonedrain", 1); + mtx_lock(&uma_mtx); + } + zone->uz_flags |= UMA_ZFLAG_DRAINING; + bucket_cache_drain(zone); + ZONE_UNLOCK(zone); + /* + * The DRAINING flag protects us from being freed while + * we're running. Normally the uma_mtx would protect us but we + * must be able to release and acquire the right lock for each keg. + */ + zone_foreach_keg(zone, &keg_drain); + ZONE_LOCK(zone); + zone->uz_flags &= ~UMA_ZFLAG_DRAINING; + wakeup(zone); +out: + ZONE_UNLOCK(zone); +} + +void +zone_drain(uma_zone_t zone) +{ + + zone_drain_wait(zone, M_NOWAIT); +} + /* - * Allocate a new slab for a zone. This does not insert the slab onto a list. + * Allocate a new slab for a keg. This does not insert the slab onto a list. * * Arguments: - * zone The zone to allocate slabs for * wait Shall we wait? * * Returns: @@ -775,27 +804,28 @@ finished: * caller specified M_NOWAIT. */ static uma_slab_t -slab_zalloc(uma_zone_t zone, int wait) +keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int wait) { uma_slabrefcnt_t slabref; + uma_alloc allocf; uma_slab_t slab; - uma_keg_t keg; u_int8_t *mem; u_int8_t flags; int i; + mtx_assert(&keg->uk_lock, MA_OWNED); slab = NULL; - keg = zone->uz_keg; #ifdef UMA_DEBUG - printf("slab_zalloc: Allocating a new slab for %s\n", zone->uz_name); + printf("slab_zalloc: Allocating a new slab for %s\n", keg->uk_name); #endif - ZONE_UNLOCK(zone); + allocf = keg->uk_allocf; + KEG_UNLOCK(keg); if (keg->uk_flags & UMA_ZONE_OFFPAGE) { - slab = uma_zalloc_internal(keg->uk_slabzone, NULL, wait); + slab = zone_alloc_item(keg->uk_slabzone, NULL, wait); if (slab == NULL) { - ZONE_LOCK(zone); + KEG_LOCK(keg); return NULL; } } @@ -812,13 +842,13 @@ slab_zalloc(uma_zone_t zone, int wait) else wait &= ~M_ZERO; - mem = keg->uk_allocf(zone, keg->uk_ppera * UMA_SLAB_SIZE, - &flags, wait); + /* zone is passed for legacy reasons. */ + mem = allocf(zone, keg->uk_ppera * UMA_SLAB_SIZE, &flags, wait); if (mem == NULL) { if (keg->uk_flags & UMA_ZONE_OFFPAGE) - uma_zfree_internal(keg->uk_slabzone, slab, NULL, + zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE, ZFREE_STATFREE); - ZONE_LOCK(zone); + KEG_LOCK(keg); return (NULL); } @@ -826,8 +856,7 @@ slab_zalloc(uma_zone_t zone, int wait) if (!(keg->uk_flags & UMA_ZONE_OFFPAGE)) slab = (uma_slab_t )(mem + keg->uk_pgoff); - if ((keg->uk_flags & UMA_ZONE_MALLOC) || - (keg->uk_flags & UMA_ZONE_REFCNT)) + if (keg->uk_flags & UMA_ZONE_VTOSLAB) for (i = 0; i < keg->uk_ppera; i++) vsetslab((vm_offset_t)mem + (i * PAGE_SIZE), slab); @@ -860,8 +889,7 @@ slab_zalloc(uma_zone_t zone, int wait) (keg->uk_rsize * i), keg->uk_size); } - if ((keg->uk_flags & UMA_ZONE_MALLOC) || - (keg->uk_flags & UMA_ZONE_REFCNT)) { + if (keg->uk_flags & UMA_ZONE_VTOSLAB) { vm_object_t obj; if (flags & UMA_SLAB_KMEM) @@ -875,15 +903,15 @@ slab_zalloc(uma_zone_t zone, int wait) (i * PAGE_SIZE), obj); } if (keg->uk_flags & UMA_ZONE_OFFPAGE) - uma_zfree_internal(keg->uk_slabzone, slab, + zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE, ZFREE_STATFREE); keg->uk_freef(mem, UMA_SLAB_SIZE * keg->uk_ppera, flags); - ZONE_LOCK(zone); + KEG_LOCK(keg); return (NULL); } } - ZONE_LOCK(zone); + KEG_LOCK(keg); if (keg->uk_flags & UMA_ZONE_HASH) UMA_HASH_INSERT(&keg->uk_hash, slab, mem); @@ -905,7 +933,7 @@ startup_alloc(uma_zone_t zone, int bytes uma_keg_t keg; uma_slab_t tmps; - keg = zone->uz_keg; + keg = zone_first_keg(zone); /* * Check our small startup cache to see if it has pages remaining. @@ -935,7 +963,6 @@ startup_alloc(uma_zone_t zone, int bytes * Allocates a number of pages from the system * * Arguments: - * zone Unused * bytes The number of bytes requested * wait Shall we wait? * @@ -958,7 +985,6 @@ page_alloc(uma_zone_t zone, int bytes, u * Allocates a number of pages from within an object * * Arguments: - * zone Unused * bytes The number of bytes requested * wait Shall we wait? * @@ -973,8 +999,10 @@ obj_alloc(uma_zone_t zone, int bytes, u_ vm_offset_t retkva, zkva; vm_page_t p; int pages, startpages; + uma_keg_t keg; - object = zone->uz_keg->uk_obj; + keg = zone_first_keg(zone); + object = keg->uk_obj; retkva = 0; /* @@ -984,7 +1012,7 @@ obj_alloc(uma_zone_t zone, int bytes, u_ p = TAILQ_LAST(&object->memq, pglist); pages = p != NULL ? p->pindex + 1 : 0; startpages = pages; - zkva = zone->uz_keg->uk_kva + pages * PAGE_SIZE; + zkva = keg->uk_kva + pages * PAGE_SIZE; for (; bytes > 0; bytes -= PAGE_SIZE) { p = vm_page_alloc(object, pages, VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED); @@ -1052,25 +1080,23 @@ zero_init(void *mem, int size, int flags } /* - * Finish creating a small uma zone. This calculates ipers, and the zone size. + * Finish creating a small uma keg. This calculates ipers, and the keg size. * * Arguments - * zone The zone we should initialize + * keg The zone we should initialize * * Returns * Nothing */ static void -zone_small_init(uma_zone_t zone) +keg_small_init(uma_keg_t keg) { - uma_keg_t keg; u_int rsize; u_int memused; u_int wastedspace; u_int shsize; - keg = zone->uz_keg; - KASSERT(keg != NULL, ("Keg is null in zone_small_init")); + KASSERT(keg != NULL, ("Keg is null in keg_small_init")); rsize = keg->uk_size; if (rsize < UMA_SMALLEST_UNIT) @@ -1090,7 +1116,7 @@ zone_small_init(uma_zone_t zone) } keg->uk_ipers = (UMA_SLAB_SIZE - shsize) / rsize; - KASSERT(keg->uk_ipers != 0, ("zone_small_init: ipers is 0")); + KASSERT(keg->uk_ipers != 0, ("keg_small_init: ipers is 0")); memused = keg->uk_ipers * rsize + shsize; wastedspace = UMA_SLAB_SIZE - memused; @@ -1109,44 +1135,41 @@ zone_small_init(uma_zone_t zone) (keg->uk_ipers < (UMA_SLAB_SIZE / keg->uk_rsize))) { keg->uk_ipers = UMA_SLAB_SIZE / keg->uk_rsize; KASSERT(keg->uk_ipers <= 255, - ("zone_small_init: keg->uk_ipers too high!")); + ("keg_small_init: keg->uk_ipers too high!")); #ifdef UMA_DEBUG printf("UMA decided we need offpage slab headers for " - "zone: %s, calculated wastedspace = %d, " + "keg: %s, calculated wastedspace = %d, " "maximum wasted space allowed = %d, " "calculated ipers = %d, " - "new wasted space = %d\n", zone->uz_name, wastedspace, + "new wasted space = %d\n", keg->uk_name, wastedspace, UMA_MAX_WASTE, keg->uk_ipers, UMA_SLAB_SIZE - keg->uk_ipers * keg->uk_rsize); #endif keg->uk_flags |= UMA_ZONE_OFFPAGE; - if ((keg->uk_flags & UMA_ZONE_MALLOC) == 0) + if ((keg->uk_flags & UMA_ZONE_VTOSLAB) == 0) keg->uk_flags |= UMA_ZONE_HASH; } } /* - * Finish creating a large (> UMA_SLAB_SIZE) uma zone. Just give in and do + * Finish creating a large (> UMA_SLAB_SIZE) uma kegs. Just give in and do * OFFPAGE for now. When I can allow for more dynamic slab sizes this will be * more complicated. * * Arguments - * zone The zone we should initialize + * keg The keg we should initialize * * Returns * Nothing */ static void -zone_large_init(uma_zone_t zone) +keg_large_init(uma_keg_t keg) { - uma_keg_t keg; int pages; - keg = zone->uz_keg; - - KASSERT(keg != NULL, ("Keg is null in zone_large_init")); + KASSERT(keg != NULL, ("Keg is null in keg_large_init")); KASSERT((keg->uk_flags & UMA_ZFLAG_CACHEONLY) == 0, - ("zone_large_init: Cannot large-init a UMA_ZFLAG_CACHEONLY zone")); + ("keg_large_init: Cannot large-init a UMA_ZFLAG_CACHEONLY keg")); pages = keg->uk_size / UMA_SLAB_SIZE; @@ -1158,12 +1181,44 @@ zone_large_init(uma_zone_t zone) keg->uk_ipers = 1; keg->uk_flags |= UMA_ZONE_OFFPAGE; - if ((keg->uk_flags & UMA_ZONE_MALLOC) == 0) + if ((keg->uk_flags & UMA_ZONE_VTOSLAB) == 0) keg->uk_flags |= UMA_ZONE_HASH; keg->uk_rsize = keg->uk_size; } +static void +keg_cachespread_init(uma_keg_t keg) +{ + int alignsize; + int trailer; + int pages; + int rsize; + + alignsize = keg->uk_align + 1; + rsize = keg->uk_size; + /* + * We want one item to start on every align boundary in a page. To + * do this we will span pages. We will also extend the item by the + * size of align if it is an even multiple of align. Otherwise, it + * would fall on the same boundary every time. + */ + if (rsize & keg->uk_align) + rsize = (rsize & ~keg->uk_align) + alignsize; + if ((rsize & alignsize) == 0) + rsize += alignsize; + trailer = rsize - keg->uk_size; + pages = (rsize * (PAGE_SIZE / alignsize)) / PAGE_SIZE; + pages = MIN(pages, (128 * 1024) / PAGE_SIZE); + keg->uk_rsize = rsize; + keg->uk_ppera = pages; + keg->uk_ipers = ((pages * PAGE_SIZE) + trailer) / rsize; + keg->uk_flags |= UMA_ZONE_OFFPAGE | UMA_ZONE_VTOSLAB; + KASSERT(keg->uk_ipers <= uma_max_ipers, + ("keg_small_init: keg->uk_ipers too high(%d) increase max_ipers", + keg->uk_ipers)); +} + /* * Keg header ctor. This initializes all fields, locks, etc. And inserts * the keg onto the global keg list. @@ -1195,7 +1250,7 @@ keg_ctor(void *mem, int size, void *udat * The master zone is passed to us at keg-creation time. */ zone = arg->zone; - zone->uz_keg = keg; + keg->uk_name = zone->uz_name; if (arg->flags & UMA_ZONE_VM) keg->uk_flags |= UMA_ZFLAG_CACHEONLY; @@ -1203,24 +1258,31 @@ keg_ctor(void *mem, int size, void *udat if (arg->flags & UMA_ZONE_ZINIT) keg->uk_init = zero_init; + if (arg->flags & UMA_ZONE_REFCNT || arg->flags & UMA_ZONE_MALLOC) + keg->uk_flags |= UMA_ZONE_VTOSLAB; + /* * The +UMA_FRITM_SZ added to uk_size is to account for the - * linkage that is added to the size in zone_small_init(). If + * linkage that is added to the size in keg_small_init(). If * we don't account for this here then we may end up in - * zone_small_init() with a calculated 'ipers' of 0. + * keg_small_init() with a calculated 'ipers' of 0. */ if (keg->uk_flags & UMA_ZONE_REFCNT) { - if ((keg->uk_size+UMA_FRITMREF_SZ) > + if (keg->uk_flags & UMA_ZONE_CACHESPREAD) + keg_cachespread_init(keg); + else if ((keg->uk_size+UMA_FRITMREF_SZ) > (UMA_SLAB_SIZE - sizeof(struct uma_slab_refcnt))) - zone_large_init(zone); + keg_large_init(keg); else - zone_small_init(zone); + keg_small_init(keg); } else { - if ((keg->uk_size+UMA_FRITM_SZ) > + if (keg->uk_flags & UMA_ZONE_CACHESPREAD) + keg_cachespread_init(keg); + else if ((keg->uk_size+UMA_FRITM_SZ) > (UMA_SLAB_SIZE - sizeof(struct uma_slab))) - zone_large_init(zone); + keg_large_init(keg); else - zone_small_init(zone); + keg_small_init(keg); } if (keg->uk_flags & UMA_ZONE_OFFPAGE) { @@ -1244,14 +1306,12 @@ keg_ctor(void *mem, int size, void *udat } /* - * Initialize keg's lock (shared among zones) through - * Master zone + * Initialize keg's lock (shared among zones). */ - zone->uz_lock = &keg->uk_lock; if (arg->flags & UMA_ZONE_MTXCLASS) - ZONE_LOCK_INIT(zone, 1); + KEG_LOCK_INIT(keg, 1); else - ZONE_LOCK_INIT(zone, 0); + KEG_LOCK_INIT(keg, 0); /* * If we're putting the slab header in the actual page we need to @@ -1300,10 +1360,10 @@ keg_ctor(void *mem, int size, void *udat hash_alloc(&keg->uk_hash); #ifdef UMA_DEBUG - printf("%s(%p) size = %d ipers = %d ppera = %d pgoff = %d\n", - zone->uz_name, zone, - keg->uk_size, keg->uk_ipers, - keg->uk_ppera, keg->uk_pgoff); + printf("UMA: %s(%p) size %d(%d) flags %d ipers %d ppera %d out %d free %d\n", + zone->uz_name, zone, keg->uk_size, keg->uk_rsize, keg->uk_flags, + keg->uk_ipers, keg->uk_ppera, + (keg->uk_ipers * keg->uk_pages) - keg->uk_free, keg->uk_free); #endif LIST_INSERT_HEAD(&keg->uk_zones, zone, uz_link); @@ -1320,7 +1380,6 @@ keg_ctor(void *mem, int size, void *udat * Arguments/Returns follow uma_ctor specifications * udata Actually uma_zctor_args */ - static int zone_ctor(void *mem, int size, void *udata, int flags) { @@ -1333,23 +1392,24 @@ zone_ctor(void *mem, int size, void *uda zone->uz_name = arg->name; zone->uz_ctor = arg->ctor; zone->uz_dtor = arg->dtor; + zone->uz_slab = zone_fetch_slab; zone->uz_init = NULL; zone->uz_fini = NULL; zone->uz_allocs = 0; zone->uz_frees = 0; zone->uz_fails = 0; zone->uz_fills = zone->uz_count = 0; + zone->uz_flags = 0; + keg = arg->keg; if (arg->flags & UMA_ZONE_SECONDARY) { KASSERT(arg->keg != NULL, ("Secondary zone on zero'd keg")); - keg = arg->keg; - zone->uz_keg = keg; zone->uz_init = arg->uminit; zone->uz_fini = arg->fini; zone->uz_lock = &keg->uk_lock; + zone->uz_flags |= UMA_ZONE_SECONDARY; mtx_lock(&uma_mtx); ZONE_LOCK(zone); - keg->uk_flags |= UMA_ZONE_SECONDARY; LIST_FOREACH(z, &keg->uk_zones, uz_link) { if (LIST_NEXT(z, uz_link) == NULL) { LIST_INSERT_AFTER(z, zone, uz_link); @@ -1358,9 +1418,9 @@ zone_ctor(void *mem, int size, void *uda } ZONE_UNLOCK(zone); mtx_unlock(&uma_mtx); - } else if (arg->keg == NULL) { - if (uma_kcreate(zone, arg->size, arg->uminit, arg->fini, - arg->align, arg->flags) == NULL) + } else if (keg == NULL) { + if ((keg = uma_kcreate(zone, arg->size, arg->uminit, arg->fini, + arg->align, arg->flags)) == NULL) return (ENOMEM); } else { struct uma_kctor_args karg; @@ -1378,15 +1438,22 @@ zone_ctor(void *mem, int size, void *uda if (error) return (error); } - keg = zone->uz_keg; + /* + * Link in the first keg. + */ + zone->uz_klink.kl_keg = keg; + LIST_INSERT_HEAD(&zone->uz_kegs, &zone->uz_klink, kl_link); zone->uz_lock = &keg->uk_lock; + zone->uz_size = keg->uk_size; + zone->uz_flags |= (keg->uk_flags & + (UMA_ZONE_INHERIT | UMA_ZFLAG_INHERIT)); /* * Some internal zones don't have room allocated for the per cpu * caches. If we're internal, bail out here. */ if (keg->uk_flags & UMA_ZFLAG_INTERNAL) { - KASSERT((keg->uk_flags & UMA_ZONE_SECONDARY) == 0, + KASSERT((zone->uz_flags & UMA_ZONE_SECONDARY) == 0, ("Secondary zone requested UMA_ZFLAG_INTERNAL")); return (0); } @@ -1413,18 +1480,17 @@ keg_dtor(void *arg, int size, void *udat uma_keg_t keg; keg = (uma_keg_t)arg; - mtx_lock(&keg->uk_lock); + KEG_LOCK(keg); if (keg->uk_free != 0) { printf("Freed UMA keg was not empty (%d items). " " Lost %d pages of memory.\n", keg->uk_free, keg->uk_pages); } - mtx_unlock(&keg->uk_lock); + KEG_UNLOCK(keg); - if (keg->uk_flags & UMA_ZONE_HASH) - hash_free(&keg->uk_hash); + hash_free(&keg->uk_hash); - mtx_destroy(&keg->uk_lock); + KEG_LOCK_FINI(keg); } /* @@ -1436,38 +1502,46 @@ keg_dtor(void *arg, int size, void *udat static void zone_dtor(void *arg, int size, void *udata) { + uma_klink_t klink; uma_zone_t zone; uma_keg_t keg; zone = (uma_zone_t)arg; - keg = zone->uz_keg; + keg = zone_first_keg(zone); - if (!(keg->uk_flags & UMA_ZFLAG_INTERNAL)) + if (!(zone->uz_flags & UMA_ZFLAG_INTERNAL)) cache_drain(zone); mtx_lock(&uma_mtx); - zone_drain(zone); - if (keg->uk_flags & UMA_ZONE_SECONDARY) { - LIST_REMOVE(zone, uz_link); - /* - * XXX there are some races here where - * the zone can be drained but zone lock - * released and then refilled before we - * remove it... we dont care for now - */ - ZONE_LOCK(zone); - if (LIST_EMPTY(&keg->uk_zones)) - keg->uk_flags &= ~UMA_ZONE_SECONDARY; - ZONE_UNLOCK(zone); - mtx_unlock(&uma_mtx); - } else { + LIST_REMOVE(zone, uz_link); + mtx_unlock(&uma_mtx); + /* + * XXX there are some races here where + * the zone can be drained but zone lock + * released and then refilled before we + * remove it... we dont care for now + */ + zone_drain_wait(zone, M_WAITOK); + /* + * Unlink all of our kegs. + */ + while ((klink = LIST_FIRST(&zone->uz_kegs)) != NULL) { + klink->kl_keg = NULL; + LIST_REMOVE(klink, kl_link); + if (klink == &zone->uz_klink) + continue; + free(klink, M_TEMP); + } + /* + * We only destroy kegs from non secondary zones. + */ + if ((zone->uz_flags & UMA_ZONE_SECONDARY) == 0) { + mtx_lock(&uma_mtx); LIST_REMOVE(keg, uk_link); - LIST_REMOVE(zone, uz_link); mtx_unlock(&uma_mtx); - uma_zfree_internal(kegs, keg, NULL, SKIP_NONE, + zone_free_item(kegs, keg, NULL, SKIP_NONE, ZFREE_STATFREE); } - zone->uz_keg = NULL; } /* @@ -1517,7 +1591,7 @@ uma_startup(void *bootmem, int boot_page * (UMA_MAX_WASTE). * * We iterate until we find an object size for - * which the calculated wastage in zone_small_init() will be + * which the calculated wastage in keg_small_init() will be * enough to warrant OFFPAGE. Since wastedspace versus objsize * is an overall increasing see-saw function, we find the smallest * objsize such that the wastage is always acceptable for objects @@ -1525,7 +1599,7 @@ uma_startup(void *bootmem, int boot_page * generates a larger possible uma_max_ipers, we use this computed * objsize to calculate the largest ipers possible. Since the * ipers calculated for OFFPAGE slab headers is always larger than - * the ipers initially calculated in zone_small_init(), we use + * the ipers initially calculated in keg_small_init(), we use * the former's equation (UMA_SLAB_SIZE / keg->uk_rsize) to * obtain the maximum ipers possible for offpage slab headers. * @@ -1557,7 +1631,7 @@ uma_startup(void *bootmem, int boot_page } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon May 18 19:54:35 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 851C1106564A; Mon, 18 May 2009 19:54:35 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71EF48FC1D; Mon, 18 May 2009 19:54:35 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IJsZ8S073156; Mon, 18 May 2009 19:54:35 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IJsZYE073145; Mon, 18 May 2009 19:54:35 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181954.n4IJsZYE073145@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 19:54:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192334 - in user/kmacy/releng_7_2_fcs/sys: amd64/amd64 amd64/include i386/i386 i386/include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 19:54:35 -0000 Author: kmacy Date: Mon May 18 19:54:34 2009 New Revision: 192334 URL: http://svn.freebsd.org/changeset/base/192334 Log: merge 187880 - Allocate apic vectors on a per-cpu basis. This allows us to allocate more irqs as we have more cpus. This is principally useful on systems with msi devices which may want many irqs per-cpu. Discussed with: jhb Sponsored by: Nokia Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/io_apic.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/msi.c user/kmacy/releng_7_2_fcs/sys/amd64/include/apicvar.h user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h user/kmacy/releng_7_2_fcs/sys/i386/i386/io_apic.c user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c user/kmacy/releng_7_2_fcs/sys/i386/i386/mp_machdep.c user/kmacy/releng_7_2_fcs/sys/i386/i386/msi.c user/kmacy/releng_7_2_fcs/sys/i386/include/apicvar.h user/kmacy/releng_7_2_fcs/sys/i386/include/intr_machdep.h Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/io_apic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/io_apic.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/io_apic.c Mon May 18 19:54:34 2009 (r192334) @@ -327,39 +327,56 @@ ioapic_assign_cpu(struct intsrc *isrc, u { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; struct ioapic *io = (struct ioapic *)isrc->is_pic; + u_int old_vector; + u_int old_id; + /* + * keep 1st core as the destination for NMI + */ + if (intpin->io_irq == IRQ_NMI) + apic_id = 0; + + /* + * Set us up to free the old irq. + */ + old_vector = intpin->io_vector; + old_id = intpin->io_cpu; + if (old_vector && apic_id == old_id) + return; + + /* + * Allocate an APIC vector for this interrupt pin. Once + * we have a vector we program the interrupt pin. + */ intpin->io_cpu = apic_id; + intpin->io_vector = apic_alloc_vector(apic_id, intpin->io_irq); if (bootverbose) { - printf("ioapic%u: Assigning ", io->io_id); + printf("ioapic%u: routing intpin %u (", io->io_id, + intpin->io_intpin); ioapic_print_irq(intpin); - printf(" to local APIC %u\n", intpin->io_cpu); + printf(") to lapic %u vector %u\n", intpin->io_cpu, + intpin->io_vector); } ioapic_program_intpin(intpin); + /* + * Free the old vector after the new one is established. This is done + * to prevent races where we could miss an interrupt. + */ + if (old_vector) + apic_free_vector(old_id, old_vector, intpin->io_irq); } static void ioapic_enable_intr(struct intsrc *isrc) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; - struct ioapic *io = (struct ioapic *)isrc->is_pic; - if (intpin->io_vector == 0) { - /* - * Allocate an APIC vector for this interrupt pin. Once - * we have a vector we program the interrupt pin. - */ - intpin->io_vector = apic_alloc_vector(intpin->io_irq); - if (bootverbose) { - printf("ioapic%u: routing intpin %u (", io->io_id, - intpin->io_intpin); - ioapic_print_irq(intpin); - printf(") to vector %u\n", intpin->io_vector); - } - ioapic_program_intpin(intpin); - apic_enable_vector(intpin->io_vector); - } + if (intpin->io_vector == 0) + ioapic_assign_cpu(isrc, pcpu_find(0)->pc_apic_id); + apic_enable_vector(intpin->io_cpu, intpin->io_vector); } + static void ioapic_disable_intr(struct intsrc *isrc) { @@ -369,11 +386,11 @@ ioapic_disable_intr(struct intsrc *isrc) if (intpin->io_vector != 0) { /* Mask this interrupt pin and free its APIC vector. */ vector = intpin->io_vector; - apic_disable_vector(vector); + apic_disable_vector(intpin->io_cpu, vector); intpin->io_masked = 1; intpin->io_vector = 0; ioapic_program_intpin(intpin); - apic_free_vector(vector, intpin->io_irq); + apic_free_vector(intpin->io_cpu, vector, intpin->io_irq); } } Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c Mon May 18 19:54:34 2009 (r192334) @@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -109,6 +111,8 @@ struct lapic { u_long la_hard_ticks; u_long la_stat_ticks; u_long la_prof_ticks; + /* Include IDT_SYSCALL to make indexing easier. */ + u_int la_ioint_irqs[APIC_NUM_IOINTS + 1]; } static lapics[MAX_APIC_ID + 1]; /* XXX: should thermal be an NMI? */ @@ -134,8 +138,6 @@ static inthand_t *ioint_handlers[] = { IDTVEC(apic_isr7), /* 224 - 255 */ }; -/* Include IDT_SYSCALL to make indexing easier. */ -static u_int ioint_irqs[APIC_NUM_IOINTS + 1]; static u_int32_t lapic_timer_divisors[] = { APIC_TDCR_1, APIC_TDCR_2, APIC_TDCR_4, APIC_TDCR_8, APIC_TDCR_16, @@ -215,14 +217,12 @@ lapic_init(vm_paddr_t addr) /* Perform basic initialization of the BSP's local APIC. */ lapic_enable(); - ioint_irqs[IDT_SYSCALL - APIC_IO_INTS] = IRQ_SYSCALL; /* Set BSP's per-CPU local APIC ID. */ PCPU_SET(apic_id, lapic_id()); /* Local APIC timer interrupt. */ setidt(APIC_TIMER_INT, IDTVEC(timerint), SDT_SYSIGT, SEL_KPL, 0); - ioint_irqs[APIC_TIMER_INT - APIC_IO_INTS] = IRQ_TIMER; /* XXX: error/thermal interrupts */ } @@ -254,6 +254,9 @@ lapic_create(u_int apic_id, int boot_cpu lapics[apic_id].la_lvts[i] = lvts[i]; lapics[apic_id].la_lvts[i].lvt_active = 0; } + lapics[apic_id].la_ioint_irqs[IDT_SYSCALL - APIC_IO_INTS] = IRQ_SYSCALL; + lapics[apic_id].la_ioint_irqs[APIC_TIMER_INT - APIC_IO_INTS] = + IRQ_TIMER; #ifdef SMP cpu_add(apic_id, boot_cpu); @@ -651,7 +654,8 @@ lapic_handle_intr(int vector, struct tra if (vector == -1) panic("Couldn't get vector from ISR!"); - isrc = intr_lookup_source(apic_idt_to_irq(vector)); + isrc = intr_lookup_source(apic_idt_to_irq(PCPU_GET(apic_id), + vector)); intr_execute_handlers(isrc, frame); } @@ -766,9 +770,19 @@ lapic_timer_enable_intr(void) lapic->lvt_timer = value; } +u_int +apic_cpuid(u_int apic_id) +{ +#ifdef SMP + return apic_cpuids[apic_id]; +#else + return 0; +#endif +} + /* Request a free IDT vector to be used by the specified IRQ. */ u_int -apic_alloc_vector(u_int irq) +apic_alloc_vector(u_int apic_id, u_int irq) { u_int vector; @@ -780,9 +794,9 @@ apic_alloc_vector(u_int irq) */ mtx_lock_spin(&icu_lock); for (vector = 0; vector < APIC_NUM_IOINTS; vector++) { - if (ioint_irqs[vector] != 0) + if (lapics[apic_id].la_ioint_irqs[vector] != 0) continue; - ioint_irqs[vector] = irq; + lapics[apic_id].la_ioint_irqs[vector] = irq; mtx_unlock_spin(&icu_lock); return (vector + APIC_IO_INTS); } @@ -797,7 +811,7 @@ apic_alloc_vector(u_int irq) * satisfied, 0 is returned. */ u_int -apic_alloc_vectors(u_int *irqs, u_int count, u_int align) +apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count, u_int align) { u_int first, run, vector; @@ -820,7 +834,7 @@ apic_alloc_vectors(u_int *irqs, u_int co for (vector = 0; vector < APIC_NUM_IOINTS; vector++) { /* Vector is in use, end run. */ - if (ioint_irqs[vector] != 0) { + if (lapics[apic_id].la_ioint_irqs[vector] != 0) { run = 0; first = 0; continue; @@ -840,7 +854,8 @@ apic_alloc_vectors(u_int *irqs, u_int co /* Found a run, assign IRQs and return the first vector. */ for (vector = 0; vector < count; vector++) - ioint_irqs[first + vector] = irqs[vector]; + lapics[apic_id].la_ioint_irqs[first + vector] = + irqs[vector]; mtx_unlock_spin(&icu_lock); return (first + APIC_IO_INTS); } @@ -849,8 +864,14 @@ apic_alloc_vectors(u_int *irqs, u_int co return (0); } +/* + * Enable a vector for a particular apic_id. Since all lapics share idt + * entries and ioint_handlers this enables the vector on all lapics. lapics + * which do not have the vector configured would report spurious interrupts + * should it fire. + */ void -apic_enable_vector(u_int vector) +apic_enable_vector(u_int apic_id, u_int vector) { KASSERT(vector != IDT_SYSCALL, ("Attempt to overwrite syscall entry")); @@ -860,7 +881,7 @@ apic_enable_vector(u_int vector) } void -apic_disable_vector(u_int vector) +apic_disable_vector(u_int apic_id, u_int vector) { KASSERT(vector != IDT_SYSCALL, ("Attempt to overwrite syscall entry")); @@ -871,27 +892,42 @@ apic_disable_vector(u_int vector) /* Release an APIC vector when it's no longer in use. */ void -apic_free_vector(u_int vector, u_int irq) +apic_free_vector(u_int apic_id, u_int vector, u_int irq) { + struct thread *td; KASSERT(vector >= APIC_IO_INTS && vector != IDT_SYSCALL && vector <= APIC_IO_INTS + APIC_NUM_IOINTS, ("Vector %u does not map to an IRQ line", vector)); KASSERT(irq < NUM_IO_INTS, ("Invalid IRQ %u", irq)); - KASSERT(ioint_irqs[vector - APIC_IO_INTS] == irq, ("IRQ mismatch")); + KASSERT(lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] == + irq, ("IRQ mismatch")); + + /* + * Bind us to the cpu that owned the vector before freeing it so + * we don't lose an interrupt delivery race. + */ + td = curthread; + thread_lock(td); + if (sched_is_bound(td)) + panic("apic_free_vector: Thread already bound.\n"); + sched_bind(td, apic_cpuid(apic_id)); mtx_lock_spin(&icu_lock); - ioint_irqs[vector - APIC_IO_INTS] = 0; + lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = 0; mtx_unlock_spin(&icu_lock); + sched_unbind(td); + thread_unlock(td); + } /* Map an IDT vector (APIC) to an IRQ (interrupt source). */ u_int -apic_idt_to_irq(u_int vector) +apic_idt_to_irq(u_int apic_id, u_int vector) { KASSERT(vector >= APIC_IO_INTS && vector != IDT_SYSCALL && vector <= APIC_IO_INTS + APIC_NUM_IOINTS, ("Vector %u does not map to an IRQ line", vector)); - return (ioint_irqs[vector - APIC_IO_INTS]); + return (lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS]); } #ifdef DDB @@ -902,6 +938,7 @@ DB_SHOW_COMMAND(apic, db_show_apic) { struct intsrc *isrc; int i, verbose; + u_int apic_id; u_int irq; if (strcmp(modif, "vv") == 0) @@ -910,9 +947,14 @@ DB_SHOW_COMMAND(apic, db_show_apic) verbose = 1; else verbose = 0; - for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) { - irq = ioint_irqs[i]; - if (irq != 0 && irq != IRQ_SYSCALL) { + for (apic_id = 0; apic_id <= MAX_APIC_ID; apic_id++) { + if (lapics[apic_id].la_present == 0) + continue; + db_printf("Interrupts bound to lapic %u\n", apic_id); + for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) { + irq = lapics[apic_id].la_ioint_irqs[i]; + if (irq == 0 || irq == IRQ_SYSCALL) + continue; db_printf("vec 0x%2x -> ", i + APIC_IO_INTS); if (irq == IRQ_TIMER) db_printf("lapic timer\n"); Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c Mon May 18 19:54:34 2009 (r192334) @@ -156,6 +156,7 @@ struct cpu_info { int cpu_hyperthread:1; } static cpu_info[MAX_APIC_ID + 1]; int cpu_apic_ids[MAXCPU]; +int apic_cpuids[MAX_APIC_ID + 1]; /* Holds pending bitmap based IPIs per CPU */ static volatile u_int cpu_ipi_pending[MAXCPU]; @@ -355,6 +356,7 @@ cpu_mp_start(void) KASSERT(boot_cpu_id == PCPU_GET(apic_id), ("BSP's APIC ID doesn't match boot_cpu_id")); cpu_apic_ids[0] = boot_cpu_id; + apic_cpuids[boot_cpu_id] = 0; /* Setup the initial logical CPUs info. */ logical_cpus = logical_cpus_mask = 0; @@ -689,6 +691,7 @@ assign_cpu_ids(void) if (mp_ncpus < MAXCPU) { cpu_apic_ids[mp_ncpus] = i; + apic_cpuids[i] = mp_ncpus; mp_ncpus++; } else cpu_info[i].cpu_disabled = 1; Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/msi.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/msi.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/msi.c Mon May 18 19:54:34 2009 (r192334) @@ -159,7 +159,9 @@ msi_enable_intr(struct intsrc *isrc) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; - apic_enable_vector(msi->msi_vector); + if (msi->msi_vector == 0) + msi_assign_cpu(isrc, 0); + apic_enable_vector(msi->msi_cpu, msi->msi_vector); } static void @@ -167,7 +169,7 @@ msi_disable_intr(struct intsrc *isrc) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; - apic_disable_vector(msi->msi_vector); + apic_disable_vector(msi->msi_cpu, msi->msi_vector); } static int @@ -197,15 +199,35 @@ static void msi_assign_cpu(struct intsrc *isrc, u_int apic_id) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; - + int old_vector; + u_int old_id; + int vector; + + /* Store information to free existing irq. */ + old_vector = msi->msi_vector; + old_id = msi->msi_cpu; + if (old_vector && old_id == apic_id) + return; + /* Allocate IDT vector on this cpu. */ + vector = apic_alloc_vector(apic_id, msi->msi_irq); + if (vector == 0) + return; /* XXX alloc_vector panics on failure. */ msi->msi_cpu = apic_id; + msi->msi_vector = vector; if (bootverbose) - printf("msi: Assigning %s IRQ %d to local APIC %u\n", + printf("msi: Assigning %s IRQ %d to local APIC %u vector %u\n", msi->msi_msix ? "MSI-X" : "MSI", msi->msi_irq, - msi->msi_cpu); + msi->msi_cpu, msi->msi_vector); pci_remap_msi_irq(msi->msi_dev, msi->msi_irq); + /* + * Free the old vector after the new one is established. This is done + * to prevent races where we could miss an interrupt. + */ + if (old_vector) + apic_free_vector(old_id, old_vector, msi->msi_irq); } + void msi_init(void) { @@ -252,7 +274,7 @@ int msi_alloc(device_t dev, int count, int maxcount, int *irqs) { struct msi_intsrc *msi, *fsrc; - int cnt, i, vector; + int cnt, i; if (!msi_enabled) return (ENXIO); @@ -298,22 +320,12 @@ again: /* Ok, we now have the IRQs allocated. */ KASSERT(cnt == count, ("count mismatch")); - /* Allocate 'count' IDT vectors. */ - vector = apic_alloc_vectors(irqs, count, maxcount); - if (vector == 0) { - mtx_unlock(&msi_lock); - return (ENOSPC); - } - /* Assign IDT vectors and make these messages owned by 'dev'. */ fsrc = (struct msi_intsrc *)intr_lookup_source(irqs[0]); for (i = 0; i < count; i++) { msi = (struct msi_intsrc *)intr_lookup_source(irqs[i]); msi->msi_dev = dev; - msi->msi_vector = vector + i; - if (bootverbose) - printf("msi: routing MSI IRQ %d to vector %u\n", - msi->msi_irq, msi->msi_vector); + msi->msi_vector = 0; msi->msi_first = fsrc; KASSERT(msi->msi_intsrc.is_handlers == 0, ("dead MSI has handlers")); @@ -366,14 +378,18 @@ msi_release(int *irqs, int count) KASSERT(msi->msi_dev == first->msi_dev, ("owner mismatch")); msi->msi_first = NULL; msi->msi_dev = NULL; - apic_free_vector(msi->msi_vector, msi->msi_irq); + if (msi->msi_vector) + apic_free_vector(msi->msi_cpu, msi->msi_vector, + msi->msi_irq); msi->msi_vector = 0; } /* Clear out the first message. */ first->msi_first = NULL; first->msi_dev = NULL; - apic_free_vector(first->msi_vector, first->msi_irq); + if (first->msi_vector) + apic_free_vector(first->msi_cpu, first->msi_vector, + first->msi_irq); first->msi_vector = 0; first->msi_count = 0; @@ -422,7 +438,7 @@ int msix_alloc(device_t dev, int *irq) { struct msi_intsrc *msi; - int i, vector; + int i; if (!msi_enabled) return (ENXIO); @@ -457,15 +473,9 @@ again: goto again; } - /* Allocate an IDT vector. */ - vector = apic_alloc_vector(i); - if (bootverbose) - printf("msi: routing MSI-X IRQ %d to vector %u\n", msi->msi_irq, - vector); - /* Setup source. */ msi->msi_dev = dev; - msi->msi_vector = vector; + msi->msi_vector = 0; msi->msi_msix = 1; KASSERT(msi->msi_intsrc.is_handlers == 0, ("dead MSI-X has handlers")); @@ -497,7 +507,8 @@ msix_release(int irq) /* Clear out the message. */ msi->msi_dev = NULL; - apic_free_vector(msi->msi_vector, msi->msi_irq); + if (msi->msi_vector) + apic_free_vector(msi->msi_cpu, msi->msi_vector, msi->msi_irq); msi->msi_vector = 0; msi->msi_msix = 0; Modified: user/kmacy/releng_7_2_fcs/sys/amd64/include/apicvar.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/include/apicvar.h Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/amd64/include/apicvar.h Mon May 18 19:54:34 2009 (r192334) @@ -176,14 +176,17 @@ inthand_t IDTVEC(apic_isr7), IDTVEC(spuriousint), IDTVEC(timerint); extern vm_paddr_t lapic_paddr; +extern int apic_cpuids[]; -u_int apic_alloc_vector(u_int irq); -u_int apic_alloc_vectors(u_int *irqs, u_int count, u_int align); -void apic_disable_vector(u_int vector); -void apic_enable_vector(u_int vector); -void apic_free_vector(u_int vector, u_int irq); -u_int apic_idt_to_irq(u_int vector); +u_int apic_alloc_vector(u_int apic_id, u_int irq); +u_int apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count, + u_int align); +void apic_disable_vector(u_int apic_id, u_int vector); +void apic_enable_vector(u_int apic_id, u_int vector); +void apic_free_vector(u_int apic_id, u_int vector, u_int irq); +u_int apic_idt_to_irq(u_int apic_id, u_int vector); void apic_register_enumerator(struct apic_enumerator *enumerator); +u_int apic_cpuid(u_int apic_id); void *ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase); int ioapic_disable_pin(void *cookie, u_int pin); int ioapic_get_vector(void *cookie, u_int pin); Modified: user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h Mon May 18 19:54:34 2009 (r192334) @@ -47,7 +47,7 @@ * IRQ values beyond 256 are used by MSI. We leave 255 unused to avoid * confusion since 255 is used in PCI to indicate an invalid IRQ. */ -#define NUM_MSI_INTS 128 +#define NUM_MSI_INTS 512 #define FIRST_MSI_INT 256 #define NUM_IO_INTS (FIRST_MSI_INT + NUM_MSI_INTS) Modified: user/kmacy/releng_7_2_fcs/sys/i386/i386/io_apic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/i386/io_apic.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/i386/i386/io_apic.c Mon May 18 19:54:34 2009 (r192334) @@ -327,39 +327,56 @@ ioapic_assign_cpu(struct intsrc *isrc, u { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; struct ioapic *io = (struct ioapic *)isrc->is_pic; + u_int old_vector; + u_int old_id; + /* + * keep 1st core as the destination for NMI + */ + if (intpin->io_irq == IRQ_NMI) + apic_id = 0; + + /* + * Set us up to free the old irq. + */ + old_vector = intpin->io_vector; + old_id = intpin->io_cpu; + if (old_vector && apic_id == old_id) + return; + + /* + * Allocate an APIC vector for this interrupt pin. Once + * we have a vector we program the interrupt pin. + */ intpin->io_cpu = apic_id; + intpin->io_vector = apic_alloc_vector(apic_id, intpin->io_irq); if (bootverbose) { - printf("ioapic%u: Assigning ", io->io_id); + printf("ioapic%u: routing intpin %u (", io->io_id, + intpin->io_intpin); ioapic_print_irq(intpin); - printf(" to local APIC %u\n", intpin->io_cpu); + printf(") to lapic %u vector %u\n", intpin->io_cpu, + intpin->io_vector); } ioapic_program_intpin(intpin); + /* + * Free the old vector after the new one is established. This is done + * to prevent races where we could miss an interrupt. + */ + if (old_vector) + apic_free_vector(old_id, old_vector, intpin->io_irq); } static void ioapic_enable_intr(struct intsrc *isrc) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; - struct ioapic *io = (struct ioapic *)isrc->is_pic; - if (intpin->io_vector == 0) { - /* - * Allocate an APIC vector for this interrupt pin. Once - * we have a vector we program the interrupt pin. - */ - intpin->io_vector = apic_alloc_vector(intpin->io_irq); - if (bootverbose) { - printf("ioapic%u: routing intpin %u (", io->io_id, - intpin->io_intpin); - ioapic_print_irq(intpin); - printf(") to vector %u\n", intpin->io_vector); - } - ioapic_program_intpin(intpin); - apic_enable_vector(intpin->io_vector); - } + if (intpin->io_vector == 0) + ioapic_assign_cpu(isrc, pcpu_find(0)->pc_apic_id); + apic_enable_vector(intpin->io_cpu, intpin->io_vector); } + static void ioapic_disable_intr(struct intsrc *isrc) { @@ -369,11 +386,11 @@ ioapic_disable_intr(struct intsrc *isrc) if (intpin->io_vector != 0) { /* Mask this interrupt pin and free its APIC vector. */ vector = intpin->io_vector; - apic_disable_vector(vector); + apic_disable_vector(intpin->io_cpu, vector); intpin->io_masked = 1; intpin->io_vector = 0; ioapic_program_intpin(intpin); - apic_free_vector(vector, intpin->io_irq); + apic_free_vector(intpin->io_cpu, vector, intpin->io_irq); } } Modified: user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c Mon May 18 19:54:34 2009 (r192334) @@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -109,6 +111,8 @@ struct lapic { u_long la_hard_ticks; u_long la_stat_ticks; u_long la_prof_ticks; + /* Include IDT_SYSCALL to make indexing easier. */ + u_int la_ioint_irqs[APIC_NUM_IOINTS + 1]; } static lapics[MAX_APIC_ID + 1]; /* XXX: should thermal be an NMI? */ @@ -134,8 +138,6 @@ static inthand_t *ioint_handlers[] = { IDTVEC(apic_isr7), /* 224 - 255 */ }; -/* Include IDT_SYSCALL to make indexing easier. */ -static u_int ioint_irqs[APIC_NUM_IOINTS + 1]; static u_int32_t lapic_timer_divisors[] = { APIC_TDCR_1, APIC_TDCR_2, APIC_TDCR_4, APIC_TDCR_8, APIC_TDCR_16, @@ -216,7 +218,6 @@ lapic_init(vm_paddr_t addr) /* Perform basic initialization of the BSP's local APIC. */ lapic_enable(); - ioint_irqs[IDT_SYSCALL - APIC_IO_INTS] = IRQ_SYSCALL; /* Set BSP's per-CPU local APIC ID. */ PCPU_SET(apic_id, lapic_id()); @@ -224,7 +225,6 @@ lapic_init(vm_paddr_t addr) /* Local APIC timer interrupt. */ setidt(APIC_TIMER_INT, IDTVEC(timerint), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); - ioint_irqs[APIC_TIMER_INT - APIC_IO_INTS] = IRQ_TIMER; /* XXX: error/thermal interrupts */ } @@ -256,6 +256,9 @@ lapic_create(u_int apic_id, int boot_cpu lapics[apic_id].la_lvts[i] = lvts[i]; lapics[apic_id].la_lvts[i].lvt_active = 0; } + lapics[apic_id].la_ioint_irqs[IDT_SYSCALL - APIC_IO_INTS] = IRQ_SYSCALL; + lapics[apic_id].la_ioint_irqs[APIC_TIMER_INT - APIC_IO_INTS] = + IRQ_TIMER; #ifdef SMP cpu_add(apic_id, boot_cpu); @@ -653,7 +656,8 @@ lapic_handle_intr(int vector, struct tra if (vector == -1) panic("Couldn't get vector from ISR!"); - isrc = intr_lookup_source(apic_idt_to_irq(vector)); + isrc = intr_lookup_source(apic_idt_to_irq(PCPU_GET(apic_id), + vector)); intr_execute_handlers(isrc, frame); } @@ -768,9 +772,19 @@ lapic_timer_enable_intr(void) lapic->lvt_timer = value; } +u_int +apic_cpuid(u_int apic_id) +{ +#ifdef SMP + return apic_cpuids[apic_id]; +#else + return 0; +#endif +} + /* Request a free IDT vector to be used by the specified IRQ. */ u_int -apic_alloc_vector(u_int irq) +apic_alloc_vector(u_int apic_id, u_int irq) { u_int vector; @@ -782,9 +796,9 @@ apic_alloc_vector(u_int irq) */ mtx_lock_spin(&icu_lock); for (vector = 0; vector < APIC_NUM_IOINTS; vector++) { - if (ioint_irqs[vector] != 0) + if (lapics[apic_id].la_ioint_irqs[vector] != 0) continue; - ioint_irqs[vector] = irq; + lapics[apic_id].la_ioint_irqs[vector] = irq; mtx_unlock_spin(&icu_lock); return (vector + APIC_IO_INTS); } @@ -799,7 +813,7 @@ apic_alloc_vector(u_int irq) * satisfied, 0 is returned. */ u_int -apic_alloc_vectors(u_int *irqs, u_int count, u_int align) +apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count, u_int align) { u_int first, run, vector; @@ -822,7 +836,7 @@ apic_alloc_vectors(u_int *irqs, u_int co for (vector = 0; vector < APIC_NUM_IOINTS; vector++) { /* Vector is in use, end run. */ - if (ioint_irqs[vector] != 0) { + if (lapics[apic_id].la_ioint_irqs[vector] != 0) { run = 0; first = 0; continue; @@ -842,7 +856,8 @@ apic_alloc_vectors(u_int *irqs, u_int co /* Found a run, assign IRQs and return the first vector. */ for (vector = 0; vector < count; vector++) - ioint_irqs[first + vector] = irqs[vector]; + lapics[apic_id].la_ioint_irqs[first + vector] = + irqs[vector]; mtx_unlock_spin(&icu_lock); return (first + APIC_IO_INTS); } @@ -851,8 +866,14 @@ apic_alloc_vectors(u_int *irqs, u_int co return (0); } +/* + * Enable a vector for a particular apic_id. Since all lapics share idt + * entries and ioint_handlers this enables the vector on all lapics. lapics + * which do not have the vector configured would report spurious interrupts + * should it fire. + */ void -apic_enable_vector(u_int vector) +apic_enable_vector(u_int apic_id, u_int vector) { KASSERT(vector != IDT_SYSCALL, ("Attempt to overwrite syscall entry")); @@ -863,7 +884,7 @@ apic_enable_vector(u_int vector) } void -apic_disable_vector(u_int vector) +apic_disable_vector(u_int apic_id, u_int vector) { KASSERT(vector != IDT_SYSCALL, ("Attempt to overwrite syscall entry")); @@ -875,27 +896,42 @@ apic_disable_vector(u_int vector) /* Release an APIC vector when it's no longer in use. */ void -apic_free_vector(u_int vector, u_int irq) +apic_free_vector(u_int apic_id, u_int vector, u_int irq) { + struct thread *td; KASSERT(vector >= APIC_IO_INTS && vector != IDT_SYSCALL && vector <= APIC_IO_INTS + APIC_NUM_IOINTS, ("Vector %u does not map to an IRQ line", vector)); KASSERT(irq < NUM_IO_INTS, ("Invalid IRQ %u", irq)); - KASSERT(ioint_irqs[vector - APIC_IO_INTS] == irq, ("IRQ mismatch")); + KASSERT(lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] == + irq, ("IRQ mismatch")); + + /* + * Bind us to the cpu that owned the vector before freeing it so + * we don't lose an interrupt delivery race. + */ + td = curthread; + thread_lock(td); + if (sched_is_bound(td)) + panic("apic_free_vector: Thread already bound.\n"); + sched_bind(td, apic_cpuid(apic_id)); mtx_lock_spin(&icu_lock); - ioint_irqs[vector - APIC_IO_INTS] = 0; + lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = 0; mtx_unlock_spin(&icu_lock); + sched_unbind(td); + thread_unlock(td); + } /* Map an IDT vector (APIC) to an IRQ (interrupt source). */ u_int -apic_idt_to_irq(u_int vector) +apic_idt_to_irq(u_int apic_id, u_int vector) { KASSERT(vector >= APIC_IO_INTS && vector != IDT_SYSCALL && vector <= APIC_IO_INTS + APIC_NUM_IOINTS, ("Vector %u does not map to an IRQ line", vector)); - return (ioint_irqs[vector - APIC_IO_INTS]); + return (lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS]); } #ifdef DDB @@ -906,6 +942,7 @@ DB_SHOW_COMMAND(apic, db_show_apic) { struct intsrc *isrc; int i, verbose; + u_int apic_id; u_int irq; if (strcmp(modif, "vv") == 0) @@ -914,9 +951,14 @@ DB_SHOW_COMMAND(apic, db_show_apic) verbose = 1; else verbose = 0; - for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) { - irq = ioint_irqs[i]; - if (irq != 0 && irq != IRQ_SYSCALL) { + for (apic_id = 0; apic_id <= MAX_APIC_ID; apic_id++) { + if (lapics[apic_id].la_present == 0) + continue; + db_printf("Interrupts bound to lapic %u\n", apic_id); + for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) { + irq = lapics[apic_id].la_ioint_irqs[i]; + if (irq == 0 || irq == IRQ_SYSCALL) + continue; db_printf("vec 0x%2x -> ", i + APIC_IO_INTS); if (irq == IRQ_TIMER) db_printf("lapic timer\n"); Modified: user/kmacy/releng_7_2_fcs/sys/i386/i386/mp_machdep.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/i386/mp_machdep.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/i386/i386/mp_machdep.c Mon May 18 19:54:34 2009 (r192334) @@ -212,6 +212,7 @@ struct cpu_info { int cpu_hyperthread:1; } static cpu_info[MAX_APIC_ID + 1]; int cpu_apic_ids[MAXCPU]; +int apic_cpuids[MAX_APIC_ID + 1]; /* Holds pending bitmap based IPIs per CPU */ static volatile u_int cpu_ipi_pending[MAXCPU]; @@ -405,6 +406,7 @@ cpu_mp_start(void) KASSERT(boot_cpu_id == PCPU_GET(apic_id), ("BSP's APIC ID doesn't match boot_cpu_id")); cpu_apic_ids[0] = boot_cpu_id; + apic_cpuids[boot_cpu_id] = 0; /* Setup the initial logical CPUs info. */ logical_cpus = logical_cpus_mask = 0; @@ -742,6 +744,7 @@ assign_cpu_ids(void) if (mp_ncpus < MAXCPU) { cpu_apic_ids[mp_ncpus] = i; + apic_cpuids[i] = mp_ncpus; mp_ncpus++; } else cpu_info[i].cpu_disabled = 1; Modified: user/kmacy/releng_7_2_fcs/sys/i386/i386/msi.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/i386/msi.c Mon May 18 19:50:18 2009 (r192333) +++ user/kmacy/releng_7_2_fcs/sys/i386/i386/msi.c Mon May 18 19:54:34 2009 (r192334) @@ -159,7 +159,9 @@ msi_enable_intr(struct intsrc *isrc) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; - apic_enable_vector(msi->msi_vector); + if (msi->msi_vector == 0) + msi_assign_cpu(isrc, 0); + apic_enable_vector(msi->msi_cpu, msi->msi_vector); } static void @@ -167,7 +169,7 @@ msi_disable_intr(struct intsrc *isrc) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; - apic_disable_vector(msi->msi_vector); + apic_disable_vector(msi->msi_cpu, msi->msi_vector); } static int @@ -197,15 +199,35 @@ static void msi_assign_cpu(struct intsrc *isrc, u_int apic_id) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; - + int old_vector; + u_int old_id; + int vector; + + /* Store information to free existing irq. */ + old_vector = msi->msi_vector; + old_id = msi->msi_cpu; + if (old_vector && old_id == apic_id) + return; + /* Allocate IDT vector on this cpu. */ + vector = apic_alloc_vector(apic_id, msi->msi_irq); + if (vector == 0) + return; /* XXX alloc_vector panics on failure. */ msi->msi_cpu = apic_id; + msi->msi_vector = vector; if (bootverbose) - printf("msi: Assigning %s IRQ %d to local APIC %u\n", + printf("msi: Assigning %s IRQ %d to local APIC %u vector %u\n", msi->msi_msix ? "MSI-X" : "MSI", msi->msi_irq, - msi->msi_cpu); + msi->msi_cpu, msi->msi_vector); pci_remap_msi_irq(msi->msi_dev, msi->msi_irq); + /* + * Free the old vector after the new one is established. This is done + * to prevent races where we could miss an interrupt. + */ + if (old_vector) + apic_free_vector(old_id, old_vector, msi->msi_irq); } + void msi_init(void) { @@ -252,7 +274,7 @@ int msi_alloc(device_t dev, int count, int maxcount, int *irqs) { struct msi_intsrc *msi, *fsrc; - int cnt, i, vector; + int cnt, i; if (!msi_enabled) return (ENXIO); @@ -298,22 +320,12 @@ again: /* Ok, we now have the IRQs allocated. */ KASSERT(cnt == count, ("count mismatch")); - /* Allocate 'count' IDT vectors. */ - vector = apic_alloc_vectors(irqs, count, maxcount); - if (vector == 0) { - mtx_unlock(&msi_lock); - return (ENOSPC); - } - /* Assign IDT vectors and make these messages owned by 'dev'. */ fsrc = (struct msi_intsrc *)intr_lookup_source(irqs[0]); for (i = 0; i < count; i++) { msi = (struct msi_intsrc *)intr_lookup_source(irqs[i]); msi->msi_dev = dev; - msi->msi_vector = vector + i; - if (bootverbose) - printf("msi: routing MSI IRQ %d to vector %u\n", - msi->msi_irq, msi->msi_vector); + msi->msi_vector = 0; msi->msi_first = fsrc; KASSERT(msi->msi_intsrc.is_handlers == 0, ("dead MSI has handlers")); @@ -366,14 +378,18 @@ msi_release(int *irqs, int count) KASSERT(msi->msi_dev == first->msi_dev, ("owner mismatch")); msi->msi_first = NULL; msi->msi_dev = NULL; - apic_free_vector(msi->msi_vector, msi->msi_irq); + if (msi->msi_vector) + apic_free_vector(msi->msi_cpu, msi->msi_vector, + msi->msi_irq); msi->msi_vector = 0; } /* Clear out the first message. */ first->msi_first = NULL; first->msi_dev = NULL; - apic_free_vector(first->msi_vector, first->msi_irq); + if (first->msi_vector) + apic_free_vector(first->msi_cpu, first->msi_vector, + first->msi_irq); first->msi_vector = 0; first->msi_count = 0; @@ -422,7 +438,7 @@ int msix_alloc(device_t dev, int *irq) { struct msi_intsrc *msi; - int i, vector; + int i; if (!msi_enabled) return (ENXIO); @@ -457,15 +473,9 @@ again: goto again; } - /* Allocate an IDT vector. */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon May 18 19:56:06 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB25B106566C; Mon, 18 May 2009 19:56:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9EB78FC12; Mon, 18 May 2009 19:56:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IJu68Q073252; Mon, 18 May 2009 19:56:06 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IJu6N4073250; Mon, 18 May 2009 19:56:06 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905181956.n4IJu6N4073250@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 19:56:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192335 - in user/kmacy/releng_7_2_fcs/sys: amd64/amd64 i386/i386 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 19:56:07 -0000 Author: kmacy Date: Mon May 18 19:56:06 2009 New Revision: 192335 URL: http://svn.freebsd.org/changeset/base/192335 Log: merge 188904 - Resolve an issue where we may clear an idt while an interrupt on a different cpu is still assigned to that vector by never clearing idt entries. This was only provided as a debugging feature and the bugs are caught by other means. - Drop the sched lock when rebinding to reassign an interrupt vector to a new cpu so that pending interrupts have a chance to be delivered before removing the old vector. Discussed with: tegge, jhb Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c Mon May 18 19:54:34 2009 (r192334) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c Mon May 18 19:56:06 2009 (r192335) @@ -887,7 +887,13 @@ apic_disable_vector(u_int apic_id, u_int KASSERT(vector != IDT_SYSCALL, ("Attempt to overwrite syscall entry")); KASSERT(ioint_handlers[vector / 32] != NULL, ("No ISR handler for vector %u", vector)); +#ifdef notyet + /* + * We can not currently clear the idt entry because other cpus + * may have a valid vector at this offset. + */ setidt(vector, &IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); +#endif } /* Release an APIC vector when it's no longer in use. */ @@ -911,9 +917,11 @@ apic_free_vector(u_int apic_id, u_int ve if (sched_is_bound(td)) panic("apic_free_vector: Thread already bound.\n"); sched_bind(td, apic_cpuid(apic_id)); + thread_unlock(td); mtx_lock_spin(&icu_lock); lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = 0; mtx_unlock_spin(&icu_lock); + thread_lock(td); sched_unbind(td); thread_unlock(td); Modified: user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c Mon May 18 19:54:34 2009 (r192334) +++ user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c Mon May 18 19:56:06 2009 (r192335) @@ -890,8 +890,14 @@ apic_disable_vector(u_int apic_id, u_int KASSERT(vector != IDT_SYSCALL, ("Attempt to overwrite syscall entry")); KASSERT(ioint_handlers[vector / 32] != NULL, ("No ISR handler for vector %u", vector)); +#ifdef notyet + /* + * We can not currently clear the idt entry because other cpus + * may have a valid vector at this offset. + */ setidt(vector, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); +#endif } /* Release an APIC vector when it's no longer in use. */ @@ -915,9 +921,11 @@ apic_free_vector(u_int apic_id, u_int ve if (sched_is_bound(td)) panic("apic_free_vector: Thread already bound.\n"); sched_bind(td, apic_cpuid(apic_id)); + thread_unlock(td); mtx_lock_spin(&icu_lock); lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = 0; mtx_unlock_spin(&icu_lock); + thread_lock(td); sched_unbind(td); thread_unlock(td); From owner-svn-src-user@FreeBSD.ORG Mon May 18 21:23:13 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7ABA106567D; Mon, 18 May 2009 21:23:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D74238FC31; Mon, 18 May 2009 21:23:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4ILNDFP075099; Mon, 18 May 2009 21:23:13 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4ILNDET075098; Mon, 18 May 2009 21:23:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905182123.n4ILNDET075098@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 21:23:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192338 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 21:23:14 -0000 Author: kmacy Date: Mon May 18 21:23:13 2009 New Revision: 192338 URL: http://svn.freebsd.org/changeset/base/192338 Log: merge 189789 Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Mon May 18 21:22:03 2009 (r192337) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Mon May 18 21:23:13 2009 (r192338) @@ -775,6 +775,7 @@ mtx_destroy(struct mtx *m) else curthread->td_locks--; + lock_profile_release_lock(&m->lock_object); /* Tell witness this isn't locked to make it happy. */ WITNESS_UNLOCK(&m->lock_object, LOP_EXCLUSIVE, __FILE__, __LINE__); From owner-svn-src-user@FreeBSD.ORG Mon May 18 21:58:22 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F3FF106564A; Mon, 18 May 2009 21:58:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A9DB8FC19; Mon, 18 May 2009 21:58:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4ILwM2r076078; Mon, 18 May 2009 21:58:22 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4ILwLvI076061; Mon, 18 May 2009 21:58:21 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905182158.n4ILwLvI076061@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 21:58:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192345 - in user/kmacy/releng_7_2_fcs/sys: compat/ndis dev/cxgb dev/cxgb/ulp/tom dev/hatm dev/iscsi/initiator dev/lge dev/msk dev/patm dev/sk dev/ti dev/wpi kern pci sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 21:58:22 -0000 Author: kmacy Date: Mon May 18 21:58:21 2009 New Revision: 192345 URL: http://svn.freebsd.org/changeset/base/192345 Log: merge 175872 Give MEXTADD() another argument to make both void pointers to the free function controlable, instead of passing the KVA of the buffer storage as the first argument. Fix all conventional users of the API to pass the KVA of the buffer as the first argument, to make this a no-op commit. Likely break the only non-convetional user of the API, after informing the relevant committer. Update the mbuf(9) manual page, which was already out of sync on this point. This paves the way for giving sendfile(9) a way to wait for the passed storage to have been accessed before returning. This does not affect the memory layout or size of mbufs. Modified: user/kmacy/releng_7_2_fcs/sys/compat/ndis/kern_ndis.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c user/kmacy/releng_7_2_fcs/sys/dev/hatm/if_hatm_intr.c user/kmacy/releng_7_2_fcs/sys/dev/iscsi/initiator/isc_soc.c user/kmacy/releng_7_2_fcs/sys/dev/lge/if_lge.c user/kmacy/releng_7_2_fcs/sys/dev/msk/if_msk.c user/kmacy/releng_7_2_fcs/sys/dev/patm/if_patm_rx.c user/kmacy/releng_7_2_fcs/sys/dev/sk/if_sk.c user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c user/kmacy/releng_7_2_fcs/sys/dev/wpi/if_wpi.c user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_cow.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c user/kmacy/releng_7_2_fcs/sys/pci/if_wb.c user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h Modified: user/kmacy/releng_7_2_fcs/sys/compat/ndis/kern_ndis.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/compat/ndis/kern_ndis.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/compat/ndis/kern_ndis.c Mon May 18 21:58:21 2009 (r192345) @@ -732,7 +732,7 @@ ndis_ptom(m0, p) m->m_len = MmGetMdlByteCount(buf); m->m_data = MmGetMdlVirtualAddress(buf); MEXTADD(m, m->m_data, m->m_len, ndis_return_packet, - p, 0, EXT_NDIS); + m->m_data, p, 0, EXT_NDIS); p->np_refcnt++; totlen += m->m_len; Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c Mon May 18 21:58:21 2009 (r192345) @@ -2552,12 +2552,8 @@ init_cluster_mbuf(caddr_t cl, int flags, m->m_ext.ref_cnt = (uint32_t *)(cl + header_size - sizeof(uint32_t)); m->m_ext.ext_size = m_getsizefromtype(type); m->m_ext.ext_free = ext_free_handler; -#if __FreeBSD_version >= 800016 m->m_ext.ext_arg1 = cl; m->m_ext.ext_arg2 = (void *)(uintptr_t)type; -#else - m->m_ext.ext_args = (void *)(uintptr_t)type; -#endif m->m_ext.ext_type = EXT_EXTREF; *(m->m_ext.ref_cnt) = 1; DPRINTF("data=%p ref_cnt=%p\n", m->m_data, m->m_ext.ref_cnt); Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c Mon May 18 21:58:21 2009 (r192345) @@ -368,7 +368,8 @@ cxgb_vm_page_to_miov(struct toepcb *toep m0->m_flags = (M_EXT|M_NOFREE); m0->m_ext.ext_type = EXT_EXTREF; m0->m_ext.ext_free = cxgb_zero_copy_free; - m0->m_ext.ext_args = NULL; /* XXX: probably wrong /phk */ + m0->m_ext.ext_arg1 = NULL; /* XXX: probably wrong /phk */ + m0->m_ext.ext_arg2 = NULL; mv = mtomv(m0); mv->mv_count = seg_count; Modified: user/kmacy/releng_7_2_fcs/sys/dev/hatm/if_hatm_intr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hatm/if_hatm_intr.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/hatm/if_hatm_intr.c Mon May 18 21:58:21 2009 (r192345) @@ -458,7 +458,7 @@ hatm_rx_buffer(struct hatm_softc *sc, u_ if (m != NULL) { m->m_ext.ref_cnt = &c0->hdr.ref_cnt; MEXTADD(m, (void *)c0, MBUF0_SIZE, - hatm_mbuf0_free, sc, M_PKTHDR, EXT_EXTREF); + hatm_mbuf0_free, c0, sc, M_PKTHDR, EXT_EXTREF); m->m_data += MBUF0_OFFSET; } else hatm_mbuf0_free(c0, sc); @@ -482,7 +482,7 @@ hatm_rx_buffer(struct hatm_softc *sc, u_ if (m != NULL) { m->m_ext.ref_cnt = &c1->hdr.ref_cnt; MEXTADD(m, (void *)c1, MBUF1_SIZE, - hatm_mbuf1_free, sc, M_PKTHDR, EXT_EXTREF); + hatm_mbuf1_free, c1, sc, M_PKTHDR, EXT_EXTREF); m->m_data += MBUF1_OFFSET; } else hatm_mbuf1_free(c1, sc); Modified: user/kmacy/releng_7_2_fcs/sys/dev/iscsi/initiator/isc_soc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/iscsi/initiator/isc_soc.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/iscsi/initiator/isc_soc.c Mon May 18 21:58:21 2009 (r192345) @@ -164,7 +164,7 @@ isc_sendPDU(isc_session_t *sp, pduq_t *p md->m_ext.ref_cnt = &nil_refcnt; l = min(MCLBYTES, len); MEXTADD(md, pp->ds + off, l, nil_fn, - NULL, 0, EXT_EXTREF); + pp->ds + off, NULL, 0, EXT_EXTREF); md->m_len = l; md->m_next = NULL; mh->m_pkthdr.len += l; Modified: user/kmacy/releng_7_2_fcs/sys/dev/lge/if_lge.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/lge/if_lge.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/lge/if_lge.c Mon May 18 21:58:21 2009 (r192345) @@ -718,7 +718,7 @@ lge_newbuf(sc, c, m) m_new->m_data = (void *)buf; m_new->m_len = m_new->m_pkthdr.len = LGE_JUMBO_FRAMELEN; MEXTADD(m_new, buf, LGE_JUMBO_FRAMELEN, lge_jfree, - (struct lge_softc *)sc, 0, EXT_NET_DRV); + buf, (struct lge_softc *)sc, 0, EXT_NET_DRV); } else { m_new = m; m_new->m_len = m_new->m_pkthdr.len = LGE_JUMBO_FRAMELEN; Modified: user/kmacy/releng_7_2_fcs/sys/dev/msk/if_msk.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/msk/if_msk.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/msk/if_msk.c Mon May 18 21:58:21 2009 (r192345) @@ -841,6 +841,14 @@ msk_jumbo_newbuf(struct msk_if_softc *sc m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); + buf = msk_jalloc(sc_if); + if (buf == NULL) { + m_freem(m); + return (ENOBUFS); + } + /* Attach the buffer to the mbuf. */ + MEXTADD(m, buf, MSK_JLEN, msk_jfree, buf, + (struct msk_if_softc *)sc_if, 0, EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); return (ENOBUFS); Modified: user/kmacy/releng_7_2_fcs/sys/dev/patm/if_patm_rx.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/patm/if_patm_rx.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/patm/if_patm_rx.c Mon May 18 21:58:21 2009 (r192345) @@ -406,11 +406,11 @@ patm_rcv_mbuf(struct patm_softc *sc, voi if ((h & ~MBUF_HMASK) == MBUF_VHANDLE) { MEXTADD(m, (caddr_t)buf, VMBUF_SIZE, mbp_ext_free, - sc->vbuf_pool, M_PKTHDR, EXT_NET_DRV); + buf, sc->vbuf_pool, M_PKTHDR, EXT_NET_DRV); m->m_data += VMBUF_OFFSET; } else { MEXTADD(m, (caddr_t)buf, SMBUF_SIZE, mbp_ext_free, - sc->sbuf_pool, M_PKTHDR, EXT_NET_DRV); + buf, sc->sbuf_pool, M_PKTHDR, EXT_NET_DRV); m->m_data += SMBUF_OFFSET; } Modified: user/kmacy/releng_7_2_fcs/sys/dev/sk/if_sk.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/sk/if_sk.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/sk/if_sk.c Mon May 18 21:58:21 2009 (r192345) @@ -1052,6 +1052,14 @@ sk_jumbo_newbuf(sc_if, idx) m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); + buf = sk_jalloc(sc_if); + if (buf == NULL) { + m_freem(m); + return (ENOBUFS); + } + /* Attach the buffer to the mbuf */ + MEXTADD(m, buf, SK_JLEN, sk_jfree, (struct sk_if_softc *)sc_if, buf, 0, + EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); return (ENOBUFS); Modified: user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c Mon May 18 21:58:21 2009 (r192345) @@ -1503,7 +1503,8 @@ ti_newbuf_jumbo(sc, idx, m_old) m[i]->m_data = (void *)sf_buf_kva(sf[i]); m[i]->m_len = PAGE_SIZE; MEXTADD(m[i], sf_buf_kva(sf[i]), PAGE_SIZE, - sf_buf_mext, sf[i], 0, EXT_DISPOSABLE); + sf_buf_mext, (void*)sf_buf_kva(sf[i]), sf[i], + 0, EXT_DISPOSABLE); m[i]->m_next = m[i+1]; } /* link the buffers to the header */ Modified: user/kmacy/releng_7_2_fcs/sys/dev/wpi/if_wpi.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/wpi/if_wpi.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/dev/wpi/if_wpi.c Mon May 18 21:58:21 2009 (r192345) @@ -971,16 +971,15 @@ wpi_alloc_rx_ring(struct wpi_softc *sc, error = ENOMEM; goto fail; } - /* map page */ - error = bus_dmamap_load(ring->data_dmat, data->map, - mtod(m, caddr_t), MJUMPAGESIZE, - wpi_dma_map_addr, &paddr, BUS_DMA_NOWAIT); - if (error != 0 && error != EFBIG) { - device_printf(sc->sc_dev, - "%s: bus_dmamap_load failed, error %d\n", - __func__, error); - m_freem(m); - error = ENOMEM; /* XXX unique code */ + + /* attach RxBuffer to mbuf */ + MEXTADD(data->m, rbuf->vaddr, WPI_RBUF_SIZE,wpi_free_rbuf, + rbuf->vaddr, rbuf, 0, EXT_NET_DRV); + + if ((data->m->m_flags & M_EXT) == 0) { + m_freem(data->m); + data->m = NULL; + error = ENOBUFS; goto fail; } bus_dmamap_sync(ring->data_dmat, data->map, @@ -1489,7 +1488,27 @@ wpi_rx_intr(struct wpi_softc *sc, struct data->m = mnew; /* update Rx descriptor */ ring->desc[ring->cur] = htole32(paddr); + /* attach Rx buffer to mbuf */ + MEXTADD(mnew, rbuf->vaddr, WPI_RBUF_SIZE, wpi_free_rbuf, + rbuf->vaddr, rbuf, 0, EXT_NET_DRV); + SLIST_REMOVE_HEAD(&sc->rxq.freelist, next); + data->m = mnew; + + /* update Rx descriptor */ + ring->desc[ring->cur] = htole32(rbuf->paddr); + } else { + /* no free rbufs, copy frame */ + m = m_dup(m, M_DONTWAIT); + if (m == NULL) { + /* no free mbufs either, drop frame */ + ifp->if_ierrors++; + return; + } + } +#ifndef WPI_CURRENT + if (sc->sc_drvbpf != NULL) { +#else if (bpf_peers_present(sc->sc_drvbpf)) { struct wpi_rx_radiotap_header *tap = &sc->sc_rxtap; Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c Mon May 18 21:58:21 2009 (r192345) @@ -469,7 +469,8 @@ mb_dtor_pack(void *mem, int size, void * KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__)); KASSERT(m->m_ext.ext_buf != NULL, ("%s: ext_buf == NULL", __func__)); KASSERT(m->m_ext.ext_free == NULL, ("%s: ext_free != NULL", __func__)); - KASSERT(m->m_ext.ext_args == NULL, ("%s: ext_args != NULL", __func__)); + KASSERT(m->m_ext.ext_arg1 == NULL, ("%s: ext_arg1 != NULL", __func__)); + KASSERT(m->m_ext.ext_arg2 == NULL, ("%s: ext_arg2 != NULL", __func__)); KASSERT(m->m_ext.ext_size == MCLBYTES, ("%s: ext_size != MCLBYTES", __func__)); KASSERT(m->m_ext.ext_type == EXT_PACKET, ("%s: ext_type != EXT_PACKET", __func__)); KASSERT(*m->m_ext.ref_cnt == 1, ("%s: ref_cnt != 1", __func__)); @@ -537,7 +538,8 @@ mb_ctor_clust(void *mem, int size, void m->m_data = m->m_ext.ext_buf; m->m_flags |= M_EXT; m->m_ext.ext_free = NULL; - m->m_ext.ext_args = NULL; + m->m_ext.ext_arg1 = NULL; + m->m_ext.ext_arg2 = NULL; m->m_ext.ext_size = size; m->m_ext.ext_type = type; m->m_ext.ref_cnt = refcnt; Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_cow.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_cow.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_cow.c Mon May 18 21:58:21 2009 (r192345) @@ -164,8 +164,8 @@ socow_setup(struct mbuf *m0, struct uio /* * attach to mbuf */ - MEXTADD(m0, sf_buf_kva(sf), PAGE_SIZE, socow_iodone, sf, M_RDONLY, - EXT_SFBUF); + MEXTADD(m0, sf_buf_kva(sf), PAGE_SIZE, socow_iodone, + (void*)sf_buf_kva(sf), sf, M_RDONLY, EXT_SFBUF); m0->m_len = PAGE_SIZE - offset; m0->m_data = (caddr_t)sf_buf_kva(sf) + offset; socow_stats.success++; Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c Mon May 18 21:58:21 2009 (r192345) @@ -186,7 +186,7 @@ m_freem(struct mbuf *mb) */ void m_extadd(struct mbuf *mb, caddr_t buf, u_int size, - void (*freef)(void *, void *), void *args, int flags, int type) + void (*freef)(void *, void *), void *arg1, void *arg2, int flags, int type) { KASSERT(type != EXT_CLUSTER, ("%s: EXT_CLUSTER not allowed", __func__)); @@ -199,7 +199,8 @@ m_extadd(struct mbuf *mb, caddr_t buf, u mb->m_data = mb->m_ext.ext_buf; mb->m_ext.ext_size = size; mb->m_ext.ext_free = freef; - mb->m_ext.ext_args = args; + mb->m_ext.ext_arg1 = arg1; + mb->m_ext.ext_arg2 = arg2; mb->m_ext.ext_type = type; } } @@ -254,8 +255,8 @@ mb_free_ext(struct mbuf *m) case EXT_EXTREF: KASSERT(m->m_ext.ext_free != NULL, ("%s: ext_free not set", __func__)); - (*(m->m_ext.ext_free))(m->m_ext.ext_buf, - m->m_ext.ext_args); + (*(m->m_ext.ext_free))(m->m_ext.ext_arg1, + m->m_ext.ext_arg2); break; default: KASSERT(m->m_ext.ext_type == 0, @@ -271,7 +272,8 @@ mb_free_ext(struct mbuf *m) */ m->m_ext.ext_buf = NULL; m->m_ext.ext_free = NULL; - m->m_ext.ext_args = NULL; + m->m_ext.ext_arg1 = NULL; + m->m_ext.ext_arg2 = NULL; m->m_ext.ref_cnt = NULL; m->m_ext.ext_size = 0; m->m_ext.ext_type = 0; @@ -296,7 +298,8 @@ mb_dupcl(struct mbuf *n, struct mbuf *m) atomic_add_int(m->m_ext.ref_cnt, 1); n->m_ext.ext_buf = m->m_ext.ext_buf; n->m_ext.ext_free = m->m_ext.ext_free; - n->m_ext.ext_args = m->m_ext.ext_args; + n->m_ext.ext_arg1 = m->m_ext.ext_arg1; + n->m_ext.ext_arg2 = m->m_ext.ext_arg2; n->m_ext.ext_size = m->m_ext.ext_size; n->m_ext.ref_cnt = m->m_ext.ref_cnt; n->m_ext.ext_type = m->m_ext.ext_type; Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Mon May 18 21:58:21 2009 (r192345) @@ -2148,7 +2148,7 @@ retry_space: break; } MEXTADD(m0, sf_buf_kva(sf), PAGE_SIZE, sf_buf_mext, - sf, M_RDONLY, EXT_SFBUF); + (void*)sf_buf_kva(sf), sf, M_RDONLY, EXT_SFBUF); m0->m_data = (char *)sf_buf_kva(sf) + pgoff; m0->m_len = xfsize; Modified: user/kmacy/releng_7_2_fcs/sys/pci/if_wb.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/pci/if_wb.c Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/pci/if_wb.c Mon May 18 21:58:21 2009 (r192345) @@ -1036,8 +1036,8 @@ wb_newbuf(sc, c, m) return(ENOBUFS); m_new->m_data = c->wb_buf; m_new->m_pkthdr.len = m_new->m_len = WB_BUFBYTES; - MEXTADD(m_new, c->wb_buf, WB_BUFBYTES, wb_bfree, NULL, 0, - EXT_NET_DRV); + MEXTADD(m_new, c->wb_buf, WB_BUFBYTES, wb_bfree, c->wb_buf, + NULL, 0, EXT_NET_DRV); } else { m_new = m; m_new->m_len = m_new->m_pkthdr.len = WB_BUFBYTES; Modified: user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h Mon May 18 21:57:28 2009 (r192344) +++ user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h Mon May 18 21:58:21 2009 (r192345) @@ -134,7 +134,8 @@ struct m_ext { caddr_t ext_buf; /* start of buffer */ void (*ext_free) /* free routine if not the usual */ (void *, void *); - void *ext_args; /* optional argument pointer */ + void *ext_arg1; /* optional argument pointer */ + void *ext_arg2; /* optional argument pointer */ u_int ext_size; /* size of buffer, for ext_free */ volatile u_int *ref_cnt; /* pointer to ref count info */ int ext_type; /* type of external storage */ @@ -597,7 +598,7 @@ m_cljset(struct mbuf *m, void *cl, int t } m->m_data = m->m_ext.ext_buf = cl; - m->m_ext.ext_free = m->m_ext.ext_args; + m->m_ext.ext_free = m->m_ext.ext_arg1 = m->m_ext.ext_arg2 = NULL; m->m_ext.ext_size = size; m->m_ext.ext_type = type; m->m_ext.ref_cnt = uma_find_refcnt(zone, cl); @@ -629,8 +630,8 @@ m_last(struct mbuf *m) #define MGET(m, how, type) ((m) = m_get((how), (type))) #define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type))) #define MCLGET(m, how) m_clget((m), (how)) -#define MEXTADD(m, buf, size, free, args, flags, type) \ - m_extadd((m), (caddr_t)(buf), (size), (free),(args),(flags), (type)) +#define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \ + m_extadd((m), (caddr_t)(buf), (size), (free),(arg1),(arg2),(flags), (type)) #define m_getm(m, len, how, type) \ m_getm2((m), (len), (how), (type), M_PKTHDR) @@ -756,7 +757,7 @@ int m_apply(struct mbuf *, int, int, int m_append(struct mbuf *, int, c_caddr_t); void m_cat(struct mbuf *, struct mbuf *); void m_extadd(struct mbuf *, caddr_t, u_int, - void (*)(void *, void *), void *, int, int); + void (*)(void *, void *), void *, void *, int, int); struct mbuf *m_collapse(struct mbuf *, int, int); void m_copyback(struct mbuf *, int, int, c_caddr_t); void m_copydata(const struct mbuf *, int, int, caddr_t); From owner-svn-src-user@FreeBSD.ORG Mon May 18 22:54:47 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB8A0106566B; Mon, 18 May 2009 22:54:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A75548FC0C; Mon, 18 May 2009 22:54:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4IMslKK077670; Mon, 18 May 2009 22:54:47 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4IMslGT077662; Mon, 18 May 2009 22:54:47 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905182254.n4IMslGT077662@svn.freebsd.org> From: Kip Macy Date: Mon, 18 May 2009 22:54:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192354 - in user/kmacy/releng_7_2_fcs/sys: dev/cxgb dev/cxgb/sys dev/ti dev/vx kern net netgraph netinet nfsclient nfsserver sys vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 22:54:48 -0000 Author: kmacy Date: Mon May 18 22:54:47 2009 New Revision: 192354 URL: http://svn.freebsd.org/changeset/base/192354 Log: merge 191958 - Merge in changes from jeff_mbuf with one addition. - In m_refm() make all referenced data available in the ext area for compatibility with existing code that makes assumptions about referenced sizes. also fix cxgb compile Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/uipc_mvec.c user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c user/kmacy/releng_7_2_fcs/sys/dev/vx/if_vx.c user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf2.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c user/kmacy/releng_7_2_fcs/sys/net/if_gre.c user/kmacy/releng_7_2_fcs/sys/netgraph/ng_tty.c user/kmacy/releng_7_2_fcs/sys/netinet/ip_options.c user/kmacy/releng_7_2_fcs/sys/netinet/sctp_os_bsd.h user/kmacy/releng_7_2_fcs/sys/nfsclient/nfsm_subs.h user/kmacy/releng_7_2_fcs/sys/nfsserver/nfsm_subs.h user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h user/kmacy/releng_7_2_fcs/sys/sys/sockbuf.h user/kmacy/releng_7_2_fcs/sys/vm/uma.h user/kmacy/releng_7_2_fcs/sys/vm/uma_core.c user/kmacy/releng_7_2_fcs/sys/vm/uma_dbg.c user/kmacy/releng_7_2_fcs/sys/vm/uma_int.h Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c Mon May 18 22:46:59 2009 (r192353) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c Mon May 18 22:54:47 2009 (r192354) @@ -517,7 +517,7 @@ refill_fl(adapter_t *sc, struct sge_fl * struct refill_fl_cb_arg cb_arg; caddr_t cl; int err, count = 0; - int header_size = sizeof(struct m_hdr) + sizeof(struct pkthdr) + sizeof(struct m_ext_) + sizeof(uint32_t); + int header_size = sizeof(struct mbuf) + sizeof(uint32_t); cb_arg.error = 0; while (n--) { @@ -2362,7 +2362,7 @@ t3_sge_alloc_qset(adapter_t *sc, u_int i q->rspq.size = p->rspq_size; - header_size = sizeof(struct m_hdr) + sizeof(struct pkthdr) + sizeof(struct m_ext_) + sizeof(uint32_t); + header_size = sizeof(struct mbuf) + sizeof(uint32_t); q->txq[TXQ_ETH].stop_thres = nports * flits_to_desc(sgl_len(TX_MAX_SEGS + 1) + 3); @@ -2537,26 +2537,15 @@ init_cluster_mbuf(caddr_t cl, int flags, struct mbuf *m; int header_size; - header_size = sizeof(struct m_hdr) + sizeof(struct pkthdr) + - sizeof(struct m_ext_) + sizeof(uint32_t); - + header_size = sizeof(struct mbuf); bzero(cl, header_size); m = (struct mbuf *)cl; cxgb_ext_inited++; SLIST_INIT(&m->m_pkthdr.tags); - m->m_type = MT_DATA; - m->m_flags = flags | M_NOFREE | M_EXT; - m->m_data = cl + header_size; - m->m_ext.ext_buf = cl; - m->m_ext.ref_cnt = (uint32_t *)(cl + header_size - sizeof(uint32_t)); - m->m_ext.ext_size = m_getsizefromtype(type); - m->m_ext.ext_free = ext_free_handler; - m->m_ext.ext_arg1 = cl; - m->m_ext.ext_arg2 = (void *)(uintptr_t)type; - m->m_ext.ext_type = EXT_EXTREF; - *(m->m_ext.ref_cnt) = 1; - DPRINTF("data=%p ref_cnt=%p\n", m->m_data, m->m_ext.ref_cnt); + m_extadd(m, cl + header_size, + m_getsizefromtype(type), ext_free_handler, cl, NULL, + flags | M_NOFREE | M_EXT, EXT_NET_DRV); } Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h Mon May 18 22:46:59 2009 (r192353) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/mvec.h Mon May 18 22:54:47 2009 (r192354) @@ -113,9 +113,9 @@ struct mbuf_iovec { #define MIOVBYTES 512 #define MAX_MBUF_IOV ((MHLEN-8)/sizeof(struct mbuf_iovec)) -#define MAX_MIOVEC_IOV ((MIOVBYTES-sizeof(struct m_hdr)-sizeof(struct pkthdr)-8)/sizeof(struct mbuf_iovec)) -#define MAX_CL_IOV ((MCLBYTES-sizeof(struct m_hdr)-sizeof(struct pkthdr)-8)/sizeof(struct mbuf_iovec)) -#define MAX_PAGE_IOV ((MJUMPAGESIZE-sizeof(struct m_hdr)-sizeof(struct pkthdr)-8)/sizeof(struct mbuf_iovec)) +#define MAX_MIOVEC_IOV ((MIOVBYTES-MBUF_HEADER_SIZE-sizeof(struct pkthdr)-8)/sizeof(struct mbuf_iovec)) +#define MAX_CL_IOV ((MCLBYTES-MBUF_HEADER_SIZE-sizeof(struct pkthdr)-8)/sizeof(struct mbuf_iovec)) +#define MAX_PAGE_IOV ((MJUMPAGESIZE-MBUF_HEADER_SIZE-sizeof(struct pkthdr)-8)/sizeof(struct mbuf_iovec)) struct mbuf_vec { uint16_t mv_first; /* first valid cluster */ @@ -250,7 +250,7 @@ m_freem_iovec(struct mbuf_iovec *mi) KASSERT((mi->mi_flags & M_NOFREE) == 0, ("no free set on mbuf")); KASSERT(m->m_next == NULL, ("freeing chain")); cxgb_mbufs_outstanding--; - m_free_fast(m); + m_free_fast(zone_mbuf, m); break; case EXT_PACKET: cxgb_pack_outstanding--; @@ -270,7 +270,6 @@ m_freem_iovec(struct mbuf_iovec *mi) case EXT_NET_DRV: case EXT_MOD_TYPE: case EXT_DISPOSABLE: - case EXT_EXTREF: mb_free_ext_fast(mi, mi->mi_type, -1); break; default: Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/uipc_mvec.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/uipc_mvec.c Mon May 18 22:46:59 2009 (r192353) +++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/sys/uipc_mvec.c Mon May 18 22:54:47 2009 (r192354) @@ -147,7 +147,6 @@ _mcl_collapse_mbuf(struct mbuf_iovec *mi mi->mi_base = m->m_ext.ext_buf; mi->mi_type = m->m_ext.ext_type; mi->mi_size = m->m_ext.ext_size; - mi->mi_refcnt = m->m_ext.ref_cnt; if (m->m_ext.ext_type == EXT_PACKET) { mi->mi_mbuf = m; #ifdef INVARIANTS @@ -256,7 +255,7 @@ retry: goto err_out; } - memcpy(m0, *m, sizeof(struct m_hdr) + sizeof(struct pkthdr)); + memcpy(m0, *m, MBUF_HEADER_SIZE + sizeof(struct pkthdr)); m0->m_type = type; KASSERT(m0->m_pkthdr.len, ("empty packet being marshalled")); mv = mtomv(m0); @@ -313,8 +312,7 @@ busdma_map_sg_vec(struct mbuf **m, struc if ((m0 = mcl_alloc(pkt_count, &type)) == NULL) return (ENOMEM); - memcpy(m0, *m, sizeof(struct m_hdr) + - sizeof(struct pkthdr)); + memcpy(m0, *m, MBUF_HEADER_SIZE + sizeof(struct pkthdr)); m0->m_type = type; mv = mtomv(m0); mv->mv_count = pkt_count; @@ -357,7 +355,7 @@ mb_free_ext_fast(struct mbuf_iovec *mi, #ifdef INVARIANTS cxgb_mbufs_outstanding--; #endif - m_free_fast((struct mbuf *)cl); + m_free_fast(zone_mbuf, (struct mbuf *)cl); return; default: break; @@ -391,10 +389,6 @@ mb_free_ext_fast(struct mbuf_iovec *mi, case EXT_MOD_TYPE: case EXT_DISPOSABLE: *(mi->mi_refcnt) = 0; - uma_zfree(zone_ext_refcnt, __DEVOLATILE(u_int *, - mi->mi_ext.ref_cnt)); - /* FALLTHROUGH */ - case EXT_EXTREF: KASSERT(mi->mi_ext.ext_free != NULL, ("%s: ext_free not set", __func__)); #if __FreeBSD_version >= 800016 Modified: user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c Mon May 18 22:46:59 2009 (r192353) +++ user/kmacy/releng_7_2_fcs/sys/dev/ti/if_ti.c Mon May 18 22:54:47 2009 (r192354) @@ -1308,12 +1308,11 @@ ti_newbuf_mini(sc, i, m) if (m_new == NULL) { return (ENOBUFS); } - m_new->m_len = m_new->m_pkthdr.len = MHLEN; } else { m_new = m; - m_new->m_data = m_new->m_pktdat; - m_new->m_len = m_new->m_pkthdr.len = MHLEN; + m_new->m_data = M_START(m); } + m_new->m_len = m_new->m_pkthdr.len = m_new->m_size; m_adj(m_new, ETHER_ALIGN); r = &sc->ti_rdata->ti_rx_mini_ring[i]; Modified: user/kmacy/releng_7_2_fcs/sys/dev/vx/if_vx.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/vx/if_vx.c Mon May 18 22:46:59 2009 (r192353) +++ user/kmacy/releng_7_2_fcs/sys/dev/vx/if_vx.c Mon May 18 22:54:47 2009 (r192354) @@ -825,8 +825,11 @@ vx_get(struct vx_softc *sc, u_int totlen /* Convert one of our saved mbuf's. */ sc->vx_next_mb = (sc->vx_next_mb + 1) % MAX_MBS; m->m_data = m->m_pktdat; - m->m_flags = M_PKTHDR; - bzero(&m->m_pkthdr, sizeof(m->m_pkthdr)); + m->m_flags |= M_PKTHDR; + if (m_pkthdr_init(m, M_NOWAIT)) { + m_free(m); + return NULL; + } } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = totlen; Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c Mon May 18 22:46:59 2009 (r192353) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_mbuf.c Mon May 18 22:54:47 2009 (r192354) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -210,27 +211,24 @@ SYSCTL_STRUCT(_kern_ipc, OID_AUTO, mbsta /* * Zones from which we allocate. */ -uma_zone_t zone_mbuf; uma_zone_t zone_clust; -uma_zone_t zone_pack; uma_zone_t zone_jumbop; uma_zone_t zone_jumbo9; uma_zone_t zone_jumbo16; -uma_zone_t zone_ext_refcnt; +uma_zone_t zone_mbuf; +uma_zone_t zone_pack; /* * Local prototypes. */ -static int mb_ctor_mbuf(void *, int, void *, int); -static int mb_ctor_clust(void *, int, void *, int); -static int mb_ctor_pack(void *, int, void *, int); -static void mb_dtor_mbuf(void *, int, void *); -static void mb_dtor_clust(void *, int, void *); -static void mb_dtor_pack(void *, int, void *); -static int mb_zinit_pack(void *, int, int); -static void mb_zfini_pack(void *, int); - +#ifdef INVARIANTS +static int mb_ctor_pack(void *mem, int size, void *arg, int how); +#endif +static void mb_dtor_pack(void *mem, int size, void *arg); static void mb_reclaim(void *); +static int mb_zinit_pack(void *mem, int size, int how); +static void mb_zfini_pack(void *mem, int size); + static void mbuf_init(void *); static void *mbuf_jumbo_alloc(uma_zone_t, int, u_int8_t *, int); static void mbuf_jumbo_free(void *, int, u_int8_t); @@ -252,73 +250,66 @@ mbuf_init(void *dummy) * Configure UMA zones for Mbufs, Clusters, and Packets. */ zone_mbuf = uma_zcreate(MBUF_MEM_NAME, MSIZE, - mb_ctor_mbuf, mb_dtor_mbuf, #ifdef INVARIANTS - trash_init, trash_fini, + trash_ctor, trash_dtor, trash_init, trash_fini, #else - NULL, NULL, + NULL, NULL, NULL, NULL, #endif MSIZE - 1, UMA_ZONE_MAXBUCKET); zone_clust = uma_zcreate(MBUF_CLUSTER_MEM_NAME, MCLBYTES, - mb_ctor_clust, mb_dtor_clust, #ifdef INVARIANTS - trash_init, trash_fini, + trash_ctor, trash_dtor, trash_init, trash_fini, #else - NULL, NULL, + NULL, NULL, NULL, NULL, #endif - UMA_ALIGN_PTR, UMA_ZONE_REFCNT); + UMA_ALIGN_PTR, UMA_ZONE_MAXBUCKET); if (nmbclusters > 0) uma_zone_set_max(zone_clust, nmbclusters); - zone_pack = uma_zsecond_create(MBUF_PACKET_MEM_NAME, mb_ctor_pack, + zone_pack = uma_zsecond_create(MBUF_PACKET_MEM_NAME, +#ifdef INVARIANTS + mb_ctor_pack, +#else + NULL, +#endif mb_dtor_pack, mb_zinit_pack, mb_zfini_pack, zone_mbuf); /* Make jumbo frame zone too. Page size, 9k and 16k. */ zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE, - mb_ctor_clust, mb_dtor_clust, #ifdef INVARIANTS - trash_init, trash_fini, + trash_ctor, trash_dtor, trash_init, trash_fini, #else - NULL, NULL, + NULL, NULL, NULL, NULL, #endif - UMA_ALIGN_PTR, UMA_ZONE_REFCNT); + UMA_ALIGN_PTR, 0); if (nmbjumbop > 0) uma_zone_set_max(zone_jumbop, nmbjumbop); zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES, - mb_ctor_clust, mb_dtor_clust, #ifdef INVARIANTS - trash_init, trash_fini, + trash_ctor, trash_dtor, trash_init, trash_fini, #else - NULL, NULL, + NULL, NULL, NULL, NULL, #endif - UMA_ALIGN_PTR, UMA_ZONE_REFCNT); + UMA_ALIGN_PTR, 0); if (nmbjumbo9 > 0) uma_zone_set_max(zone_jumbo9, nmbjumbo9); uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc); uma_zone_set_freef(zone_jumbo9, mbuf_jumbo_free); zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES, - mb_ctor_clust, mb_dtor_clust, #ifdef INVARIANTS - trash_init, trash_fini, + trash_ctor, trash_dtor, trash_init, trash_fini, #else - NULL, NULL, + NULL, NULL, NULL, NULL, #endif - UMA_ALIGN_PTR, UMA_ZONE_REFCNT); + UMA_ALIGN_PTR, 0); if (nmbjumbo16 > 0) uma_zone_set_max(zone_jumbo16, nmbjumbo16); uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc); uma_zone_set_freef(zone_jumbo16, mbuf_jumbo_free); - zone_ext_refcnt = uma_zcreate(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int), - NULL, NULL, - NULL, NULL, - UMA_ALIGN_PTR, UMA_ZONE_ZINIT); - - /* uma_prealloc() goes here... */ - /* * Hook event handler for low-memory situation, used to * drain protocols and push data back to the caches (UMA @@ -373,85 +364,18 @@ mbuf_jumbo_free(void *mem, int size, u_i contigfree(mem, size, M_JUMBOFRAME); } -/* - * Constructor for Mbuf master zone. - * - * The 'arg' pointer points to a mb_args structure which - * contains call-specific information required to support the - * mbuf allocation API. See mbuf.h. - */ +#ifdef INVARIANTS static int -mb_ctor_mbuf(void *mem, int size, void *arg, int how) +mb_ctor_pack(void *mem, int size, void *arg, int how) { struct mbuf *m; - struct mb_args *args; -#ifdef MAC - int error; -#endif - int flags; - short type; -#ifdef INVARIANTS - trash_ctor(mem, size, arg, how); -#endif m = (struct mbuf *)mem; - args = (struct mb_args *)arg; - flags = args->flags; - type = args->type; - - /* - * The mbuf is initialized later. The caller has the - * responsibility to set up any MAC labels too. - */ - if (type == MT_NOINIT) - return (0); + trash_ctor(m->m_ext.ext_buf, MCLBYTES, arg, how); - m->m_next = NULL; - m->m_nextpkt = NULL; - m->m_len = 0; - m->m_flags = flags; - m->m_type = type; - if (flags & M_PKTHDR) { - m->m_data = m->m_pktdat; - m->m_pkthdr.rcvif = NULL; - m->m_pkthdr.len = 0; - m->m_pkthdr.header = NULL; - m->m_pkthdr.csum_flags = 0; - m->m_pkthdr.csum_data = 0; - m->m_pkthdr.tso_segsz = 0; - m->m_pkthdr.ether_vtag = 0; - SLIST_INIT(&m->m_pkthdr.tags); -#ifdef MAC - /* If the label init fails, fail the alloc */ - error = mac_init_mbuf(m, how); - if (error) - return (error); -#endif - } else - m->m_data = m->m_dat; return (0); } - -/* - * The Mbuf master zone destructor. - */ -static void -mb_dtor_mbuf(void *mem, int size, void *arg) -{ - struct mbuf *m; - unsigned long flags; - - m = (struct mbuf *)mem; - flags = (unsigned long)arg; - - if ((flags & MB_NOTAGS) == 0 && (m->m_flags & M_PKTHDR) != 0) - m_tag_delete_chain(m, NULL); - KASSERT((m->m_flags & M_EXT) == 0, ("%s: M_EXT set", __func__)); - KASSERT((m->m_flags & M_NOFREE) == 0, ("%s: M_NOFREE set", __func__)); -#ifdef INVARIANTS - trash_dtor(mem, size, arg); #endif -} /* * The Mbuf Packet zone destructor. @@ -462,21 +386,21 @@ mb_dtor_pack(void *mem, int size, void * struct mbuf *m; m = (struct mbuf *)mem; - if ((m->m_flags & M_PKTHDR) != 0) - m_tag_delete_chain(m, NULL); - /* Make sure we've got a clean cluster back. */ KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__)); KASSERT(m->m_ext.ext_buf != NULL, ("%s: ext_buf == NULL", __func__)); - KASSERT(m->m_ext.ext_free == NULL, ("%s: ext_free != NULL", __func__)); + KASSERT(m->m_ext.ext_free == m_ext_free_nop, + ("%s: ext_free != m_ext_free_nop", __func__)); KASSERT(m->m_ext.ext_arg1 == NULL, ("%s: ext_arg1 != NULL", __func__)); KASSERT(m->m_ext.ext_arg2 == NULL, ("%s: ext_arg2 != NULL", __func__)); - KASSERT(m->m_ext.ext_size == MCLBYTES, ("%s: ext_size != MCLBYTES", __func__)); - KASSERT(m->m_ext.ext_type == EXT_PACKET, ("%s: ext_type != EXT_PACKET", __func__)); - KASSERT(*m->m_ext.ref_cnt == 1, ("%s: ref_cnt != 1", __func__)); -#ifdef INVARIANTS + KASSERT(m->m_ext.ext_size == MCLBYTES, ("%s: ext_size != MCLBYTES", + __func__)); + KASSERT(m->m_ext.ext_type == EXT_PACKET, ("%s: ext_type != EXT_PACKET", + __func__)); +#ifdef INVARIANTS trash_dtor(m->m_ext.ext_buf, MCLBYTES, arg); #endif + /* * If there are processes blocked on zone_clust, waiting for pages to be freed up, * cause them to be woken up by draining the packet zone. We are exposed to a race here @@ -488,85 +412,6 @@ mb_dtor_pack(void *mem, int size, void * } /* - * The Cluster and Jumbo[PAGESIZE|9|16] zone constructor. - * - * Here the 'arg' pointer points to the Mbuf which we - * are configuring cluster storage for. If 'arg' is - * empty we allocate just the cluster without setting - * the mbuf to it. See mbuf.h. - */ -static int -mb_ctor_clust(void *mem, int size, void *arg, int how) -{ - struct mbuf *m; - u_int *refcnt; - int type; - uma_zone_t zone; - -#ifdef INVARIANTS - trash_ctor(mem, size, arg, how); -#endif - switch (size) { - case MCLBYTES: - type = EXT_CLUSTER; - zone = zone_clust; - break; -#if MJUMPAGESIZE != MCLBYTES - case MJUMPAGESIZE: - type = EXT_JUMBOP; - zone = zone_jumbop; - break; -#endif - case MJUM9BYTES: - type = EXT_JUMBO9; - zone = zone_jumbo9; - break; - case MJUM16BYTES: - type = EXT_JUMBO16; - zone = zone_jumbo16; - break; - default: - panic("unknown cluster size"); - break; - } - - m = (struct mbuf *)arg; - refcnt = uma_find_refcnt(zone, mem); - *refcnt = 1; - if (m != NULL) { - m->m_ext.ext_buf = (caddr_t)mem; - m->m_data = m->m_ext.ext_buf; - m->m_flags |= M_EXT; - m->m_ext.ext_free = NULL; - m->m_ext.ext_arg1 = NULL; - m->m_ext.ext_arg2 = NULL; - m->m_ext.ext_size = size; - m->m_ext.ext_type = type; - m->m_ext.ref_cnt = refcnt; - } - - return (0); -} - -/* - * The Mbuf Cluster zone destructor. - */ -static void -mb_dtor_clust(void *mem, int size, void *arg) -{ -#ifdef INVARIANTS - uma_zone_t zone; - - zone = m_getzone(size); - KASSERT(*(uma_find_refcnt(zone, mem)) <= 1, - ("%s: refcnt incorrect %u", __func__, - *(uma_find_refcnt(zone, mem))) ); - - trash_dtor(mem, size, arg); -#endif -} - -/* * The Packet secondary zone's init routine, executed on the * object's transition from mbuf keg slab to zone cache. */ @@ -576,13 +421,16 @@ mb_zinit_pack(void *mem, int size, int h struct mbuf *m; m = (struct mbuf *)mem; /* m is virgin. */ - if (uma_zalloc_arg(zone_clust, m, how) == NULL || - m->m_ext.ext_buf == NULL) + /* + * Allocate and attach the cluster to the ext. + */ + if ((mem = uma_zalloc(zone_clust, how)) == NULL) return (ENOMEM); - m->m_ext.ext_type = EXT_PACKET; /* Override. */ + m_extadd(m, mem, MCLBYTES, m_ext_free_nop, NULL, NULL, 0, EXT_PACKET); #ifdef INVARIANTS - trash_init(m->m_ext.ext_buf, MCLBYTES, how); + return trash_init(m->m_ext.ext_buf, MCLBYTES, how); #endif + return (0); } @@ -605,56 +453,33 @@ mb_zfini_pack(void *mem, int size) #endif } -/* - * The "packet" keg constructor. - */ -static int -mb_ctor_pack(void *mem, int size, void *arg, int how) +int +m_pkthdr_init(struct mbuf *m, int how) { - struct mbuf *m; - struct mb_args *args; #ifdef MAC int error; #endif - int flags; - short type; - - m = (struct mbuf *)mem; - args = (struct mb_args *)arg; - flags = args->flags; - type = args->type; - -#ifdef INVARIANTS - trash_ctor(m->m_ext.ext_buf, MCLBYTES, arg, how); -#endif - m->m_next = NULL; - m->m_nextpkt = NULL; - m->m_data = m->m_ext.ext_buf; - m->m_len = 0; - m->m_flags = (flags | M_EXT); - m->m_type = type; - - if (flags & M_PKTHDR) { - m->m_pkthdr.rcvif = NULL; - m->m_pkthdr.len = 0; - m->m_pkthdr.header = NULL; - m->m_pkthdr.csum_flags = 0; - m->m_pkthdr.csum_data = 0; - m->m_pkthdr.tso_segsz = 0; - m->m_pkthdr.ether_vtag = 0; - SLIST_INIT(&m->m_pkthdr.tags); + m->m_data = m->m_pktdat; + SLIST_INIT(&m->m_pkthdr.tags); + m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.header = NULL; + m->m_pkthdr.len = 0; + m->m_pkthdr.flowid = 0; + m->m_pkthdr.csum_flags = 0; + m->m_pkthdr.csum_data = 0; + m->m_pkthdr.tso_segsz = 0; + m->m_pkthdr.ether_vtag = 0; #ifdef MAC - /* If the label init fails, fail the alloc */ - error = mac_init_mbuf(m, how); - if (error) - return (error); + /* If the label init fails, fail the alloc */ + error = mac_mbuf_init(m, how); + if (error) + return (error); #endif - } - /* m_ext is already initialized. */ return (0); } + /* * This is the protocol drain routine. * @@ -676,3 +501,45 @@ mb_reclaim(void *junk) if (pr->pr_drain != NULL) (*pr->pr_drain)(); } + +struct mbuf * +_m_getjcl(int how, short type, int flags, int size, uma_zone_t zone, + int exttype) +{ + struct mbuf *m; + void *mem; + + if (size == MCLBYTES) + return m_getcl(how, type, flags); + /* + * Allocate the memory and header seperate for these sizes. + */ + mem = uma_zalloc(zone, how); + if (mem == NULL) + return (NULL); + m = m_alloc(zone_mbuf, 0, how, type, flags); + if (m == NULL) { + uma_zfree(zone, mem); + return (NULL); + } + m_extadd(m, mem, size, m_ext_free_zone, zone, mem, flags, exttype); + + return (m); +} + +void * +_m_cljget(struct mbuf *m, int how, int size, uma_zone_t zone, int exttype) +{ + void *mem; + + if (m && m->m_flags & M_EXT) + printf("%s: %p mbuf already has cluster\n", __func__, m); + if (m != NULL) + m->m_ext.ext_buf = NULL; + mem = uma_zalloc(zone, how); + if (mem == NULL) + return (NULL); + if (m) + m_extadd(m, mem, size, m_ext_free_zone, zone, mem, 0, exttype); + return (mem); +} Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c Mon May 18 22:46:59 2009 (r192353) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c Mon May 18 22:54:47 2009 (r192354) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -86,6 +87,8 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, m_defrag &m_defragrandomfailures, 0, ""); #endif +static void m_refm(struct mbuf *mb, struct mbuf *m); + /* * Allocate a given length worth of mbufs and/or clusters (whatever fits * best) and return a pointer to the top of the allocated chain. If an @@ -127,8 +130,7 @@ m_getm2(struct mbuf *m, int len, int how } /* Book keeping. */ - len -= (mb->m_flags & M_EXT) ? mb->m_ext.ext_size : - ((mb->m_flags & M_PKTHDR) ? MHLEN : MLEN); + len -= mb->m_size; if (mtail != NULL) mtail->m_next = mb; else @@ -163,147 +165,63 @@ m_freem(struct mbuf *mb) mb = m_free(mb); } -/*- - * Configure a provided mbuf to refer to the provided external storage - * buffer and setup a reference count for said buffer. If the setting - * up of the reference count fails, the M_EXT bit will not be set. If - * successfull, the M_EXT bit is set in the mbuf's flags. - * - * Arguments: - * mb The existing mbuf to which to attach the provided buffer. - * buf The address of the provided external storage buffer. - * size The size of the provided buffer. - * freef A pointer to a routine that is responsible for freeing the - * provided external storage buffer. - * args A pointer to an argument structure (of any type) to be passed - * to the provided freef routine (may be NULL). - * flags Any other flags to be passed to the provided mbuf. - * type The type that the external storage buffer should be - * labeled with. - * - * Returns: - * Nothing. +/* + * Reference the existing storage area of an mbuf. The reference is readonly + * and the referenced data can not be freed until the referencing mbuf is + * freed. */ -void -m_extadd(struct mbuf *mb, caddr_t buf, u_int size, - void (*freef)(void *, void *), void *arg1, void *arg2, int flags, int type) +static void +m_refm(struct mbuf *mb, struct mbuf *m) { - KASSERT(type != EXT_CLUSTER, ("%s: EXT_CLUSTER not allowed", __func__)); - if (type != EXT_EXTREF) - mb->m_ext.ref_cnt = (u_int *)uma_zalloc(zone_ext_refcnt, M_NOWAIT); - if (mb->m_ext.ref_cnt != NULL) { - *(mb->m_ext.ref_cnt) = 1; - mb->m_flags |= (M_EXT | flags); - mb->m_ext.ext_buf = buf; - mb->m_data = mb->m_ext.ext_buf; - mb->m_ext.ext_size = size; - mb->m_ext.ext_free = freef; - mb->m_ext.ext_arg1 = arg1; - mb->m_ext.ext_arg2 = arg2; - mb->m_ext.ext_type = type; - } + if (m->m_ref > 1) + atomic_add_int(&m->m_ref, 1); + else + m->m_ref++; + mb->m_flags |= M_EXT | M_RDONLY; + mb->m_data = m->m_data; + mb->m_size = m->m_size; + mb->m_ext.ext_buf = M_START(m); + mb->m_ext.ext_size = m->m_size; + mb->m_ext.ext_free = m_ext_free_mbuf; + mb->m_ext.ext_arg1 = m; + mb->m_ext.ext_arg2 = NULL; + mb->m_ext.ext_type = EXT_MBUF; + + CTR3(KTR_NET, "m_refm: %p ref %d buf %p", + mb, mb->m_ref, mb->m_ext.ext_buf); } /* - * Non-directly-exported function to clean up after mbufs with M_EXT - * storage attached to them if the reference count hits 1. + * Free the ext area of a mbuf assuming a uma zone and argument are + * presented. */ void -mb_free_ext(struct mbuf *m) +m_ext_free_zone(void *arg1, void *arg2) { - int skipmbuf; - - KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__)); - KASSERT(m->m_ext.ref_cnt != NULL, ("%s: ref_cnt not set", __func__)); + uma_zfree(arg1, arg2); +} + +/* + * Free the ext area of a mbuf assuming it has been acquired with m_refm(). + */ +void +m_ext_free_mbuf(void *arg1, void *arg2) +{ /* - * check if the header is embedded in the cluster - */ - skipmbuf = (m->m_flags & M_NOFREE); - - /* Free attached storage if this mbuf is the only reference to it. */ - if (*(m->m_ext.ref_cnt) == 1 || - atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) { - switch (m->m_ext.ext_type) { - case EXT_PACKET: /* The packet zone is special. */ - if (*(m->m_ext.ref_cnt) == 0) - *(m->m_ext.ref_cnt) = 1; - uma_zfree(zone_pack, m); - return; /* Job done. */ - case EXT_CLUSTER: - uma_zfree(zone_clust, m->m_ext.ext_buf); - break; - case EXT_JUMBOP: - uma_zfree(zone_jumbop, m->m_ext.ext_buf); - break; - case EXT_JUMBO9: - uma_zfree(zone_jumbo9, m->m_ext.ext_buf); - break; - case EXT_JUMBO16: - uma_zfree(zone_jumbo16, m->m_ext.ext_buf); - break; - case EXT_SFBUF: - case EXT_NET_DRV: - case EXT_MOD_TYPE: - case EXT_DISPOSABLE: - *(m->m_ext.ref_cnt) = 0; - uma_zfree(zone_ext_refcnt, __DEVOLATILE(u_int *, - m->m_ext.ref_cnt)); - /* FALLTHROUGH */ - case EXT_EXTREF: - KASSERT(m->m_ext.ext_free != NULL, - ("%s: ext_free not set", __func__)); - (*(m->m_ext.ext_free))(m->m_ext.ext_arg1, - m->m_ext.ext_arg2); - break; - default: - KASSERT(m->m_ext.ext_type == 0, - ("%s: unknown ext_type", __func__)); - } - } - if (skipmbuf) - return; - - /* - * Free this mbuf back to the mbuf zone with all m_ext - * information purged. + * Release one more reference to this mbuf. If it is the last it + * will be freed. */ - m->m_ext.ext_buf = NULL; - m->m_ext.ext_free = NULL; - m->m_ext.ext_arg1 = NULL; - m->m_ext.ext_arg2 = NULL; - m->m_ext.ref_cnt = NULL; - m->m_ext.ext_size = 0; - m->m_ext.ext_type = 0; - m->m_flags &= ~M_EXT; - uma_zfree(zone_mbuf, m); + m_free(arg1); } -/* - * Attach the the cluster from *m to *n, set up m_ext in *n - * and bump the refcount of the cluster. - */ -static void -mb_dupcl(struct mbuf *n, struct mbuf *m) +void +m_ext_free_nop(void *arg1, void *arg2) { - KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__)); - KASSERT(m->m_ext.ref_cnt != NULL, ("%s: ref_cnt not set", __func__)); - KASSERT((n->m_flags & M_EXT) == 0, ("%s: M_EXT set", __func__)); - if (*(m->m_ext.ref_cnt) == 1) - *(m->m_ext.ref_cnt) += 1; - else - atomic_add_int(m->m_ext.ref_cnt, 1); - n->m_ext.ext_buf = m->m_ext.ext_buf; - n->m_ext.ext_free = m->m_ext.ext_free; - n->m_ext.ext_arg1 = m->m_ext.ext_arg1; - n->m_ext.ext_arg2 = m->m_ext.ext_arg2; - n->m_ext.ext_size = m->m_ext.ext_size; - n->m_ext.ref_cnt = m->m_ext.ref_cnt; - n->m_ext.ext_type = m->m_ext.ext_type; - n->m_flags |= M_EXT; + /* Nothing to do. */ } /* @@ -356,11 +274,8 @@ m_sanity(struct mbuf *m0, int sanitize) * unrelated kernel memory before or after us is trashed. * No way to recover from that. */ - a = ((m->m_flags & M_EXT) ? m->m_ext.ext_buf : - ((m->m_flags & M_PKTHDR) ? (caddr_t)(&m->m_pktdat) : - (caddr_t)(&m->m_dat)) ); - b = (caddr_t)(a + (m->m_flags & M_EXT ? m->m_ext.ext_size : - ((m->m_flags & M_PKTHDR) ? MHLEN : MLEN))); + a = M_START(m); + b = (caddr_t)(a + m->m_size); if ((caddr_t)m->m_data < a) M_SANITY_ACTION("m_data outside mbuf data range left"); if ((caddr_t)m->m_data > b) @@ -531,6 +446,7 @@ m_copym(struct mbuf *m, int off0, int le struct mbuf *top; int copyhdr = 0; + CTR3(KTR_NET, "m_copym(%p, %d, %d)", m, off0, len); KASSERT(off >= 0, ("m_copym, negative off %d", off)); KASSERT(len >= 0, ("m_copym, negative len %d", len)); MBUF_CHECKSLEEP(wait); @@ -567,13 +483,16 @@ m_copym(struct mbuf *m, int off0, int le n->m_pkthdr.len = len; copyhdr = 0; } + /* + * If the copied data will fit in the space of standard + * mbuf prefer to copy rather than reference. + */ n->m_len = min(len, m->m_len - off); - if (m->m_flags & M_EXT) { - n->m_data = m->m_data + off; - mb_dupcl(n, m); + if (n->m_len > n->m_size) { + m_refm(n, m); + n->m_data += off; } else - bcopy(mtod(m, caddr_t)+off, mtod(n, caddr_t), - (u_int)n->m_len); + bcopy(mtod(m, caddr_t)+off, mtod(n, caddr_t), n->m_len); if (len != M_COPYALL) len -= n->m_len; off = 0; @@ -751,7 +670,9 @@ struct mbuf * m_copypacket(struct mbuf *m, int how) { struct mbuf *top, *n, *o; + int leading; + CTR1(KTR_NET, "m_copypacket(%p)", m); MBUF_CHECKSLEEP(how); MGET(n, how, m->m_type); top = n; @@ -761,13 +682,10 @@ m_copypacket(struct mbuf *m, int how) if (!m_dup_pkthdr(n, m, how)) goto nospace; n->m_len = m->m_len; - if (m->m_flags & M_EXT) { - n->m_data = m->m_data; - mb_dupcl(n, m); - } else { - n->m_data = n->m_pktdat + (m->m_data - m->m_pktdat ); - bcopy(mtod(m, char *), mtod(n, char *), n->m_len); - } + if (n->m_len > n->m_size) + m_refm(n, m); + else + bcopy(mtod(m, caddr_t), mtod(n, caddr_t), m->m_len); m = m->m_next; while (m) { @@ -779,13 +697,13 @@ m_copypacket(struct mbuf *m, int how) n = n->m_next; n->m_len = m->m_len; - if (m->m_flags & M_EXT) { - n->m_data = m->m_data; - mb_dupcl(n, m); + leading = M_LEADINGSPACE(m); + if (n->m_len + leading > n->m_size) { + m_refm(n, m); } else { - bcopy(mtod(m, char *), mtod(n, char *), n->m_len); + n->m_data = M_START(n) + leading; + bcopy(mtod(m, caddr_t), mtod(n, caddr_t), n->m_len); } - m = m->m_next; } return top; @@ -804,6 +722,7 @@ m_copydata(const struct mbuf *m, int off { u_int count; + CTR3(KTR_NET, "m_copydata(%p, %d, %d)", m, off, len); KASSERT(off >= 0, ("m_copydata, negative off %d", off)); KASSERT(len >= 0, ("m_copydata, negative len %d", len)); while (off > 0) { @@ -833,8 +752,9 @@ struct mbuf * m_dup(struct mbuf *m, int how) { struct mbuf **p, *top = NULL; - int remain, moff, nsize; + int remain, moff; + CTR1(KTR_NET, "m_dup(%p)", m); MBUF_CHECKSLEEP(how); /* Sanity check */ if (m == NULL) @@ -849,13 +769,10 @@ m_dup(struct mbuf *m, int how) struct mbuf *n; /* Get the next new mbuf */ - if (remain >= MINCLSIZE) { + if (remain >= MINCLSIZE) n = m_getcl(how, m->m_type, 0); - nsize = MCLBYTES; - } else { + else n = m_get(how, m->m_type); - nsize = MLEN; - } if (n == NULL) goto nospace; @@ -864,8 +781,6 @@ m_dup(struct mbuf *m, int how) m_free(n); goto nospace; } - if ((n->m_flags & M_EXT) == 0) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue May 19 00:02:59 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 095BD1065676; Tue, 19 May 2009 00:02:59 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA2C48FC18; Tue, 19 May 2009 00:02:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J02wgf079189; Tue, 19 May 2009 00:02:58 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J02war079181; Tue, 19 May 2009 00:02:58 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190002.n4J02war079181@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 00:02:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192359 - in user/kmacy/releng_7_2_fcs/sys: kern netncp netsmb sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 00:02:59 -0000 Author: kmacy Date: Tue May 19 00:02:58 2009 New Revision: 192359 URL: http://svn.freebsd.org/changeset/base/192359 Log: merge 174647 Refactor select to reduce contention and hide internal implementation details from consumers. - Track individual selecters on a per-descriptor basis such that there are no longer collisions and after sleeping for events only those descriptors which triggered events must be rescaned. - Protect the selinfo (per descriptor) structure with a mtx pool mutex. mtx pool mutexes were chosen to preserve api compatibility with existing code which does nothing but bzero() to setup selinfo structures. - Use a per-thread wait channel rather than a global wait channel. - Hide select implementation details in a seltd structure which is opaque to the rest of the kernel. - Provide a 'selsocket' interface for those kernel consumers who wish to select on a socket when they have no fd so they no longer have to be aware of select implementation details. Tested by: kris Reviewed on: arch Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c user/kmacy/releng_7_2_fcs/sys/netncp/ncp_rq.c user/kmacy/releng_7_2_fcs/sys/netncp/ncp_sock.c user/kmacy/releng_7_2_fcs/sys/netncp/ncp_sock.h user/kmacy/releng_7_2_fcs/sys/netsmb/smb_trantcp.c user/kmacy/releng_7_2_fcs/sys/sys/proc.h user/kmacy/releng_7_2_fcs/sys/sys/selinfo.h user/kmacy/releng_7_2_fcs/sys/sys/socketvar.h user/kmacy/releng_7_2_fcs/sys/sys/systm.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c Mon May 18 23:36:11 2009 (r192358) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c Tue May 19 00:02:58 2009 (r192359) @@ -1460,7 +1460,8 @@ kqueue_poll(struct file *fp, int events, revents |= events & (POLLIN | POLLRDNORM); } else { selrecord(td, &kq->kq_sel); - kq->kq_state |= KQ_SEL; + if (SEL_WAITING(&kq->kq_sel)) + kq->kq_state |= KQ_SEL; } } kqueue_release(kq, 1); @@ -1553,8 +1554,9 @@ kqueue_close(struct file *fp, struct thr } if ((kq->kq_state & KQ_SEL) == KQ_SEL) { - kq->kq_state &= ~KQ_SEL; selwakeuppri(&kq->kq_sel, PSOCK); + if (!SEL_WAITING(&kq->kq_sel)) + kq->kq_state &= ~KQ_SEL; } KQ_UNLOCK(kq); @@ -1589,8 +1591,9 @@ kqueue_wakeup(struct kqueue *kq) wakeup(kq); } if ((kq->kq_state & KQ_SEL) == KQ_SEL) { - kq->kq_state &= ~KQ_SEL; selwakeuppri(&kq->kq_sel, PSOCK); + if (!SEL_WAITING(&kq->kq_sel)) + kq->kq_state &= ~KQ_SEL; } if (!knlist_empty(&kq->kq_sel.si_note)) kqueue_schedtask(kq); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Mon May 18 23:36:11 2009 (r192358) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Tue May 19 00:02:58 2009 (r192359) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -214,6 +215,7 @@ thread_fini(void *mem, int size) turnstile_free(td->td_turnstile); sleepq_free(td->td_sleepqueue); umtx_thread_fini(td); + seltdfini(td); } /* Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Mon May 18 23:36:11 2009 (r192358) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 00:02:58 2009 (r192359) @@ -69,18 +69,60 @@ __FBSDID("$FreeBSD$"); #include #endif +#include + static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer"); static MALLOC_DEFINE(M_SELECT, "select", "select() buffer"); MALLOC_DEFINE(M_IOV, "iov", "large iov's"); static int pollout(struct pollfd *, struct pollfd *, u_int); static int pollscan(struct thread *, struct pollfd *, u_int); +static int pollrescan(struct thread *); static int selscan(struct thread *, fd_mask **, fd_mask **, int); +static int selrescan(struct thread *, fd_mask **, fd_mask **); +static void selfdalloc(struct thread *, void *); +static void selfdfree(struct seltd *, struct selfd *); static int dofileread(struct thread *, int, struct file *, struct uio *, off_t, int); static int dofilewrite(struct thread *, int, struct file *, struct uio *, off_t, int); static void doselwakeup(struct selinfo *, int); +static void seltdinit(struct thread *); +static int seltdwait(struct thread *, int); +static void seltdclear(struct thread *); + +/* + * One seltd per-thread allocated on demand as needed. + * + * t - protected by st_mtx + * k - Only accessed by curthread or read-only + */ +struct seltd { + STAILQ_HEAD(, selfd) st_selq; /* (k) List of selfds. */ + struct selfd *st_free1; /* (k) free fd for read set. */ + struct selfd *st_free2; /* (k) free fd for write set. */ + struct mtx st_mtx; /* Protects struct seltd */ + struct cv st_wait; /* (t) Wait channel. */ + int st_flags; /* (t) SELTD_ flags. */ +}; + +#define SELTD_PENDING 0x0001 /* We have pending events. */ +#define SELTD_RESCAN 0x0002 /* Doing a rescan. */ + +/* + * One selfd allocated per-thread per-file-descriptor. + * f - protected by sf_mtx + */ +struct selfd { + STAILQ_ENTRY(selfd) sf_link; /* (k) fds owned by this td. */ + TAILQ_ENTRY(selfd) sf_threads; /* (f) fds on this selinfo. */ + struct selinfo *sf_si; /* (f) selinfo when linked. */ + struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ + struct seltd *sf_td; /* (k) owning seltd. */ + void *sf_cookie; /* (k) fd or pollfd. */ +}; + +static uma_zone_t selfd_zone; #ifndef _SYS_SYSPROTO_H_ struct read_args { @@ -630,14 +672,6 @@ out: return (error); } -/* - * sellock and selwait are initialized in selectinit() via SYSINIT. - */ -struct mtx sellock; -struct cv selwait; -u_int nselcoll; /* Select collisions since boot */ -SYSCTL_UINT(_kern, OID_AUTO, nselcoll, CTLFLAG_RD, &nselcoll, 0, ""); - int poll_no_poll(int events) { @@ -695,7 +729,7 @@ kern_select(struct thread *td, int nd, f fd_mask *ibits[3], *obits[3], *selbits, *sbp; struct timeval atv, rtv, ttv; int error, timo; - u_int ncoll, nbufbytes, ncpbytes, nfdbits; + u_int nbufbytes, ncpbytes, nfdbits; if (nd < 0) return (EINVAL); @@ -740,7 +774,7 @@ kern_select(struct thread *td, int nd, f sbp += ncpbytes / sizeof *sbp; \ error = copyin(name, ibits[x], ncpbytes); \ if (error != 0) \ - goto done_nosellock; \ + goto done; \ } \ } while (0) getbits(fd_in, 0); @@ -754,7 +788,7 @@ kern_select(struct thread *td, int nd, f atv = *tvp; if (itimerfix(&atv)) { error = EINVAL; - goto done_nosellock; + goto done; } getmicrouptime(&rtv); timevaladd(&atv, &rtv); @@ -763,58 +797,31 @@ kern_select(struct thread *td, int nd, f atv.tv_usec = 0; } timo = 0; - TAILQ_INIT(&td->td_selq); - mtx_lock(&sellock); -retry: - ncoll = nselcoll; - thread_lock(td); - td->td_flags |= TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - - error = selscan(td, ibits, obits, nd); - mtx_lock(&sellock); - if (error || td->td_retval[0]) - goto done; - if (atv.tv_sec || atv.tv_usec) { - getmicrouptime(&rtv); - if (timevalcmp(&rtv, &atv, >=)) - goto done; - ttv = atv; - timevalsub(&ttv, &rtv); - timo = ttv.tv_sec > 24 * 60 * 60 ? - 24 * 60 * 60 * hz : tvtohz(&ttv); - } - - /* - * An event of interest may occur while we do not hold - * sellock, so check TDF_SELECT and the number of - * collisions and rescan the file descriptors if - * necessary. - */ - thread_lock(td); - if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) { - thread_unlock(td); - goto retry; + seltdinit(td); + /* Iterate until the timeout expires or descriptors become ready. */ + for (;;) { + error = selscan(td, ibits, obits, nd); + if (error || td->td_retval[0] != 0) + break; + if (atv.tv_sec || atv.tv_usec) { + getmicrouptime(&rtv); + if (timevalcmp(&rtv, &atv, >=)) + break; + ttv = atv; + timevalsub(&ttv, &rtv); + timo = ttv.tv_sec > 24 * 60 * 60 ? + 24 * 60 * 60 * hz : tvtohz(&ttv); + } + error = seltdwait(td, timo); + if (error) + break; + error = selrescan(td, ibits, obits); + if (error || td->td_retval[0] != 0) + break; } - thread_unlock(td); - - if (timo > 0) - error = cv_timedwait_sig(&selwait, &sellock, timo); - else - error = cv_wait_sig(&selwait, &sellock); - - if (error == 0) - goto retry; + seltdclear(td); done: - clear_selinfo_list(td); - thread_lock(td); - td->td_flags &= ~TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - -done_nosellock: /* select is not restarted after signals... */ if (error == ERESTART) error = EINTR; @@ -837,6 +844,60 @@ done_nosellock: return (error); } +/* + * Traverse the list of fds attached to this thread's seltd and check for + * completion. + */ +static int +selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits) +{ + struct seltd *stp; + struct selfd *sfp; + struct selfd *sfn; + struct selinfo *si; + struct file *fp; + int msk, fd; + int n = 0; + /* Note: backend also returns POLLHUP/POLLERR if appropriate. */ + static int flag[3] = { POLLRDNORM, POLLWRNORM, POLLRDBAND }; + struct filedesc *fdp = td->td_proc->p_fd; + + stp = td->td_sel; + FILEDESC_SLOCK(fdp); + STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) { + fd = (int)(uintptr_t)sfp->sf_cookie; + si = sfp->sf_si; + selfdfree(stp, sfp); + /* If the selinfo wasn't cleared the event didn't fire. */ + if (si != NULL) + continue; + if ((fp = fget_locked(fdp, fd)) == NULL) { + FILEDESC_SUNLOCK(fdp); + return (EBADF); + } + for (msk = 0; msk < 3; msk++) { + if (ibits[msk] == NULL) + continue; + if ((ibits[msk][fd/NFDBITS] & + ((fd_mask) 1 << (fd % NFDBITS))) == 0) + continue; + if (fo_poll(fp, flag[msk], td->td_ucred, td)) { + obits[msk][(fd)/NFDBITS] |= + ((fd_mask)1 << ((fd) % NFDBITS)); + n++; + } + } + } + FILEDESC_SUNLOCK(fdp); + stp->st_flags = 0; + td->td_retval[0] = n; + return (0); +} + +/* + * Perform the initial filedescriptor scan and register ourselves with + * each selinfo. + */ static int selscan(td, ibits, obits, nfd) struct thread *td; @@ -865,6 +926,7 @@ selscan(td, ibits, obits, nfd) FILEDESC_SUNLOCK(fdp); return (EBADF); } + selfdalloc(td, (void *)(uintptr_t)fd); if (fo_poll(fp, flag[msk], td->td_ucred, td)) { obits[msk][(fd)/NFDBITS] |= @@ -895,7 +957,7 @@ poll(td, uap) struct pollfd smallbits[32]; struct timeval atv, rtv, ttv; int error = 0, timo; - u_int ncoll, nfds; + u_int nfds; size_t ni; nfds = uap->nfds; @@ -911,8 +973,7 @@ poll(td, uap) if ((nfds > lim_cur(td->td_proc, RLIMIT_NOFILE)) && (nfds > FD_SETSIZE)) { PROC_UNLOCK(td->td_proc); - error = EINVAL; - goto done2; + return (EINVAL); } PROC_UNLOCK(td->td_proc); ni = nfds * sizeof(struct pollfd); @@ -922,13 +983,13 @@ poll(td, uap) bits = smallbits; error = copyin(uap->fds, bits, ni); if (error) - goto done_nosellock; + goto done; if (uap->timeout != INFTIM) { atv.tv_sec = uap->timeout / 1000; atv.tv_usec = (uap->timeout % 1000) * 1000; if (itimerfix(&atv)) { error = EINVAL; - goto done_nosellock; + goto done; } getmicrouptime(&rtv); timevaladd(&atv, &rtv); @@ -937,56 +998,31 @@ poll(td, uap) atv.tv_usec = 0; } timo = 0; - TAILQ_INIT(&td->td_selq); - mtx_lock(&sellock); -retry: - ncoll = nselcoll; - thread_lock(td); - td->td_flags |= TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - - error = pollscan(td, bits, nfds); - mtx_lock(&sellock); - if (error || td->td_retval[0]) - goto done; - if (atv.tv_sec || atv.tv_usec) { - getmicrouptime(&rtv); - if (timevalcmp(&rtv, &atv, >=)) - goto done; - ttv = atv; - timevalsub(&ttv, &rtv); - timo = ttv.tv_sec > 24 * 60 * 60 ? - 24 * 60 * 60 * hz : tvtohz(&ttv); - } - /* - * An event of interest may occur while we do not hold - * sellock, so check TDF_SELECT and the number of collisions - * and rescan the file descriptors if necessary. - */ - thread_lock(td); - if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) { - thread_unlock(td); - goto retry; + seltdinit(td); + /* Iterate until the timeout expires or descriptors become ready. */ + for (;;) { + error = pollscan(td, bits, nfds); + if (error || td->td_retval[0] != 0) + break; + if (atv.tv_sec || atv.tv_usec) { + getmicrouptime(&rtv); + if (timevalcmp(&rtv, &atv, >=)) + break; + ttv = atv; + timevalsub(&ttv, &rtv); + timo = ttv.tv_sec > 24 * 60 * 60 ? + 24 * 60 * 60 * hz : tvtohz(&ttv); + } + error = seltdwait(td, timo); + if (error) + break; + error = pollrescan(td); + if (error || td->td_retval[0] != 0) + break; } - thread_unlock(td); - - if (timo > 0) - error = cv_timedwait_sig(&selwait, &sellock, timo); - else - error = cv_wait_sig(&selwait, &sellock); - - if (error == 0) - goto retry; + seltdclear(td); done: - clear_selinfo_list(td); - thread_lock(td); - td->td_flags &= ~TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - -done_nosellock: /* poll is not restarted after signals... */ if (error == ERESTART) error = EINTR; @@ -1000,7 +1036,6 @@ done_nosellock: out: if (ni > sizeof(smallbits)) free(bits, M_TEMP); -done2: return (error); } @@ -1025,12 +1060,56 @@ pollout(fds, ufds, nfd) } static int +pollrescan(struct thread *td) +{ + struct seltd *stp; + struct selfd *sfp; + struct selfd *sfn; + struct selinfo *si; + struct filedesc *fdp; + struct file *fp; + struct pollfd *fd; + int n; + + n = 0; + fdp = td->td_proc->p_fd; + stp = td->td_sel; + FILEDESC_SLOCK(fdp); + STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) { + fd = (struct pollfd *)sfp->sf_cookie; + si = sfp->sf_si; + selfdfree(stp, sfp); + /* If the selinfo wasn't cleared the event didn't fire. */ + if (si != NULL) + continue; + fp = fdp->fd_ofiles[fd->fd]; + if (fp == NULL) { + fd->revents = POLLNVAL; + n++; + continue; + } + /* + * Note: backend also returns POLLHUP and + * POLLERR if appropriate. + */ + fd->revents = fo_poll(fp, fd->events, td->td_ucred, td); + if (fd->revents != 0) + n++; + } + FILEDESC_SUNLOCK(fdp); + stp->st_flags = 0; + td->td_retval[0] = n; + return (0); +} + + +static int pollscan(td, fds, nfd) struct thread *td; struct pollfd *fds; u_int nfd; { - register struct filedesc *fdp = td->td_proc->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; int i; struct file *fp; int n = 0; @@ -1052,6 +1131,7 @@ pollscan(td, fds, nfd) * Note: backend also returns POLLHUP and * POLLERR if appropriate. */ + selfdalloc(td, fds); fds->revents = fo_poll(fp, fds->events, td->td_ucred, td); if (fds->revents != 0) @@ -1085,23 +1165,90 @@ openbsd_poll(td, uap) } /* - * Remove the references to the thread from all of the objects we were - * polling. - * - * This code assumes that the underlying owner of the selinfo structure will - * hold sellock before it changes it, and that it will unlink itself from our - * list if it goes away. + * XXX This was created specifically to support netncp and netsmb. This + * allows the caller to specify a socket to wait for events on. It returns + * 0 if any events matched and an error otherwise. There is no way to + * determine which events fired. */ -void -clear_selinfo_list(td) - struct thread *td; +int +selsocket(struct socket *so, int events, struct timeval *tvp, struct thread *td) { - struct selinfo *si; + struct timeval atv, rtv, ttv; + int error, timo; + + if (tvp != NULL) { + atv = *tvp; + if (itimerfix(&atv)) + return (EINVAL); + getmicrouptime(&rtv); + timevaladd(&atv, &rtv); + } else { + atv.tv_sec = 0; + atv.tv_usec = 0; + } - mtx_assert(&sellock, MA_OWNED); - TAILQ_FOREACH(si, &td->td_selq, si_thrlist) - si->si_thread = NULL; - TAILQ_INIT(&td->td_selq); + timo = 0; + seltdinit(td); + /* + * Iterate until the timeout expires or the socket becomes ready. + */ + for (;;) { + selfdalloc(td, NULL); + error = sopoll(so, events, NULL, td); + /* error here is actually the ready events. */ + if (error) + return (0); + if (atv.tv_sec || atv.tv_usec) { + getmicrouptime(&rtv); + if (timevalcmp(&rtv, &atv, >=)) { + seltdclear(td); + return (EWOULDBLOCK); + } + ttv = atv; + timevalsub(&ttv, &rtv); + timo = ttv.tv_sec > 24 * 60 * 60 ? + 24 * 60 * 60 * hz : tvtohz(&ttv); + } + error = seltdwait(td, timo); + seltdclear(td); + if (error) + break; + } + /* XXX Duplicates ncp/smb behavior. */ + if (error == ERESTART) + error = 0; + return (error); +} + +/* + * Preallocate two selfds associated with 'cookie'. Some fo_poll routines + * have two select sets, one for read and another for write. + */ +static void +selfdalloc(struct thread *td, void *cookie) +{ + struct seltd *stp; + + stp = td->td_sel; + if (stp->st_free1 == NULL) + stp->st_free1 = uma_zalloc(selfd_zone, M_WAITOK|M_ZERO); + stp->st_free1->sf_td = stp; + stp->st_free1->sf_cookie = cookie; + if (stp->st_free2 == NULL) + stp->st_free2 = uma_zalloc(selfd_zone, M_WAITOK|M_ZERO); + stp->st_free2->sf_td = stp; + stp->st_free2->sf_cookie = cookie; +} + +static void +selfdfree(struct seltd *stp, struct selfd *sfp) +{ + STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); + mtx_lock(sfp->sf_mtx); + if (sfp->sf_si) + TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); + mtx_unlock(sfp->sf_mtx); + uma_zfree(selfd_zone, sfp); } /* @@ -1112,26 +1259,46 @@ selrecord(selector, sip) struct thread *selector; struct selinfo *sip; { + struct selfd *sfp; + struct seltd *stp; + struct mtx *mtxp; - mtx_lock(&sellock); + stp = selector->td_sel; + /* + * Don't record when doing a rescan. + */ + if (stp->st_flags & SELTD_RESCAN) + return; + /* + * Grab one of the preallocated descriptors. + */ + sfp = NULL; + if ((sfp = stp->st_free1) != NULL) + stp->st_free1 = NULL; + else if ((sfp = stp->st_free2) != NULL) + stp->st_free2 = NULL; + else + panic("selrecord: No free selfd on selq"); + mtxp = mtx_pool_find(mtxpool_sleep, sip); + /* + * Initialize the sfp and queue it in the thread. + */ + sfp->sf_si = sip; + sfp->sf_mtx = mtxp; + STAILQ_INSERT_TAIL(&stp->st_selq, sfp, sf_link); /* - * If the selinfo's thread pointer is NULL then take ownership of it. - * - * If the thread pointer is not NULL and it points to another - * thread, then we have a collision. - * - * If the thread pointer is not NULL and points back to us then leave - * it alone as we've already added pointed it at us and added it to - * our list. + * Now that we've locked the sip, check for initialization. */ - if (sip->si_thread == NULL) { - sip->si_thread = selector; - TAILQ_INSERT_TAIL(&selector->td_selq, sip, si_thrlist); - } else if (sip->si_thread != selector) { - sip->si_flags |= SI_COLL; + mtx_lock(mtxp); + if (sip->si_mtx == NULL) { + sip->si_mtx = mtxp; + TAILQ_INIT(&sip->si_tdlist); } - - mtx_unlock(&sellock); + /* + * Add this thread to the list of selfds listening on this selinfo. + */ + TAILQ_INSERT_TAIL(&sip->si_tdlist, sfp, sf_threads); + mtx_unlock(sip->si_mtx); } /* Wake up a selecting thread. */ @@ -1159,36 +1326,115 @@ doselwakeup(sip, pri) struct selinfo *sip; int pri; { - struct thread *td; + struct selfd *sfp; + struct selfd *sfn; + struct seltd *stp; - mtx_lock(&sellock); - td = sip->si_thread; - if ((sip->si_flags & SI_COLL) != 0) { - nselcoll++; - sip->si_flags &= ~SI_COLL; - cv_broadcastpri(&selwait, pri); - } - if (td == NULL) { - mtx_unlock(&sellock); + /* If it's not initialized there can't be any waiters. */ + if (sip->si_mtx == NULL) return; + /* + * Locking the selinfo locks all selfds associated with it. + */ + mtx_lock(sip->si_mtx); + TAILQ_FOREACH_SAFE(sfp, &sip->si_tdlist, sf_threads, sfn) { + /* + * Once we remove this sfp from the list and clear the + * sf_si seltdclear will know to ignore this si. + */ + TAILQ_REMOVE(&sip->si_tdlist, sfp, sf_threads); + sfp->sf_si = NULL; + stp = sfp->sf_td; + mtx_lock(&stp->st_mtx); + stp->st_flags |= SELTD_PENDING; + cv_broadcastpri(&stp->st_wait, pri); + mtx_unlock(&stp->st_mtx); } - TAILQ_REMOVE(&td->td_selq, sip, si_thrlist); - sip->si_thread = NULL; - thread_lock(td); - td->td_flags &= ~TDF_SELECT; - thread_unlock(td); - sleepq_remove(td, &selwait); - mtx_unlock(&sellock); + mtx_unlock(sip->si_mtx); } -static void selectinit(void *); -SYSINIT(select, SI_SUB_LOCK, SI_ORDER_FIRST, selectinit, NULL) +static void +seltdinit(struct thread *td) +{ + struct seltd *stp; + + if ((stp = td->td_sel) != NULL) + goto out; + td->td_sel = stp = malloc(sizeof(*stp), M_SELECT, M_WAITOK|M_ZERO); + mtx_init(&stp->st_mtx, "sellck", NULL, MTX_DEF); + cv_init(&stp->st_wait, "select"); +out: + stp->st_flags = 0; + STAILQ_INIT(&stp->st_selq); +} + +static int +seltdwait(struct thread *td, int timo) +{ + struct seltd *stp; + int error; -/* ARGSUSED*/ + stp = td->td_sel; + /* + * An event of interest may occur while we do not hold the seltd + * locked so check the pending flag before we sleep. + */ + mtx_lock(&stp->st_mtx); + /* + * Any further calls to selrecord will be a rescan. + */ + stp->st_flags |= SELTD_RESCAN; + if (stp->st_flags & SELTD_PENDING) { + mtx_unlock(&stp->st_mtx); + return (0); + } + if (timo > 0) + error = cv_timedwait_sig(&stp->st_wait, &stp->st_mtx, timo); + else + error = cv_wait_sig(&stp->st_wait, &stp->st_mtx); + mtx_unlock(&stp->st_mtx); + + return (error); +} + +void +seltdfini(struct thread *td) +{ + struct seltd *stp; + + stp = td->td_sel; + if (stp == NULL) + return; + if (stp->st_free1) + uma_zfree(selfd_zone, stp->st_free1); + if (stp->st_free2) + uma_zfree(selfd_zone, stp->st_free2); + td->td_sel = NULL; + free(stp, M_SELECT); +} + +/* + * Remove the references to the thread from all of the objects we were + * polling. + */ +static void +seltdclear(struct thread *td) +{ + struct seltd *stp; + struct selfd *sfp; + struct selfd *sfn; + + stp = td->td_sel; + STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) + selfdfree(stp, sfp); + stp->st_flags = 0; +} + +static void selectinit(void *); +SYSINIT(select, SI_SUB_SYSCALLS, SI_ORDER_ANY, selectinit, NULL); static void -selectinit(dummy) - void *dummy; +selectinit(void *dummy __unused) { - cv_init(&selwait, "select"); - mtx_init(&sellock, "sellck", NULL, MTX_DEF); + selfd_zone = uma_zcreate("selfd", sizeof(struct selfd), NULL, NULL, + NULL, NULL, UMA_ALIGN_PTR, 0); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c Mon May 18 23:36:11 2009 (r192358) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c Tue May 19 00:02:58 2009 (r192359) @@ -524,8 +524,9 @@ pipeselwakeup(cpipe) PIPE_LOCK_ASSERT(cpipe, MA_OWNED); if (cpipe->pipe_state & PIPE_SEL) { - cpipe->pipe_state &= ~PIPE_SEL; selwakeuppri(&cpipe->pipe_sel, PSOCK); + if (!SEL_WAITING(&cpipe->pipe_sel)) + cpipe->pipe_state &= ~PIPE_SEL; } if ((cpipe->pipe_state & PIPE_ASYNC) && cpipe->pipe_sigio) pgsigio(&cpipe->pipe_sigio, SIGIO, 0); @@ -1356,12 +1357,14 @@ pipe_poll(fp, events, active_cred, td) if (revents == 0) { if (events & (POLLIN | POLLRDNORM)) { selrecord(td, &rpipe->pipe_sel); - rpipe->pipe_state |= PIPE_SEL; + if (SEL_WAITING(&rpipe->pipe_sel)) + rpipe->pipe_state |= PIPE_SEL; } if (events & (POLLOUT | POLLWRNORM)) { selrecord(td, &wpipe->pipe_sel); - wpipe->pipe_state |= PIPE_SEL; + if (SEL_WAITING(&wpipe->pipe_sel)) + wpipe->pipe_state |= PIPE_SEL; } } #ifdef MAC Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c Mon May 18 23:36:11 2009 (r192358) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c Tue May 19 00:02:58 2009 (r192359) @@ -179,7 +179,8 @@ sowakeup(struct socket *so, struct sockb SOCKBUF_LOCK_ASSERT(sb); selwakeuppri(&sb->sb_sel, PSOCK); - sb->sb_flags &= ~SB_SEL; + if (!SEL_WAITING(&sb->sb_sel)) + sb->sb_flags &= ~SB_SEL; if (sb->sb_flags & SB_WAIT) { sb->sb_flags &= ~SB_WAIT; wakeup(&sb->sb_cc); Modified: user/kmacy/releng_7_2_fcs/sys/netncp/ncp_rq.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netncp/ncp_rq.c Mon May 18 23:36:11 2009 (r192358) +++ user/kmacy/releng_7_2_fcs/sys/netncp/ncp_rq.c Tue May 19 00:02:58 2009 (r192359) @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -274,7 +276,9 @@ ncp_request_int(struct ncp_rq *rqp) /* * Flush out replies on previous reqs */ - while (ncp_poll(so, POLLIN) != 0) { + tv.tv_sec = 0; + tv.tv_usec = 0; + while (selsocket(so, POLLIN, &tv, td) == 0) { if (ncp_sock_recv(so, &m, &len) != 0) break; m_freem(m); @@ -319,7 +323,7 @@ ncp_request_int(struct ncp_rq *rqp) } tv.tv_sec = conn->li.timeout; tv.tv_usec = 0; - error = ncp_sock_rselect(so, td, &tv, POLLIN); + error = selsocket(so, POLLIN, &tv, td); if (error == EWOULDBLOCK ) /* timeout expired */ continue; error = ncp_chkintr(conn, td); @@ -335,7 +339,9 @@ ncp_request_int(struct ncp_rq *rqp) dosend = 1; /* resend rq if error */ for (;;) { error = 0; - if (ncp_poll(so, POLLIN) == 0) + tv.tv_sec = 0; + tv.tv_usec = 0; + if (selsocket(so, POLLIN, &tv, td) != 0) break; /* if (so->so_rcv.sb_cc == 0) { break; Modified: user/kmacy/releng_7_2_fcs/sys/netncp/ncp_sock.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/netncp/ncp_sock.c Mon May 18 23:36:11 2009 (r192358) +++ user/kmacy/releng_7_2_fcs/sys/netncp/ncp_sock.c Tue May 19 00:02:58 2009 (r192359) @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); #define ipx_setnullhost(x) ((x).x_host.s_host[0] = 0); \ ((x).x_host.s_host[1] = 0); ((x).x_host.s_host[2] = 0); -/*int ncp_poll(struct socket *so, int events);*/ /*static int ncp_getsockname(struct socket *so, caddr_t asa, int *alen);*/ static int ncp_soconnect(struct socket *so, struct sockaddr *target, struct thread *td); @@ -181,110 +180,6 @@ ncp_sock_send(struct socket *so, struct return error; } -int -ncp_poll(struct socket *so, int events) -{ - struct thread *td = curthread; - int revents; - - /* Fake up enough state to look like we are in poll(2). */ - mtx_lock(&sellock); - thread_lock(td); - td->td_flags |= TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - TAILQ_INIT(&td->td_selq); - - revents = sopoll(so, events, NULL, td); - - /* Tear down the fake poll(2) state. */ - mtx_lock(&sellock); - clear_selinfo_list(td); - thread_lock(td); - td->td_flags &= ~TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - - return (revents); -} - -int -ncp_sock_rselect(struct socket *so, struct thread *td, struct timeval *tv, - int events) -{ - struct timeval atv, rtv, ttv; - int ncoll, timo, error, revents; - - if (tv) { - atv = *tv; - if (itimerfix(&atv)) { - error = EINVAL; - goto done_noproclock; - } - getmicrouptime(&rtv); - timevaladd(&atv, &rtv); - } - timo = 0; - mtx_lock(&sellock); - -retry: - ncoll = nselcoll; - thread_lock(td); - td->td_flags |= TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - - TAILQ_INIT(&td->td_selq); - revents = sopoll(so, events, NULL, td); - mtx_lock(&sellock); - if (revents) { - error = 0; - goto done; - } - if (tv) { - getmicrouptime(&rtv); - if (timevalcmp(&rtv, &atv, >=)) { - error = EWOULDBLOCK; - goto done; - } - ttv = atv; - timevalsub(&ttv, &rtv); - timo = tvtohz(&ttv); - } - /* - * An event of our interest may occur during locking a thread. - * In order to avoid missing the event that occurred during locking - * the process, test TDF_SELECT and rescan file descriptors if - * necessary. - */ - thread_lock(td); - if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) { - thread_unlock(td); - goto retry; - } - thread_unlock(td); - - if (timo > 0) - error = cv_timedwait(&selwait, &sellock, timo); - else { - cv_wait(&selwait, &sellock); - error = 0; - } - -done: - clear_selinfo_list(td); - - thread_lock(td); - td->td_flags &= ~TDF_SELECT; - thread_unlock(td); - mtx_unlock(&sellock); - -done_noproclock: *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue May 19 01:57:26 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ADFAD1065670; Tue, 19 May 2009 01:57:26 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C4768FC15; Tue, 19 May 2009 01:57:26 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J1vQ3I081454; Tue, 19 May 2009 01:57:26 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J1vQ38081452; Tue, 19 May 2009 01:57:26 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190157.n4J1vQ38081452@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 01:57:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192362 - in user/kmacy/releng_7_2_fcs/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 01:57:26 -0000 Author: kmacy Date: Tue May 19 01:57:26 2009 New Revision: 192362 URL: http://svn.freebsd.org/changeset/base/192362 Log: fix new witness compile Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c user/kmacy/releng_7_2_fcs/sys/sys/lock.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c Tue May 19 01:41:11 2009 (r192361) +++ user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c Tue May 19 01:57:26 2009 (r192362) @@ -102,6 +102,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -322,7 +323,7 @@ static void adopt(struct witness *parent #ifdef BLESSING static int blessed(struct witness *, struct witness *); #endif -static int depart(struct witness *w); +static void depart(struct witness *w); static struct witness *enroll(const char *description, struct lock_class *lock_class); static struct lock_instance *find_instance(struct lock_list_entry *list, @@ -1687,7 +1688,7 @@ found: return (w); } -static int +static void depart(struct witness *w) { struct witness_list *list; @@ -1806,7 +1807,6 @@ adopt(struct witness *parent, struct wit static void itismychild(struct witness *parent, struct witness *child) { - struct witness_list *list; MPASS(child != NULL && parent != NULL); if (witness_cold == 0) @@ -2680,6 +2680,6 @@ _witness_debugger(int cond, const char * if (witness_trace && cond) kdb_backtrace(); if (witness_kdb && cond) - kdb_enter(KDB_WHY_WITNESS, msg); + kdb_enter_why(KDB_WHY_WITNESS, msg); } #endif Modified: user/kmacy/releng_7_2_fcs/sys/sys/lock.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/lock.h Tue May 19 01:41:11 2009 (r192361) +++ user/kmacy/releng_7_2_fcs/sys/sys/lock.h Tue May 19 01:57:26 2009 (r192362) @@ -112,18 +112,6 @@ struct lock_class { #define LA_NOTRECURSED 0x00000010 /* Lock is not recursed. */ #ifdef _KERNEL -/* - * Lock instances. A lock instance is the data associated with a lock while - * it is held by witness. For example, a lock instance will hold the - * recursion count of a lock. Lock instances are held in lists. Spin locks - * are held in a per-cpu list while sleep locks are held in per-thread list. - */ -struct lock_instance { - struct lock_object *li_lock; - const char *li_file; /* File and line of last acquire. */ - int li_line; - u_int li_flags; /* Recursion count and LI_* flags. */ -}; /* * A simple list type used to build the list of locks held by a thread @@ -135,13 +123,9 @@ struct lock_instance { * when we traverse the list we read children[count-1] as the first entry * down to children[0] as the final entry. */ -#define LOCK_NCHILDREN 3 -struct lock_list_entry { - struct lock_list_entry *ll_next; - struct lock_instance ll_children[LOCK_NCHILDREN]; - u_int ll_count; -}; +struct lock_list_entry; +struct thread; /* * If any of WITNESS, INVARIANTS, or KTR_LOCK KTR tracing has been enabled, From owner-svn-src-user@FreeBSD.ORG Tue May 19 01:58:00 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3A02106564A; Tue, 19 May 2009 01:58:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7C1D8FC25; Tue, 19 May 2009 01:58:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J1w0J8081497; Tue, 19 May 2009 01:58:00 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J1w0oD081496; Tue, 19 May 2009 01:58:00 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190158.n4J1w0oD081496@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 01:58:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192363 - user/kmacy/releng_7_2_fcs/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 01:58:01 -0000 Author: kmacy Date: Tue May 19 01:58:00 2009 New Revision: 192363 URL: http://svn.freebsd.org/changeset/base/192363 Log: remove unneeded devices Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Tue May 19 01:57:26 2009 (r192362) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Tue May 19 01:58:00 2009 (r192363) @@ -25,13 +25,13 @@ ident GENERIC #hints "GENERIC.hints" # Default places to look for devices. makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions MODULES_OVERRIDE="opensolaris zfs" +makeoptions MODULES_OVERRIDE="opensolaris zfs zlib mxge geom" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols -options SCTP # Stream Control Transmission Protocol +#options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists @@ -77,7 +77,6 @@ options DEBUG options KDB options DDB options ALT_BREAK_TO_DEBUGGER -options ADAPTIVE_SX # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel @@ -184,7 +183,6 @@ device uart # Generic UART driver device ppc device ppbus # Parallel port bus (required) device lpt # Printer -device plip # TCP/IP over parallel device ppi # Parallel port interface device #device vpo # Requires scbus and da @@ -194,80 +192,17 @@ device ppi # Parallel port interface d #device puc # PCI Ethernet NICs. -device de # DEC/Intel DC21x4x (``Tulip'') device em # Intel PRO/1000 Gigabit Ethernet Family -device igb # Intel PRO/1000 PCIE Server Gigabit Family -device ixgbe # Intel PRO/10GbE PCIE Ethernet Family -device le # AMD Am7900 LANCE and Am79C9xx PCnet -device txp # 3Com 3cR990 (``Typhoon'') -device vx # 3Com 3c590, 3c595 (``Vortex'') # PCI Ethernet NICs that use the common MII bus controller code. # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! device miibus # MII bus support -device age # Attansic/Atheros L1 Gigabit Ethernet -device ale # Atheros AR8121/AR8113/AR8114 Ethernet -device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet -device bfe # Broadcom BCM440x 10/100 Ethernet -device bge # Broadcom BCM570xx Gigabit Ethernet -device dc # DEC/Intel 21143 and various workalikes -device et # Agere ET1310 10/100/Gigabit Ethernet -device fxp # Intel EtherExpress PRO/100B (82557, 82558) -device jme # JMicron JMC250 Gigabit/JMC260 Fast Ethernet -device lge # Level 1 LXT1001 gigabit Ethernet -device msk # Marvell/SysKonnect Yukon II Gigabit Ethernet -device nfe # nVidia nForce MCP on-board Ethernet -device nge # NatSemi DP83820 gigabit Ethernet -#device nve # nVidia nForce MCP on-board Ethernet Networking -device pcn # AMD Am79C97x PCI 10/100 (precedence over 'le') -device re # RealTek 8139C+/8169/8169S/8110S -device rl # RealTek 8129/8139 -device sf # Adaptec AIC-6915 (``Starfire'') -device sis # Silicon Integrated Systems SiS 900/SiS 7016 -device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet -device ste # Sundance ST201 (D-Link DFE-550TX) -device ti # Alteon Networks Tigon I/II gigabit Ethernet -device tl # Texas Instruments ThunderLAN -device tx # SMC EtherPower II (83c170 ``EPIC'') -device vge # VIA VT612x gigabit Ethernet -device vr # VIA Rhine, Rhine II -device wb # Winbond W89C840F -device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') - -# ISA Ethernet NICs. pccard NICs included. -device cs # Crystal Semiconductor CS89x0 NIC -# 'device ed' requires 'device miibus' -device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards -device ex # Intel EtherExpress Pro/10 and Pro/10+ -device ep # Etherlink III based cards -device fe # Fujitsu MB8696x based cards -device sn # SMC's 9000 series of Ethernet chips -device xe # Xircom pccard Ethernet - -# Wireless NIC cards -device wlan # 802.11 support -device wlan_wep # 802.11 WEP support -device wlan_ccmp # 802.11 CCMP support -device wlan_tkip # 802.11 TKIP support -device wlan_amrr # AMRR transmit rate control algorithm -device wlan_scan_ap # 802.11 AP mode scanning -device wlan_scan_sta # 802.11 STA mode scanning -device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's -device ath_hal # Atheros HAL (Hardware Access Layer) -options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors -device ath_rate_sample # SampleRate tx rate control for ath -device awi # BayStack 660 and others -device ral # Ralink Technology RT2500 wireless NICs. -device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. + # Pseudo devices. device loop # Network loopback device random # Entropy device device ether # Ethernet support -device sl # Kernel SLIP -device ppp # Kernel PPP -device tun # Packet tunnel. device pty # Pseudo-ttys (telnet etc) device md # Memory "disks" device gif # IPv6 and IPv4 tunneling @@ -291,7 +226,6 @@ device ukbd # Keyboard device ulpt # Printer device umass # Disks/Mass storage - Requires scbus and da device ums # Mouse -device ural # Ralink Technology RT2500USB wireless NICs device urio # Diamond Rio 500 MP3 player device uscanner # Scanners # USB Serial devices @@ -305,18 +239,8 @@ device uplcom # Prolific PL-2303 seria device uslcom # SI Labs CP2101/CP2102 serial adapters device uvisor # Visor and Palm devices device uvscom # USB serial support for DDI pocket's PHS -# USB Ethernet, requires miibus -device aue # ADMtek USB Ethernet -device axe # ASIX Electronics USB Ethernet -device cdce # Generic USB over Ethernet -device cue # CATC USB Ethernet -device kue # Kawasaki LSI USB Ethernet -device rue # RealTek RTL8150 USB Ethernet - -# FireWire support -device firewire # FireWire bus code -device sbp # SCSI over FireWire (Requires scbus and da) -device fwe # Ethernet over FireWire (non-standard!) -device fwip # IP over FireWire (RFC 2734,3146) -device dcons # Dumb console driver -device dcons_crom # Configuration ROM for dcons + + + + + From owner-svn-src-user@FreeBSD.ORG Tue May 19 03:09:05 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76D20106566B; Tue, 19 May 2009 03:09:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A72A8FC08; Tue, 19 May 2009 03:09:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J395DQ083140; Tue, 19 May 2009 03:09:05 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J395gq083139; Tue, 19 May 2009 03:09:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190309.n4J395gq083139@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 03:09:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192366 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 03:09:05 -0000 Author: kmacy Date: Tue May 19 03:09:04 2009 New Revision: 192366 URL: http://svn.freebsd.org/changeset/base/192366 Log: update arguments to sleepq_resume_thread Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c Tue May 19 02:51:30 2009 (r192365) +++ user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c Tue May 19 03:09:04 2009 (r192366) @@ -427,7 +427,7 @@ sleepq_catch_signals(void *wchan, int pr */ if (TD_ON_SLEEPQ(td)) { sq = sleepq_lookup(wchan); - if (sleepq_resume_thread(sq, td, -1)) { + if (sleepq_resume_thread(sq, td, 0)) { #ifdef INVARIANTS /* * This thread hasn't gone to sleep yet, so it @@ -475,7 +475,7 @@ sleepq_switch(void *wchan, int pri) if (td->td_flags & TDF_TIMEOUT) { MPASS(TD_ON_SLEEPQ(td)); sq = sleepq_lookup(wchan); - if (sleepq_resume_thread(sq, td, -1)) { + if (sleepq_resume_thread(sq, td, 0)) { #ifdef INVARIANTS /* * This thread hasn't gone to sleep yet, so it @@ -638,6 +638,10 @@ sleepq_timedwait_sig(void *wchan, int pr return (rvalt); } +#ifdef INVARIANTS +extern void kdb_backtrace(void); +#endif + /* * Removes a thread from a sleep queue and makes it * runnable. @@ -691,6 +695,12 @@ sleepq_resume_thread(struct sleepqueue * TD_CLR_SLEEPING(td); /* Adjust priority if requested. */ +#ifdef INVARIANTS + if (!(pri == 0 || (pri >= PRI_MIN && pri <= PRI_MAX))) { + kdb_backtrace(); + printf("pri=%d\n", pri); + } +#endif MPASS(pri == 0 || (pri >= PRI_MIN && pri <= PRI_MAX)); if (pri != 0 && td->td_priority > pri) sched_prio(td, pri); @@ -827,7 +837,7 @@ sleepq_timeout(void *arg) sq = sleepq_lookup(wchan); MPASS(sq != NULL); td->td_flags |= TDF_TIMEOUT; - wakeup_swapper = sleepq_resume_thread(sq, td, -1); + wakeup_swapper = sleepq_resume_thread(sq, td, 0); thread_unlock(td); if (wakeup_swapper) kick_proc0(); @@ -899,7 +909,7 @@ sleepq_remove(struct thread *td, void *w thread_lock(td); MPASS(sq != NULL); MPASS(td->td_wchan == wchan); - wakeup_swapper = sleepq_resume_thread(sq, td, -1); + wakeup_swapper = sleepq_resume_thread(sq, td, 0); thread_unlock(td); sleepq_release(wchan); if (wakeup_swapper) @@ -945,7 +955,7 @@ sleepq_abort(struct thread *td, int intr MPASS(sq != NULL); /* Thread is asleep on sleep queue sq, so wake it up. */ - return (sleepq_resume_thread(sq, td, -1)); + return (sleepq_resume_thread(sq, td, 0)); } #ifdef DDB From owner-svn-src-user@FreeBSD.ORG Tue May 19 03:21:52 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BDFE106564A; Tue, 19 May 2009 03:21:52 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3F8D88FC08; Tue, 19 May 2009 03:21:52 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J3LqSp083590; Tue, 19 May 2009 03:21:52 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J3Lqnb083588; Tue, 19 May 2009 03:21:52 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190321.n4J3Lqnb083588@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 03:21:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192367 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 03:21:53 -0000 Author: kmacy Date: Tue May 19 03:21:51 2009 New Revision: 192367 URL: http://svn.freebsd.org/changeset/base/192367 Log: fix calls to sleepq_broadcast to pass a 0 priority Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c Tue May 19 03:09:04 2009 (r192366) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c Tue May 19 03:21:51 2009 (r192367) @@ -401,7 +401,7 @@ _sx_downgrade(struct sx *sx, const char (x & SX_LOCK_EXCLUSIVE_WAITERS)); if (x & SX_LOCK_SHARED_WAITERS) wakeup_swapper = sleepq_broadcast(&sx->lock_object, SLEEPQ_SX, - -1, SQ_SHARED_QUEUE); + 0, SQ_SHARED_QUEUE); sleepq_release(&sx->lock_object); LOCK_LOG_LOCK("XDOWNGRADE", &sx->lock_object, 0, 0, file, line); @@ -627,7 +627,7 @@ _sx_xunlock_hard(struct sx *sx, uintptr_ __func__, sx, queue == SQ_SHARED_QUEUE ? "shared" : "exclusive"); atomic_store_rel_ptr(&sx->sx_lock, x); - wakeup_swapper = sleepq_broadcast(&sx->lock_object, SLEEPQ_SX, -1, + wakeup_swapper = sleepq_broadcast(&sx->lock_object, SLEEPQ_SX, 0, queue); sleepq_release(&sx->lock_object); if (wakeup_swapper) @@ -878,7 +878,7 @@ _sx_sunlock_hard(struct sx *sx, const ch CTR2(KTR_LOCK, "%s: %p waking up all thread on" "exclusive queue", __func__, sx); wakeup_swapper = sleepq_broadcast(&sx->lock_object, SLEEPQ_SX, - -1, SQ_EXCLUSIVE_QUEUE); + 0, SQ_EXCLUSIVE_QUEUE); sleepq_release(&sx->lock_object); if (wakeup_swapper) kick_proc0(); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Tue May 19 03:09:04 2009 (r192366) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Tue May 19 03:21:51 2009 (r192367) @@ -333,7 +333,7 @@ wakeup(void *ident) int wakeup_swapper; sleepq_lock(ident); - wakeup_swapper = sleepq_broadcast(ident, SLEEPQ_SLEEP, -1, 0); + wakeup_swapper = sleepq_broadcast(ident, SLEEPQ_SLEEP, 0, 0); sleepq_release(ident); if (wakeup_swapper) kick_proc0(); From owner-svn-src-user@FreeBSD.ORG Tue May 19 03:45:37 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C18F106566C; Tue, 19 May 2009 03:45:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A6728FC16; Tue, 19 May 2009 03:45:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J3jbKJ084068; Tue, 19 May 2009 03:45:37 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J3jbwM084065; Tue, 19 May 2009 03:45:37 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190345.n4J3jbwM084065@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 03:45:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192368 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 03:45:37 -0000 Author: kmacy Date: Tue May 19 03:45:36 2009 New Revision: 192368 URL: http://svn.freebsd.org/changeset/base/192368 Log: fix more sleepq callers Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c Tue May 19 03:21:51 2009 (r192367) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c Tue May 19 03:45:36 2009 (r192368) @@ -417,7 +417,7 @@ cv_signal(struct cv *cvp) sleepq_lock(cvp); if (cvp->cv_waiters > 0) { cvp->cv_waiters--; - wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, -1, 0); + wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, 0, 0); } sleepq_release(cvp); if (wakeup_swapper) @@ -433,12 +433,6 @@ cv_broadcastpri(struct cv *cvp, int pri) { int wakeup_swapper; - /* - * XXX sleepq_broadcast pri argument changed from -1 meaning - * no pri to 0 meaning no pri. - */ - if (pri == -1) - pri = 0; wakeup_swapper = 0; sleepq_lock(cvp); if (cvp->cv_waiters > 0) { Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Tue May 19 03:21:51 2009 (r192367) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_synch.c Tue May 19 03:45:36 2009 (r192368) @@ -350,7 +350,7 @@ wakeup_one(void *ident) int wakeup_swapper; sleepq_lock(ident); - wakeup_swapper = sleepq_signal(ident, SLEEPQ_SLEEP, -1, 0); + wakeup_swapper = sleepq_signal(ident, SLEEPQ_SLEEP, 0, 0); sleepq_release(ident); if (wakeup_swapper) kick_proc0(); Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 03:21:51 2009 (r192367) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 03:45:36 2009 (r192368) @@ -1306,7 +1306,7 @@ void selwakeup(sip) struct selinfo *sip; { - doselwakeup(sip, -1); + doselwakeup(sip, 0); } /* Wake up a selecting thread, and set its priority. */ From owner-svn-src-user@FreeBSD.ORG Tue May 19 04:43:01 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF13A1065673; Tue, 19 May 2009 04:43:01 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B0938FC23; Tue, 19 May 2009 04:43:01 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J4h1bH085184; Tue, 19 May 2009 04:43:01 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J4h17I085171; Tue, 19 May 2009 04:43:01 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190443.n4J4h17I085171@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 04:43:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192369 - in user/kmacy/releng_7_2_fcs/sys: compat/svr4 dev/streams fs/devfs fs/fifofs kern netgraph opencrypto sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 04:43:02 -0000 Author: kmacy Date: Tue May 19 04:43:00 2009 New Revision: 192369 URL: http://svn.freebsd.org/changeset/base/192369 Log: merge 174988 Remove explicit locking of struct file. - Introduce a finit() which is used to initailize the fields of struct file in such a way that the ops vector is only valid after the data, type, and flags are valid. - Protect f_flag and f_count with atomic operations. - Remove the global list of all files and associated accounting. - Rewrite the unp garbage collection such that it no longer requires the global list of all files and instead uses a list of all unp sockets. - Mark sockets in the accept queue so we don't incorrectly gc them. Tested by: kris, pho Modified: user/kmacy/releng_7_2_fcs/sys/compat/svr4/svr4_stream.c user/kmacy/releng_7_2_fcs/sys/dev/streams/streams.c user/kmacy/releng_7_2_fcs/sys/fs/devfs/devfs_vnops.c user/kmacy/releng_7_2_fcs/sys/fs/fifofs/fifo_vnops.c user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_mqueue.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c user/kmacy/releng_7_2_fcs/sys/kern/vfs_syscalls.c user/kmacy/releng_7_2_fcs/sys/kern/vfs_vnops.c user/kmacy/releng_7_2_fcs/sys/netgraph/ng_socket.c user/kmacy/releng_7_2_fcs/sys/opencrypto/cryptodev.c user/kmacy/releng_7_2_fcs/sys/sys/file.h user/kmacy/releng_7_2_fcs/sys/sys/unpcb.h Modified: user/kmacy/releng_7_2_fcs/sys/compat/svr4/svr4_stream.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/compat/svr4/svr4_stream.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/compat/svr4/svr4_stream.c Tue May 19 04:43:00 2009 (r192369) @@ -1481,8 +1481,6 @@ svr4_do_putmsg(td, uap, fp) uap->dat, uap->flags); #endif /* DEBUG_SVR4 */ - FILE_LOCK_ASSERT(fp, MA_NOTOWNED); - if (uap->ctl != NULL) { if ((error = copyin(uap->ctl, &ctl, sizeof(ctl))) != 0) { #ifdef DEBUG_SVR4 @@ -1656,8 +1654,6 @@ svr4_do_getmsg(td, uap, fp) error = 0; afp = NULL; - FILE_LOCK_ASSERT(fp, MA_NOTOWNED); - memset(&sc, 0, sizeof(sc)); #ifdef DEBUG_SVR4 Modified: user/kmacy/releng_7_2_fcs/sys/dev/streams/streams.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/streams/streams.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/dev/streams/streams.c Tue May 19 04:43:00 2009 (r192369) @@ -251,12 +251,7 @@ streamsopen(struct cdev *dev, int oflags return error; } - FILE_LOCK(fp); - fp->f_data = so; - fp->f_flag = FREAD|FWRITE; - fp->f_ops = &svr4_netops; - fp->f_type = DTYPE_SOCKET; - FILE_UNLOCK(fp); + finit(fp, FREAD | FWRITE, DTYPE_SOCKET, so, &svr4_netops); /* * Allocate a stream structure and attach it to this socket. Modified: user/kmacy/releng_7_2_fcs/sys/fs/devfs/devfs_vnops.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/fs/devfs/devfs_vnops.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/fs/devfs/devfs_vnops.c Tue May 19 04:43:00 2009 (r192369) @@ -887,13 +887,11 @@ devfs_open(struct vop_open_args *ap) VOP_UNLOCK(vp, 0, td); + fpop = td->td_fpop; + td->td_fpop = fp; if (fp != NULL) { - FILE_LOCK(fp); fp->f_data = dev; - FILE_UNLOCK(fp); } - fpop = td->td_fpop; - td->td_fpop = fp; if(!(dsw->d_flags & D_NEEDGIANT)) { DROP_GIANT(); if (dsw->d_fdopen != NULL) @@ -923,11 +921,9 @@ devfs_open(struct vop_open_args *ap) if(fp == NULL) return (error); #endif - FILE_LOCK(fp); KASSERT(fp->f_ops == &badfileops, ("Could not vnode bypass device on fdops %p", fp->f_ops)); - fp->f_ops = &devfs_ops_f; - FILE_UNLOCK(fp); + finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f); return (error); } Modified: user/kmacy/releng_7_2_fcs/sys/fs/fifofs/fifo_vnops.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/fs/fifofs/fifo_vnops.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/fs/fifofs/fifo_vnops.c Tue May 19 04:43:00 2009 (r192369) @@ -294,11 +294,8 @@ fail1: } mtx_unlock(&fifo_mtx); KASSERT(fp != NULL, ("can't fifo/vnode bypass")); - FILE_LOCK(fp); KASSERT(fp->f_ops == &badfileops, ("not badfileops in fifo_open")); - fp->f_data = fip; - fp->f_ops = &fifo_ops_f; - FILE_UNLOCK(fp); + finit(fp, fp->f_flag, DTYPE_FIFO, fip, &fifo_ops_f); return (0); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Tue May 19 04:43:00 2009 (r192369) @@ -99,7 +99,6 @@ static int do_dup(struct thread *td, enu static int fd_first_free(struct filedesc *, int, int); static int fd_last_used(struct filedesc *, int, int); static void fdgrowtable(struct filedesc *, int); -static int fdrop_locked(struct file *fp, struct thread *td); static void fdunused(struct filedesc *fdp, int fd); static void fdused(struct filedesc *fdp, int fd); @@ -141,9 +140,7 @@ struct filedesc0 { /* * Descriptor management. */ -struct filelist filehead; /* head of list of open files */ -int openfiles; /* actual number of open files */ -struct sx filelist_lock; /* sx to protect filelist */ +volatile int openfiles; /* actual number of open files */ struct mtx sigio_lock; /* mtx to protect pointers to sigio */ void (*mq_fdclose)(struct thread *td, int fd, struct file *fp); @@ -476,9 +473,7 @@ kern_fcntl(struct thread *td, int fd, in error = EBADF; break; } - FILE_LOCK(fp); td->td_retval[0] = OFLAGS(fp->f_flag); - FILE_UNLOCK(fp); FILEDESC_SUNLOCK(fdp); break; @@ -489,12 +484,13 @@ kern_fcntl(struct thread *td, int fd, in error = EBADF; break; } - FILE_LOCK(fp); - fhold_locked(fp); - fp->f_flag &= ~FCNTLFLAGS; - fp->f_flag |= FFLAGS(arg & ~O_ACCMODE) & FCNTLFLAGS; - FILE_UNLOCK(fp); + fhold(fp); FILEDESC_SUNLOCK(fdp); + do { + tmp = flg = fp->f_flag; + tmp &= ~FCNTLFLAGS; + tmp |= FFLAGS(arg & ~O_ACCMODE) & FCNTLFLAGS; + } while(atomic_cmpset_int(&fp->f_flag, flg, tmp) == 0); tmp = fp->f_flag & FNONBLOCK; error = fo_ioctl(fp, FIONBIO, &tmp, td->td_ucred, td); if (error) { @@ -507,9 +503,7 @@ kern_fcntl(struct thread *td, int fd, in fdrop(fp, td); break; } - FILE_LOCK(fp); - fp->f_flag &= ~FNONBLOCK; - FILE_UNLOCK(fp); + atomic_clear_int(&fp->f_flag, FNONBLOCK); tmp = 0; (void)fo_ioctl(fp, FIONBIO, &tmp, td->td_ucred, td); fdrop(fp, td); @@ -1431,15 +1425,13 @@ int falloc(struct thread *td, struct file **resultfp, int *resultfd) { struct proc *p = td->td_proc; - struct file *fp, *fq; + struct file *fp; int error, i; int maxuserfiles = maxfiles - (maxfiles / 20); static struct timeval lastfail; static int curfail; fp = uma_zalloc(file_zone, M_WAITOK | M_ZERO); - sx_xlock(&filelist_lock); - if ((openfiles >= maxuserfiles && priv_check(td, PRIV_MAXFILES) != 0) || openfiles >= maxfiles) { @@ -1447,18 +1439,16 @@ falloc(struct thread *td, struct file ** printf("kern.maxfiles limit exceeded by uid %i, please see tuning(7).\n", td->td_ucred->cr_ruid); } - sx_xunlock(&filelist_lock); uma_zfree(file_zone, fp); return (ENFILE); } - openfiles++; + atomic_add_int(&openfiles, 1); /* * If the process has file descriptor zero open, add the new file * descriptor to the list of open files at that point, otherwise * put it at the front of the list of open files. */ - fp->f_mtxp = mtx_pool_alloc(mtxpool_sleep); fp->f_count = 1; if (resultfp) fp->f_count++; @@ -1467,12 +1457,6 @@ falloc(struct thread *td, struct file ** fp->f_data = NULL; fp->f_vnode = NULL; FILEDESC_XLOCK(p->p_fd); - if ((fq = p->p_fd->fd_ofiles[0])) { - LIST_INSERT_AFTER(fq, fp, f_list); - } else { - LIST_INSERT_HEAD(&filehead, fp, f_list); - } - sx_xunlock(&filelist_lock); if ((error = fdalloc(td, 0, &i))) { FILEDESC_XUNLOCK(p->p_fd); fdrop(fp, td); @@ -2037,6 +2021,23 @@ closef(struct file *fp, struct thread *t } /* + * Initialize the file pointer with the specified properties. + * + * The ops are set with release semantics to be certain that the flags, type, + * and data are visible when ops is. This is to prevent ops methods from being + * called with bad data. + */ +void +finit(struct file *fp, u_int flag, short type, void *data, struct fileops *ops) +{ + fp->f_data = data; + fp->f_flag = flag; + fp->f_type = type; + atomic_store_rel_ptr((volatile uintptr_t *)&fp->f_ops, (uintptr_t)ops); +} + + +/* * Extract the file pointer associated with the specified descriptor for the * current user process. * @@ -2210,54 +2211,20 @@ fputsock(struct socket *so) sorele(so); } -int -fdrop(struct file *fp, struct thread *td) -{ - - FILE_LOCK(fp); - return (fdrop_locked(fp, td)); -} - /* - * Drop reference on struct file passed in, may call closef if the - * reference hits zero. - * Expects struct file locked, and will unlock it. + * Handle the last reference to a file being closed. */ -static int -fdrop_locked(struct file *fp, struct thread *td) +int +_fdrop(struct file *fp, struct thread *td) { int error; - FILE_LOCK_ASSERT(fp, MA_OWNED); - - if (--fp->f_count > 0) { - FILE_UNLOCK(fp); - return (0); - } - - /* - * We might have just dropped the last reference to a file - * object that is for a UNIX domain socket whose message - * buffers are being examined in unp_gc(). If that is the - * case, FWAIT will be set in f_gcflag and we need to wait for - * unp_gc() to finish its scan. - */ - while (fp->f_gcflag & FWAIT) - msleep(&fp->f_gcflag, fp->f_mtxp, 0, "fpdrop", 0); - - /* We have the last ref so we can proceed without the file lock. */ - FILE_UNLOCK(fp); - if (fp->f_count < 0) - panic("fdrop: count < 0"); + error = 0; + if (fp->f_count != 0) + panic("fdrop: count %d", fp->f_count); if (fp->f_ops != &badfileops) error = fo_close(fp, td); - else - error = 0; - - sx_xlock(&filelist_lock); - LIST_REMOVE(fp, f_list); - openfiles--; - sx_xunlock(&filelist_lock); + atomic_subtract_int(&openfiles, 1); /* * The f_cdevpriv cannot be assigned non-NULL value while we @@ -2307,9 +2274,7 @@ flock(struct thread *td, struct flock_ar lf.l_len = 0; if (uap->how & LOCK_UN) { lf.l_type = F_UNLCK; - FILE_LOCK(fp); - fp->f_flag &= ~FHASLOCK; - FILE_UNLOCK(fp); + atomic_clear_int(&fp->f_flag, FHASLOCK); error = VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK); goto done2; } @@ -2321,9 +2286,7 @@ flock(struct thread *td, struct flock_ar error = EBADF; goto done2; } - FILE_LOCK(fp); - fp->f_flag |= FHASLOCK; - FILE_UNLOCK(fp); + atomic_set_int(&fp->f_flag, FHASLOCK); error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, (uap->how & LOCK_NB) ? F_FLOCK : F_FLOCK | F_WAIT); done2: @@ -2368,9 +2331,7 @@ dupfdopen(struct thread *td, struct file * Check that the mode the file is being opened for is a * subset of the mode of the existing descriptor. */ - FILE_LOCK(wfp); if (((mode & (FREAD|FWRITE)) | wfp->f_flag) != wfp->f_flag) { - FILE_UNLOCK(wfp); FILEDESC_XUNLOCK(fdp); return (EACCES); } @@ -2379,8 +2340,7 @@ dupfdopen(struct thread *td, struct file fdp->fd_ofileflags[indx] = fdp->fd_ofileflags[dfd]; if (fp == NULL) fdused(fdp, indx); - fhold_locked(wfp); - FILE_UNLOCK(wfp); + fhold(wfp); FILEDESC_XUNLOCK(fdp); if (fp != NULL) /* @@ -2501,29 +2461,23 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS) struct proc *p; int error, n; - /* - * Note: because the number of file descriptors is calculated - * in different ways for sizing vs returning the data, - * there is information leakage from the first loop. However, - * it is of a similar order of magnitude to the leakage from - * global system statistics such as kern.openfiles. - */ error = sysctl_wire_old_buffer(req, 0); if (error != 0) return (error); if (req->oldptr == NULL) { - n = 16; /* A slight overestimate. */ - sx_slock(&filelist_lock); - LIST_FOREACH(fp, &filehead, f_list) { - /* - * We should grab the lock, but this is an - * estimate, so does it really matter? - */ - /* mtx_lock(fp->f_mtxp); */ - n += fp->f_count; - /* mtx_unlock(f->f_mtxp); */ + n = 0; + sx_slock(&allproc_lock); + FOREACH_PROC_IN_SYSTEM(p) { + if (p->p_state == PRS_NEW) + continue; + fdp = fdhold(p); + if (fdp == NULL) + continue; + /* overestimates sparse tables. */ + n += fdp->fd_lastfile; + fddrop(fdp); } - sx_sunlock(&filelist_lock); + sx_sunlock(&allproc_lock); return (SYSCTL_OUT(req, 0, n * sizeof(xf))); } error = 0; @@ -2554,7 +2508,7 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS) xf.xf_vnode = fp->f_vnode; xf.xf_type = fp->f_type; xf.xf_count = fp->f_count; - xf.xf_msgcount = fp->f_msgcount; + xf.xf_msgcount = 0; xf.xf_offset = fp->f_offset; xf.xf_flag = fp->f_flag; error = SYSCTL_OUT(req, &xf, sizeof(xf)); @@ -2662,7 +2616,6 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLE continue; bzero(kif, sizeof(*kif)); kif->kf_structsize = sizeof(*kif); - FILE_LOCK(fp); vp = NULL; so = NULL; kif->kf_fd = i; @@ -2670,7 +2623,6 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLE case DTYPE_VNODE: kif->kf_type = KF_TYPE_VNODE; vp = fp->f_vnode; - vref(vp); break; case DTYPE_SOCKET: @@ -2722,8 +2674,8 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLE if (fp->f_flag & FHASLOCK) kif->kf_flags |= KF_FLAG_HASLOCK; kif->kf_offset = fp->f_offset; - FILE_UNLOCK(fp); if (vp != NULL) { + vref(vp); switch (vp->v_type) { case VNON: kif->kf_vnode_type = KF_VTYPE_VNON; @@ -2895,7 +2847,6 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER if ((fp = fdp->fd_ofiles[i]) == NULL) continue; bzero(kif, sizeof(*kif)); - FILE_LOCK(fp); vp = NULL; so = NULL; kif->kf_fd = i; @@ -2959,7 +2910,6 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER if (fp->f_flag & FHASLOCK) kif->kf_flags |= KF_FLAG_HASLOCK; kif->kf_offset = fp->f_offset; - FILE_UNLOCK(fp); if (vp != NULL) { switch (vp->v_type) { case VNON: @@ -3118,7 +3068,7 @@ db_print_file(struct file *fp, int heade p = file_to_first_proc(fp); db_printf("%8p %4s %8p %08x %04x %5d %6d %8p %5d %12s\n", fp, file_type_to_name(fp->f_type), fp->f_data, fp->f_flag, - fp->f_gcflag, fp->f_count, fp->f_msgcount, fp->f_vnode, + 0, fp->f_count, 0, fp->f_vnode, p != NULL ? p->p_pid : -1, p != NULL ? p->p_comm : "-"); } @@ -3136,13 +3086,24 @@ DB_SHOW_COMMAND(file, db_show_file) DB_SHOW_COMMAND(files, db_show_files) { + struct filedesc *fdp; struct file *fp; + struct proc *p; int header; + int n; header = 1; - LIST_FOREACH(fp, &filehead, f_list) { - db_print_file(fp, header); - header = 0; + FOREACH_PROC_IN_SYSTEM(p) { + if (p->p_state == PRS_NEW) + continue; + if ((fdp = p->p_fd) == NULL) + continue; + for (n = 0; n < fdp->fd_nfiles; ++n) { + if ((fp = fdp->fd_ofiles[n]) == NULL) + continue; + db_print_file(fp, header); + header = 0; + } } } #endif @@ -3154,7 +3115,7 @@ SYSCTL_INT(_kern, KERN_MAXFILES, maxfile &maxfiles, 0, "Maximum number of files"); SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD, - &openfiles, 0, "System-wide number of open files"); + __DEVOLATILE(int *, &openfiles), 0, "System-wide number of open files"); /* ARGSUSED*/ static void @@ -3163,7 +3124,6 @@ filelistinit(void *dummy) file_zone = uma_zcreate("Files", sizeof(struct file), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); - sx_init(&filelist_lock, "filelist lock"); mtx_init(&sigio_lock, "sigio lock", NULL, MTX_DEF); mtx_init(&fdesc_mtx, "fdesc", NULL, MTX_DEF); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_event.c Tue May 19 04:43:00 2009 (r192369) @@ -583,12 +583,7 @@ kqueue(struct thread *td, struct kqueue_ SLIST_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list); FILEDESC_XUNLOCK(fdp); - FILE_LOCK(fp); - fp->f_flag = FREAD | FWRITE; - fp->f_type = DTYPE_KQUEUE; - fp->f_data = kq; - fp->f_ops = &kqueueops; - FILE_UNLOCK(fp); + finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops); fdrop(fp, td); td->td_retval[0] = fd; @@ -1042,24 +1037,17 @@ kqueue_acquire(struct file *fp, struct k error = 0; - FILE_LOCK(fp); - do { - kq = fp->f_data; - if (fp->f_type != DTYPE_KQUEUE || kq == NULL) { - error = EBADF; - break; - } - *kqp = kq; - KQ_LOCK(kq); - if ((kq->kq_state & KQ_CLOSING) == KQ_CLOSING) { - KQ_UNLOCK(kq); - error = EBADF; - break; - } - kq->kq_refcnt++; + kq = fp->f_data; + if (fp->f_type != DTYPE_KQUEUE || kq == NULL) + return (EBADF); + *kqp = kq; + KQ_LOCK(kq); + if ((kq->kq_state & KQ_CLOSING) == KQ_CLOSING) { KQ_UNLOCK(kq); - } while (0); - FILE_UNLOCK(fp); + return (EBADF); + } + kq->kq_refcnt++; + KQ_UNLOCK(kq); return error; } Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 04:43:00 2009 (r192369) @@ -647,21 +647,17 @@ kern_ioctl(struct thread *td, int fd, u_ FILEDESC_XUNLOCK(fdp); goto out; case FIONBIO: - FILE_LOCK(fp); if ((tmp = *(int *)data)) - fp->f_flag |= FNONBLOCK; + atomic_set_int(&fp->f_flag, FNONBLOCK); else - fp->f_flag &= ~FNONBLOCK; - FILE_UNLOCK(fp); + atomic_clear_int(&fp->f_flag, FNONBLOCK); data = (void *)&tmp; break; case FIOASYNC: - FILE_LOCK(fp); if ((tmp = *(int *)data)) - fp->f_flag |= FASYNC; + atomic_set_int(&fp->f_flag, FASYNC); else - fp->f_flag &= ~FASYNC; - FILE_UNLOCK(fp); + atomic_clear_int(&fp->f_flag, FASYNC); data = (void *)&tmp; break; } Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_pipe.c Tue May 19 04:43:00 2009 (r192369) @@ -363,12 +363,7 @@ pipe(td, uap) * to avoid races against processes which manage to dup() the read * side while we are blocked trying to allocate the write side. */ - FILE_LOCK(rf); - rf->f_flag = FREAD | FWRITE; - rf->f_type = DTYPE_PIPE; - rf->f_data = rpipe; - rf->f_ops = &pipeops; - FILE_UNLOCK(rf); + finit(rf, FREAD | FWRITE, DTYPE_PIPE, rpipe, &pipeops); error = falloc(td, &wf, &fd); if (error) { fdclose(fdp, rf, td->td_retval[0], td); @@ -378,12 +373,7 @@ pipe(td, uap) return (error); } /* An extra reference on `wf' has been held for us by falloc(). */ - FILE_LOCK(wf); - wf->f_flag = FREAD | FWRITE; - wf->f_type = DTYPE_PIPE; - wf->f_data = wpipe; - wf->f_ops = &pipeops; - FILE_UNLOCK(wf); + finit(wf, FREAD | FWRITE, DTYPE_PIPE, wpipe, &pipeops); fdrop(wf, td); td->td_retval[1] = fd; fdrop(rf, td); Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_mqueue.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_mqueue.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_mqueue.c Tue May 19 04:43:00 2009 (r192369) @@ -1997,12 +1997,8 @@ kmq_open(struct thread *td, struct kmq_o mqnode_addref(pn); sx_xunlock(&mqfs_data.mi_lock); - FILE_LOCK(fp); - fp->f_flag = (flags & (FREAD | FWRITE | O_NONBLOCK)); - fp->f_type = DTYPE_MQUEUE; - fp->f_data = pn; - fp->f_ops = &mqueueops; - FILE_UNLOCK(fp); + finit(fp, flags & (FREAD | FWRITE | O_NONBLOCK), DTYPE_MQUEUE, pn, + &mqueueops); FILEDESC_XLOCK(fdp); if (fdp->fd_ofiles[fd] == fp) @@ -2095,6 +2091,7 @@ kmq_setattr(struct thread *td, struct km struct mqueue *mq; struct file *fp; struct mq_attr attr, oattr; + u_int oflag, flag; int error; if (uap->attr) { @@ -2110,13 +2107,15 @@ kmq_setattr(struct thread *td, struct km oattr.mq_maxmsg = mq->mq_maxmsg; oattr.mq_msgsize = mq->mq_msgsize; oattr.mq_curmsgs = mq->mq_curmsgs; - FILE_LOCK(fp); - oattr.mq_flags = (O_NONBLOCK & fp->f_flag); if (uap->attr) { - fp->f_flag &= ~O_NONBLOCK; - fp->f_flag |= (attr.mq_flags & O_NONBLOCK); - } - FILE_UNLOCK(fp); + do { + oflag = flag = fp->f_flag; + flag &= ~O_NONBLOCK; + flag |= (attr.mq_flags & O_NONBLOCK); + } while (atomic_cmpset_int(&fp->f_flag, oflag, flag) == 0); + } else + oflag = fp->f_flag; + oattr.mq_flags = (O_NONBLOCK & oflag); fdrop(fp, td); if (uap->oattr) error = copyout(&oattr, uap->oattr, sizeof(oattr)); Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Tue May 19 04:43:00 2009 (r192369) @@ -180,12 +180,7 @@ socket(td, uap) if (error) { fdclose(fdp, fp, fd, td); } else { - FILE_LOCK(fp); - fp->f_data = so; /* already has ref count */ - fp->f_flag = FREAD|FWRITE; - fp->f_type = DTYPE_SOCKET; - fp->f_ops = &socketops; - FILE_UNLOCK(fp); + finit(fp, FREAD | FWRITE, DTYPE_SOCKET, so, &socketops); td->td_retval[0] = fd; } fdrop(fp, td); @@ -427,12 +422,7 @@ kern_accept(struct thread *td, int s, st if (pgid != 0) fsetown(pgid, &so->so_sigio); - FILE_LOCK(nfp); - nfp->f_data = so; /* nfp has ref count from falloc */ - nfp->f_flag = fflag; - nfp->f_type = DTYPE_SOCKET; - nfp->f_ops = &socketops; - FILE_UNLOCK(nfp); + finit(nfp, fflag, DTYPE_SOCKET, so, &socketops); /* Sync socket nonblocking/async state with file flags */ tmp = fflag & FNONBLOCK; (void) fo_ioctl(nfp, FIONBIO, &tmp, td->td_ucred, td); @@ -652,16 +642,8 @@ socketpair(td, uap) if (error) goto free4; } - FILE_LOCK(fp1); - fp1->f_flag = FREAD|FWRITE; - fp1->f_type = DTYPE_SOCKET; - fp1->f_ops = &socketops; - FILE_UNLOCK(fp1); - FILE_LOCK(fp2); - fp2->f_flag = FREAD|FWRITE; - fp2->f_type = DTYPE_SOCKET; - fp2->f_ops = &socketops; - FILE_UNLOCK(fp2); + finit(fp1, FREAD | FWRITE, DTYPE_SOCKET, fp1->f_data, &socketops); + finit(fp2, FREAD | FWRITE, DTYPE_SOCKET, fp2->f_data, &socketops); so1 = so2 = NULL; error = copyout(sv, uap->rsv, 2 * sizeof (int)); if (error) @@ -2309,12 +2291,7 @@ sctp_peeloff(td, uap) so->so_qstate &= ~SQ_COMP; so->so_head = NULL; ACCEPT_UNLOCK(); - FILE_LOCK(nfp); - nfp->f_data = so; - nfp->f_flag = fflag; - nfp->f_type = DTYPE_SOCKET; - nfp->f_ops = &socketops; - FILE_UNLOCK(nfp); + finit(nfp, fflag, DTYPE_SOCKET, so, &socketops); error = sctp_do_peeloff(head, so, (sctp_assoc_t)uap->name); if (error) goto noconnection; Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c Tue May 19 03:45:36 2009 (r192368) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c Tue May 19 04:43:00 2009 (r192369) @@ -235,12 +235,13 @@ static void unp_shutdown(struct unpcb *) static void unp_drop(struct unpcb *, int); static void unp_gc(__unused void *, int); static void unp_scan(struct mbuf *, void (*)(struct file *)); -static void unp_mark(struct file *); static void unp_discard(struct file *); static void unp_freerights(struct file **, int); static void unp_init(void); static int unp_internalize(struct mbuf **, struct thread *); static int unp_externalize(struct mbuf *, struct mbuf **); +static void unp_internalize_fp(struct file *); +static void unp_externalize_fp(struct file *); static struct mbuf *unp_addsockcred(struct thread *, struct mbuf *); /* @@ -1606,12 +1607,7 @@ unp_externalize(struct mbuf *control, st panic("unp_externalize fdalloc failed"); fp = *rp++; td->td_proc->p_fd->fd_ofiles[f] = fp; - FILE_LOCK(fp); - fp->f_msgcount--; - FILE_UNLOCK(fp); - UNP_GLOBAL_WLOCK(); - unp_rights--; - UNP_GLOBAL_WUNLOCK(); + unp_externalize_fp(fp); *fdp++ = f; } FILEDESC_XUNLOCK(td->td_proc->p_fd); @@ -1767,13 +1763,8 @@ unp_internalize(struct mbuf **controlp, for (i = 0; i < oldfds; i++) { fp = fdescp->fd_ofiles[*fdp++]; *rp++ = fp; - FILE_LOCK(fp); - fp->f_count++; - fp->f_msgcount++; - FILE_UNLOCK(fp); - UNP_GLOBAL_WLOCK(); - unp_rights++; - UNP_GLOBAL_WUNLOCK(); + fhold(fp); + unp_internalize_fp(fp); } FILEDESC_SUNLOCK(fdescp); break; @@ -1860,255 +1851,201 @@ unp_addsockcred(struct thread *td, struc return (m); } +static struct unpcb * +fptounp(struct file *fp) +{ + struct socket *so; + + if (fp->f_type != DTYPE_SOCKET) + return (NULL); + if ((so = fp->f_data) == NULL) + return (NULL); + if (so->so_proto->pr_domain != &localdomain) + return (NULL); + return sotounpcb(so); +} + +static void +unp_discard(struct file *fp) +{ + + unp_externalize_fp(fp); + (void) closef(fp, (struct thread *)NULL); +} + +static void +unp_internalize_fp(struct file *fp) +{ + struct unpcb *unp; + + UNP_GLOBAL_WLOCK(); + if ((unp = fptounp(fp)) != NULL) { + unp->unp_file = fp; + unp->unp_msgcount++; + } + unp_rights++; + UNP_GLOBAL_WUNLOCK(); +} + +static void +unp_externalize_fp(struct file *fp) +{ + struct unpcb *unp; + + UNP_GLOBAL_WLOCK(); + if ((unp = fptounp(fp)) != NULL) + unp->unp_msgcount--; + unp_rights--; + UNP_GLOBAL_WUNLOCK(); +} + /* * unp_defer indicates whether additional work has been defered for a future * pass through unp_gc(). It is thread local and does not require explicit * synchronization. */ -static int unp_defer; +static int unp_marked; +static int unp_unreachable; -static int unp_taskcount; -SYSCTL_INT(_net_local, OID_AUTO, taskcount, CTLFLAG_RD, &unp_taskcount, 0, ""); +static void +unp_accessable(struct file *fp) +{ + struct unpcb *unp; -static int unp_recycled; -SYSCTL_INT(_net_local, OID_AUTO, recycled, CTLFLAG_RD, &unp_recycled, 0, ""); + unp = fptounp(fp); + if (fp == NULL) + return; + if (unp->unp_gcflag & UNPGC_REF) + return; + unp->unp_gcflag &= ~UNPGC_DEAD; + unp->unp_gcflag |= UNPGC_REF; + unp_marked++; +} static void -unp_gc(__unused void *arg, int pending) +unp_gc_process(struct unpcb *unp) { - struct file *fp, *nextfp; - struct socket *so; struct socket *soa; - struct file **extra_ref, **fpp; - int nunref, i; - int nfiles_snap; - int nfiles_slack = 20; - - unp_taskcount++; - unp_defer = 0; + struct socket *so; + struct file *fp; + /* Already processed. */ + if (unp->unp_gcflag & UNPGC_SCANNED) + return; + fp = unp->unp_file; /* - * Before going through all this, set all FDs to be NOT deferred and - * NOT externally accessible. + * Check for a socket potentially in a cycle. It must be in a + * queue as indicated by msgcount, and this must equal the file + * reference count. Note that when msgcount is 0 the file is NULL. */ - sx_slock(&filelist_lock); - LIST_FOREACH(fp, &filehead, f_list) - fp->f_gcflag &= ~(FMARK|FDEFER); - do { - KASSERT(unp_defer >= 0, ("unp_gc: unp_defer %d", unp_defer)); - LIST_FOREACH(fp, &filehead, f_list) { - FILE_LOCK(fp); - /* - * If the file is not open, skip it -- could be a - * file in the process of being opened, or in the - * process of being closed. If the file is - * "closing", it may have been marked for deferred - * consideration. Clear the flag now if so. - */ - if (fp->f_count == 0) { - if (fp->f_gcflag & FDEFER) - unp_defer--; - fp->f_gcflag &= ~(FMARK|FDEFER); - FILE_UNLOCK(fp); - continue; - } - - /* - * If we already marked it as 'defer' in a - * previous pass, then try to process it this - * time and un-mark it. - */ - if (fp->f_gcflag & FDEFER) { - fp->f_gcflag &= ~FDEFER; - unp_defer--; - } else { - /* - * If it's not deferred, then check if it's - * already marked.. if so skip it - */ - if (fp->f_gcflag & FMARK) { - FILE_UNLOCK(fp); - continue; - } - - /* - * If all references are from messages in - * transit, then skip it. it's not externally - * accessible. - */ - if (fp->f_count == fp->f_msgcount) { - FILE_UNLOCK(fp); - continue; - } - - /* - * If it got this far then it must be - * externally accessible. - */ - fp->f_gcflag |= FMARK; - } + if (unp->unp_msgcount != 0 && fp->f_count != 0 && + fp->f_count == unp->unp_msgcount) { + unp->unp_gcflag |= UNPGC_DEAD; + unp_unreachable++; + return; + } + /* + * Mark all sockets we reference with RIGHTS. + */ + so = unp->unp_socket; + SOCKBUF_LOCK(&so->so_rcv); + unp_scan(so->so_rcv.sb_mb, unp_accessable); + SOCKBUF_UNLOCK(&so->so_rcv); + /* + * Mark all sockets in our accept queue. + */ + ACCEPT_LOCK(); + TAILQ_FOREACH(soa, &so->so_comp, so_list) { + SOCKBUF_LOCK(&soa->so_rcv); + unp_scan(soa->so_rcv.sb_mb, unp_accessable); + SOCKBUF_UNLOCK(&soa->so_rcv); + } + ACCEPT_UNLOCK(); + unp->unp_gcflag |= UNPGC_SCANNED; +} - /* - * Either it was deferred, or it is externally - * accessible and not already marked so. Now check - * if it is possibly one of OUR sockets. - */ - if (fp->f_type != DTYPE_SOCKET || - (so = fp->f_data) == NULL) { - FILE_UNLOCK(fp); - continue; - } +static int unp_recycled; +SYSCTL_INT(_net_local, OID_AUTO, recycled, CTLFLAG_RD, &unp_recycled, 0, ""); - if (so->so_proto->pr_domain != &localdomain || - (so->so_proto->pr_flags & PR_RIGHTS) == 0) { - FILE_UNLOCK(fp); - continue; - } +static int unp_taskcount; +SYSCTL_INT(_net_local, OID_AUTO, taskcount, CTLFLAG_RD, &unp_taskcount, 0, ""); - /* - * Tell any other threads that do a subsequent - * fdrop() that we are scanning the message - * buffers. - */ - fp->f_gcflag |= FWAIT; - FILE_UNLOCK(fp); +static void +unp_gc(__unused void *arg, int pending) +{ + struct unp_head *heads[] = { &unp_dhead, &unp_shead, NULL }; + struct unp_head **head; + struct file **unref; + struct unpcb *unp; + int i; - /* - * So, Ok, it's one of our sockets and it IS - * externally accessible (or was deferred). Now we - * look to see if we hold any file descriptors in its - * message buffers. Follow those links and mark them - * as accessible too. - */ - SOCKBUF_LOCK(&so->so_rcv); - unp_scan(so->so_rcv.sb_mb, unp_mark); - SOCKBUF_UNLOCK(&so->so_rcv); + unp_taskcount++; + UNP_GLOBAL_RLOCK(); - /* - * If socket is in listening state, then sockets - * in its accept queue are accessible, and so - * are any descriptors in those sockets' receive - * queues. - */ - ACCEPT_LOCK(); - TAILQ_FOREACH(soa, &so->so_comp, so_list) { - SOCKBUF_LOCK(&soa->so_rcv); - unp_scan(soa->so_rcv.sb_mb, unp_mark); - SOCKBUF_UNLOCK(&soa->so_rcv); + /* + * First clear all gc flags from previous runs. + */ + for (head = heads; *head != NULL; head++) + LIST_FOREACH(unp, *head, unp_link) + unp->unp_gcflag &= ~(UNPGC_REF|UNPGC_DEAD); + /* + * Scan marking all reachable sockets with UNPGC_REF. Once a socket + * is reachable all of the sockets it references are reachable. + * Stop the scan once we do a complete loop without discovering + * a new reachable socket. + */ + do { + unp_unreachable = 0; + unp_marked = 0; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue May 19 04:47:31 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 476C71065670; Tue, 19 May 2009 04:47:31 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2C17E8FC15; Tue, 19 May 2009 04:47:31 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J4lVDV085320; Tue, 19 May 2009 04:47:31 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J4lVY0085319; Tue, 19 May 2009 04:47:31 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190447.n4J4lVY0085319@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 04:47:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192370 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 04:47:31 -0000 Author: kmacy Date: Tue May 19 04:47:30 2009 New Revision: 192370 URL: http://svn.freebsd.org/changeset/base/192370 Log: merge 175026,175211,175212 - Place the fhold() in unp_internalize_fp to be more consistent with refs. - Clear all of the gc flags before doing a run. Stale flags were causing us to skip some descriptors. - If a unp socket has been marked REF in a gc pass it can't be dead. Found by: rwatson's test tool. Correct typos in comments. MFC after: 3 weeks Remove "lock pushdown" todo item in comment -- I did that for 7.0. MFC after: 3 weeks Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c Tue May 19 04:43:00 2009 (r192369) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_usrreq.c Tue May 19 04:47:30 2009 (r192370) @@ -1763,7 +1763,6 @@ unp_internalize(struct mbuf **controlp, for (i = 0; i < oldfds; i++) { fp = fdescp->fd_ofiles[*fdp++]; *rp++ = fp; - fhold(fp); unp_internalize_fp(fp); } FILEDESC_SUNLOCK(fdescp); @@ -1883,6 +1882,7 @@ unp_internalize_fp(struct file *fp) unp->unp_file = fp; unp->unp_msgcount++; } + fhold(fp); unp_rights++; UNP_GLOBAL_WUNLOCK(); } @@ -1912,8 +1912,7 @@ unp_accessable(struct file *fp) { struct unpcb *unp; - unp = fptounp(fp); - if (fp == NULL) + if ((unp = fptounp(fp)) == NULL) return; if (unp->unp_gcflag & UNPGC_REF) return; @@ -1938,8 +1937,8 @@ unp_gc_process(struct unpcb *unp) * queue as indicated by msgcount, and this must equal the file * reference count. Note that when msgcount is 0 the file is NULL. */ - if (unp->unp_msgcount != 0 && fp->f_count != 0 && - fp->f_count == unp->unp_msgcount) { + if ((unp->unp_gcflag & UNPGC_REF) == 0 && fp && + unp->unp_msgcount != 0 && fp->f_count == unp->unp_msgcount) { unp->unp_gcflag |= UNPGC_DEAD; unp_unreachable++; return; @@ -1987,7 +1986,7 @@ unp_gc(__unused void *arg, int pending) */ for (head = heads; *head != NULL; head++) LIST_FOREACH(unp, *head, unp_link) - unp->unp_gcflag &= ~(UNPGC_REF|UNPGC_DEAD); + unp->unp_gcflag = 0; /* * Scan marking all reachable sockets with UNPGC_REF. Once a socket * is reachable all of the sockets it references are reachable. @@ -2018,6 +2017,7 @@ unp_gc(__unused void *arg, int pending) LIST_FOREACH(unp, *head, unp_link) if (unp->unp_gcflag & UNPGC_DEAD) { unref[i++] = unp->unp_file; + fhold(unp->unp_file); KASSERT(unp->unp_file != NULL, ("unp_gc: Invalid unpcb.")); KASSERT(i <= unp_unreachable, @@ -2026,13 +2026,6 @@ unp_gc(__unused void *arg, int pending) UNP_GLOBAL_RUNLOCK(); /* - * All further operation is now done on a local list. We first ref - * all sockets to avoid closing them until all are flushed. - */ - for (i = 0; i < unp_unreachable; i++) - fhold(unref[i]); - - /* * Now flush all sockets, free'ing rights. This will free the * struct files associated with these sockets but leave each socket * with one remaining ref. From owner-svn-src-user@FreeBSD.ORG Tue May 19 05:17:43 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD1CA1065700; Tue, 19 May 2009 05:17:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9EB88FC1F; Tue, 19 May 2009 05:17:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J5HgnW086013; Tue, 19 May 2009 05:17:42 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J5HgQD085995; Tue, 19 May 2009 05:17:42 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190517.n4J5HgQD085995@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 05:17:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192371 - in user/kmacy/releng_7_2_fcs/sys: kern sys ufs/ffs vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 05:17:43 -0000 Author: kmacy Date: Tue May 19 05:17:41 2009 New Revision: 192371 URL: http://svn.freebsd.org/changeset/base/192371 Log: merge 177368, 177374, 183297 - Relax requirements for p_numthreads, p_threads, p_swtick, and p_nice from requiring the per-process spinlock to only requiring the process lock. - Reflect these changes in the proc.h documentation and consumers throughout the kernel. This is a substantial reduction in locking cost for these fields and was made possible by recent changes to threading support. Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_cpuset.c user/kmacy/releng_7_2_fcs/sys/kern/kern_exit.c user/kmacy/releng_7_2_fcs/sys/kern/kern_proc.c user/kmacy/releng_7_2_fcs/sys/kern/kern_resource.c user/kmacy/releng_7_2_fcs/sys/kern/kern_sig.c user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c user/kmacy/releng_7_2_fcs/sys/kern/tty.c user/kmacy/releng_7_2_fcs/sys/sys/proc.h user/kmacy/releng_7_2_fcs/sys/ufs/ffs/ffs_snapshot.c user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c user/kmacy/releng_7_2_fcs/sys/vm/vm_pageout.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_cpuset.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_cpuset.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_cpuset.c Tue May 19 05:17:41 2009 (r192371) @@ -418,11 +418,9 @@ cpuset_which(cpuwhich_t which, id_t id, sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td) if (td->td_tid == id) break; - PROC_SUNLOCK(p); if (td != NULL) break; PROC_UNLOCK(p); @@ -542,11 +540,9 @@ cpuset_setproc(pid_t pid, struct cpuset error = cpuset_which(CPU_WHICH_PID, pid, &p, &td, &nset); if (error) goto out; - PROC_SLOCK(p); if (nfree >= p->p_numthreads) break; threads = p->p_numthreads; - PROC_SUNLOCK(p); PROC_UNLOCK(p); for (; nfree < threads; nfree++) { nset = uma_zalloc(cpuset_zone, M_WAITOK); @@ -554,7 +550,6 @@ cpuset_setproc(pid_t pid, struct cpuset } } PROC_LOCK_ASSERT(p, MA_OWNED); - PROC_SLOCK_ASSERT(p, MA_OWNED); /* * Now that the appropriate locks are held and we have enough cpusets, * make sure the operation will succeed before applying changes. The @@ -588,8 +583,8 @@ cpuset_setproc(pid_t pid, struct cpuset } /* * Replace each thread's cpuset while using deferred release. We - * must do this because the PROC_SLOCK has to be held while traversing - * the thread list and this limits the type of operations allowed. + * must do this because the thread lock must be held while operating + * on the thread and this limits the type of operations allowed. */ FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); @@ -623,7 +618,6 @@ cpuset_setproc(pid_t pid, struct cpuset thread_unlock(td); } unlock_out: - PROC_SUNLOCK(p); PROC_UNLOCK(p); out: while ((nset = LIST_FIRST(&droplist)) != NULL) @@ -952,13 +946,11 @@ cpuset_getaffinity(struct thread *td, st thread_unlock(ttd); break; case CPU_WHICH_PID: - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, ttd) { thread_lock(ttd); CPU_OR(mask, &ttd->td_cpuset->cs_mask); thread_unlock(ttd); } - PROC_SUNLOCK(p); break; case CPU_WHICH_CPUSET: case CPU_WHICH_JAIL: Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_exit.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_exit.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_exit.c Tue May 19 05:17:41 2009 (r192371) @@ -550,9 +550,7 @@ retry: * proc lock. */ wakeup(p->p_pptr); - PROC_SLOCK(p->p_pptr); sched_exit(p->p_pptr, td); - PROC_SUNLOCK(p->p_pptr); PROC_SLOCK(p); p->p_state = PRS_ZOMBIE; PROC_UNLOCK(p->p_pptr); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_proc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_proc.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_proc.c Tue May 19 05:17:41 2009 (r192371) @@ -682,11 +682,11 @@ fill_kinfo_proc_only(struct proc *p, str struct ucred *cred; struct sigacts *ps; + PROC_LOCK_ASSERT(p, MA_OWNED); bzero(kp, sizeof(*kp)); kp->ki_structsize = sizeof(*kp); kp->ki_paddr = p; - PROC_LOCK_ASSERT(p, MA_OWNED); kp->ki_addr =/* p->p_addr; */0; /* XXXKSE */ kp->ki_args = p->p_args; kp->ki_textvp = p->p_textvp; @@ -818,7 +818,7 @@ fill_kinfo_thread(struct thread *td, str struct proc *p; p = td->td_proc; - PROC_SLOCK_ASSERT(p, MA_OWNED); + PROC_LOCK_ASSERT(p, MA_OWNED); thread_lock(td); if (td->td_wmesg != NULL) @@ -893,10 +893,8 @@ fill_kinfo_proc(struct proc *p, struct k { fill_kinfo_proc_only(p, kp); - PROC_SLOCK(p); if (FIRST_THREAD_IN_PROC(p) != NULL) fill_kinfo_thread(FIRST_THREAD_IN_PROC(p), kp, 0); - PROC_SUNLOCK(p); } struct pstats * @@ -963,15 +961,12 @@ sysctl_out_proc(struct proc *p, struct s fill_kinfo_proc_only(p, &kinfo_proc); if (flags & KERN_PROC_NOTHREADS) { - PROC_SLOCK(p); if (FIRST_THREAD_IN_PROC(p) != NULL) fill_kinfo_thread(FIRST_THREAD_IN_PROC(p), &kinfo_proc, 0); - PROC_SUNLOCK(p); error = SYSCTL_OUT(req, (caddr_t)&kinfo_proc, sizeof(kinfo_proc)); } else { - PROC_SLOCK(p); if (FIRST_THREAD_IN_PROC(p) != NULL) FOREACH_THREAD_IN_PROC(p, td) { fill_kinfo_thread(td, &kinfo_proc, 1); @@ -983,7 +978,6 @@ sysctl_out_proc(struct proc *p, struct s else error = SYSCTL_OUT(req, (caddr_t)&kinfo_proc, sizeof(kinfo_proc)); - PROC_SUNLOCK(p); } PROC_UNLOCK(p); if (error) @@ -1725,7 +1719,7 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_A lwpidarray = NULL; numthreads = 0; - PROC_SLOCK(p); + PROC_LOCK(p); repeat: if (numthreads < p->p_numthreads) { if (lwpidarray != NULL) { @@ -1733,13 +1727,12 @@ repeat: lwpidarray = NULL; } numthreads = p->p_numthreads; - PROC_SUNLOCK(p); + PROC_UNLOCK(p); lwpidarray = malloc(sizeof(*lwpidarray) * numthreads, M_TEMP, M_WAITOK | M_ZERO); - PROC_SLOCK(p); + PROC_LOCK(p); goto repeat; } - PROC_SUNLOCK(p); i = 0; /* @@ -1751,7 +1744,6 @@ repeat: * have changed, in which case the right to extract debug info might * no longer be assured. */ - PROC_LOCK(p); FOREACH_THREAD_IN_PROC(p, td) { KASSERT(i < numthreads, ("sysctl_kern_proc_kstack: numthreads")); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_resource.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_resource.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_resource.c Tue May 19 05:17:41 2009 (r192371) @@ -264,9 +264,7 @@ donice(struct thread *td, struct proc *p n = PRIO_MIN; if (n < p->p_nice && priv_check(td, PRIV_SCHED_SETPRIORITY) != 0) return (EACCES); - PROC_SLOCK(p); sched_nice(p, n); - PROC_SUNLOCK(p); return (0); } @@ -307,7 +305,6 @@ rtprio_thread(struct thread *td, struct case RTP_LOOKUP: if ((error = p_cansee(td, p))) break; - PROC_SLOCK(p); if (uap->lwpid == 0 || uap->lwpid == td->td_tid) td1 = td; else @@ -316,7 +313,6 @@ rtprio_thread(struct thread *td, struct pri_to_rtp(td1, &rtp); else error = ESRCH; - PROC_SUNLOCK(p); PROC_UNLOCK(p); return (copyout(&rtp, uap->rtp, sizeof(struct rtprio))); case RTP_SET: @@ -341,7 +337,6 @@ rtprio_thread(struct thread *td, struct break; } - PROC_SLOCK(p); if (uap->lwpid == 0 || uap->lwpid == td->td_tid) td1 = td; else @@ -350,7 +345,6 @@ rtprio_thread(struct thread *td, struct error = rtp_to_pri(&rtp, td1); else error = ESRCH; - PROC_SUNLOCK(p); break; default: error = EINVAL; @@ -401,7 +395,6 @@ rtprio(td, uap) case RTP_LOOKUP: if ((error = p_cansee(td, p))) break; - PROC_SLOCK(p); /* * Return OUR priority if no pid specified, * or if one is, report the highest priority @@ -429,7 +422,6 @@ rtprio(td, uap) } } } - PROC_SUNLOCK(p); PROC_UNLOCK(p); return (copyout(&rtp, uap->rtp, sizeof(struct rtprio))); case RTP_SET: @@ -460,7 +452,6 @@ rtprio(td, uap) * do all the threads on that process. If we * specify our own pid we do the latter. */ - PROC_SLOCK(p); if (uap->pid == 0) { error = rtp_to_pri(&rtp, td); } else { @@ -469,7 +460,6 @@ rtprio(td, uap) break; } } - PROC_SUNLOCK(p); break; default: error = EINVAL; @@ -702,9 +692,7 @@ kern_setrlimit(td, which, limp) if (limp->rlim_cur != RLIM_INFINITY && p->p_cpulimit == RLIM_INFINITY) callout_reset(&p->p_limco, hz, lim_cb, p); - PROC_SLOCK(p); p->p_cpulimit = limp->rlim_cur; - PROC_SUNLOCK(p); break; case RLIMIT_DATA: if (limp->rlim_cur > maxdsiz) @@ -960,11 +948,12 @@ kern_getrusage(td, who, rup) struct rusage *rup; { struct proc *p; + int error; + error = 0; p = td->td_proc; PROC_LOCK(p); switch (who) { - case RUSAGE_SELF: rufetchcalc(p, rup, &rup->ru_utime, &rup->ru_stime); @@ -976,11 +965,10 @@ kern_getrusage(td, who, rup) break; default: - PROC_UNLOCK(p); - return (EINVAL); + error = EINVAL; } PROC_UNLOCK(p); - return (0); + return (error); } void Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_sig.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_sig.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_sig.c Tue May 19 05:17:41 2009 (r192371) @@ -512,10 +512,8 @@ sigqueue_delete_set_proc(struct proc *p, sigqueue_init(&worklist, NULL); sigqueue_move_set(&p->p_sigqueue, &worklist, set); - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td0) sigqueue_move_set(&td0->td_sigqueue, &worklist, set); - PROC_SUNLOCK(p); sigqueue_flush(&worklist); } @@ -1958,7 +1956,6 @@ sigtd(struct proc *p, int sig, int prop) if (curproc == p && !SIGISMEMBER(curthread->td_sigmask, sig)) return (curthread); signal_td = NULL; - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td) { if (!SIGISMEMBER(td->td_sigmask, sig)) { signal_td = td; @@ -1967,7 +1964,6 @@ sigtd(struct proc *p, int sig, int prop) } if (signal_td == NULL) signal_td = FIRST_THREAD_IN_PROC(p); - PROC_SUNLOCK(p); return (signal_td); } @@ -2020,27 +2016,6 @@ psignal_event(struct proc *p, struct sig int tdsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) { -#ifdef KSE - sigset_t saved; - int ret; - - if (p->p_flag & P_SA) - saved = p->p_sigqueue.sq_signals; - ret = do_tdsignal(p, td, sig, ksi); - if ((p->p_flag & P_SA) && !(p->p_flag & P_SIGEVENT)) { - if (!SIGSETEQ(saved, p->p_sigqueue.sq_signals)) { - /* pending set changed */ - p->p_flag |= P_SIGEVENT; - wakeup(&p->p_siglist); - } - } - return (ret); -} - -static int -do_tdsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) -{ -#endif sig_t action; sigqueue_t *sigqueue; int prop; @@ -2173,7 +2148,6 @@ do_tdsignal(struct proc *p, struct threa * waking up threads so that they can cross the user boundary. * We try do the per-process part here. */ - PROC_SLOCK(p); if (P_SHOULDSTOP(p)) { /* * The process is in stopped mode. All the threads should be @@ -2185,7 +2159,6 @@ do_tdsignal(struct proc *p, struct threa * so no further action is necessary. * No signal can restart us. */ - PROC_SUNLOCK(p); goto out; } @@ -2211,6 +2184,7 @@ do_tdsignal(struct proc *p, struct threa * Otherwise, process goes back to sleep state. */ p->p_flag &= ~P_STOPPED_SIG; + PROC_SLOCK(p); if (p->p_numthreads == p->p_suspcount) { PROC_SUNLOCK(p); p->p_flag |= P_CONTINUED; @@ -2227,22 +2201,7 @@ do_tdsignal(struct proc *p, struct threa goto out; } if (action == SIG_CATCH) { -#ifdef KSE - /* - * The process wants to catch it so it needs - * to run at least one thread, but which one? - * It would seem that the answer would be to - * run an upcall in the next KSE to run, and - * deliver the signal that way. In a NON KSE - * process, we need to make sure that the - * single thread is runnable asap. - * XXXKSE for now however, make them all run. - */ -#endif - /* - * The process wants to catch it so it needs - * to run at least one thread, but which one? - */ + PROC_SUNLOCK(p); goto runfast; } /* @@ -2259,7 +2218,6 @@ do_tdsignal(struct proc *p, struct threa * (If we did the shell could get confused). * Just make sure the signal STOP bit set. */ - PROC_SUNLOCK(p); p->p_flag |= P_STOPPED_SIG; sigqueue_delete(sigqueue, sig); goto out; @@ -2274,6 +2232,7 @@ do_tdsignal(struct proc *p, struct threa * It may run a bit until it hits a thread_suspend_check(). */ wakeup_swapper = 0; + PROC_SLOCK(p); thread_lock(td); if (TD_ON_SLEEPQ(td) && (td->td_flags & TDF_SINTR)) wakeup_swapper = sleepq_abort(td, intrval); @@ -2288,22 +2247,18 @@ do_tdsignal(struct proc *p, struct threa */ } else if (p->p_state == PRS_NORMAL) { if (p->p_flag & P_TRACED || action == SIG_CATCH) { - thread_lock(td); tdsigwakeup(td, sig, action, intrval); - thread_unlock(td); - PROC_SUNLOCK(p); goto out; } MPASS(action == SIG_DFL); if (prop & SA_STOP) { - if (p->p_flag & P_PPWAIT) { - PROC_SUNLOCK(p); + if (p->p_flag & P_PPWAIT) goto out; - } p->p_flag |= P_STOPPED_SIG; p->p_xstat = sig; + PROC_SLOCK(p); sig_suspend_threads(td, p, 1); if (p->p_numthreads == p->p_suspcount) { /* @@ -2319,13 +2274,9 @@ do_tdsignal(struct proc *p, struct threa } else PROC_SUNLOCK(p); goto out; - } - else - goto runfast; - /* NOTREACHED */ + } } else { /* Not in "NORMAL" state. discard the signal. */ - PROC_SUNLOCK(p); sigqueue_delete(sigqueue, sig); goto out; } @@ -2334,11 +2285,9 @@ do_tdsignal(struct proc *p, struct threa * The process is not stopped so we need to apply the signal to all the * running threads. */ - runfast: - thread_lock(td); tdsigwakeup(td, sig, action, intrval); - thread_unlock(td); + PROC_SLOCK(p); thread_unsuspend(p); PROC_SUNLOCK(p); out: @@ -2361,17 +2310,16 @@ tdsigwakeup(struct thread *td, int sig, wakeup_swapper = 0; PROC_LOCK_ASSERT(p, MA_OWNED); - PROC_SLOCK_ASSERT(p, MA_OWNED); - THREAD_LOCK_ASSERT(td, MA_OWNED); prop = sigprop(sig); + PROC_SLOCK(p); + thread_lock(td); /* * Bring the priority of a thread up if we want it to get * killed in this lifetime. */ if (action == SIG_DFL && (prop & SA_KILL) && td->td_priority > PUSER) sched_prio(td, PUSER); - if (TD_ON_SLEEPQ(td)) { /* * If thread is sleeping uninterruptibly @@ -2380,7 +2328,7 @@ tdsigwakeup(struct thread *td, int sig, * trap() or syscall(). */ if ((td->td_flags & TDF_SINTR) == 0) - return; + goto out; /* * If SIGCONT is default (or ignored) and process is * asleep, we are finished; the process should not @@ -2395,8 +2343,6 @@ tdsigwakeup(struct thread *td, int sig, * Remove from both for now. */ sigqueue_delete(&td->td_sigqueue, sig); - PROC_SLOCK(p); - thread_lock(td); return; } @@ -2418,8 +2364,9 @@ tdsigwakeup(struct thread *td, int sig, forward_signal(td); #endif } - if (wakeup_swapper) - kick_proc0(); +out: + PROC_SUNLOCK(p); + thread_unlock(td); } static void Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c Tue May 19 05:17:41 2009 (r192371) @@ -230,13 +230,11 @@ create_thread(struct thread *td, mcontex PROC_LOCK(td->td_proc); td->td_proc->p_flag |= P_HADTHREADS; newtd->td_sigmask = td->td_sigmask; - PROC_SLOCK(p); thread_link(newtd, p); thread_lock(td); /* let the scheduler know about these things. */ sched_fork_thread(td, newtd); thread_unlock(td); - PROC_SUNLOCK(p); PROC_UNLOCK(p); thread_lock(newtd); if (rtp != NULL) { Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Tue May 19 05:17:41 2009 (r192371) @@ -415,7 +415,6 @@ thread_exit(void) #ifdef AUDIT AUDIT_SYSCALL_EXIT(0, td); #endif - #ifdef KSE if (td->td_standin != NULL) { /* @@ -428,7 +427,6 @@ thread_exit(void) #endif umtx_thread_exit(td); - /* * drop FPU & debug register state storage, or any other * architecture specific resources that @@ -455,13 +453,7 @@ thread_exit(void) */ if (p->p_flag & P_HADTHREADS) { if (p->p_numthreads > 1) { - thread_lock(td); -#ifdef KSE - kse_unlink(td); -#else thread_unlink(td); -#endif - thread_unlock(td); td2 = FIRST_THREAD_IN_PROC(p); sched_exit_thread(td2, td); @@ -568,8 +560,8 @@ thread_link(struct thread *td, struct pr /* * XXX This can't be enabled because it's called for proc0 before - * it's spinlock has been created. - * PROC_SLOCK_ASSERT(p, MA_OWNED); + * its lock has been created. + * PROC_LOCK_ASSERT(p, MA_OWNED); */ td->td_state = TDS_INACTIVE; td->td_proc = p; @@ -619,7 +611,7 @@ thread_unlink(struct thread *td) { struct proc *p = td->td_proc; - PROC_SLOCK_ASSERT(p, MA_OWNED); + PROC_LOCK_ASSERT(p, MA_OWNED); TAILQ_REMOVE(&p->p_threads, td, td_plist); p->p_numthreads--; /* could clear a few other things here */ @@ -1020,11 +1012,9 @@ thread_find(struct proc *p, lwpid_t tid) struct thread *td; PROC_LOCK_ASSERT(p, MA_OWNED); - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td) { if (td->td_tid == tid) break; } - PROC_SUNLOCK(p); return (td); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/sched_4bsd.c Tue May 19 05:17:41 2009 (r192371) @@ -368,7 +368,7 @@ schedcpu(void) realstathz = stathz ? stathz : hz; sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { - PROC_SLOCK(p); + PROC_LOCK(p); FOREACH_THREAD_IN_PROC(p, td) { awake = 0; thread_lock(td); @@ -448,7 +448,7 @@ schedcpu(void) resetpriority_thread(td); thread_unlock(td); } - PROC_SUNLOCK(p); + PROC_UNLOCK(p); } sx_sunlock(&allproc_lock); } @@ -629,7 +629,7 @@ sched_exit(struct proc *p, struct thread CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d", td, td->td_proc->p_comm, td->td_priority); - PROC_SLOCK_ASSERT(p, MA_OWNED); + PROC_LOCK_ASSERT(p, MA_OWNED); sched_exit_thread(FIRST_THREAD_IN_PROC(p), td); } @@ -670,7 +670,6 @@ sched_nice(struct proc *p, int nice) struct thread *td; PROC_LOCK_ASSERT(p, MA_OWNED); - PROC_SLOCK_ASSERT(p, MA_OWNED); p->p_nice = nice; FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); Modified: user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/sched_ule.c Tue May 19 05:17:41 2009 (r192371) @@ -1971,7 +1971,6 @@ sched_nice(struct proc *p, int nice) struct thread *td; PROC_LOCK_ASSERT(p, MA_OWNED); - PROC_SLOCK_ASSERT(p, MA_OWNED); p->p_nice = nice; FOREACH_THREAD_IN_PROC(p, td) { @@ -2132,7 +2131,7 @@ sched_exit(struct proc *p, struct thread CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d", child, child->td_proc->p_comm, child->td_priority); - PROC_SLOCK_ASSERT(p, MA_OWNED); + PROC_LOCK_ASSERT(p, MA_OWNED); td = FIRST_THREAD_IN_PROC(p); sched_exit_thread(td, child); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 05:17:41 2009 (r192371) @@ -585,14 +585,13 @@ ioctl(struct thread *td, struct ioctl_ar return (ENOTTY); if (size > 0) { - if (!(com & IOC_VOID)) - data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK); - else { + if (com & IOC_VOID) { /* Integer argument. */ arg = (intptr_t)uap->data; data = (void *)&arg; size = 0; - } + } else + data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK); } else data = (void *)&uap->data; if (com & IOC_IN) { @@ -957,21 +956,8 @@ poll(td, uap) size_t ni; nfds = uap->nfds; - - /* - * This is kinda bogus. We have fd limits, but that is not - * really related to the size of the pollfd array. Make sure - * we let the process use at least FD_SETSIZE entries and at - * least enough for the current limits. We want to be reasonably - * safe, but not overly restrictive. - */ - PROC_LOCK(td->td_proc); - if ((nfds > lim_cur(td->td_proc, RLIMIT_NOFILE)) && - (nfds > FD_SETSIZE)) { - PROC_UNLOCK(td->td_proc); + if (nfds > maxfilesperproc && nfds > FD_SETSIZE) return (EINVAL); - } - PROC_UNLOCK(td->td_proc); ni = nfds * sizeof(struct pollfd); if (ni > sizeof(smallbits)) bits = malloc(ni, M_TEMP, M_WAITOK); Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c Tue May 19 05:17:41 2009 (r192371) @@ -528,12 +528,10 @@ kern_ptrace(struct thread *td, int req, sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td2) { if (td2->td_tid == pid) break; } - PROC_SUNLOCK(p); if (td2 != NULL) break; /* proc lock held */ PROC_UNLOCK(p); @@ -789,7 +787,6 @@ kern_ptrace(struct thread *td, int req, thread_unlock(td2); td2->td_xsig = data; - PROC_SLOCK(p); if (req == PT_DETACH) { struct thread *td3; FOREACH_THREAD_IN_PROC(p, td3) { @@ -803,11 +800,7 @@ kern_ptrace(struct thread *td, int req, * you should use PT_SUSPEND to suspend it before * continuing process. */ -#ifdef KSE - PROC_SUNLOCK(p); - thread_continued(p); PROC_SLOCK(p); -#endif p->p_flag &= ~(P_STOPPED_TRACE|P_STOPPED_SIG|P_WAITED); thread_unsuspend(p); PROC_SUNLOCK(p); @@ -972,13 +965,11 @@ kern_ptrace(struct thread *td, int req, buf = malloc(num * sizeof(lwpid_t), M_TEMP, M_WAITOK); tmp = 0; PROC_LOCK(p); - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td2) { if (tmp >= num) break; buf[tmp++] = td2->td_tid; } - PROC_SUNLOCK(p); PROC_UNLOCK(p); error = copyout(buf, addr, tmp * sizeof(lwpid_t)); free(buf, M_TEMP); Modified: user/kmacy/releng_7_2_fcs/sys/kern/tty.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/tty.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/kern/tty.c Tue May 19 05:17:41 2009 (r192371) @@ -2582,7 +2582,7 @@ ttyinfo(struct tty *tp) if (proc_compare(pick, p)) pick = p; - PROC_SLOCK(pick); + PROC_LOCK(pick); picktd = NULL; td = FIRST_THREAD_IN_PROC(pick); FOREACH_THREAD_IN_PROC(pick, td) @@ -2618,7 +2618,7 @@ ttyinfo(struct tty *tp) rss = 0; else rss = pgtok(vmspace_resident_count(pick->p_vmspace)); - PROC_SUNLOCK(pick); + PROC_UNLOCK(pick); PROC_LOCK(pick); PGRP_UNLOCK(tp->t_pgrp); rufetchcalc(pick, &ru, &utime, &stime); @@ -2747,12 +2747,12 @@ proc_compare(struct proc *p1, struct pro * Fetch various stats about these processes. After we drop the * lock the information could be stale but the race is unimportant. */ - PROC_SLOCK(p1); + PROC_LOCK(p1); runa = proc_sum(p1, &esta); - PROC_SUNLOCK(p1); - PROC_SLOCK(p2); + PROC_UNLOCK(p1); + PROC_LOCK(p2); runb = proc_sum(p2, &estb); - PROC_SUNLOCK(p2); + PROC_UNLOCK(p2); /* * see if at least one of them is runnable Modified: user/kmacy/releng_7_2_fcs/sys/sys/proc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/proc.h Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/sys/proc.h Tue May 19 05:17:41 2009 (r192371) @@ -493,7 +493,7 @@ struct rusage_ext { */ struct proc { LIST_ENTRY(proc) p_list; /* (d) List of all processes. */ - TAILQ_HEAD(, thread) p_threads; /* (j) all threads. */ + TAILQ_HEAD(, thread) p_threads; /* (c) all threads. */ TAILQ_HEAD(, kse_upcall) p_upcalls; /* (j) All upcalls in the proc. */ struct mtx p_slock; /* process spin lock */ struct ucred *p_ucred; /* (c) Process owner's identity. */ @@ -530,7 +530,7 @@ struct proc { #define p_startzero p_oppid pid_t p_oppid; /* (c + e) Save ppid in ptrace. XXX */ struct vmspace *p_vmspace; /* (b) Address space. */ - u_int p_swtick; /* (j) Tick when swapped in or out. */ + u_int p_swtick; /* (c) Tick when swapped in or out. */ struct itimerval p_realtimer; /* (c) Alarm timer. */ struct rusage p_ru; /* (a) Exit information. */ struct rusage_ext p_rux; /* (cj) Internal resource usage. */ @@ -576,14 +576,14 @@ struct proc { struct sysentvec *p_sysent; /* (b) Syscall dispatch info. */ struct pargs *p_args; /* (c) Process arguments. */ rlim_t p_cpulimit; /* (c) Current CPU limit in seconds. */ - signed char p_nice; /* (c + j) Process "nice" value. */ + signed char p_nice; /* (c) Process "nice" value. */ int p_fibnum; /* in this routing domain XXX MRT */ /* End area that is copied on creation. */ #define p_endcopy p_xstat u_short p_xstat; /* (c) Exit status; also stop sig. */ struct knlist p_klist; /* (c) Knotes attached to this proc. */ - int p_numthreads; /* (j) Number of threads. */ + int p_numthreads; /* (c) Number of threads. */ struct mdproc p_md; /* Any machine-dependent fields. */ struct callout p_itcallout; /* (h + c) Interval timer callout. */ u_short p_acflag; /* (c) Accounting flags. */ Modified: user/kmacy/releng_7_2_fcs/sys/ufs/ffs/ffs_snapshot.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/ufs/ffs/ffs_snapshot.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/ufs/ffs/ffs_snapshot.c Tue May 19 05:17:41 2009 (r192371) @@ -397,10 +397,8 @@ restart: p = td->td_proc; PROC_LOCK(p); - PROC_SLOCK(p); saved_nice = p->p_nice; sched_nice(p, 0); - PROC_SUNLOCK(p); PROC_UNLOCK(p); } /* @@ -820,9 +818,7 @@ out: p = td->td_proc; PROC_LOCK(p); - PROC_SLOCK(p); sched_nice(td->td_proc, saved_nice); - PROC_SUNLOCK(p); PROC_UNLOCK(td->td_proc); } UFS_LOCK(ump); Modified: user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/vm/vm_glue.c Tue May 19 05:17:41 2009 (r192371) @@ -334,6 +334,7 @@ vm_thread_new(struct thread *td, int pag * Allocate an object for the kstack. */ ksobj = vm_object_allocate(OBJT_DEFAULT, pages); + /* * Get a kernel virtual address for this thread's kstack. */ @@ -641,10 +642,8 @@ faultin(p) FOREACH_THREAD_IN_PROC(p, td) vm_thread_swapin(td); PROC_LOCK(p); - PROC_SLOCK(p); swapclear(p); p->p_swtick = ticks; - PROC_SUNLOCK(p); wakeup(&p->p_flag); @@ -695,7 +694,6 @@ loop: continue; } swtime = (ticks - p->p_swtick) / hz; - PROC_SLOCK(p); FOREACH_THREAD_IN_PROC(p, td) { /* * An otherwise runnable thread of a process @@ -721,7 +719,6 @@ loop: } thread_unlock(td); } - PROC_SUNLOCK(p); PROC_UNLOCK(p); } sx_sunlock(&allproc_lock); @@ -838,7 +835,7 @@ retry: if (p->p_lock != 0 || (p->p_flag & (P_STOPPED_SINGLE|P_TRACED|P_SYSTEM|P_WEXIT) ) != 0) { - goto nextproc2; + goto nextproc; } /* * only aiod changes vmspace, however it will be @@ -846,7 +843,7 @@ retry: * for P_SYSTEM */ if ((p->p_flag & (P_INMEM|P_SWAPPINGOUT|P_SWAPPINGIN)) != P_INMEM) - goto nextproc2; + goto nextproc; switch (p->p_state) { default: @@ -855,7 +852,6 @@ retry: break; case PRS_NORMAL: - PROC_SLOCK(p); /* * do not swapout a realtime process * Check all the thread groups.. @@ -917,17 +913,14 @@ retry: (minslptime > swap_idle_threshold2))) { if (swapout(p) == 0) didswap++; - PROC_SUNLOCK(p); PROC_UNLOCK(p); vm_map_unlock(&vm->vm_map); vmspace_free(vm); sx_sunlock(&allproc_lock); goto retry; } -nextproc: - PROC_SUNLOCK(p); } -nextproc2: +nextproc: PROC_UNLOCK(p); vm_map_unlock(&vm->vm_map); nextproc1: @@ -950,7 +943,6 @@ swapclear(p) struct thread *td; PROC_LOCK_ASSERT(p, MA_OWNED); - PROC_SLOCK_ASSERT(p, MA_OWNED); FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); @@ -981,7 +973,6 @@ swapout(p) struct thread *td; PROC_LOCK_ASSERT(p, MA_OWNED); - PROC_SLOCK_ASSERT(p, MA_OWNED | MA_NOTRECURSED); #if defined(SWAP_DEBUG) printf("swapping out %d\n", p->p_pid); #endif @@ -1016,7 +1007,6 @@ swapout(p) } td = FIRST_THREAD_IN_PROC(p); ++td->td_ru.ru_nswap; - PROC_SUNLOCK(p); PROC_UNLOCK(p); /* @@ -1029,7 +1019,6 @@ swapout(p) PROC_LOCK(p); p->p_flag &= ~P_SWAPPINGOUT; - PROC_SLOCK(p); p->p_swtick = ticks; return (0); } Modified: user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/vm/vm_meter.c Tue May 19 05:17:41 2009 (r192371) @@ -130,13 +130,16 @@ vmtotal(SYSCTL_HANDLER_ARGS) FOREACH_PROC_IN_SYSTEM(p) { if (p->p_flag & P_SYSTEM) continue; + PROC_LOCK(p); PROC_SLOCK(p); switch (p->p_state) { case PRS_NEW: PROC_SUNLOCK(p); + PROC_UNLOCK(p); continue; break; default: + PROC_SUNLOCK(p); FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); switch (td->td_state) { @@ -164,7 +167,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) thread_unlock(td); } } - PROC_SUNLOCK(p); + PROC_UNLOCK(p); /* * Note active objects. */ Modified: user/kmacy/releng_7_2_fcs/sys/vm/vm_pageout.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/vm/vm_pageout.c Tue May 19 04:47:30 2009 (r192370) +++ user/kmacy/releng_7_2_fcs/sys/vm/vm_pageout.c Tue May 19 05:17:41 2009 (r192371) @@ -1205,7 +1205,6 @@ unlock_and_continue: * If the process is in a non-running type state, * don't touch it. Check all the threads individually. */ - PROC_SLOCK(p); breakout = 0; FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); @@ -1218,7 +1217,6 @@ unlock_and_continue: } thread_unlock(td); } - PROC_SUNLOCK(p); if (breakout) { PROC_UNLOCK(p); continue; @@ -1248,9 +1246,7 @@ unlock_and_continue: sx_sunlock(&allproc_lock); if (bigproc != NULL) { killproc(bigproc, "out of swap space"); - PROC_SLOCK(bigproc); sched_nice(bigproc, PRIO_MIN); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue May 19 05:36:11 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E62611065673; Tue, 19 May 2009 05:36:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3AEB8FC14; Tue, 19 May 2009 05:36:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J5aAJD086453; Tue, 19 May 2009 05:36:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J5aAZP086448; Tue, 19 May 2009 05:36:10 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905190536.n4J5aAZP086448@svn.freebsd.org> From: Kip Macy Date: Tue, 19 May 2009 05:36:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192372 - in user/kmacy/releng_7_2_fcs/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 05:36:11 -0000 Author: kmacy Date: Tue May 19 05:36:10 2009 New Revision: 192372 URL: http://svn.freebsd.org/changeset/base/192372 Log: merge changes to support lockless fget 187677,187682,187693,187996,189708,192080 Fix errors introduced when I rewrote select. - Restructure selscan() and selrescan() to avoid producing extra selfps when we have a fd in multiple sets. As described below multiple selfps may still exist for other reasons. - Make selrescan() tolerate multiple selfds for a given descriptor set since sockets use two selinfos per fd. If an event on each selinfo fires selrescan() will see the descriptor twice. This could result in select() returning 2x the number of fds actually existing in fd sets. Reported by: mgleason@ncftp.com - bit has to be fd_mask to work properly on 64bit platforms. Constants must also be cast even though the result ultimately is promoted to 64bit. - Correct a loop index upper bound in selscan() Fix select on platforms where sizeof(long) != sizeof(int). This used to work by accident before the cleanup done in revision 187693. Approved by: kan (mentor) - Implement a lockless file descriptor lookup algorithm in fget_unlocked(). - Save old file descriptor tables created on expansion until the entire descriptor table is freed so that pointers may be followed without regard for expanders. - Mark the file zone as NOFREE so we may attempt to reference potentially freed files. - Convert several fget_locked() users to fget_unlocked(). This requires us to manage reference counts explicitly but reduces locking overhead in the common case. Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c user/kmacy/releng_7_2_fcs/sys/kern/vfs_syscalls.c user/kmacy/releng_7_2_fcs/sys/sys/filedesc.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Tue May 19 05:17:41 2009 (r192371) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Tue May 19 05:36:10 2009 (r192372) @@ -123,12 +123,24 @@ static void fdused(struct filedesc *fdp, #define OFILESIZE (sizeof(struct file *) + sizeof(char)) /* + * Storage to hold unused ofiles that need to be reclaimed. + */ +struct freetable { + struct file **ft_table; + SLIST_ENTRY(freetable) ft_next; +}; + +/* * Basic allocation of descriptors: * one of the above, plus arrays for NDFILE descriptors. */ struct filedesc0 { struct filedesc fd_fd; /* + * ofiles which need to be reclaimed on free. + */ + SLIST_HEAD(,freetable) fd_free; + /* * These arrays are used when the number of open files is * <= NDFILE, and are then pointed to by the pointers above. */ @@ -1282,7 +1294,10 @@ out: static void fdgrowtable(struct filedesc *fdp, int nfd) { + struct filedesc0 *fdp0; + struct freetable *fo; struct file **ntable; + struct file **otable; char *nfileflags; int nnfiles, onfiles; NDSLOTTYPE *nmap; @@ -1301,7 +1316,7 @@ fdgrowtable(struct filedesc *fdp, int nf /* allocate a new table and (if required) new bitmaps */ FILEDESC_XUNLOCK(fdp); - MALLOC(ntable, struct file **, nnfiles * OFILESIZE, + ntable = malloc((nnfiles * OFILESIZE) + sizeof(struct freetable), M_FILEDESC, M_ZERO | M_WAITOK); nfileflags = (char *)&ntable[nnfiles]; if (NDSLOTS(nnfiles) > NDSLOTS(onfiles)) @@ -1325,10 +1340,20 @@ fdgrowtable(struct filedesc *fdp, int nf } bcopy(fdp->fd_ofiles, ntable, onfiles * sizeof(*ntable)); bcopy(fdp->fd_ofileflags, nfileflags, onfiles); - if (onfiles > NDFILE) - free(fdp->fd_ofiles, M_FILEDESC); - fdp->fd_ofiles = ntable; + otable = fdp->fd_ofiles; fdp->fd_ofileflags = nfileflags; + fdp->fd_ofiles = ntable; + /* + * We must preserve ofiles until the process exits because we can't + * be certain that no threads have references to the old table via + * _fget(). + */ + if (onfiles > NDFILE) { + fo = (struct freetable *)&otable[onfiles]; + fdp0 = (struct filedesc0 *)fdp; + fo->ft_table = otable; + SLIST_INSERT_HEAD(&fdp0->fd_free, fo, ft_next); + } if (NDSLOTS(nnfiles) > NDSLOTS(onfiles)) { bcopy(fdp->fd_map, nmap, NDSLOTS(onfiles) * sizeof(*nmap)); if (NDSLOTS(onfiles) > NDSLOTS(NDFILE)) @@ -1526,6 +1551,8 @@ fdhold(struct proc *p) static void fddrop(struct filedesc *fdp) { + struct filedesc0 *fdp0; + struct freetable *ft; int i; mtx_lock(&fdesc_mtx); @@ -1535,7 +1562,12 @@ fddrop(struct filedesc *fdp) return; FILEDESC_LOCK_DESTROY(fdp); - FREE(fdp, M_FILEDESC); + fdp0 = (struct filedesc0 *)fdp; + while ((ft = SLIST_FIRST(&fdp0->fd_free)) != NULL) { + SLIST_REMOVE_HEAD(&fdp0->fd_free, ft_next); + free(ft->ft_table, M_FILEDESC); + } + free(fdp, M_FILEDESC); } /* @@ -2036,6 +2068,38 @@ finit(struct file *fp, u_int flag, short atomic_store_rel_ptr((volatile uintptr_t *)&fp->f_ops, (uintptr_t)ops); } +struct file * +fget_unlocked(struct filedesc *fdp, int fd) +{ + struct file *fp; + u_int count; + + if (fd < 0 || fd >= fdp->fd_nfiles) + return (NULL); + /* + * Fetch the descriptor locklessly. We avoid fdrop() races by + * never raising a refcount above 0. To accomplish this we have + * to use a cmpset loop rather than an atomic_add. The descriptor + * must be re-verified once we acquire a reference to be certain + * that the identity is still correct and we did not lose a race + * due to preemption. + */ + for (;;) { + fp = fdp->fd_ofiles[fd]; + if (fp == NULL) + break; + count = fp->f_count; + if (count == 0) + continue; + if (atomic_cmpset_int(&fp->f_count, count, count + 1) != 1) + continue; + if (fp == ((struct file *volatile*)fdp->fd_ofiles)[fd]) + break; + fdrop(fp, curthread); + } + + return (fp); +} /* * Extract the file pointer associated with the specified descriptor for the @@ -2043,19 +2107,12 @@ finit(struct file *fp, u_int flag, short * * If the descriptor doesn't exist, EBADF is returned. * - * If the descriptor exists but doesn't match 'flags' then return EBADF for - * read attempts and EINVAL for write attempts. - * - * If 'hold' is set (non-zero) the file's refcount will be bumped on return. - * It should be dropped with fdrop(). If it is not set, then the refcount - * will not be bumped however the thread's filedesc struct will be returned - * locked (for fgetsock). - * * If an error occured the non-zero error is returned and *fpp is set to - * NULL. Otherwise *fpp is set and zero is returned. + * NULL. Otherwise *fpp is held and set and zero is returned. Caller is + * responsible for fdrop(). */ static __inline int -_fget(struct thread *td, int fd, struct file **fpp, int flags, int hold) +_fget(struct thread *td, int fd, struct file **fpp, int flags) { struct filedesc *fdp; struct file *fp; @@ -2063,29 +2120,22 @@ _fget(struct thread *td, int fd, struct *fpp = NULL; if (td == NULL || (fdp = td->td_proc->p_fd) == NULL) return (EBADF); - FILEDESC_SLOCK(fdp); - if ((fp = fget_locked(fdp, fd)) == NULL || fp->f_ops == &badfileops) { - FILEDESC_SUNLOCK(fdp); + if ((fp = fget_unlocked(fdp, fd)) == NULL) + return (EBADF); + if (fp->f_ops == &badfileops) { + fdrop(fp, td); return (EBADF); } - /* * FREAD and FWRITE failure return EBADF as per POSIX. * * Only one flag, or 0, may be specified. */ - if (flags == FREAD && (fp->f_flag & FREAD) == 0) { - FILEDESC_SUNLOCK(fdp); - return (EBADF); - } - if (flags == FWRITE && (fp->f_flag & FWRITE) == 0) { - FILEDESC_SUNLOCK(fdp); + if ((flags == FREAD && (fp->f_flag & FREAD) == 0) || + (flags == FWRITE && (fp->f_flag & FWRITE) == 0)) { + fdrop(fp, td); return (EBADF); } - if (hold) { - fhold(fp); - FILEDESC_SUNLOCK(fdp); - } *fpp = fp; return (0); } @@ -2094,21 +2144,21 @@ int fget(struct thread *td, int fd, struct file **fpp) { - return(_fget(td, fd, fpp, 0, 1)); + return(_fget(td, fd, fpp, 0)); } int fget_read(struct thread *td, int fd, struct file **fpp) { - return(_fget(td, fd, fpp, FREAD, 1)); + return(_fget(td, fd, fpp, FREAD)); } int fget_write(struct thread *td, int fd, struct file **fpp) { - return(_fget(td, fd, fpp, FWRITE, 1)); + return(_fget(td, fd, fpp, FWRITE)); } /* @@ -2125,7 +2175,7 @@ _fgetvp(struct thread *td, int fd, struc int error; *vpp = NULL; - if ((error = _fget(td, fd, &fp, flags, 0)) != 0) + if ((error = _fget(td, fd, &fp, flags)) != 0) return (error); if (fp->f_vnode == NULL) { error = EINVAL; @@ -2133,7 +2183,8 @@ _fgetvp(struct thread *td, int fd, struc *vpp = fp->f_vnode; vref(*vpp); } - FILEDESC_SUNLOCK(td->td_proc->p_fd); + fdrop(fp, td); + return (error); } @@ -2180,7 +2231,7 @@ fgetsock(struct thread *td, int fd, stru *spp = NULL; if (fflagp != NULL) *fflagp = 0; - if ((error = _fget(td, fd, &fp, 0, 0)) != 0) + if ((error = _fget(td, fd, &fp, 0)) != 0) return (error); if (fp->f_type != DTYPE_SOCKET) { error = ENOTSOCK; @@ -2192,7 +2243,8 @@ fgetsock(struct thread *td, int fd, stru soref(*spp); SOCK_UNLOCK(*spp); } - FILEDESC_SUNLOCK(td->td_proc->p_fd); + fdrop(fp, td); + return (error); } @@ -3123,7 +3175,7 @@ filelistinit(void *dummy) { file_zone = uma_zcreate("Files", sizeof(struct file), NULL, NULL, - NULL, NULL, UMA_ALIGN_PTR, 0); + NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); mtx_init(&sigio_lock, "sigio lock", NULL, MTX_DEF); mtx_init(&fdesc_mtx, "fdesc", NULL, MTX_DEF); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 05:17:41 2009 (r192371) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_generic.c Tue May 19 05:36:10 2009 (r192372) @@ -838,6 +838,71 @@ done: return (error); } +/* + * Convert a select bit set to poll flags. + * + * The backend always returns POLLHUP/POLLERR if appropriate and we + * return this as a set bit in any set. + */ +static int select_flags[3] = { + POLLRDNORM | POLLHUP | POLLERR, + POLLWRNORM | POLLHUP | POLLERR, + POLLRDBAND | POLLHUP | POLLERR +}; + +/* + * Compute the fo_poll flags required for a fd given by the index and + * bit position in the fd_mask array. + */ +static __inline int +selflags(fd_mask **ibits, int idx, fd_mask bit) +{ + int flags; + int msk; + + flags = 0; + for (msk = 0; msk < 3; msk++) { + if (ibits[msk] == NULL) + continue; + if ((ibits[msk][idx] & bit) == 0) + continue; + flags |= select_flags[msk]; + } + return (flags); +} + +/* + * Set the appropriate output bits given a mask of fired events and the + * input bits originally requested. + */ +static __inline int +selsetbits(fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events) +{ + int msk; + int n; + + n = 0; + for (msk = 0; msk < 3; msk++) { + if ((events & select_flags[msk]) == 0) + continue; + if (ibits[msk] == NULL) + continue; + if ((ibits[msk][idx] & bit) == 0) + continue; + /* + * XXX Check for a duplicate set. This can occur because a + * socket calls selrecord() twice for each poll() call + * resulting in two selfds per real fd. selrescan() will + * call selsetbits twice as a result. + */ + if ((obits[msk][idx] & bit) != 0) + continue; + obits[msk][idx] |= bit; + n++; + } + + return (n); +} /* * Traverse the list of fds attached to this thread's seltd and check for @@ -846,19 +911,18 @@ done: static int selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits) { + struct filedesc *fdp; + struct selinfo *si; struct seltd *stp; struct selfd *sfp; struct selfd *sfn; - struct selinfo *si; struct file *fp; - int msk, fd; - int n = 0; - /* Note: backend also returns POLLHUP/POLLERR if appropriate. */ - static int flag[3] = { POLLRDNORM, POLLWRNORM, POLLRDBAND }; - struct filedesc *fdp = td->td_proc->p_fd; + fd_mask bit; + int fd, ev, n, idx; + fdp = td->td_proc->p_fd; stp = td->td_sel; - FILEDESC_SLOCK(fdp); + n = 0; STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) { fd = (int)(uintptr_t)sfp->sf_cookie; si = sfp->sf_si; @@ -866,24 +930,15 @@ selrescan(struct thread *td, fd_mask **i /* If the selinfo wasn't cleared the event didn't fire. */ if (si != NULL) continue; - if ((fp = fget_locked(fdp, fd)) == NULL) { - FILEDESC_SUNLOCK(fdp); + if ((fp = fget_unlocked(fdp, fd)) == NULL) return (EBADF); - } - for (msk = 0; msk < 3; msk++) { - if (ibits[msk] == NULL) - continue; - if ((ibits[msk][fd/NFDBITS] & - ((fd_mask) 1 << (fd % NFDBITS))) == 0) - continue; - if (fo_poll(fp, flag[msk], td->td_ucred, td)) { - obits[msk][(fd)/NFDBITS] |= - ((fd_mask)1 << ((fd) % NFDBITS)); - n++; - } - } + idx = fd / NFDBITS; + bit = (fd_mask)1 << (fd % NFDBITS); + ev = fo_poll(fp, selflags(ibits, idx, bit), td->td_ucred, td); + fdrop(fp, td); + if (ev != 0) + n += selsetbits(ibits, obits, idx, bit, ev); } - FILEDESC_SUNLOCK(fdp); stp->st_flags = 0; td->td_retval[0] = n; return (0); @@ -899,39 +954,31 @@ selscan(td, ibits, obits, nfd) fd_mask **ibits, **obits; int nfd; { - int msk, i, fd; - fd_mask bits; + struct filedesc *fdp; struct file *fp; - int n = 0; - /* Note: backend also returns POLLHUP/POLLERR if appropriate. */ - static int flag[3] = { POLLRDNORM, POLLWRNORM, POLLRDBAND }; - struct filedesc *fdp = td->td_proc->p_fd; + fd_mask bit; + int ev, flags, end, fd; + int n, idx; - FILEDESC_SLOCK(fdp); - for (msk = 0; msk < 3; msk++) { - if (ibits[msk] == NULL) - continue; - for (i = 0; i < nfd; i += NFDBITS) { - bits = ibits[msk][i/NFDBITS]; - /* ffs(int mask) not portable, fd_mask is long */ - for (fd = i; bits && fd < nfd; fd++, bits >>= 1) { - if (!(bits & 1)) - continue; - if ((fp = fget_locked(fdp, fd)) == NULL) { - FILEDESC_SUNLOCK(fdp); - return (EBADF); - } - selfdalloc(td, (void *)(uintptr_t)fd); - if (fo_poll(fp, flag[msk], td->td_ucred, - td)) { - obits[msk][(fd)/NFDBITS] |= - ((fd_mask)1 << ((fd) % NFDBITS)); - n++; - } - } + fdp = td->td_proc->p_fd; + n = 0; + for (idx = 0, fd = 0; fd < nfd; idx++) { + end = imin(fd + NFDBITS, nfd); + for (bit = 1; fd < end; bit <<= 1, fd++) { + /* Compute the list of events we're interested in. */ + flags = selflags(ibits, idx, bit); + if (flags == 0) + continue; + if ((fp = fget_unlocked(fdp, fd)) == NULL) + return (EBADF); + selfdalloc(td, (void *)(uintptr_t)fd); + ev = fo_poll(fp, flags, td->td_ucred, td); + fdrop(fp, td); + if (ev != 0) + n += selsetbits(ibits, obits, idx, bit, ev); } } - FILEDESC_SUNLOCK(fdp); + td->td_retval[0] = n; return (0); } @@ -1084,7 +1131,6 @@ pollrescan(struct thread *td) return (0); } - static int pollscan(td, fds, nfd) struct thread *td; Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Tue May 19 05:17:41 2009 (r192371) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_syscalls.c Tue May 19 05:36:10 2009 (r192372) @@ -121,23 +121,16 @@ getsock(struct filedesc *fdp, int fd, st int error; fp = NULL; - if (fdp == NULL) + if (fdp == NULL || (fp = fget_unlocked(fdp, fd)) == NULL) { error = EBADF; - else { - FILEDESC_SLOCK(fdp); - fp = fget_locked(fdp, fd); - if (fp == NULL) - error = EBADF; - else if (fp->f_type != DTYPE_SOCKET) { - fp = NULL; - error = ENOTSOCK; - } else { - fhold(fp); - if (fflagp != NULL) - *fflagp = fp->f_flag; - error = 0; - } - FILEDESC_SUNLOCK(fdp); + } else if (fp->f_type != DTYPE_SOCKET) { + fdrop(fp, curthread); + fp = NULL; + error = ENOTSOCK; + } else { + if (fflagp != NULL) + *fflagp = fp->f_flag; + error = 0; } *fpp = fp; return (error); Modified: user/kmacy/releng_7_2_fcs/sys/kern/vfs_syscalls.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/vfs_syscalls.c Tue May 19 05:17:41 2009 (r192371) +++ user/kmacy/releng_7_2_fcs/sys/kern/vfs_syscalls.c Tue May 19 05:36:10 2009 (r192372) @@ -3979,22 +3979,13 @@ getvnode(fdp, fd, fpp) int error; struct file *fp; + error = 0; fp = NULL; - if (fdp == NULL) + if (fdp == NULL || (fp = fget_unlocked(fdp, fd)) == NULL) error = EBADF; - else { - FILEDESC_SLOCK(fdp); - if ((u_int)fd >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[fd]) == NULL) - error = EBADF; - else if (fp->f_vnode == NULL) { - fp = NULL; - error = EINVAL; - } else { - fhold(fp); - error = 0; - } - FILEDESC_SUNLOCK(fdp); + else if (fp->f_vnode == NULL) { + error = EINVAL; + fdrop(fp, curthread); } *fpp = fp; return (error); Modified: user/kmacy/releng_7_2_fcs/sys/sys/filedesc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/filedesc.h Tue May 19 05:17:41 2009 (r192371) +++ user/kmacy/releng_7_2_fcs/sys/sys/filedesc.h Tue May 19 05:36:10 2009 (r192372) @@ -129,6 +129,10 @@ int getvnode(struct filedesc *fdp, int f void mountcheckdirs(struct vnode *olddp, struct vnode *newdp); void setugidsafety(struct thread *td); +/* Return a referenced file from an unlocked descriptor. */ +struct file *fget_unlocked(struct filedesc *fdp, int fd); + +/* Requires a FILEDESC_{S,X}LOCK held and returns without a ref. */ static __inline struct file * fget_locked(struct filedesc *fdp, int fd) { From owner-svn-src-user@FreeBSD.ORG Wed May 20 04:26:20 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3AEB8106566B; Wed, 20 May 2009 04:26:20 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 29F318FC1A; Wed, 20 May 2009 04:26:20 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K4QK6B018986; Wed, 20 May 2009 04:26:20 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K4QKGl018985; Wed, 20 May 2009 04:26:20 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200426.n4K4QKGl018985@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 04:26:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192420 - user/kmacy/releng_7_2_fcs/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 04:26:20 -0000 Author: kmacy Date: Wed May 20 04:26:19 2009 New Revision: 192420 URL: http://svn.freebsd.org/changeset/base/192420 Log: remove old SCSI controllers Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Wed May 20 03:49:16 2009 (r192419) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Wed May 20 04:26:19 2009 (r192420) @@ -101,12 +101,6 @@ device atapist # ATAPI tape drives options ATA_STATIC_ID # Static device numbering # SCSI Controllers -device ahc # AHA2940 and onboard AIC7xxx devices -options AHC_REG_PRETTY_PRINT # Print register bitfields in debug - # output. Adds ~128k to driver. -device ahd # AHA39320/29320 and onboard AIC79xx devices -options AHD_REG_PRETTY_PRINT # Print register bitfields in debug - # output. Adds ~215k to driver. device amd # AMD 53C974 (Tekram DC-390(T)) device hptiop # Highpoint RocketRaid 3xxx series device isp # Qlogic family From owner-svn-src-user@FreeBSD.ORG Wed May 20 05:39:41 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 853161065670; Wed, 20 May 2009 05:39:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73C048FC08; Wed, 20 May 2009 05:39:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K5dfvd020394; Wed, 20 May 2009 05:39:41 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K5dfB2020392; Wed, 20 May 2009 05:39:41 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200539.n4K5dfB2020392@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 05:39:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192421 - in user/kmacy/releng_7_2_fcs/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 05:39:41 -0000 Author: kmacy Date: Wed May 20 05:39:41 2009 New Revision: 192421 URL: http://svn.freebsd.org/changeset/base/192421 Log: Add new kthread_create_pri function which allows users to pass a priority when creating a thread Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c user/kmacy/releng_7_2_fcs/sys/sys/kthread.h Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 04:26:19 2009 (r192420) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 05:39:41 2009 (r192421) @@ -72,12 +72,11 @@ kproc_start(udata) * flags are flags to fork1 (in unistd.h) * fmt and following will be *printf'd into (*newpp)->p_comm (for ps, etc.). */ -int -kthread_create(void (*func)(void *), void *arg, - struct proc **newpp, int flags, int pages, const char *fmt, ...) +static int +kthread_create_pri_v(void (*func)(void *), void *arg, + struct proc **newpp, int flags, int pages, int prio, const char *comm) { int error; - va_list ap; struct thread *td; struct proc *p2; @@ -101,19 +100,18 @@ kthread_create(void (*func)(void *), voi mtx_unlock(&p2->p_sigacts->ps_mtx); PROC_UNLOCK(p2); - /* set up arg0 for 'ps', et al */ - va_start(ap, fmt); - vsnprintf(p2->p_comm, sizeof(p2->p_comm), fmt, ap); - va_end(ap); + memcpy(p2->p_comm, comm, sizeof(p2->p_comm)); + td = FIRST_THREAD_IN_PROC(p2); + memcpy(td->td_name, comm, sizeof(td->td_name)); /* call the processes' main()... */ - td = FIRST_THREAD_IN_PROC(p2); cpu_set_fork_handler(td, func, arg); TD_SET_CAN_RUN(td); /* Delay putting it on the run queue until now. */ if (!(flags & RFSTOPPED)) { thread_lock(td); + sched_prio(td, prio); sched_add(td, SRQ_BORING); thread_unlock(td); } @@ -121,6 +119,35 @@ kthread_create(void (*func)(void *), voi return 0; } +int +kthread_create_pri(void (*func)(void *), void *arg, + struct proc **newpp, int flags, int pages, int prio, const char *fmt, ...) +{ + va_list ap; + char p_comm[MAXCOMLEN + 1]; /* (b) Process name. XXX */ + + /* set up arg0 for 'ps', et al */ + va_start(ap, fmt); + vsnprintf(p_comm, sizeof(p_comm), fmt, ap); + va_end(ap); + + return (kthread_create_pri_v(func, arg, newpp, flags, pages, prio, p_comm)); +} + +int +kthread_create(void (*func)(void *), void *arg, + struct proc **newpp, int flags, int pages, const char *fmt, ...) +{ + va_list ap; + char p_comm[MAXCOMLEN + 1]; /* (b) Process name. XXX */ + + /* set up arg0 for 'ps', et al */ + va_start(ap, fmt); + vsnprintf(p_comm, sizeof(p_comm), fmt, ap); + va_end(ap); + return (kthread_create_pri_v(func, arg, newpp, flags, pages, 0, p_comm)); +} + void kthread_exit(int ecode) { Modified: user/kmacy/releng_7_2_fcs/sys/sys/kthread.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/kthread.h Wed May 20 04:26:19 2009 (r192420) +++ user/kmacy/releng_7_2_fcs/sys/sys/kthread.h Wed May 20 05:39:41 2009 (r192421) @@ -46,6 +46,8 @@ void kproc_shutdown(void *, int); void kproc_start(const void *); int kthread_create(void (*)(void *), void *, struct proc **, int flags, int pages, const char *, ...) __printflike(6, 7); +int kthread_create_pri(void (*)(void *), void *, struct proc **, + int flags, int pages, int prio, const char *, ...) __printflike(7, 8); void kthread_exit(int) __dead2; int kthread_resume(struct proc *); /* XXXKSE */ int kthread_suspend(struct proc *, int); /* XXXKSE */ From owner-svn-src-user@FreeBSD.ORG Wed May 20 05:42:36 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E63AD1065677; Wed, 20 May 2009 05:42:36 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4AC78FC17; Wed, 20 May 2009 05:42:36 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K5gaoM020492; Wed, 20 May 2009 05:42:36 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K5gakx020491; Wed, 20 May 2009 05:42:36 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200542.n4K5gakx020491@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 05:42:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192422 - user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 05:42:37 -0000 Author: kmacy Date: Wed May 20 05:42:36 2009 New Revision: 192422 URL: http://svn.freebsd.org/changeset/base/192422 Log: set thread priority when creating ZFS threads Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Wed May 20 05:39:41 2009 (r192421) +++ user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Wed May 20 05:42:36 2009 (r192422) @@ -40,7 +40,7 @@ #define CPU curcpu #define minclsyspri 0 -#define maxclsyspri 0 +#define maxclsyspri PRIBIO #define max_ncpus mp_ncpus #define boot_max_ncpus mp_ncpus @@ -74,8 +74,8 @@ thread_create(caddr_t stk, size_t stksiz ASSERT(len == 0); ASSERT(state == TS_RUN); - error = kthread_create(proc, arg, &p, 0, ZFS_KSTACK_PAGES, - "solthread %p", proc); + error = kthread_create_pri(proc, arg, &p, 0, ZFS_KSTACK_PAGES, + pri, "solthread %p", proc); return (error == 0 ? FIRST_THREAD_IN_PROC(p) : NULL); } From owner-svn-src-user@FreeBSD.ORG Wed May 20 06:07:54 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96554106564A; Wed, 20 May 2009 06:07:54 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4AAA48FC23; Wed, 20 May 2009 06:07:54 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K67r1g021101; Wed, 20 May 2009 06:07:53 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K67rZi021100; Wed, 20 May 2009 06:07:53 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200607.n4K67rZi021100@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 06:07:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192425 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 06:07:56 -0000 Author: kmacy Date: Wed May 20 06:07:53 2009 New Revision: 192425 URL: http://svn.freebsd.org/changeset/base/192425 Log: - give kernel threads a sensible default priority - call sched_prio after sched_add Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 06:01:20 2009 (r192424) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 06:07:53 2009 (r192425) @@ -92,6 +92,9 @@ kthread_create_pri_v(void (*func)(void * if (newpp != NULL) *newpp = p2; + if (prio == 0) + prio = PRI_MAX_KERN; + /* this is a non-swapped system process */ PROC_LOCK(p2); p2->p_flag |= P_SYSTEM | P_KTHREAD; @@ -111,8 +114,8 @@ kthread_create_pri_v(void (*func)(void * /* Delay putting it on the run queue until now. */ if (!(flags & RFSTOPPED)) { thread_lock(td); - sched_prio(td, prio); sched_add(td, SRQ_BORING); + sched_prio(td, prio); thread_unlock(td); } From owner-svn-src-user@FreeBSD.ORG Wed May 20 06:29:20 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7EAC2106566B; Wed, 20 May 2009 06:29:20 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6DA7B8FC12; Wed, 20 May 2009 06:29:20 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K6TK1C021535; Wed, 20 May 2009 06:29:20 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K6TKZf021534; Wed, 20 May 2009 06:29:20 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200629.n4K6TKZf021534@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 06:29:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192426 - user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 06:29:20 -0000 Author: kmacy Date: Wed May 20 06:29:19 2009 New Revision: 192426 URL: http://svn.freebsd.org/changeset/base/192426 Log: raise taskq priorities Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Wed May 20 06:07:53 2009 (r192425) +++ user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Wed May 20 06:29:19 2009 (r192426) @@ -39,8 +39,8 @@ #ifdef _KERNEL #define CPU curcpu -#define minclsyspri 0 -#define maxclsyspri PRIBIO +#define minclsyspri PRIBIO +#define maxclsyspri PSWP #define max_ncpus mp_ncpus #define boot_max_ncpus mp_ncpus From owner-svn-src-user@FreeBSD.ORG Wed May 20 06:45:08 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B8BF106566B; Wed, 20 May 2009 06:45:08 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A5698FC1C; Wed, 20 May 2009 06:45:08 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K6j8v9021949; Wed, 20 May 2009 06:45:08 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K6j8dt021948; Wed, 20 May 2009 06:45:08 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200645.n4K6j8dt021948@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 06:45:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192427 - user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 06:45:08 -0000 Author: kmacy Date: Wed May 20 06:45:08 2009 New Revision: 192427 URL: http://svn.freebsd.org/changeset/base/192427 Log: raise geom worker to PRIBIO Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Wed May 20 06:29:19 2009 (r192426) +++ user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Wed May 20 06:45:08 2009 (r192427) @@ -530,8 +530,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psi vd->vdev_tsd = ctx; pp = cp->provider; - kthread_create(vdev_geom_worker, ctx, NULL, 0, 0, "vdev:worker %s", - pp->name); + kthread_create_pri(vdev_geom_worker, ctx, NULL, 0, 0, PRIBIO, + "vdev:worker %s", pp->name); /* * Determine the actual size of the device. From owner-svn-src-user@FreeBSD.ORG Wed May 20 06:46:19 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2836A106564A; Wed, 20 May 2009 06:46:19 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 17A048FC16; Wed, 20 May 2009 06:46:19 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K6kIef022013; Wed, 20 May 2009 06:46:19 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K6kIa3022012; Wed, 20 May 2009 06:46:18 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200646.n4K6kIa3022012@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 06:46:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192428 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 06:46:19 -0000 Author: kmacy Date: Wed May 20 06:46:18 2009 New Revision: 192428 URL: http://svn.freebsd.org/changeset/base/192428 Log: set thread priority explicitly Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 06:45:08 2009 (r192427) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 06:46:18 2009 (r192428) @@ -106,7 +106,9 @@ kthread_create_pri_v(void (*func)(void * memcpy(p2->p_comm, comm, sizeof(p2->p_comm)); td = FIRST_THREAD_IN_PROC(p2); memcpy(td->td_name, comm, sizeof(td->td_name)); - + td->td_base_pri = prio; + td->td_priority = prio; + /* call the processes' main()... */ cpu_set_fork_handler(td, func, arg); TD_SET_CAN_RUN(td); @@ -115,7 +117,6 @@ kthread_create_pri_v(void (*func)(void * if (!(flags & RFSTOPPED)) { thread_lock(td); sched_add(td, SRQ_BORING); - sched_prio(td, prio); thread_unlock(td); } From owner-svn-src-user@FreeBSD.ORG Wed May 20 07:01:36 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6CA231065670; Wed, 20 May 2009 07:01:36 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A9118FC14; Wed, 20 May 2009 07:01:36 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K71aZT022464; Wed, 20 May 2009 07:01:36 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K71aYb022461; Wed, 20 May 2009 07:01:36 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200701.n4K71aYb022461@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 07:01:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192429 - in user/kmacy/releng_7_2_fcs/sys: cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common/fs/zfs kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 07:01:36 -0000 Author: kmacy Date: Wed May 20 07:01:36 2009 New Revision: 192429 URL: http://svn.freebsd.org/changeset/base/192429 Log: restore default kthread priority raise min / max zfs thread priority Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Wed May 20 06:46:18 2009 (r192428) +++ user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Wed May 20 07:01:36 2009 (r192429) @@ -39,8 +39,8 @@ #ifdef _KERNEL #define CPU curcpu -#define minclsyspri PRIBIO -#define maxclsyspri PSWP +#define minclsyspri PVM +#define maxclsyspri PI_SOFT #define max_ncpus mp_ncpus #define boot_max_ncpus mp_ncpus Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Wed May 20 06:46:18 2009 (r192428) +++ user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Wed May 20 07:01:36 2009 (r192429) @@ -823,7 +823,8 @@ zvol_create_minor(const char *name, majo bioq_init(&zv->zv_queue); mtx_init(&zv->zv_queue_mtx, "zvol", NULL, MTX_DEF); zv->zv_state = 0; - kthread_create(zvol_worker, zv, NULL, 0, 0, "zvol:worker %s", pp->name); + kthread_create_pri(zvol_worker, zv, NULL, 0, 0, PRIBIO, + "zvol:worker %s", pp->name); zvol_minors++; end: Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 06:46:18 2009 (r192428) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 07:01:36 2009 (r192429) @@ -93,7 +93,7 @@ kthread_create_pri_v(void (*func)(void * *newpp = p2; if (prio == 0) - prio = PRI_MAX_KERN; + prio = PVM; /* XXX compatibility :-{ */ /* this is a non-swapped system process */ PROC_LOCK(p2); From owner-svn-src-user@FreeBSD.ORG Wed May 20 07:11:46 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAA3A1065670; Wed, 20 May 2009 07:11:46 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B9C448FC14; Wed, 20 May 2009 07:11:46 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K7BkYj022729; Wed, 20 May 2009 07:11:46 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K7BkJZ022728; Wed, 20 May 2009 07:11:46 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200711.n4K7BkJZ022728@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 07:11:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192430 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 07:11:47 -0000 Author: kmacy Date: Wed May 20 07:11:46 2009 New Revision: 192430 URL: http://svn.freebsd.org/changeset/base/192430 Log: don't set prio if argument is zero Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 07:01:36 2009 (r192429) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Wed May 20 07:11:46 2009 (r192430) @@ -92,9 +92,6 @@ kthread_create_pri_v(void (*func)(void * if (newpp != NULL) *newpp = p2; - if (prio == 0) - prio = PVM; /* XXX compatibility :-{ */ - /* this is a non-swapped system process */ PROC_LOCK(p2); p2->p_flag |= P_SYSTEM | P_KTHREAD; @@ -106,8 +103,10 @@ kthread_create_pri_v(void (*func)(void * memcpy(p2->p_comm, comm, sizeof(p2->p_comm)); td = FIRST_THREAD_IN_PROC(p2); memcpy(td->td_name, comm, sizeof(td->td_name)); - td->td_base_pri = prio; - td->td_priority = prio; + if (prio != 0) { + td->td_base_pri = prio; + td->td_priority = prio; + } /* call the processes' main()... */ cpu_set_fork_handler(td, func, arg); From owner-svn-src-user@FreeBSD.ORG Wed May 20 07:31:12 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9E646106564A; Wed, 20 May 2009 07:31:12 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8BA0A8FC16; Wed, 20 May 2009 07:31:12 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4K7VC6Y023119; Wed, 20 May 2009 07:31:12 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4K7VCYZ023111; Wed, 20 May 2009 07:31:12 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905200731.n4K7VCYZ023111@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 07:31:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192431 - in user/kmacy/releng_7_2_fcs/sys: ddb kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 07:31:12 -0000 Author: kmacy Date: Wed May 20 07:31:11 2009 New Revision: 192431 URL: http://svn.freebsd.org/changeset/base/192431 Log: - Update locks to newer lock profiling and witness - Update ddb for support Modified: user/kmacy/releng_7_2_fcs/sys/ddb/db_command.c user/kmacy/releng_7_2_fcs/sys/ddb/db_command.h user/kmacy/releng_7_2_fcs/sys/ddb/db_main.c user/kmacy/releng_7_2_fcs/sys/ddb/ddb.h user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c user/kmacy/releng_7_2_fcs/sys/kern/kern_rmlock.c user/kmacy/releng_7_2_fcs/sys/kern/kern_rwlock.c user/kmacy/releng_7_2_fcs/sys/kern/kern_sx.c user/kmacy/releng_7_2_fcs/sys/kern/subr_lock.c user/kmacy/releng_7_2_fcs/sys/kern/subr_sleepqueue.c user/kmacy/releng_7_2_fcs/sys/kern/subr_turnstile.c user/kmacy/releng_7_2_fcs/sys/kern/subr_witness.c user/kmacy/releng_7_2_fcs/sys/sys/_lock.h user/kmacy/releng_7_2_fcs/sys/sys/_rwlock.h user/kmacy/releng_7_2_fcs/sys/sys/lock.h user/kmacy/releng_7_2_fcs/sys/sys/lock_profile.h user/kmacy/releng_7_2_fcs/sys/sys/proc.h user/kmacy/releng_7_2_fcs/sys/sys/rwlock.h Modified: user/kmacy/releng_7_2_fcs/sys/ddb/db_command.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/ddb/db_command.c Wed May 20 07:11:46 2009 (r192430) +++ user/kmacy/releng_7_2_fcs/sys/ddb/db_command.c Wed May 20 07:31:11 2009 (r192431) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -63,10 +64,6 @@ db_addr_t db_last_addr; db_addr_t db_prev; db_addr_t db_next; -SET_DECLARE(db_cmd_set, struct command); -SET_DECLARE(db_show_cmd_set, struct command); -SET_DECLARE(db_show_all_cmd_set, struct command); - static db_cmdfcn_t db_fncall; static db_cmdfcn_t db_gdb; static db_cmdfcn_t db_halt; @@ -81,30 +78,20 @@ static db_cmdfcn_t db_watchdog; */ static struct command db_show_all_cmds[] = { - { (char *)0 } -}; - -static struct command_table db_show_all_table = { - db_show_all_cmds, - SET_BEGIN(db_show_all_cmd_set), - SET_LIMIT(db_show_all_cmd_set) + { "trace", db_stack_trace_all, 0, 0 }, }; +struct command_table db_show_all_table = + LIST_HEAD_INITIALIZER(db_show_all_table); static struct command db_show_cmds[] = { { "all", 0, 0, &db_show_all_table }, { "registers", db_show_regs, 0, 0 }, { "breaks", db_listbreak_cmd, 0, 0 }, { "threads", db_show_threads, 0, 0 }, - { (char *)0, } }; +struct command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table); -static struct command_table db_show_table = { - db_show_cmds, - SET_BEGIN(db_show_cmd_set), - SET_LIMIT(db_show_cmd_set) -}; - -static struct command db_commands[] = { +static struct command db_cmds[] = { { "print", db_print_cmd, 0, 0 }, { "p", db_print_cmd, 0, 0 }, { "examine", db_examine_cmd, CS_SET_DOT, 0 }, @@ -130,6 +117,7 @@ static struct command db_commands[] = { { "match", db_trace_until_matching_cmd,0, 0 }, { "trace", db_stack_trace, CS_OWN, 0 }, { "t", db_stack_trace, CS_OWN, 0 }, + /* XXX alias for all trace */ { "alltrace", db_stack_trace_all, 0, 0 }, { "where", db_stack_trace, CS_OWN, 0 }, { "bt", db_stack_trace, CS_OWN, 0 }, @@ -149,14 +137,8 @@ static struct command db_commands[] = { { "unscript", db_unscript_cmd, CS_OWN, 0 }, { "capture", db_capture_cmd, CS_OWN, 0 }, { "textdump", db_textdump_cmd, CS_OWN, 0 }, - { (char *)0, } -}; - -static struct command_table db_command_table = { - db_commands, - SET_BEGIN(db_cmd_set), - SET_LIMIT(db_cmd_set) }; +struct command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table); static struct command *db_last_command = 0; @@ -197,6 +179,72 @@ static void db_command(struct command ** struct command_table *cmd_table, int dopager); /* + * Initialize the command lists from the static tables. + */ +void +db_command_init(void) +{ +#define N(a) (sizeof(a) / sizeof(a[0])) + int i; + + for (i = 0; i < N(db_cmds); i++) + db_command_register(&db_cmd_table, &db_cmds[i]); + for (i = 0; i < N(db_show_cmds); i++) + db_command_register(&db_show_table, &db_show_cmds[i]); + for (i = 0; i < N(db_show_all_cmds); i++) + db_command_register(&db_show_all_table, &db_show_all_cmds[i]); +#undef N +} + +/* + * Register a command. + */ +void +db_command_register(struct command_table *list, struct command *cmd) +{ + struct command *c, *last; + + last = NULL; + LIST_FOREACH(c, list, next) { + int n = strcmp(cmd->name, c->name); + + /* Check that the command is not already present. */ + if (n == 0) { + printf("%s: Warning, the command \"%s\" already exists;" + " ignoring request\n", __func__, cmd->name); + return; + } + if (n < 0) { + /* NB: keep list sorted lexicographically */ + LIST_INSERT_BEFORE(c, cmd, next); + return; + } + last = c; + } + if (last == NULL) + LIST_INSERT_HEAD(list, cmd, next); + else + LIST_INSERT_AFTER(last, cmd, next); +} + +/* + * Remove a command previously registered with db_command_register. + */ +void +db_command_unregister(struct command_table *list, struct command *cmd) +{ + struct command *c; + + LIST_FOREACH(c, list, next) { + if (cmd == c) { + LIST_REMOVE(cmd, next); + return; + } + } + /* NB: intentionally quiet */ +} + +/* * Helper function to match a single command. */ static void @@ -245,22 +293,14 @@ db_cmd_search(name, table, cmdp) struct command **cmdp; /* out */ { struct command *cmd; - struct command **aux_cmdp; int result = CMD_NONE; - for (cmd = table->table; cmd->name != 0; cmd++) { - db_cmd_match(name, cmd, cmdp, &result); + LIST_FOREACH(cmd, table, next) { + db_cmd_match(name,cmd,cmdp,&result); if (result == CMD_UNIQUE) - return (CMD_UNIQUE); + break; } - if (table->aux_tablep != NULL) - for (aux_cmdp = table->aux_tablep; - aux_cmdp < table->aux_tablep_end; - aux_cmdp++) { - db_cmd_match(name, *aux_cmdp, cmdp, &result); - if (result == CMD_UNIQUE) - return (CMD_UNIQUE); - } + if (result == CMD_NONE) { /* check for 'help' */ if (name[0] == 'h' && name[1] == 'e' @@ -274,19 +314,11 @@ static void db_cmd_list(table) struct command_table *table; { - register struct command *cmd; - register struct command **aux_cmdp; + register struct command *cmd; - for (cmd = table->table; cmd->name != 0; cmd++) { - db_printf("%-12s", cmd->name); - db_end_line(12); - } - if (table->aux_tablep == NULL) - return; - for (aux_cmdp = table->aux_tablep; aux_cmdp < table->aux_tablep_end; - aux_cmdp++) { - db_printf("%-12s", (*aux_cmdp)->name); - db_end_line(12); + LIST_FOREACH(cmd, table, next) { + db_printf("%-12s", cmd->name); + db_end_line(12); } } @@ -296,7 +328,7 @@ db_command(last_cmdp, cmd_table, dopager struct command_table *cmd_table; int dopager; { - struct command *cmd; + struct command *cmd = NULL; int t; char modif[TOK_STRING_SIZE]; db_expr_t addr, count; @@ -463,7 +495,7 @@ db_command_loop() db_printf("db> "); (void) db_read_line(); - db_command(&db_last_command, &db_command_table, /* dopager */ 1); + db_command(&db_last_command, &db_cmd_table, /* dopager */ 1); } } @@ -481,7 +513,7 @@ db_command_script(const char *command) { db_prev = db_next = db_dot; db_inject_line(command); - db_command(&db_last_command, &db_command_table, /* dopager */ 0); + db_command(&db_last_command, &db_cmd_table, /* dopager */ 0); } void Modified: user/kmacy/releng_7_2_fcs/sys/ddb/db_command.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/ddb/db_command.h Wed May 20 07:11:46 2009 (r192430) +++ user/kmacy/releng_7_2_fcs/sys/ddb/db_command.h Wed May 20 07:31:11 2009 (r192431) @@ -37,6 +37,7 @@ * Command loop declarations. */ +void db_command_init(void); void db_command_loop(void); void db_command_script(const char *command); Modified: user/kmacy/releng_7_2_fcs/sys/ddb/db_main.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/ddb/db_main.c Wed May 20 07:11:46 2009 (r192430) +++ user/kmacy/releng_7_2_fcs/sys/ddb/db_main.c Wed May 20 07:31:11 2009 (r192431) @@ -172,6 +172,7 @@ db_init(void) uintptr_t symtab, strtab; Elf_Size tabsz, strsz; + db_command_init(); if (ksym_end > ksym_start && ksym_start != 0) { symtab = ksym_start; tabsz = *((Elf_Size*)symtab); Modified: user/kmacy/releng_7_2_fcs/sys/ddb/ddb.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/ddb/ddb.h Wed May 20 07:11:46 2009 (r192430) +++ user/kmacy/releng_7_2_fcs/sys/ddb/ddb.h Wed May 20 07:31:11 2009 (r192431) @@ -43,6 +43,9 @@ SYSCTL_DECL(_debug_ddb); #include /* type definitions */ +#include /* LIST_* */ +#include /* SYSINIT */ + #ifndef DB_MAXARGS #define DB_MAXARGS 10 #endif @@ -73,36 +76,97 @@ SYSCTL_DECL(_debug_ddb); int DB_CALL(db_expr_t, db_expr_t *, int, db_expr_t[]); #endif +/* + * There are three "command tables": + * - One for simple commands; a list of these is displayed + * by typing 'help' at the debugger prompt. + * - One for sub-commands of 'show'; to see this type 'show' + * without any arguments. + * - The last one for sub-commands of 'show all'; type 'show all' + * without any argument to get a list. + */ +struct command; +LIST_HEAD(command_table, command); +extern struct command_table db_cmd_table; +extern struct command_table db_show_table; +extern struct command_table db_show_all_table; + +/* + * Type signature for a function implementing a ddb command. + */ typedef void db_cmdfcn_t(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif); -#define DB_COMMAND(cmd_name, func_name) \ - DB_FUNC(cmd_name, func_name, db_cmd_set, 0, NULL) -#define DB_SHOW_COMMAND(cmd_name, func_name) \ - DB_FUNC(cmd_name, func_name, db_show_cmd_set, 0, NULL) -#define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \ - DB_FUNC(cmd_name, func_name, db_show_all_cmd_set, 0, NULL) +/* + * Command table entry. + */ +struct command { + char * name; /* command name */ + db_cmdfcn_t *fcn; /* function to call */ + int flag; /* extra info: */ +#define CS_OWN 0x1 /* non-standard syntax */ +#define CS_MORE 0x2 /* standard syntax, but may have other words + * at end */ +#define CS_SET_DOT 0x100 /* set dot after command */ + struct command_table *more; /* another level of command */ + LIST_ENTRY(command) next; /* next entry in the command table */ +}; -#define DB_SET(cmd_name, func_name, set, flag, more) \ -static const struct command __CONCAT(cmd_name,_cmd) = { \ - __STRING(cmd_name), \ - func_name, \ - flag, \ - more \ +/* + * Arrange for the specified ddb command to be defined and + * bound to the specified function. Commands can be defined + * in modules in which case they will be available only when + * the module is loaded. + */ +#define _DB_SET(_suffix, _name, _func, list, _flag, _more) \ +static struct command __CONCAT(_name,_suffix) = { \ + .name = __STRING(_name), \ + .fcn = _func, \ + .flag = _flag, \ + .more = _more \ }; \ -TEXT_SET(set, __CONCAT(cmd_name,_cmd)) +static void __CONCAT(__CONCAT(_name,_suffix),_add)(void *arg __unused) \ + { db_command_register(&list, &__CONCAT(_name,_suffix)); } \ +SYSINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \ + __CONCAT(__CONCAT(_name,_suffix),_add), NULL); \ +static void __CONCAT(__CONCAT(_name,_suffix),_del)(void *arg __unused) \ + { db_command_unregister(&list, &__CONCAT(_name,_suffix)); } \ +SYSUNINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \ + __CONCAT(__CONCAT(_name,_suffix),_del), NULL); -#define DB_FUNC(cmd_name, func_name, set, flag, more) \ -static db_cmdfcn_t func_name; \ - \ -DB_SET(cmd_name, func_name, set, flag, more); \ - \ +/* + * Like _DB_SET but also create the function declaration which + * must be followed immediately by the body; e.g. + * _DB_FUNC(_cmd, panic, db_panic, db_cmd_table, 0, NULL) + * { + * ...panic implementation... + * } + * + * This macro is mostly used to define commands placed in one of + * the ddb command tables; see DB_COMMAND, etc. below. + */ +#define _DB_FUNC(_suffix, _name, _func, list, _flag, _more) \ +static db_cmdfcn_t _func; \ +_DB_SET(_suffix, _name, _func, list, _flag, _more); \ static void \ -func_name(addr, have_addr, count, modif) \ - db_expr_t addr; \ - boolean_t have_addr; \ - db_expr_t count; \ - char *modif; +_func(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif) + +/* common idom provided for backwards compatibility */ +#define DB_FUNC(_name, _func, list, _flag, _more) \ + _DB_FUNC(_cmd, _name, _func, list, _flag, _more) + +#define DB_COMMAND(cmd_name, func_name) \ + _DB_FUNC(_cmd, cmd_name, func_name, db_cmd_table, 0, NULL) +#define DB_ALIAS(alias_name, func_name) \ + _DB_SET(_cmd, alias_name, func_name, db_cmd_table, 0, NULL) +#define DB_SHOW_COMMAND(cmd_name, func_name) \ + _DB_FUNC(_show, cmd_name, func_name, db_show_table, 0, NULL) +#define DB_SHOW_ALIAS(alias_name, func_name) \ + _DB_SET(_show, alias_name, func_name, db_show_table, 0, NULL) +#define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \ + _DB_FUNC(_show_all, cmd_name, func_name, db_show_all_table, 0, NULL) +#define DB_SHOW_ALL_ALIAS(alias_name, func_name) \ + _DB_SET(_show_all, alias_name, func_name, db_show_all_table, 0, NULL) extern db_expr_t db_maxoff; extern int db_indent; @@ -150,6 +214,8 @@ void db_trace_self(void); int db_trace_thread(struct thread *, int); int db_value_of_name(const char *name, db_expr_t *valuep); int db_write_bytes(vm_offset_t addr, size_t size, char *data); +void db_command_register(struct command_table *, struct command *); +void db_command_unregister(struct command_table *, struct command *); db_cmdfcn_t db_breakpoint_cmd; db_cmdfcn_t db_capture_cmd; @@ -179,28 +245,6 @@ db_cmdfcn_t db_watchpoint_cmd; db_cmdfcn_t db_write_cmd; /* - * Command table. - */ -struct command; - -struct command_table { - struct command *table; - struct command **aux_tablep; - struct command **aux_tablep_end; -}; - -struct command { - char * name; /* command name */ - db_cmdfcn_t *fcn; /* function to call */ - int flag; /* extra info: */ -#define CS_OWN 0x1 /* non-standard syntax */ -#define CS_MORE 0x2 /* standard syntax, but may have other words - * at end */ -#define CS_SET_DOT 0x100 /* set dot after command */ - struct command_table *more; /* another level of command */ -}; - -/* * Interface between DDB and the DDB output capture facility. */ struct dumperinfo; Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Wed May 20 07:11:46 2009 (r192430) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Wed May 20 07:31:11 2009 (r192431) @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); #define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK)) +static void assert_mtx(struct lock_object *lock, int what); #ifdef DDB static void db_show_mtx(struct lock_object *lock); #endif @@ -98,6 +99,7 @@ static int unlock_spin(struct lock_objec struct lock_class lock_class_mtx_sleep = { .lc_name = "sleep mutex", .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, + .lc_assert = assert_mtx, #ifdef DDB .lc_ddb_show = db_show_mtx, #endif @@ -107,6 +109,7 @@ struct lock_class lock_class_mtx_sleep = struct lock_class lock_class_mtx_spin = { .lc_name = "spin mutex", .lc_flags = LC_SPINLOCK | LC_RECURSABLE, + .lc_assert = assert_mtx, #ifdef DDB .lc_ddb_show = db_show_mtx, #endif @@ -120,19 +123,12 @@ struct lock_class lock_class_mtx_spin = struct mtx blocked_lock; struct mtx Giant; -#ifdef LOCK_PROFILING -static inline void lock_profile_init(void) +void +assert_mtx(struct lock_object *lock, int what) { - int i; - /* Initialize the mutex profiling locks */ - for (i = 0; i < LPROF_LOCK_SIZE; i++) { - mtx_init(&lprof_locks[i], "mprof lock", - NULL, MTX_SPIN|MTX_QUIET|MTX_NOPROFILE); - } + + mtx_assert((struct mtx *)lock, what); } -#else -static inline void lock_profile_init(void) {;} -#endif void lock_mtx(struct lock_object *lock, int how) @@ -181,7 +177,7 @@ _mtx_lock_flags(struct mtx *m, int opts, ("mtx_lock() of spin mutex %s @ %s:%d", m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, - file, line); + file, line, NULL); _get_sleep_lock(m, curthread, opts, file, line); LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file, @@ -225,7 +221,7 @@ _mtx_lock_spin_flags(struct mtx *m, int ("mtx_lock_spin: recursed on non-recursive mutex %s @ %s:%d\n", m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, - file, line); + file, line, NULL); _get_spin_lock(m, curthread, opts, file, line); LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file, line); @@ -258,9 +254,12 @@ _mtx_unlock_spin_flags(struct mtx *m, in int _mtx_trylock(struct mtx *m, int opts, const char *file, int line) { - int rval, contested = 0; +#ifdef LOCK_PROFILING uint64_t waittime = 0; - + int contested = 0; +#endif + int rval; + MPASS(curthread != NULL); KASSERT(m->mtx_lock != MTX_DESTROYED, ("mtx_trylock() of destroyed mutex @ %s:%d", file, line)); @@ -300,16 +299,18 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t int line) { struct turnstile *ts; + uintptr_t v; #ifdef ADAPTIVE_MUTEXES volatile struct thread *owner; #endif #ifdef KTR int cont_logged = 0; #endif +#ifdef LOCK_PROFILING int contested = 0; uint64_t waittime = 0; - uintptr_t v; - +#endif + if (mtx_owned(m)) { KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0, ("_mtx_lock_sleep: recursed on non-recursive mutex %s @ %s:%d\n", @@ -328,7 +329,7 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->lock_object.lo_name, (void *)m->mtx_lock, file, line); - while (!_obtain_lock(m, tid)) { + while (!_obtain_lock(m, tid)) { #ifdef ADAPTIVE_MUTEXES /* * If the owner is running on another CPU, spin until the @@ -337,11 +338,7 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t v = m->mtx_lock; if (v != MTX_UNOWNED) { owner = (struct thread *)(v & ~MTX_FLAGMASK); -#ifdef ADAPTIVE_GIANT if (TD_IS_RUNNING(owner)) { -#else - if (m != &Giant && TD_IS_RUNNING(owner)) { -#endif if (LOCK_LOG_TEST(&m->lock_object, 0)) CTR3(KTR_LOCK, "%s: spinning on %p held by %p", @@ -375,11 +372,7 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t * CPU quit the hard path and try to spin. */ owner = (struct thread *)(v & ~MTX_FLAGMASK); -#ifdef ADAPTIVE_GIANT if (TD_IS_RUNNING(owner)) { -#else - if (m != &Giant && TD_IS_RUNNING(owner)) { -#endif turnstile_cancel(ts); cpu_spinwait(); continue; @@ -426,8 +419,8 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t m->lock_object.lo_name, (void *)tid, file, line); } #endif - lock_profile_obtain_lock_success(&m->lock_object, contested, - waittime, (file), (line)); + lock_profile_obtain_lock_success(&m->lock_object, contested, + waittime, file, line); } static void @@ -460,9 +453,12 @@ void _mtx_lock_spin(struct mtx *m, uintptr_t tid, int opts, const char *file, int line) { - int i = 0, contested = 0; + int i = 0; +#ifdef LOCK_PROFILING + int contested = 0; uint64_t waittime = 0; - +#endif + if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m); @@ -488,7 +484,7 @@ _mtx_lock_spin(struct mtx *m, uintptr_t if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR1(KTR_LOCK, "_mtx_lock_spin: %p spin done", m); - lock_profile_obtain_lock_success(&m->lock_object, contested, + lock_profile_obtain_lock_success(&m->lock_object, contested, waittime, (file), (line)); } #endif /* SMP */ @@ -498,11 +494,13 @@ _thread_lock_flags(struct thread *td, in { struct mtx *m; uintptr_t tid; - int i, contested; - uint64_t waittime; + int i; +#ifdef LOCK_PROFILING + int contested = 0; + uint64_t waittime = 0; +#endif - contested = i = 0; - waittime = 0; + i = 0; tid = (uintptr_t)curthread; for (;;) { retry: @@ -518,13 +516,14 @@ retry: ("thread_lock: recursed on non-recursive mutex %s @ %s:%d\n", m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, - opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line); + opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); while (!_obtain_lock(m, tid)) { if (m->mtx_lock == tid) { m->mtx_recurse++; break; } - lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); + lock_profile_obtain_lock_failed(&m->lock_object, + &contested, &waittime); /* Give interrupts a chance while we spin. */ spinlock_exit(); while (m->mtx_lock != MTX_UNOWNED) { @@ -545,8 +544,9 @@ retry: break; _rel_spin_lock(m); /* does spinlock_exit() */ } - lock_profile_obtain_lock_success(&m->lock_object, contested, - waittime, (file), (line)); + if (m->mtx_recurse == 0) + lock_profile_obtain_lock_success(&m->lock_object, contested, + waittime, (file), (line)); LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); @@ -614,10 +614,10 @@ _mtx_unlock_sleep(struct mtx *m, int opt ts = turnstile_lookup(&m->lock_object); if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m); - MPASS(ts != NULL); turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE); _release_lock_quick(m); + /* * This turnstile is now no longer associated with the mutex. We can * unlock the chain lock so a new turnstile may take it's place. @@ -807,8 +807,6 @@ mutex_init(void) mtx_init(&proc0.p_slock, "process slock", NULL, MTX_SPIN | MTX_RECURSE); mtx_init(&devmtx, "cdev", NULL, MTX_DEF); mtx_lock(&Giant); - - lock_profile_init(); } #ifdef DDB @@ -846,7 +844,7 @@ db_show_mtx(struct lock_object *lock) if (!mtx_unowned(m) && !mtx_destroyed(m)) { td = mtx_owner(m); db_printf(" owner: %p (tid %d, pid %d, \"%s\")\n", td, - td->td_tid, td->td_proc->p_pid, td->td_proc->p_comm); + td->td_tid, td->td_proc->p_pid, td->td_name); if (mtx_recursed(m)) db_printf(" recursed: %d\n", m->mtx_recurse); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_rmlock.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_rmlock.c Wed May 20 07:11:46 2009 (r192430) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_rmlock.c Wed May 20 07:31:11 2009 (r192431) @@ -32,7 +32,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: head/sys/kern/kern_rmlock.c 191539 2009-04-26 21:16:03Z rwatson $"); #include "opt_ddb.h" @@ -69,12 +69,14 @@ static __inline void compiler_memory_bar __asm __volatile("":::"memory"); } +static void assert_rm(struct lock_object *lock, int what); static void lock_rm(struct lock_object *lock, int how); static int unlock_rm(struct lock_object *lock); struct lock_class lock_class_rm = { .lc_name = "rm", .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, + .lc_assert = assert_rm, #if 0 #ifdef DDB .lc_ddb_show = db_show_rwlock, @@ -85,6 +87,13 @@ struct lock_class lock_class_rm = { }; static void +assert_rm(struct lock_object *lock, int what) +{ + + panic("assert_rm called"); +} + +static void lock_rm(struct lock_object *lock, int how) { @@ -403,7 +412,7 @@ void _rm_wlock_debug(struct rmlock *rm, { WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, - file, line); + file, line, NULL); _rm_wlock(rm); @@ -430,7 +439,7 @@ _rm_rlock_debug(struct rmlock *rm, struc const char *file, int line) { - WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER, file, line); + WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER, file, line, NULL); _rm_rlock(rm, tracker); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_rwlock.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_rwlock.c Wed May 20 07:11:46 2009 (r192430) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_rwlock.c Wed May 20 07:31:11 2009 (r192431) @@ -39,10 +39,12 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include #include +#include #include #include @@ -54,17 +56,27 @@ CTASSERT((RW_RECURSE & LO_CLASSFLAGS) == #define ADAPTIVE_RWLOCKS #endif +#ifdef ADAPTIVE_RWLOCKS +static int rowner_retries = 10; +static int rowner_loops = 10000; +SYSCTL_NODE(_debug, OID_AUTO, rwlock, CTLFLAG_RD, NULL, "rwlock debugging"); +SYSCTL_INT(_debug_rwlock, OID_AUTO, retry, CTLFLAG_RW, &rowner_retries, 0, ""); +SYSCTL_INT(_debug_rwlock, OID_AUTO, loops, CTLFLAG_RW, &rowner_loops, 0, ""); +#endif + #ifdef DDB #include static void db_show_rwlock(struct lock_object *lock); #endif +static void assert_rw(struct lock_object *lock, int what); static void lock_rw(struct lock_object *lock, int how); static int unlock_rw(struct lock_object *lock); struct lock_class lock_class_rw = { .lc_name = "rw", .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE, + .lc_assert = assert_rw, #ifdef DDB .lc_ddb_show = db_show_rwlock, #endif @@ -103,6 +115,13 @@ struct lock_class lock_class_rw = { #endif void +assert_rw(struct lock_object *lock, int what) +{ + + rw_assert((struct rwlock *)lock, what); +} + +void lock_rw(struct lock_object *lock, int how) { struct rwlock *rw; @@ -172,6 +191,14 @@ rw_sysinit(void *arg) rw_init(args->ra_rw, args->ra_desc); } +void +rw_sysinit_flags(void *arg) +{ + struct rw_args_flags *args = arg; + + rw_init_flags(args->ra_rw, args->ra_desc, args->ra_flags); +} + int rw_wowned(struct rwlock *rw) { @@ -187,7 +214,7 @@ _rw_wlock(struct rwlock *rw, const char KASSERT(rw->rw_lock != RW_DESTROYED, ("rw_wlock() of destroyed rwlock @ %s:%d", file, line)); WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file, - line); + line, NULL); __rw_wlock(rw, curthread, file, line); LOCK_LOG_LOCK("WLOCK", &rw->lock_object, 0, rw->rw_recurse, file, line); WITNESS_LOCK(&rw->lock_object, LOP_EXCLUSIVE, file, line); @@ -234,6 +261,17 @@ _rw_wunlock(struct rwlock *rw, const cha lock_profile_release_lock(&rw->lock_object); __rw_wunlock(rw, curthread, file, line); } +/* + * Determines whether a new reader can acquire a lock. Succeeds if the + * reader already owns a read lock and the lock is locked for read to + * prevent deadlock from reader recursion. Also succeeds if the lock + * is unlocked and has no writer waiters or spinners. Failing otherwise + * prioritizes writers before readers. + */ +#define RW_CAN_READ(_rw) \ + ((curthread->td_rw_rlocks && (_rw) & RW_LOCK_READ) || ((_rw) & \ + (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER)) == \ + RW_LOCK_READ) void _rw_rlock(struct rwlock *rw, const char *file, int line) @@ -241,31 +279,22 @@ _rw_rlock(struct rwlock *rw, const char struct turnstile *ts; #ifdef ADAPTIVE_RWLOCKS volatile struct thread *owner; + int spintries = 0; + int i; #endif -#ifdef LOCK_PROFILING_SHARED +#ifdef LOCK_PROFILING uint64_t waittime = 0; int contested = 0; #endif - uintptr_t x; + uintptr_t v; KASSERT(rw->rw_lock != RW_DESTROYED, ("rw_rlock() of destroyed rwlock @ %s:%d", file, line)); KASSERT(rw_wowner(rw) != curthread, ("%s (%s): wlock already held @ %s:%d", __func__, rw->lock_object.lo_name, file, line)); - WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line); + WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line, NULL); - /* - * Note that we don't make any attempt to try to block read - * locks once a writer has blocked on the lock. The reason is - * that we currently allow for read locks to recurse and we - * don't keep track of all the holders of read locks. Thus, if - * we were to block readers once a writer blocked and a reader - * tried to recurse on their reader lock after a writer had - * blocked we would end up in a deadlock since the reader would - * be blocked on the writer, and the writer would be blocked - * waiting for the reader to release its original read lock. - */ for (;;) { /* * Handle the easy case. If no other thread has a write @@ -277,33 +306,27 @@ _rw_rlock(struct rwlock *rw, const char * completely unlocked rwlock since such a lock is encoded * as a read lock with no waiters. */ - x = rw->rw_lock; - if (x & RW_LOCK_READ) { - + v = rw->rw_lock; + if (RW_CAN_READ(v)) { /* * The RW_LOCK_READ_WAITERS flag should only be set - * if another thread currently holds a write lock, - * and in that case RW_LOCK_READ should be clear. + * if the lock has been unlocked and write waiters + * were present. */ - MPASS((x & RW_LOCK_READ_WAITERS) == 0); - if (atomic_cmpset_acq_ptr(&rw->rw_lock, x, - x + RW_ONE_READER)) { -#ifdef LOCK_PROFILING_SHARED - if (RW_READERS(x) == 0) - lock_profile_obtain_lock_success( - &rw->lock_object, contested, - waittime, file, line); -#endif + if (atomic_cmpset_acq_ptr(&rw->rw_lock, v, + v + RW_ONE_READER)) { if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR4(KTR_LOCK, "%s: %p succeed %p -> %p", __func__, - rw, (void *)x, - (void *)(x + RW_ONE_READER)); + rw, (void *)v, + (void *)(v + RW_ONE_READER)); break; } cpu_spinwait(); continue; } + lock_profile_obtain_lock_failed(&rw->lock_object, + &contested, &waittime); #ifdef ADAPTIVE_RWLOCKS /* @@ -311,36 +334,45 @@ _rw_rlock(struct rwlock *rw, const char * the owner stops running or the state of the lock * changes. */ - owner = (struct thread *)RW_OWNER(x); - if (TD_IS_RUNNING(owner)) { - if (LOCK_LOG_TEST(&rw->lock_object, 0)) - CTR3(KTR_LOCK, "%s: spinning on %p held by %p", - __func__, rw, owner); -#ifdef LOCK_PROFILING_SHARED - lock_profile_obtain_lock_failed(&rw->lock_object, - &contested, &waittime); -#endif - while ((struct thread*)RW_OWNER(rw->rw_lock) == owner && - TD_IS_RUNNING(owner)) + if ((v & RW_LOCK_READ) == 0) { + owner = (struct thread *)RW_OWNER(v); + if (TD_IS_RUNNING(owner)) { + if (LOCK_LOG_TEST(&rw->lock_object, 0)) + CTR3(KTR_LOCK, + "%s: spinning on %p held by %p", + __func__, rw, owner); + while ((struct thread*)RW_OWNER(rw->rw_lock) == + owner && TD_IS_RUNNING(owner)) + cpu_spinwait(); + continue; + } + } else if (spintries < rowner_retries) { + spintries++; + for (i = 0; i < rowner_loops; i++) { + v = rw->rw_lock; + if ((v & RW_LOCK_READ) == 0 || RW_CAN_READ(v)) + break; cpu_spinwait(); - continue; + } + if (i != rowner_loops) + continue; } #endif /* * Okay, now it's the hard case. Some other thread already - * has a write lock, so acquire the turnstile lock so we can - * begin the process of blocking. + * has a write lock or there are write waiters present, + * acquire the turnstile lock so we can begin the process + * of blocking. */ ts = turnstile_trywait(&rw->lock_object); /* * The lock might have been released while we spun, so - * recheck its state and restart the loop if there is no - * longer a write lock. + * recheck its state and restart the loop if needed. */ - x = rw->rw_lock; - if (x & RW_LOCK_READ) { + v = rw->rw_lock; + if (RW_CAN_READ(v)) { turnstile_cancel(ts); cpu_spinwait(); continue; @@ -351,23 +383,30 @@ _rw_rlock(struct rwlock *rw, const char * If the current owner of the lock is executing on another * CPU quit the hard path and try to spin. */ - owner = (struct thread *)RW_OWNER(x); - if (TD_IS_RUNNING(owner)) { - turnstile_cancel(ts); - cpu_spinwait(); - continue; + if ((v & RW_LOCK_READ) == 0) { + owner = (struct thread *)RW_OWNER(v); + if (TD_IS_RUNNING(owner)) { + turnstile_cancel(ts); + cpu_spinwait(); + continue; + } } #endif /* - * Ok, it's still a write lock. If the RW_LOCK_READ_WAITERS - * flag is already set, then we can go ahead and block. If - * it is not set then try to set it. If we fail to set it - * drop the turnstile lock and restart the loop. - */ - if (!(x & RW_LOCK_READ_WAITERS)) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed May 20 19:19:42 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 391AE1065690; Wed, 20 May 2009 19:19:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 26F998FC1F; Wed, 20 May 2009 19:19:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4KJJgZv041095; Wed, 20 May 2009 19:19:42 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4KJJgK8041094; Wed, 20 May 2009 19:19:42 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905201919.n4KJJgK8041094@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 19:19:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192464 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 19:19:42 -0000 Author: kmacy Date: Wed May 20 19:19:41 2009 New Revision: 192464 URL: http://svn.freebsd.org/changeset/base/192464 Log: merge 192144 Revert r192094. The revision caused problems for sysctl(3) consumers that expect that oldlen is filled with required buffer length even when supplied buffer is too short and returned error is ENOMEM. Redo the fix for kern.proc.filedesc, by reverting the req->oldidx when remaining buffer space is too short for the current kinfo_file structure. Also, only ignore ENOMEM. We have to convert ENOMEM to no error condition to keep existing interface for the sysctl, though. Reported by: ed, Florian Smeets Tested by: pho Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Wed May 20 18:58:07 2009 (r192463) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Wed May 20 19:19:41 2009 (r192464) @@ -2872,6 +2872,7 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER struct file *fp; struct proc *p; int vfslocked; + size_t oldidx; name = (int *)arg1; if ((p = pfind((pid_t)name[0])) == NULL) @@ -3036,14 +3037,26 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER strlen(kif->kf_path) + 1; kif->kf_structsize = roundup(kif->kf_structsize, sizeof(uint64_t)); + oldidx = req->oldidx; error = SYSCTL_OUT(req, kif, kif->kf_structsize); - if (error) + if (error) { + if (error == ENOMEM) { + /* + * The hack to keep the ABI of sysctl + * kern.proc.filedesc intact, but not + * to account a partially copied + * kinfo_file into the oldidx. + */ + req->oldidx = oldidx; + error = 0; + } break; + } } FILEDESC_SUNLOCK(fdp); fddrop(fdp); free(kif, M_TEMP); - return (0); + return (error); } static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, filedesc, CTLFLAG_RD, From owner-svn-src-user@FreeBSD.ORG Wed May 20 19:40:58 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 492EB106564A; Wed, 20 May 2009 19:40:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 380958FC18; Wed, 20 May 2009 19:40:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4KJewfh041554; Wed, 20 May 2009 19:40:58 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4KJewUv041553; Wed, 20 May 2009 19:40:58 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905201940.n4KJewUv041553@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 19:40:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192465 - user/kmacy/releng_7_2_fcs/sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 19:40:58 -0000 Author: kmacy Date: Wed May 20 19:40:57 2009 New Revision: 192465 URL: http://svn.freebsd.org/changeset/base/192465 Log: fix ipfilter build by not referencing uma_zone_t if _KERNEL is not defined Modified: user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h Modified: user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h Wed May 20 19:19:41 2009 (r192464) +++ user/kmacy/releng_7_2_fcs/sys/sys/mbuf.h Wed May 20 19:40:57 2009 (r192465) @@ -128,7 +128,11 @@ struct mb_ext { struct mbuf { struct mbuf *m_next; /* next buffer in chain */ struct mbuf *m_nextpkt; /* next chain in queue/record */ +#ifdef _KERNEL uma_zone_t m_zone; /* Zone allocated from. */ +#else + caddr_t m_zone; +#endif caddr_t m_data; /* location of valid data */ volatile int m_ref; /* Reference count. */ int m_len; /* amount of data in this mbuf */ From owner-svn-src-user@FreeBSD.ORG Wed May 20 19:51:44 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50A021065676; Wed, 20 May 2009 19:51:44 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E8AC8FC1D; Wed, 20 May 2009 19:51:44 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4KJpi13041786; Wed, 20 May 2009 19:51:44 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4KJpiPC041783; Wed, 20 May 2009 19:51:44 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905201951.n4KJpiPC041783@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 19:51:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192466 - user/kmacy/releng_7_2_fcs/share/man/man9 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 19:51:44 -0000 Author: kmacy Date: Wed May 20 19:51:43 2009 New Revision: 192466 URL: http://svn.freebsd.org/changeset/base/192466 Log: update for new mbuf and firmware interface Modified: user/kmacy/releng_7_2_fcs/share/man/man9/firmware.9 user/kmacy/releng_7_2_fcs/share/man/man9/mbuf.9 Modified: user/kmacy/releng_7_2_fcs/share/man/man9/firmware.9 ============================================================================== --- user/kmacy/releng_7_2_fcs/share/man/man9/firmware.9 Wed May 20 19:40:57 2009 (r192465) +++ user/kmacy/releng_7_2_fcs/share/man/man9/firmware.9 Wed May 20 19:51:43 2009 (r192466) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 6, 2006 +.Dd May 18, 2008 .Os .Dt FIRMWARE 9 .Sh NAME @@ -31,6 +31,7 @@ .Nm firmware_unregister , .Nm firmware_get , .Nm firmware_put +.Nm firmware_drain .Nd firmware image loading and management .Sh SYNOPSIS .In sys/param.h @@ -59,6 +60,8 @@ struct firmware { .Fn firmware_get "const char *imagename" .Ft void .Fn firmware_put "const struct firmware *fp" "int flags" +.Ft void +.Fn firmware_drain "void" .Sh DESCRIPTION The .Nm firmware @@ -137,8 +140,11 @@ This involves the linker subsystem and d .Fn firmware_get must not be called with any locks (except for .Va Giant ) . -The caller must also have a process context so filesystem state such as -the root vnode is defined (e.g. you cannot load from a taskqueue thread). +Note also that if the firmware image is loaded from a filesystem +it must already be mounted. +In particular this means that it may be necessary to defer requests +from a driver attach method unless it is known the root filesystem is +already mounted. .Pp On success, .Fn firmware_get @@ -154,6 +160,21 @@ argument may be set to to indicate that firmware_put is free to reclaim resources associated with the firmware image if this is the last reference. +By default a firmware image will be deferred to a +.Xr taskqueue 9 +thread so the call may be done while holding a lock. +In certain cases, such as on driver detach, this cannot be allowed. +If the +.Dv FIRMWARE_WAIT +flag is or'd into +.Fa flags +then +.Fn firmware_put +will wait for the asynchronous operation to complete. +This can also be accomplished by calling the +.Fn firmware_drain +routine after +.Fn firmware_put . .Sh FIRMWARE LOADING MECHANISMS As mentioned before, any component of the system can register firmware images at any time by simply calling @@ -238,11 +259,7 @@ IxNpeMicrocode.fwo optional npe_fw clean "IxNpeMicrocode.fwo" IxNpeMicrocode.dat optional npe_fw \\ dependency ".PHONY" \\ - compile-with "if [ -e $S/arm/xscale/ixp425/IxNpeMicrocode.dat ]; \\ - then \\ - ln -sf $S/arm/xscale/ixp425/IxNpeMicrocode.dat .; \\ - else echo 'WARNING, no IxNpeMicrocode.dat file; you must obtain this from the Intel web site'; false; \\ - fi" \\ + compile-with "uudecode < $S/contrib/dev/npe/IxNpeMicrocode.dat.uu" \\ no-obj no-implicit-rule \\ clean "IxNpeMicrocode.dat" .Ed Modified: user/kmacy/releng_7_2_fcs/share/man/man9/mbuf.9 ============================================================================== --- user/kmacy/releng_7_2_fcs/share/man/man9/mbuf.9 Wed May 20 19:40:57 2009 (r192465) +++ user/kmacy/releng_7_2_fcs/share/man/man9/mbuf.9 Wed May 20 19:51:43 2009 (r192466) @@ -45,8 +45,9 @@ .Fa "struct mbuf *mbuf" .Fa "caddr_t buf" .Fa "u_int size" -.Fa "void (*free)(void *opt_args)" -.Fa "void *opt_args" +.Fa "void (*free)(void *opt_arg1, void *opt_arg2)" +.Fa "void *opt_arg1" +.Fa "void *opt_arg2" .Fa "short flags" .Fa "int type" .Fc From owner-svn-src-user@FreeBSD.ORG Wed May 20 19:53:10 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9190106566C; Wed, 20 May 2009 19:53:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A61268FC16; Wed, 20 May 2009 19:53:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4KJrAn8041847; Wed, 20 May 2009 19:53:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4KJrAGm041844; Wed, 20 May 2009 19:53:10 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905201953.n4KJrAGm041844@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 19:53:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192467 - in user/kmacy/releng_7_2_fcs: lib/libkvm sys/sys usr.bin/fstat X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 19:53:11 -0000 Author: kmacy Date: Wed May 20 19:53:10 2009 New Revision: 192467 URL: http://svn.freebsd.org/changeset/base/192467 Log: merge 174989, 179320 - Update kvm_deadfiles to be compatible with the new system which has no global list of all files. - Mark kvm_getfiles() as broken since the live version exports struct xfile with no filelist at the head and does so incorrectly and the deadfiles version exports struct file with a filelist at the head. It is not known if either version works or complies to the manpage. Use _WANT_FILE to make struct file visible from userland. This is similar to _WANT_UCRED and _WANT_PRISON and seems to be much nicer than defining _KERNEL. It is also needed for my sys/refcount.h change going in soon. these changes fix buildworld Modified: user/kmacy/releng_7_2_fcs/lib/libkvm/kvm_file.c user/kmacy/releng_7_2_fcs/sys/sys/file.h user/kmacy/releng_7_2_fcs/usr.bin/fstat/fstat.c Modified: user/kmacy/releng_7_2_fcs/lib/libkvm/kvm_file.c ============================================================================== --- user/kmacy/releng_7_2_fcs/lib/libkvm/kvm_file.c Wed May 20 19:51:43 2009 (r192466) +++ user/kmacy/releng_7_2_fcs/lib/libkvm/kvm_file.c Wed May 20 19:53:10 2009 (r192467) @@ -46,9 +46,8 @@ static char sccsid[] = "@(#)kvm_file.c 8 #include #include #include -#define _KERNEL +#define _WANT_FILE /* make file.h give us 'struct file' */ #include -#undef _KERNEL #include #include #include @@ -68,40 +67,78 @@ static char sccsid[] = "@(#)kvm_file.c 8 #define KREAD(kd, addr, obj) \ (kvm_read(kd, addr, obj, sizeof(*obj)) != sizeof(*obj)) +#define KREADN(kd, addr, obj, cnt) \ + (kvm_read(kd, addr, obj, (cnt)) != (cnt)) + /* * Get file structures. */ static int -kvm_deadfiles(kd, op, arg, filehead_o, nfiles) +kvm_deadfiles(kd, op, arg, allproc_o, nprocs) kvm_t *kd; - int op, arg, nfiles; - long filehead_o; + int op, arg, nprocs; + long allproc_o; { - int buflen = kd->arglen, n = 0; + struct proc proc; + struct filedesc filed; + int buflen = kd->arglen, ocnt = 0, n = 0, once = 0, i; + struct file **ofiles; struct file *fp; + struct proc *p; char *where = kd->argspc; - struct filelist filehead; - /* - * first copyout filehead - */ - if (buflen > sizeof (filehead)) { - if (KREAD(kd, filehead_o, &filehead)) { - _kvm_err(kd, kd->program, "can't read filehead"); - return (0); - } - buflen -= sizeof (filehead); - where += sizeof (filehead); - *(struct filelist *)kd->argspc = filehead; + if (buflen < sizeof (struct file *) + sizeof (struct file)) + return (0); + if (KREAD(kd, allproc_o, &p)) { + _kvm_err(kd, kd->program, "cannot read allproc"); + return (0); } - /* - * followed by an array of file structures - */ - LIST_FOREACH(fp, &filehead, f_list) { - if (buflen > sizeof (struct file)) { + for (; p != NULL; p = LIST_NEXT(&proc, p_list)) { + if (KREAD(kd, (u_long)p, &proc)) { + _kvm_err(kd, kd->program, "can't read proc at %x", p); + goto fail; + } + if (proc.p_state == PRS_NEW) + continue; + if (proc.p_fd == NULL) + continue; + if (KREAD(kd, (u_long)p->p_fd, &filed)) { + _kvm_err(kd, kd->program, "can't read filedesc at %x", + p->p_fd); + goto fail; + } + if (filed.fd_lastfile + 1 > ocnt) { + ocnt = filed.fd_lastfile + 1; + free(ofiles); + ofiles = (struct file **)_kvm_malloc(kd, + ocnt * sizeof(struct file *)); + if (ofiles == 0) + return (0); + } + if (KREADN(kd, (u_long)filed.fd_ofiles, ofiles, + ocnt * sizeof(struct file *))) { + _kvm_err(kd, kd->program, "can't read ofiles at %x", + filed.fd_ofiles); + return (0); + } + for (i = 0; i <= filed.fd_lastfile; i++) { + if ((fp = ofiles[i]) == NULL) + continue; + /* + * copyout filehead (legacy) + */ + if (!once) { + *(struct file **)kd->argspc = fp; + *(struct file **)where = fp; + buflen -= sizeof (fp); + where += sizeof (fp); + once = 1; + } + if (buflen < sizeof (struct file)) + goto fail; if (KREAD(kd, (long)fp, ((struct file *)where))) { _kvm_err(kd, kd->program, "can't read kfp"); - return (0); + goto fail; } buflen -= sizeof (struct file); fp = (struct file *)where; @@ -109,11 +146,12 @@ kvm_deadfiles(kd, op, arg, filehead_o, n n++; } } - if (n != nfiles) { - _kvm_err(kd, kd->program, "inconsistant nfiles"); - return (0); - } - return (nfiles); + free(ofiles); + return (n); +fail: + free(ofiles); + return (0); + } char * @@ -122,11 +160,11 @@ kvm_getfiles(kd, op, arg, cnt) int op, arg; int *cnt; { - int mib[2], st, nfiles; + int mib[2], st, n, nfiles, nprocs; size_t size; - struct file *fp, *fplim; - struct filelist filehead; + _kvm_syserr(kd, kd->program, "kvm_getfiles has been broken for years"); + return (0); if (ISALIVE(kd)) { size = 0; mib[0] = CTL_KERN; @@ -144,21 +182,18 @@ kvm_getfiles(kd, op, arg, cnt) return (0); kd->arglen = size; st = sysctl(mib, 2, kd->argspc, &size, NULL, 0); - if (st == -1 || size < sizeof(filehead)) { + if (st != 0) { _kvm_syserr(kd, kd->program, "kvm_getfiles"); return (0); } - filehead = *(struct filelist *)kd->argspc; - fp = (struct file *)(kd->argspc + sizeof (filehead)); - fplim = (struct file *)(kd->argspc + size); - for (nfiles = 0; LIST_FIRST(&filehead) && (fp < fplim); nfiles++, fp++) - LIST_FIRST(&filehead) = LIST_NEXT(fp, f_list); + nfiles = size / sizeof(struct xfile); } else { - struct nlist nl[3], *p; + struct nlist nl[4], *p; - nl[0].n_name = "_filehead"; - nl[1].n_name = "_nfiles"; - nl[2].n_name = 0; + nl[0].n_name = "_allproc"; + nl[1].n_name = "_nprocs"; + nl[2].n_name = "_nfiles"; + nl[3].n_name = 0; if (kvm_nlist(kd, nl) != 0) { for (p = nl; p->n_type != 0; ++p) @@ -167,11 +202,15 @@ kvm_getfiles(kd, op, arg, cnt) "%s: no such symbol", p->n_name); return (0); } - if (KREAD(kd, nl[0].n_value, &nfiles)) { + if (KREAD(kd, nl[1].n_value, &nprocs)) { + _kvm_err(kd, kd->program, "can't read nprocs"); + return (0); + } + if (KREAD(kd, nl[2].n_value, &nfiles)) { _kvm_err(kd, kd->program, "can't read nfiles"); return (0); } - size = sizeof(filehead) + (nfiles + 10) * sizeof(struct file); + size = sizeof(void *) + (nfiles + 10) * sizeof(struct file); if (kd->argspc == 0) kd->argspc = (char *)_kvm_malloc(kd, size); else if (kd->arglen < size) @@ -179,9 +218,12 @@ kvm_getfiles(kd, op, arg, cnt) if (kd->argspc == 0) return (0); kd->arglen = size; - nfiles = kvm_deadfiles(kd, op, arg, nl[1].n_value, nfiles); - if (nfiles == 0) + n = kvm_deadfiles(kd, op, arg, nl[0].n_value, nprocs); + if (n != nfiles) { + _kvm_err(kd, kd->program, "inconsistant nfiles"); return (0); + } + nfiles = n; } *cnt = nfiles; return (kd->argspc); Modified: user/kmacy/releng_7_2_fcs/sys/sys/file.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/file.h Wed May 20 19:51:43 2009 (r192466) +++ user/kmacy/releng_7_2_fcs/sys/sys/file.h Wed May 20 19:53:10 2009 (r192467) @@ -93,7 +93,9 @@ struct fileops { #define DFLAG_PASSABLE 0x01 /* may be passed via unix sockets. */ #define DFLAG_SEEKABLE 0x02 /* seekable / nonsequential */ +#endif /* _KERNEL */ +#if defined(_KERNEL) || defined(_WANT_FILE) /* * Kernel descriptor table. * One entry for each open kernel vnode and socket. @@ -133,7 +135,7 @@ struct file { #define FOFFSET_LOCKED 0x1 #define FOFFSET_LOCK_WAITING 0x2 -#endif /* _KERNEL */ +#endif /* _KERNEL || _WANT_FILE */ /* * Userland version of struct file, for sysctl Modified: user/kmacy/releng_7_2_fcs/usr.bin/fstat/fstat.c ============================================================================== --- user/kmacy/releng_7_2_fcs/usr.bin/fstat/fstat.c Wed May 20 19:51:43 2009 (r192466) +++ user/kmacy/releng_7_2_fcs/usr.bin/fstat/fstat.c Wed May 20 19:53:10 2009 (r192467) @@ -60,10 +60,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#define _WANT_FILE +#include #define _KERNEL #include #include -#include #include #include #include From owner-svn-src-user@FreeBSD.ORG Wed May 20 21:34:02 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A07B51065674; Wed, 20 May 2009 21:34:02 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8BA7C8FC24; Wed, 20 May 2009 21:34:02 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4KLY26I044551; Wed, 20 May 2009 21:34:02 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4KLY1on044536; Wed, 20 May 2009 21:34:02 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905202134.n4KLY1on044536@svn.freebsd.org> From: Kip Macy Date: Wed, 20 May 2009 21:34:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192480 - in user/kmacy/ZFS_MFC: lib/libc/net lib/libpmc release/doc/en_US.ISO8859-1/errata share/man/man4 share/man/man9 sys sys/amd64/amd64 sys/arm/arm sys/contrib/pf sys/dev/age sys/... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 21:34:02 -0000 Author: kmacy Date: Wed May 20 21:34:01 2009 New Revision: 192480 URL: http://svn.freebsd.org/changeset/base/192480 Log: MF_RELENG_7 192158:192478 bring up to date before merging back Modified: user/kmacy/ZFS_MFC/lib/libc/net/sourcefilter.c user/kmacy/ZFS_MFC/lib/libpmc/ (props changed) user/kmacy/ZFS_MFC/lib/libpmc/pmc.h user/kmacy/ZFS_MFC/lib/libpmc/pmclog.h user/kmacy/ZFS_MFC/release/doc/en_US.ISO8859-1/errata/article.sgml user/kmacy/ZFS_MFC/share/man/man4/ (props changed) user/kmacy/ZFS_MFC/share/man/man4/hifn.4 user/kmacy/ZFS_MFC/share/man/man4/igb.4 (props changed) user/kmacy/ZFS_MFC/share/man/man4/ubsec.4 user/kmacy/ZFS_MFC/share/man/man9/ (props changed) user/kmacy/ZFS_MFC/share/man/man9/sbuf.9 user/kmacy/ZFS_MFC/sys/ (props changed) user/kmacy/ZFS_MFC/sys/amd64/amd64/intr_machdep.c user/kmacy/ZFS_MFC/sys/arm/arm/intr.c user/kmacy/ZFS_MFC/sys/contrib/pf/ (props changed) user/kmacy/ZFS_MFC/sys/dev/age/if_age.c user/kmacy/ZFS_MFC/sys/dev/age/if_agereg.h user/kmacy/ZFS_MFC/sys/dev/ale/if_ale.c user/kmacy/ZFS_MFC/sys/dev/ata/ata-chipset.c user/kmacy/ZFS_MFC/sys/dev/ata/ata-pci.h user/kmacy/ZFS_MFC/sys/dev/ath/ath_hal/ (props changed) user/kmacy/ZFS_MFC/sys/dev/bce/if_bce.c user/kmacy/ZFS_MFC/sys/dev/bce/if_bcereg.h user/kmacy/ZFS_MFC/sys/dev/bge/if_bge.c user/kmacy/ZFS_MFC/sys/dev/ciss/ciss.c user/kmacy/ZFS_MFC/sys/dev/cxgb/ (props changed) user/kmacy/ZFS_MFC/sys/dev/pci/pcireg.h user/kmacy/ZFS_MFC/sys/dev/sk/if_sk.c user/kmacy/ZFS_MFC/sys/dev/uart/uart_dev_ns8250.c user/kmacy/ZFS_MFC/sys/fs/devfs/devfs_vnops.c user/kmacy/ZFS_MFC/sys/i386/i386/intr_machdep.c user/kmacy/ZFS_MFC/sys/ia64/ia64/interrupt.c user/kmacy/ZFS_MFC/sys/kern/kern_cpuset.c user/kmacy/ZFS_MFC/sys/kern/kern_intr.c user/kmacy/ZFS_MFC/sys/kern/kern_malloc.c user/kmacy/ZFS_MFC/sys/kern/kern_osd.c user/kmacy/ZFS_MFC/sys/net/if_vlan.c user/kmacy/ZFS_MFC/sys/netgraph/netflow/ng_netflow.c user/kmacy/ZFS_MFC/sys/netinet/ip_fw2.c user/kmacy/ZFS_MFC/sys/powerpc/powerpc/intr_machdep.c user/kmacy/ZFS_MFC/sys/sparc64/sparc64/intr_machdep.c user/kmacy/ZFS_MFC/sys/sun4v/sun4v/intr_machdep.c user/kmacy/ZFS_MFC/sys/sys/_null.h user/kmacy/ZFS_MFC/sys/sys/cpuset.h user/kmacy/ZFS_MFC/sys/sys/interrupt.h user/kmacy/ZFS_MFC/sys/sys/namei.h user/kmacy/ZFS_MFC/sys/ufs/ufs/ufs_extern.h user/kmacy/ZFS_MFC/sys/ufs/ufs/ufs_lookup.c user/kmacy/ZFS_MFC/sys/ufs/ufs/ufs_vnops.c user/kmacy/ZFS_MFC/usr.bin/cpuset/ (props changed) user/kmacy/ZFS_MFC/usr.bin/cpuset/cpuset.1 user/kmacy/ZFS_MFC/usr.bin/cpuset/cpuset.c user/kmacy/ZFS_MFC/usr.sbin/pciconf/ (props changed) user/kmacy/ZFS_MFC/usr.sbin/pciconf/cap.c Modified: user/kmacy/ZFS_MFC/lib/libc/net/sourcefilter.c ============================================================================== --- user/kmacy/ZFS_MFC/lib/libc/net/sourcefilter.c Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/lib/libc/net/sourcefilter.c Wed May 20 21:34:01 2009 (r192480) @@ -1,6 +1,6 @@ /*- - * Copyright (c) 2007 Bruce M. Simpson. - * All rights reserved + * Copyright (c) 2007-2009 Bruce Simpson. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,21 +10,18 @@ * 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. - * 4. Neither the name of Bruce M. Simpson nor the names of other - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY BRUCE M. SIMPSON AND AFFILIATES - * ``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 BRUCE M. SIMPSON 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. + * 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 @@ -340,7 +337,7 @@ getsourcefilter(int s, uint32_t interfac { struct __msfilterreq msfr; sockunion_t *psu; - int err, level, optlen, optname; + int err, level, nsrcs, optlen, optname; if (interface == 0 || group == NULL || numsrc == NULL || fmode == NULL) { @@ -348,6 +345,7 @@ getsourcefilter(int s, uint32_t interfac return (-1); } + nsrcs = *numsrc; *numsrc = 0; *fmode = 0; @@ -385,7 +383,7 @@ getsourcefilter(int s, uint32_t interfac memset(&msfr, 0, optlen); msfr.msfr_ifindex = interface; msfr.msfr_fmode = 0; - msfr.msfr_nsrcs = *numsrc; + msfr.msfr_nsrcs = nsrcs; memcpy(&msfr.msfr_group, &psu->ss, psu->ss.ss_len); /* Modified: user/kmacy/ZFS_MFC/lib/libpmc/pmc.h ============================================================================== --- user/kmacy/ZFS_MFC/lib/libpmc/pmc.h Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/lib/libpmc/pmc.h Wed May 20 21:34:01 2009 (r192480) @@ -29,6 +29,7 @@ #ifndef _PMC_H_ #define _PMC_H_ +#include #include /* @@ -68,6 +69,7 @@ struct pmc_pmcinfo { * Prototypes */ +__BEGIN_DECLS int pmc_allocate(const char *_ctrspec, enum pmc_mode _mode, uint32_t _flags, int _cpu, pmc_id_t *_pmcid); int pmc_attach(pmc_id_t _pmcid, pid_t _pid); @@ -105,5 +107,6 @@ const char *pmc_name_of_state(enum pmc_s int pmc_event_names_of_class(enum pmc_class _cl, const char ***_eventnames, int *_nevents); +__END_DECLS #endif Modified: user/kmacy/ZFS_MFC/lib/libpmc/pmclog.h ============================================================================== --- user/kmacy/ZFS_MFC/lib/libpmc/pmclog.h Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/lib/libpmc/pmclog.h Wed May 20 21:34:01 2009 (r192480) @@ -29,6 +29,7 @@ #ifndef _PMCLOG_H_ #define _PMCLOG_H_ +#include #include enum pmclog_state { @@ -145,10 +146,12 @@ struct pmclog_ev { #define PMCLOG_FD_NONE (-1) +__BEGIN_DECLS void *pmclog_open(int _fd); int pmclog_feed(void *_cookie, char *_data, int _len); int pmclog_read(void *_cookie, struct pmclog_ev *_ev); void pmclog_close(void *_cookie); +__END_DECLS #endif Modified: user/kmacy/ZFS_MFC/release/doc/en_US.ISO8859-1/errata/article.sgml ============================================================================== --- user/kmacy/ZFS_MFC/release/doc/en_US.ISO8859-1/errata/article.sgml Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/release/doc/en_US.ISO8859-1/errata/article.sgml Wed May 20 21:34:01 2009 (r192480) @@ -183,6 +183,15 @@ Errata Notice to fix this problem is planned after the release. + [20090507] A bug was found in the &man.fxp.4; driver. This + would cause poor TCP performance when TSO is enabled, and the + receiver has a smaller MSS than the interface MTU setting. To + workaround this issue, one can disable TSO by using + &man.ifconfig.8; parameter (per interface + basis) or setting net.inet.tcp.tso to + 0 (globally on the system). An Errata Notice + to fix this problem is planned after the release. + Late-Breaking News and Corrections @@ -190,5 +199,10 @@ &man.malloc.3; implementation and threading library has been committed to the RELENG_7 branch for public testing. + + [20090507] A patch to solve the bug in the &man.fxp.4; + driver that caused poor TCP performance has been committed to + the RELENG_7 branch for public + testing. Modified: user/kmacy/ZFS_MFC/share/man/man4/hifn.4 ============================================================================== --- user/kmacy/ZFS_MFC/share/man/man4/hifn.4 Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/share/man/man4/hifn.4 Wed May 20 21:34:01 2009 (r192480) @@ -11,8 +11,6 @@ .\" 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. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED Modified: user/kmacy/ZFS_MFC/share/man/man4/ubsec.4 ============================================================================== --- user/kmacy/ZFS_MFC/share/man/man4/ubsec.4 Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/share/man/man4/ubsec.4 Wed May 20 21:34:01 2009 (r192480) @@ -1,4 +1,4 @@ -.\" $OpenBSD: ubsec.4,v 1.18 2002/09/26 07:55:41 miod Exp $ +.\" $OpenBSD: ubsec.4,v 1.25 2003/08/12 19:42:46 jason Exp $ .\" .\" Copyright (c) 2000 Jason L. Wright (jason@thought.net) .\" All rights reserved. @@ -11,11 +11,6 @@ .\" 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by Jason L. Wright -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -31,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 1, 2006 +.Dd May 16, 2009 .Dt UBSEC 4 .Os .Sh NAME @@ -84,7 +79,7 @@ driver supports cards containing any of .It Bluesteel 5501 The original chipset, no longer made. This extremely rare unit -was not very fast, lacked a RNG, and had a number of other bugs. +was not very fast, lacked an RNG, and had a number of other bugs. .It Bluesteel 5601 A faster and fixed version of the original, with a random number unit and large number engine added. @@ -98,6 +93,7 @@ Faster version of Bluesteel 5601. 64 bit version of the chip, and significantly more advanced. .It Broadcom BCM5821 Faster version of the BCM5820. +This is the chip found on the Sun Crypto Accelerator 1000. .It Broadcom BCM5822 Faster version of the BCM5820. .It Broadcom BCM5823 Modified: user/kmacy/ZFS_MFC/share/man/man9/sbuf.9 ============================================================================== --- user/kmacy/ZFS_MFC/share/man/man9/sbuf.9 Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/share/man/man9/sbuf.9 Wed May 20 21:34:01 2009 (r192480) @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2000 Poul Henning Kamp and Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2000 Poul-Henning Kamp and Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,12 +25,13 @@ .\" .\" $FreeBSD$ .\" -.Dd July 9, 2004 +.Dd May 17, 2009 .Dt SBUF 9 .Os .Sh NAME .Nm sbuf , .Nm sbuf_new , +.Nm sbuf_new_auto , .Nm sbuf_clear , .Nm sbuf_setpos , .Nm sbuf_bcat , @@ -55,6 +56,8 @@ .In sys/sbuf.h .Ft struct sbuf * .Fn sbuf_new "struct sbuf *s" "char *buf" "int length" "int flags" +.Ft struct sbuf * +.Fn sbuf_new_auto .Ft void .Fn sbuf_clear "struct sbuf *s" .Ft int @@ -148,6 +151,19 @@ The result of accessing that array direc sbuf is undefined. .Pp The +.Fn sbuf_new_auto +function is a shortcut for creating a completely dynamic +.Nm . +It is the equivalent of calling +.Fn sbuf_new +with values +.Dv NULL , +.Dv NULL , +.Dv 0 , +and +.Dv SBUF_AUTOEXTEND . +.Pp +The .Fn sbuf_delete function clears the .Fa sbuf Modified: user/kmacy/ZFS_MFC/sys/amd64/amd64/intr_machdep.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/amd64/amd64/intr_machdep.c Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/sys/amd64/amd64/intr_machdep.c Wed May 20 21:34:01 2009 (r192480) @@ -77,12 +77,6 @@ static struct sx intr_table_lock; static struct mtx intrcnt_lock; static STAILQ_HEAD(, pic) pics; -#ifdef INTR_FILTER -static void intr_eoi_src(void *arg); -static void intr_disab_eoi_src(void *arg); -static void intr_event_stray(void *cookie); -#endif - #ifdef SMP static int assign_cpu; @@ -90,6 +84,7 @@ static void intr_assign_next_cpu(struct #endif static int intr_assign_cpu(void *arg, u_char cpu); +static void intr_disable_src(void *arg); static void intr_init(void *__dummy); static int intr_pic_registered(struct pic *pic); static void intrcnt_setname(const char *name, int index); @@ -144,16 +139,10 @@ intr_register_source(struct intsrc *isrc vector = isrc->is_pic->pic_vector(isrc); if (interrupt_sources[vector] != NULL) return (EEXIST); -#ifdef INTR_FILTER - error = intr_event_create(&isrc->is_event, isrc, 0, - (mask_fn)isrc->is_pic->pic_enable_source, - intr_eoi_src, intr_disab_eoi_src, intr_assign_cpu, "irq%d:", + error = intr_event_create(&isrc->is_event, isrc, 0, vector, + intr_disable_src, (mask_fn)isrc->is_pic->pic_enable_source, + (mask_fn)isrc->is_pic->pic_eoi_source, intr_assign_cpu, "irq%d:", vector); -#else - error = intr_event_create(&isrc->is_event, isrc, 0, - (mask_fn)isrc->is_pic->pic_enable_source, intr_assign_cpu, "irq%d:", - vector); -#endif if (error) return (error); sx_xlock(&intr_table_lock); @@ -237,84 +226,21 @@ intr_config_intr(int vector, enum intr_t return (isrc->is_pic->pic_config_intr(isrc, trig, pol)); } -#ifdef INTR_FILTER -void -intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) -{ - struct thread *td; - struct intr_event *ie; - int vector; - - td = curthread; - - /* - * We count software interrupts when we process them. The - * code here follows previous practice, but there's an - * argument for counting hardware interrupts when they're - * processed too. - */ - (*isrc->is_count)++; - PCPU_INC(cnt.v_intr); - - ie = isrc->is_event; - - /* - * XXX: We assume that IRQ 0 is only used for the ISA timer - * device (clk). - */ - vector = isrc->is_pic->pic_vector(isrc); - if (vector == 0) - clkintr_pending = 1; - - if (intr_event_handle(ie, frame) != 0) - intr_event_stray(isrc); -} - static void -intr_event_stray(void *cookie) -{ - struct intsrc *isrc; - - isrc = cookie; - /* - * For stray interrupts, mask and EOI the source, bump the - * stray count, and log the condition. - */ - isrc->is_pic->pic_disable_source(isrc, PIC_EOI); - (*isrc->is_straycount)++; - if (*isrc->is_straycount < MAX_STRAY_LOG) - log(LOG_ERR, "stray irq%d\n", isrc->is_pic->pic_vector(isrc)); - else if (*isrc->is_straycount == MAX_STRAY_LOG) - log(LOG_CRIT, - "too many stray irq %d's: not logging anymore\n", - isrc->is_pic->pic_vector(isrc)); -} - -static void -intr_eoi_src(void *arg) -{ - struct intsrc *isrc; - - isrc = arg; - isrc->is_pic->pic_eoi_source(isrc); -} - -static void -intr_disab_eoi_src(void *arg) +intr_disable_src(void *arg) { struct intsrc *isrc; isrc = arg; isrc->is_pic->pic_disable_source(isrc, PIC_EOI); } -#else + void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) { - struct thread *td; struct intr_event *ie; - struct intr_handler *ih; - int error, vector, thread, ret; + struct thread *td; + int vector; td = curthread; @@ -341,7 +267,7 @@ intr_execute_handlers(struct intsrc *isr * For stray interrupts, mask and EOI the source, bump the * stray count, and log the condition. */ - if (ie == NULL || TAILQ_EMPTY(&ie->ie_handlers)) { + if (intr_event_handle(ie, frame) != 0) { isrc->is_pic->pic_disable_source(isrc, PIC_EOI); (*isrc->is_straycount)++; if (*isrc->is_straycount < MAX_STRAY_LOG) @@ -350,60 +276,8 @@ intr_execute_handlers(struct intsrc *isr log(LOG_CRIT, "too many stray irq %d's: not logging anymore\n", vector); - return; - } - - /* - * Execute fast interrupt handlers directly. - * To support clock handlers, if a handler registers - * with a NULL argument, then we pass it a pointer to - * a trapframe as its argument. - */ - td->td_intr_nesting_level++; - ret = 0; - thread = 0; - critical_enter(); - TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) { - if (ih->ih_filter == NULL) { - thread = 1; - continue; - } - CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__, - ih->ih_filter, ih->ih_argument == NULL ? frame : - ih->ih_argument, ih->ih_name); - if (ih->ih_argument == NULL) - ret = ih->ih_filter(frame); - else - ret = ih->ih_filter(ih->ih_argument); - /* - * Wrapper handler special case: see - * i386/intr_machdep.c::intr_execute_handlers() - */ - if (!thread) { - if (ret == FILTER_SCHEDULE_THREAD) - thread = 1; - } } - - /* - * If there are any threaded handlers that need to run, - * mask the source as well as sending it an EOI. Otherwise, - * just send it an EOI but leave it unmasked. - */ - if (thread) - isrc->is_pic->pic_disable_source(isrc, PIC_EOI); - else - isrc->is_pic->pic_eoi_source(isrc); - - /* Schedule the ithread if needed. */ - if (thread) { - error = intr_event_schedule_thread(ie); - KASSERT(error == 0, ("bad stray interrupt")); - } - critical_exit(); - td->td_intr_nesting_level--; } -#endif void intr_resume(void) Modified: user/kmacy/ZFS_MFC/sys/arm/arm/intr.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/arm/arm/intr.c Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/sys/arm/arm/intr.c Wed May 20 21:34:01 2009 (r192480) @@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$"); #include #include +typedef void (*mask_fn)(void *); + static struct intr_event *intr_events[NIRQ]; static int intrcnt_tab[NIRQ]; static int intrcnt_index = 0; @@ -57,27 +59,6 @@ static int last_printed = 0; void arm_handler_execute(struct trapframe *, int); -#ifdef INTR_FILTER -static void -intr_disab_eoi_src(void *arg) -{ - uintptr_t nb; - - nb = (uintptr_t)arg; - arm_mask_irq(nb); -} - -static void -intr_eoi_src(void *arg) -{ - uintptr_t nb; - - nb = (uintptr_t)arg; - arm_unmask_irq(nb); -} - -#endif - void arm_setup_irqhandler(const char *name, driver_filter_t *filt, void (*hand)(void*), void *arg, int irq, int flags, void **cookiep) @@ -89,14 +70,9 @@ arm_setup_irqhandler(const char *name, d return; event = intr_events[irq]; if (event == NULL) { -#ifdef INTR_FILTER - error = intr_event_create(&event, (void *)irq, 0, - (void (*)(void *))arm_unmask_irq, intr_eoi_src, - intr_disab_eoi_src, NULL, "intr%d:", irq); -#else - error = intr_event_create(&event, (void *)irq, 0, - (void (*)(void *))arm_unmask_irq, NULL, "intr%d:", irq); -#endif + error = intr_event_create(&event, (void *)irq, 0, irq, + (mask_fn)arm_mask_irq, (mask_fn)arm_unmask_irq, + NULL, NULL, "intr%d:", irq); if (error) return; intr_events[irq] = event; @@ -130,57 +106,17 @@ arm_handler_execute(struct trapframe *fr { struct intr_event *event; struct thread *td = curthread; -#ifdef INTR_FILTER int i; -#else - int i, thread, ret; - struct intr_handler *ih; -#endif PCPU_INC(cnt.v_intr); td->td_intr_nesting_level++; while ((i = arm_get_next_irq()) != -1) { -#ifndef INTR_FILTER - arm_mask_irq(i); -#endif intrcnt[intrcnt_tab[i]]++; event = intr_events[i]; - if (!event || TAILQ_EMPTY(&event->ie_handlers)) { -#ifdef INTR_FILTER + if (intr_event_handle(event, frame) != 0) { + /* XXX: Log stray IRQs */ arm_mask_irq(i); -#endif - continue; } - -#ifdef INTR_FILTER - intr_event_handle(event, frame); - /* XXX: Log stray IRQs */ -#else - /* Execute fast handlers. */ - ret = 0; - thread = 0; - TAILQ_FOREACH(ih, &event->ie_handlers, ih_next) { - if (ih->ih_filter == NULL) - thread = 1; - else - ret = ih->ih_filter(ih->ih_argument ? - ih->ih_argument : frame); - /* - * Wrapper handler special case: see - * i386/intr_machdep.c::intr_execute_handlers() - */ - if (!thread) { - if (ret == FILTER_SCHEDULE_THREAD) - thread = 1; - } - } - - /* Schedule thread if needed. */ - if (thread) - intr_event_schedule_thread(event); - else - arm_unmask_irq(i); -#endif } td->td_intr_nesting_level--; } Modified: user/kmacy/ZFS_MFC/sys/dev/age/if_age.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/dev/age/if_age.c Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/sys/dev/age/if_age.c Wed May 20 21:34:01 2009 (r192480) @@ -106,8 +106,6 @@ static int age_miibus_writereg(device_t, static void age_miibus_statchg(device_t); static void age_mediastatus(struct ifnet *, struct ifmediareq *); static int age_mediachange(struct ifnet *); -static int age_read_vpd_word(struct age_softc *, uint32_t, uint32_t, - uint32_t *); static int age_probe(device_t); static void age_get_macaddr(struct age_softc *); static void age_phy_reset(struct age_softc *); @@ -321,29 +319,6 @@ age_mediachange(struct ifnet *ifp) } static int -age_read_vpd_word(struct age_softc *sc, uint32_t vpdc, uint32_t offset, - uint32_t *word) -{ - int i; - - pci_write_config(sc->age_dev, vpdc + PCIR_VPD_ADDR, offset, 2); - for (i = AGE_TIMEOUT; i > 0; i--) { - DELAY(10); - if ((pci_read_config(sc->age_dev, vpdc + PCIR_VPD_ADDR, 2) & - 0x8000) == 0x8000) - break; - } - if (i == 0) { - device_printf(sc->age_dev, "VPD read timeout!\n"); - *word = 0; - return (ETIMEDOUT); - } - - *word = pci_read_config(sc->age_dev, vpdc + PCIR_VPD_DATA, 4); - return (0); -} - -static int age_probe(device_t dev) { struct age_dev *sp; @@ -368,8 +343,8 @@ age_probe(device_t dev) static void age_get_macaddr(struct age_softc *sc) { - uint32_t ea[2], off, reg, word; - int vpd_error, match, vpdc; + uint32_t ea[2], reg; + int i, vpdc; reg = CSR_READ_4(sc, AGE_SPI_CTRL); if ((reg & SPI_VPD_ENB) != 0) { @@ -378,123 +353,114 @@ age_get_macaddr(struct age_softc *sc) CSR_WRITE_4(sc, AGE_SPI_CTRL, reg); } - vpd_error = 0; - ea[0] = ea[1] = 0; - if ((vpd_error = pci_find_extcap(sc->age_dev, PCIY_VPD, &vpdc)) == 0) { + if (pci_find_extcap(sc->age_dev, PCIY_VPD, &vpdc) == 0) { /* - * PCI VPD capability exists, but it seems that it's - * not in the standard form as stated in PCI VPD - * specification such that driver could not use - * pci_get_vpd_readonly(9) with keyword 'NA'. - * Search VPD data starting at address 0x0100. The data - * should be used as initializers to set AGE_PAR0, - * AGE_PAR1 register including other PCI configuration - * registers. + * PCI VPD capability found, let TWSI reload EEPROM. + * This will set ethernet address of controller. */ - word = 0; - match = 0; - reg = 0; - for (off = AGE_VPD_REG_CONF_START; off < AGE_VPD_REG_CONF_END; - off += sizeof(uint32_t)) { - vpd_error = age_read_vpd_word(sc, vpdc, off, &word); - if (vpd_error != 0) - break; - if (match != 0) { - switch (reg) { - case AGE_PAR0: - ea[0] = word; - break; - case AGE_PAR1: - ea[1] = word; - break; - default: - break; - } - match = 0; - } else if ((word & 0xFF) == AGE_VPD_REG_CONF_SIG) { - match = 1; - reg = word >> 16; - } else + CSR_WRITE_4(sc, AGE_TWSI_CTRL, CSR_READ_4(sc, AGE_TWSI_CTRL) | + TWSI_CTRL_SW_LD_START); + for (i = 100; i > 0; i--) { + DELAY(1000); + reg = CSR_READ_4(sc, AGE_TWSI_CTRL); + if ((reg & TWSI_CTRL_SW_LD_START) == 0) break; } - if (off >= AGE_VPD_REG_CONF_END) - vpd_error = ENOENT; - if (vpd_error == 0) { - /* - * Don't blindly trust ethernet address obtained - * from VPD. Check whether ethernet address is - * valid one. Otherwise fall-back to reading - * PAR register. - */ - ea[1] &= 0xFFFF; - if ((ea[0] == 0 && ea[1] == 0) || - (ea[0] == 0xFFFFFFFF && ea[1] == 0xFFFF)) { - if (bootverbose) - device_printf(sc->age_dev, - "invalid ethernet address " - "returned from VPD.\n"); - vpd_error = EINVAL; - } - } - if (vpd_error != 0 && (bootverbose)) - device_printf(sc->age_dev, "VPD access failure!\n"); + if (i == 0) + device_printf(sc->age_dev, + "reloading EEPROM timeout!\n"); } else { if (bootverbose) device_printf(sc->age_dev, "PCI VPD capability not found!\n"); } - /* - * It seems that L1 also provides a way to extract ethernet - * address via SPI flash interface. Because SPI flash memory - * device of different vendors vary in their instruction - * codes for read ID instruction, it's very hard to get - * instructions codes without detailed information for the - * flash memory device used on ethernet controller. To simplify - * code, just read AGE_PAR0/AGE_PAR1 register to get ethernet - * address which is supposed to be set by hardware during - * power on reset. - */ - if (vpd_error != 0) { - /* - * VPD is mapped to SPI flash memory or BIOS set it. - */ - ea[0] = CSR_READ_4(sc, AGE_PAR0); - ea[1] = CSR_READ_4(sc, AGE_PAR1); - } - - ea[1] &= 0xFFFF; - if ((ea[0] == 0 && ea[1] == 0) || - (ea[0] == 0xFFFFFFFF && ea[1] == 0xFFFF)) { - device_printf(sc->age_dev, - "generating fake ethernet address.\n"); - ea[0] = arc4random(); - /* Set OUI to ASUSTek COMPUTER INC. */ - sc->age_eaddr[0] = 0x00; - sc->age_eaddr[1] = 0x1B; - sc->age_eaddr[2] = 0xFC; - sc->age_eaddr[3] = (ea[0] >> 16) & 0xFF; - sc->age_eaddr[4] = (ea[0] >> 8) & 0xFF; - sc->age_eaddr[5] = (ea[0] >> 0) & 0xFF; - } else { - sc->age_eaddr[0] = (ea[1] >> 8) & 0xFF; - sc->age_eaddr[1] = (ea[1] >> 0) & 0xFF; - sc->age_eaddr[2] = (ea[0] >> 24) & 0xFF; - sc->age_eaddr[3] = (ea[0] >> 16) & 0xFF; - sc->age_eaddr[4] = (ea[0] >> 8) & 0xFF; - sc->age_eaddr[5] = (ea[0] >> 0) & 0xFF; - } + ea[0] = CSR_READ_4(sc, AGE_PAR0); + ea[1] = CSR_READ_4(sc, AGE_PAR1); + sc->age_eaddr[0] = (ea[1] >> 8) & 0xFF; + sc->age_eaddr[1] = (ea[1] >> 0) & 0xFF; + sc->age_eaddr[2] = (ea[0] >> 24) & 0xFF; + sc->age_eaddr[3] = (ea[0] >> 16) & 0xFF; + sc->age_eaddr[4] = (ea[0] >> 8) & 0xFF; + sc->age_eaddr[5] = (ea[0] >> 0) & 0xFF; } static void age_phy_reset(struct age_softc *sc) { + uint16_t reg, pn; + int i, linkup; /* Reset PHY. */ CSR_WRITE_4(sc, AGE_GPHY_CTRL, GPHY_CTRL_RST); - DELAY(1000); + DELAY(2000); CSR_WRITE_4(sc, AGE_GPHY_CTRL, GPHY_CTRL_CLR); - DELAY(1000); + DELAY(2000); + +#define ATPHY_DBG_ADDR 0x1D +#define ATPHY_DBG_DATA 0x1E +#define ATPHY_CDTC 0x16 +#define PHY_CDTC_ENB 0x0001 +#define PHY_CDTC_POFF 8 +#define ATPHY_CDTS 0x1C +#define PHY_CDTS_STAT_OK 0x0000 +#define PHY_CDTS_STAT_SHORT 0x0100 +#define PHY_CDTS_STAT_OPEN 0x0200 +#define PHY_CDTS_STAT_INVAL 0x0300 +#define PHY_CDTS_STAT_MASK 0x0300 + + /* Check power saving mode. Magic from Linux. */ + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, MII_BMCR, BMCR_RESET); + for (linkup = 0, pn = 0; pn < 4; pn++) { + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, ATPHY_CDTC, + (pn << PHY_CDTC_POFF) | PHY_CDTC_ENB); + for (i = 200; i > 0; i--) { + DELAY(1000); + reg = age_miibus_readreg(sc->age_dev, sc->age_phyaddr, + ATPHY_CDTC); + if ((reg & PHY_CDTC_ENB) == 0) + break; + } + DELAY(1000); + reg = age_miibus_readreg(sc->age_dev, sc->age_phyaddr, + ATPHY_CDTS); + if ((reg & PHY_CDTS_STAT_MASK) != PHY_CDTS_STAT_OPEN) { + linkup++; + break; + } + } + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, MII_BMCR, + BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG); + if (linkup == 0) { + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, + ATPHY_DBG_ADDR, 0); + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, + ATPHY_DBG_DATA, 0x124E); + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, + ATPHY_DBG_ADDR, 1); + reg = age_miibus_readreg(sc->age_dev, sc->age_phyaddr, + ATPHY_DBG_DATA); + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, + ATPHY_DBG_DATA, reg | 0x03); + /* XXX */ + DELAY(1500 * 1000); + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, + ATPHY_DBG_ADDR, 0); + age_miibus_writereg(sc->age_dev, sc->age_phyaddr, + ATPHY_DBG_DATA, 0x024E); + } + +#undef ATPHY_DBG_ADDR +#undef ATPHY_DBG_DATA +#undef ATPHY_CDTC +#undef PHY_CDTC_ENB +#undef PHY_CDTC_POFF +#undef ATPHY_CDTS +#undef PHY_CDTS_STAT_OK +#undef PHY_CDTS_STAT_SHORT +#undef PHY_CDTS_STAT_OPEN +#undef PHY_CDTS_STAT_INVAL +#undef PHY_CDTS_STAT_MASK } static int @@ -539,7 +505,8 @@ age_attach(device_t dev) sc->age_chip_rev = CSR_READ_4(sc, AGE_MASTER_CFG) >> MASTER_CHIP_REV_SHIFT; if (bootverbose) { - device_printf(dev, "PCI device revision : 0x%04x\n", sc->age_rev); + device_printf(dev, "PCI device revision : 0x%04x\n", + sc->age_rev); device_printf(dev, "Chip id/revision : 0x%04x\n", sc->age_chip_rev); } @@ -1369,7 +1336,7 @@ age_setwol(struct age_softc *sc) AGE_LOCK_ASSERT(sc); - if (pci_find_extcap(sc->age_dev, PCIY_PMG, &pmc) == 0) { + if (pci_find_extcap(sc->age_dev, PCIY_PMG, &pmc) != 0) { CSR_WRITE_4(sc, AGE_WOL_CFG, 0); /* * No PME capability, PHY power down. @@ -1524,6 +1491,9 @@ age_resume(device_t dev) cmd &= ~0x0400; pci_write_config(sc->age_dev, PCIR_COMMAND, cmd, 2); } + AGE_UNLOCK(sc); + age_phy_reset(sc); + AGE_LOCK(sc); ifp = sc->age_ifp; if ((ifp->if_flags & IFF_UP) != 0) age_init_locked(sc); @@ -2544,14 +2514,8 @@ age_reset(struct age_softc *sc) int i; CSR_WRITE_4(sc, AGE_MASTER_CFG, MASTER_RESET); - for (i = AGE_RESET_TIMEOUT; i > 0; i--) { - DELAY(1); - if ((CSR_READ_4(sc, AGE_MASTER_CFG) & MASTER_RESET) == 0) - break; - } - if (i == 0) - device_printf(sc->age_dev, "master reset timeout!\n"); - + CSR_READ_4(sc, AGE_MASTER_CFG); + DELAY(1000); for (i = AGE_RESET_TIMEOUT; i > 0; i--) { if ((reg = CSR_READ_4(sc, AGE_IDLE_STATUS)) == 0) break; Modified: user/kmacy/ZFS_MFC/sys/dev/age/if_agereg.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/dev/age/if_agereg.h Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/sys/dev/age/if_agereg.h Wed May 20 21:34:01 2009 (r192480) @@ -91,6 +91,9 @@ #define AGE_SPI_OP_READ 0x217 /* 8bits */ #define AGE_TWSI_CTRL 0x218 +#define TWSI_CTRL_SW_LD_START 0x00000800 +#define TWSI_CTRL_HW_LD_START 0x00001000 +#define TWSI_CTRL_LD_EXIST 0x00400000 #define AGE_DEV_MISC_CTRL 0x21C Modified: user/kmacy/ZFS_MFC/sys/dev/ale/if_ale.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/dev/ale/if_ale.c Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/sys/dev/ale/if_ale.c Wed May 20 21:34:01 2009 (r192480) @@ -1543,20 +1543,11 @@ ale_resume(device_t dev) struct ale_softc *sc; struct ifnet *ifp; int pmc; - uint16_t cmd, pmstat; + uint16_t pmstat; sc = device_get_softc(dev); ALE_LOCK(sc); - /* - * Clear INTx emulation disable for hardwares that - * is set in resume event. From Linux. - */ - cmd = pci_read_config(sc->ale_dev, PCIR_COMMAND, 2); - if ((cmd & 0x0400) != 0) { - cmd &= ~0x0400; - pci_write_config(sc->ale_dev, PCIR_COMMAND, cmd, 2); - } if (pci_find_extcap(sc->ale_dev, PCIY_PMG, &pmc) == 0) { /* Disable PME and clear PME status. */ pmstat = pci_read_config(sc->ale_dev, Modified: user/kmacy/ZFS_MFC/sys/dev/ata/ata-chipset.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/dev/ata/ata-chipset.c Wed May 20 21:31:47 2009 (r192479) +++ user/kmacy/ZFS_MFC/sys/dev/ata/ata-chipset.c Wed May 20 21:34:01 2009 (r192480) @@ -50,6 +50,12 @@ __FBSDID("$FreeBSD$"); #include #include +struct ata_serialize { + struct mtx locked_mtx; + int locked_ch; + int restart_ch; +}; + /* local prototypes */ /* ata-chipset.c */ static int ata_generic_chipinit(device_t dev); @@ -186,6 +192,7 @@ static struct ata_chip_id *ata_match_chi static struct ata_chip_id *ata_find_chip(device_t dev, struct ata_chip_id *index, int slot); static int ata_setup_interrupt(device_t dev); static int ata_serialize(device_t dev, int flags); +static void ata_serialize_init(struct ata_serialize *serial); static void ata_print_cable(device_t dev, u_int8_t *who); static int ata_atapi(device_t dev); static int ata_check_80pin(device_t dev, int mode); @@ -919,6 +926,7 @@ static int ata_acard_chipinit(device_t dev) { struct ata_pci_controller *ctlr = device_get_softc(dev); + struct ata_serialize *serial; if (ata_setup_interrupt(dev)) return ENXIO; @@ -927,6 +935,10 @@ ata_acard_chipinit(device_t dev) if (ctlr->chip->cfg1 == ATPOLD) { ctlr->setmode = ata_acard_850_setmode; ctlr->locking = ata_serialize; + serial = malloc(sizeof(struct ata_serialize), + M_TEMP, M_WAITOK | M_ZERO); + ata_serialize_init(serial); + ctlr->chipset_data = serial; } else ctlr->setmode = ata_acard_86X_setmode; @@ -3461,7 +3473,7 @@ ata_promise_chipinit(device_t dev) mtx_init(&hpkt->mtx, "ATA promise HPKT lock", NULL, MTX_DEF); TAILQ_INIT(&hpkt->queue); hpkt->busy = 0; - device_set_ivars(dev, hpkt); + ctlr->chipset_data = hpkt; ctlr->allocate = ata_promise_mio_allocate; ctlr->reset = ata_promise_mio_reset; ctlr->dmainit = ata_promise_mio_dmainit; @@ -3908,7 +3920,7 @@ ata_promise_mio_reset(device_t dev) case PRSX4X: /* softreset channel ATA module */ - hpktp = device_get_ivars(ctlr->dev); + hpktp = ctlr->chipset_data; ATA_OUTL(ctlr->r_res2, 0xc0260 + (ch->unit << 7), ch->unit + 1); ata_udelay(1000); ATA_OUTL(ctlr->r_res2, 0xc0260 + (ch->unit << 7), @@ -4247,7 +4259,7 @@ ata_promise_apkt(u_int8_t *bytep, struct static void ata_promise_queue_hpkt(struct ata_pci_controller *ctlr, u_int32_t hpkt) { - struct ata_promise_sx4 *hpktp = device_get_ivars(ctlr->dev); + struct ata_promise_sx4 *hpktp = ctlr->chipset_data; mtx_lock(&hpktp->mtx); if (hpktp->busy) { @@ -4266,7 +4278,7 @@ ata_promise_queue_hpkt(struct ata_pci_co static void ata_promise_next_hpkt(struct ata_pci_controller *ctlr) { - struct ata_promise_sx4 *hpktp = device_get_ivars(ctlr->dev); + struct ata_promise_sx4 *hpktp = ctlr->chipset_data; struct host_packet *hp; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu May 21 02:04:42 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C44E1065670; Thu, 21 May 2009 02:04:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 711B98FC32; Thu, 21 May 2009 02:04:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L24ghV050951; Thu, 21 May 2009 02:04:42 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L24gCp050950; Thu, 21 May 2009 02:04:42 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210204.n4L24gCp050950@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 02:04:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192504 - user/kmacy/releng_7_2_fcs/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 02:04:42 -0000 Author: kmacy Date: Thu May 21 02:04:42 2009 New Revision: 192504 URL: http://svn.freebsd.org/changeset/base/192504 Log: eliminate unneeded devices Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Thu May 21 01:50:27 2009 (r192503) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Thu May 21 02:04:42 2009 (r192504) @@ -95,12 +95,6 @@ device atapist # ATAPI tape drives options ATA_STATIC_ID # Static device numbering # SCSI Controllers -device ahc # AHA2940 and onboard AIC7xxx devices -options AHC_REG_PRETTY_PRINT # Print register bitfields in debug - # output. Adds ~128k to driver. -device ahd # AHA39320/29320 and onboard AIC79xx devices -options AHD_REG_PRETTY_PRINT # Print register bitfields in debug - # output. Adds ~215k to driver. device amd # AMD 53C974 (Tekram DC-390(T)) device hptiop # Highpoint RocketRaid 3xxx series device isp # Qlogic family @@ -187,18 +181,16 @@ device ppi # Parallel port interface d # PCI Ethernet NICs. device em # Intel PRO/1000 Gigabit Ethernet Family -device igb # Intel PRO/1000 PCIE Server Gigabit Family + # PCI Ethernet NICs that use the common MII bus controller code. # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! -#device miibus # MII bus support +device miibus # MII bus support + # Pseudo devices. device loop # Network loopback device random # Entropy device device ether # Ethernet support -#device sl # Kernel SLIP -#device ppp # Kernel PPP -#device tun # Packet tunnel. device pty # Pseudo-ttys (telnet etc) device md # Memory "disks" device gif # IPv6 and IPv4 tunneling @@ -222,7 +214,6 @@ device bpf # Berkeley packet filter #device ulpt # Printer #device umass # Disks/Mass storage - Requires scbus and da #device ums # Mouse -#device ural # Ralink Technology RT2500USB wireless NICs #device urio # Diamond Rio 500 MP3 player #device uscanner # Scanners # USB Serial devices @@ -237,15 +228,6 @@ device bpf # Berkeley packet filter #device uvisor # Visor and Palm devices #device uvscom # USB serial support for DDI pocket's PHS - -# FireWire support -#device firewire # FireWire bus code -#device sbp # SCSI over FireWire (Requires scbus and da) -#device fwe # Ethernet over FireWire (non-standard!) -#device fwip # IP over FireWire (RFC 2734,3146) -#device dcons # Dumb console driver -#device dcons_crom # Configuration ROM for dcons - options DDB options KDB options ALT_BREAK_TO_DEBUGGER From owner-svn-src-user@FreeBSD.ORG Thu May 21 02:21:10 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F53F1065672; Thu, 21 May 2009 02:21:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8E5B58FC17; Thu, 21 May 2009 02:21:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L2LA7t051477; Thu, 21 May 2009 02:21:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L2LAlg051476; Thu, 21 May 2009 02:21:10 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210221.n4L2LAlg051476@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 02:21:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192509 - user/kmacy/releng_7_2_fcs/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 02:21:10 -0000 Author: kmacy Date: Thu May 21 02:21:10 2009 New Revision: 192509 URL: http://svn.freebsd.org/changeset/base/192509 Log: add linux and linprocfs to modules Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Thu May 21 02:19:01 2009 (r192508) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Thu May 21 02:21:10 2009 (r192509) @@ -25,7 +25,7 @@ ident GENERIC #hints "GENERIC.hints" # Default places to look for devices. makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions MODULES_OVERRIDE="mxge zlib geom opensolaris zfs cxgb fxp nfe hwpmc" +makeoptions MODULES_OVERRIDE="mxge zlib geom opensolaris zfs cxgb fxp nfe hwpmc linux linprocfs" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption From owner-svn-src-user@FreeBSD.ORG Thu May 21 02:25:32 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF48F106566C; Thu, 21 May 2009 02:25:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE8A38FC08; Thu, 21 May 2009 02:25:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L2PWNA051661; Thu, 21 May 2009 02:25:32 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L2PWQv051660; Thu, 21 May 2009 02:25:32 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210225.n4L2PWQv051660@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 02:25:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192510 - user/kmacy/releng_7_2_fcs/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 02:25:33 -0000 Author: kmacy Date: Thu May 21 02:25:32 2009 New Revision: 192510 URL: http://svn.freebsd.org/changeset/base/192510 Log: give in and add back if_var.h Modified: user/kmacy/releng_7_2_fcs/sys/net/if.h Modified: user/kmacy/releng_7_2_fcs/sys/net/if.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if.h Thu May 21 02:21:10 2009 (r192509) +++ user/kmacy/releng_7_2_fcs/sys/net/if.h Thu May 21 02:25:32 2009 (r192510) @@ -451,4 +451,9 @@ unsigned int if_nametoindex(const char __END_DECLS #endif +#ifdef _KERNEL +/* XXX - this should go away soon. */ +#include +#endif + #endif /* !_NET_IF_H_ */ From owner-svn-src-user@FreeBSD.ORG Thu May 21 03:35:02 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D09051065673; Thu, 21 May 2009 03:35:02 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BECDC8FC1A; Thu, 21 May 2009 03:35:02 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L3Z2rf053412; Thu, 21 May 2009 03:35:02 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L3Z2jm053411; Thu, 21 May 2009 03:35:02 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210335.n4L3Z2jm053411@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 03:35:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192516 - user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 03:35:03 -0000 Author: kmacy Date: Thu May 21 03:35:02 2009 New Revision: 192516 URL: http://svn.freebsd.org/changeset/base/192516 Log: change prioritization of arc_reclaim handling a bit so that we don't get compressed down to nothing by the inactive queue Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu May 21 02:47:46 2009 (r192515) +++ user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu May 21 03:35:02 2009 (r192516) @@ -1820,15 +1820,16 @@ arc_reclaim_needed(void) #endif #ifdef _KERNEL + if (needfree) + return (1); + if (arc_size <= arc_c_min) + return (0); /* - * If pages are needed or we're within 2048 pages - * of needing to page need to reclaim + * If pages are needed and we're using more than half + * of kmem ... be charitable */ - if (vm_pages_needed || (vm_paging_target() > -2048)) - return (1); - - if (needfree) + if (vm_pages_needed && (arc_size > kmem_size()/2)) return (1); #if 0 From owner-svn-src-user@FreeBSD.ORG Thu May 21 04:13:00 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F19AC106566C; Thu, 21 May 2009 04:13:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E04688FC21; Thu, 21 May 2009 04:13:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L4D06L054173; Thu, 21 May 2009 04:13:00 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L4D0Zn054172; Thu, 21 May 2009 04:13:00 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210413.n4L4D0Zn054172@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 04:13:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192518 - user/kmacy/releng_7_2_fcs/sys/dev/mxge X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 04:13:01 -0000 Author: kmacy Date: Thu May 21 04:13:00 2009 New Revision: 192518 URL: http://svn.freebsd.org/changeset/base/192518 Log: update stats when directly transmitting a packet Modified: user/kmacy/releng_7_2_fcs/sys/dev/mxge/if_mxge.c Modified: user/kmacy/releng_7_2_fcs/sys/dev/mxge/if_mxge.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/mxge/if_mxge.c Thu May 21 04:00:31 2009 (r192517) +++ user/kmacy/releng_7_2_fcs/sys/dev/mxge/if_mxge.c Thu May 21 04:13:00 2009 (r192518) @@ -2179,6 +2179,7 @@ mxge_transmit_locked(struct mxge_slice_s BPF_MTAP(ifp, m); /* give it to the nic */ mxge_encap(ss, m); + drbr_stats_update(ifp, m->m_pkthdr.len, m->m_flags); } else if ((err = drbr_enqueue(ifp, tx->br, m)) != 0) { return (err); } From owner-svn-src-user@FreeBSD.ORG Thu May 21 04:36:49 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E67D31065673; Thu, 21 May 2009 04:36:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D571A8FC16; Thu, 21 May 2009 04:36:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L4anFK054649; Thu, 21 May 2009 04:36:49 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L4anuV054648; Thu, 21 May 2009 04:36:49 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210436.n4L4anuV054648@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 04:36:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192519 - user/kmacy/releng_7_2_fcs/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 04:36:50 -0000 Author: kmacy Date: Thu May 21 04:36:49 2009 New Revision: 192519 URL: http://svn.freebsd.org/changeset/base/192519 Log: add LOCK_PROFILING to the config Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Thu May 21 04:13:00 2009 (r192518) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC Thu May 21 04:36:49 2009 (r192519) @@ -232,4 +232,5 @@ options DDB options KDB options ALT_BREAK_TO_DEBUGGER options HWPMC_HOOKS +options LOCK_PROFILING From owner-svn-src-user@FreeBSD.ORG Thu May 21 04:44:22 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33EA01065677; Thu, 21 May 2009 04:44:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 22E4D8FC14; Thu, 21 May 2009 04:44:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L4iLWu054860; Thu, 21 May 2009 04:44:21 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L4iLXI054859; Thu, 21 May 2009 04:44:21 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210444.n4L4iLXI054859@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 04:44:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192520 - user/kmacy/releng_7_2_fcs/sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 04:44:22 -0000 Author: kmacy Date: Thu May 21 04:44:21 2009 New Revision: 192520 URL: http://svn.freebsd.org/changeset/base/192520 Log: remove old style lpo definition Modified: user/kmacy/releng_7_2_fcs/sys/sys/_lock.h Modified: user/kmacy/releng_7_2_fcs/sys/sys/_lock.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/_lock.h Thu May 21 04:36:49 2009 (r192519) +++ user/kmacy/releng_7_2_fcs/sys/sys/_lock.h Thu May 21 04:44:21 2009 (r192520) @@ -31,28 +31,6 @@ #ifndef _SYS__LOCK_H_ #define _SYS__LOCK_H_ -struct lock_profile_object { - /* - * This does not result in variant structure sizes because - * MUTEX_PROFILING is in opt_global.h - */ - u_int64_t lpo_acqtime; - u_int64_t lpo_waittime; - const char *lpo_filename; - u_int lpo_namehash; - int lpo_lineno; - const char *lpo_type; - /* - * Fields relating to measuring contention on mutexes. - * holding must be accessed atomically since it's - * modified by threads that don't yet hold the mutex. - * locking is only modified and referenced while - * the mutex is held. - */ - u_int lpo_contest_holding; - u_int lpo_contest_locking; -}; - struct lock_object { const char *lo_name; /* Individual lock name. */ u_int lo_flags; From owner-svn-src-user@FreeBSD.ORG Thu May 21 06:30:05 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31FA0106566C; Thu, 21 May 2009 06:30:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 210008FC12; Thu, 21 May 2009 06:30:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L6U5Sv057154; Thu, 21 May 2009 06:30:05 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L6U5YA057153; Thu, 21 May 2009 06:30:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210630.n4L6U5YA057153@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 06:30:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192524 - user/kmacy/releng_7_2_fcs/sys/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 06:30:05 -0000 Author: kmacy Date: Thu May 21 06:30:04 2009 New Revision: 192524 URL: http://svn.freebsd.org/changeset/base/192524 Log: remove KSE option to prevent foot shooting Modified: user/kmacy/releng_7_2_fcs/sys/conf/options Modified: user/kmacy/releng_7_2_fcs/sys/conf/options ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/conf/options Thu May 21 05:58:29 2009 (r192523) +++ user/kmacy/releng_7_2_fcs/sys/conf/options Thu May 21 06:30:04 2009 (r192524) @@ -105,7 +105,6 @@ GEOM_VIRSTOR opt_geom.h GEOM_VOL opt_geom.h GEOM_ZERO opt_geom.h KDTRACE_HOOKS opt_kdtrace.h -KSE opt_global.h KSTACK_MAX_PAGES KSTACK_PAGES KTRACE From owner-svn-src-user@FreeBSD.ORG Thu May 21 06:53:01 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A8CB106564A; Thu, 21 May 2009 06:53:01 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 888888FC0A; Thu, 21 May 2009 06:53:01 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4L6r1Ia057666; Thu, 21 May 2009 06:53:01 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L6r12r057662; Thu, 21 May 2009 06:53:01 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905210653.n4L6r12r057662@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 06:53:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192525 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 06:53:01 -0000 Author: kmacy Date: Thu May 21 06:53:00 2009 New Revision: 192525 URL: http://svn.freebsd.org/changeset/base/192525 Log: - remove unused KSE code - fix use of NEEDSUSPCHK Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c Thu May 21 06:30:04 2009 (r192524) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_thr.c Thu May 21 06:53:00 2009 (r192525) @@ -235,6 +235,8 @@ create_thread(struct thread *td, mcontex /* let the scheduler know about these things. */ sched_fork_thread(td, newtd); thread_unlock(td); + if (P_SHOULDSTOP(p)) + newtd->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; PROC_UNLOCK(p); thread_lock(newtd); if (rtp != NULL) { Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Thu May 21 06:30:04 2009 (r192524) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_thread.c Thu May 21 06:53:00 2009 (r192525) @@ -70,43 +70,12 @@ int max_threads_hits; SYSCTL_INT(_kern_threads, OID_AUTO, max_threads_hits, CTLFLAG_RD, &max_threads_hits, 0, ""); -#ifdef KSE -int virtual_cpu; - -#endif TAILQ_HEAD(, thread) zombie_threads = TAILQ_HEAD_INITIALIZER(zombie_threads); static struct mtx zombie_lock; MTX_SYSINIT(zombie_lock, &zombie_lock, "zombie lock", MTX_SPIN); static void thread_zombie(struct thread *); -#ifdef KSE -static int -sysctl_kse_virtual_cpu(SYSCTL_HANDLER_ARGS) -{ - int error, new_val; - int def_val; - - def_val = mp_ncpus; - if (virtual_cpu == 0) - new_val = def_val; - else - new_val = virtual_cpu; - error = sysctl_handle_int(oidp, &new_val, 0, req); - if (error != 0 || req->newptr == NULL) - return (error); - if (new_val < 0) - return (EINVAL); - virtual_cpu = new_val; - return (0); -} - -/* DEBUG ONLY */ -SYSCTL_PROC(_kern_threads, OID_AUTO, virtual_cpu, CTLTYPE_INT|CTLFLAG_RW, - 0, sizeof(virtual_cpu), sysctl_kse_virtual_cpu, "I", - "debug virtual cpus"); -#endif - struct mtx tid_lock; static struct unrhdr *tid_unrhdr; @@ -136,9 +105,6 @@ thread_ctor(void *mem, int size, void *a #ifdef AUDIT audit_thread_alloc(td); #endif - /* Free all OSD associated to this thread. */ - osd_thread_exit(td); - umtx_thread_alloc(td); return (0); } @@ -176,9 +142,11 @@ thread_dtor(void *mem, int size, void *a #ifdef AUDIT audit_thread_free(td); #endif + /* Free all OSD associated to this thread. */ + osd_thread_exit(td); + EVENTHANDLER_INVOKE(thread_dtor, td); free_unr(tid_unrhdr, td->td_tid); - sched_newthread(td); } /* @@ -237,9 +205,6 @@ void proc_linkup(struct proc *p, struct thread *td) { -#ifdef KSE - TAILQ_INIT(&p->p_upcalls); /* upcall list */ -#endif sigqueue_init(&p->p_sigqueue, p); p->p_ksi = ksiginfo_alloc(1); if (p->p_ksi != NULL) { @@ -264,9 +229,6 @@ threadinit(void) thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(), thread_ctor, thread_dtor, thread_init, thread_fini, 16 - 1, 0); -#ifdef KSE - kseinit(); /* set up kse specific stuff e.g. upcall zone*/ -#endif } /* @@ -292,7 +254,7 @@ thread_stash(struct thread *td) } /* - * Reap zombie kse resource. + * Reap zombie resources. */ void thread_reap(void) @@ -317,9 +279,6 @@ thread_reap(void) td_first = td_next; } } -#ifdef KSE - upcall_reap(); -#endif } /* @@ -349,6 +308,8 @@ thread_alloc(void) void thread_free(struct thread *td) { + + lock_profile_thread_exit(td); if (td->td_cpuset) cpuset_rel(td->td_cpuset); td->td_cpuset = NULL; @@ -415,17 +376,6 @@ thread_exit(void) #ifdef AUDIT AUDIT_SYSCALL_EXIT(0, td); #endif -#ifdef KSE - if (td->td_standin != NULL) { - /* - * Note that we don't need to free the cred here as it - * is done in thread_reap(). - */ - thread_zombie(td->td_standin); - td->td_standin = NULL; - } -#endif - umtx_thread_exit(td); /* * drop FPU & debug register state storage, or any other @@ -519,22 +469,13 @@ thread_wait(struct proc *p) mtx_assert(&Giant, MA_NOTOWNED); KASSERT((p->p_numthreads == 1), ("Multiple threads in wait1()")); td = FIRST_THREAD_IN_PROC(p); -#ifdef KSE - if (td->td_standin != NULL) { - if (td->td_standin->td_ucred != NULL) { - crfree(td->td_standin->td_ucred); - td->td_standin->td_ucred = NULL; - } - thread_free(td->td_standin); - td->td_standin = NULL; - } -#endif /* Lock the last thread so we spin until it exits cpu_throw(). */ thread_lock(td); thread_unlock(td); /* Wait for any remaining threads to exit cpu_throw(). */ while (p->p_exitthreads) sched_relinquish(curthread); + lock_profile_thread_exit(td); cpuset_rel(td->td_cpuset); td->td_cpuset = NULL; cpu_thread_clean(td); @@ -568,6 +509,8 @@ thread_link(struct thread *td, struct pr td->td_flags = TDF_INMEM; LIST_INIT(&td->td_contested); + LIST_INIT(&td->td_lprof[0]); + LIST_INIT(&td->td_lprof[1]); sigqueue_init(&td->td_sigqueue, p); callout_init(&td->td_slpcallout, CALLOUT_MPSAFE); TAILQ_INSERT_HEAD(&p->p_threads, td, td_plist); @@ -586,20 +529,7 @@ thread_unthread(struct thread *td) struct proc *p = td->td_proc; KASSERT((p->p_numthreads == 1), ("Unthreading with >1 threads")); -#ifdef KSE - thread_lock(td); - upcall_remove(td); - thread_unlock(td); - p->p_flag &= ~(P_SA|P_HADTHREADS); - td->td_mailbox = NULL; - td->td_pflags &= ~(TDP_SA | TDP_CAN_UNBIND); - if (td->td_standin != NULL) { - thread_zombie(td->td_standin); - td->td_standin = NULL; - } -#else p->p_flag &= ~P_HADTHREADS; -#endif } /* @@ -679,12 +609,10 @@ thread_single(int mode) if (td2 == td) continue; thread_lock(td2); - td2->td_flags |= TDF_ASTPENDING; + td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; if (TD_IS_INHIBITED(td2)) { switch (mode) { case SINGLE_EXIT: - if (td->td_flags & TDF_DBSUSPEND) - td->td_flags &= ~TDF_DBSUSPEND; if (TD_IS_SUSPENDED(td2)) wakeup_swapper |= thread_unsuspend_one(td2); @@ -703,7 +631,7 @@ thread_single(int mode) wakeup_swapper |= sleepq_abort(td2, ERESTART); break; - default: + default: if (TD_IS_SUSPENDED(td2)) { thread_unlock(td2); continue; @@ -869,7 +797,7 @@ thread_suspend_check(int return_instead) td->td_flags |= TDF_BOUNDARY; } PROC_SUNLOCK(p); - mi_switch(SW_INVOL, NULL); + mi_switch(SW_INVOL | SWT_SUSPEND, NULL); if (return_instead == 0) td->td_flags &= ~TDF_BOUNDARY; thread_unlock(td); @@ -897,11 +825,12 @@ thread_suspend_switch(struct thread *td) p->p_suspcount++; PROC_UNLOCK(p); thread_lock(td); + td->td_flags &= ~TDF_NEEDSUSPCHK; TD_SET_SUSPENDED(td); sched_sleep(td, 0); PROC_SUNLOCK(p); DROP_GIANT(); - mi_switch(SW_VOL, NULL); + mi_switch(SW_VOL | SWT_SUSPEND, NULL); thread_unlock(td); PICKUP_GIANT(); PROC_LOCK(p); @@ -917,6 +846,7 @@ thread_suspend_one(struct thread *td) THREAD_LOCK_ASSERT(td, MA_OWNED); KASSERT(!TD_IS_SUSPENDED(td), ("already suspended")); p->p_suspcount++; + td->td_flags &= ~TDF_NEEDSUSPCHK; TD_SET_SUSPENDED(td); sched_sleep(td, 0); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Thu May 21 06:30:04 2009 (r192524) +++ user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Thu May 21 06:53:00 2009 (r192525) @@ -181,7 +181,7 @@ ast(struct trapframe *framep) */ thread_lock(td); flags = td->td_flags; - td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | + td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK | TDF_NEEDRESCHED | TDF_INTERRUPT | TDF_ALRMPEND | TDF_PROFPEND | TDF_MACPEND); thread_unlock(td); @@ -251,7 +251,15 @@ ast(struct trapframe *framep) mtx_unlock(&p->p_sigacts->ps_mtx); PROC_UNLOCK(p); } - + /* + * We need to check to see if we have to exit or wait due to a + * single threading requirement or some other STOP condition. + */ + if (flags & TDF_NEEDSUSPCHK) { + PROC_LOCK(p); + thread_suspend_check(0); + PROC_UNLOCK(p); + } userret(td, framep); mtx_assert(&Giant, MA_NOTOWNED); } Modified: user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c Thu May 21 06:30:04 2009 (r192524) +++ user/kmacy/releng_7_2_fcs/sys/kern/sys_process.c Thu May 21 06:53:00 2009 (r192525) @@ -701,7 +701,7 @@ kern_ptrace(struct thread *td, int req, case PT_SUSPEND: thread_lock(td2); - td2->td_flags |= TDF_DBSUSPEND; + td2->td_flags |= (TDF_DBSUSPEND | TDF_NEEDSUSPCHK); thread_unlock(td2); break; From owner-svn-src-user@FreeBSD.ORG Thu May 21 19:44:05 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 613B2106568D; Thu, 21 May 2009 19:44:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4FD718FC18; Thu, 21 May 2009 19:44:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4LJi5YF076987; Thu, 21 May 2009 19:44:05 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4LJi5Eh076986; Thu, 21 May 2009 19:44:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905211944.n4LJi5Eh076986@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 19:44:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192564 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 19:44:05 -0000 Author: kmacy Date: Thu May 21 19:44:05 2009 New Revision: 192564 URL: http://svn.freebsd.org/changeset/base/192564 Log: MFC 192516, adding additional checks to sbsndptr Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c Thu May 21 19:33:46 2009 (r192563) +++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_sockbuf.c Thu May 21 19:44:05 2009 (r192564) @@ -575,10 +575,6 @@ sbappendrecord_locked(struct sockbuf *sb if (m0 == 0) return; - m = sb->sb_mb; - if (m) - while (m->m_nextpkt) - m = m->m_nextpkt; /* * Put the first mbuf on the queue. Note this permits zero length * records. @@ -586,10 +582,7 @@ sbappendrecord_locked(struct sockbuf *sb sballoc(sb, m0); SBLASTRECORDCHK(sb); SBLINKRECORD(sb, m0); - if (m) - m->m_nextpkt = m0; - else - sb->sb_mb = m0; + sb->sb_mbtail = m0; m = m0->m_next; m0->m_next = 0; if (m && (m0->m_flags & M_EOR)) { @@ -935,11 +928,13 @@ sbsndptr(struct sockbuf *sb, u_int off, /* Advance by len to be as close as possible for the next transmit. */ for (off = off - sb->sb_sndptroff + len - 1; - off > 0 && off >= m->m_len; + off > 0 && m != NULL && off >= m->m_len; m = m->m_next) { sb->sb_sndptroff += m->m_len; off -= m->m_len; } + if (off > 0 && m == NULL) + panic("%s: sockbuf %p and mbuf %p clashing", __func__, sb, ret); sb->sb_sndptr = m; return (ret); From owner-svn-src-user@FreeBSD.ORG Thu May 21 19:47:23 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EEF3106564A; Thu, 21 May 2009 19:47:23 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 397E88FC0C; Thu, 21 May 2009 19:47:23 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4LJlN95077083; Thu, 21 May 2009 19:47:23 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4LJlNbv077082; Thu, 21 May 2009 19:47:23 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905211947.n4LJlNbv077082@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 19:47:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192565 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 19:47:26 -0000 Author: kmacy Date: Thu May 21 19:47:22 2009 New Revision: 192565 URL: http://svn.freebsd.org/changeset/base/192565 Log: remove unused KSE references Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c Thu May 21 19:44:05 2009 (r192564) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_clock.c Thu May 21 19:47:22 2009 (r192565) @@ -456,10 +456,6 @@ statclock(int usermode) /* * Charge the time as appropriate. */ -#ifdef KSE - if (p->p_flag & P_SA) - thread_statclock(1); -#endif td->td_uticks++; if (p->p_nice > NZERO) cp_time[CP_NICE]++; @@ -483,10 +479,6 @@ statclock(int usermode) td->td_iticks++; cp_time[CP_INTR]++; } else { -#ifdef KSE - if (p->p_flag & P_SA) - thread_statclock(0); -#endif td->td_pticks++; td->td_sticks++; if (!TD_IS_IDLETHREAD(td)) From owner-svn-src-user@FreeBSD.ORG Thu May 21 19:50:48 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 25228106579B; Thu, 21 May 2009 19:50:48 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 080628FC1E; Thu, 21 May 2009 19:50:48 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4LJol60077207; Thu, 21 May 2009 19:50:47 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4LJolkg077204; Thu, 21 May 2009 19:50:47 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905211950.n4LJolkg077204@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 19:50:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192566 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 19:50:48 -0000 Author: kmacy Date: Thu May 21 19:50:47 2009 New Revision: 192566 URL: http://svn.freebsd.org/changeset/base/192566 Log: reduce differences with HEAD Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c user/kmacy/releng_7_2_fcs/sys/kern/kern_subr.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Thu May 21 19:47:22 2009 (r192565) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Thu May 21 19:50:47 2009 (r192566) @@ -1474,9 +1474,9 @@ falloc(struct thread *td, struct file ** * descriptor to the list of open files at that point, otherwise * put it at the front of the list of open files. */ - fp->f_count = 1; + refcount_init(&fp->f_count, 1); if (resultfp) - fp->f_count++; + fhold(fp); fp->f_cred = crhold(td->td_ucred); fp->f_ops = &badfileops; fp->f_data = NULL; @@ -2276,14 +2276,13 @@ _fdrop(struct file *fp, struct thread *t panic("fdrop: count %d", fp->f_count); if (fp->f_ops != &badfileops) error = fo_close(fp, td); - atomic_subtract_int(&openfiles, 1); - /* * The f_cdevpriv cannot be assigned non-NULL value while we * are destroying the file. */ if (fp->f_cdevpriv != NULL) devfs_fpdrop(fp); + atomic_subtract_int(&openfiles, 1); crfree(fp->f_cred); uma_zfree(file_zone, fp); @@ -2526,7 +2525,8 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS) if (fdp == NULL) continue; /* overestimates sparse tables. */ - n += fdp->fd_lastfile; + if (fdp->fd_lastfile > 0) + n += fdp->fd_lastfile; fddrop(fdp); } sx_sunlock(&allproc_lock); @@ -2907,7 +2907,6 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER case DTYPE_VNODE: kif->kf_type = KF_TYPE_VNODE; vp = fp->f_vnode; - vref(vp); break; case DTYPE_SOCKET: @@ -2964,6 +2963,7 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER kif->kf_flags |= KF_FLAG_HASLOCK; kif->kf_offset = fp->f_offset; if (vp != NULL) { + vref(vp); switch (vp->v_type) { case VNON: kif->kf_vnode_type = KF_VTYPE_VNON; Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Thu May 21 19:47:22 2009 (r192565) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Thu May 21 19:50:47 2009 (r192566) @@ -94,7 +94,9 @@ kthread_create_pri_v(void (*func)(void * /* this is a non-swapped system process */ PROC_LOCK(p2); + td = FIRST_THREAD_IN_PROC(p2); p2->p_flag |= P_SYSTEM | P_KTHREAD; + td->td_pflags |= TDP_KTHREAD; mtx_lock(&p2->p_sigacts->ps_mtx); p2->p_sigacts->ps_flag |= PS_NOCLDWAIT; mtx_unlock(&p2->p_sigacts->ps_mtx); Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_subr.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_subr.c Thu May 21 19:47:22 2009 (r192565) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_subr.c Thu May 21 19:50:47 2009 (r192566) @@ -456,7 +456,7 @@ uio_yield(void) DROP_GIANT(); thread_lock(td); sched_prio(td, td->td_user_pri); - mi_switch(SW_INVOL, NULL); + mi_switch(SW_INVOL | SWT_RELINQUISH, NULL); thread_unlock(td); PICKUP_GIANT(); } From owner-svn-src-user@FreeBSD.ORG Thu May 21 19:51:50 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 442AE106567C; Thu, 21 May 2009 19:51:50 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3231E8FC19; Thu, 21 May 2009 19:51:50 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4LJpoJi077263; Thu, 21 May 2009 19:51:50 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4LJpor6077262; Thu, 21 May 2009 19:51:50 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905211951.n4LJpor6077262@svn.freebsd.org> From: Kip Macy Date: Thu, 21 May 2009 19:51:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192567 - user/kmacy/releng_7_2_fcs/sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2009 19:51:51 -0000 Author: kmacy Date: Thu May 21 19:51:49 2009 New Revision: 192567 URL: http://svn.freebsd.org/changeset/base/192567 Log: define TDP_KTHREAD Modified: user/kmacy/releng_7_2_fcs/sys/sys/proc.h Modified: user/kmacy/releng_7_2_fcs/sys/sys/proc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/proc.h Thu May 21 19:50:47 2009 (r192566) +++ user/kmacy/releng_7_2_fcs/sys/sys/proc.h Thu May 21 19:51:49 2009 (r192567) @@ -390,6 +390,7 @@ do { \ #define TDP_NORUNNINGBUF 0x00040000 /* Ignore runningbufspace check */ #define TDP_WAKEUP 0x00080000 /* Don't sleep in umtx cond_wait */ #define TDP_INBDFLUSH 0x00100000 /* Already in BO_BDFLUSH, do not recurse */ +#define TDP_KTHREAD 0x00200000 #define TDP_IGNSUSP 0x00800000 /* Permission to ignore the MNTK_SUSPEND* */ #define TDP_AUDITREC 0x01000000 /* Audit record pending on thread */ From owner-svn-src-user@FreeBSD.ORG Fri May 22 04:50:00 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51150106566B; Fri, 22 May 2009 04:50:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3BA428FC0C; Fri, 22 May 2009 04:50:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4M4o0bg094092; Fri, 22 May 2009 04:50:00 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4M4o044094085; Fri, 22 May 2009 04:50:00 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905220450.n4M4o044094085@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 04:49:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192575 - in user/kmacy/releng_7_2_fcs: lib/libpmc sys/amd64/amd64 sys/amd64/include sys/conf sys/dev/coretemp sys/dev/hwpmc sys/i386/cpufreq sys/i386/i386 sys/i386/include sys/kern sys... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 04:50:00 -0000 Author: kmacy Date: Fri May 22 04:49:59 2009 New Revision: 192575 URL: http://svn.freebsd.org/changeset/base/192575 Log: MFC callchain, core, and i7 support from HEAD Added: user/kmacy/releng_7_2_fcs/lib/libpmc/libpmcinternal.h user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_core.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_core.h user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_intel.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_tsc.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_tsc.h Modified: user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.c user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.h user/kmacy/releng_7_2_fcs/sys/amd64/amd64/amd64_mem.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/identcpu.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/initcpu.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/local_apic.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/msi.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/trap.c user/kmacy/releng_7_2_fcs/sys/amd64/include/cputypes.h user/kmacy/releng_7_2_fcs/sys/amd64/include/md_var.h user/kmacy/releng_7_2_fcs/sys/amd64/include/pmc_mdep.h user/kmacy/releng_7_2_fcs/sys/amd64/include/specialreg.h user/kmacy/releng_7_2_fcs/sys/conf/Makefile.amd64 user/kmacy/releng_7_2_fcs/sys/conf/files.amd64 user/kmacy/releng_7_2_fcs/sys/conf/files.i386 user/kmacy/releng_7_2_fcs/sys/conf/files.pc98 user/kmacy/releng_7_2_fcs/sys/dev/coretemp/coretemp.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_amd.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_amd.h user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_pentium.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_pentium.h user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_piv.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_piv.h user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_ppro.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_ppro.h user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_x86.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/pmc_events.h user/kmacy/releng_7_2_fcs/sys/i386/cpufreq/est.c user/kmacy/releng_7_2_fcs/sys/i386/i386/exception.s user/kmacy/releng_7_2_fcs/sys/i386/i386/genassym.c user/kmacy/releng_7_2_fcs/sys/i386/i386/i686_mem.c user/kmacy/releng_7_2_fcs/sys/i386/i386/identcpu.c user/kmacy/releng_7_2_fcs/sys/i386/i386/initcpu.c user/kmacy/releng_7_2_fcs/sys/i386/i386/k6_mem.c user/kmacy/releng_7_2_fcs/sys/i386/i386/local_apic.c user/kmacy/releng_7_2_fcs/sys/i386/i386/longrun.c user/kmacy/releng_7_2_fcs/sys/i386/i386/mp_machdep.c user/kmacy/releng_7_2_fcs/sys/i386/i386/msi.c user/kmacy/releng_7_2_fcs/sys/i386/i386/trap.c user/kmacy/releng_7_2_fcs/sys/i386/include/cputypes.h user/kmacy/releng_7_2_fcs/sys/i386/include/md_var.h user/kmacy/releng_7_2_fcs/sys/i386/include/pmc_mdep.h user/kmacy/releng_7_2_fcs/sys/i386/include/specialreg.h user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c user/kmacy/releng_7_2_fcs/sys/kern/kern_pmc.c user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c user/kmacy/releng_7_2_fcs/sys/modules/hwpmc/Makefile user/kmacy/releng_7_2_fcs/sys/sys/pmc.h user/kmacy/releng_7_2_fcs/sys/sys/pmckern.h user/kmacy/releng_7_2_fcs/sys/sys/pmclog.h user/kmacy/releng_7_2_fcs/sys/sys/proc.h user/kmacy/releng_7_2_fcs/usr.sbin/pmcstat/Makefile user/kmacy/releng_7_2_fcs/usr.sbin/pmcstat/pmcstat.8 user/kmacy/releng_7_2_fcs/usr.sbin/pmcstat/pmcstat.c user/kmacy/releng_7_2_fcs/usr.sbin/pmcstat/pmcstat.h user/kmacy/releng_7_2_fcs/usr.sbin/pmcstat/pmcstat_log.c Modified: user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c Fri May 22 01:15:07 2009 (r192574) +++ user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c Fri May 22 04:49:59 2009 (r192575) @@ -42,12 +42,18 @@ __FBSDID("$FreeBSD$"); #include #include +#include "libpmcinternal.h" + /* Function prototypes */ #if defined(__i386__) static int k7_allocate_pmc(enum pmc_event _pe, char *_ctrspec, struct pmc_op_pmcallocate *_pmc_config); #endif #if defined(__amd64__) || defined(__i386__) +static int iaf_allocate_pmc(enum pmc_event _pe, char *_ctrspec, + struct pmc_op_pmcallocate *_pmc_config); +static int iap_allocate_pmc(enum pmc_event _pe, char *_ctrspec, + struct pmc_op_pmcallocate *_pmc_config); static int k8_allocate_pmc(enum pmc_event _pe, char *_ctrspec, struct pmc_op_pmcallocate *_pmc_config); static int p4_allocate_pmc(enum pmc_event _pe, char *_ctrspec, @@ -88,14 +94,131 @@ struct pmc_event_descr { enum pmc_class pm_ev_class; }; -static const struct pmc_event_descr -pmc_event_table[] = +/* + * The pmc_class_descr structure maps class name prefixes for + * event names to event tables and other PMC class data. + */ +struct pmc_class_descr { + const char *pm_evc_name; + size_t pm_evc_name_size; + enum pmc_class pm_evc_class; + const struct pmc_event_descr *pm_evc_event_table; + size_t pm_evc_event_table_size; + int (*pm_evc_allocate_pmc)(enum pmc_event _pe, + char *_ctrspec, struct pmc_op_pmcallocate *_pa); +}; + +#define PMC_TABLE_SIZE(N) (sizeof(N)/sizeof(N[0])) +#define PMC_EVENT_TABLE_SIZE(N) PMC_TABLE_SIZE(N##_event_table) + +#undef __PMC_EV +#define __PMC_EV(C,N) { #N, PMC_EV_ ## C ## _ ## N }, + +/* + * PMC_CLASSDEP_TABLE(NAME, CLASS) + * + * Define a table mapping event names and aliases to HWPMC event IDs. + */ +#define PMC_CLASSDEP_TABLE(N, C) \ + static const struct pmc_event_descr N##_event_table[] = \ + { \ + __PMC_EV_##C() \ + } + +PMC_CLASSDEP_TABLE(iaf, IAF); +PMC_CLASSDEP_TABLE(k7, K7); +PMC_CLASSDEP_TABLE(k8, K8); +PMC_CLASSDEP_TABLE(p4, P4); +PMC_CLASSDEP_TABLE(p5, P5); +PMC_CLASSDEP_TABLE(p6, P6); + +#undef __PMC_EV_ALIAS +#define __PMC_EV_ALIAS(N,CODE) { N, PMC_EV_##CODE }, + +static const struct pmc_event_descr atom_event_table[] = +{ + __PMC_EV_ALIAS_ATOM() +}; + +static const struct pmc_event_descr core_event_table[] = +{ + __PMC_EV_ALIAS_CORE() +}; + + +static const struct pmc_event_descr core2_event_table[] = +{ + __PMC_EV_ALIAS_CORE2() +}; + +/* + * PMC_MDEP_TABLE(NAME, PRIMARYCLASS, ADDITIONAL_CLASSES...) + * + * Map a CPU to the PMC classes it supports. + */ +#define PMC_MDEP_TABLE(N,C,...) \ + static const enum pmc_class N##_pmc_classes[] = { \ + PMC_CLASS_##C, __VA_ARGS__ \ + } + +PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC); +PMC_MDEP_TABLE(core, IAP, PMC_CLASS_TSC); +PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC); +PMC_MDEP_TABLE(k7, K7, PMC_CLASS_TSC); +PMC_MDEP_TABLE(k8, K8, PMC_CLASS_TSC); +PMC_MDEP_TABLE(p4, P4, PMC_CLASS_TSC); +PMC_MDEP_TABLE(p5, P5, PMC_CLASS_TSC); +PMC_MDEP_TABLE(p6, P6, PMC_CLASS_TSC); + +static const struct pmc_event_descr tsc_event_table[] = { #undef __PMC_EV #define __PMC_EV(C,N,EV) { #EV, PMC_EV_ ## C ## _ ## N, PMC_CLASS_ ## C }, __PMC_EVENTS() }; +#undef PMC_CLASS_TABLE_DESC +#define PMC_CLASS_TABLE_DESC(NAME, CLASS, EVENTS, ALLOCATOR) \ +static const struct pmc_class_descr NAME##_class_table_descr = \ + { \ + .pm_evc_name = #CLASS "-", \ + .pm_evc_name_size = sizeof(#CLASS "-") - 1, \ + .pm_evc_class = PMC_CLASS_##CLASS , \ + .pm_evc_event_table = EVENTS##_event_table , \ + .pm_evc_event_table_size = \ + PMC_EVENT_TABLE_SIZE(EVENTS), \ + .pm_evc_allocate_pmc = ALLOCATOR##_allocate_pmc \ + } + +#if defined(__i386__) || defined(__amd64__) +PMC_CLASS_TABLE_DESC(iaf, IAF, iaf, iaf); +PMC_CLASS_TABLE_DESC(atom, IAP, atom, iap); +PMC_CLASS_TABLE_DESC(core, IAP, core, iap); +PMC_CLASS_TABLE_DESC(core2, IAP, core2, iap); +#endif +#if defined(__i386__) +PMC_CLASS_TABLE_DESC(k7, K7, k7, k7); +#endif +#if defined(__i386__) || defined(__amd64__) +PMC_CLASS_TABLE_DESC(k8, K8, k8, k8); +PMC_CLASS_TABLE_DESC(p4, P4, p4, p4); +#endif +#if defined(__i386__) +PMC_CLASS_TABLE_DESC(p5, P5, p5, p5); +PMC_CLASS_TABLE_DESC(p6, P6, p6, p6); +#endif +#if defined(__i386__) || defined(__amd64__) +PMC_CLASS_TABLE_DESC(tsc, TSC, tsc, tsc); +#endif + +#undef PMC_CLASS_TABLE_DESC + +static const struct pmc_class_descr **pmc_class_table; +#define PMC_CLASS_TABLE_SIZE cpu_info.pm_nclass + +static const enum pmc_class *pmc_mdep_class_list; +static size_t pmc_mdep_class_list_size; + /* * Mapping tables, mapping enumeration values to human readable * strings. @@ -304,6 +427,238 @@ k7_allocate_pmc(enum pmc_event pe, char #if defined(__amd64__) || defined(__i386__) /* + * Intel Core (Family 6, Model E) PMCs. + */ + +static struct pmc_event_alias core_aliases[] = { + EV_ALIAS("branches", "iap-br-instr-ret"), + EV_ALIAS("branch-mispredicts", "iap-br-mispred-ret"), + EV_ALIAS("cycles", "tsc-tsc"), + EV_ALIAS("ic-misses", "iap-icache-misses"), + EV_ALIAS("instructions", "iap-instr-ret"), + EV_ALIAS("interrupts", "iap-core-hw-int-rx"), + EV_ALIAS("unhalted-cycles", "iap-unhalted-core-cycles"), + EV_ALIAS(NULL, NULL) +}; + +/* + * Intel Core2 (Family 6, Model F), Core2Extreme (Family 6, Model 17H) + * and Atom (Family 6, model 1CH) PMCs. + */ + +static struct pmc_event_alias core2_aliases[] = { + EV_ALIAS("branches", "iap-br-inst-retired.any"), + EV_ALIAS("branch-mispredicts", "iap-br-inst-retired.mispred"), + EV_ALIAS("cycles", "tsc-tsc"), + EV_ALIAS("ic-misses", "iap-l1i-misses"), + EV_ALIAS("instructions", "iaf-instr-retired.any"), + EV_ALIAS("interrupts", "iap-hw-int-rcv"), + EV_ALIAS("unhalted-cycles", "iaf-cpu-clk-unhalted.core"), + EV_ALIAS(NULL, NULL) +}; +#define atom_aliases core2_aliases + +#define IAF_KW_OS "os" +#define IAF_KW_USR "usr" +#define IAF_KW_ANYTHREAD "anythread" + +/* + * Parse an event specifier for Intel fixed function counters. + */ +static int +iaf_allocate_pmc(enum pmc_event pe, char *ctrspec, + struct pmc_op_pmcallocate *pmc_config) +{ + char *p; + + (void) pe; + + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); + pmc_config->pm_md.pm_iaf.pm_iaf_flags = 0; + + while ((p = strsep(&ctrspec, ",")) != NULL) { + if (KWMATCH(p, IAF_KW_OS)) + pmc_config->pm_caps |= PMC_CAP_SYSTEM; + else if (KWMATCH(p, IAF_KW_USR)) + pmc_config->pm_caps |= PMC_CAP_USER; + else if (KWMATCH(p, IAF_KW_ANYTHREAD)) + pmc_config->pm_md.pm_iaf.pm_iaf_flags |= IAF_ANY; + else + return (-1); + } + + return (0); +} + +/* + * Core/Core2 support. + */ + +#define IAP_KW_AGENT "agent" +#define IAP_KW_ANYTHREAD "anythread" +#define IAP_KW_CACHESTATE "cachestate" +#define IAP_KW_CMASK "cmask" +#define IAP_KW_CORE "core" +#define IAP_KW_EDGE "edge" +#define IAP_KW_INV "inv" +#define IAP_KW_OS "os" +#define IAP_KW_PREFETCH "prefetch" +#define IAP_KW_SNOOPRESPONSE "snoopresponse" +#define IAP_KW_SNOOPTYPE "snooptype" +#define IAP_KW_TRANSITION "trans" +#define IAP_KW_USR "usr" + +static struct pmc_masks iap_core_mask[] = { + PMCMASK(all, (0x3 << 14)), + PMCMASK(this, (0x1 << 14)), + NULLMASK +}; + +static struct pmc_masks iap_agent_mask[] = { + PMCMASK(this, 0), + PMCMASK(any, (0x1 << 13)), + NULLMASK +}; + +static struct pmc_masks iap_prefetch_mask[] = { + PMCMASK(both, (0x3 << 12)), + PMCMASK(only, (0x1 << 12)), + PMCMASK(exclude, 0), + NULLMASK +}; + +static struct pmc_masks iap_cachestate_mask[] = { + PMCMASK(i, (1 << 8)), + PMCMASK(s, (1 << 9)), + PMCMASK(e, (1 << 10)), + PMCMASK(m, (1 << 11)), + NULLMASK +}; + +static struct pmc_masks iap_snoopresponse_mask[] = { + PMCMASK(clean, (1 << 8)), + PMCMASK(hit, (1 << 9)), + PMCMASK(hitm, (1 << 11)), + NULLMASK +}; + +static struct pmc_masks iap_snooptype_mask[] = { + PMCMASK(cmp2s, (1 << 8)), + PMCMASK(cmp2i, (1 << 9)), + NULLMASK +}; + +static struct pmc_masks iap_transition_mask[] = { + PMCMASK(any, 0x00), + PMCMASK(frequency, 0x10), + NULLMASK +}; + +static int +iap_allocate_pmc(enum pmc_event pe, char *ctrspec, + struct pmc_op_pmcallocate *pmc_config) +{ + char *e, *p, *q; + uint32_t cachestate, evmask; + int count, n; + + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE | + PMC_CAP_QUALIFIER); + pmc_config->pm_md.pm_iap.pm_iap_config = 0; + + cachestate = evmask = 0; + + /* Parse additional modifiers if present */ + while ((p = strsep(&ctrspec, ",")) != NULL) { + + n = 0; + if (KWPREFIXMATCH(p, IAP_KW_CMASK "=")) { + q = strchr(p, '='); + if (*++q == '\0') /* skip '=' */ + return (-1); + count = strtol(q, &e, 0); + if (e == q || *e != '\0') + return (-1); + pmc_config->pm_caps |= PMC_CAP_THRESHOLD; + pmc_config->pm_md.pm_iap.pm_iap_config |= + IAP_CMASK(count); + } else if (KWMATCH(p, IAP_KW_EDGE)) { + pmc_config->pm_caps |= PMC_CAP_EDGE; + } else if (KWMATCH(p, IAP_KW_INV)) { + pmc_config->pm_caps |= PMC_CAP_INVERT; + } else if (KWMATCH(p, IAP_KW_OS)) { + pmc_config->pm_caps |= PMC_CAP_SYSTEM; + } else if (KWMATCH(p, IAP_KW_USR)) { + pmc_config->pm_caps |= PMC_CAP_USER; + } else if (KWMATCH(p, IAP_KW_ANYTHREAD)) { + pmc_config->pm_md.pm_iap.pm_iap_config |= IAP_ANY; + } else if (KWMATCH(p, IAP_KW_CORE)) { + n = pmc_parse_mask(iap_core_mask, p, &evmask); + if (n != 1) + return (-1); + } else if (KWMATCH(p, IAP_KW_AGENT)) { + n = pmc_parse_mask(iap_agent_mask, p, &evmask); + if (n != 1) + return (-1); + } else if (KWMATCH(p, IAP_KW_PREFETCH)) { + n = pmc_parse_mask(iap_prefetch_mask, p, &evmask); + if (n != 1) + return (-1); + } else if (KWMATCH(p, IAP_KW_CACHESTATE)) { + n = pmc_parse_mask(iap_cachestate_mask, p, &cachestate); + } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_CORE && + KWMATCH(p, IAP_KW_TRANSITION)) { + n = pmc_parse_mask(iap_transition_mask, p, &evmask); + if (n != 1) + return (-1); + } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_ATOM || + cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2 || + cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2EXTREME) { + if (KWMATCH(p, IAP_KW_SNOOPRESPONSE)) { + n = pmc_parse_mask(iap_snoopresponse_mask, p, + &evmask); + } else if (KWMATCH(p, IAP_KW_SNOOPTYPE)) { + n = pmc_parse_mask(iap_snooptype_mask, p, + &evmask); + } else + return (-1); + } else + return (-1); + + if (n < 0) /* Parsing failed. */ + return (-1); + } + + pmc_config->pm_md.pm_iap.pm_iap_config |= evmask; + + /* + * If the event requires a 'cachestate' qualifier but was not + * specified by the user, use a sensible default. + */ + switch (pe) { + case PMC_EV_IAP_EVENT_28H: /* Core, Core2, Atom */ + case PMC_EV_IAP_EVENT_29H: /* Core, Core2, Atom */ + case PMC_EV_IAP_EVENT_2AH: /* Core, Core2, Atom */ + case PMC_EV_IAP_EVENT_2BH: /* Atom, Core2 */ + case PMC_EV_IAP_EVENT_2EH: /* Core, Core2, Atom */ + case PMC_EV_IAP_EVENT_30H: /* Core, Core2, Atom */ + case PMC_EV_IAP_EVENT_32H: /* Core */ + case PMC_EV_IAP_EVENT_40H: /* Core */ + case PMC_EV_IAP_EVENT_41H: /* Core */ + case PMC_EV_IAP_EVENT_42H: /* Core, Core2, Atom */ + case PMC_EV_IAP_EVENT_77H: /* Core */ + if (cachestate == 0) + cachestate = (0xF << 8); + default: + break; + } + + pmc_config->pm_md.pm_iap.pm_iap_config |= cachestate; + + return (0); +} + +/* * AMD K8 PMCs. * * These are very similar to AMD K7 PMCs, but support more kinds of @@ -1637,6 +1992,75 @@ p6_allocate_pmc(enum pmc_event pe, char #endif /* + * Match an event name `name' with its canonical form. + * + * Matches are case insensitive and spaces, periods, underscores and + * hyphen characters are considered to match each other. + * + * Returns 1 for a match, 0 otherwise. + */ + +static int +pmc_match_event_name(const char *name, const char *canonicalname) +{ + int cc, nc; + const unsigned char *c, *n; + + c = (const unsigned char *) canonicalname; + n = (const unsigned char *) name; + + for (; (nc = *n) && (cc = *c); n++, c++) { + + if ((nc == ' ' || nc == '_' || nc == '-' || nc == '.') && + (cc == ' ' || cc == '_' || cc == '-' || cc == '.')) + continue; + + if (toupper(nc) == toupper(cc)) + continue; + + + return (0); + } + + if (*n == '\0' && *c == '\0') + return (1); + + return (0); +} + +/* + * Match an event name against all the event named supported by a + * PMC class. + * + * Returns an event descriptor pointer on match or NULL otherwise. + */ +static const struct pmc_event_descr * +pmc_match_event_class(const char *name, + const struct pmc_class_descr *pcd) +{ + size_t n; + const struct pmc_event_descr *ev; + + ev = pcd->pm_evc_event_table; + for (n = 0; n < pcd->pm_evc_event_table_size; n++, ev++) + if (pmc_match_event_name(name, ev->pm_ev_name)) + return (ev); + + return (NULL); +} + +static int +pmc_mdep_is_compatible_class(enum pmc_class pc) +{ + size_t n; + + for (n = 0; n < pmc_mdep_class_list_size; n++) + if (pmc_mdep_class_list[n] == pc) + return (1); + return (0); +} + +/* * API entry points */ @@ -1675,13 +2099,34 @@ pmc_allocate(const char *ctrspec, enum p r = spec_copy; ctrname = strsep(&r, ","); - /* look for the given counter name */ - - for (pe = PMC_EVENT_FIRST; pe < (PMC_EVENT_LAST+1); pe++) - if (!strcmp(ctrname, pmc_event_table[pe].pm_ev_name)) + /* + * If a explicit class prefix was given by the user, restrict the + * search for the event to the specified PMC class. + */ + ev = NULL; + for (n = 0; n < PMC_CLASS_TABLE_SIZE; n++) { + pcd = pmc_class_table[n]; + if (pmc_mdep_is_compatible_class(pcd->pm_evc_class) && + strncasecmp(ctrname, pcd->pm_evc_name, + pcd->pm_evc_name_size) == 0) { + if ((ev = pmc_match_event_class(ctrname + + pcd->pm_evc_name_size, pcd)) == NULL) { + errno = EINVAL; + goto out; + } break; - if (pe > PMC_EVENT_LAST) { + /* + * Otherwise, search for this event in all compatible PMC + * classes. + */ + for (n = 0; ev == NULL && n < PMC_CLASS_TABLE_SIZE; n++) { + pcd = pmc_class_table[n]; + if (pmc_mdep_is_compatible_class(pcd->pm_evc_class)) + ev = pmc_match_event_class(ctrname, pcd); + } + + if (ev == NULL) { errno = EINVAL; goto out; } @@ -1817,6 +2262,32 @@ pmc_event_names_of_class(enum pmc_class switch (cl) { + case PMC_CLASS_IAF: + ev = iaf_event_table; + count = PMC_EVENT_TABLE_SIZE(iaf); + break; + case PMC_CLASS_IAP: + /* + * Return the most appropriate set of event name + * spellings for the current CPU. + */ + switch (cpu_info.pm_cputype) { + default: + case PMC_CPU_INTEL_ATOM: + ev = atom_event_table; + count = PMC_EVENT_TABLE_SIZE(atom); + break; + case PMC_CPU_INTEL_CORE: + ev = core_event_table; + count = PMC_EVENT_TABLE_SIZE(core); + break; + case PMC_CPU_INTEL_CORE2: + case PMC_CPU_INTEL_CORE2EXTREME: + ev = core2_event_table; + count = PMC_EVENT_TABLE_SIZE(core2); + break; + } + break; case PMC_CLASS_TSC: ev = &pmc_event_table[PMC_EV_TSC_TSC]; count = 1; @@ -1939,16 +2410,42 @@ pmc_init(void) for (n = 0; n < cpu_info.pm_nclass; n++) cpu_info.pm_classes[n] = op_cpu_info.pm_classes[n]; - /* set parser pointer */ + pmc_class_table = malloc(PMC_CLASS_TABLE_SIZE * + sizeof(struct pmc_class_descr *)); + + if (pmc_class_table == NULL) + return (-1); + + + /* + * Fill in the class table. + */ + n = 0; +#if defined(__amd64__) || defined(__i386__) + pmc_class_table[n++] = &tsc_class_table_descr; +#endif + +#define PMC_MDEP_INIT(C) do { \ + pmc_mdep_event_aliases = C##_aliases; \ + pmc_mdep_class_list = C##_pmc_classes; \ + pmc_mdep_class_list_size = \ + PMC_TABLE_SIZE(C##_pmc_classes); \ + } while (0) + + /* Configure the event name parser. */ switch (cpu_info.pm_cputype) { #if defined(__i386__) case PMC_CPU_AMD_K7: pmc_mdep_event_aliases = k7_aliases; pmc_mdep_allocate_pmc = k7_allocate_pmc; + pmc_class_table[n] = &k7_class_table_descr; + pmc_class_table[n] = &k7_class_table_descr; break; case PMC_CPU_INTEL_P5: pmc_mdep_event_aliases = p5_aliases; pmc_mdep_allocate_pmc = p5_allocate_pmc; + pmc_class_table[n] = &p5_class_table_descr; + pmc_class_table[n] = &p5_class_table_descr; break; case PMC_CPU_INTEL_P6: /* P6 ... Pentium M CPUs have */ case PMC_CPU_INTEL_PII: /* similar PMCs. */ @@ -1956,12 +2453,35 @@ pmc_init(void) case PMC_CPU_INTEL_PM: pmc_mdep_event_aliases = p6_aliases; pmc_mdep_allocate_pmc = p6_allocate_pmc; + pmc_class_table[n] = &p6_class_table_descr; + pmc_class_table[n] = &p6_class_table_descr; break; #endif #if defined(__amd64__) || defined(__i386__) + case PMC_CPU_AMD_K8: + PMC_MDEP_INIT(k8); + pmc_class_table[n] = &k8_class_table_descr; + break; + case PMC_CPU_INTEL_ATOM: + PMC_MDEP_INIT(atom); + pmc_class_table[n++] = &iaf_class_table_descr; + pmc_class_table[n] = &atom_class_table_descr; + break; + case PMC_CPU_INTEL_CORE: + PMC_MDEP_INIT(core); + pmc_class_table[n] = &core_class_table_descr; + break; + case PMC_CPU_INTEL_CORE2: + case PMC_CPU_INTEL_CORE2EXTREME: + PMC_MDEP_INIT(core2); + pmc_class_table[n++] = &iaf_class_table_descr; + pmc_class_table[n] = &core2_class_table_descr; + break; case PMC_CPU_INTEL_PIV: pmc_mdep_event_aliases = p4_aliases; pmc_mdep_allocate_pmc = p4_allocate_pmc; + pmc_class_table[n] = &p4_class_table_descr; + pmc_class_table[n] = &p4_class_table_descr; break; case PMC_CPU_AMD_K8: pmc_mdep_event_aliases = k8_aliases; @@ -1969,6 +2489,7 @@ pmc_init(void) break; #endif + default: /* * Some kind of CPU this version of the library knows nothing @@ -2036,12 +2557,81 @@ pmc_name_of_disposition(enum pmc_disp pd } const char * -pmc_name_of_event(enum pmc_event pe) +_pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu) { if ((int) pe >= PMC_EVENT_FIRST && pe <= PMC_EVENT_LAST) return pmc_event_table[pe].pm_ev_name; + ev = evfence = NULL; + if (pe >= PMC_EV_IAF_FIRST && pe <= PMC_EV_IAF_LAST) { + ev = iaf_event_table; + evfence = iaf_event_table + PMC_EVENT_TABLE_SIZE(iaf); + } else if (pe >= PMC_EV_IAP_FIRST && pe <= PMC_EV_IAP_LAST) { + switch (cpu) { + case PMC_CPU_INTEL_ATOM: + ev = atom_event_table; + evfence = atom_event_table + PMC_EVENT_TABLE_SIZE(atom); + break; + case PMC_CPU_INTEL_CORE: + ev = core_event_table; + evfence = core_event_table + PMC_EVENT_TABLE_SIZE(core); + break; + case PMC_CPU_INTEL_CORE2: + case PMC_CPU_INTEL_CORE2EXTREME: + ev = core2_event_table; + evfence = core2_event_table + PMC_EVENT_TABLE_SIZE(core2); + break; + default: /* Unknown CPU type. */ + break; + } + } if (pe >= PMC_EV_K7_FIRST && pe <= PMC_EV_K7_LAST) { + ev = k7_event_table; + evfence = k7_event_table + PMC_EVENT_TABLE_SIZE(k7); + } else if (pe >= PMC_EV_K8_FIRST && pe <= PMC_EV_K8_LAST) { + ev = k8_event_table; + evfence = k8_event_table + PMC_EVENT_TABLE_SIZE(k8); + } else if (pe >= PMC_EV_P4_FIRST && pe <= PMC_EV_P4_LAST) { + ev = p4_event_table; + evfence = p4_event_table + PMC_EVENT_TABLE_SIZE(p4); + } else if (pe >= PMC_EV_P5_FIRST && pe <= PMC_EV_P5_LAST) { + ev = p5_event_table; + evfence = p5_event_table + PMC_EVENT_TABLE_SIZE(p5); + } else if (pe >= PMC_EV_P6_FIRST && pe <= PMC_EV_P6_LAST) { + ev = p6_event_table; + evfence = p6_event_table + PMC_EVENT_TABLE_SIZE(p6); + } else if (pe == PMC_EV_TSC_TSC) { + ev = tsc_event_table; + evfence = tsc_event_table + PMC_EVENT_TABLE_SIZE(tsc); + } + + for (; ev != evfence; ev++) + if (pe == ev->pm_ev_code) + return (ev->pm_ev_name); + + return (NULL); +} + +const char * +pmc_name_of_event(enum pmc_event pe) +{ + const char *n; + + if ((n = _pmc_name_of_event(pe, cpu_info.pm_cputype)) != NULL) + return (n); + + errno = EINVAL; + return (NULL); +} + +const char * +pmc_name_of_event(enum pmc_event pe) +{ + const char *n; + + if ((n = _pmc_name_of_event(pe, cpu_info.pm_cputype)) != NULL) + return (n); + errno = EINVAL; return NULL; } Added: user/kmacy/releng_7_2_fcs/lib/libpmc/libpmcinternal.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_fcs/lib/libpmc/libpmcinternal.h Fri May 22 04:49:59 2009 (r192575) @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2008 Joseph Koshy + * 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. + * + * $FreeBSD$ + */ + +#ifndef LIBPMC_INTERNAL_H +#define LIBPMC_INTERNAL_H 1 + +/* + * Prototypes. + */ +const char *_pmc_name_of_event(enum pmc_event _ev, enum pmc_cputype _cpu); + +#endif /* LIBPMC_INTERNAL_H */ Modified: user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.c ============================================================================== --- user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.c Fri May 22 01:15:07 2009 (r192574) +++ user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.c Fri May 22 04:49:59 2009 (r192575) @@ -1,7 +1,11 @@ /*- - * Copyright (c) 2005-2006 Joseph Koshy + * Copyright (c) 2005-2007 Joseph Koshy + * Copyright (c) 2007 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by A. Joseph Koshy under + * sponsorship from the FreeBSD Foundation and Google, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -43,6 +47,8 @@ __FBSDID("$FreeBSD$"); #include +#include "libpmcinternal.h" + #define PMCLOG_BUFFER_SIZE 4096 /* @@ -270,7 +276,7 @@ pmclog_get_event(void *cookie, char **da struct pmclog_ev *ev) { int evlen, pathlen; - uint32_t h, *le; + uint32_t h, *le, npc; enum pmclog_parser_state e; struct pmclog_parse_state *ps; @@ -310,7 +316,22 @@ pmclog_get_event(void *cookie, char **da goto error; \ } while (0) +#define PMCLOG_GET_CALLCHAIN_SIZE(SZ,E) do { \ + (SZ) = ((E) - offsetof(struct pmclog_callchain, pl_pc)) \ + / sizeof(uintfptr_t); \ + } while (0); + switch (ev->pl_type = PMCLOG_HEADER_TO_TYPE(h)) { + case PMCLOG_TYPE_CALLCHAIN: + PMCLOG_READ32(le,ev->pl_u.pl_cc.pl_pid); + PMCLOG_READ32(le,ev->pl_u.pl_cc.pl_pmcid); + PMCLOG_READ32(le,ev->pl_u.pl_cc.pl_cpuflags); + PMCLOG_GET_CALLCHAIN_SIZE(ev->pl_u.pl_cc.pl_npc,evlen); + for (npc = 0; npc < ev->pl_u.pl_cc.pl_npc; npc++) + PMCLOG_READADDR(le,ev->pl_u.pl_cc.pl_pc[npc]); + for (;npc < PMC_CALLCHAIN_DEPTH_MAX; npc++) + ev->pl_u.pl_cc.pl_pc[npc] = (uintfptr_t) 0; + break; case PMCLOG_TYPE_CLOSELOG: case PMCLOG_TYPE_DROPNOTIFY: /* nothing to do */ @@ -344,7 +365,8 @@ pmclog_get_event(void *cookie, char **da PMCLOG_READ32(le,ev->pl_u.pl_a.pl_event); PMCLOG_READ32(le,ev->pl_u.pl_a.pl_flags); if ((ev->pl_u.pl_a.pl_evname = - pmc_name_of_event(ev->pl_u.pl_a.pl_event)) == NULL) + _pmc_name_of_event(ev->pl_u.pl_a.pl_event, ps->ps_arch)) + == NULL) goto error; break; case PMCLOG_TYPE_PMCATTACH: @@ -387,7 +409,7 @@ pmclog_get_event(void *cookie, char **da default: /* unknown record type */ ps->ps_state = PL_STATE_ERROR; ev->pl_state = PMCLOG_ERROR; - return -1; + return (-1); } ev->pl_offset = (ps->ps_offset += evlen); Modified: user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.h ============================================================================== --- user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.h Fri May 22 01:15:07 2009 (r192574) +++ user/kmacy/releng_7_2_fcs/lib/libpmc/pmclog.h Fri May 22 04:49:59 2009 (r192575) @@ -1,7 +1,11 @@ /*- - * Copyright (c) 2005-2006 Joseph Koshy + * Copyright (c) 2005-2007 Joseph Koshy + * Copyright (c) 2007 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by A. Joseph Koshy under + * sponsorship from the FreeBSD Foundation and Google, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -38,6 +42,14 @@ enum pmclog_state { PMCLOG_ERROR }; +struct pmclog_ev_callchain { + uint32_t pl_pid; + uint32_t pl_pmcid; + uint32_t pl_cpuflags; + uint32_t pl_npc; + uintfptr_t pl_pc[PMC_CALLCHAIN_DEPTH_MAX]; +}; + struct pmclog_ev_dropnotify { }; @@ -125,6 +137,7 @@ struct pmclog_ev { struct timespec pl_ts; /* log entry timestamp */ enum pmclog_type pl_type; /* type of log entry */ union { /* log entry data */ + struct pmclog_ev_callchain pl_cc; struct pmclog_ev_closelog pl_cl; struct pmclog_ev_dropnotify pl_dn; struct pmclog_ev_initialize pl_i; Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/amd64_mem.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/amd64_mem.c Fri May 22 01:15:07 2009 (r192574) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/amd64_mem.c Fri May 22 04:49:59 2009 (r192575) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -677,8 +678,8 @@ amd64_mem_drvinit(void *unused) return; if ((cpu_id & 0xf00) != 0x600 && (cpu_id & 0xf00) != 0xf00) return; - if ((strcmp(cpu_vendor, "GenuineIntel") != 0) && - (strcmp(cpu_vendor, "AuthenticAMD") != 0)) + if (cpu_vendor_id != CPU_VENDOR_INTEL && + cpu_vendor_id != CPU_VENDOR_AMD) return; mem_range_softc.mr_op = &amd64_mrops; } Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S Fri May 22 01:15:07 2009 (r192574) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S Fri May 22 04:49:59 2009 (r192575) @@ -1,8 +1,12 @@ /*- * Copyright (c) 1989, 1990 William F. Jolitz. * Copyright (c) 1990 The Regents of the University of California. + * Copyright (c) 2007 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by A. Joseph Koshy under + * sponsorship from the FreeBSD Foundation and Google, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -33,6 +37,7 @@ #include "opt_atpic.h" #include "opt_compat.h" #include "opt_kdtrace.h" +#include "opt_hwpmc_hooks.h" #include #include @@ -56,6 +61,9 @@ dtrace_invop_calltrap_addr: .zero 8 #endif .text +#ifdef HWPMC_HOOKS + ENTRY(start_exceptions) +#endif /*****************************************************************************/ /* Trap handling */ @@ -388,6 +396,9 @@ IDTVEC(fast_syscall32) * execute the NMI handler with interrupts disabled to prevent a * nested interrupt from executing an 'iretq' instruction and * inadvertently taking the processor out of NMI mode. + * + * Third, the NMI handler runs on its own stack (tss_ist1), shared + * with the double fault handler. */ IDTVEC(nmi) @@ -426,6 +437,61 @@ nmi_calltrap: movq %rsp, %rdi call trap MEXITCOUNT +#ifdef HWPMC_HOOKS + /* + * Check if the current trap was from user mode and if so + * whether the current thread needs a user call chain to be + * captured. We are still in NMI mode at this point. + */ + testb $SEL_RPL_MASK,TF_CS(%rsp) + jz nocallchain + movq PCPU(CURTHREAD),%rax /* curthread present? */ + orq %rax,%rax + jz nocallchain + testl $TDP_CALLCHAIN,TD_PFLAGS(%rax) /* flagged for capture? */ + jz nocallchain + /* + * A user callchain is to be captured, so: + * - Move execution to the regular kernel stack, to allow for + * nested NMI interrupts. + * - Take the processor out of "NMI" mode by faking an "iret". + * - Enable interrupts, so that copyin() can work. + */ + movq %rsp,%rsi /* source stack pointer */ + movq $TF_SIZE,%rcx + movq PCPU(RSP0),%rbx + subq %rcx,%rbx + movq %rbx,%rdi /* destination stack pointer */ + + shrq $3,%rcx /* trap frame size in long words */ + cld + rep + movsq /* copy trapframe */ + + movl %ss,%eax + pushq %rax /* tf_ss */ + pushq %rbx /* tf_rsp (on kernel stack) */ + pushfq /* tf_rflags */ + movl %cs,%eax + pushq %rax /* tf_cs */ + pushq $outofnmi /* tf_rip */ + iretq +outofnmi: + /* + * At this point the processor has exited NMI mode and is running + * with interrupts turned off on the normal kernel stack. + * We turn interrupts back on, and take the usual 'doreti' exit + * path. + * + * If a pending NMI gets recognized at or after this point, it + * will cause a kernel callchain to be traced. Since this path + * is only taken for NMI interrupts from user space, our `swapgs' + * state is correct for taking the doreti path. + */ + sti + jmp doreti +nocallchain: +#endif testl %ebx,%ebx jz nmi_restoreregs swapgs @@ -593,3 +659,6 @@ doreti_iret_fault: movq $0,TF_ADDR(%rsp) FAKE_MCOUNT(TF_RIP(%rsp)) jmp calltrap +#ifdef HWPMC_HOOKS + ENTRY(end_exceptions) +#endif *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri May 22 05:11:04 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 109BA1065686; Fri, 22 May 2009 05:11:04 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F2B348FC13; Fri, 22 May 2009 05:11:03 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4M5B3Fb094608; Fri, 22 May 2009 05:11:03 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4M5B3KJ094606; Fri, 22 May 2009 05:11:03 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905220511.n4M5B3KJ094606@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 05:11:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192576 - user/kmacy/releng_7_2_fcs/sys/dev/hwpmc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 05:11:04 -0000 Author: kmacy Date: Fri May 22 05:11:03 2009 New Revision: 192576 URL: http://svn.freebsd.org/changeset/base/192576 Log: update piv and amd Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_amd.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_piv.c Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_amd.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_amd.c Fri May 22 04:49:59 2009 (r192575) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_amd.c Fri May 22 05:11:03 2009 (r192576) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003-2007 Joseph Koshy + * Copyright (c) 2003-2008 Joseph Koshy * Copyright (c) 2007 The FreeBSD Foundation * All rights reserved. * @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -265,7 +266,7 @@ amd_read_pmc(int cpu, int ri, pmc_value_ struct pmc *pm; pmc_value_t tmp; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); @@ -290,12 +291,15 @@ amd_read_pmc(int cpu, int ri, pmc_value_ #endif tmp = rdmsr(pd->pm_perfctr); /* RDMSR serializes */ - if (PMC_IS_SAMPLING_MODE(mode)) - *v = AMD_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); - else - *v = tmp; + PMCDBG(MDP,REA,2,"amd-read (pre-munge) id=%d -> %jd", ri, tmp); + if (PMC_IS_SAMPLING_MODE(mode)) { + /* Sign extend 48 bit value to 64 bits. */ + tmp = (pmc_value_t) (((int64_t) tmp << 16) >> 16); + tmp = AMD_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); + } + *v = tmp; - PMCDBG(MDP,REA,2,"amd-read id=%d -> %jd", ri, *v); + PMCDBG(MDP,REA,2,"amd-read (post-munge) id=%d -> %jd", ri, *v); return 0; } @@ -311,7 +315,7 @@ amd_write_pmc(int cpu, int ri, pmc_value enum pmc_mode mode; struct pmc *pm; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); @@ -354,7 +358,7 @@ amd_config_pmc(int cpu, int ri, struct p PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm); - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); @@ -436,7 +440,7 @@ amd_allocate_pmc(int cpu, int ri, struct (void) cpu; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row index %d", __LINE__, ri)); @@ -518,7 +522,7 @@ amd_release_pmc(int cpu, int ri, struct (void) pmc; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); @@ -550,7 +554,7 @@ amd_start_pmc(int cpu, int ri) struct pmc_hw *phw; const struct amd_descr *pd; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); @@ -590,7 +594,7 @@ amd_stop_pmc(int cpu, int ri) const struct amd_descr *pd; uint64_t config; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); @@ -628,13 +632,12 @@ amd_intr(int cpu, struct trapframe *tf) uint32_t config, evsel, perfctr; struct pmc *pm; struct amd_cpu *pac; - struct pmc_hw *phw; pmc_value_t v; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] out of range CPU %d", __LINE__, cpu)); - PMCDBG(MDP,INT,1, "cpu=%d tf=0x%p um=%d", cpu, (void *) tf, + PMCDBG(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf, TRAPF_USERMODE(tf)); retval = 0; @@ -656,21 +659,19 @@ amd_intr(int cpu, struct trapframe *tf) for (i = 0; retval == 0 && i < AMD_NPMCS; i++) { - if (!AMD_PMC_HAS_OVERFLOWED(i)) - continue; - - phw = &pac->pc_amdpmcs[i]; - - KASSERT(phw != NULL, ("[amd,%d] null PHW pointer", __LINE__)); - - if ((pm = phw->phw_pmc) == NULL || - pm->pm_state != PMC_STATE_RUNNING || + if ((pm = pac->pc_amdpmcs[i].phw_pmc) == NULL || !PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) { continue; } + if (!AMD_PMC_HAS_OVERFLOWED(i)) + continue; + retval = 1; /* Found an interrupting PMC. */ + if (pm->pm_state != PMC_STATE_RUNNING) + continue; + /* Stop the PMC, reload count. */ evsel = AMD_PMC_EVSEL_0 + i; perfctr = AMD_PMC_PERFCTR_0 + i; @@ -708,7 +709,7 @@ amd_describe(int cpu, int ri, struct pmc const struct amd_descr *pd; struct pmc_hw *phw; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] row-index %d out of range", __LINE__, ri)); @@ -764,7 +765,7 @@ amd_pcpu_init(struct pmc_mdep *md, int c struct amd_cpu *pac; struct pmc_hw *phw; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] insane cpu number %d", __LINE__, cpu)); PMCDBG(MDP,INI,1,"amd-init cpu=%d", cpu); @@ -811,7 +812,7 @@ amd_pcpu_fini(struct pmc_mdep *md, int c struct pmc_cpu *pc; struct amd_cpu *pac; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] insane cpu number (%d)", __LINE__, cpu)); PMCDBG(MDP,INI,1,"amd-cleanup cpu=%d", cpu); @@ -954,7 +955,7 @@ pmc_amd_initialize(void) for (i = 0; i < AMD_NPMCS; i++) { (void) snprintf(amd_pmcdesc[i].pm_descr.pd_name, sizeof(amd_pmcdesc[i].pm_descr.pd_name), "%s-%d", - name, i-1); + name, i); amd_pmcdesc[i].pm_descr.pd_class = class; } Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_piv.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_piv.c Fri May 22 04:49:59 2009 (r192575) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_piv.c Fri May 22 05:11:03 2009 (r192576) @@ -490,8 +490,8 @@ static int p4_escrdisp[P4_NESCR]; KASSERT(p4_escrdisp[(E)] <= 0, ("[p4,%d] row disposition error",\ __LINE__)); \ atomic_add_int(&p4_escrdisp[(E)], -1); \ - KASSERT(p4_escrdisp[(E)] >= (-mp_ncpus), ("[p4,%d] row " \ - "disposition error", __LINE__)); \ + KASSERT(p4_escrdisp[(E)] >= (-pmc_cpu_max_active()), \ + ("[p4,%d] row disposition error", __LINE__)); \ } while (0) #define P4_ESCR_UNMARK_ROW_STANDALONE(E) do { \ @@ -554,11 +554,11 @@ p4_pcpu_init(struct pmc_mdep *md, int cp struct p4_cpu *p4c; struct pmc_cpu *pc, *plc; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[p4,%d] insane cpu number %d", __LINE__, cpu)); - PMCDBG(MDP,INI,0, "p4-init cpu=%d logical=%d", cpu, - pmc_cpu_is_logical(cpu) != 0); + PMCDBG(MDP,INI,0, "p4-init cpu=%d is-primary=%d", cpu, + pmc_cpu_is_primary(cpu) != 0); first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_P4].pcd_ri; @@ -574,7 +574,7 @@ p4_pcpu_init(struct pmc_mdep *md, int cp * secondary. */ - if (pmc_cpu_is_logical(cpu) && (cpu & 1)) { + if (!pmc_cpu_is_primary(cpu) && (cpu & 1)) { p4_system_has_htt = 1; @@ -678,7 +678,7 @@ p4_read_pmc(int cpu, int ri, pmc_value_t enum pmc_mode mode; struct p4pmc_descr *pd; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[p4,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < P4_NPMCS, ("[p4,%d] illegal row-index %d", __LINE__, ri)); @@ -735,7 +735,7 @@ p4_write_pmc(int cpu, int ri, pmc_value_ const struct pmc_hw *phw; const struct p4pmc_descr *pd; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < P4_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); @@ -788,7 +788,7 @@ p4_config_pmc(int cpu, int ri, struct pm struct p4_cpu *pc; int cfgflags, cpuflag; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[p4,%d] illegal CPU %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < P4_NPMCS, @@ -917,7 +917,7 @@ p4_allocate_pmc(int cpu, int ri, struct struct p4_event_descr *pevent; const struct p4pmc_descr *pd; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[p4,%d] illegal CPU %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < P4_NPMCS, ("[p4,%d] illegal row-index value %d", __LINE__, ri)); @@ -1153,7 +1153,7 @@ p4_start_pmc(int cpu, int ri) struct p4pmc_descr *pd; uint32_t cccrvalue, cccrtbits, escrvalue, escrmsr, escrtbits; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[p4,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < P4_NPMCS, ("[p4,%d] illegal row-index %d", __LINE__, ri)); @@ -1299,7 +1299,7 @@ p4_stop_pmc(int cpu, int ri) struct p4pmc_descr *pd; pmc_value_t tmp; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[p4,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < P4_NPMCS, ("[p4,%d] illegal row index %d", __LINE__, ri)); @@ -1557,7 +1557,7 @@ p4_describe(int cpu, int ri, struct pmc_ size_t copied; const struct p4pmc_descr *pd; - KASSERT(cpu >= 0 && cpu < mp_ncpus, + KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[p4,%d] illegal CPU %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < P4_NPMCS, ("[p4,%d] row-index %d out of range", __LINE__, ri)); From owner-svn-src-user@FreeBSD.ORG Fri May 22 18:19:21 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A0131065670; Fri, 22 May 2009 18:19:21 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 05D9C8FC14; Fri, 22 May 2009 18:19:21 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MIJLq6014644; Fri, 22 May 2009 18:19:21 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MIJLBO014642; Fri, 22 May 2009 18:19:21 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905221819.n4MIJLBO014642@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 18:19:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192592 - in user/kmacy/releng_7_2_fcs: lib/libpmc sys/amd64/include sys/i386/include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 18:19:21 -0000 Author: kmacy Date: Fri May 22 18:19:20 2009 New Revision: 192592 URL: http://svn.freebsd.org/changeset/base/192592 Log: fix pmc tools build Modified: user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c user/kmacy/releng_7_2_fcs/sys/amd64/include/pmc_mdep.h user/kmacy/releng_7_2_fcs/sys/i386/include/pmc_mdep.h Modified: user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c Fri May 22 18:10:39 2009 (r192591) +++ user/kmacy/releng_7_2_fcs/lib/libpmc/libpmc.c Fri May 22 18:19:20 2009 (r192592) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003-2006 Joseph Koshy + * Copyright (c) 2003-2008 Joseph Koshy * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,6 +65,10 @@ static int p5_allocate_pmc(enum pmc_even static int p6_allocate_pmc(enum pmc_event _pe, char *_ctrspec, struct pmc_op_pmcallocate *_pmc_config); #endif +#if defined(__amd64__) || defined(__i386__) +static int tsc_allocate_pmc(enum pmc_event _pe, char *_ctrspec, + struct pmc_op_pmcallocate *_pmc_config); +#endif #define PMC_CALL(cmd, params) \ syscall(pmc_syscall, PMC_OP_##cmd, (params)) @@ -75,7 +79,6 @@ static int p6_allocate_pmc(enum pmc_even * mapped to the appropriate canonical event descriptions using a * lookup table. */ - struct pmc_event_alias { const char *pm_alias; const char *pm_spec; @@ -84,14 +87,12 @@ struct pmc_event_alias { static const struct pmc_event_alias *pmc_mdep_event_aliases; /* - * The pmc_event_descr table maps symbolic names known to the user + * The pmc_event_descr structure maps symbolic names known to the user * to integer codes used by the PMC KLD. */ - struct pmc_event_descr { const char *pm_ev_name; enum pmc_event pm_ev_code; - enum pmc_class pm_ev_class; }; /* @@ -151,6 +152,11 @@ static const struct pmc_event_descr core __PMC_EV_ALIAS_CORE2() }; +static const struct pmc_event_descr corei7_event_table[] = +{ + __PMC_EV_ALIAS_COREI7() +}; + /* * PMC_MDEP_TABLE(NAME, PRIMARYCLASS, ADDITIONAL_CLASSES...) * @@ -164,6 +170,7 @@ static const struct pmc_event_descr core PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC); PMC_MDEP_TABLE(core, IAP, PMC_CLASS_TSC); PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC); +PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC); PMC_MDEP_TABLE(k7, K7, PMC_CLASS_TSC); PMC_MDEP_TABLE(k8, K8, PMC_CLASS_TSC); PMC_MDEP_TABLE(p4, P4, PMC_CLASS_TSC); @@ -172,9 +179,7 @@ PMC_MDEP_TABLE(p6, P6, PMC_CLASS_TSC); static const struct pmc_event_descr tsc_event_table[] = { -#undef __PMC_EV -#define __PMC_EV(C,N,EV) { #EV, PMC_EV_ ## C ## _ ## N, PMC_CLASS_ ## C }, - __PMC_EVENTS() + __PMC_EV_TSC() }; #undef PMC_CLASS_TABLE_DESC @@ -195,6 +200,7 @@ PMC_CLASS_TABLE_DESC(iaf, IAF, iaf, iaf) PMC_CLASS_TABLE_DESC(atom, IAP, atom, iap); PMC_CLASS_TABLE_DESC(core, IAP, core, iap); PMC_CLASS_TABLE_DESC(core2, IAP, core2, iap); +PMC_CLASS_TABLE_DESC(corei7, IAP, corei7, iap); #endif #if defined(__i386__) PMC_CLASS_TABLE_DESC(k7, K7, k7, k7); @@ -236,9 +242,14 @@ static const char * pmc_class_names[] = __PMC_CLASSES() }; -static const char * pmc_cputype_names[] = { +struct pmc_cputype_map { + enum pmc_class pm_cputype; + const char *pm_name; +}; + +static const struct pmc_cputype_map pmc_cputype_names[] = { #undef __PMC_CPU -#define __PMC_CPU(S, D) #S , +#define __PMC_CPU(S, V, D) { .pm_cputype = PMC_CPU_##S, .pm_name = #S } , __PMC_CPUS() }; @@ -264,11 +275,6 @@ static int pmc_syscall = -1; /* filled static struct pmc_cpuinfo cpu_info; /* filled in by pmc_init() */ - -/* Architecture dependent event parsing */ -static int (*pmc_mdep_allocate_pmc)(enum pmc_event _pe, char *_ctrspec, - struct pmc_op_pmcallocate *_pmc_config); - /* Event masks for events */ struct pmc_masks { const char *pm_name; @@ -286,20 +292,21 @@ pmc_parse_mask(const struct pmc_masks *p int c; if (pmask == NULL) /* no mask keywords */ - return -1; - q = strchr(p, '='); /* skip '=' */ + return (-1); + q = strchr(p, '='); /* skip '=' */ if (*++q == '\0') /* no more data */ - return -1; + return (-1); c = 0; /* count of mask keywords seen */ while ((r = strsep(&q, "+")) != NULL) { - for (pm = pmask; pm->pm_name && strcmp(r, pm->pm_name); pm++) + for (pm = pmask; pm->pm_name && strcasecmp(r, pm->pm_name); + pm++) ; if (pm->pm_name == NULL) /* not found */ - return -1; + return (-1); *evmask |= pm->pm_value; c++; } - return c; + return (c); } #endif @@ -317,7 +324,7 @@ static struct pmc_event_alias k7_aliases EV_ALIAS("branches", "k7-retired-branches"), EV_ALIAS("branch-mispredicts", "k7-retired-branches-mispredicted"), EV_ALIAS("cycles", "tsc"), - EV_ALIAS("dc-misses", "k7-dc-misses,mask=moesi"), + EV_ALIAS("dc-misses", "k7-dc-misses"), EV_ALIAS("ic-misses", "k7-ic-misses"), EV_ALIAS("instructions", "k7-retired-instructions"), EV_ALIAS("interrupts", "k7-hardware-interrupts"), @@ -335,19 +342,12 @@ static int k7_allocate_pmc(enum pmc_event pe, char *ctrspec, struct pmc_op_pmcallocate *pmc_config) { - char *e, *p, *q; - int c, has_unitmask; + char *e, *p, *q; + int c, has_unitmask; uint32_t count, unitmask; pmc_config->pm_md.pm_amd.pm_amd_config = 0; - pmc_config->pm_caps |= PMC_CAP_READ; - - if (pe == PMC_EV_TSC_TSC) { - /* TSC events must be unqualified. */ - if (ctrspec && *ctrspec != '\0') - return -1; - return 0; - } + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); if (pe == PMC_EV_K7_DC_REFILLS_FROM_L2 || pe == PMC_EV_K7_DC_REFILLS_FROM_SYSTEM || @@ -357,17 +357,15 @@ k7_allocate_pmc(enum pmc_event pe, char } else unitmask = has_unitmask = 0; - pmc_config->pm_caps |= PMC_CAP_WRITE; - while ((p = strsep(&ctrspec, ",")) != NULL) { if (KWPREFIXMATCH(p, K7_KW_COUNT "=")) { q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); count = strtol(q, &e, 0); if (e == q || *e != '\0') - return -1; + return (-1); pmc_config->pm_caps |= PMC_CAP_THRESHOLD; pmc_config->pm_md.pm_amd.pm_amd_config |= @@ -381,11 +379,11 @@ k7_allocate_pmc(enum pmc_event pe, char pmc_config->pm_caps |= PMC_CAP_SYSTEM; } else if (KWPREFIXMATCH(p, K7_KW_UNITMASK "=")) { if (has_unitmask == 0) - return -1; + return (-1); unitmask = 0; q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); while ((c = tolower(*q++)) != 0) if (c == 'm') @@ -401,15 +399,15 @@ k7_allocate_pmc(enum pmc_event pe, char else if (c == '+') continue; else - return -1; + return (-1); if (unitmask == 0) - return -1; + return (-1); } else if (KWMATCH(p, K7_KW_USR)) { pmc_config->pm_caps |= PMC_CAP_USER; } else - return -1; + return (-1); } if (has_unitmask) { @@ -418,7 +416,7 @@ k7_allocate_pmc(enum pmc_event pe, char AMD_PMC_TO_UNITMASK(unitmask); } - return 0; + return (0); } @@ -457,6 +455,7 @@ static struct pmc_event_alias core2_alia EV_ALIAS(NULL, NULL) }; #define atom_aliases core2_aliases +#define corei7_aliases core2_aliases #define IAF_KW_OS "os" #define IAF_KW_USR "usr" @@ -613,7 +612,8 @@ iap_allocate_pmc(enum pmc_event pe, char return (-1); } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_ATOM || cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2 || - cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2EXTREME) { + cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2EXTREME || + cpu_info.pm_cputype == PMC_CPU_INTEL_COREI7) { if (KWMATCH(p, IAP_KW_SNOOPRESPONSE)) { n = pmc_parse_mask(iap_snoopresponse_mask, p, &evmask); @@ -672,7 +672,7 @@ static struct pmc_event_alias k8_aliases EV_ALIAS("cycles", "tsc"), EV_ALIAS("dc-misses", "k8-dc-miss"), EV_ALIAS("ic-misses", "k8-ic-miss"), - EV_ALIAS("instructions", "k8-fr-retired-x86-instructions"), + EV_ALIAS("instructions", "k8-fr-retired-x86-instructions"), EV_ALIAS("interrupts", "k8-fr-taken-hardware-interrupts"), EV_ALIAS("unhalted-cycles", "k8-bu-cpu-clk-unhalted"), EV_ALIAS(NULL, NULL) @@ -847,7 +847,7 @@ static const struct pmc_masks k8_mask_np /* nb hypertransport bus bandwidth */ static const struct pmc_masks k8_mask_nhbb[] = { /* HT bus bandwidth */ __K8MASK(command, 0), - __K8MASK(data, 1), + __K8MASK(data, 1), __K8MASK(buffer-release, 2), __K8MASK(nop, 3), NULLMASK @@ -866,21 +866,14 @@ static int k8_allocate_pmc(enum pmc_event pe, char *ctrspec, struct pmc_op_pmcallocate *pmc_config) { - char *e, *p, *q; - int n; + char *e, *p, *q; + int n; uint32_t count, evmask; const struct pmc_masks *pm, *pmask; - pmc_config->pm_caps |= PMC_CAP_READ; + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); pmc_config->pm_md.pm_amd.pm_amd_config = 0; - if (pe == PMC_EV_TSC_TSC) { - /* TSC events must be unqualified. */ - if (ctrspec && *ctrspec != '\0') - return -1; - return 0; - } - pmask = NULL; evmask = 0; @@ -954,17 +947,15 @@ k8_allocate_pmc(enum pmc_event pe, char break; /* no options defined */ } - pmc_config->pm_caps |= PMC_CAP_WRITE; - while ((p = strsep(&ctrspec, ",")) != NULL) { if (KWPREFIXMATCH(p, K8_KW_COUNT "=")) { q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); count = strtol(q, &e, 0); if (e == q || *e != '\0') - return -1; + return (-1); pmc_config->pm_caps |= PMC_CAP_THRESHOLD; pmc_config->pm_md.pm_amd.pm_amd_config |= @@ -976,18 +967,17 @@ k8_allocate_pmc(enum pmc_event pe, char pmc_config->pm_caps |= PMC_CAP_INVERT; } else if (KWPREFIXMATCH(p, K8_KW_MASK "=")) { if ((n = pmc_parse_mask(pmask, p, &evmask)) < 0) - return -1; + return (-1); pmc_config->pm_caps |= PMC_CAP_QUALIFIER; } else if (KWMATCH(p, K8_KW_OS)) { pmc_config->pm_caps |= PMC_CAP_SYSTEM; } else if (KWMATCH(p, K8_KW_USR)) { pmc_config->pm_caps |= PMC_CAP_USER; } else - return -1; + return (-1); } /* other post processing */ - switch (pe) { case PMC_EV_K8_FP_DISPATCHED_FPU_OPS: case PMC_EV_K8_FP_CYCLES_WITH_NO_FPU_OPS_RETIRED: @@ -1003,7 +993,7 @@ k8_allocate_pmc(enum pmc_event pe, char case PMC_EV_K8_LS_LOCKED_OPERATION: /* XXX CPU Rev A,B evmask is to be zero */ if (evmask & (evmask - 1)) /* > 1 bit set */ - return -1; + return (-1); if (evmask == 0) { evmask = 0x01; /* Rev C and later: #instrs */ pmc_config->pm_caps |= PMC_CAP_QUALIFIER; @@ -1021,7 +1011,7 @@ k8_allocate_pmc(enum pmc_event pe, char pmc_config->pm_md.pm_amd.pm_amd_config = AMD_PMC_TO_UNITMASK(evmask); - return 0; + return (0); } #endif @@ -1363,25 +1353,17 @@ p4_allocate_pmc(enum pmc_event pe, char uint32_t evmask, cccractivemask; const struct pmc_masks *pm, *pmask; - pmc_config->pm_caps |= PMC_CAP_READ; + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); pmc_config->pm_md.pm_p4.pm_p4_cccrconfig = pmc_config->pm_md.pm_p4.pm_p4_escrconfig = 0; - if (pe == PMC_EV_TSC_TSC) { - /* TSC must not be further qualified */ - if (ctrspec && *ctrspec != '\0') - return -1; - return 0; - } - pmask = NULL; evmask = 0; cccractivemask = 0x3; has_tag = has_busreqtype = 0; - pmc_config->pm_caps |= PMC_CAP_WRITE; #define __P4SETMASK(M) do { \ - pmask = p4_mask_##M; \ + pmask = p4_mask_##M; \ } while (0) switch (pe) { @@ -1514,7 +1496,7 @@ p4_allocate_pmc(enum pmc_event pe, char __P4SETMASK(machclr); break; default: - return -1; + return (-1); } /* process additional flags */ @@ -1522,30 +1504,30 @@ p4_allocate_pmc(enum pmc_event pe, char if (KWPREFIXMATCH(p, P4_KW_ACTIVE)) { q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); - if (strcmp(q, P4_KW_ACTIVE_NONE) == 0) + if (strcasecmp(q, P4_KW_ACTIVE_NONE) == 0) cccractivemask = 0x0; - else if (strcmp(q, P4_KW_ACTIVE_SINGLE) == 0) + else if (strcasecmp(q, P4_KW_ACTIVE_SINGLE) == 0) cccractivemask = 0x1; - else if (strcmp(q, P4_KW_ACTIVE_BOTH) == 0) + else if (strcasecmp(q, P4_KW_ACTIVE_BOTH) == 0) cccractivemask = 0x2; - else if (strcmp(q, P4_KW_ACTIVE_ANY) == 0) + else if (strcasecmp(q, P4_KW_ACTIVE_ANY) == 0) cccractivemask = 0x3; else - return -1; + return (-1); } else if (KWPREFIXMATCH(p, P4_KW_BUSREQTYPE)) { if (has_busreqtype == 0) - return -1; + return (-1); q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); count = strtol(q, &e, 0); if (e == q || *e != '\0') - return -1; + return (-1); evmask = (evmask & ~0x1F) | (count & 0x1F); } else if (KWMATCH(p, P4_KW_CASCADE)) pmc_config->pm_caps |= PMC_CAP_CASCADE; @@ -1555,7 +1537,7 @@ p4_allocate_pmc(enum pmc_event pe, char pmc_config->pm_caps |= PMC_CAP_INVERT; else if (KWPREFIXMATCH(p, P4_KW_MASK "=")) { if ((n = pmc_parse_mask(pmask, p, &evmask)) < 0) - return -1; + return (-1); pmc_config->pm_caps |= PMC_CAP_QUALIFIER; } else if (KWMATCH(p, P4_KW_OS)) pmc_config->pm_caps |= PMC_CAP_SYSTEM; @@ -1563,15 +1545,15 @@ p4_allocate_pmc(enum pmc_event pe, char pmc_config->pm_caps |= PMC_CAP_PRECISE; else if (KWPREFIXMATCH(p, P4_KW_TAG "=")) { if (has_tag == 0) - return -1; + return (-1); q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); count = strtol(q, &e, 0); if (e == q || *e != '\0') - return -1; + return (-1); pmc_config->pm_caps |= PMC_CAP_TAGGING; pmc_config->pm_md.pm_p4.pm_p4_escrconfig |= @@ -1579,11 +1561,11 @@ p4_allocate_pmc(enum pmc_event pe, char } else if (KWPREFIXMATCH(p, P4_KW_THRESHOLD "=")) { q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); count = strtol(q, &e, 0); if (e == q || *e != '\0') - return -1; + return (-1); pmc_config->pm_caps |= PMC_CAP_THRESHOLD; pmc_config->pm_md.pm_p4.pm_p4_cccrconfig &= @@ -1593,7 +1575,7 @@ p4_allocate_pmc(enum pmc_event pe, char } else if (KWMATCH(p, P4_KW_USR)) pmc_config->pm_caps |= PMC_CAP_USER; else - return -1; + return (-1); } /* other post processing */ @@ -1613,16 +1595,16 @@ p4_allocate_pmc(enum pmc_event pe, char case PMC_EV_P4_FSB_DATA_ACTIVITY: if ((evmask & 0x06) == 0x06 || (evmask & 0x18) == 0x18) - return -1; /* can't have own+other bits together */ + return (-1); /* can't have own+other bits together */ if (evmask == 0) /* default:drdy-{drv,own}+dbsy{drv,own} */ evmask = 0x1D; break; case PMC_EV_P4_MACHINE_CLEAR: /* only one bit is allowed to be set */ if ((evmask & (evmask - 1)) != 0) - return -1; + return (-1); if (evmask == 0) { - evmask = 0x1; /* 'CLEAR' */ + evmask = 0x1; /* 'CLEAR' */ pmc_config->pm_caps |= PMC_CAP_QUALIFIER; } break; @@ -1637,7 +1619,7 @@ p4_allocate_pmc(enum pmc_event pe, char pmc_config->pm_md.pm_p4.pm_p4_escrconfig = P4_ESCR_TO_EVENT_MASK(evmask); - return 0; + return (0); } #endif @@ -1649,7 +1631,14 @@ p4_allocate_pmc(enum pmc_event pe, char */ static struct pmc_event_alias p5_aliases[] = { - EV_ALIAS("cycles", "tsc"), + EV_ALIAS("branches", "p5-taken-branches"), + EV_ALIAS("cycles", "tsc"), + EV_ALIAS("dc-misses", "p5-data-read-miss-or-write-miss"), + EV_ALIAS("ic-misses", "p5-code-cache-miss"), + EV_ALIAS("instructions", "p5-instructions-executed"), + EV_ALIAS("interrupts", "p5-hardware-interrupts"), + EV_ALIAS("unhalted-cycles", + "p5-number-of-cycles-not-in-halt-state"), EV_ALIAS(NULL, NULL) }; @@ -1657,7 +1646,7 @@ static int p5_allocate_pmc(enum pmc_event pe, char *ctrspec, struct pmc_op_pmcallocate *pmc_config) { - return -1 || pe || ctrspec || pmc_config; /* shut up gcc */ + return (-1 || pe || ctrspec || pmc_config); /* shut up gcc */ } /* @@ -1793,22 +1782,15 @@ p6_allocate_pmc(enum pmc_event pe, char int count, n; const struct pmc_masks *pm, *pmask; - pmc_config->pm_caps |= PMC_CAP_READ; + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); pmc_config->pm_md.pm_ppro.pm_ppro_config = 0; - if (pe == PMC_EV_TSC_TSC) { - if (ctrspec && *ctrspec != '\0') - return -1; - return 0; - } - - pmc_config->pm_caps |= PMC_CAP_WRITE; evmask = 0; #define P6MASKSET(M) pmask = p6_mask_ ## M switch(pe) { - case PMC_EV_P6_L2_IFETCH: P6MASKSET(mesi); break; + case PMC_EV_P6_L2_IFETCH: P6MASKSET(mesi); break; case PMC_EV_P6_L2_LD: P6MASKSET(mesi); break; case PMC_EV_P6_L2_ST: P6MASKSET(mesi); break; case PMC_EV_P6_L2_RQSTS: P6MASKSET(mesi); break; @@ -1868,10 +1850,10 @@ p6_allocate_pmc(enum pmc_event pe, char if (KWPREFIXMATCH(p, P6_KW_CMASK "=")) { q = strchr(p, '='); if (*++q == '\0') /* skip '=' */ - return -1; + return (-1); count = strtol(q, &e, 0); if (e == q || *e != '\0') - return -1; + return (-1); pmc_config->pm_caps |= PMC_CAP_THRESHOLD; pmc_config->pm_md.pm_ppro.pm_ppro_config |= P6_EVSEL_TO_CMASK(count); @@ -1884,7 +1866,7 @@ p6_allocate_pmc(enum pmc_event pe, char } else if (KWPREFIXMATCH(p, P6_KW_UMASK "=")) { evmask = 0; if ((n = pmc_parse_mask(pmask, p, &evmask)) < 0) - return -1; + return (-1); if ((pe == PMC_EV_P6_BUS_DRDY_CLOCKS || pe == PMC_EV_P6_BUS_LOCK_CLOCKS || pe == PMC_EV_P6_BUS_TRAN_BRD || @@ -1908,13 +1890,13 @@ p6_allocate_pmc(enum pmc_event pe, char pe == PMC_EV_P6_EMON_SSE_SSE2_COMP_INST_RETIRED || pe == PMC_EV_P6_EMON_SSE_SSE2_INST_RETIRED || pe == PMC_EV_P6_FP_MMX_TRANS) - && (n > 1)) - return -1; /* only one mask keyword allowed */ + && (n > 1)) /* Only one mask keyword is allowed. */ + return (-1); pmc_config->pm_caps |= PMC_CAP_QUALIFIER; } else if (KWMATCH(p, P6_KW_USR)) { pmc_config->pm_caps |= PMC_CAP_USER; } else - return -1; + return (-1); } /* post processing */ @@ -1967,12 +1949,10 @@ p6_allocate_pmc(enum pmc_event pe, char break; default: - /* * For all other events, set the default event mask * to a logical OR of all the allowed event mask bits. */ - if (evmask == 0 && pmask) { for (pm = pmask; pm->pm_name; pm++) evmask |= pm->pm_value; @@ -1986,11 +1966,30 @@ p6_allocate_pmc(enum pmc_event pe, char pmc_config->pm_md.pm_ppro.pm_ppro_config |= P6_EVSEL_TO_UMASK(evmask); - return 0; + return (0); } #endif +#if defined(__i386__) || defined(__amd64__) +static int +tsc_allocate_pmc(enum pmc_event pe, char *ctrspec, + struct pmc_op_pmcallocate *pmc_config) +{ + if (pe != PMC_EV_TSC_TSC) + return (-1); + + /* TSC events must be unqualified. */ + if (ctrspec && *ctrspec != '\0') + return (-1); + + pmc_config->pm_md.pm_amd.pm_amd_config = 0; + pmc_config->pm_caps |= PMC_CAP_READ; + + return (0); +} +#endif + /* * Match an event name `name' with its canonical form. * @@ -2064,17 +2063,18 @@ pmc_mdep_is_compatible_class(enum pmc_cl * API entry points */ - int pmc_allocate(const char *ctrspec, enum pmc_mode mode, uint32_t flags, int cpu, pmc_id_t *pmcid) { + size_t n; int retval; - enum pmc_event pe; char *r, *spec_copy; const char *ctrname; - const struct pmc_event_alias *p; + const struct pmc_event_descr *ev; + const struct pmc_event_alias *alias; struct pmc_op_pmcallocate pmc_config; + const struct pmc_class_descr *pcd; spec_copy = NULL; retval = -1; @@ -2087,9 +2087,9 @@ pmc_allocate(const char *ctrspec, enum p /* replace an event alias with the canonical event specifier */ if (pmc_mdep_event_aliases) - for (p = pmc_mdep_event_aliases; p->pm_alias; p++) - if (!strcmp(ctrspec, p->pm_alias)) { - spec_copy = strdup(p->pm_spec); + for (alias = pmc_mdep_event_aliases; alias->pm_alias; alias++) + if (!strcasecmp(ctrspec, alias->pm_alias)) { + spec_copy = strdup(alias->pm_spec); break; } @@ -2115,6 +2115,8 @@ pmc_allocate(const char *ctrspec, enum p goto out; } break; + } + } /* * Otherwise, search for this event in all compatible PMC @@ -2132,8 +2134,8 @@ pmc_allocate(const char *ctrspec, enum p } bzero(&pmc_config, sizeof(pmc_config)); - pmc_config.pm_ev = pmc_event_table[pe].pm_ev_code; - pmc_config.pm_class = pmc_event_table[pe].pm_ev_class; + pmc_config.pm_ev = ev->pm_ev_code; + pmc_config.pm_class = pcd->pm_evc_class; pmc_config.pm_cpu = cpu; pmc_config.pm_mode = mode; pmc_config.pm_flags = flags; @@ -2141,7 +2143,7 @@ pmc_allocate(const char *ctrspec, enum p if (PMC_IS_SAMPLING_MODE(mode)) pmc_config.pm_caps |= PMC_CAP_INTERRUPT; - if (pmc_mdep_allocate_pmc(pe, r, &pmc_config) < 0) { + if (pcd->pm_evc_allocate_pmc(ev->pm_ev_code, r, &pmc_config) < 0) { errno = EINVAL; goto out; } @@ -2157,7 +2159,7 @@ pmc_allocate(const char *ctrspec, enum p if (spec_copy) free(spec_copy); - return retval; + return (retval); } int @@ -2168,7 +2170,7 @@ pmc_attach(pmc_id_t pmc, pid_t pid) pmc_attach_args.pm_pmc = pmc; pmc_attach_args.pm_pid = pid; - return PMC_CALL(PMCATTACH, &pmc_attach_args); + return (PMC_CALL(PMCATTACH, &pmc_attach_args)); } int @@ -2181,9 +2183,10 @@ pmc_capabilities(pmc_id_t pmcid, uint32_ for (i = 0; i < cpu_info.pm_nclass; i++) if (cpu_info.pm_classes[i].pm_class == cl) { *caps = cpu_info.pm_classes[i].pm_caps; - return 0; + return (0); } - return EINVAL; + errno = EINVAL; + return (-1); } int @@ -2193,8 +2196,8 @@ pmc_configure_logfile(int fd) cla.pm_logfd = fd; if (PMC_CALL(CONFIGURELOG, &cla) < 0) - return -1; - return 0; + return (-1); + return (0); } int @@ -2202,11 +2205,11 @@ pmc_cpuinfo(const struct pmc_cpuinfo **p { if (pmc_syscall == -1) { errno = ENXIO; - return -1; + return (-1); } *pci = &cpu_info; - return 0; + return (0); } int @@ -2216,8 +2219,7 @@ pmc_detach(pmc_id_t pmc, pid_t pid) pmc_detach_args.pm_pmc = pmc; pmc_detach_args.pm_pid = pid; - - return PMC_CALL(PMCDETACH, &pmc_detach_args); + return (PMC_CALL(PMCDETACH, &pmc_detach_args)); } int @@ -2228,7 +2230,7 @@ pmc_disable(int cpu, int pmc) ssa.pm_cpu = cpu; ssa.pm_pmc = pmc; ssa.pm_state = PMC_STATE_DISABLED; - return PMC_CALL(PMCADMIN, &ssa); + return (PMC_CALL(PMCADMIN, &ssa)); } int @@ -2239,7 +2241,7 @@ pmc_enable(int cpu, int pmc) ssa.pm_cpu = cpu; ssa.pm_pmc = pmc; ssa.pm_state = PMC_STATE_FREE; - return PMC_CALL(PMCADMIN, &ssa); + return (PMC_CALL(PMCADMIN, &ssa)); } /* @@ -2251,7 +2253,6 @@ pmc_enable(int cpu, int pmc) * The space for 'eventnames' is allocated using malloc(3). The caller * is responsible for freeing this space when done. */ - int pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames, int *nevents) @@ -2286,52 +2287,56 @@ pmc_event_names_of_class(enum pmc_class ev = core2_event_table; count = PMC_EVENT_TABLE_SIZE(core2); break; + case PMC_CPU_INTEL_COREI7: + ev = corei7_event_table; + count = PMC_EVENT_TABLE_SIZE(corei7); + break; } break; case PMC_CLASS_TSC: - ev = &pmc_event_table[PMC_EV_TSC_TSC]; - count = 1; + ev = tsc_event_table; + count = PMC_EVENT_TABLE_SIZE(tsc); break; case PMC_CLASS_K7: - ev = &pmc_event_table[PMC_EV_K7_FIRST]; - count = PMC_EV_K7_LAST - PMC_EV_K7_FIRST + 1; + ev = k7_event_table; + count = PMC_EVENT_TABLE_SIZE(k7); break; case PMC_CLASS_K8: - ev = &pmc_event_table[PMC_EV_K8_FIRST]; - count = PMC_EV_K8_LAST - PMC_EV_K8_FIRST + 1; + ev = k8_event_table; + count = PMC_EVENT_TABLE_SIZE(k8); + break; + case PMC_CLASS_P4: + ev = p4_event_table; + count = PMC_EVENT_TABLE_SIZE(p4); break; case PMC_CLASS_P5: - ev = &pmc_event_table[PMC_EV_P5_FIRST]; - count = PMC_EV_P5_LAST - PMC_EV_P5_FIRST + 1; + ev = p5_event_table; + count = PMC_EVENT_TABLE_SIZE(p5); break; case PMC_CLASS_P6: - ev = &pmc_event_table[PMC_EV_P6_FIRST]; - count = PMC_EV_P6_LAST - PMC_EV_P6_FIRST + 1; - break; - case PMC_CLASS_P4: - ev = &pmc_event_table[PMC_EV_P4_FIRST]; - count = PMC_EV_P4_LAST - PMC_EV_P4_FIRST + 1; + ev = p6_event_table; + count = PMC_EVENT_TABLE_SIZE(p6); break; default: errno = EINVAL; - return -1; + return (-1); } if ((names = malloc(count * sizeof(const char *))) == NULL) - return -1; + return (-1); *eventnames = names; *nevents = count; for (;count--; ev++, names++) *names = ev->pm_ev_name; - return 0; + return (0); } int pmc_flush_logfile(void) { - return PMC_CALL(FLUSHLOG,0); + return (PMC_CALL(FLUSHLOG,0)); } int @@ -2340,7 +2345,7 @@ pmc_get_driver_stats(struct pmc_driverst struct pmc_op_getdriverstats gms; if (PMC_CALL(GETDRIVERSTATS, &gms) < 0) - return -1; + return (-1); /* copy out fields in the current userland<->library interface */ ds->pm_intr_ignored = gms.pm_intr_ignored; @@ -2351,8 +2356,7 @@ pmc_get_driver_stats(struct pmc_driverst ds->pm_buffer_requests = gms.pm_buffer_requests; ds->pm_buffer_requests_failed = gms.pm_buffer_requests_failed; ds->pm_log_sweeps = gms.pm_log_sweeps; - - return 0; + return (0); } int @@ -2362,9 +2366,9 @@ pmc_get_msr(pmc_id_t pmc, uint32_t *msr) gm.pm_pmcid = pmc; if (PMC_CALL(PMCGETMSR, &gm) < 0) - return -1; + return (-1); *msr = gm.pm_msr; - return 0; + return (0); } int @@ -2377,15 +2381,15 @@ pmc_init(void) struct pmc_op_getcpuinfo op_cpu_info; if (pmc_syscall != -1) /* already inited */ - return 0; + return (0); /* retrieve the system call number from the KLD */ if ((pmc_mod_id = modfind(PMC_MODULE_NAME)) < 0) - return -1; + return (-1); pmc_modstat.version = sizeof(struct module_stat); if ((error = modstat(pmc_mod_id, &pmc_modstat)) < 0) - return -1; + return (-1); pmc_syscall = pmc_modstat.data.intval; @@ -2436,24 +2440,18 @@ pmc_init(void) switch (cpu_info.pm_cputype) { #if defined(__i386__) case PMC_CPU_AMD_K7: - pmc_mdep_event_aliases = k7_aliases; - pmc_mdep_allocate_pmc = k7_allocate_pmc; - pmc_class_table[n] = &k7_class_table_descr; + PMC_MDEP_INIT(k7); pmc_class_table[n] = &k7_class_table_descr; break; case PMC_CPU_INTEL_P5: - pmc_mdep_event_aliases = p5_aliases; - pmc_mdep_allocate_pmc = p5_allocate_pmc; - pmc_class_table[n] = &p5_class_table_descr; + PMC_MDEP_INIT(p5); pmc_class_table[n] = &p5_class_table_descr; break; case PMC_CPU_INTEL_P6: /* P6 ... Pentium M CPUs have */ case PMC_CPU_INTEL_PII: /* similar PMCs. */ case PMC_CPU_INTEL_PIII: case PMC_CPU_INTEL_PM: - pmc_mdep_event_aliases = p6_aliases; - pmc_mdep_allocate_pmc = p6_allocate_pmc; - pmc_class_table[n] = &p6_class_table_descr; + PMC_MDEP_INIT(p6); pmc_class_table[n] = &p6_class_table_descr; break; #endif @@ -2477,16 +2475,15 @@ pmc_init(void) pmc_class_table[n++] = &iaf_class_table_descr; pmc_class_table[n] = &core2_class_table_descr; break; + case PMC_CPU_INTEL_COREI7: + PMC_MDEP_INIT(corei7); + pmc_class_table[n++] = &iaf_class_table_descr; + pmc_class_table[n] = &corei7_class_table_descr; + break; case PMC_CPU_INTEL_PIV: - pmc_mdep_event_aliases = p4_aliases; - pmc_mdep_allocate_pmc = p4_allocate_pmc; - pmc_class_table[n] = &p4_class_table_descr; + PMC_MDEP_INIT(p4); pmc_class_table[n] = &p4_class_table_descr; break; - case PMC_CPU_AMD_K8: - pmc_mdep_event_aliases = k8_aliases; - pmc_mdep_allocate_pmc = k8_allocate_pmc; - break; #endif @@ -2500,7 +2497,7 @@ pmc_init(void) return (pmc_syscall = -1); } - return 0; + return (0); } const char * @@ -2512,16 +2509,14 @@ pmc_name_of_capability(enum pmc_caps cap * 'cap' should have a single bit set and should be in * range. */ - if ((cap & (cap - 1)) || cap < PMC_CAP_FIRST || cap > PMC_CAP_LAST) { errno = EINVAL; - return NULL; + return (NULL); } i = ffs(cap); - *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri May 22 18:30:00 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4001C106564A; Fri, 22 May 2009 18:30:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2DC898FC18; Fri, 22 May 2009 18:30:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MIU0Wo014987; Fri, 22 May 2009 18:30:00 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MIU0wL014986; Fri, 22 May 2009 18:30:00 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905221830.n4MIU0wL014986@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 18:30:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192594 - user/kmacy/releng_7_2_fcs/sys/dev/hwpmc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 18:30:00 -0000 Author: kmacy Date: Fri May 22 18:29:59 2009 New Revision: 192594 URL: http://svn.freebsd.org/changeset/base/192594 Log: update trapframe sp macro Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_x86.c Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_x86.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_x86.c Fri May 22 18:26:47 2009 (r192593) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_x86.c Fri May 22 18:29:59 2009 (r192594) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2005, Joseph Koshy + * Copyright (c) 2005,2008 Joseph Koshy * Copyright (c) 2007 The FreeBSD Foundation * All rights reserved. * @@ -91,7 +91,7 @@ pmc_save_user_callchain(uintptr_t *cc, i pc = PMC_TRAPFRAME_TO_PC(tf); oldfp = fp = PMC_TRAPFRAME_TO_FP(tf); - sp = PMC_TRAPFRAME_TO_SP(tf); + sp = PMC_TRAPFRAME_TO_USER_SP(tf); *cc++ = pc; n = 1; @@ -172,7 +172,7 @@ pmc_save_kernel_callchain(uintptr_t *cc, pc = PMC_TRAPFRAME_TO_PC(tf); fp = PMC_TRAPFRAME_TO_FP(tf); - sp = PMC_TRAPFRAME_TO_SP(tf); + sp = PMC_TRAPFRAME_TO_KERNEL_SP(tf); *cc++ = pc; r = fp + sizeof(uintptr_t); /* points to return address */ From owner-svn-src-user@FreeBSD.ORG Fri May 22 19:28:13 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBFF4106564A; Fri, 22 May 2009 19:28:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEF838FC22; Fri, 22 May 2009 19:28:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MJSDbt016390; Fri, 22 May 2009 19:28:13 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MJSDON016387; Fri, 22 May 2009 19:28:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905221928.n4MJSDON016387@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 19:28:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192597 - in user/kmacy/releng_7_2_fcs/sys: dev/hwpmc sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 19:28:14 -0000 Author: kmacy Date: Fri May 22 19:28:13 2009 New Revision: 192597 URL: http://svn.freebsd.org/changeset/base/192597 Log: switch per-pmc wakeups to a condvar Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c user/kmacy/releng_7_2_fcs/sys/sys/pmc.h Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Fri May 22 19:05:48 2009 (r192596) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Fri May 22 19:28:13 2009 (r192597) @@ -287,9 +287,7 @@ pmclog_loop(void *arg) wakeup_one(po->po_kthread); } - - (void) msleep(po, &pmc_kthread_mtx, - PWAIT, "pmcloop", 0); + cv_wait(&po->po_cv, &pmc_kthread_mtx); continue; } @@ -502,6 +500,7 @@ pmclog_schedule_io(struct pmc_owner *po) PMCDBG(LOG,SIO, 1, "po=%p", po); + mtx_assert(&pmc_kthread_mtx, MA_OWNED); mtx_assert(&po->po_mtx, MA_OWNED); /* @@ -510,7 +509,7 @@ pmclog_schedule_io(struct pmc_owner *po) */ TAILQ_INSERT_TAIL(&po->po_logbuffers, po->po_curbuf, plb_next); po->po_curbuf = NULL; - wakeup_one(po); + cv_signal(&po->po_cv); } /* @@ -527,7 +526,7 @@ pmclog_stop_kthread(struct pmc_owner *po mtx_assert(&pmc_kthread_mtx, MA_OWNED); po->po_flags &= ~PMC_PO_OWNS_LOGFILE; - wakeup_one(po); + cv_signal(&po->po_cv); if (po->po_kthread) msleep(po->po_kthread, &pmc_kthread_mtx, PPAUSE, "pmckstp", 0); } Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c Fri May 22 19:05:48 2009 (r192596) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c Fri May 22 19:28:13 2009 (r192597) @@ -1906,6 +1906,7 @@ pmc_allocate_owner_descriptor(struct pro TAILQ_INIT(&po->po_logbuffers); mtx_init(&po->po_mtx, "pmc-owner-mtx", "pmc-per-proc", MTX_SPIN); + cv_init(&po->po_cv, "pmc-cv"); PMCDBG(OWN,ALL,1, "allocate-owner proc=%p (%d, %s) pmc-owner=%p", p, p->p_pid, p->p_comm, po); Modified: user/kmacy/releng_7_2_fcs/sys/sys/pmc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/pmc.h Fri May 22 19:05:48 2009 (r192596) +++ user/kmacy/releng_7_2_fcs/sys/sys/pmc.h Fri May 22 19:28:13 2009 (r192597) @@ -33,6 +33,7 @@ #ifndef _SYS_PMC_H_ #define _SYS_PMC_H_ +#include #include #include @@ -756,6 +757,7 @@ struct pmc_owner { struct file *po_file; /* file reference */ int po_error; /* recorded error */ int po_sscount; /* # SS PMCs owned */ + struct cv po_cv; /* condvar */ }; #define PMC_PO_OWNS_LOGFILE 0x00000001 /* has a log file */ From owner-svn-src-user@FreeBSD.ORG Fri May 22 20:04:07 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F97B1065694; Fri, 22 May 2009 20:04:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 629518FC08; Fri, 22 May 2009 20:04:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MK47Bp017275; Fri, 22 May 2009 20:04:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MK471x017274; Fri, 22 May 2009 20:04:07 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905222004.n4MK471x017274@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 20:04:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192598 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 20:04:08 -0000 Author: kmacy Date: Fri May 22 20:04:07 2009 New Revision: 192598 URL: http://svn.freebsd.org/changeset/base/192598 Log: - remove dead KSE code - remove duplicated HWPMC code - use new switch stats mechanism Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Fri May 22 19:28:13 2009 (r192597) +++ user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Fri May 22 20:04:07 2009 (r192598) @@ -96,11 +96,9 @@ userret(struct thread *td, struct trapfr thread_unlock(td); PROC_UNLOCK(p); #endif - #ifdef KTRACE KTRUSERRET(td); #endif - /* * If this thread tickled GEOM, we need to wait for the giggling to * stop before we return to userland @@ -120,22 +118,12 @@ userret(struct thread *td, struct trapfr PROC_UNLOCK(p); } -#ifdef KSE - /* - * Do special thread processing, e.g. upcall tweaking and such. - */ - if (p->p_flag & P_SA) - thread_userret(td, frame); -#endif - /* * Charge system time if profiling. */ if (p->p_flag & P_PROFIL) { - addupc_task(td, TRAPF_PC(frame), td->td_pticks * psratio); } - /* * Let the scheduler adjust our priority etc. */ @@ -173,11 +161,6 @@ ast(struct trapframe *framep) td->td_frame = framep; td->td_pticks = 0; -#ifdef KSE - if ((p->p_flag & P_SA) && (td->td_mailbox == NULL)) - thread_user_enter(td); -#endif - /* * This updates the td_flag's for the checks below in one * "atomic" operation with turning off the astpending flag. @@ -207,13 +190,6 @@ ast(struct trapframe *framep) td->td_profil_ticks = 0; td->td_pflags &= ~TDP_OWEUPC; } -#if defined(HWPMC_HOOKS) - if (td->td_pflags & TDP_CALLCHAIN) { - PMC_CALL_HOOK_UNLOCKED(td, PMC_FN_USER_CALLCHAIN, - (void *) framep); - td->td_pflags &= ~TDP_CALLCHAIN; - } -#endif if (flags & TDF_ALRMPEND) { PROC_LOCK(p); psignal(p, SIGVTALRM); @@ -248,8 +224,7 @@ ast(struct trapframe *framep) #endif thread_lock(td); sched_prio(td, td->td_user_pri); - SCHED_STAT_INC(switch_needresched); - mi_switch(SW_INVOL, NULL); + mi_switch(SW_INVOL | SWT_NEEDRESCHED, NULL); thread_unlock(td); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -273,6 +248,7 @@ ast(struct trapframe *framep) thread_suspend_check(0); PROC_UNLOCK(p); } + userret(td, framep); mtx_assert(&Giant, MA_NOTOWNED); } From owner-svn-src-user@FreeBSD.ORG Fri May 22 21:45:43 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDB27106566B; Fri, 22 May 2009 21:45:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DBA6E8FC0A; Fri, 22 May 2009 21:45:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MLjh05019805; Fri, 22 May 2009 21:45:43 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MLjhm3019802; Fri, 22 May 2009 21:45:43 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905222145.n4MLjhm3019802@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 21:45:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192604 - in user/kmacy/releng_7_2_fcs/sys: dev/hwpmc sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 21:45:44 -0000 Author: kmacy Date: Fri May 22 21:45:43 2009 New Revision: 192604 URL: http://svn.freebsd.org/changeset/base/192604 Log: - remove pmc_kthread_mtx - replace sleep/wakeup on kthread with a condvar Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c user/kmacy/releng_7_2_fcs/sys/sys/pmc.h Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Fri May 22 21:44:15 2009 (r192603) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Fri May 22 21:45:43 2009 (r192604) @@ -84,7 +84,6 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, nbuffe TAILQ_HEAD(, pmclog_buffer) pmc_bufferlist = TAILQ_HEAD_INITIALIZER(pmc_bufferlist); static struct mtx pmc_bufferlist_mtx; /* spin lock */ -static struct mtx pmc_kthread_mtx; /* sleep lock */ #define PMCLOG_INIT_BUFFER_DESCRIPTOR(D) do { \ const int __roundup = roundup(sizeof(*D), \ @@ -268,34 +267,31 @@ pmclog_loop(void *arg) * is deconfigured. */ - mtx_lock(&pmc_kthread_mtx); - + mtx_lock_spin(&po->po_mtx); for (;;) { /* check if we've been asked to exit */ - if ((po->po_flags & PMC_PO_OWNS_LOGFILE) == 0) + if ((po->po_flags & PMC_PO_OWNS_LOGFILE) == 0) { + mtx_unlock_spin(&po->po_mtx); break; - + } + if (lb == NULL) { /* look for a fresh buffer to write */ - mtx_lock_spin(&po->po_mtx); if ((lb = TAILQ_FIRST(&po->po_logbuffers)) == NULL) { - mtx_unlock_spin(&po->po_mtx); /* wakeup any processes waiting for a FLUSH */ if (po->po_flags & PMC_PO_IN_FLUSH) { po->po_flags &= ~PMC_PO_IN_FLUSH; - wakeup_one(po->po_kthread); + cv_signal(&po->po_kthread_cv); } - cv_wait(&po->po_cv, &pmc_kthread_mtx); + cv_wait(&po->po_cv, &po->po_mtx); continue; } - TAILQ_REMOVE(&po->po_logbuffers, lb, plb_next); - mtx_unlock_spin(&po->po_mtx); } + mtx_unlock_spin(&po->po_mtx); - mtx_unlock(&pmc_kthread_mtx); /* process the request */ PMCDBG(LOG,WRI,2, "po=%p base=%p ptr=%p", po, @@ -318,8 +314,6 @@ pmclog_loop(void *arg) error = fo_write(po->po_file, &auio, ownercred, 0, td); td->td_ucred = mycred; - mtx_lock(&pmc_kthread_mtx); - if (error) { /* XXX some errors are recoverable */ /* XXX also check for SIGPIPE if a socket */ @@ -341,14 +335,12 @@ pmclog_loop(void *arg) mtx_lock_spin(&pmc_bufferlist_mtx); TAILQ_INSERT_HEAD(&pmc_bufferlist, lb, plb_next); - mtx_unlock_spin(&pmc_bufferlist_mtx); lb = NULL; } - + mtx_lock_spin(&po->po_mtx); po->po_kthread = NULL; - - mtx_unlock(&pmc_kthread_mtx); + mtx_unlock_spin(&po->po_mtx); /* return the current I/O buffer to the global pool */ if (lb) { @@ -500,7 +492,6 @@ pmclog_schedule_io(struct pmc_owner *po) PMCDBG(LOG,SIO, 1, "po=%p", po); - mtx_assert(&pmc_kthread_mtx, MA_OWNED); mtx_assert(&po->po_mtx, MA_OWNED); /* @@ -524,11 +515,11 @@ pmclog_stop_kthread(struct pmc_owner *po * wait for it to exit */ - mtx_assert(&pmc_kthread_mtx, MA_OWNED); + mtx_assert(&po->po_mtx, MA_OWNED); po->po_flags &= ~PMC_PO_OWNS_LOGFILE; cv_signal(&po->po_cv); if (po->po_kthread) - msleep(po->po_kthread, &pmc_kthread_mtx, PPAUSE, "pmckstp", 0); + cv_wait(&po->po_kthread_cv, &po->po_mtx); } /* @@ -591,10 +582,10 @@ pmclog_configure_log(struct pmc_mdep *md error: /* shutdown the thread */ - mtx_lock(&pmc_kthread_mtx); + mtx_lock_spin(&po->po_mtx); if (po->po_kthread) pmclog_stop_kthread(po); - mtx_unlock(&pmc_kthread_mtx); + mtx_lock_spin(&po->po_mtx); KASSERT(po->po_kthread == NULL, ("[pmc,%d] po=%p kthread not stopped", __LINE__, po)); @@ -630,10 +621,11 @@ pmclog_deconfigure_log(struct pmc_owner ("[pmc,%d] po=%p no log file", __LINE__, po)); /* stop the kthread, this will reset the 'OWNS_LOGFILE' flag */ - mtx_lock(&pmc_kthread_mtx); + mtx_lock_spin(&po->po_mtx); if (po->po_kthread) pmclog_stop_kthread(po); - mtx_unlock(&pmc_kthread_mtx); + mtx_unlock_spin(&po->po_mtx); + KASSERT(po->po_kthread == NULL, ("[pmc,%d] po=%p kthread not stopped", __LINE__, po)); @@ -686,7 +678,7 @@ pmclog_flush(struct pmc_owner *po) /* * Check that we do have an active log file. */ - mtx_lock(&pmc_kthread_mtx); + mtx_lock_spin(&po->po_mtx); if ((po->po_flags & PMC_PO_OWNS_LOGFILE) == 0) { error = EINVAL; goto error; @@ -695,20 +687,17 @@ pmclog_flush(struct pmc_owner *po) /* * Schedule the current buffer if any. */ - mtx_lock_spin(&po->po_mtx); if (po->po_curbuf) pmclog_schedule_io(po); has_pending_buffers = !TAILQ_EMPTY(&po->po_logbuffers); - mtx_unlock_spin(&po->po_mtx); if (has_pending_buffers) { po->po_flags |= PMC_PO_IN_FLUSH; /* ask for a wakeup */ - error = msleep(po->po_kthread, &pmc_kthread_mtx, PWAIT, - "pmcflush", 0); + error = cv_wait_sig(&po->po_kthread_cv, &po->po_mtx); } error: - mtx_unlock(&pmc_kthread_mtx); + mtx_unlock_spin(&po->po_mtx); return error; } @@ -980,7 +969,6 @@ pmclog_initialize() } mtx_init(&pmc_bufferlist_mtx, "pmc-buffer-list", "pmc-leaf", MTX_SPIN); - mtx_init(&pmc_kthread_mtx, "pmc-kthread", "pmc-sleep", MTX_DEF); } /* @@ -994,7 +982,6 @@ pmclog_shutdown() { struct pmclog_buffer *plb; - mtx_destroy(&pmc_kthread_mtx); mtx_destroy(&pmc_bufferlist_mtx); while ((plb = TAILQ_FIRST(&pmc_bufferlist)) != NULL) { Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c Fri May 22 21:44:15 2009 (r192603) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_mod.c Fri May 22 21:45:43 2009 (r192604) @@ -1907,6 +1907,7 @@ pmc_allocate_owner_descriptor(struct pro TAILQ_INIT(&po->po_logbuffers); mtx_init(&po->po_mtx, "pmc-owner-mtx", "pmc-per-proc", MTX_SPIN); cv_init(&po->po_cv, "pmc-cv"); + cv_init(&po->po_kthread_cv, "pmc-kthread-cv"); PMCDBG(OWN,ALL,1, "allocate-owner proc=%p (%d, %s) pmc-owner=%p", p, p->p_pid, p->p_comm, po); Modified: user/kmacy/releng_7_2_fcs/sys/sys/pmc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/sys/pmc.h Fri May 22 21:44:15 2009 (r192603) +++ user/kmacy/releng_7_2_fcs/sys/sys/pmc.h Fri May 22 21:45:43 2009 (r192604) @@ -758,6 +758,7 @@ struct pmc_owner { int po_error; /* recorded error */ int po_sscount; /* # SS PMCs owned */ struct cv po_cv; /* condvar */ + struct cv po_kthread_cv; /* condvar */ }; #define PMC_PO_OWNS_LOGFILE 0x00000001 /* has a log file */ From owner-svn-src-user@FreeBSD.ORG Fri May 22 22:09:06 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 126071065688; Fri, 22 May 2009 22:09:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 014BF8FC0A; Fri, 22 May 2009 22:09:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MM95QH020405; Fri, 22 May 2009 22:09:05 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MM95NV020404; Fri, 22 May 2009 22:09:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905222209.n4MM95NV020404@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 22:09:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192606 - user/kmacy/releng_7_2_fcs/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 22:09:07 -0000 Author: kmacy Date: Fri May 22 22:09:05 2009 New Revision: 192606 URL: http://svn.freebsd.org/changeset/base/192606 Log: add common modules Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Modified: user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Fri May 22 22:09:00 2009 (r192605) +++ user/kmacy/releng_7_2_fcs/sys/amd64/conf/GENERIC_MINUS Fri May 22 22:09:05 2009 (r192606) @@ -25,7 +25,7 @@ ident GENERIC #hints "GENERIC.hints" # Default places to look for devices. makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions MODULES_OVERRIDE="opensolaris zfs zlib mxge geom" +makeoptions MODULES_OVERRIDE="opensolaris zfs zlib mxge geom hwpmc linux linprocfs" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption From owner-svn-src-user@FreeBSD.ORG Fri May 22 22:48:55 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF95D106566B; Fri, 22 May 2009 22:48:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BEB898FC14; Fri, 22 May 2009 22:48:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MMmt4Q021296; Fri, 22 May 2009 22:48:55 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MMmtBP021295; Fri, 22 May 2009 22:48:55 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905222248.n4MMmtBP021295@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 22:48:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192609 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 22:48:56 -0000 Author: kmacy Date: Fri May 22 22:48:55 2009 New Revision: 192609 URL: http://svn.freebsd.org/changeset/base/192609 Log: enable condvar and friends to operate on spin locks Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Fri May 22 22:22:21 2009 (r192608) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Fri May 22 22:48:55 2009 (r192609) @@ -141,7 +141,7 @@ void lock_spin(struct lock_object *lock, int how) { - panic("spin locks can only use msleep_spin"); + mtx_lock_spin((struct mtx *)lock); } int @@ -158,8 +158,11 @@ unlock_mtx(struct lock_object *lock) int unlock_spin(struct lock_object *lock) { + struct mtx *m; - panic("spin locks can only use msleep_spin"); + m = (struct mtx *)lock; + mtx_assert(m, MA_OWNED | MA_NOTRECURSED); + mtx_unlock_spin(m); } /* From owner-svn-src-user@FreeBSD.ORG Fri May 22 22:50:24 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD7BC1065670; Fri, 22 May 2009 22:50:24 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CCA828FC22; Fri, 22 May 2009 22:50:24 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4MMoOOi021366; Fri, 22 May 2009 22:50:24 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4MMoO01021365; Fri, 22 May 2009 22:50:24 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905222250.n4MMoO01021365@svn.freebsd.org> From: Kip Macy Date: Fri, 22 May 2009 22:50:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192610 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 22:50:25 -0000 Author: kmacy Date: Fri May 22 22:50:24 2009 New Revision: 192610 URL: http://svn.freebsd.org/changeset/base/192610 Log: compile fix Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Fri May 22 22:48:55 2009 (r192609) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_mutex.c Fri May 22 22:50:24 2009 (r192610) @@ -163,6 +163,7 @@ unlock_spin(struct lock_object *lock) m = (struct mtx *)lock; mtx_assert(m, MA_OWNED | MA_NOTRECURSED); mtx_unlock_spin(m); + return (0); } /* From owner-svn-src-user@FreeBSD.ORG Sat May 23 02:31:42 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01F9B106566C; Sat, 23 May 2009 02:31:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA7308FC0A; Sat, 23 May 2009 02:31:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4N2Vf8t026250; Sat, 23 May 2009 02:31:41 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4N2VfQQ026249; Sat, 23 May 2009 02:31:41 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905230231.n4N2VfQQ026249@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 02:31:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192618 - user/kmacy/releng_7_2_fcs/rescue/rescue X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 02:31:42 -0000 Author: kmacy Date: Sat May 23 02:31:41 2009 New Revision: 192618 URL: http://svn.freebsd.org/changeset/base/192618 Log: Add zfs/zpool to rescue programs Modified: user/kmacy/releng_7_2_fcs/rescue/rescue/Makefile Modified: user/kmacy/releng_7_2_fcs/rescue/rescue/Makefile ============================================================================== --- user/kmacy/releng_7_2_fcs/rescue/rescue/Makefile Sat May 23 00:47:23 2009 (r192617) +++ user/kmacy/releng_7_2_fcs/rescue/rescue/Makefile Sat May 23 02:31:41 2009 (r192618) @@ -71,7 +71,7 @@ CRUNCH_SRCDIRS+= bin CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ ed expr getfacl hostname kenv kill ln ls mkdir mv pax ps pwd \ realpath rm rmdir setfacl sh stty sync test -CRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil +CRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -ltermcap -lutil .if ${MK_OPENSSL} != "no" CRUNCH_LIBS+= -lcrypto .endif @@ -129,6 +129,10 @@ CRUNCH_PROGS_sbin+= ping6 .if ${MK_IPFILTER} != "no" CRUNCH_PROGS_sbin+= ipf .endif +.if ${MK_ZFS} != "no" +CRUNCH_PROGS_sbin+= zfs +CRUNCH_PROGS_sbin+= zpool +.endif # crunchgen does not like C++ programs; this should be fixed someday # CRUNCH_PROGS+= devd @@ -137,6 +141,9 @@ CRUNCH_LIBS+= -lalias -lcam -lcurses -ld .if ${MK_IPX} != "no" CRUNCH_LIBS+= -lipx .endif +.if ${MK_ZFS} != "no" +CRUNCH_LIBS+= -lzfs -lnvpair -luutil -lavl +.endif CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz .if ${MACHINE_ARCH} == "i386" @@ -173,6 +180,10 @@ CRUNCH_SRCDIR_fore_dnld= $(.CURDIR)/../. CRUNCH_SRCDIR_ilmid= $(.CURDIR)/../../sbin/atm/ilmid CRUNCH_SRCDIR_rtquery= $(.CURDIR)/../../sbin/routed/rtquery CRUNCH_SRCDIR_ipf= $(.CURDIR)/../../sbin/ipf/ipf +.if ${MK_ZFS} != "no" +CRUNCH_SRCDIR_zfs= ${.CURDIR}/../../cddl/sbin/zfs +CRUNCH_SRCDIR_zpool= ${.CURDIR}/../../cddl/sbin/zpool +.endif CRUNCH_ALIAS_reboot= fastboot halt fasthalt CRUNCH_ALIAS_restore= rrestore CRUNCH_ALIAS_dump= rdump @@ -210,6 +221,12 @@ CRUNCH_SRCDIRS+= usr.sbin CRUNCH_PROGS_usr.sbin+= chroot +CRUNCH_PROGS_usr.sbin+= chown +CRUNCH_ALIAS_chown= chgrp + +################################################################## +CRUNCH_LIBS+= -lm + ################################################################## # The following is pretty nearly a generic crunchgen-handling makefile # From owner-svn-src-user@FreeBSD.ORG Sat May 23 02:48:15 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B0A0106566B; Sat, 23 May 2009 02:48:15 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 59C598FC13; Sat, 23 May 2009 02:48:15 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4N2mFxj026605; Sat, 23 May 2009 02:48:15 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4N2mFQp026604; Sat, 23 May 2009 02:48:15 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905230248.n4N2mFQp026604@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 02:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192619 - user/kmacy/releng_7_2_fcs/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 02:48:15 -0000 Author: kmacy Date: Sat May 23 02:48:15 2009 New Revision: 192619 URL: http://svn.freebsd.org/changeset/base/192619 Log: allow non-sleepable lock in cv_wait Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c Sat May 23 02:31:41 2009 (r192618) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_condvar.c Sat May 23 02:48:15 2009 (r192619) @@ -106,7 +106,7 @@ _cv_wait(struct cv *cvp, struct lock_obj ktrcsw(1, 0); #endif CV_ASSERT(cvp, lock, td); - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, + WITNESS_WARN(WARN_GIANTOK, lock, "Waiting on \"%s\"", cvp->cv_description); WITNESS_SAVE(lock, lock_witness); class = LOCK_CLASS(lock); From owner-svn-src-user@FreeBSD.ORG Sat May 23 03:08:37 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59079106566C; Sat, 23 May 2009 03:08:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4757B8FC0A; Sat, 23 May 2009 03:08:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4N38b5r027154; Sat, 23 May 2009 03:08:37 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4N38bOC027153; Sat, 23 May 2009 03:08:37 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905230308.n4N38bOC027153@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 03:08:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192620 - user/kmacy/releng_7_2_fcs/sys/dev/hwpmc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 03:08:37 -0000 Author: kmacy Date: Sat May 23 03:08:36 2009 New Revision: 192620 URL: http://svn.freebsd.org/changeset/base/192620 Log: fix locking in loggiing loop Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Sat May 23 02:48:15 2009 (r192619) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Sat May 23 03:08:36 2009 (r192620) @@ -266,10 +266,8 @@ pmclog_loop(void *arg) * struct's queue. The loop is exited when the log file * is deconfigured. */ - - mtx_lock_spin(&po->po_mtx); for (;;) { - + mtx_lock_spin(&po->po_mtx); /* check if we've been asked to exit */ if ((po->po_flags & PMC_PO_OWNS_LOGFILE) == 0) { mtx_unlock_spin(&po->po_mtx); @@ -335,7 +333,7 @@ pmclog_loop(void *arg) mtx_lock_spin(&pmc_bufferlist_mtx); TAILQ_INSERT_HEAD(&pmc_bufferlist, lb, plb_next); - + mtx_unlock_spin(&pmc_bufferlist_mtx); lb = NULL; } mtx_lock_spin(&po->po_mtx); From owner-svn-src-user@FreeBSD.ORG Sat May 23 03:13:39 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 676A11065678; Sat, 23 May 2009 03:13:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 55E8C8FC20; Sat, 23 May 2009 03:13:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4N3Ddhp027464; Sat, 23 May 2009 03:13:39 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4N3DdJj027463; Sat, 23 May 2009 03:13:39 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905230313.n4N3DdJj027463@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 03:13:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192621 - user/kmacy/releng_7_2_fcs/sys/dev/hwpmc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 03:13:39 -0000 Author: kmacy Date: Sat May 23 03:13:39 2009 New Revision: 192621 URL: http://svn.freebsd.org/changeset/base/192621 Log: fix missed continue case Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Sat May 23 03:08:36 2009 (r192620) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Sat May 23 03:13:39 2009 (r192621) @@ -266,8 +266,8 @@ pmclog_loop(void *arg) * struct's queue. The loop is exited when the log file * is deconfigured. */ + mtx_lock_spin(&po->po_mtx); for (;;) { - mtx_lock_spin(&po->po_mtx); /* check if we've been asked to exit */ if ((po->po_flags & PMC_PO_OWNS_LOGFILE) == 0) { mtx_unlock_spin(&po->po_mtx); @@ -335,6 +335,7 @@ pmclog_loop(void *arg) TAILQ_INSERT_HEAD(&pmc_bufferlist, lb, plb_next); mtx_unlock_spin(&pmc_bufferlist_mtx); lb = NULL; + mtx_lock_spin(&po->po_mtx); } mtx_lock_spin(&po->po_mtx); po->po_kthread = NULL; From owner-svn-src-user@FreeBSD.ORG Sat May 23 03:35:30 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C039106564A; Sat, 23 May 2009 03:35:30 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1A98D8FC1A; Sat, 23 May 2009 03:35:30 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4N3ZTbH027913; Sat, 23 May 2009 03:35:29 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4N3ZT3r027912; Sat, 23 May 2009 03:35:29 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905230335.n4N3ZT3r027912@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 03:35:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192622 - user/kmacy/releng_7_2_fcs/sys/dev/hwpmc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 03:35:30 -0000 Author: kmacy Date: Sat May 23 03:35:29 2009 New Revision: 192622 URL: http://svn.freebsd.org/changeset/base/192622 Log: wakeup waiting process before exiting Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Modified: user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Sat May 23 03:13:39 2009 (r192621) +++ user/kmacy/releng_7_2_fcs/sys/dev/hwpmc/hwpmc_logging.c Sat May 23 03:35:29 2009 (r192622) @@ -339,6 +339,7 @@ pmclog_loop(void *arg) } mtx_lock_spin(&po->po_mtx); po->po_kthread = NULL; + cv_signal(&po->po_kthread_cv); mtx_unlock_spin(&po->po_mtx); /* return the current I/O buffer to the global pool */ From owner-svn-src-user@FreeBSD.ORG Sat May 23 19:17:28 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 480F51065678; Sat, 23 May 2009 19:17:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34BB98FC26; Sat, 23 May 2009 19:17:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4NJHSPF064646; Sat, 23 May 2009 19:17:28 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4NJHRC6064638; Sat, 23 May 2009 19:17:27 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905231917.n4NJHRC6064638@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 19:17:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192663 - in user/kmacy/releng_7_2_fcs/sys: amd64/amd64 amd64/include i386/i386 kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 19:17:28 -0000 Author: kmacy Date: Sat May 23 19:17:27 2009 New Revision: 192663 URL: http://svn.freebsd.org/changeset/base/192663 Log: fix hwpmc callchain and NMI handling Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/machdep.c user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h user/kmacy/releng_7_2_fcs/sys/i386/i386/exception.s user/kmacy/releng_7_2_fcs/sys/i386/i386/genassym.c user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/exception.S Sat May 23 19:17:27 2009 (r192663) @@ -383,22 +383,24 @@ IDTVEC(fast_syscall32) * NMI handling is special. * * First, NMIs do not respect the state of the processor's RFLAGS.IF - * bit and the NMI handler may be invoked at any time, including when - * the processor is in a critical section with RFLAGS.IF == 0. In - * particular, this means that the processor's GS.base values could be - * inconsistent on entry to the handler, and so we need to read - * MSR_GSBASE to determine if a 'swapgs' is needed. We use '%ebx', a - * C-preserved register, to remember whether to swap GS back on the - * exit path. + * bit. The NMI handler may be entered at any time, including when + * the processor is in a critical section with RFLAGS.IF == 0. + * The processor's GS.base value could be invalid on entry to the + * handler. * * Second, the processor treats NMIs specially, blocking further NMIs - * until an 'iretq' instruction is executed. We therefore need to - * execute the NMI handler with interrupts disabled to prevent a - * nested interrupt from executing an 'iretq' instruction and - * inadvertently taking the processor out of NMI mode. + * until an 'iretq' instruction is executed. We thus need to execute + * the NMI handler with interrupts disabled, to prevent a nested interrupt + * from executing an 'iretq' instruction and inadvertently taking the + * processor out of NMI mode. * - * Third, the NMI handler runs on its own stack (tss_ist1), shared - * with the double fault handler. + * Third, the NMI handler runs on its own stack (tss_ist2). The canonical + * GS.base value for the processor is stored just above the bottom of its + * NMI stack. For NMIs taken from kernel mode, the current value in + * the processor's GS.base is saved at entry to C-preserved register %r12, + * the canonical value for GS.base is then loaded into the processor, and + * the saved value is restored at exit time. For NMIs taken from user mode, + * the cheaper 'SWAPGS' instructions are used for swapping GS.base. */ IDTVEC(nmi) @@ -423,12 +425,22 @@ IDTVEC(nmi) movq %r15,TF_R15(%rsp) xorl %ebx,%ebx testb $SEL_RPL_MASK,TF_CS(%rsp) - jnz nmi_needswapgs /* we came from userland */ + jnz nmi_fromuserspace + /* + * We've interrupted the kernel. Preserve GS.base in %r12. + */ movl $MSR_GSBASE,%ecx rdmsr - cmpl $VM_MAXUSER_ADDRESS >> 32,%edx - jae nmi_calltrap /* GS.base holds a kernel VA */ -nmi_needswapgs: + movq %rax,%r12 + shlq $32,%rdx + orq %rdx,%r12 + /* Retrieve and load the canonical value for GS.base. */ + movq TF_SIZE(%rsp),%rdx + movl %edx,%eax + shrq $32,%rdx + wrmsr + jmp nmi_calltrap +nmi_fromuserspace: incl %ebx swapgs /* Note: this label is also used by ddb and gdb: */ @@ -439,14 +451,19 @@ nmi_calltrap: MEXITCOUNT #ifdef HWPMC_HOOKS /* - * Check if the current trap was from user mode and if so - * whether the current thread needs a user call chain to be - * captured. We are still in NMI mode at this point. + * Capture a userspace callchain if needed. + * + * - Check if the current trap was from user mode. + * - Check if the current thread is valid. + * - Check if the thread requires a user call chain to be + * captured. + * + * We are still in NMI mode at this point. */ - testb $SEL_RPL_MASK,TF_CS(%rsp) - jz nocallchain - movq PCPU(CURTHREAD),%rax /* curthread present? */ - orq %rax,%rax + testl %ebx,%ebx + jz nocallchain /* not from userspace */ + movq PCPU(CURTHREAD),%rax + orq %rax,%rax /* curthread present? */ jz nocallchain testl $TDP_CALLCHAIN,TD_PFLAGS(%rax) /* flagged for capture? */ jz nocallchain @@ -459,9 +476,9 @@ nmi_calltrap: */ movq %rsp,%rsi /* source stack pointer */ movq $TF_SIZE,%rcx - movq PCPU(RSP0),%rbx - subq %rcx,%rbx - movq %rbx,%rdi /* destination stack pointer */ + movq PCPU(RSP0),%rdx + subq %rcx,%rdx + movq %rdx,%rdi /* destination stack pointer */ shrq $3,%rcx /* trap frame size in long words */ cld @@ -470,7 +487,7 @@ nmi_calltrap: movl %ss,%eax pushq %rax /* tf_ss */ - pushq %rbx /* tf_rsp (on kernel stack) */ + pushq %rdx /* tf_rsp (on kernel stack) */ pushfq /* tf_rflags */ movl %cs,%eax pushq %rax /* tf_cs */ @@ -480,21 +497,36 @@ outofnmi: /* * At this point the processor has exited NMI mode and is running * with interrupts turned off on the normal kernel stack. - * We turn interrupts back on, and take the usual 'doreti' exit - * path. * * If a pending NMI gets recognized at or after this point, it - * will cause a kernel callchain to be traced. Since this path - * is only taken for NMI interrupts from user space, our `swapgs' - * state is correct for taking the doreti path. + * will cause a kernel callchain to be traced. + * + * We turn interrupts back on, and call the user callchain capture hook. */ + movq pmc_hook,%rax + orq %rax,%rax + jz nocallchain + movq PCPU(CURTHREAD),%rdi /* thread */ + movq $PMC_FN_USER_CALLCHAIN,%rsi /* command */ + movq %rsp,%rdx /* frame */ sti - jmp doreti + call *%rax + cli nocallchain: #endif testl %ebx,%ebx - jz nmi_restoreregs + jz nmi_kernelexit swapgs + jmp nmi_restoreregs +nmi_kernelexit: + /* + * Put back the preserved MSR_GSBASE value. + */ + movl $MSR_GSBASE,%ecx + movq %r12,%rdx + movl %edx,%eax + shrq $32,%rdx + wrmsr nmi_restoreregs: movq TF_RDI(%rsp),%rdi movq TF_RSI(%rsp),%rsi Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/genassym.c Sat May 23 19:17:27 2009 (r192663) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" +#include "opt_hwpmc_hooks.h" #include "opt_kstack_pages.h" #include @@ -44,6 +45,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef HWPMC_HOOKS +#include +#endif #include #include #include @@ -223,3 +227,7 @@ ASSYM(MTX_LOCK, offsetof(struct mtx, mtx ASSYM(MTX_RECURSECNT, offsetof(struct mtx, mtx_recurse)); ASSYM(MSR_GSBASE, MSR_GSBASE); + +#ifdef HWPMC_HOOKS +ASSYM(PMC_FN_USER_CALLCHAIN, PMC_FN_USER_CALLCHAIN); +#endif Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/machdep.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/machdep.c Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/machdep.c Sat May 23 19:17:27 2009 (r192663) @@ -680,6 +680,9 @@ struct gate_descriptor *idt = &idt0[0]; static char dblfault_stack[PAGE_SIZE] __aligned(16); +static char nmi0_stack[PAGE_SIZE] __aligned(16); +CTASSERT(sizeof(struct nmi_pcpu) == 16); + struct amd64tss common_tss[MAXCPU]; /* software prototypes -- in more palatable form */ @@ -1150,6 +1153,7 @@ hammer_time(u_int64_t modulep, u_int64_t caddr_t kmdp; int gsel_tss, x; struct pcpu *pc; + struct nmi_pcpu *np; u_int64_t msr; char *env; @@ -1224,7 +1228,7 @@ hammer_time(u_int64_t modulep, u_int64_t setidt(x, &IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_DE, &IDTVEC(div), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_DB, &IDTVEC(dbg), SDT_SYSIGT, SEL_KPL, 0); - setidt(IDT_NMI, &IDTVEC(nmi), SDT_SYSIGT, SEL_KPL, 1); + setidt(IDT_NMI, &IDTVEC(nmi), SDT_SYSIGT, SEL_KPL, 2); setidt(IDT_BP, &IDTVEC(bpt), SDT_SYSIGT, SEL_UPL, 0); setidt(IDT_OF, &IDTVEC(ofl), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_BR, &IDTVEC(bnd), SDT_SYSIGT, SEL_KPL, 0); @@ -1297,6 +1301,14 @@ hammer_time(u_int64_t modulep, u_int64_t /* doublefault stack space, runs on ist1 */ common_tss[0].tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)]; + /* + * NMI stack, runs on ist2. The pcpu pointer is stored just + * above the start of the ist2 stack. + */ + np = ((struct nmi_pcpu *) &nmi0_stack[sizeof(nmi0_stack)]) - 1; + np->np_pcpu = (register_t) pc; + common_tss[0].tss_ist2 = (long) np; + /* Set the IO permission bitmap (empty due to tss seg limit) */ common_tss[0].tss_iobase = sizeof(struct amd64tss); Modified: user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/amd64/amd64/mp_machdep.c Sat May 23 19:17:27 2009 (r192663) @@ -98,6 +98,7 @@ void *bootstacks[MAXCPU]; /* Temporary holder for double fault stack */ char *doublefault_stack; +char *nmi_stack; /* Hotwire a 0->4MB V==P mapping */ extern pt_entry_t *KPTphys; @@ -455,6 +456,7 @@ void init_secondary(void) { struct pcpu *pc; + struct nmi_pcpu *np; u_int64_t msr, cr0; int cpu, gsel_tss, x; struct region_descriptor ap_gdt; @@ -468,6 +470,10 @@ init_secondary(void) common_tss[cpu].tss_iobase = sizeof(struct amd64tss); common_tss[cpu].tss_ist1 = (long)&doublefault_stack[PAGE_SIZE]; + /* The NMI stack runs on IST2. */ + np = ((struct nmi_pcpu *) &nmi_stack[PAGE_SIZE]) - 1; + common_tss[cpu].tss_ist2 = (long) np; + /* Prepare private GDT */ gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu]; ssdtosyssd(&gdt_segs[GPROC0_SEL], @@ -492,6 +498,9 @@ init_secondary(void) pc->pc_rsp0 = 0; pc->pc_gs32p = &gdt[NGDT * cpu + GUGS32_SEL]; + /* Save the per-cpu pointer for use by the NMI handler. */ + np->np_pcpu = (register_t) pc; + wrmsr(MSR_FSBASE, 0); /* User value */ wrmsr(MSR_GSBASE, (u_int64_t)pc); wrmsr(MSR_KGSBASE, (u_int64_t)pc); /* XXX User value while we're in the kernel */ @@ -758,6 +767,7 @@ start_all_aps(void) /* allocate and set up an idle stack data page */ bootstacks[cpu] = (void *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); doublefault_stack = (char *)kmem_alloc(kernel_map, PAGE_SIZE); + nmi_stack = (char *)kmem_alloc(kernel_map, PAGE_SIZE); bootSTK = (char *)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 8; bootAP = cpu; Modified: user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/amd64/include/intr_machdep.h Sat May 23 19:17:27 2009 (r192663) @@ -120,6 +120,15 @@ struct intsrc { struct trapframe; +/* + * The following data structure holds per-cpu data, and is placed just + * above the top of the space used for the NMI stack. + */ +struct nmi_pcpu { + register_t np_pcpu; + register_t __padding; /* pad to 16 bytes */ +}; + extern struct mtx icu_lock; extern int elcr_found; Modified: user/kmacy/releng_7_2_fcs/sys/i386/i386/exception.s ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/i386/exception.s Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/i386/i386/exception.s Sat May 23 19:17:27 2009 (r192663) @@ -439,9 +439,18 @@ doreti_nmi: iret outofnmi: /* - * Clear interrupts and jump to AST handling code. + * Call the callchain capture hook after turning interrupts back on. */ + movl pmc_hook,%ecx + orl %ecx,%ecx + jz doreti_exit + pushl %esp /* frame pointer */ + pushl $PMC_FN_USER_CALLCHAIN /* command */ + movl PCPU(CURTHREAD),%eax + pushl %eax /* curthread */ sti + call *%ecx + addl $12,%esp jmp doreti_ast ENTRY(end_exceptions) #endif Modified: user/kmacy/releng_7_2_fcs/sys/i386/i386/genassym.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/i386/i386/genassym.c Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/i386/i386/genassym.c Sat May 23 19:17:27 2009 (r192663) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include "opt_apic.h" #include "opt_compat.h" +#include "opt_hwpmc_hooks.h" #include "opt_kstack_pages.h" #include @@ -44,6 +45,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef HWPMC_HOOKS +#include +#endif #include #include #include @@ -231,3 +235,13 @@ ASSYM(MTX_RECURSECNT, offsetof(struct mt ASSYM(BUS_SPACE_HANDLE_BASE, offsetof(struct bus_space_handle, bsh_base)); ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat)); #endif + +#ifdef XEN +#include +ASSYM(PC_CR3, offsetof(struct pcpu, pc_cr3)); +ASSYM(HYPERVISOR_VIRT_START, __HYPERVISOR_VIRT_START); +#endif + +#ifdef HWPMC_HOOKS +ASSYM(PMC_FN_USER_CALLCHAIN, PMC_FN_USER_CALLCHAIN); +#endif Modified: user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Sat May 23 19:17:05 2009 (r192662) +++ user/kmacy/releng_7_2_fcs/sys/kern/subr_trap.c Sat May 23 19:17:27 2009 (r192663) @@ -44,7 +44,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_hwpmc_hooks.h" #include "opt_ktrace.h" #include "opt_mac.h" #ifdef __i386__ From owner-svn-src-user@FreeBSD.ORG Sat May 23 19:57:12 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 623E8106564A; Sat, 23 May 2009 19:57:12 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4F6F58FC14; Sat, 23 May 2009 19:57:12 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4NJvC5w066576; Sat, 23 May 2009 19:57:12 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4NJvBNN066564; Sat, 23 May 2009 19:57:11 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905231957.n4NJvBNN066564@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 19:57:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192666 - in user/kmacy/releng_7_2_fcs/sys/boot: . common i386 i386/libi386 i386/loader i386/zfsboot zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 19:57:12 -0000 Author: kmacy Date: Sat May 23 19:57:11 2009 New Revision: 192666 URL: http://svn.freebsd.org/changeset/base/192666 Log: merge 192665 Import ZFS loader support missed in the initial MFC set LOADER_ZFS_SUPPORT=Y in make.conf to enable Added: user/kmacy/releng_7_2_fcs/sys/boot/i386/zfsboot/Makefile user/kmacy/releng_7_2_fcs/sys/boot/i386/zfsboot/zfsldr.S user/kmacy/releng_7_2_fcs/sys/boot/zfs/Makefile user/kmacy/releng_7_2_fcs/sys/boot/zfs/zfs.c Modified: user/kmacy/releng_7_2_fcs/sys/boot/Makefile user/kmacy/releng_7_2_fcs/sys/boot/common/bootstrap.h user/kmacy/releng_7_2_fcs/sys/boot/i386/Makefile user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/bootinfo32.c user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/devicename.c user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/conf.c user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/main.c Modified: user/kmacy/releng_7_2_fcs/sys/boot/Makefile ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/Makefile Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/Makefile Sat May 23 19:57:11 2009 (r192666) @@ -17,6 +17,10 @@ SUBDIR+= efi SUBDIR+= ofw .endif +.if defined(LOADER_ZFS_SUPPORT) +SUBDIR+= zfs +.endif + # Pick the machine-dependent subdir based on the target architecture. SUBDIR+= ${MACHINE:S/amd64/i386/:S/sun4v/sparc64/} Modified: user/kmacy/releng_7_2_fcs/sys/boot/common/bootstrap.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/common/bootstrap.h Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/common/bootstrap.h Sat May 23 19:57:11 2009 (r192666) @@ -43,6 +43,7 @@ struct devdesc #define DEVT_DISK 1 #define DEVT_NET 2 #define DEVT_CD 3 +#define DEVT_ZFS 4 int d_unit; }; Modified: user/kmacy/releng_7_2_fcs/sys/boot/i386/Makefile ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/i386/Makefile Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/Makefile Sat May 23 19:57:11 2009 (r192666) @@ -1,7 +1,7 @@ # $FreeBSD$ -SUBDIR= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot kgzldr \ - libi386 libfirewire loader +SUBDIR= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot zfsboot \ + kgzldr libi386 libfirewire loader # special boot programs, 'self-extracting boot2+loader' SUBDIR+= pxeldr Modified: user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/bootinfo32.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/bootinfo32.c Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/bootinfo32.c Sat May 23 19:57:11 2009 (r192666) @@ -183,6 +183,7 @@ bi_load32(char *args, int *howtop, int * break; case DEVT_NET: + case DEVT_ZFS: break; default: Modified: user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/devicename.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/devicename.c Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/libi386/devicename.c Sat May 23 19:57:11 2009 (r192666) @@ -171,6 +171,7 @@ i386_parsedev(struct i386_devdesc **dev, case DEVT_CD: case DEVT_NET: + case DEVT_ZFS: unit = 0; if (*np && (*np != ':')) { @@ -246,6 +247,7 @@ i386_fmtdev(void *vdev) break; case DEVT_NET: + case DEVT_ZFS: sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); break; } Modified: user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile Sat May 23 19:57:11 2009 (r192666) @@ -15,6 +15,12 @@ CFLAGS+= -DLOADER_FIREWIRE_SUPPORT LIBFIREWIRE= ${.OBJDIR}/../libfirewire/libfirewire.a .endif +# Put LOADER_ZFS_SUPPORT=yes in /etc/make.conf for ZFS support +.if defined(LOADER_ZFS_SUPPORT) +CFLAGS+= -DLOADER_ZFS_SUPPORT +LIBZFS= ${.OBJDIR}/../../zfs/libzfsboot.a +.endif + # Enable PXE TFTP or NFS support, not both. .if defined(LOADER_TFTP_SUPPORT) CFLAGS+= -DLOADER_TFTP_SUPPORT @@ -99,8 +105,8 @@ FILES+= loader.rc # XXX crt0.o needs to be first for pxeboot(8) to work OBJS= ${BTXCRT} -DPADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBI386} ${LIBSTAND} -LDADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBI386} -lstand +DPADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFS} ${LIBI386} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFS} ${LIBI386} -lstand .include Modified: user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/conf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/conf.c Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/conf.c Sat May 23 19:57:11 2009 (r192666) @@ -50,6 +50,10 @@ __FBSDID("$FreeBSD$"); extern struct devsw fwohci; #endif +#if defined(LOADER_ZFS_SUPPORT) +extern struct devsw zfs_dev; +#endif + /* Exported for libstand */ struct devsw *devsw[] = { &bioscd, @@ -60,15 +64,25 @@ struct devsw *devsw[] = { #if defined(LOADER_FIREWIRE_SUPPORT) &fwohci, #endif +#if defined(LOADER_ZFS_SUPPORT) + &zfs_dev, +#endif NULL }; +#if defined(LOADER_ZFS_SUPPORT) +extern struct fs_ops zfs_fsops; +#endif + struct fs_ops *file_system[] = { &ufs_fsops, &ext2fs_fsops, &dosfs_fsops, &cd9660_fsops, &splitfs_fsops, +#if defined(LOADER_ZFS_SUPPORT) + &zfs_fsops, +#endif #ifdef LOADER_GZIP_SUPPORT &gzipfs_fsops, #endif Modified: user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/main.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/main.c Sat May 23 19:54:18 2009 (r192665) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/main.c Sat May 23 19:57:11 2009 (r192666) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #define KARGS_FLAGS_CD 0x1 #define KARGS_FLAGS_PXE 0x2 +#define KARGS_FLAGS_ZFS 0x4 /* Arguments passed in from the boot1/boot2 loader */ static struct @@ -51,8 +52,13 @@ static struct u_int32_t howto; u_int32_t bootdev; u_int32_t bootflags; - u_int32_t pxeinfo; - u_int32_t res2; + union { + struct { + u_int32_t pxeinfo; + u_int32_t res2; + }; + uint64_t zfspool; + }; u_int32_t bootinfo; } *kargs; @@ -96,7 +102,7 @@ main(void) */ bios_getmem(); -#if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || defined(LOADER_GPT_SUPPORT) +#if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || defined(LOADER_GPT_SUPPORT) || defined(LOADER_ZFS_SUPPORT) heap_top = PTOV(memtop_copyin); memtop_copyin -= 0x300000; heap_bottom = PTOV(memtop_copyin); @@ -145,6 +151,14 @@ main(void) bc_add(initial_bootdev); } + archsw.arch_autoload = i386_autoload; + archsw.arch_getdev = i386_getdev; + archsw.arch_copyin = i386_copyin; + archsw.arch_copyout = i386_copyout; + archsw.arch_readin = i386_readin; + archsw.arch_isainb = isa_inb; + archsw.arch_isaoutb = isa_outb; + /* * March through the device switch probing for things. */ @@ -172,14 +186,6 @@ main(void) bios_getsmap(); - archsw.arch_autoload = i386_autoload; - archsw.arch_getdev = i386_getdev; - archsw.arch_copyin = i386_copyin; - archsw.arch_copyout = i386_copyout; - archsw.arch_readin = i386_readin; - archsw.arch_isainb = isa_inb; - archsw.arch_isaoutb = isa_outb; - interact(); /* doesn't return */ /* if we ever get here, it is an error */ @@ -252,6 +258,29 @@ extract_currdev(void) i386_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), env_noset, env_nounset); + +#ifdef LOADER_ZFS_SUPPORT + /* + * If we were started from a ZFS-aware boot2, we can work out + * which ZFS pool we are booting from. + */ + if (kargs->bootflags & KARGS_FLAGS_ZFS) { + /* + * Dig out the pool guid and convert it to a 'unit number' + */ + uint64_t guid; + int unit; + char devname[32]; + extern int zfs_guid_to_unit(uint64_t); + + guid = kargs->zfspool; + unit = zfs_guid_to_unit(guid); + if (unit >= 0) { + sprintf(devname, "zfs%d", unit); + setenv("currdev", devname, 1); + } + } +#endif } COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); Added: user/kmacy/releng_7_2_fcs/sys/boot/i386/zfsboot/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/zfsboot/Makefile Sat May 23 19:57:11 2009 (r192666) @@ -0,0 +1,108 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../boot2 + +FILES= zfsboot + +NM?= nm + +# A value of 0x80 enables LBA support. +BOOT_BOOT1_FLAGS?= 0x80 + +BOOT_COMCONSOLE_PORT?= 0x3f8 +BOOT_COMCONSOLE_SPEED?= 9600 +B2SIOFMT?= 0x3 + +REL1= 0x700 +ORG1= 0x7c00 +ORG2= 0x2000 + +CFLAGS= -Os -g \ + -fno-guess-branch-probability \ + -fomit-frame-pointer \ + -fno-unit-at-a-time \ + -mno-align-long-strings \ + -mrtd \ + -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \ + -DBOOT2 \ + -DFLAGS=${BOOT_BOOT1_FLAGS} \ + -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ + -DSIOFMT=${B2SIOFMT} \ + -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ + -I${.CURDIR}/../../zfs \ + -I${.CURDIR}/../../../cddl/boot/zfs \ + -I${.CURDIR}/../btx/lib -I. \ + -I${.CURDIR}/../boot2 \ + -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ + -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ + -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ + -Winline --param max-inline-insns-single=100 + +LDFLAGS=-static -N --gc-sections + +# Pick up ../Makefile.inc early. +.include + +CLEANFILES= zfsboot + +zfsboot: zfsboot1 zfsboot2 + cat zfsboot1 zfsboot2 > zfsboot + +CLEANFILES+= zfsboot1 zfsldr.out zfsldr.o + +zfsboot1: zfsldr.out + objcopy -S -O binary zfsldr.out ${.TARGET} + +zfsldr.out: zfsldr.o + ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o + +CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ + zfsboot.o zfsboot.s zfsboot.s.tmp zfsboot.h sio.o + +# We currently allow 32768 bytes for zfsboot - in practice it could be +# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. +# +BOOT2SIZE= 32768 + +zfsboot2: zfsboot.ld + @set -- `ls -l zfsboot.ld`; x=$$((${BOOT2SIZE}-$$5)); \ + echo "$$x bytes available"; test $$x -ge 0 + dd if=zfsboot.ld of=${.TARGET} obs=${BOOT2SIZE} conv=osync + +zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN} + btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \ + -o ${.TARGET} -P 1 zfsboot.bin + +zfsboot.ldr: + cp /dev/null ${.TARGET} + +zfsboot.bin: zfsboot.out + objcopy -S -O binary zfsboot.out ${.TARGET} + +zfsboot.out: ${BTXCRT} zfsboot.o sio.o + ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND} + +zfsboot.o: zfsboot.s + +SRCS= zfsboot.c zfsboot.h + +zfsboot.s: zfsboot.c zfsboot.h ${.CURDIR}/../../zfs/zfsimpl.c + ${CC} ${CFLAGS} -S -o zfsboot.s.tmp ${.CURDIR}/zfsboot.c + sed -e '/align/d' -e '/nop/d' < zfsboot.s.tmp > zfsboot.s + rm -f zfsboot.s.tmp + +zfsboot.h: zfsldr.out + ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ + { x = $$1 - ORG1; \ + printf("#define XREADORG %#x\n", REL1 + x) }' \ + ORG1=`printf "%d" ${ORG1}` \ + REL1=`printf "%d" ${REL1}` > ${.TARGET} + +.if ${MACHINE_ARCH} == "amd64" +beforedepend zfsboot.s: machine +CLEANFILES+= machine +machine: + ln -sf ${.CURDIR}/../../../i386/include machine +.endif + +.include Added: user/kmacy/releng_7_2_fcs/sys/boot/i386/zfsboot/zfsldr.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/zfsboot/zfsldr.S Sat May 23 19:57:11 2009 (r192666) @@ -0,0 +1,402 @@ +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD$ + */ + +/* Memory Locations */ + .set MEM_REL,0x700 # Relocation address + .set MEM_ARG,0x900 # Arguments + .set MEM_ORG,0x7c00 # Origin + .set MEM_BUF,0x8000 # Load area + .set MEM_BTX,0x9000 # BTX start + .set MEM_JMP,0x9010 # BTX entry point + .set MEM_USR,0xa000 # Client start + .set BDA_BOOT,0x472 # Boot howto flag + +/* Partition Constants */ + .set PRT_OFF,0x1be # Partition offset + .set PRT_NUM,0x4 # Partitions + .set PRT_BSD,0xa5 # Partition type + +/* Flag Bits */ + .set FL_PACKET,0x80 # Packet mode + +/* Misc. Constants */ + .set SIZ_PAG,0x1000 # Page size + .set SIZ_SEC,0x200 # Sector size + + .set NSECT,0x40 + .globl start + .globl xread + .code16 + +start: jmp main # Start recognizably + +/* + * This is the start of a standard BIOS Parameter Block (BPB). Most bootable + * FAT disks have this at the start of their MBR. While normal BIOS's will + * work fine without this section, IBM's El Torito emulation "fixes" up the + * BPB by writing into the memory copy of the MBR. Rather than have data + * written into our xread routine, we'll define a BPB to work around it. + * The data marked with (T) indicates a field required for a ThinkPad to + * recognize the disk and (W) indicates fields written from IBM BIOS code. + * The use of the BPB is based on what OpenBSD and NetBSD implemented in + * their boot code but the required fields were determined by trial and error. + * + * Note: If additional space is needed in boot1, one solution would be to + * move the "prompt" message data (below) to replace the OEM ID. + */ + .org 0x03, 0x00 +oemid: .space 0x08, 0x00 # OEM ID + + .org 0x0b, 0x00 +bpb: .word 512 # sector size (T) + .byte 0 # sectors/clustor + .word 0 # reserved sectors + .byte 0 # number of FATs + .word 0 # root entries + .word 0 # small sectors + .byte 0 # media type (W) + .word 0 # sectors/fat + .word 18 # sectors per track (T) + .word 2 # number of heads (T) + .long 0 # hidden sectors (W) + .long 0 # large sectors + + .org 0x24, 0x00 +ebpb: .byte 0 # BIOS physical drive number (W) + + .org 0x25,0x90 +/* + * Trampoline used by boot2 to call read to read data from the disk via + * the BIOS. Call with: + * + * %cx:%ax - long - LBA to read in + * %es:(%bx) - caddr_t - buffer to read data into + * %dl - byte - drive to read from + * %dh - byte - num sectors to read + */ + +xread: push %ss # Address + pop %ds # data +/* + * Setup an EDD disk packet and pass it to read + */ +xread.1: # Starting + pushl $0x0 # absolute + push %cx # block + push %ax # number + push %es # Address of + push %bx # transfer buffer + xor %ax,%ax # Number of + movb %dh,%al # blocks to + push %ax # transfer + push $0x10 # Size of packet + mov %sp,%bp # Packet pointer + callw read # Read from disk + lea 0x10(%bp),%sp # Clear stack + lret # To far caller +/* + * Load the rest of boot2 and BTX up, copy the parts to the right locations, + * and start it all up. + */ + +/* + * Setup the segment registers to flat addressing (segment 0) and setup the + * stack to end just below the start of our code. + */ +main: cld # String ops inc + xor %cx,%cx # Zero + mov %cx,%es # Address + mov %cx,%ds # data + mov %cx,%ss # Set up + mov $start,%sp # stack +/* + * Relocate ourself to MEM_REL. Since %cx == 0, the inc %ch sets + * %cx == 0x100. + */ + mov %sp,%si # Source + mov $MEM_REL,%di # Destination + incb %ch # Word count + rep # Copy + movsw # code +/* + * If we are on a hard drive, then load the MBR and look for the first + * FreeBSD slice. We use the fake partition entry below that points to + * the MBR when we call nread. The first pass looks for the first active + * FreeBSD slice. The second pass looks for the first non-active FreeBSD + * slice if the first one fails. + */ + mov $part4,%si # Partition + cmpb $0x80,%dl # Hard drive? + jb main.4 # No + movb $0x1,%dh # Block count + callw nread # Read MBR + mov $0x1,%cx # Two passes +main.1: mov $MEM_BUF+PRT_OFF,%si # Partition table + movb $0x1,%dh # Partition +main.2: cmpb $PRT_BSD,0x4(%si) # Our partition type? + jne main.3 # No + jcxz main.5 # If second pass + testb $0x80,(%si) # Active? + jnz main.5 # Yes +main.3: add $0x10,%si # Next entry + incb %dh # Partition + cmpb $0x1+PRT_NUM,%dh # In table? + jb main.2 # Yes + dec %cx # Do two + jcxz main.1 # passes +/* + * If we get here, we didn't find any FreeBSD slices at all, so print an + * error message and die. + */ + mov $msg_part,%si # Message + jmp error # Error +/* + * Floppies use partition 0 of drive 0. + */ +main.4: xor %dx,%dx # Partition:drive + +/* + * Ok, we have a slice and drive in %dx now, so use that to locate and + * load boot2. %si references the start of the slice we are looking + * for, so go ahead and load up the 64 sectors starting at sector 1024 + * (i.e. after the two vdev labels). We don't have do anything fancy + * here to allow for an extra copy of boot1 and a partition table + * (compare to this section of the UFS bootstrap) so we just load it + * all at 0x8000. The first part of boot2 is BTX, which wants to run + * at 0x9000. The boot2.bin binary starts right after the end of BTX, + * so we have to figure out where the start of it is and then move the + * binary to 0xc000. After we have moved the client, we relocate BTX + * itself to 0x9000 - doing it in this order means that none of the + * memcpy regions overlap which would corrupt the copy. Normally, BTX + * clients start at MEM_USR, or 0xa000, but when we use btxld to + * create boot2, we use an entry point of 0x2000. That entry point is + * relative to MEM_USR; thus boot2.bin starts at 0xc000. + * + * The load area and the target area for the client overlap so we have + * to use a decrementing string move. We also play segment register + * games with the destination address for the move so that the client + * can be larger than 16k (which would overflow the zero segment since + * the client starts at 0xc000). Relocating BTX is easy since the load + * area and target area do not overlap. + */ +main.5: mov %dx,MEM_ARG # Save args + movb $NSECT,%dh # Sector count + movw $1024,%ax # Offset to boot2 + callw nread.1 # Read disk +main.6: mov $MEM_BUF,%si # BTX (before reloc) + mov 0xa(%si),%bx # Get BTX length and set + mov $NSECT*SIZ_SEC-1,%di # Size of load area (less one) + mov %di,%si # End of load + add $MEM_BUF,%si # area + sub %bx,%di # End of client, 0xc000 rel + mov %di,%cx # Size of + inc %cx # client + mov $(MEM_USR+2*SIZ_PAG)>>4,%dx # Segment + mov %dx,%es # addressing 0xc000 + std # Move with decrement + rep # Relocate + movsb # client + mov %ds,%dx # Back to + mov %dx,%es # zero segment + mov $MEM_BUF,%si # BTX (before reloc) + mov $MEM_BTX,%di # BTX + mov %bx,%cx # Get BTX length + cld # Increment this time + rep # Relocate + movsb # BTX + +/* + * Enable A20 so we can access memory above 1 meg. + * Use the zero-valued %cx as a timeout for embedded hardware which do not + * have a keyboard controller. + */ +seta20: cli # Disable interrupts +seta20.1: dec %cx # Timeout? + jz seta20.3 # Yes + inb $0x64,%al # Get status + testb $0x2,%al # Busy? + jnz seta20.1 # Yes + movb $0xd1,%al # Command: Write + outb %al,$0x64 # output port +seta20.2: inb $0x64,%al # Get status + testb $0x2,%al # Busy? + jnz seta20.2 # Yes + movb $0xdf,%al # Enable + outb %al,$0x60 # A20 +seta20.3: sti # Enable interrupts + + jmp start+MEM_JMP-MEM_ORG # Start BTX + + +/* + * Trampoline used to call read from within boot1. + */ +nread: xor %ax,%ax # Sector offset in partition +nread.1: mov $MEM_BUF,%bx # Transfer buffer + add 0x8(%si),%ax # Get + mov 0xa(%si),%cx # LBA + push %cs # Read from + callw xread.1 # disk + jnc return # If success, return + mov $msg_read,%si # Otherwise, set the error + # message and fall through to + # the error routine +/* + * Print out the error message pointed to by %ds:(%si) followed + * by a prompt, wait for a keypress, and then reboot the machine. + */ +error: callw putstr # Display message + mov $prompt,%si # Display + callw putstr # prompt + xorb %ah,%ah # BIOS: Get + int $0x16 # keypress + movw $0x1234, BDA_BOOT # Do a warm boot + ljmp $0xffff,$0x0 # reboot the machine +/* + * Display a null-terminated string using the BIOS output. + */ +putstr.0: mov $0x7,%bx # Page:attribute + movb $0xe,%ah # BIOS: Display + int $0x10 # character +putstr: lodsb # Get char + testb %al,%al # End of string? + jne putstr.0 # No + +/* + * Overused return code. ereturn is used to return an error from the + * read function. Since we assume putstr succeeds, we (ab)use the + * same code when we return from putstr. + */ +ereturn: movb $0x1,%ah # Invalid + stc # argument +return: retw # To caller +/* + * Reads sectors from the disk. If EDD is enabled, then check if it is + * installed and use it if it is. If it is not installed or not enabled, then + * fall back to using CHS. Since we use a LBA, if we are using CHS, we have to + * fetch the drive parameters from the BIOS and divide it out ourselves. + * Call with: + * + * %dl - byte - drive number + * stack - 10 bytes - EDD Packet + */ +read: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled? + jz read.1 # No, use CHS + cmpb $0x80,%dl # Hard drive? + jb read.1 # No, use CHS + mov $0x55aa,%bx # Magic + push %dx # Save + movb $0x41,%ah # BIOS: Check + int $0x13 # extensions present + pop %dx # Restore + jc read.1 # If error, use CHS + cmp $0xaa55,%bx # Magic? + jne read.1 # No, so use CHS + testb $0x1,%cl # Packet interface? + jz read.1 # No, so use CHS + mov %bp,%si # Disk packet + movb $0x42,%ah # BIOS: Extended + int $0x13 # read + retw # To caller +#if 0 +read.1: push %dx # Save + movb $0x8,%ah # BIOS: Get drive + int $0x13 # parameters + movb %dh,%ch # Max head number + pop %dx # Restore + jc return # If error + andb $0x3f,%cl # Sectors per track + jz ereturn # If zero + cli # Disable interrupts + mov 0x8(%bp),%eax # Get LBA + push %dx # Save + movzbl %cl,%ebx # Divide by + xor %edx,%edx # sectors + div %ebx # per track + movb %ch,%bl # Max head number + movb %dl,%ch # Sector number + inc %bx # Divide by + xorb %dl,%dl # number + div %ebx # of heads + movb %dl,%bh # Head number + pop %dx # Restore + cmpl $0x3ff,%eax # Cylinder number supportable? + sti # Enable interrupts + ja ereturn # No, return an error + xchgb %al,%ah # Set up cylinder + rorb $0x2,%al # number + orb %ch,%al # Merge + inc %ax # sector + xchg %ax,%cx # number + movb %bh,%dh # Head number + subb %ah,%al # Sectors this track + mov 0x2(%bp),%ah # Blocks to read + cmpb %ah,%al # To read + jb read.2 # this +#ifdef TRACK_AT_A_TIME + movb %ah,%al # track +#else + movb $1,%al # one sector +#endif +read.2: mov $0x5,%di # Try count +read.3: les 0x4(%bp),%bx # Transfer buffer + push %ax # Save + movb $0x2,%ah # BIOS: Read + int $0x13 # from disk + pop %bx # Restore + jnc read.4 # If success + dec %di # Retry? + jz read.6 # No + xorb %ah,%ah # BIOS: Reset + int $0x13 # disk system + xchg %bx,%ax # Block count + jmp read.3 # Continue +read.4: movzbw %bl,%ax # Sectors read + add %ax,0x8(%bp) # Adjust + jnc read.5 # LBA, + incw 0xa(%bp) # transfer +read.5: shlb %bl # buffer + add %bl,0x5(%bp) # pointer, + sub %al,0x2(%bp) # block count + ja read.1 # If not done +read.6: retw # To caller +#else +read.1: mov $msg_chs,%si + jmp error +msg_chs: .asciz "CHS not supported" +#endif + +/* Messages */ + +msg_read: .asciz "Read" +msg_part: .asciz "Boot" + +prompt: .asciz " error\r\n" + +flags: .byte FLAGS # Flags + + .org PRT_OFF,0x90 + +/* Partition table */ + + .fill 0x30,0x1,0x0 +part4: .byte 0x80, 0x00, 0x01, 0x00 + .byte 0xa5, 0xfe, 0xff, 0xff + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x50, 0xc3, 0x00, 0x00 # 50000 sectors long, bleh + + .word 0xaa55 # Magic number Added: user/kmacy/releng_7_2_fcs/sys/boot/zfs/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_fcs/sys/boot/zfs/Makefile Sat May 23 19:57:11 2009 (r192666) @@ -0,0 +1,39 @@ +# $FreeBSD$ + +LIB= zfsboot +INTERNALLIB= + +SRCS+= zfs.c + +CFLAGS+= -I${.CURDIR}/../common -I${.CURDIR}/../.. -I. +CFLAGS+= -I${.CURDIR}/../../../lib/libstand +CFLAGS+= -I${.CURDIR}/../../cddl/boot/zfs + +CFLAGS+= -ffreestanding +.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" +CFLAGS+= -mpreferred-stack-boundary=2 +CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 +.endif +.if ${MACHINE_ARCH} == "i386" +CFLAGS+= -mno-sse3 +.endif +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "arm" +CFLAGS+= -msoft-float +.endif +.if ${MACHINE_ARCH} == "amd64" +CFLAGS+= -m32 -march=i386 +.endif + +CFLAGS+= -Wformat -Wall + +.if ${MACHINE_ARCH} == "amd64" +CLEANFILES+= machine +machine: + ln -sf ${.CURDIR}/../../i386/include machine +.endif + +.include + +.if ${MACHINE_ARCH} == "amd64" +beforedepend ${OBJS}: machine +.endif Added: user/kmacy/releng_7_2_fcs/sys/boot/zfs/zfs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/releng_7_2_fcs/sys/boot/zfs/zfs.c Sat May 23 19:57:11 2009 (r192666) @@ -0,0 +1,518 @@ +/*- + * Copyright (c) 2007 Doug Rabson + * 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. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * Stand-alone file reading package. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "zfsimpl.c" + +static int zfs_open(const char *path, struct open_file *f); +static int zfs_write(struct open_file *f, void *buf, size_t size, size_t *resid); +static int zfs_close(struct open_file *f); +static int zfs_read(struct open_file *f, void *buf, size_t size, size_t *resid); +static off_t zfs_seek(struct open_file *f, off_t offset, int where); +static int zfs_stat(struct open_file *f, struct stat *sb); +static int zfs_readdir(struct open_file *f, struct dirent *d); + +struct devsw zfs_dev; + +struct fs_ops zfs_fsops = { + "zfs", + zfs_open, + zfs_close, + zfs_read, + zfs_write, + zfs_seek, + zfs_stat, + zfs_readdir +}; + +/* + * In-core open file. + */ +struct file { + off_t f_seekp; /* seek pointer */ + dnode_phys_t f_dnode; + uint64_t f_zap_type; /* zap type for readdir */ + uint64_t f_num_leafs; /* number of fzap leaf blocks */ + zap_leaf_phys_t *f_zap_leaf; /* zap leaf buffer */ +}; + +/* + * Open a file. + */ +static int +zfs_open(const char *upath, struct open_file *f) +{ + spa_t *spa = (spa_t *) f->f_devdata; + struct file *fp; + int rc; + + if (f->f_dev != &zfs_dev) + return (EINVAL); + + rc = zfs_mount_pool(spa); + if (rc) + return (rc); + + /* allocate file system specific data structure */ + fp = malloc(sizeof(struct file)); + bzero(fp, sizeof(struct file)); + f->f_fsdata = (void *)fp; + + if (spa->spa_root_objset.os_type != DMU_OST_ZFS) { + printf("Unexpected object set type %lld\n", + spa->spa_root_objset.os_type); + rc = EIO; + goto out; + } + + rc = zfs_lookup(spa, upath, &fp->f_dnode); + if (rc) + goto out; + + fp->f_seekp = 0; +out: + if (rc) { + f->f_fsdata = NULL; + free(fp); + } + return (rc); +} + +static int +zfs_close(struct open_file *f) +{ + struct file *fp = (struct file *)f->f_fsdata; + + dnode_cache_obj = 0; + f->f_fsdata = (void *)0; + if (fp == (struct file *)0) + return (0); + + free(fp); + return (0); +} + +/* + * Copy a portion of a file into kernel memory. + * Cross block boundaries when necessary. + */ +static int +zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */) +{ + spa_t *spa = (spa_t *) f->f_devdata; + struct file *fp = (struct file *)f->f_fsdata; + const znode_phys_t *zp = (const znode_phys_t *) fp->f_dnode.dn_bonus; + size_t n; + int rc; + + n = size; + if (fp->f_seekp + n > zp->zp_size) + n = zp->zp_size - fp->f_seekp; + + rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, start, n); + if (rc) + return (rc); + + if (0) { + int i; + for (i = 0; i < n; i++) + putchar(((char*) start)[i]); + } + fp->f_seekp += n; + if (resid) + *resid = size - n; + + return (0); +} + +/* + * Don't be silly - the bootstrap has no business writing anything. + */ +static int +zfs_write(struct open_file *f, void *start, size_t size, size_t *resid /* out */) +{ + + return (EROFS); +} + +static off_t +zfs_seek(struct open_file *f, off_t offset, int where) +{ + struct file *fp = (struct file *)f->f_fsdata; + znode_phys_t *zp = (znode_phys_t *) fp->f_dnode.dn_bonus; + + switch (where) { + case SEEK_SET: + fp->f_seekp = offset; + break; + case SEEK_CUR: + fp->f_seekp += offset; + break; + case SEEK_END: + fp->f_seekp = zp->zp_size - offset; + break; + default: + errno = EINVAL; + return (-1); + } + return (fp->f_seekp); +} + +static int +zfs_stat(struct open_file *f, struct stat *sb) +{ + struct file *fp = (struct file *)f->f_fsdata; + znode_phys_t *zp = (znode_phys_t *) fp->f_dnode.dn_bonus; + + /* only important stuff */ + sb->st_mode = zp->zp_mode; + sb->st_uid = zp->zp_uid; + sb->st_gid = zp->zp_gid; + sb->st_size = zp->zp_size; + + return (0); +} + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat May 23 20:03:34 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 880BA106564A; Sat, 23 May 2009 20:03:34 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 76B558FC13; Sat, 23 May 2009 20:03:34 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4NK3YUf066745; Sat, 23 May 2009 20:03:34 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4NK3Yon066743; Sat, 23 May 2009 20:03:34 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905232003.n4NK3Yon066743@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 20:03:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192667 - in user/kmacy/releng_7_2_fcs/sys/boot: . i386/loader X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 20:03:34 -0000 Author: kmacy Date: Sat May 23 20:03:34 2009 New Revision: 192667 URL: http://svn.freebsd.org/changeset/base/192667 Log: be consistent with the rest of /src and make ZFS loader support opt out - CDDL contaminates by its presence not by being linked in, this seems to be a source of confusion for many Modified: user/kmacy/releng_7_2_fcs/sys/boot/Makefile user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile Modified: user/kmacy/releng_7_2_fcs/sys/boot/Makefile ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/Makefile Sat May 23 19:57:11 2009 (r192666) +++ user/kmacy/releng_7_2_fcs/sys/boot/Makefile Sat May 23 20:03:34 2009 (r192667) @@ -17,7 +17,7 @@ SUBDIR+= efi SUBDIR+= ofw .endif -.if defined(LOADER_ZFS_SUPPORT) +.if ${MK_ZFS} != "no" SUBDIR+= zfs .endif Modified: user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile Sat May 23 19:57:11 2009 (r192666) +++ user/kmacy/releng_7_2_fcs/sys/boot/i386/loader/Makefile Sat May 23 20:03:34 2009 (r192667) @@ -16,7 +16,7 @@ LIBFIREWIRE= ${.OBJDIR}/../libfirewire/l .endif # Put LOADER_ZFS_SUPPORT=yes in /etc/make.conf for ZFS support -.if defined(LOADER_ZFS_SUPPORT) +.if ${MK_ZFS} != "no" CFLAGS+= -DLOADER_ZFS_SUPPORT LIBZFS= ${.OBJDIR}/../../zfs/libzfsboot.a .endif From owner-svn-src-user@FreeBSD.ORG Sat May 23 20:33:54 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C8371065670; Sat, 23 May 2009 20:33:54 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E47728FC08; Sat, 23 May 2009 20:33:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4NKXrs8067407; Sat, 23 May 2009 20:33:53 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4NKXrET067405; Sat, 23 May 2009 20:33:53 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905232033.n4NKXrET067405@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 20:33:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192668 - in user/kmacy/releng_7_2_fcs/sys: cddl/compat/opensolaris/sys kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 20:33:54 -0000 Author: kmacy Date: Sat May 23 20:33:53 2009 New Revision: 192668 URL: http://svn.freebsd.org/changeset/base/192668 Log: push kthread priorities down Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Modified: user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Sat May 23 20:03:34 2009 (r192667) +++ user/kmacy/releng_7_2_fcs/sys/cddl/compat/opensolaris/sys/proc.h Sat May 23 20:33:53 2009 (r192668) @@ -39,8 +39,8 @@ #ifdef _KERNEL #define CPU curcpu -#define minclsyspri PVM -#define maxclsyspri PI_SOFT +#define minclsyspri PRIBIO +#define maxclsyspri PVM #define max_ncpus mp_ncpus #define boot_max_ncpus mp_ncpus Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Sat May 23 20:03:34 2009 (r192667) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_kthread.c Sat May 23 20:33:53 2009 (r192668) @@ -108,6 +108,9 @@ kthread_create_pri_v(void (*func)(void * if (prio != 0) { td->td_base_pri = prio; td->td_priority = prio; + } else { + td->td_base_pri = PRI_MAX_KERN; + td->td_priority = PRI_MAX_KERN; } /* call the processes' main()... */ From owner-svn-src-user@FreeBSD.ORG Sat May 23 23:08:08 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 290C11065670; Sat, 23 May 2009 23:08:08 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 17C558FC1E; Sat, 23 May 2009 23:08:08 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4NN87fA070594; Sat, 23 May 2009 23:08:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4NN873h070593; Sat, 23 May 2009 23:08:07 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905232308.n4NN873h070593@svn.freebsd.org> From: Kip Macy Date: Sat, 23 May 2009 23:08:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192673 - user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 23:08:08 -0000 Author: kmacy Date: Sat May 23 23:08:07 2009 New Revision: 192673 URL: http://svn.freebsd.org/changeset/base/192673 Log: print out hash table size, retry large failed allocations Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Sat May 23 22:57:49 2009 (r192672) +++ user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Sat May 23 23:08:07 2009 (r192673) @@ -234,7 +234,7 @@ dbuf_init(void) { uint64_t hsize = 1ULL << 16; dbuf_hash_table_t *h = &dbuf_hash_table; - int i; + int i = 0; /* * The hash table is big enough to fill all of physical memory @@ -250,10 +250,15 @@ retry: if (h->hash_table == NULL) { /* XXX - we should really return an error instead of assert */ ASSERT(hsize > (1ULL << 10)); + /* try a few times before dropping */ + if (i++ < 4) + goto retry; + i = 0; hsize >>= 1; goto retry; } + printf("ZFS hash table has %ld buckets\n", hsize); dbuf_cache = kmem_cache_create("dmu_buf_impl_t", sizeof (dmu_buf_impl_t), 0, dbuf_cons, dbuf_dest, NULL, NULL, NULL, 0);