From owner-svn-src-user@FreeBSD.ORG Sun Feb 15 07:47:19 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2ECD72E2; Sun, 15 Feb 2015 07:47:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 00A53774; Sun, 15 Feb 2015 07:47:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1F7lIrw078945; Sun, 15 Feb 2015 07:47:18 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1F7lIqJ078944; Sun, 15 Feb 2015 07:47:18 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502150747.t1F7lIqJ078944@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 15 Feb 2015 07:47:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278792 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 15 Feb 2015 07:47:19 -0000 Author: dchagin Date: Sun Feb 15 07:47:18 2015 New Revision: 278792 URL: https://svnweb.freebsd.org/changeset/base/278792 Log: Add vdso and stack names to the /proc/self/maps. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sun Feb 15 01:34:00 2015 (r278791) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sun Feb 15 07:47:18 2015 (r278792) @@ -989,6 +989,8 @@ linprocfs_doprocenviron(PFS_FILL_ARGS) static char l32_map_str[] = "%08lx-%08lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n"; static char l64_map_str[] = "%016lx-%016lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n"; +static char vdso_str[] = " [vdso]"; +static char stack_str[] = " [stack]"; /* * Filler function for proc/pid/maps @@ -1025,6 +1027,11 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) vm = vmspace_acquire_ref(p); if (vm == NULL) return (ESRCH); + + if (SV_CURPROC_FLAG(SV_LP64)) + l_map_str = l64_map_str; + else + l_map_str = l32_map_str; map = &vm->vm_map; vm_map_lock_read(map); for (entry = map->header.next; entry != &map->header; @@ -1067,6 +1074,11 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) VOP_GETATTR(vp, &vat, td->td_ucred); ino = vat.va_fileid; vput(vp); + } else { + if (e_start == p->p_sysent->sv_shared_page_base) + name = vdso_str; + if (e_end == p->p_sysent->sv_usrstack) + name = stack_str; } } else { flags = 0; @@ -1078,10 +1090,6 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) * format: * start, end, access, offset, major, minor, inode, name. */ - if (SV_CURPROC_FLAG(SV_LP64)) - l_map_str = l64_map_str; - else - l_map_str = l32_map_str; error = sbuf_printf(sb, l_map_str, (u_long)e_start, (u_long)e_end, (e_prot & VM_PROT_READ)?"r":"-", From owner-svn-src-user@FreeBSD.ORG Sun Feb 15 21:50:09 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 63022942; Sun, 15 Feb 2015 21:50:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DCD1C70; Sun, 15 Feb 2015 21:50:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FLo9Rt075977; Sun, 15 Feb 2015 21:50:09 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FLo9km075976; Sun, 15 Feb 2015 21:50:09 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502152150.t1FLo9km075976@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 15 Feb 2015 21:50:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278821 - user/dchagin/lemul/sys/fs/pseudofs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 15 Feb 2015 21:50:09 -0000 Author: dchagin Date: Sun Feb 15 21:50:08 2015 New Revision: 278821 URL: https://svnweb.freebsd.org/changeset/base/278821 Log: To allow reading pseudofs files by chunks replace sbuf from fixed to autoextend. The problem appears when the user tries to read a small chunk of the pseudofs file. The underlying fill method will fail if the size of the supplied sbuf sb is less than required to contain method data. Modified: user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Modified: user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Sun Feb 15 21:47:43 2015 (r278820) +++ user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Sun Feb 15 21:50:08 2015 (r278821) @@ -662,7 +662,7 @@ pfs_read(struct vop_read_args *va) if (buflen > MAXPHYS) buflen = MAXPHYS; - sb = sbuf_new(sb, NULL, buflen + 1, 0); + sb = sbuf_new_auto(); if (sb == NULL) { error = EIO; goto ret; From owner-svn-src-user@FreeBSD.ORG Sun Feb 15 21:52:42 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AA24AB2D; Sun, 15 Feb 2015 21:52:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 948E1D1F; Sun, 15 Feb 2015 21:52:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FLqgAx079811; Sun, 15 Feb 2015 21:52:42 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FLqgXS079810; Sun, 15 Feb 2015 21:52:42 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502152152.t1FLqgXS079810@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 15 Feb 2015 21:52:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278822 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 15 Feb 2015 21:52:42 -0000 Author: dchagin Date: Sun Feb 15 21:52:41 2015 New Revision: 278822 URL: https://svnweb.freebsd.org/changeset/base/278822 Log: Add aupport for /proc//auxv. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sun Feb 15 21:50:08 2015 (r278821) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sun Feb 15 21:52:41 2015 (r278822) @@ -1397,6 +1397,38 @@ linprocfs_douuid(PFS_FILL_ARGS) return(0); } +/* + * Filler function for proc/pid/auxv + */ +static int +linprocfs_doauxv(PFS_FILL_ARGS) +{ + int ret; + + PROC_LOCK(p); + if ((ret = p_candebug(td, p)) != 0) { + PROC_UNLOCK(p); + return (ret); + } + + /* + * Mimic linux behavior and pass only processes with usermode + * address space as valid. Return zero silently otherwize. + */ + if (p->p_vmspace == &vmspace0) { + PROC_UNLOCK(p); + return (0); + } + + if ((p->p_flag & P_SYSTEM) != 0) { + PROC_UNLOCK(p); + return (0); + } + + PROC_UNLOCK(p); + + return (proc_getauxv(td, p, sb)); +} /* * Constructor @@ -1472,6 +1504,8 @@ linprocfs_init(PFS_INIT_ARGS) NULL, NULL, NULL, PFS_RD); pfs_create_link(dir, "fd", &linprocfs_dofdescfs, NULL, NULL, NULL, 0); + pfs_create_file(dir, "auxv", &linprocfs_doauxv, + NULL, NULL, NULL, PFS_RD); /* /proc/scsi/... */ dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0); From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 01:26:42 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5F4EB776; Tue, 17 Feb 2015 01:26:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31304F4B; Tue, 17 Feb 2015 01:26:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H1Qg9S072451; Tue, 17 Feb 2015 01:26:42 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H1QgW7072450; Tue, 17 Feb 2015 01:26:42 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502170126.t1H1QgW7072450@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 17 Feb 2015 01:26:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278877 - user/nwhitehorn/ppc64-pmap-rework X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 01:26:42 -0000 Author: nwhitehorn Date: Tue Feb 17 01:26:41 2015 New Revision: 278877 URL: https://svnweb.freebsd.org/changeset/base/278877 Log: Branch PowerPC code for rework of 64-bit pmap code. The current code has terrible performance on big SMP hardware for architectural reasons. Added: - copied from r278876, head/sys/powerpc/ Directory Properties: user/nwhitehorn/ppc64-pmap-rework/ (props changed) From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 01:45:39 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CAA56CAF; Tue, 17 Feb 2015 01:45:39 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B3B7416E; Tue, 17 Feb 2015 01:45:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H1jdBs081882; Tue, 17 Feb 2015 01:45:39 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H1jdDu081880; Tue, 17 Feb 2015 01:45:39 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502170145.t1H1jdDu081880@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 17 Feb 2015 01:45:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278878 - in user/nwhitehorn/ppc64-pmap-rework: aim include pseries X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 01:45:39 -0000 Author: nwhitehorn Date: Tue Feb 17 01:45:38 2015 New Revision: 278878 URL: https://svnweb.freebsd.org/changeset/base/278878 Log: First round of new code. This is a (nearly) ground-up rewrite of the 64-bit pmap code designed to maximize concurrency. Some pieces are still missing (PS3 support, in particular) but this is capable of surviving make -j16 on a POWER8 at least. Core ingredients: - Remove all global locks and shared state from normal operation. The two page table backends do keep a global lock that is used for evictions, but these are extremely rare. Standard operations for two pmaps using disjoint memory can proceed completely in parallel. - Completely remove the second memory hash table used for overflows in favor of recoverable state and operations on vm_pages. - Use one of the software bits in the PTEs as a lock, the way Linux does and the architecture manual recommends. Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.h user/nwhitehorn/ppc64-pmap-rework/aim/moea64_if.m user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c user/nwhitehorn/ppc64-pmap-rework/include/pmap.h user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Tue Feb 17 01:26:41 2015 (r278877) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Tue Feb 17 01:45:38 2015 (r278878) @@ -1,86 +1,27 @@ /*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of Allegro Networks, Inc. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ -/*- - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. + * Copyright (c) 2008-2015 Nathan Whitehorn * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - * - * $NetBSD: pmap.c,v 1.28 2000/03/26 20:42:36 kleink Exp $ - */ -/*- - * Copyright (C) 2001 Benno Rice. - * 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 Benno Rice ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 TOOLS GMBH 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. + * IN NO EVENT SHALL THE AUTHOR 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 @@ -166,18 +107,23 @@ uintptr_t moea64_get_unique_vsid(void); /* * Locking semantics: - * -- Read lock: if no modifications are being made to either the PVO lists - * or page table or if any modifications being made result in internal - * changes (e.g. wiring, protection) such that the existence of the PVOs - * is unchanged and they remain associated with the same pmap (in which - * case the changes should be protected by the pmap lock) - * -- Write lock: required if PTEs/PVOs are being inserted or removed. + * + * There are two locks of interest: the page locks and the pmap locks, which + * protect their individual PVO lists and are locked in that order. The contents + * of all PVO entries are protected by the locks of their respective pmaps. + * The pmap of any PVO is guaranteed not to change so long as the PVO is linked + * into any list. + * */ -#define LOCK_TABLE_RD() rw_rlock(&moea64_table_lock) -#define UNLOCK_TABLE_RD() rw_runlock(&moea64_table_lock) -#define LOCK_TABLE_WR() rw_wlock(&moea64_table_lock) -#define UNLOCK_TABLE_WR() rw_wunlock(&moea64_table_lock) +static struct mtx_padalign pv_lock[PA_LOCK_COUNT]; + +#define PV_LOCKPTR(pa) ((struct mtx *)(&pv_lock[pa_index(pa) % PA_LOCK_COUNT])) +#define PV_LOCK(pa) mtx_lock(PV_LOCKPTR(pa)) +#define PV_TRYLOCK(pa) mtx_trylock(PV_LOCKPTR(pa)) +#define PV_UNLOCK(pa) mtx_unlock(PV_LOCKPTR(pa)) +#define PV_PAGE_LOCK(m) PV_LOCK(VM_PAGE_TO_PHYS(m)) +#define PV_PAGE_UNLOCK(m) PV_UNLOCK(VM_PAGE_TO_PHYS(m)) struct ofw_map { cell_t om_va; @@ -202,9 +148,8 @@ static int regions_sz, pregions_sz; extern void bs_remap_earlyboot(void); /* - * Lock for the pteg and pvo tables. + * Lock for the SLB tables. */ -struct rwlock moea64_table_lock; struct mtx moea64_slb_mutex; /* @@ -216,10 +161,8 @@ u_int moea64_pteg_mask; /* * PVO data. */ -struct pvo_head *moea64_pvo_table; /* pvo entries by pteg index */ -uma_zone_t moea64_upvo_zone; /* zone for pvo entries for unmanaged pages */ -uma_zone_t moea64_mpvo_zone; /* zone for pvo entries for managed pages */ +uma_zone_t moea64_pvo_zone; /* zone for pvo entries */ static struct pvo_entry *moea64_bpvo_pool; static int moea64_bpvo_pool_index = 0; @@ -261,7 +204,6 @@ SYSCTL_INT(_machdep, OID_AUTO, moea64_pv vm_offset_t moea64_scratchpage_va[2]; struct pvo_entry *moea64_scratchpage_pvo[2]; -uintptr_t moea64_scratchpage_pte[2]; struct mtx moea64_scratchpage_mtx; uint64_t moea64_large_page_mask = 0; @@ -271,16 +213,18 @@ int moea64_large_page_shift = 0; /* * PVO calls. */ -static int moea64_pvo_enter(mmu_t, pmap_t, uma_zone_t, struct pvo_head *, - vm_offset_t, vm_offset_t, uint64_t, int, int8_t); +static int moea64_pvo_enter(mmu_t mmu, struct pvo_entry *pvo, + struct pvo_head *pvo_head); static void moea64_pvo_remove(mmu_t, struct pvo_entry *); +static void moea64_pvo_remove_from_pmap(mmu_t mmu, struct pvo_entry *pvo); +static void moea64_pvo_remove_from_page(mmu_t mmu, struct pvo_entry *pvo); static struct pvo_entry *moea64_pvo_find_va(pmap_t, vm_offset_t); /* * Utility routines. */ -static boolean_t moea64_query_bit(mmu_t, vm_page_t, u_int64_t); -static u_int moea64_clear_bit(mmu_t, vm_page_t, u_int64_t); +static boolean_t moea64_query_bit(mmu_t, vm_page_t, uint64_t); +static u_int moea64_clear_bit(mmu_t, vm_page_t, uint64_t); static void moea64_kremove(mmu_t, vm_offset_t); static void moea64_syncicache(mmu_t, pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_size_t sz); @@ -388,43 +332,103 @@ static mmu_method_t moea64_methods[] = { MMU_DEF(oea64_mmu, "mmu_oea64_base", moea64_methods, 0); -static __inline u_int -va_to_pteg(uint64_t vsid, vm_offset_t addr, int large) +static struct pvo_head * +vm_page_to_pvoh(vm_page_t m) +{ + + mtx_assert(PV_LOCKPTR(VM_PAGE_TO_PHYS(m)), MA_OWNED); + return (&m->md.mdpg_pvoh); +} + +static struct pvo_entry * +alloc_pvo_entry(int bootstrap) +{ + struct pvo_entry *pvo; + + if (!moea64_initialized || bootstrap) { + if (moea64_bpvo_pool_index >= moea64_bpvo_pool_size) { + panic("moea64_enter: bpvo pool exhausted, %d, %d, %zd", + moea64_bpvo_pool_index, moea64_bpvo_pool_size, + moea64_bpvo_pool_size * sizeof(struct pvo_entry)); + } + pvo = &moea64_bpvo_pool[ + atomic_fetchadd_int(&moea64_bpvo_pool_index, 1)]; + bzero(pvo, sizeof(*pvo)); + pvo->pvo_vaddr = PVO_BOOTSTRAP; + } else { + pvo = uma_zalloc(moea64_pvo_zone, M_NOWAIT); + bzero(pvo, sizeof(*pvo)); + } + + return (pvo); +} + + +static void +init_pvo_entry(struct pvo_entry *pvo, pmap_t pmap, vm_offset_t va) { + uint64_t vsid; uint64_t hash; int shift; - shift = large ? moea64_large_page_shift : ADDR_PIDX_SHFT; - hash = (vsid & VSID_HASH_MASK) ^ (((uint64_t)addr & ADDR_PIDX) >> - shift); - return (hash & moea64_pteg_mask); + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + + pvo->pvo_pmap = pmap; + va &= ~ADDR_POFF; + pvo->pvo_vaddr |= va; + vsid = va_to_vsid(pmap, va); + pvo->pvo_vpn = (uint64_t)((va & ADDR_PIDX) >> ADDR_PIDX_SHFT) + | (vsid << 16); + + shift = (pvo->pvo_vaddr & PVO_LARGE) ? moea64_large_page_shift : + ADDR_PIDX_SHFT; + hash = (vsid & VSID_HASH_MASK) ^ (((uint64_t)va & ADDR_PIDX) >> shift); + pvo->pvo_pte.slot = (hash & moea64_pteg_mask) << 3; } -static __inline struct pvo_head * -vm_page_to_pvoh(vm_page_t m) +static void +free_pvo_entry(struct pvo_entry *pvo) { - return (&m->md.mdpg_pvoh); + if (!(pvo->pvo_vaddr & PVO_BOOTSTRAP)) + uma_zfree(moea64_pvo_zone, pvo); } -static __inline void -moea64_pte_create(struct lpte *pt, uint64_t vsid, vm_offset_t va, - uint64_t pte_lo, int flags) +void +moea64_pte_from_pvo(const struct pvo_entry *pvo, struct lpte *lpte) { - /* - * Construct a PTE. Default to IMB initially. Valid bit only gets - * set when the real pte is set in memory. - * - * Note: Don't set the valid bit for correct operation of tlb update. - */ - pt->pte_hi = (vsid << LPTE_VSID_SHIFT) | - (((uint64_t)(va & ADDR_PIDX) >> ADDR_API_SHFT64) & LPTE_API); + lpte->pte_hi = (pvo->pvo_vpn >> (ADDR_API_SHFT64 - ADDR_PIDX_SHFT)) & + LPTE_AVPN_MASK; + lpte->pte_hi |= LPTE_VALID; + + if (pvo->pvo_vaddr & PVO_LARGE) + lpte->pte_hi |= LPTE_BIG; + if (pvo->pvo_vaddr & PVO_WIRED) + lpte->pte_hi |= LPTE_WIRED; + if (pvo->pvo_vaddr & PVO_HID) + lpte->pte_hi |= LPTE_HID; + + lpte->pte_lo = pvo->pvo_pte.pa; /* Includes WIMG bits */ + if (pvo->pvo_pte.prot & VM_PROT_WRITE) + lpte->pte_lo |= LPTE_BW; + else + lpte->pte_lo |= LPTE_BR; + + if (!(pvo->pvo_pte.prot & VM_PROT_EXECUTE)) + lpte->pte_lo |= LPTE_NOEXEC; +} + +void +moea64_sync_refchg(uint64_t lpte_lo) +{ + vm_page_t pg; - if (flags & PVO_LARGE) - pt->pte_hi |= LPTE_BIG; + pg = PHYS_TO_VM_PAGE(lpte_lo & LPTE_RPGN); + if (pg == NULL || (pg->oflags & VPO_UNMANAGED)) + return; - pt->pte_lo = pte_lo; + atomic_set_32(&pg->md.mdpg_attrs, lpte_lo & (LPTE_REF | LPTE_CHG)); } static __inline uint64_t @@ -606,6 +610,7 @@ static void moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) { + struct pvo_entry *pvo; register_t msr; vm_paddr_t pa; vm_offset_t size, off; @@ -617,13 +622,16 @@ moea64_setup_direct_map(mmu_t mmup, vm_o DISABLE_TRANS(msr); if (hw_direct_map) { - LOCK_TABLE_WR(); PMAP_LOCK(kernel_pmap); for (i = 0; i < pregions_sz; i++) { for (pa = pregions[i].mr_start; pa < pregions[i].mr_start + pregions[i].mr_size; pa += moea64_large_page_size) { pte_lo = LPTE_M; + pvo = alloc_pvo_entry(1 /* bootstrap */); + pvo->pvo_vaddr |= PVO_WIRED | PVO_LARGE; + init_pvo_entry(pvo, kernel_pmap, pa); + /* * Set memory access as guarded if prefetch within * the page could exit the available physmem area. @@ -636,18 +644,14 @@ moea64_setup_direct_map(mmu_t mmup, vm_o pregions[i].mr_start + pregions[i].mr_size) pte_lo |= LPTE_G; - moea64_pvo_enter(mmup, kernel_pmap, moea64_upvo_zone, - NULL, pa, pa, pte_lo, - PVO_WIRED | PVO_LARGE, 0); + pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE | + VM_PROT_EXECUTE; + pvo->pvo_pte.pa = pa | pte_lo; + moea64_pvo_enter(mmup, pvo, NULL); } } PMAP_UNLOCK(kernel_pmap); - UNLOCK_TABLE_WR(); } else { - size = sizeof(struct pvo_head) * moea64_pteg_count; - off = (vm_offset_t)(moea64_pvo_table); - for (pa = off; pa < off + size; pa += PAGE_SIZE) - moea64_kenter(mmup, pa, pa); size = moea64_bpvo_pool_size*sizeof(struct pvo_entry); off = (vm_offset_t)(moea64_bpvo_pool); for (pa = off; pa < off + size; pa += PAGE_SIZE) @@ -782,8 +786,6 @@ moea64_early_bootstrap(mmu_t mmup, vm_of void moea64_mid_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) { - vm_size_t size; - register_t msr; int i; /* @@ -792,28 +794,14 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offs moea64_pteg_mask = moea64_pteg_count - 1; /* - * Allocate pv/overflow lists. - */ - size = sizeof(struct pvo_head) * moea64_pteg_count; - - moea64_pvo_table = (struct pvo_head *)moea64_bootstrap_alloc(size, - PAGE_SIZE); - CTR1(KTR_PMAP, "moea64_bootstrap: PVO table at %p", moea64_pvo_table); - - DISABLE_TRANS(msr); - for (i = 0; i < moea64_pteg_count; i++) - LIST_INIT(&moea64_pvo_table[i]); - ENABLE_TRANS(msr); - - /* - * Initialize the lock that synchronizes access to the pteg and pvo - * tables. + * Initialize SLB table lock and page locks */ - rw_init_flags(&moea64_table_lock, "pmap tables", RW_RECURSE); mtx_init(&moea64_slb_mutex, "SLB table", NULL, MTX_DEF); + for (i = 0; i < PA_LOCK_COUNT; i++) + mtx_init(&pv_lock[i], "page pv", NULL, MTX_DEF); /* - * Initialise the unmanaged pvo pool. + * Initialise the bootstrap pvo pool. */ moea64_bpvo_pool = (struct pvo_entry *)moea64_bootstrap_alloc( moea64_bpvo_pool_size*sizeof(struct pvo_entry), 0); @@ -990,22 +978,13 @@ moea64_late_bootstrap(mmu_t mmup, vm_off moea64_scratchpage_pvo[i] = moea64_pvo_find_va( kernel_pmap, (vm_offset_t)moea64_scratchpage_va[i]); - LOCK_TABLE_RD(); - moea64_scratchpage_pte[i] = MOEA64_PVO_TO_PTE( - mmup, moea64_scratchpage_pvo[i]); - moea64_scratchpage_pvo[i]->pvo_pte.lpte.pte_hi - |= LPTE_LOCKED; - MOEA64_PTE_CHANGE(mmup, moea64_scratchpage_pte[i], - &moea64_scratchpage_pvo[i]->pvo_pte.lpte, - moea64_scratchpage_pvo[i]->pvo_vpn); - UNLOCK_TABLE_RD(); } } } /* - * Activate a user pmap. The pmap must be activated before its address - * space can be accessed in any way. + * Activate a user pmap. This mostly involves setting some non-CPU + * state. */ void moea64_activate(mmu_t mmu, struct thread *td) @@ -1040,35 +1019,19 @@ void moea64_unwire(mmu_t mmu, pmap_t pm, vm_offset_t sva, vm_offset_t eva) { struct pvo_entry key, *pvo; - uintptr_t pt; - LOCK_TABLE_RD(); PMAP_LOCK(pm); key.pvo_vaddr = sva; for (pvo = RB_NFIND(pvo_tree, &pm->pmap_pvo, &key); pvo != NULL && PVO_VADDR(pvo) < eva; pvo = RB_NEXT(pvo_tree, &pm->pmap_pvo, pvo)) { - pt = MOEA64_PVO_TO_PTE(mmu, pvo); if ((pvo->pvo_vaddr & PVO_WIRED) == 0) panic("moea64_unwire: pvo %p is missing PVO_WIRED", pvo); pvo->pvo_vaddr &= ~PVO_WIRED; - if ((pvo->pvo_pte.lpte.pte_hi & LPTE_WIRED) == 0) - panic("moea64_unwire: pte %p is missing LPTE_WIRED", - &pvo->pvo_pte.lpte); - pvo->pvo_pte.lpte.pte_hi &= ~LPTE_WIRED; - if (pt != -1) { - /* - * The PTE's wired attribute is not a hardware - * feature, so there is no need to invalidate any TLB - * entries. - */ - MOEA64_PTE_CHANGE(mmu, pt, &pvo->pvo_pte.lpte, - pvo->pvo_vpn); - } + MOEA64_PTE_REPLACE(mmu, pvo, 0 /* Doesn't need invalidation */); pm->pm_stats.wired_count--; } - UNLOCK_TABLE_RD(); PMAP_UNLOCK(pm); } @@ -1085,13 +1048,10 @@ void moea64_set_scratchpage_pa(mmu_t mmu KASSERT(!hw_direct_map, ("Using OEA64 scratchpage with a direct map!")); mtx_assert(&moea64_scratchpage_mtx, MA_OWNED); - moea64_scratchpage_pvo[which]->pvo_pte.lpte.pte_lo &= - ~(LPTE_WIMG | LPTE_RPGN); - moea64_scratchpage_pvo[which]->pvo_pte.lpte.pte_lo |= + moea64_scratchpage_pvo[which]->pvo_pte.pa = moea64_calc_wimg(pa, VM_MEMATTR_DEFAULT) | (uint64_t)pa; - MOEA64_PTE_CHANGE(mmup, moea64_scratchpage_pte[which], - &moea64_scratchpage_pvo[which]->pvo_pte.lpte, - moea64_scratchpage_pvo[which]->pvo_vpn); + MOEA64_PTE_REPLACE(mmup, moea64_scratchpage_pvo[which], + MOEA64_PTE_INVALIDATE); isync(); } @@ -1245,48 +1205,74 @@ int moea64_enter(mmu_t mmu, pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, u_int flags, int8_t psind) { + struct pvo_entry *pvo, *oldpvo; struct pvo_head *pvo_head; - uma_zone_t zone; uint64_t pte_lo; - u_int pvo_flags; int error; if ((m->oflags & VPO_UNMANAGED) == 0 && !vm_page_xbusied(m)) VM_OBJECT_ASSERT_LOCKED(m->object); - if ((m->oflags & VPO_UNMANAGED) != 0 || !moea64_initialized) { - pvo_head = NULL; - zone = moea64_upvo_zone; - pvo_flags = 0; - } else { - pvo_head = vm_page_to_pvoh(m); - zone = moea64_mpvo_zone; - pvo_flags = PVO_MANAGED; - } + pvo = alloc_pvo_entry(0); + pvo->pvo_pmap = NULL; /* to be filled in later */ + pvo->pvo_pte.prot = prot; pte_lo = moea64_calc_wimg(VM_PAGE_TO_PHYS(m), pmap_page_get_memattr(m)); - - if (prot & VM_PROT_WRITE) { - pte_lo |= LPTE_BW; - if (pmap_bootstrapped && - (m->oflags & VPO_UNMANAGED) == 0) - vm_page_aflag_set(m, PGA_WRITEABLE); - } else - pte_lo |= LPTE_BR; - - if ((prot & VM_PROT_EXECUTE) == 0) - pte_lo |= LPTE_NOEXEC; + pvo->pvo_pte.pa = VM_PAGE_TO_PHYS(m) | pte_lo; if ((flags & PMAP_ENTER_WIRED) != 0) - pvo_flags |= PVO_WIRED; + pvo->pvo_vaddr |= PVO_WIRED; + if ((m->oflags & VPO_UNMANAGED) != 0 || !moea64_initialized) { + pvo_head = NULL; + } else { + pvo_head = &m->md.mdpg_pvoh; + pvo->pvo_vaddr |= PVO_MANAGED; + } + for (;;) { - LOCK_TABLE_WR(); + PV_PAGE_LOCK(m); PMAP_LOCK(pmap); - error = moea64_pvo_enter(mmu, pmap, zone, pvo_head, va, - VM_PAGE_TO_PHYS(m), pte_lo, pvo_flags, psind); + if (pvo->pvo_pmap == NULL) + init_pvo_entry(pvo, pmap, va); + if (prot & VM_PROT_WRITE) + if (pmap_bootstrapped && + (m->oflags & VPO_UNMANAGED) == 0) + vm_page_aflag_set(m, PGA_WRITEABLE); + + oldpvo = moea64_pvo_find_va(pmap, va); + if (oldpvo != NULL) { + if (oldpvo->pvo_vaddr == pvo->pvo_vaddr && + oldpvo->pvo_pte.pa == pvo->pvo_pte.pa && + oldpvo->pvo_pte.prot == prot) { + /* Identical mapping already exists */ + error = 0; + if (MOEA64_PTE_SYNCH(mmu, oldpvo) >= 0) { + /* ... and present in page table */ + PV_PAGE_UNLOCK(m); + PMAP_UNLOCK(pmap); + free_pvo_entry(pvo); + break; /* all done */ + } + } + + /* Otherwise, need to kill it first */ + KASSERT(oldpvo->pvo_pmap == pmap, ("pmap of old " + "mapping does not match new mapping")); + moea64_pvo_remove_from_pmap(mmu, oldpvo); + } + error = moea64_pvo_enter(mmu, pvo, pvo_head); + PV_PAGE_UNLOCK(m); PMAP_UNLOCK(pmap); - UNLOCK_TABLE_WR(); + + /* Free any dead pages */ + if (oldpvo != NULL) { + PV_LOCK(oldpvo->pvo_pte.pa & LPTE_RPGN); + moea64_pvo_remove_from_page(mmu, oldpvo); + PV_UNLOCK(oldpvo->pvo_pte.pa & LPTE_RPGN); + free_pvo_entry(oldpvo); + } + if (error != ENOMEM) break; if ((flags & PMAP_ENTER_NOSLEEP) != 0) @@ -1394,9 +1380,9 @@ moea64_extract(mmu_t mmu, pmap_t pm, vm_ if (pvo == NULL) pa = 0; else - pa = (pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN) | - (va - PVO_VADDR(pvo)); + pa = (pvo->pvo_pte.pa & LPTE_RPGN) | (va - PVO_VADDR(pvo)); PMAP_UNLOCK(pm); + return (pa); } @@ -1417,13 +1403,11 @@ moea64_extract_and_hold(mmu_t mmu, pmap_ PMAP_LOCK(pmap); retry: pvo = moea64_pvo_find_va(pmap, va & ~ADDR_POFF); - if (pvo != NULL && (pvo->pvo_pte.lpte.pte_hi & LPTE_VALID) && - ((pvo->pvo_pte.lpte.pte_lo & LPTE_PP) == LPTE_RW || - (prot & VM_PROT_WRITE) == 0)) { + if (pvo != NULL && (pvo->pvo_pte.prot & prot) == prot) { if (vm_page_pa_tryrelock(pmap, - pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN, &pa)) + pvo->pvo_pte.pa & LPTE_RPGN, &pa)) goto retry; - m = PHYS_TO_VM_PAGE(pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN); + m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN); vm_page_hold(m); } PA_UNLOCK_COND(pa); @@ -1436,16 +1420,17 @@ static mmu_t installed_mmu; static void * moea64_uma_page_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) { + struct pvo_entry *pvo; + vm_offset_t va; + vm_page_t m; + int pflags, needed_lock; + /* * This entire routine is a horrible hack to avoid bothering kmem * for new KVA addresses. Because this can get called from inside * kmem allocation routines, calling kmem for a new address here * can lead to multiply locking non-recursive mutexes. */ - vm_offset_t va; - - vm_page_t m; - int pflags, needed_lock; *flags = UMA_SLAB_PRIV; needed_lock = !PMAP_LOCKED(kernel_pmap); @@ -1463,17 +1448,21 @@ moea64_uma_page_alloc(uma_zone_t zone, i va = VM_PAGE_TO_PHYS(m); - LOCK_TABLE_WR(); + pvo = alloc_pvo_entry(1 /* bootstrap */); + + pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE; + pvo->pvo_pte.pa = VM_PAGE_TO_PHYS(m) | LPTE_M; + if (needed_lock) PMAP_LOCK(kernel_pmap); - moea64_pvo_enter(installed_mmu, kernel_pmap, moea64_upvo_zone, - NULL, va, VM_PAGE_TO_PHYS(m), LPTE_M, PVO_WIRED | PVO_BOOTSTRAP, - 0); + init_pvo_entry(pvo, kernel_pmap, va); + pvo->pvo_vaddr |= PVO_WIRED; + + moea64_pvo_enter(installed_mmu, pvo, NULL); if (needed_lock) PMAP_UNLOCK(kernel_pmap); - UNLOCK_TABLE_WR(); if ((wait & M_ZERO) && (m->flags & PG_ZERO) == 0) bzero((void *)va, PAGE_SIZE); @@ -1489,17 +1478,13 @@ moea64_init(mmu_t mmu) CTR0(KTR_PMAP, "moea64_init"); - moea64_upvo_zone = uma_zcreate("UPVO entry", sizeof (struct pvo_entry), - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, - UMA_ZONE_VM | UMA_ZONE_NOFREE); - moea64_mpvo_zone = uma_zcreate("MPVO entry", sizeof(struct pvo_entry), + moea64_pvo_zone = uma_zcreate("UPVO entry", sizeof (struct pvo_entry), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM | UMA_ZONE_NOFREE); if (!hw_direct_map) { installed_mmu = mmu; - uma_zone_set_allocf(moea64_upvo_zone,moea64_uma_page_alloc); - uma_zone_set_allocf(moea64_mpvo_zone,moea64_uma_page_alloc); + uma_zone_set_allocf(moea64_pvo_zone,moea64_uma_page_alloc); } #ifdef COMPAT_FREEBSD32 @@ -1515,7 +1500,8 @@ moea64_is_referenced(mmu_t mmu, vm_page_ KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("moea64_is_referenced: page %p is not managed", m)); - return (moea64_query_bit(mmu, m, PTE_REF)); + + return (moea64_query_bit(mmu, m, LPTE_REF)); } boolean_t @@ -1540,11 +1526,14 @@ boolean_t moea64_is_prefaultable(mmu_t mmu, pmap_t pmap, vm_offset_t va) { struct pvo_entry *pvo; - boolean_t rv; + boolean_t rv = TRUE; PMAP_LOCK(pmap); pvo = moea64_pvo_find_va(pmap, va & ~ADDR_POFF); - rv = pvo == NULL || (pvo->pvo_pte.lpte.pte_hi & LPTE_VALID) == 0; + if (pvo != NULL) { + if (MOEA64_PTE_SYNCH(mmu, pvo) >= 0) /* in page table? */ + rv = FALSE; + } PMAP_UNLOCK(pmap); return (rv); } @@ -1576,9 +1565,7 @@ void moea64_remove_write(mmu_t mmu, vm_page_t m) { struct pvo_entry *pvo; - uintptr_t pt; pmap_t pmap; - uint64_t lo = 0; KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("moea64_remove_write: page %p is not managed", m)); @@ -1592,30 +1579,23 @@ moea64_remove_write(mmu_t mmu, vm_page_t if (!vm_page_xbusied(m) && (m->aflags & PGA_WRITEABLE) == 0) return; powerpc_sync(); - LOCK_TABLE_RD(); + PV_PAGE_LOCK(m); LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) { pmap = pvo->pvo_pmap; PMAP_LOCK(pmap); - if ((pvo->pvo_pte.lpte.pte_lo & LPTE_PP) != LPTE_BR) { - pt = MOEA64_PVO_TO_PTE(mmu, pvo); - pvo->pvo_pte.lpte.pte_lo &= ~LPTE_PP; - pvo->pvo_pte.lpte.pte_lo |= LPTE_BR; - if (pt != -1) { - MOEA64_PTE_SYNCH(mmu, pt, &pvo->pvo_pte.lpte); - lo |= pvo->pvo_pte.lpte.pte_lo; - pvo->pvo_pte.lpte.pte_lo &= ~LPTE_CHG; - MOEA64_PTE_CHANGE(mmu, pt, - &pvo->pvo_pte.lpte, pvo->pvo_vpn); - if (pvo->pvo_pmap == kernel_pmap) - isync(); - } + if (!(pvo->pvo_vaddr & PVO_DEAD) && + (pvo->pvo_pte.prot & VM_PROT_WRITE)) { + pvo->pvo_pte.prot &= ~VM_PROT_WRITE; + MOEA64_PTE_REPLACE(mmu, pvo, MOEA64_PTE_PROT_UPDATE); + if (pvo->pvo_pmap == kernel_pmap) + isync(); } - if ((lo & LPTE_CHG) != 0) - vm_page_dirty(m); PMAP_UNLOCK(pmap); } - UNLOCK_TABLE_RD(); + if (atomic_readandclear_32(&m->md.mdpg_attrs) & LPTE_CHG) + vm_page_dirty(m); vm_page_aflag_clear(m, PGA_WRITEABLE); + PV_PAGE_UNLOCK(m); } /* @@ -1646,8 +1626,6 @@ void moea64_page_set_memattr(mmu_t mmu, vm_page_t m, vm_memattr_t ma) { struct pvo_entry *pvo; - struct pvo_head *pvo_head; - uintptr_t pt; pmap_t pmap; uint64_t lo; @@ -1656,25 +1634,23 @@ moea64_page_set_memattr(mmu_t mmu, vm_pa return; } - pvo_head = vm_page_to_pvoh(m); lo = moea64_calc_wimg(VM_PAGE_TO_PHYS(m), ma); - LOCK_TABLE_RD(); - LIST_FOREACH(pvo, pvo_head, pvo_vlink) { + + PV_PAGE_LOCK(m); + LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) { pmap = pvo->pvo_pmap; PMAP_LOCK(pmap); - pt = MOEA64_PVO_TO_PTE(mmu, pvo); - pvo->pvo_pte.lpte.pte_lo &= ~LPTE_WIMG; - pvo->pvo_pte.lpte.pte_lo |= lo; - if (pt != -1) { - MOEA64_PTE_CHANGE(mmu, pt, &pvo->pvo_pte.lpte, - pvo->pvo_vpn); + if (!(pvo->pvo_vaddr & PVO_DEAD)) { + pvo->pvo_pte.pa &= ~LPTE_WIMG; + pvo->pvo_pte.pa |= lo; + MOEA64_PTE_REPLACE(mmu, pvo, MOEA64_PTE_INVALIDATE); if (pvo->pvo_pmap == kernel_pmap) isync(); } PMAP_UNLOCK(pmap); } - UNLOCK_TABLE_RD(); m->md.mdpg_cache_attrs = ma; + PV_PAGE_UNLOCK(m); } /* @@ -1683,17 +1659,18 @@ moea64_page_set_memattr(mmu_t mmu, vm_pa void moea64_kenter_attr(mmu_t mmu, vm_offset_t va, vm_offset_t pa, vm_memattr_t ma) { - uint64_t pte_lo; int error; + struct pvo_entry *pvo; - pte_lo = moea64_calc_wimg(pa, ma); + pvo = alloc_pvo_entry(0); + pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE; + pvo->pvo_pte.pa = (pa & ~ADDR_POFF) | moea64_calc_wimg(pa, ma); + pvo->pvo_vaddr |= PVO_WIRED; - LOCK_TABLE_WR(); PMAP_LOCK(kernel_pmap); - error = moea64_pvo_enter(mmu, kernel_pmap, moea64_upvo_zone, - NULL, va, pa, pte_lo, PVO_WIRED, 0); + init_pvo_entry(pvo, kernel_pmap, va); + error = moea64_pvo_enter(mmu, pvo, NULL); PMAP_UNLOCK(kernel_pmap); - UNLOCK_TABLE_WR(); if (error != 0 && error != ENOENT) panic("moea64_kenter: failed to enter va %#zx pa %#zx: %d", va, @@ -1728,7 +1705,7 @@ moea64_kextract(mmu_t mmu, vm_offset_t v pvo = moea64_pvo_find_va(kernel_pmap, va); KASSERT(pvo != NULL, ("moea64_kextract: no addr found for %#" PRIxPTR, va)); - pa = (pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN) | (va - PVO_VADDR(pvo)); + pa = (pvo->pvo_pte.pa & LPTE_RPGN) | (va - PVO_VADDR(pvo)); PMAP_UNLOCK(kernel_pmap); return (pa); } @@ -1748,8 +1725,8 @@ moea64_kremove(mmu_t mmu, vm_offset_t va * The value passed in *virt is a suggested virtual address for the mapping. * Architectures which can support a direct-mapped physical to virtual region * can return the appropriate address within that region, leaving '*virt' - * unchanged. We cannot and therefore do not; *virt is updated with the - * first usable address after the mapped region. + * unchanged. Other architectures should map the pages starting at '*virt' and + * update '*virt' with the first usable address after the mapped region. */ vm_offset_t moea64_map(mmu_t mmu, vm_offset_t *virt, vm_paddr_t pa_start, @@ -1757,8 +1734,22 @@ moea64_map(mmu_t mmu, vm_offset_t *virt, { vm_offset_t sva, va; + if (hw_direct_map) { + /* + * Check if every page in the region is covered by the direct + * map. The direct map covers all of physical memory, so use + * moea64_calc_wimg() as a shortcut to see if the page is in + * physical memory as a way to see if the direct map covers it. + */ + for (va = pa_start; va < pa_end; va += PAGE_SIZE) + if (moea64_calc_wimg(va, VM_MEMATTR_DEFAULT) != LPTE_M) + break; + if (va == pa_end) + return (pa_start); + } sva = *virt; va = sva; + /* XXX respect prot argument */ for (; pa_start < pa_end; pa_start += PAGE_SIZE, va += PAGE_SIZE) moea64_kenter(mmu, va, pa_start); *virt = va; @@ -1784,16 +1775,16 @@ moea64_page_exists_quick(mmu_t mmu, pmap ("moea64_page_exists_quick: page %p is not managed", m)); loops = 0; rv = FALSE; - LOCK_TABLE_RD(); + PV_PAGE_LOCK(m); LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) { - if (pvo->pvo_pmap == pmap) { + if (!(pvo->pvo_vaddr & PVO_DEAD) && pvo->pvo_pmap == pmap) { rv = TRUE; break; } if (++loops >= 16) break; } - UNLOCK_TABLE_RD(); + PV_PAGE_UNLOCK(m); return (rv); } @@ -1810,11 +1801,11 @@ moea64_page_wired_mappings(mmu_t mmu, vm count = 0; if ((m->oflags & VPO_UNMANAGED) != 0) return (count); - LOCK_TABLE_RD(); + PV_PAGE_LOCK(m); LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) - if ((pvo->pvo_vaddr & PVO_WIRED) != 0) + if ((pvo->pvo_vaddr & (PVO_DEAD | PVO_WIRED)) == PVO_WIRED) count++; - UNLOCK_TABLE_RD(); + PV_PAGE_UNLOCK(m); return (count); } @@ -1926,59 +1917,43 @@ moea64_pinit0(mmu_t mmu, pmap_t pm) static void moea64_pvo_protect(mmu_t mmu, pmap_t pm, struct pvo_entry *pvo, vm_prot_t prot) { - uintptr_t pt; - struct vm_page *pg; - uint64_t oldlo; + struct vm_page *pg; + vm_prot_t oldprot; + int32_t refchg; PMAP_LOCK_ASSERT(pm, MA_OWNED); /* - * Grab the PTE pointer before we diddle with the cached PTE - * copy. - */ - pt = MOEA64_PVO_TO_PTE(mmu, pvo); - - /* * Change the protection of the page. */ - oldlo = pvo->pvo_pte.lpte.pte_lo; - pvo->pvo_pte.lpte.pte_lo &= ~LPTE_PP; - pvo->pvo_pte.lpte.pte_lo &= ~LPTE_NOEXEC; - if ((prot & VM_PROT_EXECUTE) == 0) - pvo->pvo_pte.lpte.pte_lo |= LPTE_NOEXEC; - if (prot & VM_PROT_WRITE) - pvo->pvo_pte.lpte.pte_lo |= LPTE_BW; - else - pvo->pvo_pte.lpte.pte_lo |= LPTE_BR; - - pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN); + oldprot = pvo->pvo_pte.prot; + pvo->pvo_pte.prot = prot; + pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN); /* - * If the PVO is in the page table, update that pte as well. + * If the PVO is in the page table, update mapping */ - if (pt != -1) - MOEA64_PTE_CHANGE(mmu, pt, &pvo->pvo_pte.lpte, - pvo->pvo_vpn); + MOEA64_PTE_REPLACE(mmu, pvo, MOEA64_PTE_PROT_UPDATE); + if (pm != kernel_pmap && pg != NULL && !(pg->aflags & PGA_EXECUTABLE) && - (pvo->pvo_pte.lpte.pte_lo & (LPTE_I | LPTE_G | LPTE_NOEXEC)) == 0) { + (pvo->pvo_pte.pa & (LPTE_I | LPTE_G | LPTE_NOEXEC)) == 0) { if ((pg->oflags & VPO_UNMANAGED) == 0) vm_page_aflag_set(pg, PGA_EXECUTABLE); moea64_syncicache(mmu, pm, PVO_VADDR(pvo), - pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN, PAGE_SIZE); + pvo->pvo_pte.pa & LPTE_RPGN, PAGE_SIZE); } /* * Update vm about the REF/CHG bits if the page is managed and we have * removed write access. */ - if ((pvo->pvo_vaddr & PVO_MANAGED) == PVO_MANAGED && - (oldlo & LPTE_PP) != LPTE_BR && !(prot & VM_PROT_WRITE)) { - if (pg != NULL) { - if (pvo->pvo_pte.lpte.pte_lo & LPTE_CHG) - vm_page_dirty(pg); - if (pvo->pvo_pte.lpte.pte_lo & LPTE_REF) - vm_page_aflag_set(pg, PGA_REFERENCED); - } + if (pg != NULL && (pvo->pvo_vaddr & PVO_MANAGED) && + (oldprot & VM_PROT_WRITE) && !(prot & VM_PROT_WRITE)) { + refchg = atomic_readandclear_32(&pg->md.mdpg_attrs); + if (refchg & LPTE_CHG) + vm_page_dirty(pg); + if (refchg & LPTE_REF) + vm_page_aflag_set(pg, PGA_REFERENCED); } } @@ -1999,7 +1974,6 @@ moea64_protect(mmu_t mmu, pmap_t pm, vm_ return; } - LOCK_TABLE_RD(); PMAP_LOCK(pm); key.pvo_vaddr = sva; for (pvo = RB_NFIND(pvo_tree, &pm->pmap_pvo, &key); @@ -2007,7 +1981,6 @@ moea64_protect(mmu_t mmu, pmap_t pm, vm_ tpvo = RB_NEXT(pvo_tree, &pm->pmap_pvo, pvo); moea64_pvo_protect(mmu, pm, pvo, prot); } - UNLOCK_TABLE_RD(); PMAP_UNLOCK(pm); } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 05:36:17 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D58D9386; Tue, 17 Feb 2015 05:36:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0A4FC13; Tue, 17 Feb 2015 05:36:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H5aH7Q091192; Tue, 17 Feb 2015 05:36:17 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H5aHm4091191; Tue, 17 Feb 2015 05:36:17 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502170536.t1H5aHm4091191@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 17 Feb 2015 05:36:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278882 - user/nwhitehorn/ppc64-pmap-rework/pseries X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 05:36:17 -0000 Author: nwhitehorn Date: Tue Feb 17 05:36:16 2015 New Revision: 278882 URL: https://svnweb.freebsd.org/changeset/base/278882 Log: Enable use of H_PROTECT. This branch currently uses half the system time (and 65% the wall time) of HEAD to complete a make -j32 buildworld. Modified: user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Modified: user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Tue Feb 17 05:10:41 2015 (r278881) +++ user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Tue Feb 17 05:36:16 2015 (r278882) @@ -289,27 +289,27 @@ mphyp_pte_unset(mmu_t mmu, struct pvo_en static void mphyp_pte_replace(mmu_t mmu, struct pvo_entry *pvo, int flags) { - struct lpte evicted; + struct lpte pte; int64_t result; PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); - if (0 && flags == MOEA64_PTE_PROT_UPDATE) { - moea64_pte_from_pvo(pvo, &evicted); + if (flags == MOEA64_PTE_PROT_UPDATE) { + moea64_pte_from_pvo(pvo, &pte); result = phyp_hcall(H_PROTECT, - H_AVPN | (pvo->pvo_pte.pa & LPTE_PP), pvo->pvo_pte.slot, - evicted.pte_hi & LPTE_AVPN_MASK); + H_AVPN | (pte.pte_lo & (LPTE_PP | LPTE_NOEXEC)), + pvo->pvo_pte.slot, pte.pte_hi & LPTE_AVPN_MASK); if (result == H_NOT_FOUND) return; KASSERT(result == H_SUCCESS || result == H_NOT_FOUND, ("Error changing page protection: %d", (int)result)); - /* Mark RC changes */ - result = mphyp_pte_clear(mmu, pvo, LPTE_REF | LPTE_CHG); + /* Mark C changes (R zeroed by H_PROTECT) */ + result = mphyp_pte_clear(mmu, pvo, LPTE_CHG); if (result > 0) moea64_sync_refchg(pvo->pvo_pte.pa | - (result & (LPTE_REF | LPTE_CHG))); + (result & LPTE_CHG)); return; } From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 08:28:44 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6986E7F6; Tue, 17 Feb 2015 08:28:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 54A9EDCD; Tue, 17 Feb 2015 08:28:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H8Sik4071356; Tue, 17 Feb 2015 08:28:44 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H8SikS071355; Tue, 17 Feb 2015 08:28:44 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502170828.t1H8SikS071355@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 17 Feb 2015 08:28:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278884 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 08:28:44 -0000 Author: pho Date: Tue Feb 17 08:28:43 2015 New Revision: 278884 URL: https://svnweb.freebsd.org/changeset/base/278884 Log: Added more tests to list of tests not to run. Place log files / temporary files in directory with write access. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/all.sh Modified: user/pho/stress2/misc/all.sh ============================================================================== --- user/pho/stress2/misc/all.sh Tue Feb 17 07:52:50 2015 (r278883) +++ user/pho/stress2/misc/all.sh Tue Feb 17 08:28:43 2015 (r278884) @@ -41,17 +41,29 @@ # g_vfs_done():md6a[WRITE(offset=...)]error = 28 20111230 # dfull.sh umount stuck in "mount drain" 20111227 # ext2fs.sh Deadlock 20120510 +# ext2fs2.sh panic 20140716 +# fuse.sh Memory corruption seen in log file kostik734.txt 20141114 # fuse2.sh Deadlock seen 20121129 +# fuse3.sh Deadlock seen 20141120 # gbde.sh panic: handle_written_inodeblock: Invalid link count... 20131128 # gjournal.sh kmem_malloc(131072): kmem_map too small 20120626 -# gjournal2.sh +# gjournal2.sh # gjournal3.sh panic: Journal overflow 20130729 +# memguard.sh Waiting for fix commit +# memguard2.sh Waiting for fix commit +# memguard3.sh Waiting for fix commit +# mmap18.sh panic: vm_fault_copy_entry: main object missing page 20141015 +# mmap21.sh panic: vm_reserv_populate: reserv is already promoted 20141122 +# msdos5.sh Panic: Freeing unused sector ... 20141118 # newfs.sh Memory modified after free. ... used by inodedep 20111217 # newfs2.sh umount stuck in ufs 20111226 # nfs2.sh panic: wrong diroffset 20140219 +# nfs5.sh Deadlock panic 20141120 +# nfs6.sh Hang 20141012 # nfs9.sh panic: lockmgr still held 20130503 # nfs10.sh Deadlock 20130401 # nfs11.sh Deadlock 20130429 +# pfl3.sh panic: handle_written_inodeblock: live inodedep 20140812 # pmc.sh NMI ... going to debugger 20111217 # snap5-1.sh mksnap_ffs deadlock 20111218 # quota2.sh panic: dqflush: stray dquot 20120221 @@ -63,10 +75,13 @@ # snap5.sh mksnap_ffs stuck in getblk 20111224 # snap6.sh panic: softdep_deallocate_dependencies: unrecovered ... 20130630 # snap8.sh panic: softdep_deallocate_dependencies: unrecovered ... 20120630 +# suj9.sh page fault in softdep_count_dependencies+0x27 20141116 # suj11.sh panic: ufsdirhash_newblk: bad offset 20120118 +# suj13.sh general protection fault in bufdaemon 20141130 # suj18.sh panic: Bad tailq NEXT(0xc1e2a6088->tqh_last_s) != NULL 20120213 # suj30.sh panic: flush_pagedep_deps: MKDIR_PARENT 20121020 # suj34.sh Various hangs and panics 20131210 +# trim4.sh Page fault in softdep_count_dependencies+0x27 20140608 # umountf3.sh KDB: enter: watchdog timeout 20111217 # umountf7.sh panic: handle_written_inodeblock: live inodedep ... 20131129 # unionfs.sh insmntque: non-locked vp: xx is not exclusive locked... 20130909 @@ -77,6 +92,9 @@ # fuzz.sh A know issue # newfs3.sh OK, but runs for a very long time +# mmap10.sh OK, but runs for a long time +# mmap11.sh OK, but runs for a very long time +# mmap15.sh Rung for a very long time # statfs.sh Not very interesting # syscall.sh OK, but runs for a very long time # syscall2.sh OK, but runs for a very long time @@ -96,7 +114,9 @@ # suj27.sh # suj28.sh -# kevent8.sh Deadlock seen. 20131017 +# Exclude NFS loopback tests +# nfs13.sh +# nullfs8.sh # End of list @@ -106,19 +126,26 @@ [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +# Log files: +alllog=/tmp/stress2.all.log # Tests run +allfaillog=/tmp/stress2.all.fail.log # Tests that failed +alllast=/tmp/stress2.all.last # Last test run +alloutput=/tmp/stress2.all.output # Output from current test + args=`getopt acno $*` [ $? -ne 0 ] && echo "Usage $0 [-a] [-c] [-n] [tests]" && exit 1 set -- $args for i; do case "$i" in -a) all=1 # Run all tests + echo "Note: including known problem tests." shift ;; - -c) rm -f .all.last # Clear last know test + -c) rm -f $alllast # Clear last know test shift ;; -n) noshuffle=1 # Do not shuffle the list of tests - shift + shift # Resume test after last test ;; -o) once=1 # Only run once shift @@ -130,26 +157,31 @@ for i; do esac done -> .all.log -find . -maxdepth 1 -name .all.last -mtime +12h -delete -touch .all.last -chmod 555 .all.last .all.log +rm -f $alllog $allfaillog +find `dirname $alllast` -maxdepth 1 -name $alllast -mtime +12h -delete +touch $alllast $alllog +chmod 640 $alllast $alllog while true; do exclude=`sed -n '/^# Start of list/,/^# End of list/p' < $0 | - cat - all.exclude 2>/dev/null | + cat - all.exclude 2>/dev/null | grep "\.sh" | awk '{print $2}'` - list=`ls *.sh | egrep -v "all\.sh|cleanup\.sh"` + list=`echo *.sh` [ $# -ne 0 ] && list=$* + list=`echo $list | sed "s/all\.sh//; s/cleanup\.sh//"` if [ -n "$noshuffle" -a $# -eq 0 ]; then - last=`cat .all.last` + last=`cat $alllast` if [ -n "$last" ]; then - list=`echo "$list" | sed "1,/$last/d"` - echo "Resuming test at `echo "$list" | head -1`" + l=`echo "$list" | sed "s/.*$last//"` + [ -z "$l" ] && l=$list # start over + list=$l + echo "Resuming test at `echo "$list" | \ + awk '{print $1}'`" fi fi [ -n "$noshuffle" ] || - list=`echo $list | tr '\n' ' ' | ../tools/shuffle | tr ' ' '\n'` + list=`echo $list | tr '\n' ' ' | ../tools/shuffle | \ + tr ' ' '\n'` lst="" for i in $list; do @@ -158,17 +190,26 @@ while true; do done [ -z "$lst" ] && exit + . ../default.cfg n1=0 n2=`echo $lst | wc -w | sed 's/ //g'` for i in $lst; do n1=$((n1 + 1)) - echo $i > .all.last + echo $i > $alllast ./cleanup.sh - echo "`date '+%Y%m%d %T'` all: $i" | tee /dev/tty >> .all.log + echo "`date '+%Y%m%d %T'` all: $i" + echo "`date '+%Y%m%d %T'` all: $i" >> $alllog printf "`date '+%Y%m%d %T'` all ($n1/$n2): $i\r\n" > /dev/console logger "Starting test all: $i" sync;sync;sync - ./$i + start=`date '+%s'` + ./$i 2>&1 | tee $alloutput + grep -qw FAIL $alloutput && + echo "`date '+%Y%m%d %T'` $i" >> $allfaillog + rm -f $alloutput + [ $((`date '+%s'` - $start)) -gt 1830 ] && + printf "*** Excessive run time: %s %d min\r\n" $i, \ + $(((`date '+%s'` - $start) / 60))> /dev/console done [ -n "$once" ] && break done From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 08:38:05 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1608C99A; Tue, 17 Feb 2015 08:38:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 01CADEB8; Tue, 17 Feb 2015 08:38:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H8c42A076012; Tue, 17 Feb 2015 08:38:04 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H8c3U7076006; Tue, 17 Feb 2015 08:38:03 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502170838.t1H8c3U7076006@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 17 Feb 2015 08:38:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278885 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 08:38:05 -0000 Author: pho Date: Tue Feb 17 08:38:02 2015 New Revision: 278885 URL: https://svnweb.freebsd.org/changeset/base/278885 Log: Do not run the zfs tests on small memory hosts. Fix trailing whitespace. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/zfs.sh user/pho/stress2/misc/zfs2.sh user/pho/stress2/misc/zfs3.sh user/pho/stress2/misc/zfs4.sh user/pho/stress2/misc/zfs5.sh Modified: user/pho/stress2/misc/zfs.sh ============================================================================== --- user/pho/stress2/misc/zfs.sh Tue Feb 17 08:28:43 2015 (r278884) +++ user/pho/stress2/misc/zfs.sh Tue Feb 17 08:38:02 2015 (r278885) @@ -31,6 +31,7 @@ # Simple zfs raidz test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ $((`sysctl -n hw.usermem` / 1024 / 1024 / 1024)) -lt 3 ] && exit 0 . ../default.cfg @@ -53,7 +54,7 @@ zfs create tank/test export RUNDIR=/tank/test/stressX export runRUNTIME=20m -(cd ..; ./run.sh marcus.cfg) +(cd ..; ./run.sh marcus.cfg) zfs destroy -r tank zpool destroy tank Modified: user/pho/stress2/misc/zfs2.sh ============================================================================== --- user/pho/stress2/misc/zfs2.sh Tue Feb 17 08:28:43 2015 (r278884) +++ user/pho/stress2/misc/zfs2.sh Tue Feb 17 08:38:02 2015 (r278885) @@ -31,6 +31,7 @@ # Simple zfs mirror test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ $((`sysctl -n hw.usermem` / 1024 / 1024 / 1024)) -lt 3 ] && exit 0 . ../default.cfg @@ -55,7 +56,7 @@ zpool create tank mirror md$u1 md$u2 export RUNDIR=/tank/stressX export runRUNTIME=10m -(cd ..; ./run.sh marcus.cfg) +(cd ..; ./run.sh marcus.cfg) zfs destroy -r tank zpool destroy tank Modified: user/pho/stress2/misc/zfs3.sh ============================================================================== --- user/pho/stress2/misc/zfs3.sh Tue Feb 17 08:28:43 2015 (r278884) +++ user/pho/stress2/misc/zfs3.sh Tue Feb 17 08:38:02 2015 (r278885) @@ -33,6 +33,7 @@ # page fault from fs/zfs/dbuf.c:1807 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ $((`sysctl -n hw.usermem` / 1024 / 1024 / 1024)) -lt 3 ] && exit 0 . ../default.cfg @@ -60,7 +61,7 @@ zfs snapshot tank/test@snap1 export RUNDIR=/tank/test/stressX export runRUNTIME=10m -(cd ..; ./run.sh marcus.cfg) +(cd ..; ./run.sh marcus.cfg) zfs rollback tank/test@snap1 zfs destroy tank/test@snap1 Modified: user/pho/stress2/misc/zfs4.sh ============================================================================== --- user/pho/stress2/misc/zfs4.sh Tue Feb 17 08:28:43 2015 (r278884) +++ user/pho/stress2/misc/zfs4.sh Tue Feb 17 08:38:02 2015 (r278885) @@ -31,6 +31,7 @@ # Simple zfs snapshot test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ $((`sysctl -n hw.usermem` / 1024 / 1024 / 1024)) -lt 3 ] && exit 0 . ../default.cfg Modified: user/pho/stress2/misc/zfs5.sh ============================================================================== --- user/pho/stress2/misc/zfs5.sh Tue Feb 17 08:28:43 2015 (r278884) +++ user/pho/stress2/misc/zfs5.sh Tue Feb 17 08:38:02 2015 (r278885) @@ -31,6 +31,7 @@ # Simple zfs test of vdev as a file and snapshot clones [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ $((`sysctl -n hw.usermem` / 1024 / 1024 / 1024)) -lt 3 ] && exit 0 . ../default.cfg From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 08:42:27 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0D562E1F; Tue, 17 Feb 2015 08:42:27 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED69AF72; Tue, 17 Feb 2015 08:42:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H8gQiY080194; Tue, 17 Feb 2015 08:42:26 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H8gQtF080193; Tue, 17 Feb 2015 08:42:26 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502170842.t1H8gQtF080193@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 17 Feb 2015 08:42:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278887 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 08:42:27 -0000 Author: pho Date: Tue Feb 17 08:42:26 2015 New Revision: 278887 URL: https://svnweb.freebsd.org/changeset/base/278887 Log: Limit runtime, rename snapshot. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/altbufferflushes.sh Modified: user/pho/stress2/misc/altbufferflushes.sh ============================================================================== --- user/pho/stress2/misc/altbufferflushes.sh Tue Feb 17 08:40:27 2015 (r278886) +++ user/pho/stress2/misc/altbufferflushes.sh Tue Feb 17 08:42:26 2015 (r278887) @@ -79,13 +79,14 @@ persist () { diskfree=`df -k /var/tmp | tail -1 | awk '{print $4}'` [ $((diskfree / 1024 / 1024)) -lt 5 ] && echo "Not enough disk space" && exit 1 -rm -f /var/.snap/pho /var/tmp/big.? -trap "rm -f /var/.snap/pho /var/tmp/big.?" 0 -persist 'mksnap_ffs /var /var/.snap/pho' -sysctl vfs.dirtybufthresh=10 > /dev/null 2>&1 +rm -f /var/.snap/stress2 /var/tmp/big.? +trap "rm -f /var/.snap/stress2 /var/tmp/big.?" 0 +persist 'mksnap_ffs /var /var/.snap/stress2' +tresh=`sysctl vfs.dirtybufthresh | awk '{print $NF}'` +sysctl vfs.dirtybufthresh=10 cd /var/tmp -for j in `jot 10`; do +for j in `jot 5`; do old=`sysctl vfs.altbufferflushes | awk '{print $NF}'` for i in `jot 4`; do echo "`date '+%T'` Create big.$i" @@ -96,4 +97,5 @@ for j in `jot 10`; do new=`sysctl vfs.altbufferflushes | awk '{print $NF}'` [ $new -ne $old ] && echo "vfs.altbufferflushes changed from $old to $new." done -rm -f /var/.snap/pho +sysctl vfs.dirtybufthresh=$tresh +rm -f /var/.snap/stress2 From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 09:34:49 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6078C1C2; Tue, 17 Feb 2015 09:34:49 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 32ACD77D; Tue, 17 Feb 2015 09:34:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H9YnDn004295; Tue, 17 Feb 2015 09:34:49 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H9Ym8W004293; Tue, 17 Feb 2015 09:34:48 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502170934.t1H9Ym8W004293@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 17 Feb 2015 09:34:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278892 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 09:34:49 -0000 Author: pho Date: Tue Feb 17 09:34:48 2015 New Revision: 278892 URL: https://svnweb.freebsd.org/changeset/base/278892 Log: Change name of snapshot file. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/quota3.sh user/pho/stress2/misc/recursiveflushes.sh Modified: user/pho/stress2/misc/quota3.sh ============================================================================== --- user/pho/stress2/misc/quota3.sh Tue Feb 17 09:31:58 2015 (r278891) +++ user/pho/stress2/misc/quota3.sh Tue Feb 17 09:34:48 2015 (r278892) @@ -48,7 +48,7 @@ mount ${mntpoint} edquota -u -f $mntpoint -e $mntpoint:850000:900000:130000:140000 root quotacheck $mntpoint quotaon $mntpoint -mksnap_ffs $mntpoint $mntpoint/.snap/pho +mksnap_ffs $mntpoint $mntpoint/.snap/stress2 export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes (cd ..; ./run.sh disk.cfg) Modified: user/pho/stress2/misc/recursiveflushes.sh ============================================================================== --- user/pho/stress2/misc/recursiveflushes.sh Tue Feb 17 09:31:58 2015 (r278891) +++ user/pho/stress2/misc/recursiveflushes.sh Tue Feb 17 09:34:48 2015 (r278892) @@ -50,12 +50,12 @@ mount /dev/md${mdstart}$part $mntpoint old=`sysctl vfs.recursiveflushes | awk '{print $NF}'` cd $mntpoint -rm -f $mntpoint/.snap/pho.* -snap $mntpoint $mntpoint/.snap/pho.1 -snap $mntpoint $mntpoint/.snap/pho.2 -snap $mntpoint $mntpoint/.snap/pho.3 -snap $mntpoint $mntpoint/.snap/pho.4 -snap $mntpoint $mntpoint/.snap/pho.5 +rm -f $mntpoint/.snap/stress2.* +snap $mntpoint $mntpoint/.snap/stress2.1 +snap $mntpoint $mntpoint/.snap/stress2.2 +snap $mntpoint $mntpoint/.snap/stress2.3 +snap $mntpoint $mntpoint/.snap/stress2.4 +snap $mntpoint $mntpoint/.snap/stress2.5 for i in `jot 32`; do # Create 32 Mb files @@ -68,7 +68,7 @@ for i in `jot 32`; do rm -f big.$i done -rm -f $mntpoint/.snap/pho.* +rm -f $mntpoint/.snap/stress2.* new=`sysctl vfs.recursiveflushes | awk '{print $NF}'` [ $old != $new ] && echo "vfs.recursiveflushes changed from $old to $new" From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 09:40:38 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9B5C130A; Tue, 17 Feb 2015 09:40:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6D8B084F; Tue, 17 Feb 2015 09:40:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H9ec5n005101; Tue, 17 Feb 2015 09:40:38 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H9eboV005097; Tue, 17 Feb 2015 09:40:37 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502170940.t1H9eboV005097@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 17 Feb 2015 09:40:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278893 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 09:40:38 -0000 Author: pho Date: Tue Feb 17 09:40:36 2015 New Revision: 278893 URL: https://svnweb.freebsd.org/changeset/base/278893 Log: Fix whitespace, limit runtime and user $testuser. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/quota1.sh user/pho/stress2/misc/quota10.sh user/pho/stress2/misc/quota5.sh Modified: user/pho/stress2/misc/quota1.sh ============================================================================== --- user/pho/stress2/misc/quota1.sh Tue Feb 17 09:34:48 2015 (r278892) +++ user/pho/stress2/misc/quota1.sh Tue Feb 17 09:40:36 2015 (r278893) @@ -48,7 +48,7 @@ newfs $newfs_flags md${mdstart}$part > mount /dev/md${mdstart}$part $mntpoint export RUNDIR=${mntpoint}/stressX export runRUNTIME=10m # Run tests for 10 minutes -(cd ..; ./run.sh disk.cfg) +(cd ..; ./run.sh disk.cfg) while mount | grep -q $mntpoint; do umount $mntpoint > /dev/null 2>&1 || sleep 1 done Modified: user/pho/stress2/misc/quota10.sh ============================================================================== --- user/pho/stress2/misc/quota10.sh Tue Feb 17 09:34:48 2015 (r278892) +++ user/pho/stress2/misc/quota10.sh Tue Feb 17 09:40:36 2015 (r278893) @@ -88,7 +88,7 @@ else else # The test: Parallel mount and unmounts - for i in `jot 1024`; do + for i in `jot 1000`; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount $opt /dev/md${m}${part} ${mntpoint}$m Modified: user/pho/stress2/misc/quota5.sh ============================================================================== --- user/pho/stress2/misc/quota5.sh Tue Feb 17 09:34:48 2015 (r278892) +++ user/pho/stress2/misc/quota5.sh Tue Feb 17 09:40:36 2015 (r278893) @@ -30,15 +30,16 @@ [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +mount | grep -q "on /tmp (ufs," || exit 0 if ! grep /tmp /etc/fstab | grep -q quota ; then echo "/tmp must have quota enabled!" exit 2 -fi -edquota -u -f /tmp -e /tmp:1500000:1400000:200000:180000 pho -edquota -g -f /tmp -e /tmp:1500000:1400000:200000:180000 pho +fi +edquota -u -f /tmp -e /tmp:1500000:1400000:200000:180000 $testuser +edquota -g -f /tmp -e /tmp:1500000:1400000:200000:180000 $testuser quotaon /tmp -#su pho -c "export runRUNTIME=60m; cd /home/pho/stress2; ./run.sh disk.cfg" -su pho -c "export runRUNTIME=60m; cd ..; ./mkdir -t 1h -i 200 -v -v" +su $testuser -c "export runRUNTIME=60m; cd ../testcases/mkdir; \ + ./mkdir -t 30m -i 200 -v -v" quotaoff /tmp From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 14:33:53 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7243FD83; Tue, 17 Feb 2015 14:33:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5C9F8D3D; Tue, 17 Feb 2015 14:33:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HEXrnU047179; Tue, 17 Feb 2015 14:33:53 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HEXqYN047176; Tue, 17 Feb 2015 14:33:52 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502171433.t1HEXqYN047176@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 17 Feb 2015 14:33:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278897 - in user/nwhitehorn/ppc64-pmap-rework: aim include pseries X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 14:33:53 -0000 Author: nwhitehorn Date: Tue Feb 17 14:33:51 2015 New Revision: 278897 URL: https://svnweb.freebsd.org/changeset/base/278897 Log: H_PROTECT is somehow slower than unset + insert, so don't bother with the special case for it. Restore some statistics as well. Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c user/nwhitehorn/ppc64-pmap-rework/include/pmap.h user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Tue Feb 17 13:12:54 2015 (r278896) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Tue Feb 17 14:33:51 2015 (r278897) @@ -1254,6 +1254,7 @@ moea64_enter(mmu_t mmu, pmap_t pmap, vm_ free_pvo_entry(pvo); break; /* all done */ } + /* XXX: protection update */ } /* Otherwise, need to kill it first */ @@ -2241,6 +2242,8 @@ moea64_pvo_enter(mmu_t mmu, struct pvo_e panic("moea64_pvo_enter: overflow"); } + moea64_pvo_entries++; + if (pvo->pvo_pmap == kernel_pmap) isync(); Modified: user/nwhitehorn/ppc64-pmap-rework/include/pmap.h ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/include/pmap.h Tue Feb 17 13:12:54 2015 (r278896) +++ user/nwhitehorn/ppc64-pmap-rework/include/pmap.h Tue Feb 17 14:33:51 2015 (r278897) @@ -91,8 +91,10 @@ struct pvo_entry { #endif RB_ENTRY(pvo_entry) pvo_plink; /* Link to pmap entries */ struct { +#ifndef __powerpc64__ /* 32-bit fields */ struct pte pte; +#endif /* 64-bit fields */ uintptr_t slot; vm_paddr_t pa; Modified: user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Tue Feb 17 13:12:54 2015 (r278896) +++ user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Tue Feb 17 14:33:51 2015 (r278897) @@ -282,40 +282,23 @@ mphyp_pte_unset(mmu_t mmu, struct pvo_en ("Error removing page: %d", err)); if (err == H_SUCCESS) - moea64_sync_refchg(pvo->pvo_pte.pa | + moea64_sync_refchg((pvo->pvo_pte.pa & LPTE_RPGN) | (pte.pte_lo & (LPTE_REF | LPTE_CHG))); + + if (err == H_NOT_FOUND) + moea64_pte_overflow--; } static void mphyp_pte_replace(mmu_t mmu, struct pvo_entry *pvo, int flags) { - struct lpte pte; - int64_t result; PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); - if (flags == MOEA64_PTE_PROT_UPDATE) { - moea64_pte_from_pvo(pvo, &pte); - - result = phyp_hcall(H_PROTECT, - H_AVPN | (pte.pte_lo & (LPTE_PP | LPTE_NOEXEC)), - pvo->pvo_pte.slot, pte.pte_hi & LPTE_AVPN_MASK); - if (result == H_NOT_FOUND) - return; - KASSERT(result == H_SUCCESS || result == H_NOT_FOUND, - ("Error changing page protection: %d", (int)result)); - - /* Mark C changes (R zeroed by H_PROTECT) */ - result = mphyp_pte_clear(mmu, pvo, LPTE_CHG); - if (result > 0) - moea64_sync_refchg(pvo->pvo_pte.pa | - (result & LPTE_CHG)); - return; - } - /* * For anything other than a simple page protection update, we have to - * reinsert the page. + * reinsert the page. H_PROTECT is somehow slower than this, so just do + * unset followed by insert unconditionally. */ mphyp_pte_unset(mmu, pvo); mphyp_pte_insert(mmu, pvo); @@ -436,6 +419,7 @@ mphyp_pte_insert(mmu_t mmu, struct pvo_e result = phyp_pft_hcall(H_REMOVE, H_AVPN, index, evicted.pte_hi & LPTE_AVPN_MASK, 0, &junk, &lastptelo, &junk); + moea64_pte_overflow++; KASSERT(result == H_SUCCESS, ("Error evicting page: %d", (int)result)); From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 15:04:56 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9A3B0B61; Tue, 17 Feb 2015 15:04:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 84969D9; Tue, 17 Feb 2015 15:04:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HF4u3e061949; Tue, 17 Feb 2015 15:04:56 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HF4rAu061931; Tue, 17 Feb 2015 15:04:53 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502171504.t1HF4rAu061931@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 17 Feb 2015 15:04:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278903 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 15:04:56 -0000 Author: pho Date: Tue Feb 17 15:04:53 2015 New Revision: 278903 URL: https://svnweb.freebsd.org/changeset/base/278903 Log: Changed the name of the snapshot file, make two tests less verbose and add a new tests based on a bug report. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/snap9.sh (contents, props changed) Modified: user/pho/stress2/misc/snap.sh user/pho/stress2/misc/snap2-1.sh user/pho/stress2/misc/snap2.sh user/pho/stress2/misc/snap3.sh user/pho/stress2/misc/snap4.sh user/pho/stress2/misc/snap5-1.sh user/pho/stress2/misc/snap5.sh user/pho/stress2/misc/snap6.sh user/pho/stress2/misc/snap7.sh Modified: user/pho/stress2/misc/snap.sh ============================================================================== --- user/pho/stress2/misc/snap.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -32,25 +32,25 @@ . ../default.cfg -mount | grep -q "on /tmp " || exit 0 +mount | grep -q "on /tmp (ufs," || exit 0 mount | grep -q "/dev/md$mdstart on $mntpoint" && umount $mntpoint -rm -f /tmp/.snap/pho -trap "rm -f /tmp/.snap/pho" 0 +rm -f /tmp/.snap/stress2 +trap "rm -f /tmp/.snap/stress2" 0 for i in `jot 2`; do - mksnap_ffs /tmp /tmp/.snap/pho - mdconfig -a -t vnode -f /tmp/.snap/pho -u $mdstart -o readonly + mksnap_ffs /tmp /tmp/.snap/stress2 + mdconfig -a -t vnode -f /tmp/.snap/stress2 -u $mdstart -o readonly mount -r /dev/md$mdstart $mntpoint ls -l $mntpoint > /dev/null umount $mntpoint mdconfig -d -u $mdstart - rm -f /tmp/.snap/pho + rm -f /tmp/.snap/stress2 done for i in `jot 2`; do - mksnap_ffs /tmp /tmp/.snap/pho - rm -f /tmp/.snap/pho + mksnap_ffs /tmp /tmp/.snap/stress2 + rm -f /tmp/.snap/stress2 done Modified: user/pho/stress2/misc/snap2-1.sh ============================================================================== --- user/pho/stress2/misc/snap2-1.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap2-1.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -42,15 +42,15 @@ # --- trap 0xc, eip = 0xc060bcfb, esp = 0xe76728f8, ebp = 0xe767291c --- # g_io_request(c53ff7bc,c5051d40,d8c72408,c54ca110,e7672950) at g_io_request+0x5f -mount | grep -q "on /tmp " || exit 0 -rm -f /tmp/.snap/pho +mount | grep -q "on /tmp (ufs," || exit 0 +rm -f /tmp/.snap/stress2 [ -d /tmp/.snap ] || mkdir /tmp/.snap -trap "rm -f /tmp/.snap/pho" 0 +trap "rm -f /tmp/.snap/stress2" 0 mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart -mksnap_ffs /tmp /tmp/.snap/pho -mdconfig -a -t vnode -o readonly -f /tmp/.snap/pho -u $mdstart +mksnap_ffs /tmp /tmp/.snap/stress2 +mdconfig -a -t vnode -o readonly -f /tmp/.snap/stress2 -u $mdstart mount -o ro /dev/md$mdstart $mntpoint ls -lR $mntpoint > /dev/null 2>&1 & @@ -58,4 +58,4 @@ mdconfig -d -u $mdstart > /dev/null 2>&1 umount -f $mntpoint mdconfig -d -u $mdstart -rm -f /tmp/.snap/pho +rm -f /tmp/.snap/stress2 Modified: user/pho/stress2/misc/snap2.sh ============================================================================== --- user/pho/stress2/misc/snap2.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap2.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -42,14 +42,14 @@ . ../default.cfg -mount | grep -q "on /tmp " || exit 0 -rm -f /tmp/.snap/pho -trap "rm -f /tmp/.snap/pho" 0 +mount | grep -q "on /tmp (ufs," || exit 0 +rm -f /tmp/.snap/stress2 +trap "rm -f /tmp/.snap/stress2" 0 mount | grep "${mntpoint}" | grep -q md${mdstart} && umount -f ${mntpoint} mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} -mksnap_ffs /tmp /tmp/.snap/pho -mdconfig -a -t vnode -f /tmp/.snap/pho -u $mdstart -o readonly +mksnap_ffs /tmp /tmp/.snap/stress2 +mdconfig -a -t vnode -f /tmp/.snap/stress2 -u $mdstart -o readonly mount -r /dev/md${mdstart} ${mntpoint} ls -lR > /dev/null 2>&1 & @@ -58,4 +58,4 @@ mdconfig -d -u $mdstart > /dev/null 2>&1 umount ${mntpoint} > /dev/null 2>&1 umount -f ${mntpoint} > /dev/null 2>&1 mdconfig -d -u $mdstart -rm -f /tmp/.snap/pho +rm -f /tmp/.snap/stress2 Modified: user/pho/stress2/misc/snap3.sh ============================================================================== --- user/pho/stress2/misc/snap3.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap3.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -35,10 +35,10 @@ # Test with two snapshots # 20070506 Page fault in g_io_request+0x7f -mount | grep -q "on /tmp " || exit 0 -rm -f /tmp/.snap/pho.1 -rm -f /tmp/.snap/pho.2 -trap "rm -f /tmp/.snap/pho.?" 0 +mount | grep -q "on /tmp (ufs," || exit 0 +rm -f /tmp/.snap/stress2.1 +rm -f /tmp/.snap/stress2.2 +trap "rm -f /tmp/.snap/stress2.?" 0 mount | grep $mntpoint | grep -q md && umount $mntpoint m1=$mdstart m2=$((m1 + 1)) @@ -47,11 +47,11 @@ mdconfig -l | grep -q md$m2 && mdconfig start=`date '+%s'` while [ `date '+%s'` -lt $((start + 1800)) ]; do - mksnap_ffs /tmp /tmp/.snap/pho.1 - mksnap_ffs /tmp /tmp/.snap/pho.2 - if [ -r /tmp/.snap/pho.1 -a -r /tmp/.snap/pho.2 ]; then - mdconfig -a -t vnode -f /tmp/.snap/pho.1 -u $m1 -o readonly - mdconfig -a -t vnode -f /tmp/.snap/pho.2 -u $m2 -o readonly + mksnap_ffs /tmp /tmp/.snap/stress2.1 + mksnap_ffs /tmp /tmp/.snap/stress2.2 + if [ -r /tmp/.snap/stress2.1 -a -r /tmp/.snap/stress2.2 ]; then + mdconfig -a -t vnode -f /tmp/.snap/stress2.1 -u $m1 -o readonly + mdconfig -a -t vnode -f /tmp/.snap/stress2.2 -u $m2 -o readonly mount -o ro /dev/md$m1 $mntpoint sleep 3 @@ -60,5 +60,5 @@ while [ `date '+%s'` -lt $((start + 1800 mdconfig -d -u $m1 mdconfig -d -u $m2 fi - rm -f /tmp/.snap/pho.1 /tmp/.snap/pho.2 + rm -f /tmp/.snap/stress2.1 /tmp/.snap/stress2.2 done Modified: user/pho/stress2/misc/snap4.sh ============================================================================== --- user/pho/stress2/misc/snap4.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap4.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -34,23 +34,23 @@ . ../default.cfg -mount | grep -q "on /tmp " || exit 0 +mount | grep -q "on /tmp (ufs," || exit 0 mount | grep -q "/dev/md$mdstart on $mntpoint" && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart -rm -f /tmp/.snap/pho -trap "rm -f /tmp/.snap/pho" 0 +rm -f /tmp/.snap/stress2 +trap "rm -f /tmp/.snap/stress2" 0 start=`date '+%s'` while [ `date '+%s'` -lt $((start + 1800)) ]; do - mksnap_ffs /tmp /tmp/.snap/pho - mdconfig -a -t vnode -f /tmp/.snap/pho -u $mdstart -o readonly + mksnap_ffs /tmp /tmp/.snap/stress2 + mdconfig -a -t vnode -f /tmp/.snap/stress2 -u $mdstart -o readonly mount -o ro /dev/md$mdstart $mntpoint ls -l $mntpoint > /dev/null - rm -f /tmp/.snap/pho + rm -f /tmp/.snap/stress2 sleep 1 umount $mntpoint mdconfig -d -u $mdstart - rm -f /tmp/.snap/pho + rm -f /tmp/.snap/stress2 done Modified: user/pho/stress2/misc/snap5-1.sh ============================================================================== --- user/pho/stress2/misc/snap5-1.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap5-1.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -32,11 +32,11 @@ . ../default.cfg -mount | grep -q "on /tmp " || exit 0 +mount | grep -q "on /tmp (ufs," || exit 0 mnt2=${mntpoint}2 [ ! -d $mnt2 ] && mkdir $mnt2 -trap "rm -f /tmp/.snap/pho" 0 +trap "rm -f /tmp/.snap/stress2" 0 start=`date '+%s'` while [ `date '+%s'` -lt $((start + 1800)) ]; do if mount | grep -q "/dev/md$mdstart on $mnt2"; then @@ -45,15 +45,16 @@ while [ `date '+%s'` -lt $((start + 1800 if mdconfig -l | grep -q md$mdstart; then mdconfig -d -u $mdstart || exit 3 fi - rm -f /tmp/.snap/pho + rm -f /tmp/.snap/stress2 date '+%T' - mksnap_ffs /tmp /tmp/.snap/pho || continue - mdconfig -a -t vnode -f /tmp/.snap/pho -u $mdstart -o readonly || exit 4 + mksnap_ffs /tmp /tmp/.snap/stress2 || continue + mdconfig -a -t vnode -f /tmp/.snap/stress2 -u $mdstart -o readonly || + exit 4 mount -o ro /dev/md$mdstart $mnt2 || exit 5 ls -l $mnt2 > /dev/null - r=`head -c4 /dev/urandom | od -N2 -tu4 | sed -ne '1s/ *$//;1s/.* //p'` + r=`head -c4 /dev/random | od -N2 -tu4 | sed -ne '1s/ *$//;1s/.* //p'` sleep $(( r % 120 )) done mount | grep -q "/dev/md$mdstart on $mnt2" && umount $mnt2 Modified: user/pho/stress2/misc/snap5.sh ============================================================================== --- user/pho/stress2/misc/snap5.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap5.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -32,26 +32,26 @@ . ../default.cfg -mount | grep -q "on /tmp " || exit 0 +mount | grep -q "on /tmp (ufs," || exit 0 mnt2=${mntpoint}2 [ ! -d $mnt2 ] && mkdir $mnt2 mount | grep -q "/dev/md$mdstart on $mnt2" && umount $mnt2 mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart -rm -f /tmp/.snap/pho -trap "rm -f /tmp/.snap/pho" 0 +rm -f /tmp/.snap/stress2 +trap "rm -f /tmp/.snap/stress2" 0 start=`date '+%s'` while [ `date '+%s'` -lt $((start + 1800)) ]; do date '+%T' - mksnap_ffs /tmp /tmp/.snap/pho - mdconfig -a -t vnode -f /tmp/.snap/pho -u $mdstart -o readonly + mksnap_ffs /tmp /tmp/.snap/stress2 + mdconfig -a -t vnode -f /tmp/.snap/stress2 -u $mdstart -o readonly mount -o ro /dev/md$mdstart $mnt2 ls -l $mnt2 > /dev/null - r=`head -c4 /dev/urandom | od -N2 -tu4 | sed -ne '1s/ *$//;1s/.* //p'` + r=`head -c4 /dev/random | od -N2 -tu4 | sed -ne '1s/ *$//;1s/.* //p'` sleep $(( r % 120 )) umount $mnt2 mdconfig -d -u $mdstart - rm -f /tmp/.snap/pho + rm -f /tmp/.snap/stress2 done Modified: user/pho/stress2/misc/snap6.sh ============================================================================== --- user/pho/stress2/misc/snap6.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap6.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -25,21 +25,21 @@ root=/var -mount | grep -q "on /var " || exit 0 -rm -f $root/.snap/pho $root/big $root/big2 -trap "rm -f $root/.snap/pho $root/big $root/big2" 0 +mount | grep -q "on /var (ufs," || exit 0 +rm -f $root/.snap/stress2 $root/big $root/big2 +trap "rm -f $root/.snap/stress2 $root/big $root/big2" 0 free=`df $root | tail -1 | awk '{print $4}'` dd if=/dev/zero of=$root/big bs=1m count=$(( free / 1024 - 90)) > /dev/null 2>&1 df $root for i in `jot 1024`; do date - nice -20 mksnap_ffs $root $root/.snap/pho & + nice -20 mksnap_ffs $root $root/.snap/stress2 & dd if=/dev/zero of=$root/big2 bs=1m > /dev/null 2>&1 wait - [ -f $root/.snap/pho ] && exit 0 - rm -f $root/.snap/pho $root/big2 + [ -f $root/.snap/stress2 ] && exit 0 + rm -f $root/.snap/stress2 $root/big2 done df $root -rm -f $root/.snap/pho $root/big $root/big2 +rm -f $root/.snap/stress2 $root/big $root/big2 Modified: user/pho/stress2/misc/snap7.sh ============================================================================== --- user/pho/stress2/misc/snap7.sh Tue Feb 17 14:48:16 2015 (r278902) +++ user/pho/stress2/misc/snap7.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -35,23 +35,23 @@ # Test with unmount and paralless access to mountpoint # 20070508 page fault in g_io_request+0xa6 -mount | grep -q "on /tmp " || exit 0 +mount | grep -q "on /tmp (ufs," || exit 0 mount | grep -q "/dev/md$mdstart on $mntpoint" && umount $mntpoint -rm -f /tmp/.snap/pho.1 -trap "rm -f /tmp/.snap/pho.1" 0 +rm -f /tmp/.snap/stress2.1 +trap "rm -f /tmp/.snap/stress2.1" 0 mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart start=`date '+%s'` while [ `date '+%s'` -lt $((start + 1800)) ]; do - mksnap_ffs /tmp /tmp/.snap/pho.1 - mdconfig -a -t vnode -f /tmp/.snap/pho.1 -u $mdstart -o readonly + mksnap_ffs /tmp /tmp/.snap/stress2.1 + mdconfig -a -t vnode -f /tmp/.snap/stress2.1 -u $mdstart -o readonly sh -c "while true; do ls $mntpoint > /dev/null;done" & for i in `jot 64`; do - mount -o ro /dev/md$mdstart $mntpoint - umount $mntpoint + mount -o ro /dev/md$mdstart $mntpoint 2>/dev/null + umount $mntpoint 2>/dev/null done kill $! mdconfig -d -u $mdstart - rm -f /tmp/.snap/pho.1 + rm -f /tmp/.snap/stress2.1 done Added: user/pho/stress2/misc/snap9.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/snap9.sh Tue Feb 17 15:04:53 2015 (r278903) @@ -0,0 +1,70 @@ +#!/bin/sh + +# +# Copyright (c) 2013 Peter Holm +# 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$ +# + +# Disk full with one snapshot scenario +# "panic: softdep_deallocate_dependencies: unrecovered I/O error" seen. + +# kern/162362: ufs with snapshot(s) panics when getting full + + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +exit 0 # Waiting for fix. Still an issue @ 20150217 + +mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart + +mdconfig -a -t swap -s 2g -u $mdstart || exit 1 +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint + +dd if=/dev/zero of=$mntpoint/big1 bs=1m count=512 2>&1 | \ + egrep -v "records|transferred" +dd if=/dev/zero of=$mntpoint/big2 bs=1m count=512 2>&1 | \ + egrep -v "records|transferred" +dd if=/dev/zero of=$mntpoint/big3 bs=1m count=512 2>&1 | \ + egrep -v "records|transferred" + +mksnap_ffs $mntpoint $mntpoint/.snap/snap + +for i in `jot 10`; do + dd if=/dev/zero of=$mntpoint/big.$i bs=1m count=512 2>&1 | \ + egrep -v "records|transferred" || break +done +rm $mntpoint/big.* +rm -f $mntpoint/.snap/snap + +while mount | grep "$mntpoint" | grep -q md$mdstart; do + umount /mnt || sleep 1 +done +mdconfig -d -u $mdstart From owner-svn-src-user@FreeBSD.ORG Tue Feb 17 21:39:23 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 96A185A0; Tue, 17 Feb 2015 21:39:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 77712894; Tue, 17 Feb 2015 21:39:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HLdNeK051362; Tue, 17 Feb 2015 21:39:23 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HLdNTM051361; Tue, 17 Feb 2015 21:39:23 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502172139.t1HLdNTM051361@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 17 Feb 2015 21:39:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278923 - user/nwhitehorn/ppc64-pmap-rework/aim X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 17 Feb 2015 21:39:23 -0000 Author: nwhitehorn Date: Tue Feb 17 21:39:22 2015 New Revision: 278923 URL: https://svnweb.freebsd.org/changeset/base/278923 Log: Close race in pmap_remove_all() that could result in pmap_is_page_mapped() briefly returning true after the function returned. This was caused by pmap_remove_all() ignoring dead mappings in the middle of removal somewhere else. Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Tue Feb 17 21:18:17 2015 (r278922) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Tue Feb 17 21:39:22 2015 (r278923) @@ -116,14 +116,16 @@ uintptr_t moea64_get_unique_vsid(void); * */ -static struct mtx_padalign pv_lock[PA_LOCK_COUNT]; +#define PV_LOCK_COUNT PA_LOCK_COUNT*3 +static struct mtx_padalign pv_lock[PV_LOCK_COUNT]; -#define PV_LOCKPTR(pa) ((struct mtx *)(&pv_lock[pa_index(pa) % PA_LOCK_COUNT])) -#define PV_LOCK(pa) mtx_lock(PV_LOCKPTR(pa)) -#define PV_TRYLOCK(pa) mtx_trylock(PV_LOCKPTR(pa)) -#define PV_UNLOCK(pa) mtx_unlock(PV_LOCKPTR(pa)) -#define PV_PAGE_LOCK(m) PV_LOCK(VM_PAGE_TO_PHYS(m)) +#define PV_LOCKPTR(pa) ((struct mtx *)(&pv_lock[pa_index(pa) % PV_LOCK_COUNT])) +#define PV_LOCK(pa) mtx_lock(PV_LOCKPTR(pa)) +#define PV_UNLOCK(pa) mtx_unlock(PV_LOCKPTR(pa)) +#define PV_LOCKASSERT(pa) mtx_assert(PV_LOCKPTR(pa), MA_OWNED) +#define PV_PAGE_LOCK(m) PV_LOCK(VM_PAGE_TO_PHYS(m)) #define PV_PAGE_UNLOCK(m) PV_UNLOCK(VM_PAGE_TO_PHYS(m)) +#define PV_PAGE_LOCKASSERT(m) PV_LOCKASSERT(VM_PAGE_TO_PHYS(m)) struct ofw_map { cell_t om_va; @@ -215,7 +217,6 @@ int moea64_large_page_shift = 0; */ static int moea64_pvo_enter(mmu_t mmu, struct pvo_entry *pvo, struct pvo_head *pvo_head); -static void moea64_pvo_remove(mmu_t, struct pvo_entry *); static void moea64_pvo_remove_from_pmap(mmu_t mmu, struct pvo_entry *pvo); static void moea64_pvo_remove_from_page(mmu_t mmu, struct pvo_entry *pvo); static struct pvo_entry *moea64_pvo_find_va(pmap_t, vm_offset_t); @@ -797,7 +798,7 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offs * Initialize SLB table lock and page locks */ mtx_init(&moea64_slb_mutex, "SLB table", NULL, MTX_DEF); - for (i = 0; i < PA_LOCK_COUNT; i++) + for (i = 0; i < PV_LOCK_COUNT; i++) mtx_init(&pv_lock[i], "page pv", NULL, MTX_DEF); /* @@ -962,7 +963,7 @@ moea64_late_bootstrap(mmu_t mmup, vm_off /* * Allocate some things for page zeroing. We put this directly - * in the page table, marked with LPTE_LOCKED, to avoid any + * in the page table and use MOEA64_PTE_REPLACE to avoid * of the PVO book-keeping or other parts of the VM system * from even knowing that this hack exists. */ @@ -1020,8 +1021,8 @@ moea64_unwire(mmu_t mmu, pmap_t pm, vm_o { struct pvo_entry key, *pvo; - PMAP_LOCK(pm); key.pvo_vaddr = sva; + PMAP_LOCK(pm); for (pvo = RB_NFIND(pvo_tree, &pm->pmap_pvo, &key); pvo != NULL && PVO_VADDR(pvo) < eva; pvo = RB_NEXT(pvo_tree, &pm->pmap_pvo, pvo)) { @@ -1738,7 +1739,7 @@ moea64_map(mmu_t mmu, vm_offset_t *virt, if (hw_direct_map) { /* * Check if every page in the region is covered by the direct - * map. The direct map covers all of physical memory, so use + * map. The direct map covers all of physical memory. Use * moea64_calc_wimg() as a shortcut to see if the page is in * physical memory as a way to see if the direct map covers it. */ @@ -2133,6 +2134,7 @@ moea64_remove_all(mmu_t mmu, vm_page_t m { struct pvo_entry *pvo, *next_pvo; struct pvo_head freequeue; + int wasdead; pmap_t pmap; LIST_INIT(&freequeue); @@ -2141,11 +2143,14 @@ moea64_remove_all(mmu_t mmu, vm_page_t m LIST_FOREACH_SAFE(pvo, vm_page_to_pvoh(m), pvo_vlink, next_pvo) { pmap = pvo->pvo_pmap; PMAP_LOCK(pmap); - if (!(pvo->pvo_vaddr & PVO_DEAD)) { - moea64_pvo_remove(mmu, pvo); + wasdead = (pvo->pvo_vaddr & PVO_DEAD); + if (!wasdead) + moea64_pvo_remove_from_pmap(mmu, pvo); + moea64_pvo_remove_from_page(mmu, pvo); + if (!wasdead) LIST_INSERT_HEAD(&freequeue, pvo, pvo_vlink); - } PMAP_UNLOCK(pmap); + } if ((m->aflags & PGA_WRITEABLE) && (atomic_readandclear_32(&m->md.mdpg_attrs) & LPTE_CHG)) @@ -2153,6 +2158,7 @@ moea64_remove_all(mmu_t mmu, vm_page_t m vm_page_aflag_clear(m, PGA_WRITEABLE); vm_page_aflag_clear(m, PGA_EXECUTABLE); + KASSERT(!pmap_page_is_mapped(m), ("Page still has mappings")); PV_PAGE_UNLOCK(m); /* Clean up UMA allocations */ @@ -2264,6 +2270,7 @@ static void moea64_pvo_remove_from_pmap(mmu_t mmu, struct pvo_entry *pvo) { + KASSERT(pvo->pvo_pmap != NULL, ("Trying to remove PVO with no pmap")); PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); KASSERT(!(pvo->pvo_vaddr & PVO_DEAD), ("Trying to remove dead PVO")); @@ -2298,12 +2305,18 @@ moea64_pvo_remove_from_page(mmu_t mmu, s KASSERT(pvo->pvo_vaddr & PVO_DEAD, ("Trying to delink live page")); + /* Use NULL pmaps as a sentinel for races in page deletion */ + if (pvo->pvo_pmap == NULL) + return; + pvo->pvo_pmap = NULL; + /* * Update vm about page writeability/executability if managed */ pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN); + PV_PAGE_LOCKASSERT(pg); - if ((pvo->pvo_vaddr & PVO_MANAGED) == PVO_MANAGED && pg != NULL) { + if ((pvo->pvo_vaddr & PVO_MANAGED) && pg != NULL) { LIST_REMOVE(pvo, pvo_vlink); if (pvo->pvo_pte.prot & VM_PROT_WRITE) { /* If page is managed, send RC bits over the fence */ @@ -2323,14 +2336,6 @@ moea64_pvo_remove_from_page(mmu_t mmu, s moea64_pvo_remove_calls++; } -static void -moea64_pvo_remove(mmu_t mmu, struct pvo_entry *pvo) -{ - - moea64_pvo_remove_from_pmap(mmu, pvo); - moea64_pvo_remove_from_page(mmu, pvo); -} - static struct pvo_entry * moea64_pvo_find_va(pmap_t pm, vm_offset_t va) { From owner-svn-src-user@FreeBSD.ORG Wed Feb 18 05:20:53 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 889E11D0; Wed, 18 Feb 2015 05:20:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 63613CBF; Wed, 18 Feb 2015 05:20:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I5Kqca045838; Wed, 18 Feb 2015 05:20:52 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I5Kq0M045837; Wed, 18 Feb 2015 05:20:52 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502180520.t1I5Kq0M045837@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Wed, 18 Feb 2015 05:20:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278935 - user/nwhitehorn/ppc64-pmap-rework/aim X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 18 Feb 2015 05:20:53 -0000 Author: nwhitehorn Date: Wed Feb 18 05:20:52 2015 New Revision: 278935 URL: https://svnweb.freebsd.org/changeset/base/278935 Log: Optimize reinsertion after evictions and add in some miscellaneous paranoia. Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Wed Feb 18 03:54:54 2015 (r278934) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Wed Feb 18 05:20:52 2015 (r278935) @@ -1248,14 +1248,16 @@ moea64_enter(mmu_t mmu, pmap_t pmap, vm_ oldpvo->pvo_pte.prot == prot) { /* Identical mapping already exists */ error = 0; - if (MOEA64_PTE_SYNCH(mmu, oldpvo) >= 0) { - /* ... and present in page table */ - PV_PAGE_UNLOCK(m); - PMAP_UNLOCK(pmap); - free_pvo_entry(pvo); - break; /* all done */ - } - /* XXX: protection update */ + + /* If not in page table, reinsert it */ + if (MOEA64_PTE_SYNCH(mmu, oldpvo) < 0) + MOEA64_PTE_INSERT(mmu, oldpvo); + + /* Then just clean up and go home */ + PV_PAGE_UNLOCK(m); + PMAP_UNLOCK(pmap); + free_pvo_entry(pvo); + break; } /* Otherwise, need to kill it first */ @@ -1532,10 +1534,8 @@ moea64_is_prefaultable(mmu_t mmu, pmap_t PMAP_LOCK(pmap); pvo = moea64_pvo_find_va(pmap, va & ~ADDR_POFF); - if (pvo != NULL) { - if (MOEA64_PTE_SYNCH(mmu, pvo) >= 0) /* in page table? */ - rv = FALSE; - } + if (pvo != NULL) + rv = FALSE; PMAP_UNLOCK(pmap); return (rv); } @@ -2152,13 +2152,8 @@ moea64_remove_all(mmu_t mmu, vm_page_t m PMAP_UNLOCK(pmap); } - if ((m->aflags & PGA_WRITEABLE) && - (atomic_readandclear_32(&m->md.mdpg_attrs) & LPTE_CHG)) - vm_page_dirty(m); - - vm_page_aflag_clear(m, PGA_WRITEABLE); - vm_page_aflag_clear(m, PGA_EXECUTABLE); KASSERT(!pmap_page_is_mapped(m), ("Page still has mappings")); + KASSERT(!(m->aflags & PGA_WRITEABLE), ("Page still writable")); PV_PAGE_UNLOCK(m); /* Clean up UMA allocations */ @@ -2269,6 +2264,8 @@ moea64_pvo_enter(mmu_t mmu, struct pvo_e static void moea64_pvo_remove_from_pmap(mmu_t mmu, struct pvo_entry *pvo) { + struct vm_page *pg; + int32_t refchg; KASSERT(pvo->pvo_pmap != NULL, ("Trying to remove PVO with no pmap")); PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); @@ -2295,13 +2292,25 @@ moea64_pvo_remove_from_pmap(mmu_t mmu, s * Mark this for the next sweep */ pvo->pvo_vaddr |= PVO_DEAD; + + /* Send RC bits to VM */ + if ((pvo->pvo_vaddr & PVO_MANAGED) && + (pvo->pvo_pte.prot & VM_PROT_WRITE)) { + pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN); + if (pg != NULL) { + refchg = atomic_readandclear_32(&pg->md.mdpg_attrs); + if (refchg & LPTE_CHG) + vm_page_dirty(pg); + if (refchg & LPTE_REF) + vm_page_aflag_set(pg, PGA_REFERENCED); + } + } } static void moea64_pvo_remove_from_page(mmu_t mmu, struct pvo_entry *pvo) { struct vm_page *pg; - int32_t refchg; KASSERT(pvo->pvo_vaddr & PVO_DEAD, ("Trying to delink live page")); @@ -2313,23 +2322,13 @@ moea64_pvo_remove_from_page(mmu_t mmu, s /* * Update vm about page writeability/executability if managed */ + PV_LOCKASSERT(pvo->pvo_pte.pa & LPTE_RPGN); pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN); - PV_PAGE_LOCKASSERT(pg); if ((pvo->pvo_vaddr & PVO_MANAGED) && pg != NULL) { LIST_REMOVE(pvo, pvo_vlink); - if (pvo->pvo_pte.prot & VM_PROT_WRITE) { - /* If page is managed, send RC bits over the fence */ - refchg = atomic_readandclear_32(&pg->md.mdpg_attrs); - if (refchg & LPTE_CHG) - vm_page_dirty(pg); - if (refchg & LPTE_REF) - vm_page_aflag_set(pg, PGA_REFERENCED); - if (LIST_EMPTY(vm_page_to_pvoh(pg))) - vm_page_aflag_clear(pg, PGA_WRITEABLE); - } if (LIST_EMPTY(vm_page_to_pvoh(pg))) - vm_page_aflag_clear(pg, PGA_EXECUTABLE); + vm_page_aflag_clear(pg, PGA_WRITEABLE | PGA_EXECUTABLE); } moea64_pvo_entries--; @@ -2423,7 +2422,7 @@ moea64_clear_bit(mmu_t mmu, vm_page_t m, if (ret > 0 && (ret & ptebit)) count++; } - atomic_clear_32(&m->md.mdpg_attrs, LPTE_REF | LPTE_CHG); + atomic_clear_32(&m->md.mdpg_attrs, ptebit); PV_PAGE_UNLOCK(m); return (count); From owner-svn-src-user@FreeBSD.ORG Wed Feb 18 06:55:12 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CAC6A884; Wed, 18 Feb 2015 06:55:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B515288C; Wed, 18 Feb 2015 06:55:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I6tCGF091999; Wed, 18 Feb 2015 06:55:12 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I6tCwX091997; Wed, 18 Feb 2015 06:55:12 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502180655.t1I6tCwX091997@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Wed, 18 Feb 2015 06:55:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278944 - in user/nwhitehorn/ppc64-pmap-rework: conf pseries X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 18 Feb 2015 06:55:13 -0000 Author: nwhitehorn Date: Wed Feb 18 06:55:11 2015 New Revision: 278944 URL: https://svnweb.freebsd.org/changeset/base/278944 Log: Work around a bug in Linux KVM: the ability to unset referenced and changed bits in the page table doesn't exist despite these hypervisor calls being mandatory. To "fix" this, when asked to clear the bits, don't clear them and don't return the reference bit. This makes swap work at the expense of performance. It also results in pmap_ts_referenced() sometimes returning zero when the page has in fact been referenced. It is not clear to me whether this creates a problem beyond performance. In addition to adding a large warning banner if this issue is detected, I've sent a bug report to the PowerPC KVM list. Modified: user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Modified: user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 Wed Feb 18 06:53:40 2015 (r278943) +++ user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 Wed Feb 18 06:55:11 2015 (r278944) @@ -28,7 +28,7 @@ makeoptions WITH_CTF=1 # Platform support options POWERMAC #NewWorld Apple PowerMacs -options PS3 #Sony Playstation 3 +#options PS3 #Sony Playstation 3 options MAMBO #IBM Mambo Full System Simulator options PSERIES #PAPR-compliant systems (e.g. IBM p) Modified: user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Wed Feb 18 06:53:40 2015 (r278943) +++ user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Wed Feb 18 06:55:11 2015 (r278944) @@ -91,6 +91,23 @@ static mmu_method_t mphyp_methods[] = { MMU_DEF_INHERIT(pseries_mmu, "mmu_phyp", mphyp_methods, 0, oea64_mmu); +static int brokenkvm = 0; + +static void +print_kvm_bug_warning(void *data) +{ + + if (brokenkvm) + printf("WARNING: Running on a broken hypervisor that does " + "not support mandatory H_CLEAR_MOD and H_CLEAR_REF " + "hypercalls. Performance will be suboptimal.\n"); +} + +SYSINIT(kvmbugwarn1, SI_SUB_COPYRIGHT, SI_ORDER_THIRD + 1, + print_kvm_bug_warning, NULL); +SYSINIT(kvmbugwarn2, SI_SUB_LAST, SI_ORDER_THIRD + 1, print_kvm_bug_warning, + NULL); + static void mphyp_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) { @@ -183,6 +200,10 @@ mphyp_bootstrap(mmu_t mmup, vm_offset_t moea64_mid_bootstrap(mmup, kernelstart, kernelend); moea64_late_bootstrap(mmup, kernelstart, kernelend); + + /* Test for broken versions of KVM that don't conform to the spec */ + if (phyp_hcall(H_CLEAR_MOD, 0, 0) == H_FUNCTION) + brokenkvm = 1; } static void @@ -231,6 +252,7 @@ mphyp_pte_clear(mmu_t mmu, struct pvo_en { int64_t refchg; uint64_t ptelo, junk; + int err; /* * This involves two steps (synch and clear) so we need the entry @@ -248,14 +270,28 @@ mphyp_pte_clear(mmu_t mmu, struct pvo_en return (refchg); } + if (brokenkvm) { + /* + * No way to clear either bit, which is total madness. + * Pessimistically claim that, once modified, it stays so + * forever and that it is never referenced. + */ + rw_runlock(&mphyp_eviction_lock); + return (refchg & ~LPTE_REF); + } + if (ptebit & LPTE_CHG) { - phyp_pft_hcall(H_CLEAR_MOD, 0, pvo->pvo_pte.slot, 0, 0, &ptelo, - &junk, &junk); + err = phyp_pft_hcall(H_CLEAR_MOD, 0, pvo->pvo_pte.slot, 0, 0, + &ptelo, &junk, &junk); + KASSERT(err == H_SUCCESS, + ("Error clearing page change bit: %d", err)); refchg |= (ptelo & LPTE_CHG); } if (ptebit & LPTE_REF) { - phyp_pft_hcall(H_CLEAR_REF, 0, pvo->pvo_pte.slot, 0, 0, &ptelo, - &junk, &junk); + err = phyp_pft_hcall(H_CLEAR_REF, 0, pvo->pvo_pte.slot, 0, 0, + &ptelo, &junk, &junk); + KASSERT(err == H_SUCCESS, + ("Error clearing page reference bit: %d", err)); refchg |= (ptelo & LPTE_REF); } From owner-svn-src-user@FreeBSD.ORG Wed Feb 18 09:00:11 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7A4E3BB1; Wed, 18 Feb 2015 09:00:11 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 65B9778E; Wed, 18 Feb 2015 09:00:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I90BGD050037; Wed, 18 Feb 2015 09:00:11 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I90Ag3050034; Wed, 18 Feb 2015 09:00:10 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502180900.t1I90Ag3050034@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Wed, 18 Feb 2015 09:00:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278952 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 18 Feb 2015 09:00:11 -0000 Author: pho Date: Wed Feb 18 09:00:10 2015 New Revision: 278952 URL: https://svnweb.freebsd.org/changeset/base/278952 Log: Move the "no run" action to all.sh Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/all.sh user/pho/stress2/misc/snap9.sh Modified: user/pho/stress2/misc/all.sh ============================================================================== --- user/pho/stress2/misc/all.sh Wed Feb 18 08:24:00 2015 (r278951) +++ user/pho/stress2/misc/all.sh Wed Feb 18 09:00:10 2015 (r278952) @@ -75,6 +75,7 @@ # snap5.sh mksnap_ffs stuck in getblk 20111224 # snap6.sh panic: softdep_deallocate_dependencies: unrecovered ... 20130630 # snap8.sh panic: softdep_deallocate_dependencies: unrecovered ... 20120630 +# snap9.sh panic: softdep_deallocate_dependencies: unrecovered ... 20150217 # suj9.sh page fault in softdep_count_dependencies+0x27 20141116 # suj11.sh panic: ufsdirhash_newblk: bad offset 20120118 # suj13.sh general protection fault in bufdaemon 20141130 Modified: user/pho/stress2/misc/snap9.sh ============================================================================== --- user/pho/stress2/misc/snap9.sh Wed Feb 18 08:24:00 2015 (r278951) +++ user/pho/stress2/misc/snap9.sh Wed Feb 18 09:00:10 2015 (r278952) @@ -38,8 +38,6 @@ . ../default.cfg -exit 0 # Waiting for fix. Still an issue @ 20150217 - mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart From owner-svn-src-user@FreeBSD.ORG Wed Feb 18 09:02:59 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7E966CD4; Wed, 18 Feb 2015 09:02:59 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 689EF83D; Wed, 18 Feb 2015 09:02:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I92xi8053201; Wed, 18 Feb 2015 09:02:59 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I92x3s053194; Wed, 18 Feb 2015 09:02:59 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502180902.t1I92x3s053194@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Wed, 18 Feb 2015 09:02:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278953 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 18 Feb 2015 09:02:59 -0000 Author: pho Date: Wed Feb 18 09:02:58 2015 New Revision: 278953 URL: https://svnweb.freebsd.org/changeset/base/278953 Log: Added two tests using pthread_mutexattr_setprotocol(..., PTHREAD_PRIO_INHERIT). Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/pthread7.sh (contents, props changed) user/pho/stress2/misc/pthread8.sh (contents, props changed) Added: user/pho/stress2/misc/pthread7.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/pthread7.sh Wed Feb 18 09:02:58 2015 (r278953) @@ -0,0 +1,287 @@ +#!/bin/sh + +# +# Copyright (c) 2015 EMC Corp. +# 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$ +# + +# PTHREAD_PRIO_INHERIT version of pthread2.sh + +. ../default.cfg + +export LANG=C +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > pthread7.c +mycc -o pthread7 -Wall -Wextra -O2 -g -gdwarf-2 pthread7.c -lpthread || exit 1 +rm -f pthread7.c + +for i in `jot 5`; do + for i in `jot 8`; do + /tmp/pthread7 & + done + wait +done +rm -f /tmp/pthread7 +exit 0 +EOF +/* + * Threaded producer-consumer test. + * Loosly based on work by + * Andrey Zonov (c) 2012 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __FreeBSD__ +#include +#define __NP__ +#endif +#include +#include +#include +#include +#include +#include +#include + +#define LOCK(x) plock(&x.mtx) +#define UNLOCK(x) punlock(&x.mtx) +#define SIGNAL(x) psig(&x.wait) +#define WAIT(x) pwait(&x.wait, &x.mtx) + +long ncreate, nrename, nunlink; +int bench, max; +char *dirname1; +char *dirname2; + +struct file { + char *name; + STAILQ_ENTRY(file) next; +}; + +struct files { + pthread_mutex_t mtx; + pthread_cond_t wait; + STAILQ_HEAD(, file) list; +}; + +static struct files newfiles; +static struct files renamedfiles; + + +static void +hand(int i __unused) { /* handler */ + fprintf(stderr, "max = %d, ncreate = %ld, nrename = %ld, nunlink = %ld\n", + max, ncreate, nrename, nunlink); +} + +static void +ahand(int i __unused) { /* handler */ + fprintf(stderr, "FAIL\n"); + hand(0); + _exit(0); +} + +void +plock(pthread_mutex_t *l) +{ + int rc; + + if ((rc = pthread_mutex_lock(l)) != 0) + errc(1, rc, "pthread_mutex_lock"); +} + +void +punlock(pthread_mutex_t *l) +{ + int rc; + + if ((rc = pthread_mutex_unlock(l)) != 0) + errc(1, rc, "pthread_mutex_unlock"); +} + +void +psig(pthread_cond_t *c) +{ + int rc; + + if ((rc = pthread_cond_signal(c)) != 0) + errc(1, rc, "pthread_cond_signal"); +} + +void +pwait(pthread_cond_t *c, pthread_mutex_t *l) +{ + int rc; + + if ((rc = pthread_cond_wait(c, l)) != 0) + errc(1, rc, "pthread_cond_wait"); +} + +void * +loop_create(void *arg __unused) +{ + int i, j; + struct file *file; + +#ifdef __NP__ + pthread_set_name_np(pthread_self(), __func__); +#endif + + for (i = 0; i < max; i++) { + file = malloc(sizeof(*file)); + asprintf(&file->name, "%s/filename_too-long:%d", dirname1, i); + LOCK(newfiles); + STAILQ_INSERT_TAIL(&newfiles.list, file, next); + ncreate++; + UNLOCK(newfiles); + SIGNAL(newfiles); + if ((bench == 0) && (i > 0) && (i % 100000 == 0)) + for (j = 0; j < 10 && ncreate != nrename; j++) + usleep(400); + } + return (NULL); +} + +void * +loop_rename(void *arg __unused) +{ + char *filename, *newname; + struct file *file; + +#ifdef __NP__ + pthread_set_name_np(pthread_self(), __func__); +#endif + + while (nrename < max) { + LOCK(newfiles); + while (STAILQ_EMPTY(&newfiles.list)) { + WAIT(newfiles); + } + file = STAILQ_FIRST(&newfiles.list); + STAILQ_REMOVE_HEAD(&newfiles.list, next); + UNLOCK(newfiles); + filename = strrchr(file->name, '/'); + asprintf(&newname, "%s/%s", dirname2, filename); + nrename++; + free(file->name); + file->name = newname; + LOCK(renamedfiles); + STAILQ_INSERT_TAIL(&renamedfiles.list, file, next); + UNLOCK(renamedfiles); + SIGNAL(renamedfiles); + } + return (NULL); +} + +void * +loop_unlink(void *arg __unused) +{ + struct file *file; + +#ifdef __NP__ + pthread_set_name_np(pthread_self(), __func__); +#endif + + while (nunlink < max) { + LOCK(renamedfiles); + while (STAILQ_EMPTY(&renamedfiles.list)) { + WAIT(renamedfiles); + } + file = STAILQ_FIRST(&renamedfiles.list); + STAILQ_REMOVE_HEAD(&renamedfiles.list, next); + nunlink++; + UNLOCK(renamedfiles); + free(file->name); + free(file); + } + return (NULL); +} + +int +main(void) +{ + int i; + int rc; + pthread_t tid[3]; + pthread_mutexattr_t attr, *pattr = NULL; + + bench = getenv("bench") != NULL; + asprintf(&dirname1, "%s.1", "f1"); + asprintf(&dirname2, "%s.2", "f2"); + max = 15000000; + + STAILQ_INIT(&newfiles.list); + STAILQ_INIT(&renamedfiles.list); + + pthread_mutexattr_init (&attr); + if ((rc = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) != 0) + errc(1, rc, "PTHREAD_PRIO_INHERIT"); + pattr = &attr; + if ((rc = pthread_mutex_init(&newfiles.mtx, pattr)) != 0) + errc(1, rc, "pthread_mutex_init()"); + if ((rc = pthread_cond_init(&newfiles.wait, NULL)) != 0) + errc(1, rc, "pthread_cond_init()"); + if ((rc = pthread_mutex_init(&renamedfiles.mtx, NULL)) != 0) + errc(1, rc, "pthread_mutex_init()"); + if ((rc = pthread_cond_init(&renamedfiles.wait, NULL)) != 0) + errc(1, rc, "pthread_cond_init()"); + + signal(SIGINFO, hand); + signal(SIGALRM, ahand); + alarm(300); + if ((rc = pthread_create(&tid[0], NULL, loop_create, NULL)) != 0) + errc(1, rc, "pthread_create()"); + if ((rc = pthread_create(&tid[1], NULL, loop_rename, NULL)) != 0) + errc(1, rc, "pthread_create()"); + if ((rc = pthread_create(&tid[2], NULL, loop_unlink, NULL)) != 0) + errc(1, rc, "pthread_create()"); + + for (i = 0; i < 3; i++) { + if ((rc = pthread_join(tid[i], NULL)) != 0) + errc(1, rc, "pthread_join(%d)", i); + } + + if ((rc = pthread_mutex_destroy(&newfiles.mtx)) != 0) + errc(1, rc, "pthread_mutex_destroy(newfiles)"); + if ((rc = pthread_cond_destroy(&newfiles.wait)) != 0) + errc(1, rc, "pthread_cond_destroy(newfiles)"); + if ((rc = pthread_mutex_destroy(&renamedfiles.mtx)) != 0) + errc(1, rc, "pthread_mutex_destroy(renamedfiles)"); + if ((rc = pthread_cond_destroy(&renamedfiles.wait)) != 0) + errc(1, rc, "pthread_cond_destroy(renamedfiles)"); + free(dirname1); + free(dirname2); + + return (0); +} Added: user/pho/stress2/misc/pthread8.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/pthread8.sh Wed Feb 18 09:02:58 2015 (r278953) @@ -0,0 +1,139 @@ +#!/bin/sh + +# +# Copyright (c) 2015 EMC Corp. +# 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$ +# + +# PTHREAD_PRIO_INHERIT test scenario + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > pthread8.c +mycc -o pthread8 -Wall -Wextra -O0 -g pthread8.c -lpthread || exit 1 +#rm -f pthread8.c /tmp/pthread8.core + +/tmp/pthread8 + +#rm -f /tmp/pthread8 +exit 0 +EOF +/* $Id: pi.c,v 1.2 2015/01/31 11:36:07 kostik Exp kostik $ */ + +#include +#include +#include +#include +#include +#include +#include + +struct runner_arg { + pthread_mutex_t *locks; + u_int lock_cnt; +}; + +int stop; + +void * +runner(void *arg) +{ + struct runner_arg *ra; + pthread_mutex_t *l; + u_int i; + int error; + + ra = arg; + while (stop == 0) { + for (i = 0; i < ra->lock_cnt; i++) { + l = &ra->locks[i]; + error = pthread_mutex_lock(l); + if (error != 0) + errc(1, error, "pthread_mutex_lock"); + pthread_yield(); + } + for (i = 0; i < ra->lock_cnt; i++) { + l = &ra->locks[i]; + error = pthread_mutex_unlock(l); + if (error != 0) + errc(1, error, "pthread_mutex_lock"); + pthread_yield(); + } + } + return (NULL); +} + +int +main(void) +{ + struct runner_arg ra; + time_t start; + pthread_t *threads; + pthread_mutexattr_t mattr; + u_int i, ncpus; + int error; + size_t ncpus_len; + + ncpus_len = sizeof(ncpus); + error = sysctlbyname("hw.ncpu", &ncpus, &ncpus_len, NULL, 0); + if (error != 0) + err(1, "sysctl hw.ncpus"); + threads = calloc(ncpus, sizeof(pthread_t)); + if (threads == NULL) + err(1, "calloc threads"); + + ra.lock_cnt = 100; + ra.locks = calloc(ra.lock_cnt, sizeof(pthread_mutex_t)); + if (ra.locks == NULL) + err(1, "calloc locks"); + error = pthread_mutexattr_init(&mattr); + if (error != 0) + errc(1, error, "pthread_mutexattr_init"); + error = pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT); + if (error != 0) + errc(1, error, "pthread_mutexattr_setprotocol PRIO_INHERIT"); + for (i = 0; i < ra.lock_cnt; i++) { + error = pthread_mutex_init(&ra.locks[i], &mattr); + if (error != 0) + errc(1, error, "pthread_mutex_init"); + } + + for (i = 0; i < ncpus; i++) { + error = pthread_create(&threads[i], NULL, runner, &ra); + if (error != 0) + errc(1, error, "pthread_create"); + } + start = time(NULL); + while (time(NULL) - start < 180) + sleep(1); + stop = 1; + for (i = 0; i < ncpus; i++) + pthread_join(threads[i], NULL); + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Wed Feb 18 13:07:28 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B71738EB; Wed, 18 Feb 2015 13:07:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A0DA46A5; Wed, 18 Feb 2015 13:07:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1ID7STf065380; Wed, 18 Feb 2015 13:07:28 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1ID7R4l065368; Wed, 18 Feb 2015 13:07:27 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502181307.t1ID7R4l065368@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Wed, 18 Feb 2015 13:07:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278955 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 18 Feb 2015 13:07:28 -0000 Author: pho Date: Wed Feb 18 13:07:26 2015 New Revision: 278955 URL: https://svnweb.freebsd.org/changeset/base/278955 Log: Added more mmap(2)/mlock(2) test scenarios. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/mmap14.sh (contents, props changed) user/pho/stress2/misc/mmap15.sh (contents, props changed) user/pho/stress2/misc/mmap16.sh (contents, props changed) user/pho/stress2/misc/mmap17.sh (contents, props changed) user/pho/stress2/misc/mmap18.sh (contents, props changed) user/pho/stress2/misc/mmap20.sh (contents, props changed) user/pho/stress2/misc/mmap21.sh (contents, props changed) user/pho/stress2/misc/mmap22.sh (contents, props changed) Added: user/pho/stress2/misc/mmap14.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mmap14.sh Wed Feb 18 13:07:26 2015 (r278955) @@ -0,0 +1,222 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +# Simplified version of mmap10.sh with focus on core dumps +# Deadlock seen: +# http://people.freebsd.org/~pho/stress/log/kostik673.txt +# No issues seen with r272060. + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mmap14.c +mycc -o mmap14 -Wall -Wextra -O2 -g mmap14.c -lpthread || exit 1 +rm -f mmap14.c + +daemon sh -c "(cd $here/../testcases/swap; ./swap -t 2m -i 20 -k -h)" +rnd=`od -An -N1 -t u1 /dev/random | sed 's/ //g'` +sleep $((rnd % 10)) +for i in `jot 2`; do + /tmp/mmap14 +done +killall -q swap + +rm -f /tmp/mmap14 /tmp/mmap14.core +exit 0 +EOF +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOOPS 2 +#define N (128 * 1024 / (int)sizeof(u_int32_t)) +#define PARALLEL 50 + +void *p; +u_int32_t r[N]; + +unsigned long +makearg(void) +{ + unsigned long val; + unsigned int i; + + val = arc4random(); + i = arc4random() % 100; + if (i < 20) + val = val & 0xff; + if (i >= 20 && i < 40) + val = val & 0xffff; + if (i >= 40 && i < 60) + val = (unsigned long)(r) | (val & 0xffff); +#if defined(__LP64__) + if (i >= 60) { + val = (val << 32) | arc4random(); + if (i > 80) + val = val & 0x00007fffffffffffUL; + } +#endif + + return(val); +} + +void * +makeptr(void) +{ + unsigned long val; + + if (p != MAP_FAILED && p != NULL) + val = (unsigned long)p + arc4random(); + else + val = makearg(); + val = trunc_page(val); + + return ((void *)val); +} + +void * +tmmap(void *arg __unused) +{ + size_t len; + int i, fd; + + pthread_set_name_np(pthread_self(), __func__); + len = 1LL * 1024 * 1024 * 1024; + + for (i = 0; i < 100; i++) { + if ((fd = open("/dev/zero", O_RDWR)) == -1) + err(1,"open()"); + + if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, + 0)) != MAP_FAILED) { + usleep(100); + munmap(p, len); + } + + if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0)) != + MAP_FAILED) { + usleep(100); + munmap(p, len); + } + close(fd); + } + + return (NULL); +} + +void * +tmlock(void *arg __unused) +{ + size_t len; + int i, n; + + pthread_set_name_np(pthread_self(), __func__); + n = 0; + for (i = 0; i < 200; i++) { + len = trunc_page(makearg()); + if (mlock(makeptr(), len) == 0) + n++; + len = trunc_page(makearg()); + if (arc4random() % 100 < 50) + if (munlock(makeptr(), len) == 0) + n++; + } + if (n < 10) + fprintf(stderr, "Note: tmlock() only succeeded %d times.\n", + n); + + return (NULL); +} + +void +test(void) +{ + pthread_t tid[4]; + int i, rc; + + if ((rc = pthread_create(&tid[0], NULL, tmmap, NULL)) != 0) + errc(1, rc, "tmmap()"); + if ((rc = pthread_create(&tid[1], NULL, tmlock, NULL)) != 0) + errc(1, rc, "tmlock()"); + + for (i = 0; i < 100; i++) { + if (fork() == 0) { + usleep(10000); + _exit(0); + } + wait(NULL); + } + + raise(SIGSEGV); + + for (i = 0; i < 2; i++) + if ((rc = pthread_join(tid[i], NULL)) != 0) + errc(1, rc, "pthread_join(%d)", i); + _exit(0); +} + +int +main(void) +{ + int i, j; + + for (i = 0; i < N; i++) + r[i] = arc4random(); + + for (i = 0; i < LOOPS; i++) { + for (j = 0; j < PARALLEL; j++) { + if (fork() == 0) + test(); + } + + for (j = 0; j < PARALLEL; j++) + wait(NULL); + } + + return (0); +} Added: user/pho/stress2/misc/mmap15.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mmap15.sh Wed Feb 18 13:07:26 2015 (r278955) @@ -0,0 +1,213 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +# Missing wakeup in the bufobj_wwait(). + +# Snapshot of WiP work. +# http://people.freebsd.org/~pho/stress/log/mmap15.txt +# Not fixed + +# panic: invalid size +# http://people.freebsd.org/~pho/stress/log/kostik738.txt +# Fixed in r274878 + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mmap15.c +mycc -o mmap15 -Wall -Wextra -O2 -g mmap15.c -lpthread || exit 1 +rm -f mmap15.c + +for i in `jot 2`; do + su $testuser -c /tmp/mmap15 +done + +rm -f /tmp/mmap15 /tmp/mmap15.core +exit 0 +EOF +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOOPS 2 +#define N (128 * 1024 / (int)sizeof(u_int32_t)) +#define PARALLEL 50 + +void *p; +u_int32_t r[N]; + +unsigned long +makearg(void) +{ + unsigned long val; + unsigned int i; + + val = arc4random(); + i = arc4random() % 100; + if (i < 20) + val = val & 0xff; + if (i >= 20 && i < 40) + val = val & 0xffff; + if (i >= 40 && i < 60) + val = (unsigned long)(r) | (val & 0xffff); +#if defined(__LP64__) + if (i >= 60) { + val = (val << 32) | arc4random(); + if (i > 80) + val = val & 0x00007fffffffffffUL; + } +#endif + + return(val); +} + +void * +makeptr(void) +{ + unsigned long val; + + if (p != MAP_FAILED && p != NULL) + val = (unsigned long)p + arc4random(); + else + val = makearg(); + val = trunc_page(val); + + return ((void *)val); +} + +void * +tmmap(void *arg __unused) +{ + size_t len; + int i, fd; + + pthread_set_name_np(pthread_self(), __func__); + len = 1LL * 128 * 1024 * 1024; + + if ((fd = open("/dev/zero", O_RDWR)) == -1) + err(1,"open()"); + for (i = 0; i < 100; i++) { + p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + } + close(fd); + + return (NULL); +} + +void * +tmlock(void *arg __unused) +{ + size_t len; + int i, n; + + pthread_set_name_np(pthread_self(), __func__); + n = 0; + for (i = 0; i < 200; i++) { + len = trunc_page(makearg()); + if (mlock(makeptr(), len) == 0) + n++; + len = trunc_page(makearg()); + if (arc4random() % 100 < 50) + if (munlock(makeptr(), len) == 0) + n++; + } + if (n < 10) + fprintf(stderr, "Note: tmlock() only succeeded %d times.\n", + n); + + return (NULL); +} + +void +test(void) +{ + pthread_t tid[2]; + int i, rc; + + if ((rc = pthread_create(&tid[0], NULL, tmmap, NULL)) != 0) + errc(1, rc, "tmmap()"); + if ((rc = pthread_create(&tid[1], NULL, tmlock, NULL)) != 0) + errc(1, rc, "tmlock()"); + + for (i = 0; i < 100; i++) { + if (fork() == 0) { + usleep(10000); + _exit(0); + } + wait(NULL); + } + + raise(SIGSEGV); + + for (i = 0; i < 2; i++) + if ((rc = pthread_join(tid[i], NULL)) != 0) + errc(1, rc, "pthread_join(%d)", i); + _exit(0); +} + +int +main(void) +{ + int i, j; + + alarm(120); + for (i = 0; i < N; i++) + r[i] = arc4random(); + + for (i = 0; i < LOOPS; i++) { + for (j = 0; j < PARALLEL; j++) { + if (fork() == 0) + test(); + } + + for (j = 0; j < PARALLEL; j++) + wait(NULL); + } + + return (0); +} Added: user/pho/stress2/misc/mmap16.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mmap16.sh Wed Feb 18 13:07:26 2015 (r278955) @@ -0,0 +1,147 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +exit 0 # Experimental test scenario + +# Test scenario by kib@ + +[ `uname -m` = "i386" ] || exit 0 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mmap16.c +mycc -o mmap16 -Wall -Wextra -O2 -g mmap16.c -lpthread || exit 1 +rm -f mmap16.c /tmp/mmap16.core +rm -f /tmp/mmap16.core + +/tmp/mmap16 > /dev/null + +rm -f /tmp/mmap16 /tmp/mmap16.core +exit 0 +EOF +/* $Id: map_hole.c,v 1.6 2014/06/16 05:52:03 kostik Exp kostik $ */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef MAP_HOLE +#define MAP_HOLE 0x00002000 /* no backing pages */ +#endif + +static void +sighandler(int signo, siginfo_t *info, void *uap1) +{ + static char scratch; + ucontext_t *uap; + + uap = uap1; + printf("SIG%s(%d) at %p (%%eax %p)\n", + signo < sys_nsig ? sys_signame[signo] : "SOME", signo, + info->si_addr, (void *)(uintptr_t)uap->uc_mcontext.mc_eax); + uap->uc_mcontext.mc_eax = (uintptr_t)&scratch; +} + +static void +access_addr(char *addr) +{ + char r; + + r = '1'; + printf("accessing %p\n", addr); + __asm __volatile("movb %0,(%%eax)" : : "i"(r), "a"(addr) : "memory"); + printf("done\n"); +} + +static int pagesz; + +static void +test_access(char *addr) +{ + struct rusage ru; + long majflt, minflt; + + if (getrusage(RUSAGE_THREAD, &ru) == -1) + err(1, "getrusage"); + majflt = ru.ru_majflt; + minflt = ru.ru_minflt; + access_addr(addr); + if (mprotect(addr, pagesz, PROT_READ | PROT_WRITE) == -1) + warn("mprotect"); + access_addr(addr); + if (getrusage(RUSAGE_THREAD, &ru) == -1) + err(1, "getrusage"); + majflt = ru.ru_majflt - majflt; + minflt = ru.ru_minflt - minflt; + printf("majflt %ld minflt %ld\n", majflt, minflt); +} + +int +main(void) +{ + struct sigaction sa; + char *addr; + char cmd[128]; + + bzero(&sa, sizeof(sa)); + sa.sa_sigaction = sighandler; + sa.sa_flags = SA_SIGINFO; + if (sigaction(SIGSEGV, &sa, NULL) == -1) + err(1, "sigaction"); + pagesz = getpagesize(); + + printf("MAP_HOLE\n"); + addr = mmap(NULL, pagesz, PROT_NONE, MAP_HOLE, -1, 0); + if (addr == (char *)MAP_FAILED) + err(1, "FAIL: mmap(MAP_HOLE)"); + test_access(addr); + + printf("PROT_NONE wire\n"); + addr = mmap(NULL, pagesz, PROT_NONE, MAP_ANON, -1, 0); + if (addr == (char *)MAP_FAILED) + err(1, "mmap(PROT_NONE)"); + if (mlock(addr, pagesz) == -1) + err(1, "mlock"); + test_access(addr); + + snprintf(cmd, sizeof(cmd), "procstat -v %d", getpid()); + system(cmd); + + return (0); +} Added: user/pho/stress2/misc/mmap17.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mmap17.sh Wed Feb 18 13:07:26 2015 (r278955) @@ -0,0 +1,88 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +# Test scenario by kib@ + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mmap17.c +mycc -o mmap17 -Wall -Wextra -O2 -g mmap17.c -lpthread || exit 1 +rm -f mmap17.c /tmp/mmap17.core +rm -f /tmp/mmap17.core + +{ /tmp/mmap17 > /dev/null; } 2>&1 | grep -v worked + +rm -f /tmp/mmap17 /tmp/mmap17.core +exit 0 +EOF +/* $Id: map_excl.c,v 1.2 2014/06/16 06:02:52 kostik Exp kostik $ */ + +#include +#include +#include +#include +#include + +#ifndef MAP_EXCL +#define MAP_EXCL 0x00004000 /* for MAP_FIXED, fail if address is used */ +#endif + +int +main(void) +{ + char *addr, *addr1; + int pagesz; + char cmd[128]; + + pagesz = getpagesize(); + addr = mmap(NULL, pagesz, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + if (addr == (char *)MAP_FAILED) + err(1, "mmap 1"); + printf("addr %p\n", addr); + + addr -= pagesz; + addr1 = mmap(addr, 3 * pagesz, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_FIXED | MAP_EXCL, -1, 0); + if (addr1 == MAP_FAILED) + warn("EXCL worked"); + else + fprintf(stderr, "EXCL failed\n"); + + addr1 = mmap(addr, 3 * pagesz, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_FIXED, -1, 0); + printf("addr1 %p\n", addr); + + snprintf(cmd, sizeof(cmd), "procstat -v %d", getpid()); + system(cmd); + + return (0); +} Added: user/pho/stress2/misc/mmap18.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mmap18.sh Wed Feb 18 13:07:26 2015 (r278955) @@ -0,0 +1,275 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +# Copy of mmap10.sh with core dump disabled. +# http://people.freebsd.org/~pho/stress/log/kostik711.txt +# http://people.freebsd.org/~pho/stress/log/mmap18.txt + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mmap18.c +mycc -o mmap18 -Wall -Wextra -O2 mmap18.c -lpthread || exit 1 +rm -f mmap18.c + +daemon sh -c "(cd $here/../testcases/swap; ./swap -t 2m -i 20 -k)" +rnd=`od -An -N1 -t u1 /dev/random | sed 's/ //g'` +sleep $((rnd % 10)) +for i in `jot 2`; do + /tmp/mmap18 +done +killall -q swap + +rm -f /tmp/mmap18 /tmp/mmap18.core +exit 0 +EOF +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOOPS 50 +#define N (128 * 1024 / (int)sizeof(u_int32_t)) +#define PARALLEL 50 + +u_int32_t r[N]; +void *p; + +unsigned long +makearg(void) +{ + unsigned long val; + unsigned int i; + + val = arc4random(); + i = arc4random() % 100; + if (i < 20) + val = val & 0xff; + if (i >= 20 && i < 40) + val = val & 0xffff; + if (i >= 40 && i < 60) + val = (unsigned long)(r) | (val & 0xffff); +#if defined(__LP64__) + if (i >= 60) { + val = (val << 32) | arc4random(); + if (i > 80) + val = val & 0x00007fffffffffffUL; + } +#endif + + return(val); +} + +void * +makeptr(void) +{ + unsigned long val; + + if (p != MAP_FAILED && p != NULL) + val = (unsigned long)p + arc4random(); + else + val = makearg(); + val = trunc_page(val); + + return ((void *)val); +} + +void * +tmmap(void *arg __unused) +{ + size_t len; + int i, fd; + + pthread_set_name_np(pthread_self(), __func__); + len = 1LL * 1024 * 1024 * 1024; + + for (i = 0; i < 100; i++) { + if ((fd = open("/dev/zero", O_RDWR)) == -1) + err(1,"open()"); + + if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, + fd, 0)) != MAP_FAILED) { + usleep(100); + munmap(p, len); + } + + if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, + 0)) != MAP_FAILED) { + usleep(100); + munmap(p, len); + } + close(fd); + } + + return (NULL); +} + +void * +tmlock(void *arg __unused) +{ + int i, n; + size_t len; + + pthread_set_name_np(pthread_self(), __func__); + n = 0; + for (i = 0; i < 200; i++) { + len = trunc_page(makearg()); + if (mlock(makeptr(), len) == 0) + n++; + len = trunc_page(makearg()); + if (arc4random() % 100 < 50) + if (munlock(makeptr(), len) == 0) + n++; + } + if (n < 10) + fprintf(stderr, "Note: tmlock() only succeeded %d times.\n", + n); + + return (NULL); +} + +void * +tmprotect(void *arg __unused) +{ + const void *addr; + size_t len; + int i, n, prot; + + pthread_set_name_np(pthread_self(), __func__); + n = 0; + for (i = 0; i < 200; i++) { + addr = makeptr(); + len = trunc_page(makearg()); + prot = makearg(); + if (mprotect(addr, len, prot) == 0) + n++; + usleep(1000); + } + if (n < 10) + fprintf(stderr, "Note: tmprotect() only succeeded %d times.\n", + n); + + return (NULL); +} + +void * +tmlockall(void *arg __unused) +{ + int flags, i, n; + + pthread_set_name_np(pthread_self(), __func__); + n = 0; + for (i = 0; i < 200; i++) { + flags = makearg(); + if (mlockall(flags) == 0) + n++; + usleep(100); + munlockall(); + usleep(1000); + } + if (n < 10) + fprintf(stderr, "Note: tmlockall() only succeeded %d times.\n", + n); + + return (NULL); +} + +void +test(void) +{ + pthread_t tid[4]; + int i, rc; + + if ((rc = pthread_create(&tid[0], NULL, tmmap, NULL)) != 0) + errc(1, rc, "tmmap()"); + if ((rc = pthread_create(&tid[1], NULL, tmlock, NULL)) != 0) + errc(1, rc, "tmlock()"); + if ((rc = pthread_create(&tid[2], NULL, tmprotect, NULL)) != 0) + errc(1, rc, "tmprotect()"); + if ((rc = pthread_create(&tid[3], NULL, tmlockall, NULL)) != 0) + errc(1, rc, "tmlockall()"); + + for (i = 0; i < 100; i++) { + if (fork() == 0) { + usleep(10000); + _exit(0); + } + wait(NULL); + } + + for (i = 0; i < 4; i++) + if ((rc = pthread_join(tid[i], NULL)) != 0) + errc(1, rc, "pthread_join(%d)", i); + _exit(0); +} + +int +main(void) +{ + struct rlimit rl; + int i, j; + + rl.rlim_max = rl.rlim_cur = 0; + if (setrlimit(RLIMIT_CORE, &rl) == -1) + warn("setrlimit"); + + for (i = 0; i < N; i++) + r[i] = arc4random(); + + for (i = 0; i < LOOPS; i++) { + for (j = 0; j < PARALLEL; j++) { + if (fork() == 0) + test(); + } + + for (j = 0; j < PARALLEL; j++) + wait(NULL); + } + + return (0); +} Added: user/pho/stress2/misc/mmap20.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mmap20.sh Wed Feb 18 13:07:26 2015 (r278955) @@ -0,0 +1,84 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +# "panic: pmap_unwire: pte 0x672d405 is missing PG_W" seen. +# http://people.freebsd.org/~pho/stress/log/mmap20.txt + +# Test scenario by: Mark Johnston markj@ + +# Fixed by r272036 + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Feb 18 19:54:03 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EB751336; Wed, 18 Feb 2015 19:54:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D195DE7D; Wed, 18 Feb 2015 19:54:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1IJs3vP070378; Wed, 18 Feb 2015 19:54:03 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1IJrvZ6070336; Wed, 18 Feb 2015 19:53:57 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502181953.t1IJrvZ6070336@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Wed, 18 Feb 2015 19:53:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278969 - in user/dchagin/lemul: . bin/ln bin/pkill/tests bin/sh bin/sh/tests/expansion cddl/contrib/opensolaris/lib/libdtrace/common contrib/elftoolchain/addr2line contrib/elftoolchain... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 18 Feb 2015 19:54:04 -0000 Author: dchagin Date: Wed Feb 18 19:53:56 2015 New Revision: 278969 URL: https://svnweb.freebsd.org/changeset/base/278969 Log: Merge from head. Added: user/dchagin/lemul/bin/sh/tests/expansion/ifs5.0 - copied unchanged from r278968, head/bin/sh/tests/expansion/ifs5.0 user/dchagin/lemul/bin/sh/tests/expansion/pathname5.0 - copied unchanged from r278968, head/bin/sh/tests/expansion/pathname5.0 user/dchagin/lemul/lib/libc/sparc64/sys/sigaction1.S - copied unchanged from r278968, head/lib/libc/sparc64/sys/sigaction1.S user/dchagin/lemul/share/man/man4/udl.4 - copied unchanged from r278968, head/share/man/man4/udl.4 user/dchagin/lemul/sys/arm/arm/unwind.c - copied unchanged from r278968, head/sys/arm/arm/unwind.c user/dchagin/lemul/sys/conf/config.mk - copied unchanged from r278968, head/sys/conf/config.mk user/dchagin/lemul/sys/dev/usb/video/ - copied from r278968, head/sys/dev/usb/video/ user/dchagin/lemul/sys/dev/videomode/ - copied from r278968, head/sys/dev/videomode/ user/dchagin/lemul/sys/modules/usb/udl/ - copied from r278968, head/sys/modules/usb/udl/ user/dchagin/lemul/sys/modules/videomode/ - copied from r278968, head/sys/modules/videomode/ user/dchagin/lemul/sys/ofed/drivers/infiniband/core/peer_mem.c - copied unchanged from r278968, head/sys/ofed/drivers/infiniband/core/peer_mem.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_exp.c - copied unchanged from r278968, head/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_exp.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_exp.h - copied unchanged from r278968, head/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_exp.h user/dchagin/lemul/sys/ofed/include/linux/printk.h - copied unchanged from r278968, head/sys/ofed/include/linux/printk.h user/dchagin/lemul/sys/ofed/include/rdma/ib_peer_mem.h - copied unchanged from r278968, head/sys/ofed/include/rdma/ib_peer_mem.h user/dchagin/lemul/sys/ofed/include/rdma/ib_user_verbs_exp.h - copied unchanged from r278968, head/sys/ofed/include/rdma/ib_user_verbs_exp.h user/dchagin/lemul/sys/ofed/include/rdma/ib_verbs_exp.h - copied unchanged from r278968, head/sys/ofed/include/rdma/ib_verbs_exp.h user/dchagin/lemul/sys/ofed/include/rdma/peer_mem.h - copied unchanged from r278968, head/sys/ofed/include/rdma/peer_mem.h Deleted: user/dchagin/lemul/lib/libc/sparc64/sys/sigaction.S user/dchagin/lemul/sys/dev/ic/hd64570.h user/dchagin/lemul/sys/ofed/drivers/infiniband/core/Makefile user/dchagin/lemul/sys/ofed/drivers/infiniband/core/local_sa.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/notice.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/Makefile user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/ipoib/Makefile Modified: user/dchagin/lemul/Makefile.inc1 user/dchagin/lemul/ObsoleteFiles.inc user/dchagin/lemul/UPDATING user/dchagin/lemul/bin/ln/symlink.7 user/dchagin/lemul/bin/pkill/tests/pkill-j_test.sh user/dchagin/lemul/bin/sh/cd.c user/dchagin/lemul/bin/sh/eval.c user/dchagin/lemul/bin/sh/expand.c user/dchagin/lemul/bin/sh/mail.c user/dchagin/lemul/bin/sh/memalloc.c user/dchagin/lemul/bin/sh/memalloc.h user/dchagin/lemul/bin/sh/miscbltin.c user/dchagin/lemul/bin/sh/nodetypes user/dchagin/lemul/bin/sh/parser.c user/dchagin/lemul/bin/sh/tests/expansion/Makefile user/dchagin/lemul/bin/sh/var.c user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c user/dchagin/lemul/contrib/elftoolchain/addr2line/addr2line.c user/dchagin/lemul/contrib/elftoolchain/common/_elftc.h user/dchagin/lemul/contrib/elftoolchain/common/elfdefinitions.h user/dchagin/lemul/contrib/elftoolchain/elfcopy/main.c user/dchagin/lemul/contrib/elftoolchain/elfcopy/sections.c user/dchagin/lemul/contrib/elftoolchain/libdwarf/_libdwarf.h user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_attrval.c user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_get_AT_name.3 user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_get_arange_info.3 user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3 user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_hasattr.3 user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_reloc.c user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_set_reloc_application.3 user/dchagin/lemul/contrib/elftoolchain/libdwarf/dwarf_whatattr.3 user/dchagin/lemul/contrib/elftoolchain/libdwarf/libdwarf.c user/dchagin/lemul/contrib/elftoolchain/libdwarf/libdwarf.h user/dchagin/lemul/contrib/elftoolchain/libdwarf/libdwarf_elf_init.c user/dchagin/lemul/contrib/elftoolchain/libdwarf/libdwarf_reloc.c user/dchagin/lemul/contrib/elftoolchain/libelf/_libelf_config.h user/dchagin/lemul/contrib/elftoolchain/libelf/elf.3 user/dchagin/lemul/contrib/elftoolchain/libelf/elf_scn.c user/dchagin/lemul/contrib/elftoolchain/libelf/libelf_ar_util.c user/dchagin/lemul/contrib/elftoolchain/libelf/libelf_convert.m4 user/dchagin/lemul/contrib/elftoolchain/nm/nm.1 user/dchagin/lemul/contrib/elftoolchain/nm/nm.c user/dchagin/lemul/contrib/elftoolchain/readelf/readelf.c user/dchagin/lemul/contrib/llvm/tools/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp user/dchagin/lemul/etc/network.subr user/dchagin/lemul/lib/libc/gen/_spinlock_stub.c user/dchagin/lemul/lib/libc/gen/dlopen.3 user/dchagin/lemul/lib/libc/gen/fstab.c user/dchagin/lemul/lib/libc/gen/getgrent.c user/dchagin/lemul/lib/libc/gen/getpwent.c user/dchagin/lemul/lib/libc/gen/ulimit.c user/dchagin/lemul/lib/libc/include/libc_private.h user/dchagin/lemul/lib/libc/rpc/clnt_dg.c user/dchagin/lemul/lib/libc/rpc/rpc_soc.c user/dchagin/lemul/lib/libc/sparc64/sys/Makefile.inc user/dchagin/lemul/lib/libc/stdio/xprintf_float.c user/dchagin/lemul/lib/libc/sys/Makefile.inc user/dchagin/lemul/lib/libc/sys/interposing_table.c user/dchagin/lemul/lib/libcompat/4.3/rexec.c user/dchagin/lemul/lib/libelftc/elftc_version.c user/dchagin/lemul/lib/liblzma/config.h user/dchagin/lemul/lib/libthr/thread/thr_private.h user/dchagin/lemul/lib/libthr/thread/thr_spinlock.c user/dchagin/lemul/lib/libthr/thread/thr_syscalls.c user/dchagin/lemul/release/Makefile user/dchagin/lemul/release/Makefile.vm user/dchagin/lemul/sbin/camcontrol/camcontrol.c user/dchagin/lemul/share/man/man4/Makefile user/dchagin/lemul/share/man/man4/wlan.4 user/dchagin/lemul/share/mk/bsd.dep.mk user/dchagin/lemul/share/mk/bsd.libnames.mk user/dchagin/lemul/share/mk/bsd.own.mk user/dchagin/lemul/sys/amd64/amd64/mp_machdep.c user/dchagin/lemul/sys/arm/arm/cpuinfo.c user/dchagin/lemul/sys/arm/arm/db_trace.c user/dchagin/lemul/sys/arm/broadcom/bcm2835/bcm2835_bsc.c user/dchagin/lemul/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h user/dchagin/lemul/sys/arm/broadcom/bcm2835/bcm2835_gpio.c user/dchagin/lemul/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h user/dchagin/lemul/sys/arm/include/stack.h user/dchagin/lemul/sys/boot/fdt/dts/arm/bcm2835.dtsi user/dchagin/lemul/sys/cam/cam_ccb.h user/dchagin/lemul/sys/cam/scsi/scsi_da.c user/dchagin/lemul/sys/cam/scsi/scsi_enc_ses.c user/dchagin/lemul/sys/conf/files user/dchagin/lemul/sys/conf/files.arm user/dchagin/lemul/sys/conf/kern.mk user/dchagin/lemul/sys/conf/kern.pre.mk user/dchagin/lemul/sys/conf/kmod.mk user/dchagin/lemul/sys/conf/options user/dchagin/lemul/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h user/dchagin/lemul/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_beacon.c user/dchagin/lemul/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c user/dchagin/lemul/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c user/dchagin/lemul/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c user/dchagin/lemul/sys/contrib/rdma/krping/krping.c user/dchagin/lemul/sys/dev/acpica/acpi_pcib.c user/dchagin/lemul/sys/dev/ath/if_ath_pci.c user/dchagin/lemul/sys/dev/atkbdc/atkbd.c user/dchagin/lemul/sys/dev/atkbdc/atkbdc.c user/dchagin/lemul/sys/dev/atkbdc/atkbdcreg.h user/dchagin/lemul/sys/dev/atkbdc/psm.c user/dchagin/lemul/sys/dev/cardbus/cardbus.c user/dchagin/lemul/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c user/dchagin/lemul/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_qp.c user/dchagin/lemul/sys/dev/cxgbe/iw_cxgbe/cq.c user/dchagin/lemul/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h user/dchagin/lemul/sys/dev/cxgbe/iw_cxgbe/mem.c user/dchagin/lemul/sys/dev/fb/fbd.c user/dchagin/lemul/sys/dev/iicbus/lm75.c user/dchagin/lemul/sys/dev/lmc/if_lmc.h user/dchagin/lemul/sys/dev/mpr/mpr_sas.c user/dchagin/lemul/sys/dev/mps/mps_sas.c user/dchagin/lemul/sys/dev/netmap/netmap.c user/dchagin/lemul/sys/dev/pccbb/pccbb.c user/dchagin/lemul/sys/dev/pci/pci.c user/dchagin/lemul/sys/dev/random/dummy_rng.c user/dchagin/lemul/sys/dev/random/fortuna.c user/dchagin/lemul/sys/dev/random/random_adaptors.c user/dchagin/lemul/sys/dev/random/randomdev.c user/dchagin/lemul/sys/dev/random/randomdev.h user/dchagin/lemul/sys/dev/random/yarrow.c user/dchagin/lemul/sys/dev/sfxge/common/efx_ev.c user/dchagin/lemul/sys/dev/sfxge/common/efx_mac.c user/dchagin/lemul/sys/dev/sfxge/common/efx_mcdi.c user/dchagin/lemul/sys/dev/sfxge/common/efx_mcdi.h user/dchagin/lemul/sys/dev/sfxge/common/efx_nic.c user/dchagin/lemul/sys/dev/sfxge/common/efx_regs_mcdi.h user/dchagin/lemul/sys/dev/sfxge/common/efx_rx.c user/dchagin/lemul/sys/dev/sfxge/common/efx_tx.c user/dchagin/lemul/sys/dev/sfxge/common/siena_mon.c user/dchagin/lemul/sys/dev/sfxge/common/siena_nic.c user/dchagin/lemul/sys/dev/sfxge/common/siena_nvram.c user/dchagin/lemul/sys/dev/sfxge/common/siena_phy.c user/dchagin/lemul/sys/dev/sfxge/common/siena_vpd.c user/dchagin/lemul/sys/dev/sfxge/sfxge.h user/dchagin/lemul/sys/dev/sfxge/sfxge_ev.c user/dchagin/lemul/sys/dev/sfxge/sfxge_port.c user/dchagin/lemul/sys/dev/sfxge/sfxge_rx.c user/dchagin/lemul/sys/dev/sfxge/sfxge_tx.c user/dchagin/lemul/sys/dev/sfxge/sfxge_tx.h user/dchagin/lemul/sys/dev/spibus/spi.h user/dchagin/lemul/sys/dev/spibus/spibus.c user/dchagin/lemul/sys/dev/spibus/spibusvar.h user/dchagin/lemul/sys/dev/usb/controller/musb_otg.c user/dchagin/lemul/sys/dev/usb/controller/uhci.c user/dchagin/lemul/sys/dev/usb/usbdevs user/dchagin/lemul/sys/dev/vt/vt_core.c user/dchagin/lemul/sys/dev/wpi/if_wpi.c user/dchagin/lemul/sys/dev/wpi/if_wpireg.h user/dchagin/lemul/sys/dev/xen/xenstore/xenstore_dev.c user/dchagin/lemul/sys/fs/ext2fs/ext2_htree.c user/dchagin/lemul/sys/fs/ext2fs/ext2_vfsops.c user/dchagin/lemul/sys/i386/i386/mp_machdep.c user/dchagin/lemul/sys/kern/imgact_elf.c user/dchagin/lemul/sys/kern/kern_descrip.c user/dchagin/lemul/sys/kern/kern_procctl.c user/dchagin/lemul/sys/kern/subr_taskqueue.c user/dchagin/lemul/sys/kern/sys_generic.c user/dchagin/lemul/sys/kern/sysv_shm.c user/dchagin/lemul/sys/kern/tty.c user/dchagin/lemul/sys/kern/uipc_mbuf.c user/dchagin/lemul/sys/kern/uipc_socket.c user/dchagin/lemul/sys/kern/uipc_syscalls.c user/dchagin/lemul/sys/kern/vfs_subr.c user/dchagin/lemul/sys/kern/vfs_syscalls.c user/dchagin/lemul/sys/mips/conf/AR71XX_BASE user/dchagin/lemul/sys/modules/Makefile user/dchagin/lemul/sys/modules/cxgbe/if_cxgbe/Makefile user/dchagin/lemul/sys/modules/dpt/Makefile user/dchagin/lemul/sys/modules/drm2/radeonkms/Makefile user/dchagin/lemul/sys/modules/ed/Makefile user/dchagin/lemul/sys/modules/ep/Makefile user/dchagin/lemul/sys/modules/ibcore/Makefile user/dchagin/lemul/sys/modules/if_gif/Makefile user/dchagin/lemul/sys/modules/if_gre/Makefile user/dchagin/lemul/sys/modules/ipoib/Makefile user/dchagin/lemul/sys/modules/mlx4/Makefile user/dchagin/lemul/sys/modules/mlx4ib/Makefile user/dchagin/lemul/sys/modules/mlxen/Makefile user/dchagin/lemul/sys/modules/mthca/Makefile user/dchagin/lemul/sys/modules/si/Makefile user/dchagin/lemul/sys/modules/vx/Makefile user/dchagin/lemul/sys/net/if_bridge.c user/dchagin/lemul/sys/net/pfvar.h user/dchagin/lemul/sys/netinet6/frag6.c user/dchagin/lemul/sys/netinet6/ip6_output.c user/dchagin/lemul/sys/netinet6/ip6_var.h user/dchagin/lemul/sys/netpfil/pf/pf.c user/dchagin/lemul/sys/netpfil/pf/pf.h user/dchagin/lemul/sys/netpfil/pf/pf_mtag.h user/dchagin/lemul/sys/netpfil/pf/pf_norm.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/addr.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/cache.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/cm.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/cm_msgs.h user/dchagin/lemul/sys/ofed/drivers/infiniband/core/cma.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/core_priv.h user/dchagin/lemul/sys/ofed/drivers/infiniband/core/device.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/fmr_pool.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/iwcm.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/mad.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/mad_priv.h user/dchagin/lemul/sys/ofed/drivers/infiniband/core/mad_rmpp.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/multicast.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/packer.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/sa.h user/dchagin/lemul/sys/ofed/drivers/infiniband/core/sa_query.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/smi.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/sysfs.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/ucm.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/ucma.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/ud_header.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/umem.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/user_mad.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/uverbs.h user/dchagin/lemul/sys/ofed/drivers/infiniband/core/uverbs_cmd.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/uverbs_main.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/uverbs_marshall.c user/dchagin/lemul/sys/ofed/drivers/infiniband/core/verbs.c user/dchagin/lemul/sys/ofed/drivers/infiniband/debug/memtrack.c user/dchagin/lemul/sys/ofed/drivers/infiniband/debug/memtrack.h user/dchagin/lemul/sys/ofed/drivers/infiniband/debug/mtrack.h user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/ah.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/alias_GUID.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/cm.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/cq.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/doorbell.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/mad.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/main.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/mcg.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_ib.h user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/mr.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/qp.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mlx4/sysfs.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c user/dchagin/lemul/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c user/dchagin/lemul/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c user/dchagin/lemul/sys/ofed/drivers/net/mlx4/Makefile user/dchagin/lemul/sys/ofed/drivers/net/mlx4/en_rx.c user/dchagin/lemul/sys/ofed/include/linux/device.h user/dchagin/lemul/sys/ofed/include/linux/file.h user/dchagin/lemul/sys/ofed/include/linux/linux_compat.c user/dchagin/lemul/sys/ofed/include/net/ip.h user/dchagin/lemul/sys/ofed/include/rdma/ib_addr.h user/dchagin/lemul/sys/ofed/include/rdma/ib_cache.h user/dchagin/lemul/sys/ofed/include/rdma/ib_cm.h user/dchagin/lemul/sys/ofed/include/rdma/ib_mad.h user/dchagin/lemul/sys/ofed/include/rdma/ib_pack.h user/dchagin/lemul/sys/ofed/include/rdma/ib_sa.h user/dchagin/lemul/sys/ofed/include/rdma/ib_umem.h user/dchagin/lemul/sys/ofed/include/rdma/ib_user_verbs.h user/dchagin/lemul/sys/ofed/include/rdma/ib_verbs.h user/dchagin/lemul/sys/ofed/include/rdma/iw_cm.h user/dchagin/lemul/sys/ofed/include/rdma/rdma_cm.h user/dchagin/lemul/sys/ofed/include/rdma/rdma_user_cm.h user/dchagin/lemul/sys/powerpc/powermac/atibl.c user/dchagin/lemul/sys/powerpc/powermac/nvbl.c user/dchagin/lemul/sys/powerpc/powerpc/db_trace.c user/dchagin/lemul/sys/sparc64/include/asm.h user/dchagin/lemul/sys/sys/fbio.h user/dchagin/lemul/sys/sys/file.h user/dchagin/lemul/sys/sys/filedesc.h user/dchagin/lemul/sys/sys/mbuf.h user/dchagin/lemul/sys/sys/param.h user/dchagin/lemul/sys/sys/taskqueue.h user/dchagin/lemul/sys/vm/memguard.c user/dchagin/lemul/sys/x86/acpica/acpi_wakeup.c user/dchagin/lemul/sys/x86/acpica/madt.c user/dchagin/lemul/sys/x86/include/vmware.h user/dchagin/lemul/sys/x86/x86/local_apic.c user/dchagin/lemul/sys/x86/xen/pvcpu_enum.c user/dchagin/lemul/sys/x86/xen/xen_intr.c user/dchagin/lemul/usr.bin/compress/compress.c user/dchagin/lemul/usr.bin/du/du.c user/dchagin/lemul/usr.bin/gcore/elfcore.c user/dchagin/lemul/usr.bin/gzip/gzip.c user/dchagin/lemul/usr.bin/kdump/kdump.c user/dchagin/lemul/usr.bin/ministat/ministat.c user/dchagin/lemul/usr.bin/timeout/timeout.c user/dchagin/lemul/usr.bin/touch/touch.c user/dchagin/lemul/usr.sbin/binmiscctl/binmiscctl.8 user/dchagin/lemul/usr.sbin/binmiscctl/binmiscctl.c user/dchagin/lemul/usr.sbin/devctl/Makefile user/dchagin/lemul/usr.sbin/pw/tests/pw_useradd.sh user/dchagin/lemul/usr.sbin/pw/tests/pw_usernext.sh Directory Properties: user/dchagin/lemul/ (props changed) user/dchagin/lemul/cddl/ (props changed) user/dchagin/lemul/cddl/contrib/opensolaris/ (props changed) user/dchagin/lemul/contrib/elftoolchain/ (props changed) user/dchagin/lemul/contrib/llvm/ (props changed) user/dchagin/lemul/contrib/llvm/tools/lldb/ (props changed) user/dchagin/lemul/etc/ (props changed) user/dchagin/lemul/lib/libc/ (props changed) user/dchagin/lemul/sbin/ (props changed) user/dchagin/lemul/share/ (props changed) user/dchagin/lemul/share/man/man4/ (props changed) user/dchagin/lemul/sys/ (props changed) user/dchagin/lemul/sys/boot/ (props changed) user/dchagin/lemul/sys/conf/ (props changed) Modified: user/dchagin/lemul/Makefile.inc1 ============================================================================== --- user/dchagin/lemul/Makefile.inc1 Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/Makefile.inc1 Wed Feb 18 19:53:56 2015 (r278969) @@ -343,16 +343,15 @@ WMAKEENV+= CC="${XCC} ${XCFLAGS}" CXX="$ SIZE="${XSIZE}" .if ${XCC:M/*} -XFLAGS= --sysroot=${WORLDTMP} .if defined(CROSS_BINUTILS_PREFIX) # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a # directory, but the compiler will look in the right place for it's # tools so we don't need to tell it where to look. .if exists(${CROSS_BINUTILS_PREFIX}) -XFLAGS+= -B${CROSS_BINUTILS_PREFIX} +BFLAGS+= -B${CROSS_BINUTILS_PREFIX} .endif .else -XFLAGS+= -B${WORLDTMP}/usr/bin +BFLAGS+= -B${WORLDTMP}/usr/bin .endif .if ${TARGET} == "arm" .if ${TARGET_ARCH:M*hf*} != "" @@ -369,6 +368,8 @@ DEPFLAGS+= -I${WORLDTMP}/usr/include/c++ TARGET_ABI?= unknown TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0 XCFLAGS+= -target ${TARGET_TRIPLE} +XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS} +XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS} .endif .endif @@ -912,25 +913,25 @@ packageworld: .for dist in base ${EXTRA_DISTRIBUTIONS} .if defined(NO_ROOT) ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \ - --exclude usr/lib/debug \ - @${DESTDIR}/${DISTDIR}/${dist}.meta + tar cvf - --exclude usr/lib/debug \ + @${DESTDIR}/${DISTDIR}/${dist}.meta | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz .else ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \ - --exclude usr/lib/debug . + tar cvf - --exclude usr/lib/debug . | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz .endif .endfor .for dist in ${DEBUG_DISTRIBUTIONS} . if defined(NO_ROOT) ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvJf ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \ - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta + tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz . else ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ - tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \ - usr/lib/debug + tar cvLf - usr/lib/debug | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz . endif .endfor @@ -1138,19 +1139,21 @@ distributekernel distributekernel.debug: packagekernel: .if defined(NO_ROOT) cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \ - @${DESTDIR}/${DISTDIR}/kernel.meta + tar cvf - @${DESTDIR}/${DISTDIR}/kernel.meta | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \ - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta + tar cvf - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .endfor .else cd ${DESTDIR}/${DISTDIR}/kernel; \ - tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz . + tar cvf - . | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ - tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz . + tar cvf - . | \ + ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .endfor .endif Modified: user/dchagin/lemul/ObsoleteFiles.inc ============================================================================== --- user/dchagin/lemul/ObsoleteFiles.inc Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/ObsoleteFiles.inc Wed Feb 18 19:53:56 2015 (r278969) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20150217: Removed remnants of ar(4) driver +OLD_FILES+=usr/include/sys/dev/ic/hd64570.h # 20150212: /usr/games moving into /usr/bin OLD_FILES+=usr/games/bcd OLD_FILES+=usr/games/caesar Modified: user/dchagin/lemul/UPDATING ============================================================================== --- user/dchagin/lemul/UPDATING Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/UPDATING Wed Feb 18 19:53:56 2015 (r278969) @@ -31,6 +31,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20150217: + If you are running a -CURRENT kernel since r273872 (Oct 30th, 2014), + but before r278950, the RNG was not seeded properly. Immediately + upgrade the kernel to r278950 or later and regenerate any keys (e.g. + ssh keys or openssl keys) that were generated w/ a kernel from that + range. This does not effect programs that directly used /dev/random + or /dev/urandom. All userland uses of arc4random(3) are effected. + 20150210: The autofs(4) ABI was changed in order to restore binary compatibility with 10.1-RELEASE. The automountd(8) daemon needs to be rebuilt to work Modified: user/dchagin/lemul/bin/ln/symlink.7 ============================================================================== --- user/dchagin/lemul/bin/ln/symlink.7 Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/ln/symlink.7 Wed Feb 18 19:53:56 2015 (r278969) @@ -29,7 +29,7 @@ .\" @(#)symlink.7 8.3 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd January 23, 2015 +.Dd February 16, 2015 .Dt SYMLINK 7 .Os .Sh NAME @@ -146,6 +146,7 @@ The following system calls follow symbol unless given the .Dv AT_SYMLINK_NOFOLLOW flag: +.Xr chflagsat 2 , .Xr fchmodat 2 , .Xr fchownat 2 , .Xr fstatat 2 Modified: user/dchagin/lemul/bin/pkill/tests/pkill-j_test.sh ============================================================================== --- user/dchagin/lemul/bin/pkill/tests/pkill-j_test.sh Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/pkill/tests/pkill-j_test.sh Wed Feb 18 19:53:56 2015 (r278969) @@ -4,99 +4,90 @@ jail_name_to_jid() { local check_name="$1" - ( - line="$(jls -n 2> /dev/null | grep name=$check_name )" - for nv in $line; do - local name="${nv%=*}" - if [ "${name}" = "jid" ]; then - eval $nv - echo $jid - break - fi - done - ) + jls -j "$check_name" -s 2>/dev/null | tr ' ' '\n' | grep jid= | sed -e 's/.*=//g' } base=pkill_j_test +if [ `id -u` -ne 0 ]; then + echo "1..0 # skip Test needs uid 0." + exit 0 +fi + echo "1..3" +sleep=$(pwd)/sleep.txt +ln -sf /bin/sleep $sleep + name="pkill -j " -if [ `id -u` -eq 0 ]; then - sleep=$(pwd)/sleep.txt - ln -sf /bin/sleep $sleep - jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \ - command=daemon -p ${PWD}/${base}_1_1.pid $sleep 5 & +sleep_amount=5 +jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_1_1.pid $sleep $sleep_amount & + +jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_1_2.pid $sleep $sleep_amount & - jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \ - command=daemon -p ${PWD}/${base}_1_2.pid $sleep 5 & +$sleep $sleep_amount & - $sleep 5 & - sleep 0.5 +for i in `seq 1 10`; do jid1=$(jail_name_to_jid ${base}_1_1) jid2=$(jail_name_to_jid ${base}_1_2) jid="${jid1},${jid2}" - if pkill -f -j "$jid" $sleep && sleep 0.5 && - ! -f ${PWD}/${base}_1_1.pid && - ! -f ${PWD}/${base}_1_2.pid ; then - echo "ok 1 - $name" - else - echo "not ok 1 - $name" - fi 2>/dev/null - rm -f $sleep - [ -f ${PWD}/${base}_1_1.pid ] && kill $(cat ${PWD}/${base}_1_1.pid) - [ -f ${PWD}/${base}_1_2.pid ] && kill $(cat ${PWD}/${base}_1_2.pid) - wait + case "$jid" in + [0-9]+,[0-9]+) + break + ;; + esac + sleep 0.1 +done + +if pkill -f -j "$jid" $sleep && sleep 0.5 && + ! -f ${PWD}/${base}_1_1.pid && + ! -f ${PWD}/${base}_1_2.pid ; then + echo "ok 1 - $name" else - echo "ok 1 - $name # skip Test needs uid 0." -fi + echo "not ok 1 - $name" +fi 2>/dev/null +[ -f ${PWD}/${base}_1_1.pid ] && kill $(cat ${PWD}/${base}_1_1.pid) +[ -f ${PWD}/${base}_1_2.pid ] && kill $(cat ${PWD}/${base}_1_2.pid) +wait name="pkill -j any" -if [ `id -u` -eq 0 ]; then - sleep=$(pwd)/sleep.txt - ln -sf /bin/sleep $sleep - jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \ - command=daemon -p ${PWD}/${base}_2_1.pid $sleep 5 & - - jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \ - command=daemon -p ${PWD}/${base}_2_2.pid $sleep 5 & - - $sleep 5 & - sleep 0.5 - chpid3=$! - if pkill -f -j any $sleep && sleep 0.5 && - [ ! -f ${PWD}/${base}_2_1.pid -a - ! -f ${PWD}/${base}_2_2.pid ] && kill $chpid3; then - echo "ok 2 - $name" - else - echo "not ok 2 - $name" - fi 2>/dev/null - rm -f $sleep - [ -f ${PWD}/${base}_2_1.pid ] && kill $(cat ${PWD}/${base}_2_1.pid) - [ -f ${PWD}/${base}_2_2.pid ] && kill $(cat ${PWD}/${base}_2_2.pid) - wait +sleep_amount=6 +jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_2_1.pid $sleep $sleep_amount & + +jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_2_2.pid $sleep $sleep_amount & + +$sleep $sleep_amount & +chpid3=$! +sleep 0.5 +if pkill -f -j any $sleep && sleep 0.5 && + [ ! -f ${PWD}/${base}_2_1.pid -a + ! -f ${PWD}/${base}_2_2.pid ] && kill $chpid3; then + echo "ok 2 - $name" else - echo "ok 2 - $name # skip Test needs uid 0." -fi + echo "not ok 2 - $name" +fi 2>/dev/null +[ -f ${PWD}/${base}_2_1.pid ] && kill $(cat ${PWD}/${base}_2_1.pid) +[ -f ${PWD}/${base}_2_2.pid ] && kill $(cat ${PWD}/${base}_2_2.pid) +wait name="pkill -j none" -if [ `id -u` -eq 0 ]; then - sleep=$(pwd)/sleep.txt - ln -sf /bin/sleep $sleep - daemon -p ${PWD}/${base}_3_1.pid $sleep 5 - jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \ - command=daemon -p ${PWD}/${base}_3_2.pid $sleep 5 & - sleep 1 - if pkill -f -j none "$sleep 5" && sleep 1 && - [ ! -f ${PWD}/${base}_3_1.pid -a -f ${PWD}/${base}_3_2.pid ] ; then - echo "ok 3 - $name" - else - ls ${PWD}/*.pid - echo "not ok 3 - $name" - fi 2>/dev/null - rm -f $sleep - [ -f ${PWD}/${base}_3_1.pid ] && kill $(cat ${base}_3_1.pid) - [ -f ${PWD}/${base}_3_2.pid ] && kill $(cat ${base}_3_2.pid) +sleep_amount=7 +daemon -p ${PWD}/${base}_3_1.pid $sleep $sleep_amount +jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_3_2.pid $sleep $sleep_amount & +sleep 1 +if pkill -f -j none "$sleep $sleep_amount" && sleep 1 && + [ ! -f ${PWD}/${base}_3_1.pid -a -f ${PWD}/${base}_3_2.pid ] ; then + echo "ok 3 - $name" else - echo "ok 3 - $name # skip Test needs uid 0." -fi + ls ${PWD}/*.pid + echo "not ok 3 - $name" +fi 2>/dev/null +[ -f ${PWD}/${base}_3_1.pid ] && kill $(cat ${base}_3_1.pid) +[ -f ${PWD}/${base}_3_2.pid ] && kill $(cat ${base}_3_2.pid) + +rm -f $sleep Modified: user/dchagin/lemul/bin/sh/cd.c ============================================================================== --- user/dchagin/lemul/bin/sh/cd.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/cd.c Wed Feb 18 19:53:56 2015 (r278969) @@ -122,7 +122,7 @@ cdcmd(int argc __unused, char **argv __u (dest[0] == '.' && (dest[1] == '/' || dest[1] == '\0')) || (dest[0] == '.' && dest[1] == '.' && (dest[2] == '/' || dest[2] == '\0')) || (path = bltinlookup("CDPATH", 1)) == NULL) - path = nullstr; + path = ""; while ((p = padvance(&path, dest)) != NULL) { if (stat(p, &statb) < 0) { if (errno != ENOENT) @@ -182,7 +182,6 @@ cdlogical(char *dest) struct stat statb; int first; int badstat; - size_t len; /* * Check each component of the path. If we find a symlink or @@ -190,9 +189,7 @@ cdlogical(char *dest) * next time we get the value of the current directory. */ badstat = 0; - len = strlen(dest); - cdcomppath = stalloc(len + 1); - memcpy(cdcomppath, dest, len + 1); + cdcomppath = stsavestr(dest); STARTSTACKSTR(p); if (*dest == '/') { STPUTC('/', p); @@ -277,7 +274,6 @@ findcwd(char *dir) { char *new; char *p; - size_t len; /* * If our argument is NULL, we don't know the current directory @@ -286,9 +282,7 @@ findcwd(char *dir) */ if (dir == NULL || curdir == NULL) return getpwd2(); - len = strlen(dir); - cdcomppath = stalloc(len + 1); - memcpy(cdcomppath, dir, len + 1); + cdcomppath = stsavestr(dir); STARTSTACKSTR(new); if (*dir != '/') { STPUTS(curdir, new); Modified: user/dchagin/lemul/bin/sh/eval.c ============================================================================== --- user/dchagin/lemul/bin/sh/eval.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/eval.c Wed Feb 18 19:53:56 2015 (r278969) @@ -498,7 +498,7 @@ exphere(union node *redir, struct arglis struct localvar *savelocalvars; int need_longjmp = 0; - redir->nhere.expdoc = nullstr; + redir->nhere.expdoc = ""; savelocalvars = localvars; localvars = NULL; forcelocal++; Modified: user/dchagin/lemul/bin/sh/expand.c ============================================================================== --- user/dchagin/lemul/bin/sh/expand.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/expand.c Wed Feb 18 19:53:56 2015 (r278969) @@ -105,11 +105,12 @@ static void expbackq(union node *, int, static int subevalvar(char *, char *, int, int, int, int, int); static char *evalvar(char *, int); static int varisset(const char *, int); +static void strtodest(const char *, int, int, int); static void varvalue(const char *, int, int, int); static void recordregion(int, int, int); static void removerecordregions(int); static void ifsbreakup(char *, struct arglist *); -static void expandmeta(struct strlist *, int); +static void expandmeta(struct strlist *); static void expmeta(char *, char *); static void addfname(char *); static struct strlist *expsort(struct strlist *); @@ -175,7 +176,7 @@ expandarg(union node *arg, struct arglis ifsbreakup(p, &exparg); *exparg.lastp = NULL; exparg.lastp = &exparg.list; - expandmeta(exparg.list, flag); + expandmeta(exparg.list); } else { sp = (struct strlist *)stalloc(sizeof (struct strlist)); sp->text = p; @@ -298,9 +299,9 @@ exptilde(char *p, int flag) char c, *startp = p; struct passwd *pw; char *home; - int quotes = flag & (EXP_FULL | EXP_CASE); - while ((c = *p) != '\0') { + for (;;) { + c = *p; switch(c) { case CTLESC: /* This means CTL* are always considered quoted. */ case CTLVAR: @@ -311,31 +312,27 @@ exptilde(char *p, int flag) case CTLQUOTEMARK: return (startp); case ':': - if (flag & EXP_VARTILDE) - goto done; - break; + if ((flag & EXP_VARTILDE) == 0) + break; + /* FALLTHROUGH */ + case '\0': case '/': case CTLENDVAR: - goto done; + *p = '\0'; + if (*(startp+1) == '\0') { + home = lookupvar("HOME"); + } else { + pw = getpwnam(startp+1); + home = pw != NULL ? pw->pw_dir : NULL; + } + *p = c; + if (home == NULL || *home == '\0') + return (startp); + strtodest(home, flag, VSNORMAL, 1); + return (p); } p++; } -done: - *p = '\0'; - if (*(startp+1) == '\0') { - home = lookupvar("HOME"); - } else { - pw = getpwnam(startp+1); - home = pw != NULL ? pw->pw_dir : NULL; - } - *p = c; - if (home == NULL || *home == '\0') - return (startp); - if (quotes) - STPUTS_QUOTES(home, DQSYNTAX, expdest); - else - STPUTS(home, expdest); - return (p); } @@ -496,6 +493,17 @@ expbackq(union node *cmd, int quoted, in +static void +recordleft(const char *str, const char *loc, char *startp) +{ + int amount; + + amount = ((str - 1) - (loc - startp)) - expdest; + STADJUST(amount, expdest); + while (loc != str - 1) + *startp++ = *loc++; +} + static int subevalvar(char *p, char *str, int strloc, int subtype, int startloc, int varflags, int quotes) @@ -530,8 +538,7 @@ subevalvar(char *p, char *str, int strlo error((char *)NULL); } error("%.*s: parameter %snot set", (int)(p - str - 1), - str, (varflags & VSNUL) ? "null or " - : nullstr); + str, (varflags & VSNUL) ? "null or " : ""); return 0; case VSTRIMLEFT: @@ -540,7 +547,8 @@ subevalvar(char *p, char *str, int strlo *loc = '\0'; if (patmatch(str, startp, quotes)) { *loc = c; - goto recordleft; + recordleft(str, loc, startp); + return 1; } *loc = c; if (quotes && *loc == CTLESC) @@ -554,7 +562,8 @@ subevalvar(char *p, char *str, int strlo *loc = '\0'; if (patmatch(str, startp, quotes)) { *loc = c; - goto recordleft; + recordleft(str, loc, startp); + return 1; } *loc = c; loc--; @@ -602,13 +611,6 @@ subevalvar(char *p, char *str, int strlo default: abort(); } - -recordleft: - amount = ((str - 1) - (loc - startp)) - expdest; - STADJUST(amount, expdest); - while (loc != str - 1) - *startp++ = *loc++; - return 1; } @@ -633,6 +635,7 @@ evalvar(char *p, int flag) int varlenb; int easy; int quotes = flag & (EXP_FULL | EXP_CASE); + int record; varflags = (unsigned char)*p++; subtype = varflags & VSTYPE; @@ -690,22 +693,15 @@ again: /* jump here after setting a vari STADJUST(-varlenb, expdest); } } else { - char const *syntax = (varflags & VSQUOTE) ? DQSYNTAX - : BASESYNTAX; - if (subtype == VSLENGTH) { for (;*val; val++) if (!localeisutf8 || (*val & 0xC0) != 0x80) varlen++; } - else { - if (quotes) - STPUTS_QUOTES(val, syntax, expdest); - else - STPUTS(val, expdest); - - } + else + strtodest(val, flag, subtype, + varflags & VSQUOTE); } } @@ -719,15 +715,11 @@ again: /* jump here after setting a vari switch (subtype) { case VSLENGTH: expdest = cvtnum(varlen, expdest); - goto record; + record = 1; + break; case VSNORMAL: - if (!easy) - break; -record: - recordregion(startloc, expdest - stackblock(), - varflags & VSQUOTE || (ifsset() && ifsval()[0] == '\0' && - (*var == '@' || *var == '*'))); + record = easy; break; case VSPLUS: @@ -737,8 +729,7 @@ record: (varflags & VSQUOTE ? EXP_LIT_QUOTED : 0)); break; } - if (easy) - goto record; + record = easy; break; case VSTRIMLEFT: @@ -760,7 +751,8 @@ record: } /* Remove any recorded regions beyond start of variable */ removerecordregions(startloc); - goto record; + record = 1; + break; case VSASSIGN: case VSQUESTION: @@ -777,8 +769,7 @@ record: } break; } - if (easy) - goto record; + record = easy; break; case VSERROR: @@ -790,6 +781,11 @@ record: abort(); } + if (record) + recordregion(startloc, expdest - stackblock(), + varflags & VSQUOTE || (ifsset() && ifsval()[0] == '\0' && + (*var == '@' || *var == '*'))); + if (subtype != VSNORMAL) { /* skip to end of alternative */ int nesting = 1; for (;;) { @@ -1093,7 +1089,7 @@ static char expdir[PATH_MAX]; * The results are stored in the list exparg. */ static void -expandmeta(struct strlist *str, int flag __unused) +expandmeta(struct strlist *str) { char *p; struct strlist **savelastp; @@ -1284,11 +1280,8 @@ addfname(char *name) { char *p; struct strlist *sp; - size_t len; - len = strlen(name); - p = stalloc(len + 1); - memcpy(p, name, len + 1); + p = stsavestr(name); sp = (struct strlist *)stalloc(sizeof *sp); sp->text = p; *exparg.lastp = sp; @@ -1478,16 +1471,14 @@ patmatch(const char *pattern, const char endp = p; if (*endp == '!' || *endp == '^') endp++; - for (;;) { + do { while (*endp == CTLQUOTEMARK) endp++; if (*endp == 0) goto dft; /* no matching ] */ if (*endp == CTLESC) endp++; - if (*++endp == ']') - break; - } + } while (*++endp != ']'); invert = 0; if (*p == '!' || *p == '^') { invert++; Modified: user/dchagin/lemul/bin/sh/mail.c ============================================================================== --- user/dchagin/lemul/bin/sh/mail.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/mail.c Wed Feb 18 19:53:56 2015 (r278969) @@ -85,7 +85,7 @@ chkmail(int silent) setstackmark(&smark); mpath = mpathset()? mpathval() : mailval(); for (i = 0 ; i < nmboxes ; i++) { - p = padvance(&mpath, nullstr); + p = padvance(&mpath, ""); if (p == NULL) break; if (*p == '\0') Modified: user/dchagin/lemul/bin/sh/memalloc.c ============================================================================== --- user/dchagin/lemul/bin/sh/memalloc.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/memalloc.c Wed Feb 18 19:53:56 2015 (r278969) @@ -180,6 +180,18 @@ stunalloc(pointer p) } +char * +stsavestr(const char *s) +{ + char *p; + size_t len; + + len = strlen(s); + p = stalloc(len + 1); + memcpy(p, s, len + 1); + return p; +} + void setstackmark(struct stackmark *mark) Modified: user/dchagin/lemul/bin/sh/memalloc.h ============================================================================== --- user/dchagin/lemul/bin/sh/memalloc.h Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/memalloc.h Wed Feb 18 19:53:56 2015 (r278969) @@ -52,6 +52,7 @@ void ckfree(pointer); char *savestr(const char *); pointer stalloc(int); void stunalloc(pointer); +char *stsavestr(const char *); void setstackmark(struct stackmark *); void popstackmark(struct stackmark *); char *growstackstr(void); Modified: user/dchagin/lemul/bin/sh/miscbltin.c ============================================================================== --- user/dchagin/lemul/bin/sh/miscbltin.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/miscbltin.c Wed Feb 18 19:53:56 2015 (r278969) @@ -265,7 +265,7 @@ readcmd(int argc __unused, char **argv _ /* Set any remaining args to "" */ while (*++ap != NULL) - setvar(*ap, nullstr, 0); + setvar(*ap, "", 0); return status; } Modified: user/dchagin/lemul/bin/sh/nodetypes ============================================================================== --- user/dchagin/lemul/bin/sh/nodetypes Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/bin/sh/nodetypes Wed Feb 18 19:53:56 2015 (r278969) @@ -138,7 +138,7 @@ NXHERE nhere # fd<flags & VREADONLY) return (1); if (vp->text[vp->name_len + 1] != '\0') - setvar(s, nullstr, 0); + setvar(s, "", 0); if ((vp->flags & VEXPORT) && localevar(vp->text)) { change_env(s, 0); setlocale(LC_ALL, ""); Modified: user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c ============================================================================== --- user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c Wed Feb 18 19:53:56 2015 (r278969) @@ -36,7 +36,6 @@ #include #include #include -#include /* * In Solaris 10 GA, the only mechanism for communicating helper information @@ -62,9 +61,7 @@ static const char *olddevname = "/device static const char *modname; /* Name of this load object */ static int gen; /* DOF helper generation */ -#ifdef illumos extern dof_hdr_t __SUNW_dof; /* DOF defined in the .SUNW_dof section */ -#endif static boolean_t dof_init_debug = B_FALSE; /* From DTRACE_DOF_INIT_DEBUG */ static void @@ -99,11 +96,7 @@ static void dtrace_dof_init(void) __attr static void dtrace_dof_init(void) { -#ifdef illumos dof_hdr_t *dof = &__SUNW_dof; -#else - dof_hdr_t *dof = NULL; -#endif #ifdef _LP64 Elf64_Ehdr *elf; #else @@ -118,17 +111,6 @@ dtrace_dof_init(void) #endif int fd; const char *p; -#ifndef illumos - Elf *e; - Elf_Scn *scn = NULL; - Elf_Data *dofdata = NULL; - dof_hdr_t *dof_next = NULL; - GElf_Shdr shdr; - int efd; - char *s; - size_t shstridx; - uint64_t aligned_filesz; -#endif if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL) return; @@ -152,42 +134,6 @@ dtrace_dof_init(void) modname = lmp->l_name; else modname++; -#ifndef illumos - elf_version(EV_CURRENT); - if ((efd = open(lmp->l_name, O_RDONLY, 0)) < 0) { - dprintf(1, "couldn't open file for reading\n"); - return; - } - if ((e = elf_begin(efd, ELF_C_READ, NULL)) == NULL) { - dprintf(1, "elf_begin failed\n"); - close(efd); - return; - } - elf_getshdrstrndx(e, &shstridx); - dof = NULL; - while ((scn = elf_nextscn(e, scn)) != NULL) { - gelf_getshdr(scn, &shdr); - if (shdr.sh_type == SHT_SUNW_dof) { - s = elf_strptr(e, shstridx, shdr.sh_name); - if (s != NULL && strcmp(s, ".SUNW_dof") == 0) { - dofdata = elf_getdata(scn, NULL); - dof = dofdata->d_buf; - break; - } - } - } - if (dof == NULL) { - dprintf(1, "SUNW_dof section not found\n"); - elf_end(e); - close(efd); - return; - } - - while ((char *) dof < (char *) dofdata->d_buf + dofdata->d_size) { - aligned_filesz = (shdr.sh_addralign == 0 ? dof->dofh_filesz : - roundup2(dof->dofh_filesz, shdr.sh_addralign)); - dof_next = (void *) ((char *) dof + aligned_filesz); -#endif if (dof->dofh_ident[DOF_ID_MAG0] != DOF_MAG_MAG0 || dof->dofh_ident[DOF_ID_MAG1] != DOF_MAG_MAG1 || @@ -237,21 +183,12 @@ dtrace_dof_init(void) dprintf(1, "DTrace ioctl failed for DOF at %p", dof); else { dprintf(1, "DTrace ioctl succeeded for DOF at %p\n", dof); -#ifndef illumos +#ifdef __FreeBSD__ gen = dh.gen; #endif } (void) close(fd); - -#ifndef illumos - /* End of while loop */ - dof = dof_next; - } - - elf_end(e); - (void) close(efd); -#endif } #ifdef illumos Modified: user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h ============================================================================== --- user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h Wed Feb 18 19:53:56 2015 (r278969) @@ -275,6 +275,9 @@ struct dtrace_hdl { int dt_cpp_argc; /* count of initialized cpp(1) arguments */ int dt_cpp_args; /* size of dt_cpp_argv[] array */ char *dt_ld_path; /* pathname of ld(1) to invoke if needed */ +#ifdef __FreeBSD__ + char *dt_objcopy_path; /* pathname of objcopy(1) to invoke if needed */ +#endif dt_list_t dt_lib_path; /* linked-list forming library search path */ uint_t dt_lazyload; /* boolean: set via -xlazyload */ uint_t dt_droptags; /* boolean: set via -xdroptags */ Modified: user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c ============================================================================== --- user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Wed Feb 18 19:42:37 2015 (r278968) +++ user/dchagin/lemul/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Wed Feb 18 19:53:56 2015 (r278969) @@ -281,7 +281,11 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION_ sym->st_value = 0; sym->st_size = dof->dofh_filesz; sym->st_info = ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT); +#ifdef illumos sym->st_other = 0; +#else + sym->st_other = ELF32_ST_VISIBILITY(STV_HIDDEN); +#endif sym->st_shndx = ESHDR_DOF; sym++; @@ -471,7 +475,11 @@ prepare_elf64(dtrace_hdl_t *dtp, const d sym->st_value = 0; sym->st_size = dof->dofh_filesz; sym->st_info = GELF_ST_INFO(STB_GLOBAL, STT_OBJECT); +#ifdef illumos sym->st_other = 0; +#else + sym->st_other = ELF64_ST_VISIBILITY(STV_HIDDEN); +#endif sym->st_shndx = ESHDR_DOF; sym++; @@ -711,11 +719,7 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_ shp = &elf_file.shdr[ESHDR_DOF]; shp->sh_name = 11; /* DTRACE_SHSTRTAB64[11] = ".SUNW_dof" */ -#ifdef illumos shp->sh_flags = SHF_ALLOC; -#else - shp->sh_flags = SHF_WRITE | SHF_ALLOC; -#endif shp->sh_type = SHT_SUNW_dof; shp->sh_offset = off; shp->sh_size = dof->dofh_filesz; @@ -1874,7 +1878,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, d #endif (void) snprintf(drti, sizeof (drti), "/usr/lib%s/dtrace/drti.o", - use_32 ? "32":""); + use_32 ? "32" : ""); len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, tfile, drti) + 1; @@ -1885,26 +1889,61 @@ dtrace_program_link(dtrace_hdl_t *dtp, d drti); #endif if ((status = system(cmd)) == -1) { - ret = dt_link_error(dtp, NULL, -1, NULL, + ret = dt_link_error(dtp, NULL, fd, NULL, "failed to run %s: %s", dtp->dt_ld_path, strerror(errno)); goto done; } if (WIFSIGNALED(status)) { - ret = dt_link_error(dtp, NULL, -1, NULL, + ret = dt_link_error(dtp, NULL, fd, NULL, "failed to link %s: %s failed due to signal %d", file, dtp->dt_ld_path, WTERMSIG(status)); goto done; } if (WEXITSTATUS(status) != 0) { - ret = dt_link_error(dtp, NULL, -1, NULL, + ret = dt_link_error(dtp, NULL, fd, NULL, "failed to link %s: %s exited with status %d\n", file, dtp->dt_ld_path, WEXITSTATUS(status)); goto done; } (void) close(fd); /* release temporary file */ + +#ifdef __FreeBSD__ + /* + * Now that we've linked drti.o, reduce the global __SUNW_dof + * symbol to a local symbol. This is needed to so that multiple + * generated object files (for different providers, for + * instance) can be linked together. This is accomplished using + * the -Blocal flag with Sun's linker, but GNU ld doesn't appear + * to have an equivalent option. + */ + asprintf(&cmd, "%s --localize-hidden %s", dtp->dt_objcopy_path, + file); + if ((status = system(cmd)) == -1) { + ret = dt_link_error(dtp, NULL, -1, NULL, + "failed to run %s: %s", dtp->dt_objcopy_path, + strerror(errno)); + free(cmd); + goto done; + } + free(cmd); + + if (WIFSIGNALED(status)) { + ret = dt_link_error(dtp, NULL, -1, NULL, + "failed to link %s: %s failed due to signal %d", + file, dtp->dt_objcopy_path, WTERMSIG(status)); + goto done; + } + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Feb 19 09:02:54 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CA8A5195; Thu, 19 Feb 2015 09:02:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B53435FF; Thu, 19 Feb 2015 09:02:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1J92sJd044994; Thu, 19 Feb 2015 09:02:54 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1J92sLm044992; Thu, 19 Feb 2015 09:02:54 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502190902.t1J92sLm044992@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 19 Feb 2015 09:02:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278989 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 19 Feb 2015 09:02:54 -0000 Author: pho Date: Thu Feb 19 09:02:53 2015 New Revision: 278989 URL: https://svnweb.freebsd.org/changeset/base/278989 Log: Do not rely on /usr/src being installed; embed the source for fsx. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/tmpfs5.sh user/pho/stress2/misc/umountf2.sh Modified: user/pho/stress2/misc/tmpfs5.sh ============================================================================== --- user/pho/stress2/misc/tmpfs5.sh Thu Feb 19 06:27:14 2015 (r278988) +++ user/pho/stress2/misc/tmpfs5.sh Thu Feb 19 09:02:53 2015 (r278989) @@ -35,10 +35,10 @@ . ../default.cfg here=`pwd` -src=`uname -v | sed 's/.*:.*:\(.*\)\/sys\/.*/\1/'` -[ -r $src/tools/regression/fsx/fsx.c ] || exit 1 cd /tmp -mycc -o fsx -Wall $src/tools/regression/fsx/fsx.c +sed '1,/^EOF/d' < $here/umountf2.sh > /tmp/fsx.c +mycc -o /tmp/fsx -O2 /tmp/fsx.c || exit 1 +rm -f fsx.c mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint Modified: user/pho/stress2/misc/umountf2.sh ============================================================================== --- user/pho/stress2/misc/umountf2.sh Thu Feb 19 06:27:14 2015 (r278988) +++ user/pho/stress2/misc/umountf2.sh Thu Feb 19 09:02:53 2015 (r278989) @@ -39,11 +39,9 @@ . ../default.cfg -fsxc=`find -x /usr/src -name fsx.c | tail -1` -[ -z "$fsxc" ] && fsxc=`find -x / -name fsx.c | tail -1` -[ -z "$fsxc" ] && exit - -mycc -o /tmp/fsx $fsxc +sed '1,/^EOF/d' < $0 > /tmp/fsx.c +mycc -o /tmp/fsx -O2 /tmp/fsx.c || exit 1 +rm -f fsx.c D=$diskimage dede $D 1m 1k || exit 1 @@ -65,8 +63,1241 @@ for i in `jot 10`; do sleep 30 pgrep -q fsx || break done -pgrep -q fsx && echo FAIL && pkill fsx +if pgrep -q fsx; then + echo FAIL + ps -l $! + pkill fsx +fi sleep 5 wait mdconfig -d -u $mdstart rm -f $D /tmp/fsx +exit 0 +EOF +/* + * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 2.0 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + * + * File: fsx.c + * Author: Avadis Tevanian, Jr. + * + * File system exerciser. + * + * Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com + * + * Various features from Joe Sokol, Pat Dirks, and Clark Warner. + * + * Small changes to work under Linux -- davej@suse.de + * + * Sundry porting patches from Guy Harris 12/2001 + * + * Checks for mmap last-page zero fill. + * + * Updated license to APSL 2.0, 2004/7/27 - Jordan Hubbard + * + * $FreeBSD$ + * + */ + +#include +#include +#ifdef _UWIN +# include +# include +# include +# include +#endif +#include +#include +#ifndef MAP_FILE +# define MAP_FILE 0 +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */ + +/* + * A log entry is an operation and a bunch of arguments. + */ + +struct log_entry { + int operation; + int args[3]; +}; + +#define LOGSIZE 1000 + +struct log_entry oplog[LOGSIZE]; /* the log */ +int logptr = 0; /* current position in log */ +int logcount = 0; /* total ops */ + +/* + * Define operations + */ + +#define OP_READ 1 +#define OP_WRITE 2 +#define OP_TRUNCATE 3 +#define OP_CLOSEOPEN 4 +#define OP_MAPREAD 5 +#define OP_MAPWRITE 6 +#define OP_SKIPPED 7 +#define OP_INVALIDATE 8 + +int page_size; +int page_mask; + +char *original_buf; /* a pointer to the original data */ +char *good_buf; /* a pointer to the correct data */ +char *temp_buf; /* a pointer to the current data */ +char *fname; /* name of our test file */ +int fd; /* fd for our test file */ + +off_t file_size = 0; +off_t biggest = 0; +char state[256]; +unsigned long testcalls = 0; /* calls to function "test" */ + +unsigned long simulatedopcount = 0; /* -b flag */ +int closeprob = 0; /* -c flag */ +int invlprob = 0; /* -i flag */ +int debug = 0; /* -d flag */ +unsigned long debugstart = 0; /* -D flag */ +unsigned long maxfilelen = 256 * 1024; /* -l flag */ +int sizechecks = 1; /* -n flag disables them */ +int maxoplen = 64 * 1024; /* -o flag */ +int quiet = 0; /* -q flag */ +unsigned long progressinterval = 0; /* -p flag */ +int readbdy = 1; /* -r flag */ +int style = 0; /* -s flag */ +int truncbdy = 1; /* -t flag */ +int writebdy = 1; /* -w flag */ +long monitorstart = -1; /* -m flag */ +long monitorend = -1; /* -m flag */ +int lite = 0; /* -L flag */ +long numops = -1; /* -N flag */ +int randomoplen = 1; /* -O flag disables it */ +int seed = 1; /* -S flag */ +int mapped_writes = 1; /* -W flag disables */ +int mapped_reads = 1; /* -R flag disables it */ +int mapped_msync = 1; /* -U flag disables */ +int fsxgoodfd = 0; +FILE * fsxlogf = NULL; +int badoff = -1; +int closeopen = 0; +int invl = 0; + + +void +vwarnc(code, fmt, ap) + int code; + const char *fmt; + va_list ap; +{ + fprintf(stderr, "fsx: "); + if (fmt != NULL) { + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": "); + } + fprintf(stderr, "%s\n", strerror(code)); +} + + +void +warn(const char * fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vwarnc(errno, fmt, ap); + va_end(ap); +} + + +void +prt(char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vfprintf(stdout, fmt, args); + va_end(args); + + if (fsxlogf) { + va_start(args, fmt); + vfprintf(fsxlogf, fmt, args); + va_end(args); + } +} + +void +prterr(char *prefix) +{ + prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno)); +} + + +void +do_log4(int operation, int arg0, int arg1, int arg2) +{ + struct log_entry *le; + + le = &oplog[logptr]; + le->operation = operation; + le->args[0] = arg0; + le->args[1] = arg1; + le->args[2] = arg2; + logptr++; + logcount++; + if (logptr >= LOGSIZE) + logptr = 0; +} + + +void +log4(int operation, int arg0, int arg1, int arg2) +{ + do_log4(operation, arg0, arg1, arg2); + if (closeopen) + do_log4(OP_CLOSEOPEN, 0, 0, 0); + if (invl) + do_log4(OP_INVALIDATE, 0, 0, 0); +} + + +void +logdump(void) +{ + struct log_entry *lp; + int i, count, down, opnum; + + prt("LOG DUMP (%d total operations):\n", logcount); + if (logcount < LOGSIZE) { + i = 0; + count = logcount; + } else { + i = logptr; + count = LOGSIZE; + } + + opnum = i + 1 + (logcount/LOGSIZE)*LOGSIZE; + for ( ; count > 0; count--) { + lp = &oplog[i]; + + if (lp->operation == OP_CLOSEOPEN || + lp->operation == OP_INVALIDATE) { + switch (lp->operation) { + case OP_CLOSEOPEN: + prt("\t\tCLOSE/OPEN\n"); + break; + case OP_INVALIDATE: + prt("\t\tMS_INVALIDATE\n"); + break; + } + i++; + if (i == LOGSIZE) + i = 0; + continue; + } + + prt("%d(%d mod 256): ", opnum, opnum%256); + switch (lp->operation) { + case OP_MAPREAD: + prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1]); + if (badoff >= lp->args[0] && badoff < + lp->args[0] + lp->args[1]) + prt("\t***RRRR***"); + break; + case OP_MAPWRITE: + prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1]); + if (badoff >= lp->args[0] && badoff < + lp->args[0] + lp->args[1]) + prt("\t******WWWW"); + break; + case OP_READ: + prt("READ\t0x%x thru 0x%x\t(0x%x bytes)", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1]); + if (badoff >= lp->args[0] && + badoff < lp->args[0] + lp->args[1]) + prt("\t***RRRR***"); + break; + case OP_WRITE: + prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)", + lp->args[0], lp->args[0] + lp->args[1] - 1, + lp->args[1]); + if (lp->args[0] > lp->args[2]) + prt(" HOLE"); + else if (lp->args[0] + lp->args[1] > lp->args[2]) + prt(" EXTEND"); + if ((badoff >= lp->args[0] || badoff >=lp->args[2]) && + badoff < lp->args[0] + lp->args[1]) + prt("\t***WWWW"); + break; + case OP_TRUNCATE: + down = lp->args[0] < lp->args[1]; + prt("TRUNCATE %s\tfrom 0x%x to 0x%x", + down ? "DOWN" : "UP", lp->args[1], lp->args[0]); + if (badoff >= lp->args[!down] && + badoff < lp->args[!!down]) + prt("\t******WWWW"); + break; + case OP_SKIPPED: + prt("SKIPPED (no operation)"); + break; + default: + prt("BOGUS LOG ENTRY (operation code = %d)!", + lp->operation); + } + prt("\n"); + opnum++; + i++; + if (i == LOGSIZE) + i = 0; + } +} + + +void +save_buffer(char *buffer, off_t bufferlength, int fd) +{ + off_t ret; + ssize_t byteswritten; + + if (fd <= 0 || bufferlength == 0) + return; + + if (bufferlength > SSIZE_MAX) { + prt("fsx flaw: overflow in save_buffer\n"); + exit(67); + } + if (lite) { + off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END); + if (size_by_seek == (off_t)-1) + prterr("save_buffer: lseek eof"); + else if (bufferlength > size_by_seek) { + warn("save_buffer: .fsxgood file too short... will save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek, + (unsigned long long)bufferlength); + bufferlength = size_by_seek; + } + } + + ret = lseek(fd, (off_t)0, SEEK_SET); + if (ret == (off_t)-1) + prterr("save_buffer: lseek 0"); + + byteswritten = write(fd, buffer, (size_t)bufferlength); + if (byteswritten != bufferlength) { + if (byteswritten == -1) + prterr("save_buffer write"); + else + warn("save_buffer: short write, 0x%x bytes instead of 0x%llx\n", + (unsigned)byteswritten, + (unsigned long long)bufferlength); + } +} + + +void +report_failure(int status) +{ + logdump(); + + if (fsxgoodfd) { + if (good_buf) { + save_buffer(good_buf, file_size, fsxgoodfd); + prt("Correct content saved for comparison\n"); + prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n", + fname, fname); + } + close(fsxgoodfd); + } + exit(status); +} + + +#define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \ + *(((unsigned char *)(cp)) + 1))) + +void +check_buffers(unsigned offset, unsigned size) +{ + unsigned char c, t; + unsigned i = 0; + unsigned n = 0; + unsigned op = 0; + unsigned bad = 0; + + if (memcmp(good_buf + offset, temp_buf, size) != 0) { + prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n", + offset, size); + prt("OFFSET\tGOOD\tBAD\tRANGE\n"); + while (size > 0) { + c = good_buf[offset]; + t = temp_buf[i]; + if (c != t) { + if (n == 0) { + bad = short_at(&temp_buf[i]); + prt("0x%5x\t0x%04x\t0x%04x", offset, + short_at(&good_buf[offset]), bad); + op = temp_buf[offset & 1 ? i+1 : i]; + } + n++; + badoff = offset; + } + offset++; + i++; + size--; + } + if (n) { + prt("\t0x%5x\n", n); + if (bad) + prt("operation# (mod 256) for the bad data may be %u\n", ((unsigned)op & 0xff)); + else + prt("operation# (mod 256) for the bad data unknown, check HOLE and EXTEND ops\n"); + } else + prt("????????????????\n"); + report_failure(110); + } +} + + +void +check_size(void) +{ + struct stat statbuf; + off_t size_by_seek; + + if (fstat(fd, &statbuf)) { + prterr("check_size: fstat"); + statbuf.st_size = -1; + } + size_by_seek = lseek(fd, (off_t)0, SEEK_END); + if (file_size != statbuf.st_size || file_size != size_by_seek) { + prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n", + (unsigned long long)file_size, + (unsigned long long)statbuf.st_size, + (unsigned long long)size_by_seek); + report_failure(120); + } +} + + +void +check_trunc_hack(void) +{ + struct stat statbuf; + + ftruncate(fd, (off_t)0); + ftruncate(fd, (off_t)100000); + fstat(fd, &statbuf); + if (statbuf.st_size != (off_t)100000) { + prt("no extend on truncate! not posix!\n"); + exit(130); + } + ftruncate(fd, (off_t)0); +} + + +void +doread(unsigned offset, unsigned size) +{ + off_t ret; + unsigned iret; + + offset -= offset % readbdy; + if (size == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero size read\n"); + log4(OP_SKIPPED, OP_READ, offset, size); + return; + } + if (size + offset > file_size) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping seek/read past end of file\n"); + log4(OP_SKIPPED, OP_READ, offset, size); + return; + } + + log4(OP_READ, offset, size, 0); + + if (testcalls <= simulatedopcount) + return; + + if (!quiet && ((progressinterval && + testcalls % progressinterval == 0) || + (debug && + (monitorstart == -1 || + (offset + size > monitorstart && + (monitorend == -1 || offset <= monitorend)))))) + prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, + offset, offset + size - 1, size); + ret = lseek(fd, (off_t)offset, SEEK_SET); + if (ret == (off_t)-1) { + prterr("doread: lseek"); + report_failure(140); + } + iret = read(fd, temp_buf, size); + if (iret != size) { + if (iret == -1) + prterr("doread: read"); + else + prt("short read: 0x%x bytes instead of 0x%x\n", + iret, size); + report_failure(141); + } + check_buffers(offset, size); +} + + +void +check_eofpage(char *s, unsigned offset, char *p, int size) +{ + uintptr_t last_page, should_be_zero; + + if (offset + size <= (file_size & ~page_mask)) + return; + /* + * we landed in the last page of the file + * test to make sure the VM system provided 0's + * beyond the true end of the file mapping + * (as required by mmap def in 1996 posix 1003.1) + */ + last_page = ((uintptr_t)p + (offset & page_mask) + size) & ~page_mask; + + for (should_be_zero = last_page + (file_size & page_mask); + should_be_zero < last_page + page_size; + should_be_zero++) + if (*(char *)should_be_zero) { + prt("Mapped %s: non-zero data past EOF (0x%llx) page offset 0x%x is 0x%04x\n", + s, file_size - 1, should_be_zero & page_mask, + short_at(should_be_zero)); + report_failure(205); + } +} + + +void +domapread(unsigned offset, unsigned size) +{ + unsigned pg_offset; + unsigned map_size; + char *p; + + offset -= offset % readbdy; + if (size == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero size read\n"); + log4(OP_SKIPPED, OP_MAPREAD, offset, size); + return; + } + if (size + offset > file_size) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping seek/read past end of file\n"); + log4(OP_SKIPPED, OP_MAPREAD, offset, size); + return; + } + + log4(OP_MAPREAD, offset, size, 0); + + if (testcalls <= simulatedopcount) + return; + + if (!quiet && ((progressinterval && + testcalls % progressinterval == 0) || + (debug && + (monitorstart == -1 || + (offset + size > monitorstart && + (monitorend == -1 || offset <= monitorend)))))) + prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, + offset, offset + size - 1, size); + + pg_offset = offset & page_mask; + map_size = pg_offset + size; + + if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd, + (off_t)(offset - pg_offset))) == (char *)-1) { + prterr("domapread: mmap"); + report_failure(190); + } + memcpy(temp_buf, p + pg_offset, size); + + check_eofpage("Read", offset, p, size); + + if (munmap(p, map_size) != 0) { + prterr("domapread: munmap"); + report_failure(191); + } + + check_buffers(offset, size); +} + + +void +gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size) +{ + while (size--) { + good_buf[offset] = testcalls % 256; + if (offset % 2) + good_buf[offset] += original_buf[offset]; + offset++; + } +} + + +void +dowrite(unsigned offset, unsigned size) +{ + off_t ret; + unsigned iret; + + offset -= offset % writebdy; + if (size == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero size write\n"); + log4(OP_SKIPPED, OP_WRITE, offset, size); + return; + } + + log4(OP_WRITE, offset, size, file_size); + + gendata(original_buf, good_buf, offset, size); + if (file_size < offset + size) { + if (file_size < offset) + memset(good_buf + file_size, '\0', offset - file_size); + file_size = offset + size; + if (lite) { + warn("Lite file size bug in fsx!"); + report_failure(149); + } + } + + if (testcalls <= simulatedopcount) + return; + + if (!quiet && ((progressinterval && + testcalls % progressinterval == 0) || + (debug && + (monitorstart == -1 || + (offset + size > monitorstart && + (monitorend == -1 || offset <= monitorend)))))) + prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, + offset, offset + size - 1, size); + ret = lseek(fd, (off_t)offset, SEEK_SET); + if (ret == (off_t)-1) { + prterr("dowrite: lseek"); + report_failure(150); + } + iret = write(fd, good_buf + offset, size); + if (iret != size) { + if (iret == -1) + prterr("dowrite: write"); + else + prt("short write: 0x%x bytes instead of 0x%x\n", + iret, size); + report_failure(151); + } +} + + +void +domapwrite(unsigned offset, unsigned size) +{ + unsigned pg_offset; + unsigned map_size; + off_t cur_filesize; + char *p; + + offset -= offset % writebdy; + if (size == 0) { + if (!quiet && testcalls > simulatedopcount) + prt("skipping zero size write\n"); + log4(OP_SKIPPED, OP_MAPWRITE, offset, size); + return; + } + cur_filesize = file_size; + + log4(OP_MAPWRITE, offset, size, 0); + + gendata(original_buf, good_buf, offset, size); + if (file_size < offset + size) { + if (file_size < offset) + memset(good_buf + file_size, '\0', offset - file_size); + file_size = offset + size; + if (lite) { + warn("Lite file size bug in fsx!"); + report_failure(200); + } + } + + if (testcalls <= simulatedopcount) + return; + + if (!quiet && ((progressinterval && + testcalls % progressinterval == 0) || + (debug && + (monitorstart == -1 || + (offset + size > monitorstart && + (monitorend == -1 || offset <= monitorend)))))) + prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, + offset, offset + size - 1, size); + + if (file_size > cur_filesize) { + if (ftruncate(fd, file_size) == -1) { + prterr("domapwrite: ftruncate"); + exit(201); + } + } + pg_offset = offset & page_mask; + map_size = pg_offset + size; + + if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE, + MAP_FILE | MAP_SHARED, fd, + (off_t)(offset - pg_offset))) == MAP_FAILED) { + prterr("domapwrite: mmap"); + report_failure(202); + } + memcpy(p + pg_offset, good_buf + offset, size); + if (mapped_msync && msync(p, map_size, MS_SYNC) != 0) { + prterr("domapwrite: msync"); + report_failure(203); + } + + check_eofpage("Write", offset, p, size); + + if (munmap(p, map_size) != 0) { + prterr("domapwrite: munmap"); + report_failure(204); + } +} + + +void +dotruncate(unsigned size) +{ + int oldsize = file_size; + + size -= size % truncbdy; + if (size > biggest) { + biggest = size; + if (!quiet && testcalls > simulatedopcount) + prt("truncating to largest ever: 0x%x\n", size); + } + + log4(OP_TRUNCATE, size, (unsigned)file_size, 0); + + if (size > file_size) + memset(good_buf + file_size, '\0', size - file_size); + file_size = size; + + if (testcalls <= simulatedopcount) + return; + + if ((progressinterval && testcalls % progressinterval == 0) || + (debug && (monitorstart == -1 || monitorend == -1 || + size <= monitorend))) + prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size); + if (ftruncate(fd, (off_t)size) == -1) { + prt("ftruncate1: %x\n", size); + prterr("dotruncate: ftruncate"); + report_failure(160); + } +} + + +void +writefileimage() +{ + ssize_t iret; + + if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) { + prterr("writefileimage: lseek"); + report_failure(171); + } + iret = write(fd, good_buf, file_size); + if ((off_t)iret != file_size) { + if (iret == -1) + prterr("writefileimage: write"); + else + prt("short write: 0x%x bytes instead of 0x%llx\n", + iret, (unsigned long long)file_size); + report_failure(172); + } + if (lite ? 0 : ftruncate(fd, file_size) == -1) { + prt("ftruncate2: %llx\n", (unsigned long long)file_size); + prterr("writefileimage: ftruncate"); + report_failure(173); + } +} + + +void +docloseopen(void) +{ + if (testcalls <= simulatedopcount) + return; + + if (debug) + prt("%lu close/open\n", testcalls); + if (close(fd)) { + prterr("docloseopen: close"); + report_failure(180); + } + fd = open(fname, O_RDWR, 0); + if (fd < 0) { + prterr("docloseopen: open"); + report_failure(181); + } +} + + +void +doinvl(void) +{ + char *p; + + if (file_size == 0) + return; + if (testcalls <= simulatedopcount) + return; + if (debug) + prt("%lu msync(MS_INVALIDATE)\n", testcalls); + + if ((p = (char *)mmap(0, file_size, PROT_READ | PROT_WRITE, + MAP_FILE | MAP_SHARED, fd, 0)) == MAP_FAILED) { + prterr("doinvl: mmap"); + report_failure(205); + } + + if (msync(p, 0, MS_SYNC | MS_INVALIDATE) != 0) { + prterr("doinvl: msync"); + report_failure(206); + } + + if (munmap(p, file_size) != 0) { + prterr("doinvl: munmap"); + report_failure(207); + } +} + + +void +test(void) +{ + unsigned long offset; + unsigned long size = maxoplen; + unsigned long rv = random(); + unsigned long op = rv % (3 + !lite + mapped_writes); + + /* turn off the map read if necessary */ + + if (op == 2 && !mapped_reads) + op = 0; + + if (simulatedopcount > 0 && testcalls == simulatedopcount) + writefileimage(); + + testcalls++; + + if (closeprob) + closeopen = (rv >> 3) < (1 << 28) / closeprob; + if (invlprob) + invl = (rv >> 3) < (1 << 28) / invlprob; + + if (debugstart > 0 && testcalls >= debugstart) + debug = 1; + + if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0) + prt("%lu...\n", testcalls); + + /* + * READ: op = 0 + * WRITE: op = 1 + * MAPREAD: op = 2 + * TRUNCATE: op = 3 + * MAPWRITE: op = 3 or 4 + */ + if (lite ? 0 : op == 3 && style == 0) /* vanilla truncate? */ + dotruncate(random() % maxfilelen); + else { + if (randomoplen) + size = random() % (maxoplen+1); + if (lite ? 0 : op == 3) + dotruncate(size); + else { + offset = random(); + if (op == 1 || op == (lite ? 3 : 4)) { + offset %= maxfilelen; + if (offset + size > maxfilelen) + size = maxfilelen - offset; + if (op != 1) + domapwrite(offset, size); + else + dowrite(offset, size); + } else { + if (file_size) + offset %= file_size; + else + offset = 0; + if (offset + size > file_size) + size = file_size - offset; + if (op != 0) + domapread(offset, size); + else + doread(offset, size); + } + } + } + if (sizechecks && testcalls > simulatedopcount) + check_size(); + if (invl) + doinvl(); + if (closeopen) + docloseopen(); +} + + +void +cleanup(sig) + int sig; +{ + if (sig) + prt("signal %d\n", sig); + prt("testcalls = %lu\n", testcalls); + exit(sig); +} + + +void +usage(void) +{ + fprintf(stdout, "usage: %s", + "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ + -b opnum: beginning operation number (default 1)\n\ + -c P: 1 in P chance of file close+open at each op (default infinity)\n\ + -d: debug output for all operations\n\ + -i P: 1 in P chance of calling msync(MS_INVALIDATE) (default infinity)\n\ + -l flen: the upper bound on file size (default 262144)\n\ + -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\ + -n: no verifications of file size\n\ + -o oplen: the upper bound on operation size (default 65536)\n\ + -p progressinterval: debug output at specified operation interval\n\ + -q: quieter operation\n\ + -r readbdy: 4096 would make reads page aligned (default 1)\n\ + -s style: 1 gives smaller truncates (default 0)\n\ + -t truncbdy: 4096 would make truncates page aligned (default 1)\n\ + -w writebdy: 4096 would make writes page aligned (default 1)\n\ + -D startingop: debug output starting at specified operation\n\ + -L: fsxLite - no file creations & no file size changes\n\ + -N numops: total # operations to do (default infinity)\n\ + -O: use oplen (see -o flag) for every op (default random)\n\ + -P dirpath: save .fsxlog and .fsxgood files in dirpath (default ./)\n\ + -S seed: for random # generator (default 1) 0 gets timestamp\n\ + -W: mapped write operations DISabled\n\ + -R: mapped read operations DISabled)\n\ + -U: msync after mapped write operations DISabled\n\ + fname: this filename is REQUIRED (no default)\n"); + exit(90); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Feb 19 10:28:23 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C2D6E8D6; Thu, 19 Feb 2015 10:28:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE31AECA; Thu, 19 Feb 2015 10:28:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JASNte083378; Thu, 19 Feb 2015 10:28:23 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JASNuO083376; Thu, 19 Feb 2015 10:28:23 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502191028.t1JASNuO083376@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 19 Feb 2015 10:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r278991 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 19 Feb 2015 10:28:23 -0000 Author: pho Date: Thu Feb 19 10:28:22 2015 New Revision: 278991 URL: https://svnweb.freebsd.org/changeset/base/278991 Log: Added two more core dump test scenarios. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/core2.sh (contents, props changed) user/pho/stress2/misc/core3.sh (contents, props changed) Added: user/pho/stress2/misc/core2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/core2.sh Thu Feb 19 10:28:22 2015 (r278991) @@ -0,0 +1,95 @@ +#!/bin/sh + +# +# Copyright (c) 2013 EMC Corp. +# 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$ +# + +# Test multiple (parallel) core dumps and umount + +. ../default.cfg + +odir=`pwd` + +cd /tmp +sed '1,/^EOF/d' < $odir/$0 > core2.c +mycc -o core2 -Wall -Wextra -O0 core2.c || exit 1 +rm -f core2.c +cd $RUNDIR + +mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint +[ -c /dev/mn$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint + +touch /tmp/continue +for i in `jot 64`; do + mkdir -p $mntpoint/d$i + (cd $mntpoint; /tmp/core2) & +done +rm -f /tmp/continue + +for i in `jot 60`; do + umount $mntpoint 2>/dev/null || sleep 1 + mount | grep -q "on $mntpoint " || break +done +mount | grep -q "on $mntpoint " && + umount -f $mntpoint +mdconfig -d -u $mdstart +rm -f core2 +exit +EOF +#include + +#include +#include +#include +#include +#include +#include +#include + +#define SIZ 1L * 128 * 1024 * 1024 + +void *p; + +int +main(void) +{ + size_t len; + + len = SIZ; + p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + + while (access("/tmp/continue", R_OK) == 0) + usleep(1); + + raise(SIGSEGV); + + return (0); +} Added: user/pho/stress2/misc/core3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/core3.sh Thu Feb 19 10:28:22 2015 (r278991) @@ -0,0 +1,151 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +# Test multiple (parallel) core dumps and mount / umount. +# mount(8) stuck in "ufs" or "tmpfs". +# http://people.freebsd.org/~pho/stress/log/kostik724.txt +# Fixed by r272535. +# On i386 pgrep(1) loops. Fixed by r272566. + +. ../default.cfg + +odir=`pwd` + +cd /tmp +sed '1,/^EOF/d' < $odir/$0 > core3.c +mycc -o core3 -Wall -Wextra -O2 core3.c || exit 1 +rm -f core3.c +cd $odir + +mount | grep -q "on $mntpoint " && umount $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +chmod 755 /mnt +mount /dev/md${mdstart}$part $mntpoint +mkdir $mntpoint/d +chmod 777 $mntpoint/d + +su $testuser -c "/tmp/core3 $mntpoint/d" & +sleep 1 + +while pgrep -q core3; do + [ -d $mntpoint/d ] && + umount -f $mntpoint +done > /dev/null 2>&1 & +while pgrep -q core3; do + [ -d $mntpoint/d ] || + mount /dev/md${mdstart}$part $mntpoint +done > /dev/null 2>&1 +wait +mount | grep -q "on $mntpoint " && + umount -f $mntpoint +mdconfig -d -u $mdstart + +# tmpfs +mount -t tmpfs tmpfs $mntpoint +su $testuser -c "/tmp/core3 $mntpoint/d" & +sleep 1 + +while pgrep -q core3; do + [ -d $mntpoint/d ] && + umount -f $mntpoint +done & +while pgrep -q core3; do + if [ ! -d $mntpoint/d ]; then + mount -t tmpfs tmpfs $mntpoint + mkdir $mntpoint/d + fi +done +wait +mount | grep -q "on $mntpoint " && + umount -f $mntpoint + +rm -f core3 +exit +EOF +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define PARALLEL 64 +#define SIZ (4 * 1024 * 1024) + +void *p; + +void +test(char *argv[]) +{ + size_t len; + + len = SIZ; + p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + + /* + * This loop caused mount to wait in "ufs". + * Adding a usleep(200) would remove the hang. + */ + while (chdir(argv[1]) == -1) + ; + + raise(SIGSEGV); + + _exit(0); +} + +int +main(int argc, char *argv[]) +{ + time_t start; + int i; + + if (argc != 2) + errx(1, "Usage: %s ", argv[0]); + + start = time(NULL); + while (time(NULL) - start < 600) { + for (i = 0; i < PARALLEL; i++) { + if (fork() == 0) + test(argv); + } + for (i = 0; i < PARALLEL; i++) + wait(NULL); + } + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Fri Feb 20 05:17:26 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9A418DF8; Fri, 20 Feb 2015 05:17:26 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8453DF57; Fri, 20 Feb 2015 05:17:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1K5HQlE034579; Fri, 20 Feb 2015 05:17:26 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1K5HOK6034568; Fri, 20 Feb 2015 05:17:24 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502200517.t1K5HOK6034568@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Fri, 20 Feb 2015 05:17:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279040 - in user/nwhitehorn/ppc64-pmap-rework: aim conf ps3 pseries X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 20 Feb 2015 05:17:26 -0000 Author: nwhitehorn Date: Fri Feb 20 05:17:24 2015 New Revision: 279040 URL: https://svnweb.freebsd.org/changeset/base/279040 Log: Rearrange handling of reference and changed bits from pages leaving the page table either by unset or eviction so that the page table methods don't need to keep any state at all. This is helpful for some hypervisors that do not allow you to read the mapped real address of a given page table entry when removing it. This enables porting the PS3 MMU code to the new framework (compile-tested only). Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.h user/nwhitehorn/ppc64-pmap-rework/aim/moea64_if.m user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Fri Feb 20 02:43:08 2015 (r279039) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Fri Feb 20 05:17:24 2015 (r279040) @@ -420,18 +420,6 @@ moea64_pte_from_pvo(const struct pvo_ent lpte->pte_lo |= LPTE_NOEXEC; } -void -moea64_sync_refchg(uint64_t lpte_lo) -{ - vm_page_t pg; - - pg = PHYS_TO_VM_PAGE(lpte_lo & LPTE_RPGN); - if (pg == NULL || (pg->oflags & VPO_UNMANAGED)) - return; - - atomic_set_32(&pg->md.mdpg_attrs, lpte_lo & (LPTE_REF | LPTE_CHG)); -} - static __inline uint64_t moea64_calc_wimg(vm_offset_t pa, vm_memattr_t ma) { @@ -963,7 +951,7 @@ moea64_late_bootstrap(mmu_t mmup, vm_off /* * Allocate some things for page zeroing. We put this directly - * in the page table and use MOEA64_PTE_REPLACE to avoid + * in the page table and use MOEA64_PTE_REPLACE to avoid any * of the PVO book-keeping or other parts of the VM system * from even knowing that this hack exists. */ @@ -1020,6 +1008,8 @@ void moea64_unwire(mmu_t mmu, pmap_t pm, vm_offset_t sva, vm_offset_t eva) { struct pvo_entry key, *pvo; + vm_page_t m; + int64_t refchg; key.pvo_vaddr = sva; PMAP_LOCK(pm); @@ -1030,7 +1020,19 @@ moea64_unwire(mmu_t mmu, pmap_t pm, vm_o panic("moea64_unwire: pvo %p is missing PVO_WIRED", pvo); pvo->pvo_vaddr &= ~PVO_WIRED; - MOEA64_PTE_REPLACE(mmu, pvo, 0 /* Doesn't need invalidation */); + refchg = MOEA64_PTE_REPLACE(mmu, pvo, 0 /* No invalidation */); + if ((pvo->pvo_vaddr & PVO_MANAGED) && + (pvo->pvo_pte.prot & VM_PROT_WRITE)) { + if (refchg < 0) + refchg = LPTE_CHG; + m = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN); + + refchg |= atomic_readandclear_32(&m->md.mdpg_attrs); + if (refchg & LPTE_CHG) + vm_page_dirty(m); + if (refchg & LPTE_REF) + vm_page_aflag_set(m, PGA_REFERENCED); + } pm->pm_stats.wired_count--; } PMAP_UNLOCK(pm); @@ -1567,6 +1569,7 @@ void moea64_remove_write(mmu_t mmu, vm_page_t m) { struct pvo_entry *pvo; + int64_t refchg, ret; pmap_t pmap; KASSERT((m->oflags & VPO_UNMANAGED) == 0, @@ -1582,19 +1585,24 @@ moea64_remove_write(mmu_t mmu, vm_page_t return; powerpc_sync(); PV_PAGE_LOCK(m); + refchg = 0; LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) { pmap = pvo->pvo_pmap; PMAP_LOCK(pmap); if (!(pvo->pvo_vaddr & PVO_DEAD) && (pvo->pvo_pte.prot & VM_PROT_WRITE)) { pvo->pvo_pte.prot &= ~VM_PROT_WRITE; - MOEA64_PTE_REPLACE(mmu, pvo, MOEA64_PTE_PROT_UPDATE); + ret = MOEA64_PTE_REPLACE(mmu, pvo, + MOEA64_PTE_PROT_UPDATE); + if (ret < 0) + ret = LPTE_CHG; + refchg |= ret; if (pvo->pvo_pmap == kernel_pmap) isync(); } PMAP_UNLOCK(pmap); } - if (atomic_readandclear_32(&m->md.mdpg_attrs) & LPTE_CHG) + if ((refchg | atomic_readandclear_32(&m->md.mdpg_attrs)) & LPTE_CHG) vm_page_dirty(m); vm_page_aflag_clear(m, PGA_WRITEABLE); PV_PAGE_UNLOCK(m); @@ -1628,6 +1636,7 @@ void moea64_page_set_memattr(mmu_t mmu, vm_page_t m, vm_memattr_t ma) { struct pvo_entry *pvo; + int64_t refchg; pmap_t pmap; uint64_t lo; @@ -1645,7 +1654,20 @@ moea64_page_set_memattr(mmu_t mmu, vm_pa if (!(pvo->pvo_vaddr & PVO_DEAD)) { pvo->pvo_pte.pa &= ~LPTE_WIMG; pvo->pvo_pte.pa |= lo; - MOEA64_PTE_REPLACE(mmu, pvo, MOEA64_PTE_INVALIDATE); + refchg = MOEA64_PTE_REPLACE(mmu, pvo, + MOEA64_PTE_INVALIDATE); + if (refchg < 0) + refchg = (pvo->pvo_pte.prot & VM_PROT_WRITE) ? + LPTE_CHG : 0; + if ((pvo->pvo_vaddr & PVO_MANAGED) && + (pvo->pvo_pte.prot & VM_PROT_WRITE)) { + refchg |= + atomic_readandclear_32(&m->md.mdpg_attrs); + if (refchg & LPTE_CHG) + vm_page_dirty(m); + if (refchg & LPTE_REF) + vm_page_aflag_set(m, PGA_REFERENCED); + } if (pvo->pvo_pmap == kernel_pmap) isync(); } @@ -1935,7 +1957,9 @@ moea64_pvo_protect(mmu_t mmu, pmap_t pm /* * If the PVO is in the page table, update mapping */ - MOEA64_PTE_REPLACE(mmu, pvo, MOEA64_PTE_PROT_UPDATE); + refchg = MOEA64_PTE_REPLACE(mmu, pvo, MOEA64_PTE_PROT_UPDATE); + if (refchg < 0) + refchg = (oldprot & VM_PROT_WRITE) ? LPTE_CHG : 0; if (pm != kernel_pmap && pg != NULL && !(pg->aflags & PGA_EXECUTABLE) && (pvo->pvo_pte.pa & (LPTE_I | LPTE_G | LPTE_NOEXEC)) == 0) { @@ -1950,8 +1974,8 @@ moea64_pvo_protect(mmu_t mmu, pmap_t pm * removed write access. */ if (pg != NULL && (pvo->pvo_vaddr & PVO_MANAGED) && - (oldprot & VM_PROT_WRITE) && !(prot & VM_PROT_WRITE)) { - refchg = atomic_readandclear_32(&pg->md.mdpg_attrs); + (oldprot & VM_PROT_WRITE)) { + refchg |= atomic_readandclear_32(&pg->md.mdpg_attrs); if (refchg & LPTE_CHG) vm_page_dirty(pg); if (refchg & LPTE_REF) @@ -2274,7 +2298,17 @@ moea64_pvo_remove_from_pmap(mmu_t mmu, s /* * If there is an active pte entry, we need to deactivate it */ - MOEA64_PTE_UNSET(mmu, pvo); + refchg = MOEA64_PTE_UNSET(mmu, pvo); + if (refchg < 0) { + /* + * If it was evicted from the page table, be pessimistic and + * dirty the page. + */ + if (pvo->pvo_pte.prot & VM_PROT_WRITE) + refchg = LPTE_CHG; + else + refchg = 0; + } /* * Update our statistics. @@ -2298,7 +2332,7 @@ moea64_pvo_remove_from_pmap(mmu_t mmu, s (pvo->pvo_pte.prot & VM_PROT_WRITE)) { pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pa & LPTE_RPGN); if (pg != NULL) { - refchg = atomic_readandclear_32(&pg->md.mdpg_attrs); + refchg |= atomic_readandclear_32(&pg->md.mdpg_attrs); if (refchg & LPTE_CHG) vm_page_dirty(pg); if (refchg & LPTE_REF) Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.h ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.h Fri Feb 20 02:43:08 2015 (r279039) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.h Fri Feb 20 05:17:24 2015 (r279040) @@ -40,8 +40,6 @@ extern mmu_def_t oea64_mmu; vm_offset_t moea64_bootstrap_alloc(vm_size_t, u_int); /* Set an LPTE structure to match the contents of a PVO */ void moea64_pte_from_pvo(const struct pvo_entry *pvo, struct lpte *lpte); -/* Synchronize reference/changed bits of a given PTE with the VM system. */ -void moea64_sync_refchg(uint64_t lpte_lo); /* * Flags Modified: user/nwhitehorn/ppc64-pmap-rework/aim/moea64_if.m ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/moea64_if.m Fri Feb 20 02:43:08 2015 (r279039) +++ user/nwhitehorn/ppc64-pmap-rework/aim/moea64_if.m Fri Feb 20 05:17:24 2015 (r279040) @@ -44,6 +44,20 @@ INTERFACE moea64; +CODE { + static moea64_pte_replace_t moea64_pte_replace_default; + + static int64_t moea64_pte_replace_default(mmu_t mmu, + struct pvo_entry *pvo, int flags) + { + int64_t refchg; + + refchg = MOEA64_PTE_UNSET(mmu, pvo); + MOEA64_PTE_INSERT(mmu, pvo); + + return (refchg); + } +} /** * Return ref/changed bits from PTE referenced by _pvo if _pvo is currently in @@ -66,11 +80,10 @@ METHOD int64_t pte_clear { }; /** - * Invalidate the PTE referenced by _pvo, synchronizing its validity - * and ref/changed bits after completion to the backing page. - * Does nothing if PTE not currently present in page table. + * Invalidate the PTE referenced by _pvo, returning its ref/changed bits. + * Returns -1 if PTE not currently present in page table. */ -METHOD void pte_unset { +METHOD int64_t pte_unset { mmu_t _mmu; struct pvo_entry *_pvo; }; @@ -79,7 +92,7 @@ METHOD void pte_unset { * Update the reference PTE to correspond to the contents of _pvo. Has the * same ref/changed semantics as pte_unset() (and should clear R/C bits). May * change the PVO's location in the page table or return with it unmapped if - * PVO_WIRED is not set. + * PVO_WIRED is not set. By default, does unset() followed by insert(). * * _flags is a bitmask describing what level of page invalidation should occur: * 0 means no invalidation is required @@ -87,11 +100,11 @@ METHOD void pte_unset { * MOEA64_PTE_INVALIDATE requires an invalidation of the same strength as * pte_unset() followed by pte_insert() */ -METHOD void pte_replace { +METHOD int64_t pte_replace { mmu_t _mmu; struct pvo_entry *_pvo; int _flags; -}; +} DEFAULT moea64_pte_replace_default; /** * Insert a PTE corresponding to _pvo into the page table, returning any errors Modified: user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Fri Feb 20 02:43:08 2015 (r279039) +++ user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Fri Feb 20 05:17:24 2015 (r279040) @@ -190,8 +190,8 @@ static struct rwlock moea64_eviction_loc static int moea64_pte_insert_native(mmu_t, struct pvo_entry *); static int64_t moea64_pte_synch_native(mmu_t, struct pvo_entry *); static int64_t moea64_pte_clear_native(mmu_t, struct pvo_entry *, uint64_t); -static void moea64_pte_replace_native(mmu_t, struct pvo_entry *, int); -static void moea64_pte_unset_native(mmu_t mmu, struct pvo_entry *); +static int64_t moea64_pte_replace_native(mmu_t, struct pvo_entry *, int); +static int64_t moea64_pte_unset_native(mmu_t mmu, struct pvo_entry *); /* * Utility routines. @@ -312,7 +312,7 @@ moea64_pte_set_native(struct lpte *pvo_p return (0); } -static void +static int64_t moea64_pte_unset_native(mmu_t mmu, struct pvo_entry *pvo) { volatile struct lpte *pt = moea64_pteg_table + pvo->pvo_pte.slot; @@ -328,7 +328,7 @@ moea64_pte_unset_native(mmu_t mmu, struc (properpt.pte_hi & LPTE_AVPN_MASK)) { /* Evicted */ rw_runlock(&moea64_eviction_lock); - return; + return (-1); } /* @@ -343,16 +343,13 @@ moea64_pte_unset_native(mmu_t mmu, struc *((volatile int32_t *)(&pt->pte_hi) + 1) = 0; /* Release lock */ critical_exit(); - /* - * Save the ref & chg bits. - */ - moea64_sync_refchg(ptelo); - /* Keep statistics */ moea64_pte_valid--; + + return (ptelo & (LPTE_CHG | LPTE_REF)); } -static void +static int64_t moea64_pte_replace_native(mmu_t mmu, struct pvo_entry *pvo, int flags) { volatile struct lpte *pt = moea64_pteg_table + pvo->pvo_pte.slot; @@ -367,17 +364,10 @@ moea64_pte_replace_native(mmu_t mmu, str result = atomic_cmpset_32((volatile int32_t *)(&pt->pte_hi) + 1, properpt.pte_hi & 0xffffffff, (properpt.pte_hi | LPTE_LOCKED) & 0xffffffff); - if (!result) - return; /* Page being evicted or already evicted */ - if (flags == 0) { + if (result && flags == 0) { /* Just some software bits changing. The order in which this is * done is important on 32-bit systems. */ - result = atomic_cmpset_32((volatile int32_t *)(&pt->pte_hi) + 1, - properpt.pte_hi & 0xffffffff, - (properpt.pte_hi | LPTE_LOCKED) & 0xffffffff); - if (!result) - return; /* Page being evicted or already evicted */ *(volatile int32_t *)(&pt->pte_hi) = properpt.pte_hi >> 32; *(volatile int32_t *)(&pt->pte_lo) = properpt.pte_lo >> 32; pt->pte_lo = properpt.pte_lo & 0xffffffff; @@ -386,16 +376,19 @@ moea64_pte_replace_native(mmu_t mmu, str EIEIO(); *((volatile int32_t *)(&pt->pte_hi) + 1) = properpt.pte_hi & 0xffffffff; - moea64_sync_refchg(properpt.pte_lo | lowbits); - return; + return (lowbits & (LPTE_REF | LPTE_CHG)); } /* * Anything else requires invalidation and reinsertion, so just do that */ - moea64_pte_unset_native(mmu, pvo); + lowbits = -1; + if (result) + lowbits = moea64_pte_unset_native(mmu, pvo); moea64_pte_insert_native(mmu, pvo); + + return (lowbits); } static void @@ -650,9 +643,6 @@ moea64_pte_insert_native(mmu_t mmu, stru (ADDR_API_SHFT64 - ADDR_PIDX_SHFT)); critical_exit(); - /* Save ref/changed from old page */ - moea64_sync_refchg(be64toh(pt->pte_lo)); - /* New translation */ pt->pte_lo = insertpt.pte_lo; EIEIO(); Modified: user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 Fri Feb 20 02:43:08 2015 (r279039) +++ user/nwhitehorn/ppc64-pmap-rework/conf/GENERIC64 Fri Feb 20 05:17:24 2015 (r279040) @@ -28,7 +28,7 @@ makeoptions WITH_CTF=1 # Platform support options POWERMAC #NewWorld Apple PowerMacs -#options PS3 #Sony Playstation 3 +options PS3 #Sony Playstation 3 options MAMBO #IBM Mambo Full System Simulator options PSERIES #PAPR-compliant systems (e.g. IBM p) Modified: user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c Fri Feb 20 02:43:08 2015 (r279039) +++ user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c Fri Feb 20 05:17:24 2015 (r279040) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -67,15 +68,10 @@ static uint64_t mps3_vas_id; static void mps3_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend); static void mps3_cpu_bootstrap(mmu_t mmup, int ap); -static void mps3_pte_synch(mmu_t, uintptr_t pt, struct lpte *pvo_pt); -static void mps3_pte_clear(mmu_t, uintptr_t pt, struct lpte *pvo_pt, - uint64_t vpn, uint64_t ptebit); -static void mps3_pte_unset(mmu_t, uintptr_t pt, struct lpte *pvo_pt, - uint64_t vpn); -static void mps3_pte_change(mmu_t, uintptr_t pt, struct lpte *pvo_pt, - uint64_t vpn); -static int mps3_pte_insert(mmu_t, u_int ptegidx, struct lpte *pvo_pt); -static uintptr_t mps3_pvo_to_pte(mmu_t, const struct pvo_entry *pvo); +static int64_t mps3_pte_synch(mmu_t, struct pvo_entry *); +static int64_t mps3_pte_clear(mmu_t, struct pvo_entry *, uint64_t ptebit); +static int64_t mps3_pte_unset(mmu_t, struct pvo_entry *); +static int mps3_pte_insert(mmu_t, struct pvo_entry *); static mmu_method_t mps3_methods[] = { @@ -85,20 +81,22 @@ static mmu_method_t mps3_methods[] = { MMUMETHOD(moea64_pte_synch, mps3_pte_synch), MMUMETHOD(moea64_pte_clear, mps3_pte_clear), MMUMETHOD(moea64_pte_unset, mps3_pte_unset), - MMUMETHOD(moea64_pte_change, mps3_pte_change), MMUMETHOD(moea64_pte_insert, mps3_pte_insert), - MMUMETHOD(moea64_pvo_to_pte, mps3_pvo_to_pte), { 0, 0 } }; MMU_DEF_INHERIT(ps3_mmu, "mmu_ps3", mps3_methods, 0, oea64_mmu); +static struct rwlock mps3_eviction_lock; + static void mps3_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) { uint64_t final_pteg_count; + rw_init(&mps3_eviction_lock, "pte eviction"); + moea64_early_bootstrap(mmup, kernelstart, kernelend); lv1_construct_virtual_address_space( @@ -151,72 +149,94 @@ mps3_cpu_bootstrap(mmu_t mmup, int ap) } } -static void -mps3_pte_synch(mmu_t mmu, uintptr_t slot, struct lpte *pvo_pt) +static int64_t +mps3_pte_synch(mmu_t mmu, struct pvo_entry *pvo) { uint64_t halfbucket[4], rcbits; PTESYNC(); - lv1_read_htab_entries(mps3_vas_id, slot & ~0x3UL, &halfbucket[0], - &halfbucket[1], &halfbucket[2], &halfbucket[3], &rcbits); + lv1_read_htab_entries(mps3_vas_id, pvo->pvo_pte.slot & ~0x3UL, + &halfbucket[0], &halfbucket[1], &halfbucket[2], &halfbucket[3], + &rcbits); + + /* Check if present in page table */ + if ((halfbucket[pvo->pvo_pte.slot & 0x3] & LPTE_AVPN_MASK) != + ((pvo->pvo_vpn >> (ADDR_API_SHFT64 - ADDR_PIDX_SHFT)) & + LPTE_AVPN_MASK)) + return (-1); + if (!(halfbucket[pvo->pvo_pte.slot & 0x3] & LPTE_VALID)) + return (-1); /* * rcbits contains the low 12 bits of each PTEs 2nd part, * spaced at 16-bit intervals */ - KASSERT((halfbucket[slot & 0x3] & LPTE_AVPN_MASK) == - (pvo_pt->pte_hi & LPTE_AVPN_MASK), - ("PTE upper word %#lx != %#lx\n", - halfbucket[slot & 0x3], pvo_pt->pte_hi)); - - pvo_pt->pte_lo |= (rcbits >> ((3 - (slot & 0x3))*16)) & - (LPTE_CHG | LPTE_REF); + return ((rcbits >> ((3 - (pvo->pvo_pte.slot & 0x3))*16)) & + (LPTE_CHG | LPTE_REF)); } -static void -mps3_pte_clear(mmu_t mmu, uintptr_t slot, struct lpte *pvo_pt, uint64_t vpn, - u_int64_t ptebit) +static int64_t +mps3_pte_clear(mmu_t mmu, struct pvo_entry *pvo, uint64_t ptebit) { + int64_t refchg; + struct lpte pte; + + rw_rlock(&mps3_eviction_lock); + + refchg = mps3_pte_synch(mmu, pvo); + if (refchg < 0) { + rw_runlock(&mps3_eviction_lock); + return (refchg); + } - lv1_write_htab_entry(mps3_vas_id, slot, pvo_pt->pte_hi, - pvo_pt->pte_lo & ~ptebit); + moea64_pte_from_pvo(pvo, &pte); + + pte.pte_lo |= refchg; + pte.pte_lo &= ~ptebit; + lv1_write_htab_entry(mps3_vas_id, pvo->pvo_pte.slot, pte.pte_hi, + pte.pte_lo); + rw_runlock(&mps3_eviction_lock); + + return (refchg); } -static void -mps3_pte_unset(mmu_t mmu, uintptr_t slot, struct lpte *pvo_pt, uint64_t vpn) +static int64_t +mps3_pte_unset(mmu_t mmu, struct pvo_entry *pvo) { + int64_t refchg; - mps3_pte_synch(mmu, slot, pvo_pt); - pvo_pt->pte_hi &= ~LPTE_VALID; - lv1_write_htab_entry(mps3_vas_id, slot, 0, 0); + rw_rlock(&mps3_eviction_lock); + refchg = mps3_pte_synch(mmu, pvo); + if (refchg < 0) { + rw_runlock(&mps3_eviction_lock); + return (-1); + } + /* XXX: race on RC bits between unset and sync. Anything to do? */ + lv1_write_htab_entry(mps3_vas_id, pvo->pvo_pte.slot, 0, 0); + rw_runlock(&mps3_eviction_lock); moea64_pte_valid--; -} -static void -mps3_pte_change(mmu_t mmu, uintptr_t slot, struct lpte *pvo_pt, uint64_t vpn) -{ - - mps3_pte_synch(mmu, slot, pvo_pt); - lv1_write_htab_entry(mps3_vas_id, slot, pvo_pt->pte_hi, - pvo_pt->pte_lo); + return (refchg & (LPTE_REF | LPTE_CHG)); } static int -mps3_pte_insert(mmu_t mmu, u_int ptegidx, struct lpte *pvo_pt) +mps3_pte_insert(mmu_t mmu, struct pvo_entry *pvo) { int result; - struct lpte evicted; - struct pvo_entry *pvo; + struct lpte pte, evicted; uint64_t index; - pvo_pt->pte_hi |= LPTE_VALID; - pvo_pt->pte_hi &= ~LPTE_HID; + pvo->pvo_pte.slot &= ~7UL; + pvo->pvo_vaddr &= ~PVO_HID; + moea64_pte_from_pvo(pvo, &pte); evicted.pte_hi = 0; PTESYNC(); - result = lv1_insert_htab_entry(mps3_vas_id, ptegidx << 3, - pvo_pt->pte_hi, pvo_pt->pte_lo, LPTE_LOCKED | LPTE_WIRED, 0, + rw_wlock(&mps3_eviction_lock); + result = lv1_insert_htab_entry(mps3_vas_id, pvo->pvo_pte.slot, + pte.pte_hi, pte.pte_lo, LPTE_LOCKED | LPTE_WIRED, 0, &index, &evicted.pte_hi, &evicted.pte_lo); + rw_wunlock(&mps3_eviction_lock); if (result != 0) { /* No freeable slots in either PTEG? We're hosed. */ @@ -227,84 +247,19 @@ mps3_pte_insert(mmu_t mmu, u_int ptegidx /* * See where we ended up. */ - if (index >> 3 != ptegidx) - pvo_pt->pte_hi |= LPTE_HID; + if ((index & ~7UL) != pvo->pvo_pte.slot) + pvo->pvo_vaddr |= PVO_HID; + pvo->pvo_pte.slot = index; moea64_pte_valid++; - if (!evicted.pte_hi) - return (index & 0x7); - - /* - * Synchronize the sacrifice PTE with its PVO, then mark both - * invalid. The PVO will be reused when/if the VM system comes - * here after a fault. - */ - - ptegidx = index >> 3; /* Where the sacrifice PTE was found */ - if (evicted.pte_hi & LPTE_HID) - ptegidx ^= moea64_pteg_mask; /* PTEs indexed by primary */ - - KASSERT((evicted.pte_hi & (LPTE_WIRED | LPTE_LOCKED)) == 0, - ("Evicted a wired PTE")); - - result = 0; - LIST_FOREACH(pvo, &moea64_pvo_table[ptegidx], pvo_olink) { - if (!PVO_PTEGIDX_ISSET(pvo)) - continue; - - if (pvo->pvo_pte.lpte.pte_hi == (evicted.pte_hi | LPTE_VALID)) { - KASSERT(pvo->pvo_pte.lpte.pte_hi & LPTE_VALID, - ("Invalid PVO for valid PTE!")); - pvo->pvo_pte.lpte.pte_hi &= ~LPTE_VALID; - pvo->pvo_pte.lpte.pte_lo |= - evicted.pte_lo & (LPTE_REF | LPTE_CHG); - PVO_PTEGIDX_CLR(pvo); - moea64_pte_valid--; - moea64_pte_overflow++; - result = 1; - break; - } + if (evicted.pte_hi) { + KASSERT((evicted.pte_hi & (LPTE_WIRED | LPTE_LOCKED)) == 0, + ("Evicted a wired PTE")); + moea64_pte_valid--; + moea64_pte_overflow++; } - KASSERT(result == 1, ("PVO for sacrifice PTE not found")); - - return (index & 0x7); -} - -static __inline u_int -va_to_pteg(uint64_t vsid, vm_offset_t addr, int large) -{ - uint64_t hash; - int shift; - - shift = large ? moea64_large_page_shift : ADDR_PIDX_SHFT; - hash = (vsid & VSID_HASH_MASK) ^ (((uint64_t)addr & ADDR_PIDX) >> - shift); - return (hash & moea64_pteg_mask); -} - -uintptr_t -mps3_pvo_to_pte(mmu_t mmu, const struct pvo_entry *pvo) -{ - uint64_t vsid; - u_int ptegidx; - - /* If the PTEG index is not set, then there is no page table entry */ - if (!PVO_PTEGIDX_ISSET(pvo)) - return (-1); - - vsid = PVO_VSID(pvo); - ptegidx = va_to_pteg(vsid, PVO_VADDR(pvo), pvo->pvo_vaddr & PVO_LARGE); - - /* - * We can find the actual pte entry without searching by grabbing - * the PTEG index from 3 unused bits in pvo_vaddr and by - * noticing the HID bit. - */ - if (pvo->pvo_pte.lpte.pte_hi & LPTE_HID) - ptegidx ^= moea64_pteg_mask; - - return ((ptegidx << 3) | PVO_PTEGIDX_GET(pvo)); + return (0); } Modified: user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Fri Feb 20 02:43:08 2015 (r279039) +++ user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Fri Feb 20 05:17:24 2015 (r279040) @@ -70,8 +70,7 @@ static void mphyp_bootstrap(mmu_t mmup, static void mphyp_cpu_bootstrap(mmu_t mmup, int ap); static int64_t mphyp_pte_synch(mmu_t, struct pvo_entry *pvo); static int64_t mphyp_pte_clear(mmu_t, struct pvo_entry *pvo, uint64_t ptebit); -static void mphyp_pte_unset(mmu_t, struct pvo_entry *pvo); -static void mphyp_pte_replace(mmu_t, struct pvo_entry *pvo, int flags); +static int64_t mphyp_pte_unset(mmu_t, struct pvo_entry *pvo); static int mphyp_pte_insert(mmu_t, struct pvo_entry *pvo); static mmu_method_t mphyp_methods[] = { @@ -81,7 +80,6 @@ static mmu_method_t mphyp_methods[] = { MMUMETHOD(moea64_pte_synch, mphyp_pte_synch), MMUMETHOD(moea64_pte_clear, mphyp_pte_clear), MMUMETHOD(moea64_pte_unset, mphyp_pte_unset), - MMUMETHOD(moea64_pte_replace, mphyp_pte_replace), MMUMETHOD(moea64_pte_insert, mphyp_pte_insert), /* XXX: pmap_copy_page, pmap_init_page with H_PAGE_INIT */ @@ -91,23 +89,6 @@ static mmu_method_t mphyp_methods[] = { MMU_DEF_INHERIT(pseries_mmu, "mmu_phyp", mphyp_methods, 0, oea64_mmu); -static int brokenkvm = 0; - -static void -print_kvm_bug_warning(void *data) -{ - - if (brokenkvm) - printf("WARNING: Running on a broken hypervisor that does " - "not support mandatory H_CLEAR_MOD and H_CLEAR_REF " - "hypercalls. Performance will be suboptimal.\n"); -} - -SYSINIT(kvmbugwarn1, SI_SUB_COPYRIGHT, SI_ORDER_THIRD + 1, - print_kvm_bug_warning, NULL); -SYSINIT(kvmbugwarn2, SI_SUB_LAST, SI_ORDER_THIRD + 1, print_kvm_bug_warning, - NULL); - static void mphyp_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) { @@ -200,10 +181,6 @@ mphyp_bootstrap(mmu_t mmup, vm_offset_t moea64_mid_bootstrap(mmup, kernelstart, kernelend); moea64_late_bootstrap(mmup, kernelstart, kernelend); - - /* Test for broken versions of KVM that don't conform to the spec */ - if (phyp_hcall(H_CLEAR_MOD, 0, 0) == H_FUNCTION) - brokenkvm = 1; } static void @@ -252,7 +229,6 @@ mphyp_pte_clear(mmu_t mmu, struct pvo_en { int64_t refchg; uint64_t ptelo, junk; - int err; /* * This involves two steps (synch and clear) so we need the entry @@ -270,28 +246,14 @@ mphyp_pte_clear(mmu_t mmu, struct pvo_en return (refchg); } - if (brokenkvm) { - /* - * No way to clear either bit, which is total madness. - * Pessimistically claim that, once modified, it stays so - * forever and that it is never referenced. - */ - rw_runlock(&mphyp_eviction_lock); - return (refchg & ~LPTE_REF); - } - if (ptebit & LPTE_CHG) { - err = phyp_pft_hcall(H_CLEAR_MOD, 0, pvo->pvo_pte.slot, 0, 0, - &ptelo, &junk, &junk); - KASSERT(err == H_SUCCESS, - ("Error clearing page change bit: %d", err)); + phyp_pft_hcall(H_CLEAR_MOD, 0, pvo->pvo_pte.slot, 0, 0, &ptelo, + &junk, &junk); refchg |= (ptelo & LPTE_CHG); } if (ptebit & LPTE_REF) { - err = phyp_pft_hcall(H_CLEAR_REF, 0, pvo->pvo_pte.slot, 0, 0, - &ptelo, &junk, &junk); - KASSERT(err == H_SUCCESS, - ("Error clearing page reference bit: %d", err)); + phyp_pft_hcall(H_CLEAR_REF, 0, pvo->pvo_pte.slot, 0, 0, &ptelo, + &junk, &junk); refchg |= (ptelo & LPTE_REF); } @@ -300,7 +262,7 @@ mphyp_pte_clear(mmu_t mmu, struct pvo_en return (refchg); } -static void +static int64_t mphyp_pte_unset(mmu_t mmu, struct pvo_entry *pvo) { struct lpte pte; @@ -317,27 +279,12 @@ mphyp_pte_unset(mmu_t mmu, struct pvo_en KASSERT(err == H_SUCCESS || err == H_NOT_FOUND, ("Error removing page: %d", err)); - if (err == H_SUCCESS) - moea64_sync_refchg((pvo->pvo_pte.pa & LPTE_RPGN) | - (pte.pte_lo & (LPTE_REF | LPTE_CHG))); - - if (err == H_NOT_FOUND) + if (err == H_NOT_FOUND) { moea64_pte_overflow--; -} - -static void -mphyp_pte_replace(mmu_t mmu, struct pvo_entry *pvo, int flags) -{ - - PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); + return (-1); + } - /* - * For anything other than a simple page protection update, we have to - * reinsert the page. H_PROTECT is somehow slower than this, so just do - * unset followed by insert unconditionally. - */ - mphyp_pte_unset(mmu, pvo); - mphyp_pte_insert(mmu, pvo); + return (pte.pte_lo & (LPTE_REF | LPTE_CHG)); } static uintptr_t @@ -352,7 +299,7 @@ mphyp_pte_spillable_ident(uintptr_t pteg k = -1; for (j = 0; j < 8; j++) { slot = ptegbase + (i + j) % 8; - phyp_pft_hcall(H_READ, H_R_XLATE, slot, 0, 0, &pt.pte_hi, + phyp_pft_hcall(H_READ, 0, slot, 0, 0, &pt.pte_hi, &pt.pte_lo, &junk); if (pt.pte_hi & LPTE_WIRED) @@ -362,7 +309,7 @@ mphyp_pte_spillable_ident(uintptr_t pteg k = slot; /* Try to get a page that has not been used lately */ - if (!(pt.pte_lo & LPTE_REF)) { + if (!(pt.pte_hi & LPTE_VALID) || !(pt.pte_lo & LPTE_REF)) { memcpy(to_evict, &pt, sizeof(struct lpte)); return (k); } @@ -371,7 +318,7 @@ mphyp_pte_spillable_ident(uintptr_t pteg if (k == -1) return (k); - phyp_pft_hcall(H_READ, H_R_XLATE, k, 0, 0, &to_evict->pte_hi, + phyp_pft_hcall(H_READ, 0, k, 0, 0, &to_evict->pte_hi, &to_evict->pte_lo, &junk); return (k); } @@ -458,14 +405,6 @@ mphyp_pte_insert(mmu_t mmu, struct pvo_e moea64_pte_overflow++; KASSERT(result == H_SUCCESS, ("Error evicting page: %d", (int)result)); - - /* - * Update VM system on final disposition of the old entry. The - * RPN we get from H_REMOVE is not necessarily meaningful, so - * combine the one from H_READ with the RC bits from H_REMOVE - */ - moea64_sync_refchg((evicted.pte_lo & LPTE_RPGN) | - (lastptelo & (LPTE_REF | LPTE_CHG))); } /* From owner-svn-src-user@FreeBSD.ORG Fri Feb 20 05:29:23 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 298EA234; Fri, 20 Feb 2015 05:29:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0C5E6C8; Fri, 20 Feb 2015 05:29:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1K5TMHK039532; Fri, 20 Feb 2015 05:29:22 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1K5TMNo039531; Fri, 20 Feb 2015 05:29:22 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502200529.t1K5TMNo039531@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Fri, 20 Feb 2015 05:29:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279042 - user/nwhitehorn/ppc64-pmap-rework/pseries X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 20 Feb 2015 05:29:23 -0000 Author: nwhitehorn Date: Fri Feb 20 05:29:22 2015 New Revision: 279042 URL: https://svnweb.freebsd.org/changeset/base/279042 Log: Restore accidentally deleted broken KVM detection. This is being fixed upstream. Modified: user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Modified: user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Fri Feb 20 05:23:51 2015 (r279041) +++ user/nwhitehorn/ppc64-pmap-rework/pseries/mmu_phyp.c Fri Feb 20 05:29:22 2015 (r279042) @@ -89,6 +89,23 @@ static mmu_method_t mphyp_methods[] = { MMU_DEF_INHERIT(pseries_mmu, "mmu_phyp", mphyp_methods, 0, oea64_mmu); +static int brokenkvm = 0; + +static void +print_kvm_bug_warning(void *data) +{ + + if (brokenkvm) + printf("WARNING: Running on a broken hypervisor that does " + "not support mandatory H_CLEAR_MOD and H_CLEAR_REF " + "hypercalls. Performance will be suboptimal.\n"); +} + +SYSINIT(kvmbugwarn1, SI_SUB_COPYRIGHT, SI_ORDER_THIRD + 1, + print_kvm_bug_warning, NULL); +SYSINIT(kvmbugwarn2, SI_SUB_LAST, SI_ORDER_THIRD + 1, print_kvm_bug_warning, + NULL); + static void mphyp_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) { @@ -181,6 +198,10 @@ mphyp_bootstrap(mmu_t mmup, vm_offset_t moea64_mid_bootstrap(mmup, kernelstart, kernelend); moea64_late_bootstrap(mmup, kernelstart, kernelend); + + /* Test for broken versions of KVM that don't conform to the spec */ + if (phyp_hcall(H_CLEAR_MOD, 0, 0) == H_FUNCTION) + brokenkvm = 1; } static void @@ -229,6 +250,7 @@ mphyp_pte_clear(mmu_t mmu, struct pvo_en { int64_t refchg; uint64_t ptelo, junk; + int err; /* * This involves two steps (synch and clear) so we need the entry @@ -246,14 +268,28 @@ mphyp_pte_clear(mmu_t mmu, struct pvo_en return (refchg); } + if (brokenkvm) { + /* + * No way to clear either bit, which is total madness. + * Pessimistically claim that, once modified, it stays so + * forever and that it is never referenced. + */ + rw_runlock(&mphyp_eviction_lock); + return (refchg & ~LPTE_REF); + } + if (ptebit & LPTE_CHG) { - phyp_pft_hcall(H_CLEAR_MOD, 0, pvo->pvo_pte.slot, 0, 0, &ptelo, - &junk, &junk); + err = phyp_pft_hcall(H_CLEAR_MOD, 0, pvo->pvo_pte.slot, 0, 0, + &ptelo, &junk, &junk); + KASSERT(err == H_SUCCESS, + ("Error clearing page change bit: %d", err)); refchg |= (ptelo & LPTE_CHG); } if (ptebit & LPTE_REF) { - phyp_pft_hcall(H_CLEAR_REF, 0, pvo->pvo_pte.slot, 0, 0, &ptelo, - &junk, &junk); + err = phyp_pft_hcall(H_CLEAR_REF, 0, pvo->pvo_pte.slot, 0, 0, + &ptelo, &junk, &junk); + KASSERT(err == H_SUCCESS, + ("Error clearing page reference bit: %d", err)); refchg |= (ptelo & LPTE_REF); } From owner-svn-src-user@FreeBSD.ORG Fri Feb 20 06:13:53 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 17397772; Fri, 20 Feb 2015 06:13:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DCA846EA; Fri, 20 Feb 2015 06:13:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1K6DqJm062224; Fri, 20 Feb 2015 06:13:52 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1K6DqRb062223; Fri, 20 Feb 2015 06:13:52 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502200613.t1K6DqRb062223@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Fri, 20 Feb 2015 06:13:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279044 - user/nwhitehorn/ppc64-pmap-rework/aim X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 20 Feb 2015 06:13:53 -0000 Author: nwhitehorn Date: Fri Feb 20 06:13:52 2015 New Revision: 279044 URL: https://svnweb.freebsd.org/changeset/base/279044 Log: Fix bug where pmap_qenter() could introduce double mappings in the page table, resulting in either machine checks (best case, since they are loud) or the CPU using physical memory from either the old or new mapping at random (worst case). Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Fri Feb 20 05:40:39 2015 (r279043) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Fri Feb 20 06:13:52 2015 (r279044) @@ -1684,7 +1684,7 @@ void moea64_kenter_attr(mmu_t mmu, vm_offset_t va, vm_offset_t pa, vm_memattr_t ma) { int error; - struct pvo_entry *pvo; + struct pvo_entry *pvo, *oldpvo; pvo = alloc_pvo_entry(0); pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE; @@ -1692,10 +1692,21 @@ moea64_kenter_attr(mmu_t mmu, vm_offset_ pvo->pvo_vaddr |= PVO_WIRED; PMAP_LOCK(kernel_pmap); + oldpvo = moea64_pvo_find_va(kernel_pmap, va); + if (oldpvo != NULL) + moea64_pvo_remove_from_pmap(mmu, oldpvo); init_pvo_entry(pvo, kernel_pmap, va); error = moea64_pvo_enter(mmu, pvo, NULL); PMAP_UNLOCK(kernel_pmap); + /* Free any dead pages */ + if (oldpvo != NULL) { + PV_LOCK(oldpvo->pvo_pte.pa & LPTE_RPGN); + moea64_pvo_remove_from_page(mmu, oldpvo); + PV_UNLOCK(oldpvo->pvo_pte.pa & LPTE_RPGN); + free_pvo_entry(oldpvo); + } + if (error != 0 && error != ENOENT) panic("moea64_kenter: failed to enter va %#zx pa %#zx: %d", va, pa, error); @@ -2237,6 +2248,8 @@ moea64_pvo_enter(mmu_t mmu, struct pvo_e int first, err; PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); + KASSERT(moea64_pvo_find_va(pvo->pvo_pmap, PVO_VADDR(pvo)) == NULL, + ("Existing mapping for VA %#zx", PVO_VADDR(pvo))); moea64_pvo_enter_calls++; From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 09:13:33 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 311995EE; Sat, 21 Feb 2015 09:13:33 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C51ABAA; Sat, 21 Feb 2015 09:13:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1L9DWPG033007; Sat, 21 Feb 2015 09:13:32 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1L9DWQu033006; Sat, 21 Feb 2015 09:13:32 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502210913.t1L9DWQu033006@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 09:13:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279099 - user/dchagin/lemul/sys/fs/pseudofs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 09:13:33 -0000 Author: dchagin Date: Sat Feb 21 09:13:32 2015 New Revision: 279099 URL: https://svnweb.freebsd.org/changeset/base/279099 Log: Revert r278821. Its not so trivial to implement pfs fill methods with autosized sbuf. Will use RAW flag for auxv emulation. Modified: user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Modified: user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Sat Feb 21 06:28:31 2015 (r279098) +++ user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Sat Feb 21 09:13:32 2015 (r279099) @@ -662,7 +662,7 @@ pfs_read(struct vop_read_args *va) if (buflen > MAXPHYS) buflen = MAXPHYS; - sb = sbuf_new_auto(); + sb = sbuf_new(sb, NULL, buflen + 1, 0); if (sb == NULL) { error = EIO; goto ret; From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 09:17:32 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9774372A; Sat, 21 Feb 2015 09:17:32 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6984CBDE; Sat, 21 Feb 2015 09:17:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1L9HWN3033556; Sat, 21 Feb 2015 09:17:32 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1L9HWG0033555; Sat, 21 Feb 2015 09:17:32 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502210917.t1L9HWG0033555@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 09:17:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279100 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 09:17:32 -0000 Author: dchagin Date: Sat Feb 21 09:17:31 2015 New Revision: 279100 URL: https://svnweb.freebsd.org/changeset/base/279100 Log: Reimplement /proc//auxv using RAW pfs method. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 09:13:32 2015 (r279099) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 09:17:31 2015 (r279100) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1403,31 +1404,37 @@ linprocfs_douuid(PFS_FILL_ARGS) static int linprocfs_doauxv(PFS_FILL_ARGS) { - int ret; - - PROC_LOCK(p); - if ((ret = p_candebug(td, p)) != 0) { - PROC_UNLOCK(p); - return (ret); - } + struct sbuf *asb; + off_t buflen; + int error; /* * Mimic linux behavior and pass only processes with usermode * address space as valid. Return zero silently otherwize. */ - if (p->p_vmspace == &vmspace0) { - PROC_UNLOCK(p); + if (p->p_vmspace == &vmspace0) return (0); - } - if ((p->p_flag & P_SYSTEM) != 0) { - PROC_UNLOCK(p); + if (uio->uio_resid == 0) return (0); - } - - PROC_UNLOCK(p); - - return (proc_getauxv(td, p, sb)); + if (uio->uio_offset < 0 || uio->uio_resid < 0) + return (EINVAL); + buflen = uio->uio_resid; + if (buflen > IOSIZE_MAX) + return (EINVAL); + if (buflen > MAXPHYS) + buflen = MAXPHYS; + + asb = sbuf_new_auto(); + if (asb == NULL) + return (ENOMEM); + error = proc_getauxv(td, p, asb); + if (error == 0) + error = sbuf_finish(asb); + if (error == 0) + error = uiomove(sbuf_data(asb) + uio->uio_offset, buflen, uio); + sbuf_delete(asb); + return (error); } /* @@ -1505,7 +1512,7 @@ linprocfs_init(PFS_INIT_ARGS) pfs_create_link(dir, "fd", &linprocfs_dofdescfs, NULL, NULL, NULL, 0); pfs_create_file(dir, "auxv", &linprocfs_doauxv, - NULL, NULL, NULL, PFS_RD); + NULL, &procfs_candebug, NULL, PFS_RD|PFS_RAWRD); /* /proc/scsi/... */ dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0); From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 09:25:54 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6676886A; Sat, 21 Feb 2015 09:25:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 525F4C90; Sat, 21 Feb 2015 09:25:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1L9Pr5F038029; Sat, 21 Feb 2015 09:25:53 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1L9Prfa038028; Sat, 21 Feb 2015 09:25:53 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502210925.t1L9Prfa038028@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 09:25:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279101 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 09:25:54 -0000 Author: dchagin Date: Sat Feb 21 09:25:53 2015 New Revision: 279101 URL: https://svnweb.freebsd.org/changeset/base/279101 Log: Print vdso and stack names to the /proc/self/maps only for Linux procs. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 09:17:31 2015 (r279100) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 09:25:53 2015 (r279101) @@ -1075,7 +1075,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) VOP_GETATTR(vp, &vat, td->td_ucred); ino = vat.va_fileid; vput(vp); - } else { + } else if (SV_PROC_ABI(p) == SV_ABI_LINUX) { if (e_start == p->p_sysent->sv_shared_page_base) name = vdso_str; if (e_end == p->p_sysent->sv_usrstack) From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 10:10:27 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4F18BD83; Sat, 21 Feb 2015 10:10:27 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3AECEFCF; Sat, 21 Feb 2015 10:10:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LAARwv058154; Sat, 21 Feb 2015 10:10:27 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LAAR2U058153; Sat, 21 Feb 2015 10:10:27 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502211010.t1LAAR2U058153@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 10:10:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279102 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 10:10:27 -0000 Author: dchagin Date: Sat Feb 21 10:10:26 2015 New Revision: 279102 URL: https://svnweb.freebsd.org/changeset/base/279102 Log: Add a resid bounds checking to doprocauxv() method. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 09:25:53 2015 (r279101) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 10:10:26 2015 (r279102) @@ -1405,7 +1405,7 @@ static int linprocfs_doauxv(PFS_FILL_ARGS) { struct sbuf *asb; - off_t buflen; + off_t buflen, resid; int error; /* @@ -1419,11 +1419,6 @@ linprocfs_doauxv(PFS_FILL_ARGS) return (0); if (uio->uio_offset < 0 || uio->uio_resid < 0) return (EINVAL); - buflen = uio->uio_resid; - if (buflen > IOSIZE_MAX) - return (EINVAL); - if (buflen > MAXPHYS) - buflen = MAXPHYS; asb = sbuf_new_auto(); if (asb == NULL) @@ -1431,6 +1426,19 @@ linprocfs_doauxv(PFS_FILL_ARGS) error = proc_getauxv(td, p, asb); if (error == 0) error = sbuf_finish(asb); + + resid = sbuf_len(asb) - uio->uio_offset; + if (resid > uio->uio_resid) + buflen = uio->uio_resid; + else + buflen = resid; + if (buflen > IOSIZE_MAX) + return (EINVAL); + if (buflen > MAXPHYS) + buflen = MAXPHYS; + if (resid <= 0) + return (0); + if (error == 0) error = uiomove(sbuf_data(asb) + uio->uio_offset, buflen, uio); sbuf_delete(asb); From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 15:15:17 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 937201AE; Sat, 21 Feb 2015 15:15:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7EEF6FC4; Sat, 21 Feb 2015 15:15:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LFFH8W005160; Sat, 21 Feb 2015 15:15:17 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LFFHiX005158; Sat, 21 Feb 2015 15:15:17 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502211515.t1LFFHiX005158@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sat, 21 Feb 2015 15:15:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279105 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 15:15:17 -0000 Author: pho Date: Sat Feb 21 15:15:16 2015 New Revision: 279105 URL: https://svnweb.freebsd.org/changeset/base/279105 Log: Use /tmp as working directory. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/callout_reset_on.sh user/pho/stress2/misc/signal.sh Modified: user/pho/stress2/misc/callout_reset_on.sh ============================================================================== --- user/pho/stress2/misc/callout_reset_on.sh Sat Feb 21 15:02:27 2015 (r279104) +++ user/pho/stress2/misc/callout_reset_on.sh Sat Feb 21 15:15:16 2015 (r279105) @@ -311,6 +311,7 @@ mycc -o /tmp/crlogger -Wall -Wextra -O2 rm -f /tmp/crlogger.c N=200 +cd /tmp for i in `jot 40`; do for j in `jot $N`; do /tmp/crwriter | /tmp/crlogger 1236$j 2>/dev/null & Modified: user/pho/stress2/misc/signal.sh ============================================================================== --- user/pho/stress2/misc/signal.sh Sat Feb 21 15:02:27 2015 (r279104) +++ user/pho/stress2/misc/signal.sh Sat Feb 21 15:15:16 2015 (r279105) @@ -36,6 +36,11 @@ . ../default.cfg +here=`pwd` +wd=/tmp/signal.dir +rm -rf $wd +mkdir -p $wd +cd $wd cat > waitthread.c < #include @@ -226,5 +231,6 @@ else fi kill $fifopid $gdbpid > /dev/null 2>&1 -rm -f gdbfifo gdbout pstat waitthread tkill /tmp/waitthread ps | grep -v grep | grep waitthread | awk '{print $1}' | xargs kill +cd $here +rm -rf $wd /tmp/waitthread From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 15:18:26 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CD815381; Sat, 21 Feb 2015 15:18:26 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8239FDE; Sat, 21 Feb 2015 15:18:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LFIQuR005568; Sat, 21 Feb 2015 15:18:26 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LFIQnN005565; Sat, 21 Feb 2015 15:18:26 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201502211518.t1LFIQnN005565@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sat, 21 Feb 2015 15:18:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279106 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 15:18:27 -0000 Author: pho Date: Sat Feb 21 15:18:25 2015 New Revision: 279106 URL: https://svnweb.freebsd.org/changeset/base/279106 Log: ADded test scenario for lockf(1) and lockf(3). Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/lockf2.sh (contents, props changed) user/pho/stress2/misc/lockf3.sh (contents, props changed) Added: user/pho/stress2/misc/lockf2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/lockf2.sh Sat Feb 21 15:18:25 2015 (r279106) @@ -0,0 +1,45 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +for i in `jot 100`; do + for j in `jot 50`; do + file=/tmp/lockf2.$$.$j + touch $file + lockf -t 10 $file sleep 3 & + done + + for j in `jot 50`; do + rm -f /tmp/lockf2.$$.$j + done + + for j in `jot 50`; do + wait + done +done Added: user/pho/stress2/misc/lockf3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/lockf3.sh Sat Feb 21 15:18:25 2015 (r279106) @@ -0,0 +1,160 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# 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$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > lockf3.c +mycc -o lockf3 -Wall -Wextra -O2 lockf3.c || exit 1 +rm -f lockf3.c + +mount | grep -q "$mntpoint" && umount $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +mdconfig -a -t swap -s 40m -u $mdstart +bsdlabel -w md${mdstart} auto + +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint + +cd $mntpoint +for i in `jot 3`; do + $here/../testcases/swap/swap -t 10m -i 200 > /dev/null & + /tmp/lockf3 || break + killall swap +done +killall -q -9 lockf3 swap +cd $here + +while mount | grep -q "on $mntpoint "; do + umount $mntpoint || sleep 1 +done +rm -rf /tmp/lockf3 +exit 0 +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOOPS 10000 +#define PIDS 100 + +void +handler(int s __unused) +{ +} + +void +int_handler(int s __unused) +{ + _exit(0); +} + +void +ahandler(int s __unused) +{ + fprintf(stderr, "FAIL timed out\n"); + _exit(1); +} + +int +main(void) +{ + int fd, i, j; + char name[128]; + pid_t pid[PIDS]; + struct sigaction sa; + int status; + + signal(SIGALRM, ahandler); + alarm(15 * 60); + for (i = 0; i < PIDS; i++) { + sprintf(name, "lock.%06d", getpid()); + if ((fd = open(name, O_CREAT | O_TRUNC | O_RDWR, 0640)) == -1) + err(1, "open(%s)", name); + if (lockf(fd, F_LOCK, 0) == -1) + err(1, "flock 1"); + + if ((pid[i] = fork()) == -1) + err(1, "fork"); + + if (pid[i] == 0) { + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = handler; + if (sigaction(SIGHUP, &sa, NULL) == -1) + err(1, "signal"); + sa.sa_handler = int_handler; + if (sigaction(SIGINT, &sa, NULL) == -1) + err(1, "signal"); + + for (;;) { + if (lockf(fd, F_LOCK, 0) == -1) + if (errno != EINTR) + warn("lockf"); + } + _exit(0); + } + unlink(name); + } + + usleep(10000); + + for (i = 0; i < LOOPS; i++) { + for (j = 0; j < PIDS; j++) { + if (kill(pid[j], SIGHUP) == -1) { + warn("kill(%d), i = %d, j = %d", pid[j], i, j); + pid[j] = 0; + } + } + } + for (j = 0; j < PIDS; j++) { + if (kill(pid[j], SIGINT) == -1) { + warn("kill(%d), i = %d, j = %d", pid[j], i, j); + pid[j] = 0; + } + } + + for (j = 0; j < PIDS; j++) { + if (waitpid(pid[j], &status, 0) == -1) + err(1, "waitpid(%d)", pid[j]); + } + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 20:40:44 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2316399C; Sat, 21 Feb 2015 20:40:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0BFB1362; Sat, 21 Feb 2015 20:40:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LKeiM2057522; Sat, 21 Feb 2015 20:40:44 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LKefji057495; Sat, 21 Feb 2015 20:40:41 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502212040.t1LKefji057495@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 20:40:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279107 - in user/dchagin/lemul/sys: amd64/linux amd64/linux32 compat/linux i386/linux modules/linux modules/linux_common X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 20:40:44 -0000 Author: dchagin Date: Sat Feb 21 20:40:40 2015 New Revision: 279107 URL: https://svnweb.freebsd.org/changeset/base/279107 Log: Rework signal code to allow using it by other modules, like linprocfs: 1. Linux sigset always 64 bit on all platforms. In order to move Linux sigset code to the linux_common module define it as 64 bit int. Move Linux sigset manipulation routines to the MI path. 2. Move Linux signal number definitions to the MI path. In geneeral they are the same on all platforms except for a few signals. 3. Map Linux RT signals to the FreeBSD RT signals and hide signal conversion tables to avoid conversion errors. 4. Emulate Linux SIGPWR signal via FreeBSD SIGRTMIN signal which is outside of allowed on Linux signal numbers. PR: 197216 Added: user/dchagin/lemul/sys/compat/linux/linux.c (contents, props changed) user/dchagin/lemul/sys/compat/linux/linux.h (contents, props changed) Modified: user/dchagin/lemul/sys/amd64/linux/linux.h user/dchagin/lemul/sys/amd64/linux/linux_machdep.c user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c user/dchagin/lemul/sys/amd64/linux32/linux.h user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c user/dchagin/lemul/sys/compat/linux/linux_fork.c user/dchagin/lemul/sys/compat/linux/linux_misc.c user/dchagin/lemul/sys/compat/linux/linux_signal.c user/dchagin/lemul/sys/compat/linux/linux_signal.h user/dchagin/lemul/sys/i386/linux/linux.h user/dchagin/lemul/sys/i386/linux/linux_sysvec.c user/dchagin/lemul/sys/modules/linux/Makefile user/dchagin/lemul/sys/modules/linux_common/Makefile Modified: user/dchagin/lemul/sys/amd64/linux/linux.h ============================================================================== --- user/dchagin/lemul/sys/amd64/linux/linux.h Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/amd64/linux/linux.h Sat Feb 21 20:40:40 2015 (r279107) @@ -32,6 +32,7 @@ #ifndef _AMD64_LINUX_H_ #define _AMD64_LINUX_H_ +#include #include /* @@ -173,49 +174,6 @@ struct l_newstat { l_long __unused3; }; -/* - * Signalling - */ -#define LINUX_SIGHUP 1 -#define LINUX_SIGINT 2 -#define LINUX_SIGQUIT 3 -#define LINUX_SIGILL 4 -#define LINUX_SIGTRAP 5 -#define LINUX_SIGABRT 6 -#define LINUX_SIGIOT LINUX_SIGABRT -#define LINUX_SIGBUS 7 -#define LINUX_SIGFPE 8 -#define LINUX_SIGKILL 9 -#define LINUX_SIGUSR1 10 -#define LINUX_SIGSEGV 11 -#define LINUX_SIGUSR2 12 -#define LINUX_SIGPIPE 13 -#define LINUX_SIGALRM 14 -#define LINUX_SIGTERM 15 -#define LINUX_SIGSTKFLT 16 -#define LINUX_SIGCHLD 17 -#define LINUX_SIGCONT 18 -#define LINUX_SIGSTOP 19 -#define LINUX_SIGTSTP 20 -#define LINUX_SIGTTIN 21 -#define LINUX_SIGTTOU 22 -#define LINUX_SIGURG 23 -#define LINUX_SIGXCPU 24 -#define LINUX_SIGXFSZ 25 -#define LINUX_SIGVTALRM 26 -#define LINUX_SIGPROF 27 -#define LINUX_SIGWINCH 28 -#define LINUX_SIGIO 29 -#define LINUX_SIGPOLL LINUX_SIGIO -#define LINUX_SIGPWR 30 -#define LINUX_SIGSYS 31 -#define LINUX_SIGRTMIN 32 - -#define LINUX_SIGTBLSZ 31 -#define LINUX_NSIG 64 -#define LINUX_NBPW 64 -#define LINUX_NSIG_WORDS (LINUX_NSIG / LINUX_NBPW) - /* sigaction flags */ #define LINUX_SA_NOCLDSTOP 0x00000001 #define LINUX_SA_NOCLDWAIT 0x00000002 @@ -232,31 +190,12 @@ struct l_newstat { #define LINUX_SIG_UNBLOCK 1 #define LINUX_SIG_SETMASK 2 -/* primitives to manipulate sigset_t */ - -#define LINUX_SIGEMPTYSET(set) \ - do { \ - (set).__bits[0] = 0; \ - } while(0) - -#define LINUX_SIGISMEMBER(set, sig) \ - (1UL & ((set).__bits[0] >> _SIG_IDX(sig))) - -#define LINUX_SIGADDSET(set, sig) \ - (set).__bits[0] |= 1UL << _SIG_IDX(sig) - /* sigaltstack */ #define LINUX_MINSIGSTKSZ 2048 -#define LINUX_SS_ONSTACK 1 -#define LINUX_SS_DISABLE 2 typedef void (*l_handler_t)(l_int); typedef struct { - l_ulong __bits[LINUX_NSIG_WORDS]; -} l_sigset_t; - -typedef struct { l_handler_t lsa_handler; l_ulong lsa_flags; l_uintptr_t lsa_restorer; Modified: user/dchagin/lemul/sys/amd64/linux/linux_machdep.c ============================================================================== --- user/dchagin/lemul/sys/amd64/linux/linux_machdep.c Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/amd64/linux/linux_machdep.c Sat Feb 21 20:40:40 2015 (r279107) @@ -432,42 +432,6 @@ linux_set_cloned_tls(struct thread *td, return (0); } -void -linux_to_bsd_sigset(l_sigset_t *lss, sigset_t *bss) -{ - int b, l; - - SIGEMPTYSET(*bss); - for (l = 1; l <= LINUX_NSIG; l++) { - if (LINUX_SIGISMEMBER(*lss, l)) { - if (l <= LINUX_SIGTBLSZ) - b = linux_to_bsd_signal[_SIG_IDX(l)]; - else - b = l; - if (b) - SIGADDSET(*bss, b); - } - } -} - -void -bsd_to_linux_sigset(sigset_t *bss, l_sigset_t *lss) -{ - int b, l; - - LINUX_SIGEMPTYSET(*lss); - for (b = 1; b <= LINUX_NSIG; b++) { - if (SIGISMEMBER(*bss, b)) { - if (b <= LINUX_SIGTBLSZ) - l = bsd_to_linux_signal[_SIG_IDX(b)]; - else - l = b; - if (l) - LINUX_SIGADDSET(*lss, l); - } - } -} - int linux_wait4(struct thread *td, struct linux_wait4_args *args) { @@ -552,7 +516,7 @@ linux_waitid(struct thread *td, struct l if (td->td_retval[0] == 0) bzero(&lsi, sizeof(lsi)); else { - sig = BSD_TO_LINUX_SIGNAL(siginfo.si_signo); + sig = bsd_to_linux_signal(siginfo.si_signo); siginfo_to_lsiginfo(&siginfo, &lsi, sig); } error = copyout(&lsi, args->info, sizeof(lsi)); Modified: user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c ============================================================================== --- user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c Sat Feb 21 20:40:40 2015 (r279107) @@ -151,28 +151,6 @@ static int bsd_to_linux_errno[ELAST + 1] -72, -67, -71 }; -int bsd_to_linux_signal[LINUX_SIGTBLSZ] = { - LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL, - LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE, - LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, LINUX_SIGSYS, - LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG, - LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD, - LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU, - LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH, - 0, LINUX_SIGUSR1, LINUX_SIGUSR2 -}; - -int linux_to_bsd_signal[LINUX_SIGTBLSZ] = { - SIGHUP, SIGINT, SIGQUIT, SIGILL, - SIGTRAP, SIGABRT, SIGBUS, SIGFPE, - SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2, - SIGPIPE, SIGALRM, SIGTERM, SIGBUS, - SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP, - SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, - SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, - SIGIO, SIGURG, SIGSYS -}; - #define LINUX_T_UNKNOWN 255 static int _bsd_to_linux_trapcode[] = { LINUX_T_UNKNOWN, /* 0 */ @@ -658,8 +636,8 @@ linux_rt_sendsig(sig_t catcher, ksiginfo sfp = (struct l_rt_sigframe *)((unsigned long)sp & ~0xFul); mtx_unlock(&psp->ps_mtx); - /* Translate the signal if appropriate. */ - sig = BSD_TO_LINUX_SIGNAL(sig); + /* Translate the signal. */ + sig = bsd_to_linux_signal(sig); /* Save user context. */ bzero(&sf, sizeof(sf)); @@ -825,8 +803,8 @@ struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, .sv_mask = 0, - .sv_sigsize = LINUX_SIGTBLSZ, - .sv_sigtbl = bsd_to_linux_signal, + .sv_sigsize = 0, + .sv_sigtbl = NULL, .sv_errsize = ELAST + 1, .sv_errtbl = bsd_to_linux_errno, .sv_transtrap = translate_traps, Modified: user/dchagin/lemul/sys/amd64/linux32/linux.h ============================================================================== --- user/dchagin/lemul/sys/amd64/linux32/linux.h Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/amd64/linux32/linux.h Sat Feb 21 20:40:40 2015 (r279107) @@ -33,6 +33,7 @@ #ifndef _AMD64_LINUX_H_ #define _AMD64_LINUX_H_ +#include #include /* @@ -259,49 +260,6 @@ struct l_statfs64 { l_int f_spare[6]; } __packed; -/* - * Signalling - */ -#define LINUX_SIGHUP 1 -#define LINUX_SIGINT 2 -#define LINUX_SIGQUIT 3 -#define LINUX_SIGILL 4 -#define LINUX_SIGTRAP 5 -#define LINUX_SIGABRT 6 -#define LINUX_SIGIOT LINUX_SIGABRT -#define LINUX_SIGBUS 7 -#define LINUX_SIGFPE 8 -#define LINUX_SIGKILL 9 -#define LINUX_SIGUSR1 10 -#define LINUX_SIGSEGV 11 -#define LINUX_SIGUSR2 12 -#define LINUX_SIGPIPE 13 -#define LINUX_SIGALRM 14 -#define LINUX_SIGTERM 15 -#define LINUX_SIGSTKFLT 16 -#define LINUX_SIGCHLD 17 -#define LINUX_SIGCONT 18 -#define LINUX_SIGSTOP 19 -#define LINUX_SIGTSTP 20 -#define LINUX_SIGTTIN 21 -#define LINUX_SIGTTOU 22 -#define LINUX_SIGURG 23 -#define LINUX_SIGXCPU 24 -#define LINUX_SIGXFSZ 25 -#define LINUX_SIGVTALRM 26 -#define LINUX_SIGPROF 27 -#define LINUX_SIGWINCH 28 -#define LINUX_SIGIO 29 -#define LINUX_SIGPOLL LINUX_SIGIO -#define LINUX_SIGPWR 30 -#define LINUX_SIGSYS 31 -#define LINUX_SIGRTMIN 32 - -#define LINUX_SIGTBLSZ 31 -#define LINUX_NSIG_WORDS 2 -#define LINUX_NBPW 32 -#define LINUX_NSIG (LINUX_NBPW * LINUX_NSIG_WORDS) - /* sigaction flags */ #define LINUX_SA_NOCLDSTOP 0x00000001 #define LINUX_SA_NOCLDWAIT 0x00000002 @@ -318,24 +276,13 @@ struct l_statfs64 { #define LINUX_SIG_UNBLOCK 1 #define LINUX_SIG_SETMASK 2 -/* sigset_t macros */ -#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 -#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) -#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) - /* sigaltstack */ #define LINUX_MINSIGSTKSZ 2048 -#define LINUX_SS_ONSTACK 1 -#define LINUX_SS_DISABLE 2 typedef l_uintptr_t l_handler_t; typedef l_ulong l_osigset_t; typedef struct { - l_uint __bits[LINUX_NSIG_WORDS]; -} __packed l_sigset_t; - -typedef struct { l_handler_t lsa_handler; l_osigset_t lsa_mask; l_ulong lsa_flags; @@ -504,7 +451,7 @@ struct l_sigframe { l_int sf_sig; struct l_sigcontext sf_sc; struct l_fpstate sf_fpstate; - l_uint sf_extramask[LINUX_NSIG_WORDS-1]; + l_uint sf_extramask[1]; l_handler_t sf_handler; } __packed; Modified: user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/amd64/linux32/linux32_machdep.c Sat Feb 21 20:40:40 2015 (r279107) @@ -696,7 +696,7 @@ linux_sigaction(struct thread *td, struc act.lsa_flags = osa.lsa_flags; act.lsa_restorer = osa.lsa_restorer; LINUX_SIGEMPTYSET(act.lsa_mask); - act.lsa_mask.__bits[0] = osa.lsa_mask; + act.lsa_mask.__mask = osa.lsa_mask; } error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL, @@ -706,7 +706,7 @@ linux_sigaction(struct thread *td, struc osa.lsa_handler = oact.lsa_handler; osa.lsa_flags = oact.lsa_flags; osa.lsa_restorer = oact.lsa_restorer; - osa.lsa_mask = oact.lsa_mask.__bits[0]; + osa.lsa_mask = oact.lsa_mask.__mask; error = copyout(&osa, args->osa, sizeof(l_osigaction_t)); } @@ -730,7 +730,7 @@ linux_sigsuspend(struct thread *td, stru #endif LINUX_SIGEMPTYSET(mask); - mask.__bits[0] = args->mask; + mask.__mask = args->mask; linux_to_bsd_sigset(&mask, &sigmask); return (kern_sigsuspend(td, sigmask)); } @@ -1082,7 +1082,7 @@ linux_waitid(struct thread *td, struct l if (td->td_retval[0] == 0) bzero(&lsi, sizeof(lsi)); else { - sig = BSD_TO_LINUX_SIGNAL(siginfo.si_signo); + sig = bsd_to_linux_signal(siginfo.si_signo); siginfo_to_lsiginfo(&siginfo, &lsi, sig); } error = copyout(&lsi, args->info, sizeof(lsi)); Modified: user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c Sat Feb 21 20:40:40 2015 (r279107) @@ -150,28 +150,6 @@ static int bsd_to_linux_errno[ELAST + 1] -72, -67, -71 }; -int bsd_to_linux_signal[LINUX_SIGTBLSZ] = { - LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL, - LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE, - LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, LINUX_SIGSYS, - LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG, - LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD, - LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU, - LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH, - 0, LINUX_SIGUSR1, LINUX_SIGUSR2 -}; - -int linux_to_bsd_signal[LINUX_SIGTBLSZ] = { - SIGHUP, SIGINT, SIGQUIT, SIGILL, - SIGTRAP, SIGABRT, SIGBUS, SIGFPE, - SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2, - SIGPIPE, SIGALRM, SIGTERM, SIGBUS, - SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP, - SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, - SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, - SIGIO, SIGURG, SIGSYS -}; - #define LINUX_T_UNKNOWN 255 static int _bsd_to_linux_trapcode[] = { LINUX_T_UNKNOWN, /* 0 */ @@ -344,7 +322,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo /* * Build the argument list for the signal handler. */ - sig = BSD_TO_LINUX_SIGNAL(sig); + sig = bsd_to_linux_signal(sig); bzero(&frame, sizeof(frame)); @@ -371,7 +349,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask); - frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0]; + frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__mask; frame.sf_sc.uc_mcontext.sc_edi = regs->tf_rdi; frame.sf_sc.uc_mcontext.sc_esi = regs->tf_rsi; frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_rbp; @@ -452,7 +430,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t struct trapframe *regs; struct l_sigframe *fp, frame; l_sigset_t lmask; - int oonstack, i; + int oonstack; int sig, code; sig = ksi->ksi_signo; @@ -490,7 +468,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t /* * Build the argument list for the signal handler. */ - sig = BSD_TO_LINUX_SIGNAL(sig); + sig = bsd_to_linux_signal(sig); bzero(&frame, sizeof(frame)); @@ -502,7 +480,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t /* * Build the signal context to be used by sigreturn. */ - frame.sf_sc.sc_mask = lmask.__bits[0]; + frame.sf_sc.sc_mask = lmask.__mask; frame.sf_sc.sc_gs = regs->tf_gs; frame.sf_sc.sc_fs = regs->tf_fs; frame.sf_sc.sc_es = regs->tf_es; @@ -524,8 +502,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t frame.sf_sc.sc_cr2 = (u_int32_t)(uintptr_t)ksi->ksi_addr; frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code); - for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) - frame.sf_extramask[i] = lmask.__bits[i+1]; + frame.sf_extramask[0] = lmask.__mask; if (copyout(&frame, fp, sizeof(frame)) != 0) { /* @@ -571,7 +548,7 @@ linux_sigreturn(struct thread *td, struc struct trapframe *regs; sigset_t bmask; l_sigset_t lmask; - int eflags, i; + int eflags; ksiginfo_t ksi; regs = td->td_frame; @@ -612,9 +589,8 @@ linux_sigreturn(struct thread *td, struc return(EINVAL); } - lmask.__bits[0] = frame.sf_sc.sc_mask; - for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) - lmask.__bits[i+1] = frame.sf_extramask[i]; + lmask.__mask = frame.sf_sc.sc_mask; + lmask.__mask = frame.sf_extramask[0]; linux_to_bsd_sigset(&lmask, &bmask); kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); @@ -1035,8 +1011,8 @@ struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, .sv_mask = 0, - .sv_sigsize = LINUX_SIGTBLSZ, - .sv_sigtbl = bsd_to_linux_signal, + .sv_sigsize = 0, + .sv_sigtbl = NULL, .sv_errsize = ELAST + 1, .sv_errtbl = bsd_to_linux_errno, .sv_transtrap = translate_traps, Added: user/dchagin/lemul/sys/compat/linux/linux.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/dchagin/lemul/sys/compat/linux/linux.c Sat Feb 21 20:40:40 2015 (r279107) @@ -0,0 +1,205 @@ +/*- + * Copyright (c) 2015 Dmitry Chagin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include + + +static int bsd_to_linux_sigtbl[LINUX_SIGTBLSZ] = { + LINUX_SIGHUP, /* SIGHUP */ + LINUX_SIGINT, /* SIGINT */ + LINUX_SIGQUIT, /* SIGQUIT */ + LINUX_SIGILL, /* SIGILL */ + LINUX_SIGTRAP, /* SIGTRAP */ + LINUX_SIGABRT, /* SIGABRT */ + 0, /* SIGEMT */ + LINUX_SIGFPE, /* SIGFPE */ + LINUX_SIGKILL, /* SIGKILL */ + LINUX_SIGBUS, /* SIGBUS */ + LINUX_SIGSEGV, /* SIGSEGV */ + LINUX_SIGSYS, /* SIGSYS */ + LINUX_SIGPIPE, /* SIGPIPE */ + LINUX_SIGALRM, /* SIGALRM */ + LINUX_SIGTERM, /* SIGTERM */ + LINUX_SIGURG, /* SIGURG */ + LINUX_SIGSTOP, /* SIGSTOP */ + LINUX_SIGTSTP, /* SIGTSTP */ + LINUX_SIGCONT, /* SIGCONT */ + LINUX_SIGCHLD, /* SIGCHLD */ + LINUX_SIGTTIN, /* SIGTTIN */ + LINUX_SIGTTOU, /* SIGTTOU */ + LINUX_SIGIO, /* SIGIO */ + LINUX_SIGXCPU, /* SIGXCPU */ + LINUX_SIGXFSZ, /* SIGXFSZ */ + LINUX_SIGVTALRM,/* SIGVTALRM */ + LINUX_SIGPROF, /* SIGPROF */ + LINUX_SIGWINCH, /* SIGWINCH */ + 0, /* SIGINFO */ + LINUX_SIGUSR1, /* SIGUSR1 */ + LINUX_SIGUSR2 /* SIGUSR2 */ +}; + +static int linux_to_bsd_sigtbl[LINUX_SIGTBLSZ] = { + SIGHUP, /* LINUX_SIGHUP */ + SIGINT, /* LINUX_SIGINT */ + SIGQUIT, /* LINUX_SIGQUIT */ + SIGILL, /* LINUX_SIGILL */ + SIGTRAP, /* LINUX_SIGTRAP */ + SIGABRT, /* LINUX_SIGABRT */ + SIGBUS, /* LINUX_SIGBUS */ + SIGFPE, /* LINUX_SIGFPE */ + SIGKILL, /* LINUX_SIGKILL */ + SIGUSR1, /* LINUX_SIGUSR1 */ + SIGSEGV, /* LINUX_SIGSEGV */ + SIGUSR2, /* LINUX_SIGUSR2 */ + SIGPIPE, /* LINUX_SIGPIPE */ + SIGALRM, /* LINUX_SIGALRM */ + SIGTERM, /* LINUX_SIGTERM */ + SIGBUS, /* LINUX_SIGSTKFLT */ + SIGCHLD, /* LINUX_SIGCHLD */ + SIGCONT, /* LINUX_SIGCONT */ + SIGSTOP, /* LINUX_SIGSTOP */ + SIGTSTP, /* LINUX_SIGTSTP */ + SIGTTIN, /* LINUX_SIGTTIN */ + SIGTTOU, /* LINUX_SIGTTOU */ + SIGURG, /* LINUX_SIGURG */ + SIGXCPU, /* LINUX_SIGXCPU */ + SIGXFSZ, /* LINUX_SIGXFSZ */ + SIGVTALRM, /* LINUX_SIGVTALARM */ + SIGPROF, /* LINUX_SIGPROF */ + SIGWINCH, /* LINUX_SIGWINCH */ + SIGIO, /* LINUX_SIGIO */ + /* + * FreeBSD does not have SIGPWR signal, map Linux SIGPWR signal + * to the first unused FreeBSD signal number. Since Linux supports + * signals from 1 to 64 we are ok here as our SIGRTMIN = 65. + */ + SIGRTMIN, /* LINUX_SIGPWR */ + SIGSYS /* LINUX_SIGSYS */ +}; + +/* + * Map Linux RT signals to the FreeBSD RT signals. + */ +static inline int +linux_to_bsd_rt_signal(int sig) +{ + + return (SIGRTMIN + 1 + sig - LINUX_SIGRTMIN); +} + +static inline int +bsd_to_linux_rt_signal(int sig) +{ + + return (sig - SIGRTMIN - 1 + LINUX_SIGRTMIN); +} + +int +linux_to_bsd_signal(int sig) +{ + + KASSERT(sig > 0 && sig <= LINUX_SIGRTMAX, ("Invalid Linux signal\n")); + + if (sig < LINUX_SIGRTMIN) + return (linux_to_bsd_sigtbl[_SIG_IDX(sig)]); + + return (linux_to_bsd_rt_signal(sig)); +} + +int +bsd_to_linux_signal(int sig) +{ + + if (sig <= LINUX_SIGTBLSZ) + return (bsd_to_linux_sigtbl[_SIG_IDX(sig)]); + if (sig == SIGRTMIN) + return (LINUX_SIGPWR); + + return (bsd_to_linux_rt_signal(sig)); +} + +int +linux_to_bsd_sigaltstack(int lsa) +{ + int bsa = 0; + + if (lsa & LINUX_SS_DISABLE) + bsa |= SS_DISABLE; + /* + * Linux ignores SS_ONSTACK flag for ss + * parameter while FreeBSD prohibits it. + */ + return (bsa); +} + +int +bsd_to_linux_sigaltstack(int bsa) +{ + int lsa = 0; + + if (bsa & SS_DISABLE) + lsa |= LINUX_SS_DISABLE; + if (bsa & SS_ONSTACK) + lsa |= LINUX_SS_ONSTACK; + return (lsa); +} + +void +linux_to_bsd_sigset(l_sigset_t *lss, sigset_t *bss) +{ + int b, l; + + SIGEMPTYSET(*bss); + for (l = 1; l <= LINUX_SIGRTMAX; l++) { + if (LINUX_SIGISMEMBER(*lss, l)) { + b = linux_to_bsd_signal(l); + if (b) + SIGADDSET(*bss, b); + } + } +} + +void +bsd_to_linux_sigset(sigset_t *bss, l_sigset_t *lss) +{ + int b, l; + + LINUX_SIGEMPTYSET(*lss); + for (b = 1; b <= SIGRTMAX; b++) { + if (SIGISMEMBER(*bss, b)) { + l = bsd_to_linux_signal(b); + if (l) + LINUX_SIGADDSET(*lss, l); + } + } +} Added: user/dchagin/lemul/sys/compat/linux/linux.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/dchagin/lemul/sys/compat/linux/linux.h Sat Feb 21 20:40:40 2015 (r279107) @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2015 Dmitry Chagin + * 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 _LINUX_MI_H_ +#define _LINUX_MI_H_ + +/* sigaltstack */ +#define LINUX_SS_ONSTACK 1 +#define LINUX_SS_DISABLE 2 + +int linux_to_bsd_sigaltstack(int lsa); +int bsd_to_linux_sigaltstack(int bsa); + +/* sigset */ +#define LINUX_SIGTBLSZ 31 +#define LINUX_NSIG 64 + +typedef struct { + uint64_t __mask; +} l_sigset_t; + +/* primitives to manipulate sigset_t */ +#define LINUX_SIGEMPTYSET(set) (set).__mask = 0 +#define LINUX_SIGISMEMBER(set, sig) (1UL & ((set).__mask >> _SIG_IDX(sig))) +#define LINUX_SIGADDSET(set, sig) (set).__mask |= 1UL << _SIG_IDX(sig) + +void linux_to_bsd_sigset(l_sigset_t *, sigset_t *); +void bsd_to_linux_sigset(sigset_t *, l_sigset_t *); + +/* signaling */ +#define LINUX_SIGHUP 1 +#define LINUX_SIGINT 2 +#define LINUX_SIGQUIT 3 +#define LINUX_SIGILL 4 +#define LINUX_SIGTRAP 5 +#define LINUX_SIGABRT 6 +#define LINUX_SIGIOT LINUX_SIGABRT +#define LINUX_SIGBUS 7 +#define LINUX_SIGFPE 8 +#define LINUX_SIGKILL 9 +#define LINUX_SIGUSR1 10 +#define LINUX_SIGSEGV 11 +#define LINUX_SIGUSR2 12 +#define LINUX_SIGPIPE 13 +#define LINUX_SIGALRM 14 +#define LINUX_SIGTERM 15 +#define LINUX_SIGSTKFLT 16 +#define LINUX_SIGCHLD 17 +#define LINUX_SIGCONT 18 +#define LINUX_SIGSTOP 19 +#define LINUX_SIGTSTP 20 +#define LINUX_SIGTTIN 21 +#define LINUX_SIGTTOU 22 +#define LINUX_SIGURG 23 +#define LINUX_SIGXCPU 24 +#define LINUX_SIGXFSZ 25 +#define LINUX_SIGVTALRM 26 +#define LINUX_SIGPROF 27 +#define LINUX_SIGWINCH 28 +#define LINUX_SIGIO 29 +#define LINUX_SIGPOLL LINUX_SIGIO +#define LINUX_SIGPWR 30 +#define LINUX_SIGSYS 31 +#define LINUX_SIGRTMIN 32 +#define LINUX_SIGRTMAX LINUX_NSIG-1 + +#define LINUX_SIG_VALID(sig) ((sig) <= LINUX_SIGRTMAX && (sig) > 0) + +int linux_to_bsd_signal(int sig); +int bsd_to_linux_signal(int sig); + +#endif /* _LINUX_MI_H_ */ Modified: user/dchagin/lemul/sys/compat/linux/linux_fork.c ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_fork.c Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/compat/linux/linux_fork.c Sat Feb 21 20:40:40 2015 (r279107) @@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$"); #include #include #endif -#include #include #include #include @@ -159,9 +158,7 @@ linux_clone_proc(struct thread *td, stru exit_signal = args->flags & 0x000000ff; if (LINUX_SIG_VALID(exit_signal)) { - if (exit_signal <= LINUX_SIGTBLSZ) - exit_signal = - linux_to_bsd_signal[_SIG_IDX(exit_signal)]; + exit_signal = linux_to_bsd_signal(exit_signal); } else if (exit_signal != 0) return (EINVAL); Modified: user/dchagin/lemul/sys/compat/linux/linux_misc.c ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_misc.c Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/compat/linux/linux_misc.c Sat Feb 21 20:40:40 2015 (r279107) @@ -871,10 +871,10 @@ linux_common_wait(struct thread *td, int tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | - BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); + bsd_to_linux_signal(WTERMSIG(tmpstat)); else if (WIFSTOPPED(tmpstat)) tmpstat = (tmpstat & 0xffff00ff) | - (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); + (bsd_to_linux_signal(WSTOPSIG(tmpstat)) << 8); else if (WIFCONTINUED(tmpstat)) tmpstat = 0xffff; error = copyout(&tmpstat, status, sizeof(int)); Modified: user/dchagin/lemul/sys/compat/linux/linux_signal.c ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_signal.c Sat Feb 21 15:18:25 2015 (r279106) +++ user/dchagin/lemul/sys/compat/linux/linux_signal.c Sat Feb 21 20:40:40 2015 (r279107) @@ -60,42 +60,6 @@ static int linux_do_tkill(struct thread static void sicode_to_lsicode(int si_code, int *lsi_code); -#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) -void -linux_to_bsd_sigset(l_sigset_t *lss, sigset_t *bss) -{ - int b, l; - - SIGEMPTYSET(*bss); - bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); - bss->__bits[1] = lss->__bits[1]; - for (l = 1; l <= LINUX_SIGTBLSZ; l++) { - if (LINUX_SIGISMEMBER(*lss, l)) { - b = linux_to_bsd_signal[_SIG_IDX(l)]; - if (b) - SIGADDSET(*bss, b); - } - } -} - -void -bsd_to_linux_sigset(sigset_t *bss, l_sigset_t *lss) -{ - int b, l; - - LINUX_SIGEMPTYSET(*lss); - lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); - lss->__bits[1] = bss->__bits[1]; - for (b = 1; b <= LINUX_SIGTBLSZ; b++) { - if (SIGISMEMBER(*bss, b)) { - l = bsd_to_linux_signal[_SIG_IDX(b)]; - if (l) - LINUX_SIGADDSET(*lss, l); - } - } -} -#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ - static void linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa) { @@ -163,11 +127,7 @@ linux_do_sigaction(struct thread *td, in linux_to_bsd_sigaction(linux_nsa, nsa); } else nsa = NULL; - - if (linux_sig <= LINUX_SIGTBLSZ) - sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)]; - else - sig = linux_sig; + sig = linux_to_bsd_signal(linux_sig); error = kern_sigaction(td, sig, nsa, osa, 0); if (error) @@ -289,7 +249,7 @@ linux_sigprocmask(struct thread *td, str if (error) return (error); LINUX_SIGEMPTYSET(set); - set.__bits[0] = mask; + set.__mask = mask; } error = linux_do_sigprocmask(td, args->how, @@ -297,7 +257,7 @@ linux_sigprocmask(struct thread *td, str args->omask ? &oset : NULL); if (args->omask != NULL && !error) { - mask = oset.__bits[0]; + mask = oset.__mask; error = copyout(&mask, args->omask, sizeof(l_osigset_t)); } @@ -353,7 +313,7 @@ linux_sgetmask(struct thread *td, struct PROC_LOCK(p); bsd_to_linux_sigset(&td->td_sigmask, &mask); PROC_UNLOCK(p); - td->td_retval[0] = mask.__bits[0]; + td->td_retval[0] = mask.__mask; return (0); } @@ -371,9 +331,9 @@ linux_ssetmask(struct thread *td, struct PROC_LOCK(p); bsd_to_linux_sigset(&td->td_sigmask, &lset); - td->td_retval[0] = lset.__bits[0]; + td->td_retval[0] = lset.__mask; LINUX_SIGEMPTYSET(lset); - lset.__bits[0] = args->mask; + lset.__mask = args->mask; linux_to_bsd_sigset(&lset, &bset); td->td_sigmask = bset; SIG_CANTMASK(td->td_sigmask); @@ -401,7 +361,7 @@ linux_sigpending(struct thread *td, stru SIGSETAND(bset, td->td_sigmask); PROC_UNLOCK(p); bsd_to_linux_sigset(&bset, &lset); - mask = lset.__bits[0]; + mask = lset.__mask; return (copyout(&mask, args->mask, sizeof(mask))); } #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ @@ -505,7 +465,7 @@ linux_rt_sigtimedwait(struct thread *td, if (error) return (error); - sig = BSD_TO_LINUX_SIGNAL(info.ksi_signo); + sig = bsd_to_linux_signal(info.ksi_signo); if (args->ptr) { memset(&linfo, 0, sizeof(linfo)); @@ -537,10 +497,10 @@ linux_kill(struct thread *td, struct lin if (!LINUX_SIG_VALID(args->signum) && args->signum != 0) return (EINVAL); - if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ) - tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)]; + if (args->signum > 0) + tmp.signum = linux_to_bsd_signal(args->signum); else - tmp.signum = args->signum; + tmp.signum = 0; tmp.pid = args->pid; return (sys_kill(td, &tmp)); @@ -590,10 +550,10 @@ linux_tgkill(struct thread *td, struct l if (!LINUX_SIG_VALID(args->sig) && args->sig != 0) return (EINVAL); - if (args->sig > 0 && args->sig <= LINUX_SIGTBLSZ) - sig = linux_to_bsd_signal[_SIG_IDX(args->sig)]; + if (args->sig > 0) + sig = linux_to_bsd_signal(args->sig); else - sig = args->sig; + sig = 0; tdt = linux_tdfind(td, args->pid, args->tgid); if (tdt == NULL) @@ -628,8 +588,7 @@ linux_tkill(struct thread *td, struct li if (!LINUX_SIG_VALID(args->sig)) return (EINVAL); - - sig = BSD_TO_LINUX_SIGNAL(args->sig); + sig = linux_to_bsd_signal(args->sig); tdt = linux_tdfind(td, args->tid, -1); if (tdt == NULL) @@ -683,32 +642,6 @@ sicode_to_lsicode(int si_code, int *lsi_ } } -int -linux_to_bsd_sigaltstack(int lsa) -{ - int bsa = 0; - - if (lsa & LINUX_SS_DISABLE) - bsa |= SS_DISABLE; - /* - * Linux ignores SS_ONSTACK flag for ss - * parameter while FreeBSD prohibits it. - */ - return (bsa); -} - -int -bsd_to_linux_sigaltstack(int bsa) -{ - int lsa = 0; - - if (bsa & SS_DISABLE) - lsa |= LINUX_SS_DISABLE; - if (bsa & SS_ONSTACK) - lsa |= LINUX_SS_ONSTACK; - return (lsa); -} - void lsiginfo_to_ksiginfo(l_siginfo_t *lsi, ksiginfo_t *ksi, int sig) { @@ -740,7 +673,7 @@ linux_rt_sigqueueinfo(struct thread *td, if (linfo.lsi_code >= 0) return (EPERM); - sig = BSD_TO_LINUX_SIGNAL(args->sig); + sig = linux_to_bsd_signal(args->sig); error = ESRCH; if ((p = pfind(args->pid)) != NULL || @@ -796,9 +729,9 @@ siginfo_to_lsiginfo(siginfo_t *si, l_sig lsi->lsi_uid = si->si_uid; if (si->si_code == CLD_STOPPED) - lsi->lsi_status = BSD_TO_LINUX_SIGNAL(si->si_status); + lsi->lsi_status = bsd_to_linux_signal(si->si_status); else if (si->si_code == CLD_CONTINUED) - lsi->lsi_status = BSD_TO_LINUX_SIGNAL(SIGCONT); + lsi->lsi_status = LINUX_SIGCONT; else lsi->lsi_status = si->si_status; break; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 20:41:51 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DE0BEA89; Sat, 21 Feb 2015 20:41:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AEFC85EC; Sat, 21 Feb 2015 20:41:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LKfp65060644; Sat, 21 Feb 2015 20:41:51 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LKfpGP060643; Sat, 21 Feb 2015 20:41:51 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502212041.t1LKfpGP060643@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 20:41:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279108 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 20:41:52 -0000 Author: dchagin Date: Sat Feb 21 20:41:50 2015 New Revision: 279108 URL: https://svnweb.freebsd.org/changeset/base/279108 Log: Convert Linux sigsets before showing. Linux kernel displays sigset always as 16x4 bit mask. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 20:40:40 2015 (r279107) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 20:41:50 2015 (r279108) @@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$"); #include #endif /* __i386__ || __amd64__ */ +#include #include #include #include @@ -754,6 +755,7 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) segsz_t lsize; struct thread *td2; struct sigacts *ps; + l_sigset_t siglist, sigignore, sigcatch; int i; sx_slock(&proctree_lock); @@ -845,29 +847,25 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) /* * Signal masks - * - * We support up to 128 signals, while Linux supports 32, - * but we only define 32 (the same 32 as Linux, to boot), so - * just show the lower 32 bits of each mask. XXX hack. - * - * NB: on certain platforms (Sparc at least) Linux actually - * supports 64 signals, but this code is a long way from - * running on anything but i386, so ignore that for now. */ PROC_LOCK(p); - sbuf_printf(sb, "SigPnd:\t%08x\n", p->p_siglist.__bits[0]); - /* - * I can't seem to find out where the signal mask is in - * relation to struct proc, so SigBlk is left unimplemented. - */ - sbuf_printf(sb, "SigBlk:\t%08x\n", 0); /* XXX */ + bsd_to_linux_sigset(&p->p_siglist, &siglist); ps = p->p_sigacts; mtx_lock(&ps->ps_mtx); - sbuf_printf(sb, "SigIgn:\t%08x\n", ps->ps_sigignore.__bits[0]); - sbuf_printf(sb, "SigCgt:\t%08x\n", ps->ps_sigcatch.__bits[0]); + bsd_to_linux_sigset(&ps->ps_sigignore, &sigignore); + bsd_to_linux_sigset(&ps->ps_sigcatch, &sigcatch); mtx_unlock(&ps->ps_mtx); PROC_UNLOCK(p); + sbuf_printf(sb, "SigPnd:\t%016lx\n", siglist.__mask); + /* + * XXX. SigBlk - target thread's signal mask, td_sigmask. + * To implement SigBlk pseudofs should support proc/tid dir entries. + */ + sbuf_printf(sb, "SigBlk:\t%016x\n", 0); + sbuf_printf(sb, "SigIgn:\t%016lx\n", sigignore.__mask); + sbuf_printf(sb, "SigCgt:\t%016lx\n", sigcatch.__mask); + /* * Linux also prints the capability masks, but we don't have * capabilities yet, and when we do get them they're likely to From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 21:10:12 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0741E1D2; Sat, 21 Feb 2015 21:10:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CCCDE854; Sat, 21 Feb 2015 21:10:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LLABj7071910; Sat, 21 Feb 2015 21:10:11 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LLABfh071907; Sat, 21 Feb 2015 21:10:11 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502212110.t1LLABfh071907@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sat, 21 Feb 2015 21:10:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279109 - user/nwhitehorn/ppc64-pmap-rework/aim X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 21:10:12 -0000 Author: nwhitehorn Date: Sat Feb 21 21:10:10 2015 New Revision: 279109 URL: https://svnweb.freebsd.org/changeset/base/279109 Log: Fix locking problems on Apple G5s. Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Sat Feb 21 20:41:50 2015 (r279108) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Sat Feb 21 21:10:10 2015 (r279109) @@ -482,6 +482,7 @@ moea64_add_ofw_mappings(mmu_t mmup, phan { struct ofw_map translations[sz/(4*sizeof(cell_t))]; /*>= 4 cells per */ pcell_t acells, trans_cells[sz/sizeof(cell_t)]; + struct pvo_entry *pvo; register_t msr; vm_offset_t off; vm_paddr_t pa_base; @@ -535,8 +536,11 @@ moea64_add_ofw_mappings(mmu_t mmup, phan moea64_calc_wimg(pa_base + off, VM_MEMATTR_DEFAULT) == LPTE_M) continue; - if (moea64_pvo_find_va(kernel_pmap, - translations[i].om_va + off) != NULL) + PMAP_LOCK(kernel_pmap); + pvo = moea64_pvo_find_va(kernel_pmap, + translations[i].om_va + off); + PMAP_UNLOCK(kernel_pmap); + if (pvo != NULL) continue; moea64_kenter(mmup, translations[i].om_va + off, Modified: user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Sat Feb 21 20:41:50 2015 (r279108) +++ user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Sat Feb 21 21:10:10 2015 (r279109) @@ -342,6 +342,7 @@ moea64_pte_unset_native(mmu_t mmu, struc ptelo = be64toh(pt->pte_lo); *((volatile int32_t *)(&pt->pte_hi) + 1) = 0; /* Release lock */ critical_exit(); + rw_runlock(&moea64_eviction_lock); /* Keep statistics */ moea64_pte_valid--; From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 21:12:13 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6FBDD2BC; Sat, 21 Feb 2015 21:12:13 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5B5728EF; Sat, 21 Feb 2015 21:12:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LLCDSq075633; Sat, 21 Feb 2015 21:12:13 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LLCDY1075632; Sat, 21 Feb 2015 21:12:13 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502212112.t1LLCDY1075632@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 21:12:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279110 - user/dchagin/lemul/sys/compat/linux X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 21:12:13 -0000 Author: dchagin Date: Sat Feb 21 21:12:12 2015 New Revision: 279110 URL: https://svnweb.freebsd.org/changeset/base/279110 Log: Convert Linux signal number to the FreeBSD. Modified: user/dchagin/lemul/sys/compat/linux/linux_timer.c Modified: user/dchagin/lemul/sys/compat/linux/linux_timer.c ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_timer.c Sat Feb 21 21:10:10 2015 (r279109) +++ user/dchagin/lemul/sys/compat/linux/linux_timer.c Sat Feb 21 21:12:12 2015 (r279110) @@ -58,7 +58,7 @@ linux_convert_l_sigevent(struct l_sigeve switch (l_sig->sigev_notify) { case L_SIGEV_SIGNAL: sig->sigev_notify = SIGEV_SIGNAL; - CP(*l_sig, *sig, sigev_signo); + sig->sigev_signo = linux_to_bsd_signal(l_sig->sigev_signo); PTRIN_CP(*l_sig, *sig, sigev_value.sival_ptr); break; case L_SIGEV_NONE: @@ -75,7 +75,7 @@ linux_convert_l_sigevent(struct l_sigeve case L_SIGEV_THREAD_ID: sig->sigev_notify = SIGEV_THREAD_ID; CP2(*l_sig, *sig, _l_sigev_un._tid, sigev_notify_thread_id); - CP(*l_sig, *sig, sigev_signo); + sig->sigev_signo = linux_to_bsd_signal(l_sig->sigev_signo); PTRIN_CP(*l_sig, *sig, sigev_value.sival_ptr); break; default: From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 21:28:46 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 68AC05F2; Sat, 21 Feb 2015 21:28:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53BD7A06; Sat, 21 Feb 2015 21:28:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LLSkFt081071; Sat, 21 Feb 2015 21:28:46 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LLSkPL081070; Sat, 21 Feb 2015 21:28:46 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502212128.t1LLSkPL081070@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 21:28:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279111 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 21:28:46 -0000 Author: dchagin Date: Sat Feb 21 21:28:45 2015 New Revision: 279111 URL: https://svnweb.freebsd.org/changeset/base/279111 Log: Fix linprocfs build on i386 - specify proper format for int64_t. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 21:12:12 2015 (r279110) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 21:28:45 2015 (r279111) @@ -857,14 +857,14 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) mtx_unlock(&ps->ps_mtx); PROC_UNLOCK(p); - sbuf_printf(sb, "SigPnd:\t%016lx\n", siglist.__mask); + sbuf_printf(sb, "SigPnd:\t%016jx\n", siglist.__mask); /* * XXX. SigBlk - target thread's signal mask, td_sigmask. * To implement SigBlk pseudofs should support proc/tid dir entries. */ sbuf_printf(sb, "SigBlk:\t%016x\n", 0); - sbuf_printf(sb, "SigIgn:\t%016lx\n", sigignore.__mask); - sbuf_printf(sb, "SigCgt:\t%016lx\n", sigcatch.__mask); + sbuf_printf(sb, "SigIgn:\t%016jx\n", sigignore.__mask); + sbuf_printf(sb, "SigCgt:\t%016jx\n", sigcatch.__mask); /* * Linux also prints the capability masks, but we don't have From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 21:59:05 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 62C27F25; Sat, 21 Feb 2015 21:59:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CB50D51; Sat, 21 Feb 2015 21:59:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LLx5xh096160; Sat, 21 Feb 2015 21:59:05 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LLx5QP096159; Sat, 21 Feb 2015 21:59:05 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502212159.t1LLx5QP096159@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sat, 21 Feb 2015 21:59:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279112 - user/nwhitehorn/ppc64-pmap-rework/aim X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 21:59:05 -0000 Author: nwhitehorn Date: Sat Feb 21 21:59:04 2015 New Revision: 279112 URL: https://svnweb.freebsd.org/changeset/base/279112 Log: Simplicity and correctness improvements to native page table access. Modified: user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Sat Feb 21 21:28:45 2015 (r279111) +++ user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Sat Feb 21 21:59:04 2015 (r279112) @@ -196,10 +196,10 @@ static int64_t moea64_pte_unset_native(m /* * Utility routines. */ -static void moea64_bootstrap_native(mmu_t mmup, - vm_offset_t kernelstart, vm_offset_t kernelend); -static void moea64_cpu_bootstrap_native(mmu_t, int ap); -static void tlbia(void); +static void moea64_bootstrap_native(mmu_t mmup, + vm_offset_t kernelstart, vm_offset_t kernelend); +static void moea64_cpu_bootstrap_native(mmu_t, int ap); +static void tlbia(void); static mmu_method_t moea64_native_methods[] = { /* Internal interfaces */ @@ -256,8 +256,6 @@ moea64_pte_clear_native(mmu_t mmu, struc moea64_pte_from_pvo(pvo, &properpt); - /* See "Resetting the Reference Bit" in arch manual */ - rw_rlock(&moea64_eviction_lock); if ((pt->pte_hi & LPTE_AVPN_MASK) != (properpt.pte_hi & LPTE_AVPN_MASK)) { @@ -266,52 +264,29 @@ moea64_pte_clear_native(mmu_t mmu, struc return (-1); } - /* - * As shown in Section 7.6.3.2.3 - */ - PTESYNC(); - ptelo = atomic_swap_32((volatile int32_t *)(&pt->pte_lo) + 1, - (pt->pte_lo & ~ptebit) & 0xffffffff); - ptelo |= pt->pte_lo; - rw_runlock(&moea64_eviction_lock); + if (ptebit == LPTE_REF) { + /* See "Resetting the Reference Bit" in arch manual */ + PTESYNC(); + /* 2-step here safe: precision is not guaranteed */ + ptelo |= pt->pte_lo; + + /* One-byte store to avoid touching the C bit */ + ((volatile uint8_t *)(&pt->pte_lo))[6] = + ((uint8_t *)(&properpt.pte_lo))[6]; + rw_runlock(&moea64_eviction_lock); - critical_enter(); - TLBIE(pvo->pvo_vpn); - critical_exit(); + critical_enter(); + TLBIE(pvo->pvo_vpn); + critical_exit(); + } else { + rw_runlock(&moea64_eviction_lock); + ptelo = moea64_pte_unset_native(mmu, pvo); + moea64_pte_insert_native(mmu, pvo); + } return (ptelo & (LPTE_REF | LPTE_CHG)); } -static int -moea64_pte_set_native(struct lpte *pvo_pt, uintptr_t offset) -{ - volatile struct lpte *pt = moea64_pteg_table + offset; - int result; - - result = atomic_cmpset_32((volatile int32_t *)(&pt->pte_hi) + 1, - pt->pte_hi & ~(LPTE_LOCKED | LPTE_VALID), LPTE_LOCKED); - if (!result) - return (-1); - - /* - * Update the PTE as defined in section 7.6.3.1. - */ - pt->pte_lo = pvo_pt->pte_lo; - EIEIO(); -#ifdef __powerpc64__ - pt->pte_hi = pvo_pt->pte_hi; -#else - *(volatile int32_t *)(&pt->pte_hi) = pvo_pt->pte_hi >> 32; - EIEIO(); - *((volatile int32_t *)(&pt->pte_hi) + 1) = pvo_pt->pte_hi & 0xffffffff; -#endif - PTESYNC(); - - /* Keep statistics */ - moea64_pte_valid++; - return (0); -} - static int64_t moea64_pte_unset_native(mmu_t mmu, struct pvo_entry *pvo) { @@ -332,7 +307,8 @@ moea64_pte_unset_native(mmu_t mmu, struc } /* - * Invalidate the pte. + * Invalidate the pte, briefly locking it to collect RC bits. No + * atomics needed since this is protected against eviction by the lock. */ isync(); critical_enter(); @@ -355,41 +331,30 @@ moea64_pte_replace_native(mmu_t mmu, str { volatile struct lpte *pt = moea64_pteg_table + pvo->pvo_pte.slot; struct lpte properpt; - int result; - volatile int32_t lowbits; + int64_t ptelo; PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); - moea64_pte_from_pvo(pvo, &properpt); - - result = atomic_cmpset_32((volatile int32_t *)(&pt->pte_hi) + 1, - properpt.pte_hi & 0xffffffff, (properpt.pte_hi | LPTE_LOCKED) - & 0xffffffff); - - if (result && flags == 0) { - /* Just some software bits changing. The order in which this is - * done is important on 32-bit systems. */ - *(volatile int32_t *)(&pt->pte_hi) = properpt.pte_hi >> 32; - *(volatile int32_t *)(&pt->pte_lo) = properpt.pte_lo >> 32; - pt->pte_lo = properpt.pte_lo & 0xffffffff; - lowbits = atomic_swap_32((volatile int32_t *)(&pt->pte_lo) + 1, - *((int32_t *)(&properpt.pte_lo) + 1)); - EIEIO(); - *((volatile int32_t *)(&pt->pte_hi) + 1) = - properpt.pte_hi & 0xffffffff; - return (lowbits & (LPTE_REF | LPTE_CHG)); + if (flags == 0) { + /* Just some software bits changing. */ + moea64_pte_from_pvo(pvo, &properpt); + + rw_rlock(&moea64_eviction_lock); + if ((pt->pte_hi & LPTE_AVPN_MASK) != + (properpt.pte_hi & LPTE_AVPN_MASK)) { + rw_runlock(&moea64_eviction_lock); + return (-1); + } + pt->pte_hi = properpt.pte_hi; + ptelo = pt->pte_lo; + rw_runlock(&moea64_eviction_lock); + } else { + /* Otherwise, need reinsertion and deletion */ + ptelo = moea64_pte_unset_native(mmu, pvo); + moea64_pte_insert_native(mmu, pvo); } - /* - * Anything else requires invalidation and reinsertion, so just do that - */ - - lowbits = -1; - if (result) - lowbits = moea64_pte_unset_native(mmu, pvo); - moea64_pte_insert_native(mmu, pvo); - - return (lowbits); + return (ptelo); } static void @@ -524,38 +489,106 @@ tlbia(void) TLBSYNC(); } -static __inline int -moea64_pte_spillable_ident(uintptr_t slotbase) +static int +atomic_pte_lock(volatile struct lpte *pte, uint64_t bitmask, uint64_t *oldhi) +{ + int ret; + uint32_t oldhihalf; + + /* + * Note: in principle, if just the locked bit were set here, we + * could avoid needing the eviction lock. However, eviction occurs + * so rarely that it isn't worth bothering about in practice. + */ + + __asm __volatile ( + "1:\tlwarx %1, 0, %3\n\t" /* load old value */ + "and. %0,%1,%4\n\t" /* check if any bits set */ + "bne 2f\n\t" /* exit if any set */ + "stwcx. %5, 0, %3\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 3f\n\t" /* we've succeeded */ + "2:\n\t" + "stwcx. %1, 0, %3\n\t" /* clear reservation (74xx) */ + "li %0, 0\n\t" /* failure - retval = 0 */ + "3:\n\t" + : "=&r" (ret), "=&r"(oldhihalf), "=m" (pte->pte_hi) + : "r" ((volatile char *)&pte->pte_hi + 4), "r" (bitmask), + "r" (LPTE_LOCKED), "m" (pte->pte_hi) + : "cr0", "cr1", "cr2", "memory"); + + *oldhi = (pte->pte_hi & 0xffffffff00000000ULL) | oldhihalf; + + return (ret); +} + +static uintptr_t +moea64_insert_to_pteg_native(struct lpte *pvo_pt, uintptr_t slotbase, + uint64_t mask) { - volatile struct lpte *pt; - int i, j; + volatile struct lpte *pt; + uint64_t oldptehi, va; uintptr_t k; + int i, j; /* Start at a random slot */ i = mftb() % 8; - k = -1; for (j = 0; j < 8; j++) { - pt = &moea64_pteg_table[slotbase + (i + j) % 8]; - if (pt->pte_hi & LPTE_WIRED) - continue; - - /* This is a candidate, so remember it */ - k = (i + j) % 8; - - /* Try to get a page that has not been used lately */ - if (!(pt->pte_lo & LPTE_REF) || !(pt->pte_hi & LPTE_VALID)) - return (k); + k = slotbase + (i + j) % 8; + pt = &moea64_pteg_table[k]; + /* Invalidate and seize lock only if no bits in mask set */ + if (atomic_pte_lock(pt, mask, &oldptehi)) /* Lock obtained */ + break; } - + + if (j == 8) + return (-1); + + if (oldptehi & LPTE_VALID) { + KASSERT(!(oldptehi & LPTE_WIRED), ("Unmapped wired entry")); + /* + * Need to invalidate old entry completely: see + * "Modifying a Page Table Entry". Need to reconstruct + * the virtual address for the outgoing entry to do that. + */ + if (oldptehi & LPTE_BIG) + va = oldptehi >> moea64_large_page_shift; + else + va = oldptehi >> ADDR_PIDX_SHFT; + if (oldptehi & LPTE_HID) + va = (((k >> 3) ^ moea64_pteg_mask) ^ va) & + VSID_HASH_MASK; + else + va = ((k >> 3) ^ va) & VSID_HASH_MASK; + va |= (oldptehi & LPTE_AVPN_MASK) << + (ADDR_API_SHFT64 - ADDR_PIDX_SHFT); + PTESYNC(); + TLBIE(va); + moea64_pte_valid--; + moea64_pte_overflow++; + } + + /* + * Update the PTE as per "Adding a Page Table Entry". Lock is released + * by setting the high doubleworld. + */ + pt->pte_lo = pvo_pt->pte_lo; + EIEIO(); + pt->pte_hi = pvo_pt->pte_hi; + PTESYNC(); + + /* Keep statistics */ + moea64_pte_valid++; + return (k); } static int moea64_pte_insert_native(mmu_t mmu, struct pvo_entry *pvo) { - volatile struct lpte *pt; - struct lpte insertpt; - int i; + struct lpte insertpt; + uintptr_t slot; PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED); @@ -568,17 +601,13 @@ moea64_pte_insert_native(mmu_t mmu, stru /* * First try primary hash. */ - pvo->pvo_pte.slot &= ~7UL; /* Base slot address */ - for (pt = &moea64_pteg_table[pvo->pvo_pte.slot], i = 0; i < 8; - i++, pt++) { - if (!(pt->pte_hi & LPTE_VALID)) { - if (moea64_pte_set_native(&insertpt, - pvo->pvo_pte.slot + i) == 0) { - rw_runlock(&moea64_eviction_lock); - pvo->pvo_pte.slot += i; - return (0); - } - } + pvo->pvo_pte.slot &= ~7ULL; /* Base slot address */ + slot = moea64_insert_to_pteg_native(&insertpt, pvo->pvo_pte.slot, + LPTE_VALID | LPTE_WIRED | LPTE_LOCKED); + if (slot != -1) { + rw_runlock(&moea64_eviction_lock); + pvo->pvo_pte.slot = slot; + return (0); } /* @@ -587,17 +616,12 @@ moea64_pte_insert_native(mmu_t mmu, stru pvo->pvo_vaddr ^= PVO_HID; insertpt.pte_hi ^= LPTE_HID; pvo->pvo_pte.slot ^= (moea64_pteg_mask << 3); - - for (pt = &moea64_pteg_table[pvo->pvo_pte.slot], i = 0; i < 8; - i++, pt++) { - if (!(pt->pte_hi & LPTE_VALID)) { - if (moea64_pte_set_native(&insertpt, - pvo->pvo_pte.slot + i) == 0) { - rw_runlock(&moea64_eviction_lock); - pvo->pvo_pte.slot += i; - return (0); - } - } + slot = moea64_insert_to_pteg_native(&insertpt, pvo->pvo_pte.slot, + LPTE_VALID | LPTE_WIRED | LPTE_LOCKED); + if (slot != -1) { + rw_runlock(&moea64_eviction_lock); + pvo->pvo_pte.slot = slot; + return (0); } /* @@ -610,51 +634,29 @@ moea64_pte_insert_native(mmu_t mmu, stru rw_wlock(&moea64_eviction_lock); } - i = moea64_pte_spillable_ident(pvo->pvo_pte.slot); - if (i < 0) { - /* Try other hash table? */ - pvo->pvo_vaddr ^= PVO_HID; - insertpt.pte_hi ^= LPTE_HID; - pvo->pvo_pte.slot ^= (moea64_pteg_mask << 3); - i = moea64_pte_spillable_ident(pvo->pvo_pte.slot); + slot = moea64_insert_to_pteg_native(&insertpt, pvo->pvo_pte.slot, + LPTE_WIRED | LPTE_LOCKED); + if (slot != -1) { + rw_wunlock(&moea64_eviction_lock); + pvo->pvo_pte.slot = slot; + return (0); } - if (i < 0) { - /* No freeable slots in either PTEG? We're hosed. */ + /* Try other hash table. Now we're getting desperate... */ + pvo->pvo_vaddr ^= PVO_HID; + insertpt.pte_hi ^= LPTE_HID; + pvo->pvo_pte.slot ^= (moea64_pteg_mask << 3); + slot = moea64_insert_to_pteg_native(&insertpt, pvo->pvo_pte.slot, + LPTE_WIRED | LPTE_LOCKED); + if (slot != -1) { rw_wunlock(&moea64_eviction_lock); - panic("moea64_pte_insert: overflow"); - return (-1); + pvo->pvo_pte.slot = slot; + return (0); } - pvo->pvo_pte.slot += i; - - /* - * Collect ref/changed bits from the victim and replace it. - */ - pt = &moea64_pteg_table[pvo->pvo_pte.slot]; - - /* - * Invalidate the pte. - */ - isync(); - critical_enter(); - pt->pte_hi &= ~LPTE_VALID; - PTESYNC(); - TLBIE((pt->pte_hi & LPTE_AVPN_MASK) << - (ADDR_API_SHFT64 - ADDR_PIDX_SHFT)); - critical_exit(); - - /* New translation */ - pt->pte_lo = insertpt.pte_lo; - EIEIO(); - pt->pte_hi = insertpt.pte_hi; - PTESYNC(); - + /* No freeable slots in either PTEG? We're hosed. */ rw_wunlock(&moea64_eviction_lock); - - /* Keep statistics */ - moea64_pte_valid++; - - return (0); + panic("moea64_pte_insert: overflow"); + return (-1); } From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 22:10:15 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8CF572CF; Sat, 21 Feb 2015 22:10:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 78800E27; Sat, 21 Feb 2015 22:10:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LMAF8p001500; Sat, 21 Feb 2015 22:10:15 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LMAFUe001499; Sat, 21 Feb 2015 22:10:15 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502212210.t1LMAFUe001499@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 22:10:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279113 - user/dchagin/lemul/sys/fs/procfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 22:10:15 -0000 Author: dchagin Date: Sat Feb 21 22:10:14 2015 New Revision: 279113 URL: https://svnweb.freebsd.org/changeset/base/279113 Log: Remove extra proc visibility check as it has been done by pn_vis which is pointed to the procfs_candebug(). Modified: user/dchagin/lemul/sys/fs/procfs/procfs_mem.c Modified: user/dchagin/lemul/sys/fs/procfs/procfs_mem.c ============================================================================== --- user/dchagin/lemul/sys/fs/procfs/procfs_mem.c Sat Feb 21 21:59:04 2015 (r279112) +++ user/dchagin/lemul/sys/fs/procfs/procfs_mem.c Sat Feb 21 22:10:14 2015 (r279113) @@ -56,16 +56,9 @@ int procfs_doprocmem(PFS_FILL_ARGS) { - int error; if (uio->uio_resid == 0) return (0); - PROC_LOCK(p); - error = p_candebug(td, p); - PROC_UNLOCK(p); - if (error == 0) - error = proc_rwmem(p, uio); - - return (error); + return (proc_rwmem(p, uio)); } From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 22:27:59 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9CBA0865; Sat, 21 Feb 2015 22:27:59 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7CE78FB0; Sat, 21 Feb 2015 22:27:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LMRxFC010970; Sat, 21 Feb 2015 22:27:59 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LMRwFV010966; Sat, 21 Feb 2015 22:27:58 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502212227.t1LMRwFV010966@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 22:27:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279116 - user/dchagin/lemul/sys/i386/linux X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 22:27:59 -0000 Author: dchagin Date: Sat Feb 21 22:27:57 2015 New Revision: 279116 URL: https://svnweb.freebsd.org/changeset/base/279116 Log: Finish r279107. Fix build on i386. Modified: user/dchagin/lemul/sys/i386/linux/linux.h user/dchagin/lemul/sys/i386/linux/linux_machdep.c user/dchagin/lemul/sys/i386/linux/linux_ptrace.c user/dchagin/lemul/sys/i386/linux/linux_sysvec.c Modified: user/dchagin/lemul/sys/i386/linux/linux.h ============================================================================== --- user/dchagin/lemul/sys/i386/linux/linux.h Sat Feb 21 22:25:24 2015 (r279115) +++ user/dchagin/lemul/sys/i386/linux/linux.h Sat Feb 21 22:27:57 2015 (r279116) @@ -33,6 +33,7 @@ #include /* for sigval union */ +#include #include /* Modified: user/dchagin/lemul/sys/i386/linux/linux_machdep.c ============================================================================== --- user/dchagin/lemul/sys/i386/linux/linux_machdep.c Sat Feb 21 22:25:24 2015 (r279115) +++ user/dchagin/lemul/sys/i386/linux/linux_machdep.c Sat Feb 21 22:27:57 2015 (r279116) @@ -677,7 +677,7 @@ linux_sigaction(struct thread *td, struc act.lsa_flags = osa.lsa_flags; act.lsa_restorer = osa.lsa_restorer; LINUX_SIGEMPTYSET(act.lsa_mask); - act.lsa_mask.__bits[0] = osa.lsa_mask; + act.lsa_mask.__mask = osa.lsa_mask; } error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL, @@ -687,7 +687,7 @@ linux_sigaction(struct thread *td, struc osa.lsa_handler = oact.lsa_handler; osa.lsa_flags = oact.lsa_flags; osa.lsa_restorer = oact.lsa_restorer; - osa.lsa_mask = oact.lsa_mask.__bits[0]; + osa.lsa_mask = oact.lsa_mask.__mask; error = copyout(&osa, args->osa, sizeof(l_osigaction_t)); } @@ -711,7 +711,7 @@ linux_sigsuspend(struct thread *td, stru #endif LINUX_SIGEMPTYSET(mask); - mask.__bits[0] = args->mask; + mask.__mask = args->mask; linux_to_bsd_sigset(&mask, &sigmask); return (kern_sigsuspend(td, sigmask)); } @@ -1100,7 +1100,7 @@ linux_waitid(struct thread *td, struct l if (td->td_retval[0] == 0) bzero(&lsi, sizeof(lsi)); else { - sig = BSD_TO_LINUX_SIGNAL(siginfo.si_signo); + sig = bsd_to_linux_signal(siginfo.si_signo); siginfo_to_lsiginfo(&siginfo, &lsi, sig); } error = copyout(&lsi, args->info, sizeof(lsi)); Modified: user/dchagin/lemul/sys/i386/linux/linux_ptrace.c ============================================================================== --- user/dchagin/lemul/sys/i386/linux/linux_ptrace.c Sat Feb 21 22:25:24 2015 (r279115) +++ user/dchagin/lemul/sys/i386/linux/linux_ptrace.c Sat Feb 21 22:27:57 2015 (r279116) @@ -91,8 +91,7 @@ static __inline int map_signum(int signum) { - if (signum > 0 && signum <= LINUX_SIGTBLSZ) - signum = linux_to_bsd_signal[_SIG_IDX(signum)]; + signum = linux_to_bsd_signal(signum); return ((signum == SIGSTOP)? 0 : signum); } Modified: user/dchagin/lemul/sys/i386/linux/linux_sysvec.c ============================================================================== --- user/dchagin/lemul/sys/i386/linux/linux_sysvec.c Sat Feb 21 22:25:24 2015 (r279115) +++ user/dchagin/lemul/sys/i386/linux/linux_sysvec.c Sat Feb 21 22:27:57 2015 (r279116) @@ -458,7 +458,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo /* * Build the argument list for the signal handler. */ - sig = BSD_TO_LINUX_SIGNAL(sig); + sig = bsd_to_linux_signal(sig); bzero(&frame, sizeof(frame)); @@ -484,7 +484,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask); - frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0]; + frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__mask; frame.sf_sc.uc_mcontext.sc_gs = rgs(); frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs; frame.sf_sc.uc_mcontext.sc_es = regs->tf_es; @@ -563,7 +563,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t struct l_sigframe *fp, frame; l_sigset_t lmask; int sig, code; - int oonstack, i; + int oonstack; PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; @@ -599,7 +599,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t /* * Build the argument list for the signal handler. */ - sig = BSD_TO_LINUX_SIGNAL(sig); + sig = bsd_to_linux_signal(sig); bzero(&frame, sizeof(frame)); @@ -611,7 +611,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t /* * Build the signal context to be used by sigreturn. */ - frame.sf_sc.sc_mask = lmask.__bits[0]; + frame.sf_sc.sc_mask = lmask.__mask; frame.sf_sc.sc_gs = rgs(); frame.sf_sc.sc_fs = regs->tf_fs; frame.sf_sc.sc_es = regs->tf_es; @@ -633,8 +633,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t frame.sf_sc.sc_cr2 = (register_t)ksi->ksi_addr; frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(ksi->ksi_trapno); - for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) - frame.sf_extramask[i] = lmask.__bits[i+1]; + frame.sf_extramask[0] = lmask.__mask; if (copyout(&frame, fp, sizeof(frame)) != 0) { /* @@ -677,7 +676,7 @@ linux_sigreturn(struct thread *td, struc struct trapframe *regs; l_sigset_t lmask; sigset_t bmask; - int eflags, i; + int eflags; ksiginfo_t ksi; regs = td->td_frame; @@ -718,9 +717,7 @@ linux_sigreturn(struct thread *td, struc return (EINVAL); } - lmask.__bits[0] = frame.sf_sc.sc_mask; - for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) - lmask.__bits[i+1] = frame.sf_extramask[i]; + lmask.__mask = frame.sf_sc.sc_mask; linux_to_bsd_sigset(&lmask, &bmask); kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); @@ -959,8 +956,8 @@ struct sysentvec linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, .sv_mask = 0, - .sv_sigsize = LINUX_SIGTBLSZ, - .sv_sigtbl = bsd_to_linux_signal, + .sv_sigsize = 0, + .sv_sigtbl = NULL, .sv_errsize = ELAST + 1, .sv_errtbl = bsd_to_linux_errno, .sv_transtrap = translate_traps, From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 23:04:19 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D1C7569D; Sat, 21 Feb 2015 23:04:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BCFB0400; Sat, 21 Feb 2015 23:04:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LN4Joi030196; Sat, 21 Feb 2015 23:04:19 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LN4JGh030192; Sat, 21 Feb 2015 23:04:19 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502212304.t1LN4JGh030192@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sat, 21 Feb 2015 23:04:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279118 - user/nwhitehorn/ppc64-pmap-rework/aim X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 23:04:19 -0000 Author: nwhitehorn Date: Sat Feb 21 23:04:18 2015 New Revision: 279118 URL: https://svnweb.freebsd.org/changeset/base/279118 Log: Keep overflow statistics updated. Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Modified: user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Sat Feb 21 22:38:32 2015 (r279117) +++ user/nwhitehorn/ppc64-pmap-rework/aim/mmu_oea64.c Sat Feb 21 23:04:18 2015 (r279118) @@ -1256,8 +1256,10 @@ moea64_enter(mmu_t mmu, pmap_t pmap, vm_ error = 0; /* If not in page table, reinsert it */ - if (MOEA64_PTE_SYNCH(mmu, oldpvo) < 0) + if (MOEA64_PTE_SYNCH(mmu, oldpvo) < 0) { + moea64_pte_overflow--; MOEA64_PTE_INSERT(mmu, oldpvo); + } /* Then just clean up and go home */ PV_PAGE_UNLOCK(m); Modified: user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Sat Feb 21 22:38:32 2015 (r279117) +++ user/nwhitehorn/ppc64-pmap-rework/aim/moea64_native.c Sat Feb 21 23:04:18 2015 (r279118) @@ -302,6 +302,7 @@ moea64_pte_unset_native(mmu_t mmu, struc if ((pt->pte_hi & LPTE_AVPN_MASK) != (properpt.pte_hi & LPTE_AVPN_MASK)) { /* Evicted */ + moea64_pte_overflow--; rw_runlock(&moea64_eviction_lock); return (-1); } From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 23:21:41 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 689909E3; Sat, 21 Feb 2015 23:21:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 396FF7D0; Sat, 21 Feb 2015 23:21:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1LNLfve039272; Sat, 21 Feb 2015 23:21:41 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1LNLf2K039270; Sat, 21 Feb 2015 23:21:41 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201502212321.t1LNLf2K039270@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sat, 21 Feb 2015 23:21:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279120 - user/nwhitehorn/ppc64-pmap-rework/ps3 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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, 21 Feb 2015 23:21:41 -0000 Author: nwhitehorn Date: Sat Feb 21 23:21:40 2015 New Revision: 279120 URL: https://svnweb.freebsd.org/changeset/base/279120 Log: Fix reinsertion of pages into secondary PTE group. Something here is still causing instability under high load, but this is a step forward at least. Modified: user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c Modified: user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c Sat Feb 21 23:20:05 2015 (r279119) +++ user/nwhitehorn/ppc64-pmap-rework/ps3/mmu_ps3.c Sat Feb 21 23:21:40 2015 (r279120) @@ -185,15 +185,16 @@ mps3_pte_clear(mmu_t mmu, struct pvo_ent rw_rlock(&mps3_eviction_lock); refchg = mps3_pte_synch(mmu, pvo); - if (refchg < 0) { - rw_runlock(&mps3_eviction_lock); - return (refchg); - } + if (refchg < 0) { + rw_runlock(&mps3_eviction_lock); + return (refchg); + } moea64_pte_from_pvo(pvo, &pte); pte.pte_lo |= refchg; pte.pte_lo &= ~ptebit; + /* XXX: race on RC bits between write and sync. Anything to do? */ lv1_write_htab_entry(mps3_vas_id, pvo->pvo_pte.slot, pte.pte_hi, pte.pte_lo); rw_runlock(&mps3_eviction_lock); @@ -208,10 +209,11 @@ mps3_pte_unset(mmu_t mmu, struct pvo_ent rw_rlock(&mps3_eviction_lock); refchg = mps3_pte_synch(mmu, pvo); - if (refchg < 0) { - rw_runlock(&mps3_eviction_lock); - return (-1); - } + if (refchg < 0) { + moea64_pte_overflow--; + rw_runlock(&mps3_eviction_lock); + return (-1); + } /* XXX: race on RC bits between unset and sync. Anything to do? */ lv1_write_htab_entry(mps3_vas_id, pvo->pvo_pte.slot, 0, 0); rw_runlock(&mps3_eviction_lock); @@ -227,8 +229,13 @@ mps3_pte_insert(mmu_t mmu, struct pvo_en struct lpte pte, evicted; uint64_t index; + if (pvo->pvo_vaddr & PVO_HID) { + /* Hypercall needs primary PTEG */ + pvo->pvo_vaddr &= ~PVO_HID; + pvo->pvo_pte.slot ^= (moea64_pteg_mask << 3); + } + pvo->pvo_pte.slot &= ~7UL; - pvo->pvo_vaddr &= ~PVO_HID; moea64_pte_from_pvo(pvo, &pte); evicted.pte_hi = 0; PTESYNC();