From owner-svn-src-stable-11@freebsd.org Sun Dec 31 02:48:17 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 946D0E83767; Sun, 31 Dec 2017 02:48:17 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60FB97C20A; Sun, 31 Dec 2017 02:48:17 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV2mGDF077609; Sun, 31 Dec 2017 02:48:16 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV2mGoC077608; Sun, 31 Dec 2017 02:48:16 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310248.vBV2mGoC077608@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 02:48:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327403 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 327403 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 02:48:17 -0000 Author: mjg Date: Sun Dec 31 02:48:16 2017 New Revision: 327403 URL: https://svnweb.freebsd.org/changeset/base/327403 Log: MFC r321922: amd64: annotate the syscall return address check with __predict_false before: 0xffffffff80b03ebb <+2059>: mov 0x460(%r14),%rax 0xffffffff80b03ec2 <+2066>: mov 0x98(%rax),%rax 0xffffffff80b03ec9 <+2073>: shr $0x2f,%rax 0xffffffff80b03ecd <+2077>: je 0xffffffff80b03edd 0xffffffff80b03ecf <+2079>: mov 0x3f8(%r14),%rax 0xffffffff80b03ed6 <+2086>: orl $0x1,0xc8(%rax) 0xffffffff80b03edd <+2093>: add $0xf8,%rsp after: 0xffffffff80b03ebb <+2059>: mov 0x460(%r14),%rax 0xffffffff80b03ec2 <+2066>: mov 0x98(%rax),%rax 0xffffffff80b03ec9 <+2073>: shr $0x2f,%rax 0xffffffff80b03ecd <+2077>: jne 0xffffffff80b03eef 0xffffffff80b03ecf <+2079>: add $0xf8,%rsp Modified: stable/11/sys/amd64/amd64/trap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/trap.c ============================================================================== --- stable/11/sys/amd64/amd64/trap.c Sun Dec 31 02:31:01 2017 (r327402) +++ stable/11/sys/amd64/amd64/trap.c Sun Dec 31 02:48:16 2017 (r327403) @@ -947,6 +947,6 @@ amd64_syscall(struct thread *td, int traced) * not be safe. Instead, use the full return path which * catches the problem safely. */ - if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) + if (__predict_false(td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS)) set_pcb_flags(td->td_pcb, PCB_FULL_IRET); } From owner-svn-src-stable-11@freebsd.org Sun Dec 31 03:15:46 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D7BA8E85173; Sun, 31 Dec 2017 03:15:46 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A45937D83C; Sun, 31 Dec 2017 03:15:46 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV3FjPx091147; Sun, 31 Dec 2017 03:15:45 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV3FjCO091146; Sun, 31 Dec 2017 03:15:45 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310315.vBV3FjCO091146@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 03:15:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327406 - stable/11/sys/fs/tmpfs X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/fs/tmpfs X-SVN-Commit-Revision: 327406 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 03:15:47 -0000 Author: mjg Date: Sun Dec 31 03:15:45 2017 New Revision: 327406 URL: https://svnweb.freebsd.org/changeset/base/327406 Log: MFC r324127: tmpfs: skip zero-sized page count updates Such updates consisted of vast majority of modificiations, especially in tmpfs_reg_resize. For the case where page count did no change and the size grew we only need to update tn_size. Use this fact to avoid vm object lock/relock. Modified: stable/11/sys/fs/tmpfs/tmpfs_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- stable/11/sys/fs/tmpfs/tmpfs_subr.c Sun Dec 31 03:13:45 2017 (r327405) +++ stable/11/sys/fs/tmpfs/tmpfs_subr.c Sun Dec 31 03:15:45 2017 (r327406) @@ -350,7 +350,8 @@ tmpfs_free_node_locked(struct tmpfs_mount *tmp, struct case VREG: uobj = node->tn_reg.tn_aobj; if (uobj != NULL) { - atomic_subtract_long(&tmp->tm_pages_used, uobj->size); + if (uobj->size != 0) + atomic_subtract_long(&tmp->tm_pages_used, uobj->size); KASSERT((uobj->flags & OBJ_TMPFS) == 0, ("leaked OBJ_TMPFS node %p vm_obj %p", node, uobj)); vm_object_deallocate(uobj); @@ -1375,6 +1376,12 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, bool oldpages = OFF_TO_IDX(oldsize + PAGE_MASK); MPASS(oldpages == uobj->size); newpages = OFF_TO_IDX(newsize + PAGE_MASK); + + if (__predict_true(newpages == oldpages && newsize >= oldsize)) { + node->tn_size = newsize; + return (0); + } + if (newpages > oldpages && tmpfs_pages_check_avail(tmp, newpages - oldpages) == 0) return (ENOSPC); From owner-svn-src-stable-11@freebsd.org Sun Dec 31 03:06:31 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76454E84720; Sun, 31 Dec 2017 03:06:31 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 506F17CF96; Sun, 31 Dec 2017 03:06:31 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV36UXa086528; Sun, 31 Dec 2017 03:06:30 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV36TcH086521; Sun, 31 Dec 2017 03:06:29 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310306.vBV36TcH086521@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 03:06:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327404 - in stable/11/sys: kern vm X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in stable/11/sys: kern vm X-SVN-Commit-Revision: 327404 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 03:06:31 -0000 Author: mjg Date: Sun Dec 31 03:06:29 2017 New Revision: 327404 URL: https://svnweb.freebsd.org/changeset/base/327404 Log: MFC r323234,r323305,r323306,r324044: Start annotating global _padalign locks with __exclusive_cache_line While these locks are guarnteed to not share their respective cache lines, their current placement leaves unnecessary holes in lines which preceeded them. For instance the annotation of vm_page_queue_free_mtx allows 2 neighbour cachelines (previously separate by the lock) to be collapsed into 1. The annotation is only effective on architectures which have it implemented in their linker script (currently only amd64). Thus locks are not converted to their not-padaligned variants as to not affect the rest. ============= Annotate global process locks with __exclusive_cache_line ============= Annotate Giant with __exclusive_cache_line ============= Annotate sysctlmemlock with __exclusive_cache_line. Modified: stable/11/sys/kern/kern_proc.c stable/11/sys/kern/kern_sysctl.c stable/11/sys/kern/subr_vmem.c stable/11/sys/kern/vfs_bio.c stable/11/sys/vm/uma_core.c stable/11/sys/vm/vm_page.c stable/11/sys/vm/vm_pager.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_proc.c ============================================================================== --- stable/11/sys/kern/kern_proc.c Sun Dec 31 02:48:16 2017 (r327403) +++ stable/11/sys/kern/kern_proc.c Sun Dec 31 03:06:29 2017 (r327404) @@ -131,9 +131,9 @@ struct pgrphashhead *pgrphashtbl; u_long pgrphash; struct proclist allproc; struct proclist zombproc; -struct sx allproc_lock; -struct sx proctree_lock; -struct mtx ppeers_lock; +struct sx __exclusive_cache_line allproc_lock; +struct sx __exclusive_cache_line proctree_lock; +struct mtx __exclusive_cache_line ppeers_lock; uma_zone_t proc_zone; /* Modified: stable/11/sys/kern/kern_sysctl.c ============================================================================== --- stable/11/sys/kern/kern_sysctl.c Sun Dec 31 02:48:16 2017 (r327403) +++ stable/11/sys/kern/kern_sysctl.c Sun Dec 31 03:06:29 2017 (r327404) @@ -88,7 +88,7 @@ static MALLOC_DEFINE(M_SYSCTLTMP, "sysctltmp", "sysctl * sysctl requests larger than a single page via an exclusive lock. */ static struct rmlock sysctllock; -static struct sx sysctlmemlock; +static struct sx __exclusive_cache_line sysctlmemlock; #define SYSCTL_WLOCK() rm_wlock(&sysctllock) #define SYSCTL_WUNLOCK() rm_wunlock(&sysctllock) Modified: stable/11/sys/kern/subr_vmem.c ============================================================================== --- stable/11/sys/kern/subr_vmem.c Sun Dec 31 02:48:16 2017 (r327403) +++ stable/11/sys/kern/subr_vmem.c Sun Dec 31 03:06:29 2017 (r327404) @@ -181,7 +181,7 @@ static struct callout vmem_periodic_ch; static int vmem_periodic_interval; static struct task vmem_periodic_wk; -static struct mtx_padalign vmem_list_lock; +static struct mtx_padalign __exclusive_cache_line vmem_list_lock; static LIST_HEAD(, vmem) vmem_list = LIST_HEAD_INITIALIZER(vmem_list); /* ---- misc */ @@ -580,7 +580,7 @@ qc_drain(vmem_t *vm) #ifndef UMA_MD_SMALL_ALLOC -static struct mtx_padalign vmem_bt_lock; +static struct mtx_padalign __exclusive_cache_line vmem_bt_lock; /* * vmem_bt_alloc: Allocate a new page of boundary tags. Modified: stable/11/sys/kern/vfs_bio.c ============================================================================== --- stable/11/sys/kern/vfs_bio.c Sun Dec 31 02:48:16 2017 (r327403) +++ stable/11/sys/kern/vfs_bio.c Sun Dec 31 03:06:29 2017 (r327404) @@ -253,23 +253,23 @@ SYSCTL_INT(_vfs, OID_AUTO, maxbcachebuf, CTLFLAG_RDTUN /* * This lock synchronizes access to bd_request. */ -static struct mtx_padalign bdlock; +static struct mtx_padalign __exclusive_cache_line bdlock; /* * This lock protects the runningbufreq and synchronizes runningbufwakeup and * waitrunningbufspace(). */ -static struct mtx_padalign rbreqlock; +static struct mtx_padalign __exclusive_cache_line rbreqlock; /* * Lock that protects needsbuffer and the sleeps/wakeups surrounding it. */ -static struct rwlock_padalign nblock; +static struct rwlock_padalign __exclusive_cache_line nblock; /* * Lock that protects bdirtywait. */ -static struct mtx_padalign bdirtylock; +static struct mtx_padalign __exclusive_cache_line bdirtylock; /* * Wakeup point for bufdaemon, as well as indicator of whether it is already @@ -348,7 +348,7 @@ static int bq_len[BUFFER_QUEUES]; /* * Lock for each bufqueue */ -static struct mtx_padalign bqlocks[BUFFER_QUEUES]; +static struct mtx_padalign __exclusive_cache_line bqlocks[BUFFER_QUEUES]; /* * per-cpu empty buffer cache. Modified: stable/11/sys/vm/uma_core.c ============================================================================== --- stable/11/sys/vm/uma_core.c Sun Dec 31 02:48:16 2017 (r327403) +++ stable/11/sys/vm/uma_core.c Sun Dec 31 03:06:29 2017 (r327404) @@ -138,7 +138,7 @@ static LIST_HEAD(,uma_zone) uma_cachezones = LIST_HEAD_INITIALIZER(uma_cachezones); /* This RW lock protects the keg list */ -static struct rwlock_padalign uma_rwlock; +static struct rwlock_padalign __exclusive_cache_line uma_rwlock; /* Linked list of boot time pages */ static LIST_HEAD(,uma_slab) uma_boot_pages = Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Sun Dec 31 02:48:16 2017 (r327403) +++ stable/11/sys/vm/vm_page.c Sun Dec 31 03:06:29 2017 (r327404) @@ -127,9 +127,9 @@ __FBSDID("$FreeBSD$"); */ struct vm_domain vm_dom[MAXMEMDOM]; -struct mtx_padalign vm_page_queue_free_mtx; +struct mtx_padalign __exclusive_cache_line vm_page_queue_free_mtx; -struct mtx_padalign pa_lock[PA_LOCK_COUNT]; +struct mtx_padalign __exclusive_cache_line pa_lock[PA_LOCK_COUNT]; vm_page_t vm_page_array; long vm_page_array_size; Modified: stable/11/sys/vm/vm_pager.c ============================================================================== --- stable/11/sys/vm/vm_pager.c Sun Dec 31 02:48:16 2017 (r327403) +++ stable/11/sys/vm/vm_pager.c Sun Dec 31 03:06:29 2017 (r327404) @@ -165,7 +165,7 @@ struct pagerops *pagertab[] = { * cleaning requests (NPENDINGIO == 64) * the maximum swap cluster size * (MAXPHYS == 64k) if you want to get the most efficiency. */ -struct mtx_padalign pbuf_mtx; +struct mtx_padalign __exclusive_cache_line pbuf_mtx; static TAILQ_HEAD(swqueue, buf) bswlist; static int bswneeded; vm_offset_t swapbkva; /* swap buffers kva */ From owner-svn-src-stable-11@freebsd.org Sun Dec 31 03:17:30 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23338E85252; Sun, 31 Dec 2017 03:17:30 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E23067DA02; Sun, 31 Dec 2017 03:17:29 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV3HT9i091253; Sun, 31 Dec 2017 03:17:29 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV3HTiF091252; Sun, 31 Dec 2017 03:17:29 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310317.vBV3HTiF091252@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 03:17:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327407 - stable/11/usr.bin/xinstall X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/usr.bin/xinstall X-SVN-Commit-Revision: 327407 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 03:17:30 -0000 Author: mjg Date: Sun Dec 31 03:17:28 2017 New Revision: 327407 URL: https://svnweb.freebsd.org/changeset/base/327407 Log: MFC r324547: xinstall: plug an infinite loop in directory creation If stat continues to fail with ENOENT and mkdir with EEXIST the code wont finish. In particular this can show up when the target path follows through a symlink to a non-existent directory. Modified: stable/11/usr.bin/xinstall/xinstall.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/xinstall/xinstall.c ============================================================================== --- stable/11/usr.bin/xinstall/xinstall.c Sun Dec 31 03:15:45 2017 (r327406) +++ stable/11/usr.bin/xinstall/xinstall.c Sun Dec 31 03:17:28 2017 (r327407) @@ -1292,17 +1292,19 @@ install_dir(char *path) { char *p; struct stat sb; - int ch; + int ch, tried_mkdir; for (p = path;; ++p) if (!*p || (p != path && *p == '/')) { + tried_mkdir = 0; ch = *p; *p = '\0'; again: if (stat(path, &sb) < 0) { - if (errno != ENOENT) + if (errno != ENOENT || tried_mkdir) err(EX_OSERR, "stat %s", path); if (mkdir(path, 0755) < 0) { + tried_mkdir = 1; if (errno == EEXIST) goto again; err(EX_OSERR, "mkdir %s", path); From owner-svn-src-stable-11@freebsd.org Sun Dec 31 03:35:37 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37CD9E86729; Sun, 31 Dec 2017 03:35:37 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 11EA47E7C3; Sun, 31 Dec 2017 03:35:36 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV3Za6F099275; Sun, 31 Dec 2017 03:35:36 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV3ZZro099265; Sun, 31 Dec 2017 03:35:35 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310335.vBV3ZZro099265@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 03:35:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327409 - in stable/11/sys: conf kern security/audit sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in stable/11/sys: conf kern security/audit sys X-SVN-Commit-Revision: 327409 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 03:35:37 -0000 Author: mjg Date: Sun Dec 31 03:35:34 2017 New Revision: 327409 URL: https://svnweb.freebsd.org/changeset/base/327409 Log: MFC r323235,r323236,r324789,r324863: Introduce __read_frequently While __read_mostly groups variables together, their placement is not specified. In particular 2 frequently used variables can end up in different lines. This annotation is only expected to be used for variables read all the time, e.g. on each syscall entry. ============= Sprinkle __read_frequently on few obvious places. Note that some of annotated variables should probably change their types to something smaller, preferably bit-sized. ============= Mark kdb_active as __read_frequently and switch to bool to eat less space. ============= Change kdb_active type to u_char. Fixes warnings from gcc and keeps the small size. Perhaps nesting should be moved to another variablle. Modified: stable/11/sys/conf/ldscript.amd64 stable/11/sys/kern/kern_dtrace.c stable/11/sys/kern/kern_lockstat.c stable/11/sys/kern/kern_mutex.c stable/11/sys/kern/kern_rwlock.c stable/11/sys/kern/kern_sx.c stable/11/sys/kern/subr_kdb.c stable/11/sys/security/audit/audit.c stable/11/sys/sys/kdb.h stable/11/sys/sys/systm.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/ldscript.amd64 ============================================================================== --- stable/11/sys/conf/ldscript.amd64 Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/conf/ldscript.amd64 Sun Dec 31 03:35:34 2017 (r327409) @@ -146,6 +146,10 @@ SECTIONS . = DATA_SEGMENT_RELRO_END (24, .); .got.plt : { *(.got.plt) } . = ALIGN(64); + .data.read_frequently : + { + *(.data.read_frequently) + } .data.read_mostly : { *(.data.read_mostly) Modified: stable/11/sys/kern/kern_dtrace.c ============================================================================== --- stable/11/sys/kern/kern_dtrace.c Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/kern/kern_dtrace.c Sun Dec 31 03:35:34 2017 (r327409) @@ -54,7 +54,7 @@ dtrace_doubletrap_func_t dtrace_doubletrap_func; dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr; dtrace_return_probe_ptr_t dtrace_return_probe_ptr; -systrace_probe_func_t systrace_probe_func; +systrace_probe_func_t __read_frequently systrace_probe_func; /* Return the DTrace process data size compiled in the kernel hooks. */ size_t Modified: stable/11/sys/kern/kern_lockstat.c ============================================================================== --- stable/11/sys/kern/kern_lockstat.c Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/kern/kern_lockstat.c Sun Dec 31 03:35:34 2017 (r327409) @@ -62,7 +62,7 @@ SDT_PROBE_DEFINE1(lockstat, , , sx__downgrade, "struct SDT_PROBE_DEFINE2(lockstat, , , thread__spin, "struct mtx *", "uint64_t"); -volatile int __read_mostly lockstat_enabled; +volatile int __read_frequently lockstat_enabled; uint64_t lockstat_nsecs(struct lock_object *lo) Modified: stable/11/sys/kern/kern_mutex.c ============================================================================== --- stable/11/sys/kern/kern_mutex.c Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/kern/kern_mutex.c Sun Dec 31 03:35:34 2017 (r327409) @@ -140,7 +140,7 @@ struct lock_class lock_class_mtx_spin = { #ifdef ADAPTIVE_MUTEXES static SYSCTL_NODE(_debug, OID_AUTO, mtx, CTLFLAG_RD, NULL, "mtx debugging"); -static struct lock_delay_config __read_mostly mtx_delay; +static struct lock_delay_config __read_frequently mtx_delay; SYSCTL_INT(_debug_mtx, OID_AUTO, delay_base, CTLFLAG_RW, &mtx_delay.base, 0, ""); @@ -153,7 +153,7 @@ LOCK_DELAY_SYSINIT_DEFAULT(mtx_delay); static SYSCTL_NODE(_debug, OID_AUTO, mtx_spin, CTLFLAG_RD, NULL, "mtx spin debugging"); -static struct lock_delay_config __read_mostly mtx_spin_delay; +static struct lock_delay_config __read_frequently mtx_spin_delay; SYSCTL_INT(_debug_mtx_spin, OID_AUTO, delay_base, CTLFLAG_RW, &mtx_spin_delay.base, 0, ""); Modified: stable/11/sys/kern/kern_rwlock.c ============================================================================== --- stable/11/sys/kern/kern_rwlock.c Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/kern/kern_rwlock.c Sun Dec 31 03:35:34 2017 (r327409) @@ -93,14 +93,14 @@ struct lock_class lock_class_rw = { }; #ifdef ADAPTIVE_RWLOCKS -static int rowner_retries = 10; -static int rowner_loops = 10000; +static int __read_frequently rowner_retries = 10; +static int __read_frequently rowner_loops = 10000; static SYSCTL_NODE(_debug, OID_AUTO, rwlock, CTLFLAG_RD, NULL, "rwlock debugging"); SYSCTL_INT(_debug_rwlock, OID_AUTO, retry, CTLFLAG_RW, &rowner_retries, 0, ""); SYSCTL_INT(_debug_rwlock, OID_AUTO, loops, CTLFLAG_RW, &rowner_loops, 0, ""); -static struct lock_delay_config __read_mostly rw_delay; +static struct lock_delay_config __read_frequently rw_delay; SYSCTL_INT(_debug_rwlock, OID_AUTO, delay_base, CTLFLAG_RW, &rw_delay.base, 0, ""); Modified: stable/11/sys/kern/kern_sx.c ============================================================================== --- stable/11/sys/kern/kern_sx.c Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/kern/kern_sx.c Sun Dec 31 03:35:34 2017 (r327409) @@ -142,13 +142,13 @@ struct lock_class lock_class_sx = { #endif #ifdef ADAPTIVE_SX -static u_int asx_retries = 10; -static u_int asx_loops = 10000; +static __read_frequently u_int asx_retries = 10; +static __read_frequently u_int asx_loops = 10000; static SYSCTL_NODE(_debug, OID_AUTO, sx, CTLFLAG_RD, NULL, "sxlock debugging"); SYSCTL_UINT(_debug_sx, OID_AUTO, retries, CTLFLAG_RW, &asx_retries, 0, ""); SYSCTL_UINT(_debug_sx, OID_AUTO, loops, CTLFLAG_RW, &asx_loops, 0, ""); -static struct lock_delay_config __read_mostly sx_delay; +static struct lock_delay_config __read_frequently sx_delay; SYSCTL_INT(_debug_sx, OID_AUTO, delay_base, CTLFLAG_RW, &sx_delay.base, 0, ""); Modified: stable/11/sys/kern/subr_kdb.c ============================================================================== --- stable/11/sys/kern/subr_kdb.c Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/kern/subr_kdb.c Sun Dec 31 03:35:34 2017 (r327409) @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); #include #endif -int kdb_active = 0; +u_char __read_frequently kdb_active = 0; static void *kdb_jmpbufp = NULL; struct kdb_dbbe *kdb_dbbe = NULL; static struct pcb kdb_pcb; Modified: stable/11/sys/security/audit/audit.c ============================================================================== --- stable/11/sys/security/audit/audit.c Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/security/audit/audit.c Sun Dec 31 03:35:34 2017 (r327409) @@ -91,7 +91,7 @@ static SYSCTL_NODE(_security, OID_AUTO, audit, CTLFLAG * * Define the audit control flags. */ -int audit_enabled; +int __read_frequently audit_enabled; int audit_suspended; /* Modified: stable/11/sys/sys/kdb.h ============================================================================== --- stable/11/sys/sys/kdb.h Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/sys/kdb.h Sun Dec 31 03:35:34 2017 (r327409) @@ -59,7 +59,7 @@ struct kdb_dbbe { }; \ DATA_SET(kdb_dbbe_set, name##_dbbe) -extern int kdb_active; /* Non-zero while in debugger. */ +extern u_char kdb_active; /* Non-zero while in debugger. */ extern int debugger_on_panic; /* enter the debugger on panic. */ extern struct kdb_dbbe *kdb_dbbe; /* Default debugger backend or NULL. */ extern struct trapframe *kdb_frame; /* Frame to kdb_trap(). */ Modified: stable/11/sys/sys/systm.h ============================================================================== --- stable/11/sys/sys/systm.h Sun Dec 31 03:34:00 2017 (r327408) +++ stable/11/sys/sys/systm.h Sun Dec 31 03:35:34 2017 (r327409) @@ -138,6 +138,7 @@ void kassert_panic(const char *fmt, ...) __printflike * Align variables. */ #define __read_mostly __section(".data.read_mostly") +#define __read_frequently __section(".data.read_frequently") #define __exclusive_cache_line __aligned(CACHE_LINE_SIZE) \ __section(".data.exclusive_cache_line") /* From owner-svn-src-stable-11@freebsd.org Sun Dec 31 05:16:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8EBF1EA131F; Sun, 31 Dec 2017 05:16:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5978F2B06; Sun, 31 Dec 2017 05:16:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV5GN3v042067; Sun, 31 Dec 2017 05:16:23 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV5GN7F042066; Sun, 31 Dec 2017 05:16:23 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310516.vBV5GN7F042066@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 05:16:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327415 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 327415 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 05:16:24 -0000 Author: mjg Date: Sun Dec 31 05:16:23 2017 New Revision: 327415 URL: https://svnweb.freebsd.org/changeset/base/327415 Log: MFC r324045: sysctl: remove target buffer read/write checks prior to calling the handler Said checks were inherently racy anyway as jokers could unmap target areas before the handler got around to accessing them. This saves time by avoiding locking the address space. Modified: stable/11/sys/kern/kern_sysctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sysctl.c ============================================================================== --- stable/11/sys/kern/kern_sysctl.c Sun Dec 31 05:14:40 2017 (r327414) +++ stable/11/sys/kern/kern_sysctl.c Sun Dec 31 05:16:23 2017 (r327415) @@ -1982,16 +1982,9 @@ userland_sysctl(struct thread *td, int *name, u_int na } } req.validlen = req.oldlen; + req.oldptr = old; - if (old) { - if (!useracc(old, req.oldlen, VM_PROT_WRITE)) - return (EFAULT); - req.oldptr= old; - } - if (new != NULL) { - if (!useracc(new, newlen, VM_PROT_READ)) - return (EFAULT); req.newlen = newlen; req.newptr = new; } From owner-svn-src-stable-11@freebsd.org Sun Dec 31 04:09:41 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 732E8E896FC; Sun, 31 Dec 2017 04:09:41 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D39C7FB8A; Sun, 31 Dec 2017 04:09:41 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV49esG012499; Sun, 31 Dec 2017 04:09:40 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV49eGs012498; Sun, 31 Dec 2017 04:09:40 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310409.vBV49eGs012498@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 04:09:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327412 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 327412 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 04:09:41 -0000 Author: mjg Date: Sun Dec 31 04:09:40 2017 New Revision: 327412 URL: https://svnweb.freebsd.org/changeset/base/327412 Log: MFC r325725: sysctl: try to avoid malloc in name2oid name2oid is called all the time and passed names are almost always very short (< 16 characters). Modified: stable/11/sys/kern/kern_sysctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sysctl.c ============================================================================== --- stable/11/sys/kern/kern_sysctl.c Sun Dec 31 04:06:11 2017 (r327411) +++ stable/11/sys/kern/kern_sysctl.c Sun Dec 31 04:09:40 2017 (r327412) @@ -1117,17 +1117,21 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS) int error, oid[CTL_MAXNAME], len = 0; struct sysctl_oid *op = NULL; struct rm_priotracker tracker; + char buf[32]; if (!req->newlen) return (ENOENT); if (req->newlen >= MAXPATHLEN) /* XXX arbitrary, undocumented */ return (ENAMETOOLONG); - p = malloc(req->newlen+1, M_SYSCTL, M_WAITOK); + p = buf; + if (req->newlen >= sizeof(buf)) + p = malloc(req->newlen+1, M_SYSCTL, M_WAITOK); error = SYSCTL_IN(req, p, req->newlen); if (error) { - free(p, M_SYSCTL); + if (p != buf) + free(p, M_SYSCTL); return (error); } @@ -1137,7 +1141,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS) error = name2oid(p, oid, &len, &op); SYSCTL_RUNLOCK(&tracker); - free(p, M_SYSCTL); + if (p != buf) + free(p, M_SYSCTL); if (error) return (error); From owner-svn-src-stable-11@freebsd.org Sun Dec 31 04:06:12 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E3A5E89437; Sun, 31 Dec 2017 04:06:12 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E86D7F9D4; Sun, 31 Dec 2017 04:06:12 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV46BBw012339; Sun, 31 Dec 2017 04:06:11 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV46Bvp012338; Sun, 31 Dec 2017 04:06:11 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310406.vBV46Bvp012338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 04:06:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327411 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 327411 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 04:06:12 -0000 Author: mjg Date: Sun Dec 31 04:06:11 2017 New Revision: 327411 URL: https://svnweb.freebsd.org/changeset/base/327411 Log: MFC r323307,r323308,r323385,r324378,r325266,r325268,r325433,r325451,r325456, r325458: namecache: factor out dot lookup into a dedicated function The intent is to move uncommon cases out of the way. ============= namecache: fold the unlock label into the only consumer No functional changes. ============= namecache: clean up struct namecache_ts handling namecache_ts differs from mere namecache by few fields placed mid struct. The access to the last element (the name) is thus special-cased. The standard solution is to put new fields at the very beginning anad embedd the original struct. The pointer shuffled around points to the embedded part. If needed, access to new fields can be gained through __containerof. ============= namecache: factor out ~MAKEENTRY lookups from the common path Lookups of the sort are rare compared to regular ones and succesfull ones result in removing entries from the cache. In the current code buckets are rlocked and a trylock dance is performed, which can fail and cause a restart. Fixing it will require a little bit of surgery and in order to keep the code maintaineable the 2 cases have to split. ============= namecache: ncnegfactor 16 -> 12 It is used on each new entry addition to decide whether to whack an existing negative entry in order to prevent a blow out in size, but the parameter was set years ago and never revisited. Building with poudriere results in about 400 evictions per second which unnecessarily grab entries from the hot list. With the new parameter there are next to no evictions of the sort. ============= namecache: fix .. check broken after r324378 ============= namecache: skip locking in cache_purge_negative if there are no entries ============= namecache: skip locking in cache_lookup_nomakeentry if there is no entry ============= namecache: wlock buckets in cache_lookup_nomakeentry Since the case of an empty chain was already covered, it si very likely that the existing entry is matching. Skipping readlocking saves on lock upgrade. ============= namecache: bump numcache after dropping all locks This makes no difference correctness-wise, but shortens total hold time. Modified: stable/11/sys/kern/vfs_cache.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_cache.c ============================================================================== --- stable/11/sys/kern/vfs_cache.c Sun Dec 31 04:01:47 2017 (r327410) +++ stable/11/sys/kern/vfs_cache.c Sun Dec 31 04:06:11 2017 (r327411) @@ -13,7 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -117,20 +117,10 @@ struct namecache { * parent. */ struct namecache_ts { - LIST_ENTRY(namecache) nc_hash; /* hash chain */ - LIST_ENTRY(namecache) nc_src; /* source vnode list */ - TAILQ_ENTRY(namecache) nc_dst; /* destination vnode list */ - struct vnode *nc_dvp; /* vnode of parent of name */ - union { - struct vnode *nu_vp; /* vnode the name refers to */ - u_int nu_neghits; /* negative entry hits */ - } n_un; - u_char nc_flag; /* flag bits */ - u_char nc_nlen; /* length of name */ struct timespec nc_time; /* timespec provided by fs */ struct timespec nc_dotdottime; /* dotdot timespec provided by fs */ int nc_ticks; /* ticks value when entry was added */ - char nc_name[0]; /* segment name + nul */ + struct namecache nc_nc; }; #define nc_vp n_un.nu_vp @@ -204,7 +194,7 @@ static __read_mostly LIST_HEAD(nchashhead, namecache) static u_long __read_mostly nchash; /* size of hash table */ SYSCTL_ULONG(_debug, OID_AUTO, nchash, CTLFLAG_RD, &nchash, 0, "Size of namecache hash table"); -static u_long __read_mostly ncnegfactor = 16; /* ratio of negative entries */ +static u_long __read_mostly ncnegfactor = 12; /* ratio of negative entries */ SYSCTL_ULONG(_vfs, OID_AUTO, ncnegfactor, CTLFLAG_RW, &ncnegfactor, 0, "Ratio of negative namecache entries"); static u_long __exclusive_cache_line numneg; /* number of negative entries allocated */ @@ -281,63 +271,64 @@ static uma_zone_t __read_mostly cache_zone_large_ts; static struct namecache * cache_alloc(int len, int ts) { + struct namecache_ts *ncp_ts; + struct namecache *ncp; - if (len > CACHE_PATH_CUTOFF) { - if (ts) - return (uma_zalloc(cache_zone_large_ts, M_WAITOK)); + if (__predict_false(ts)) { + if (len <= CACHE_PATH_CUTOFF) + ncp_ts = uma_zalloc(cache_zone_small_ts, M_WAITOK); else - return (uma_zalloc(cache_zone_large, M_WAITOK)); + ncp_ts = uma_zalloc(cache_zone_large_ts, M_WAITOK); + ncp = &ncp_ts->nc_nc; + } else { + if (len <= CACHE_PATH_CUTOFF) + ncp = uma_zalloc(cache_zone_small, M_WAITOK); + else + ncp = uma_zalloc(cache_zone_large, M_WAITOK); } - if (ts) - return (uma_zalloc(cache_zone_small_ts, M_WAITOK)); - else - return (uma_zalloc(cache_zone_small, M_WAITOK)); + return (ncp); } static void cache_free(struct namecache *ncp) { - int ts; + struct namecache_ts *ncp_ts; if (ncp == NULL) return; - ts = ncp->nc_flag & NCF_TS; if ((ncp->nc_flag & NCF_DVDROP) != 0) vdrop(ncp->nc_dvp); - if (ncp->nc_nlen <= CACHE_PATH_CUTOFF) { - if (ts) - uma_zfree(cache_zone_small_ts, ncp); + if (__predict_false(ncp->nc_flag & NCF_TS)) { + ncp_ts = __containerof(ncp, struct namecache_ts, nc_nc); + if (ncp->nc_nlen <= CACHE_PATH_CUTOFF) + uma_zfree(cache_zone_small_ts, ncp_ts); else + uma_zfree(cache_zone_large_ts, ncp_ts); + } else { + if (ncp->nc_nlen <= CACHE_PATH_CUTOFF) uma_zfree(cache_zone_small, ncp); - } else if (ts) - uma_zfree(cache_zone_large_ts, ncp); - else - uma_zfree(cache_zone_large, ncp); + else + uma_zfree(cache_zone_large, ncp); + } } -static char * -nc_get_name(struct namecache *ncp) -{ - struct namecache_ts *ncp_ts; - - if ((ncp->nc_flag & NCF_TS) == 0) - return (ncp->nc_name); - ncp_ts = (struct namecache_ts *)ncp; - return (ncp_ts->nc_name); -} - static void cache_out_ts(struct namecache *ncp, struct timespec *tsp, int *ticksp) { + struct namecache_ts *ncp_ts; KASSERT((ncp->nc_flag & NCF_TS) != 0 || (tsp == NULL && ticksp == NULL), ("No NCF_TS")); + if (tsp == NULL && ticksp == NULL) + return; + + ncp_ts = __containerof(ncp, struct namecache_ts, nc_nc); if (tsp != NULL) - *tsp = ((struct namecache_ts *)ncp)->nc_time; + *tsp = ncp_ts->nc_time; if (ticksp != NULL) - *ticksp = ((struct namecache_ts *)ncp)->nc_ticks; + *ticksp = ncp_ts->nc_ticks; } static int __read_mostly doingcache = 1; /* 1 => enable the cache */ @@ -437,7 +428,7 @@ NCP2BUCKETLOCK(struct namecache *ncp) { uint32_t hash; - hash = cache_get_hash(nc_get_name(ncp), ncp->nc_nlen, ncp->nc_dvp); + hash = cache_get_hash(ncp->nc_name, ncp->nc_nlen, ncp->nc_dvp); return (HASH2BUCKETLOCK(hash)); } @@ -823,7 +814,7 @@ cache_negative_zap_one(void) goto out_unlock_all; } SDT_PROBE3(vfs, namecache, shrink_negative, done, ncp->nc_dvp, - nc_get_name(ncp), ncp->nc_neghits); + ncp->nc_name, ncp->nc_neghits); cache_zap_locked(ncp, true); out_unlock_all: @@ -854,10 +845,10 @@ cache_zap_locked(struct namecache *ncp, bool neg_locke (ncp->nc_flag & NCF_NEGATIVE) ? NULL : ncp->nc_vp); if (!(ncp->nc_flag & NCF_NEGATIVE)) { SDT_PROBE3(vfs, namecache, zap, done, ncp->nc_dvp, - nc_get_name(ncp), ncp->nc_vp); + ncp->nc_name, ncp->nc_vp); } else { SDT_PROBE3(vfs, namecache, zap_negative, done, ncp->nc_dvp, - nc_get_name(ncp), ncp->nc_neghits); + ncp->nc_name, ncp->nc_neghits); } LIST_REMOVE(ncp, nc_hash); if (!(ncp->nc_flag & NCF_NEGATIVE)) { @@ -993,6 +984,28 @@ out: } static int +cache_zap_wlocked_bucket(struct namecache *ncp, struct rwlock *blp) +{ + struct mtx *dvlp, *vlp; + + cache_assert_bucket_locked(ncp, RA_WLOCKED); + + dvlp = VP2VNODELOCK(ncp->nc_dvp); + vlp = NULL; + if (!(ncp->nc_flag & NCF_NEGATIVE)) + vlp = VP2VNODELOCK(ncp->nc_vp); + if (cache_trylock_vnodes(dvlp, vlp) == 0) { + cache_zap_locked(ncp, false); + rw_wunlock(blp); + cache_unlock_vnodes(dvlp, vlp); + return (0); + } + + rw_wunlock(blp); + return (EAGAIN); +} + +static int cache_zap_rlocked_bucket(struct namecache *ncp, struct rwlock *blp) { struct mtx *dvlp, *vlp; @@ -1067,12 +1080,47 @@ cache_lookup_unlock(struct rwlock *blp, struct mtx *vl if (blp != NULL) { rw_runlock(blp); - mtx_assert(vlp, MA_NOTOWNED); } else { mtx_unlock(vlp); } } +static int __noinline +cache_lookup_dot(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, + struct timespec *tsp, int *ticksp) +{ + int ltype; + + *vpp = dvp; + CTR2(KTR_VFS, "cache_lookup(%p, %s) found via .", + dvp, cnp->cn_nameptr); + counter_u64_add(dothits, 1); + SDT_PROBE3(vfs, namecache, lookup, hit, dvp, ".", *vpp); + if (tsp != NULL) + timespecclear(tsp); + if (ticksp != NULL) + *ticksp = ticks; + vrefact(*vpp); + /* + * When we lookup "." we still can be asked to lock it + * differently... + */ + ltype = cnp->cn_lkflags & LK_TYPE_MASK; + if (ltype != VOP_ISLOCKED(*vpp)) { + if (ltype == LK_EXCLUSIVE) { + vn_lock(*vpp, LK_UPGRADE | LK_RETRY); + if ((*vpp)->v_iflag & VI_DOOMED) { + /* forced unmount */ + vrele(*vpp); + *vpp = NULL; + return (ENOENT); + } + } else + vn_lock(*vpp, LK_DOWNGRADE | LK_RETRY); + } + return (-1); +} + /* * Lookup an entry in the cache * @@ -1090,10 +1138,94 @@ cache_lookup_unlock(struct rwlock *blp, struct mtx *vl * not recursively acquired. */ +static __noinline int +cache_lookup_nomakeentry(struct vnode *dvp, struct vnode **vpp, + struct componentname *cnp, struct timespec *tsp, int *ticksp) +{ + struct namecache *ncp; + struct rwlock *blp; + struct mtx *dvlp, *dvlp2; + uint32_t hash; + int error; + + if (cnp->cn_namelen == 2 && + cnp->cn_nameptr[0] == '.' && cnp->cn_nameptr[1] == '.') { + counter_u64_add(dotdothits, 1); + dvlp = VP2VNODELOCK(dvp); + dvlp2 = NULL; + mtx_lock(dvlp); +retry_dotdot: + ncp = dvp->v_cache_dd; + if (ncp == NULL) { + SDT_PROBE3(vfs, namecache, lookup, miss, dvp, + "..", NULL); + mtx_unlock(dvlp); + if (dvlp2 != NULL) + mtx_unlock(dvlp2); + return (0); + } + if ((ncp->nc_flag & NCF_ISDOTDOT) != 0) { + if (ncp->nc_dvp != dvp) + panic("dvp %p v_cache_dd %p\n", dvp, ncp); + if (!cache_zap_locked_vnode_kl2(ncp, + dvp, &dvlp2)) + goto retry_dotdot; + MPASS(dvp->v_cache_dd == NULL); + mtx_unlock(dvlp); + if (dvlp2 != NULL) + mtx_unlock(dvlp2); + cache_free(ncp); + } else { + dvp->v_cache_dd = NULL; + mtx_unlock(dvlp); + if (dvlp2 != NULL) + mtx_unlock(dvlp2); + } + return (0); + } + + hash = cache_get_hash(cnp->cn_nameptr, cnp->cn_namelen, dvp); + blp = HASH2BUCKETLOCK(hash); +retry: + if (LIST_EMPTY(NCHHASH(hash))) + goto out_no_entry; + + rw_wlock(blp); + + LIST_FOREACH(ncp, (NCHHASH(hash)), nc_hash) { + counter_u64_add(numchecks, 1); + if (ncp->nc_dvp == dvp && ncp->nc_nlen == cnp->cn_namelen && + !bcmp(ncp->nc_name, cnp->cn_nameptr, ncp->nc_nlen)) + break; + } + + /* We failed to find an entry */ + if (ncp == NULL) { + rw_wunlock(blp); + goto out_no_entry; + } + + counter_u64_add(numposzaps, 1); + + error = cache_zap_wlocked_bucket(ncp, blp); + if (error != 0) { + zap_and_exit_bucket_fail++; + cache_maybe_yield(); + goto retry; + } + cache_free(ncp); + return (0); +out_no_entry: + SDT_PROBE3(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr, NULL); + counter_u64_add(nummisszap, 1); + return (0); +} + int cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct timespec *tsp, int *ticksp) { + struct namecache_ts *ncp_ts; struct namecache *ncp; struct rwlock *blp; struct mtx *dvlp, *dvlp2; @@ -1104,98 +1236,52 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, st cnp->cn_flags &= ~MAKEENTRY; return (0); } + + counter_u64_add(numcalls, 1); + + if (__predict_false(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.')) + return (cache_lookup_dot(dvp, vpp, cnp, tsp, ticksp)); + + if ((cnp->cn_flags & MAKEENTRY) == 0) + return (cache_lookup_nomakeentry(dvp, vpp, cnp, tsp, ticksp)); + retry: blp = NULL; - dvlp = VP2VNODELOCK(dvp); error = 0; - counter_u64_add(numcalls, 1); - - if (cnp->cn_nameptr[0] == '.') { - if (cnp->cn_namelen == 1) { - *vpp = dvp; - CTR2(KTR_VFS, "cache_lookup(%p, %s) found via .", - dvp, cnp->cn_nameptr); - counter_u64_add(dothits, 1); - SDT_PROBE3(vfs, namecache, lookup, hit, dvp, ".", *vpp); - if (tsp != NULL) - timespecclear(tsp); - if (ticksp != NULL) - *ticksp = ticks; - vrefact(*vpp); - /* - * When we lookup "." we still can be asked to lock it - * differently... - */ - ltype = cnp->cn_lkflags & LK_TYPE_MASK; - if (ltype != VOP_ISLOCKED(*vpp)) { - if (ltype == LK_EXCLUSIVE) { - vn_lock(*vpp, LK_UPGRADE | LK_RETRY); - if ((*vpp)->v_iflag & VI_DOOMED) { - /* forced unmount */ - vrele(*vpp); - *vpp = NULL; - return (ENOENT); - } - } else - vn_lock(*vpp, LK_DOWNGRADE | LK_RETRY); - } - return (-1); + if (cnp->cn_namelen == 2 && + cnp->cn_nameptr[0] == '.' && cnp->cn_nameptr[1] == '.') { + counter_u64_add(dotdothits, 1); + dvlp = VP2VNODELOCK(dvp); + dvlp2 = NULL; + mtx_lock(dvlp); + ncp = dvp->v_cache_dd; + if (ncp == NULL) { + SDT_PROBE3(vfs, namecache, lookup, miss, dvp, + "..", NULL); + mtx_unlock(dvlp); + return (0); } - if (cnp->cn_namelen == 2 && cnp->cn_nameptr[1] == '.') { - counter_u64_add(dotdothits, 1); - dvlp2 = NULL; - mtx_lock(dvlp); -retry_dotdot: - ncp = dvp->v_cache_dd; - if (ncp == NULL) { - SDT_PROBE3(vfs, namecache, lookup, miss, dvp, - "..", NULL); - mtx_unlock(dvlp); - if (dvlp2 != NULL) - mtx_unlock(dvlp2); - return (0); - } - if ((cnp->cn_flags & MAKEENTRY) == 0) { - if ((ncp->nc_flag & NCF_ISDOTDOT) != 0) { - if (ncp->nc_dvp != dvp) - panic("dvp %p v_cache_dd %p\n", dvp, ncp); - if (!cache_zap_locked_vnode_kl2(ncp, - dvp, &dvlp2)) - goto retry_dotdot; - MPASS(dvp->v_cache_dd == NULL); - mtx_unlock(dvlp); - if (dvlp2 != NULL) - mtx_unlock(dvlp2); - cache_free(ncp); - } else { - dvp->v_cache_dd = NULL; - mtx_unlock(dvlp); - if (dvlp2 != NULL) - mtx_unlock(dvlp2); - } - return (0); - } - if ((ncp->nc_flag & NCF_ISDOTDOT) != 0) { - if (ncp->nc_flag & NCF_NEGATIVE) - *vpp = NULL; - else - *vpp = ncp->nc_vp; - } else - *vpp = ncp->nc_dvp; - /* Return failure if negative entry was found. */ - if (*vpp == NULL) - goto negative_success; - CTR3(KTR_VFS, "cache_lookup(%p, %s) found %p via ..", - dvp, cnp->cn_nameptr, *vpp); - SDT_PROBE3(vfs, namecache, lookup, hit, dvp, "..", - *vpp); - cache_out_ts(ncp, tsp, ticksp); - if ((ncp->nc_flag & (NCF_ISDOTDOT | NCF_DTS)) == - NCF_DTS && tsp != NULL) - *tsp = ((struct namecache_ts *)ncp)-> - nc_dotdottime; - goto success; + if ((ncp->nc_flag & NCF_ISDOTDOT) != 0) { + if (ncp->nc_flag & NCF_NEGATIVE) + *vpp = NULL; + else + *vpp = ncp->nc_vp; + } else + *vpp = ncp->nc_dvp; + /* Return failure if negative entry was found. */ + if (*vpp == NULL) + goto negative_success; + CTR3(KTR_VFS, "cache_lookup(%p, %s) found %p via ..", + dvp, cnp->cn_nameptr, *vpp); + SDT_PROBE3(vfs, namecache, lookup, hit, dvp, "..", + *vpp); + cache_out_ts(ncp, tsp, ticksp); + if ((ncp->nc_flag & (NCF_ISDOTDOT | NCF_DTS)) == + NCF_DTS && tsp != NULL) { + ncp_ts = __containerof(ncp, struct namecache_ts, nc_nc); + *tsp = ncp_ts->nc_dotdottime; } + goto success; } hash = cache_get_hash(cnp->cn_nameptr, cnp->cn_namelen, dvp); @@ -1205,35 +1291,26 @@ retry_dotdot: LIST_FOREACH(ncp, (NCHHASH(hash)), nc_hash) { counter_u64_add(numchecks, 1); if (ncp->nc_dvp == dvp && ncp->nc_nlen == cnp->cn_namelen && - !bcmp(nc_get_name(ncp), cnp->cn_nameptr, ncp->nc_nlen)) + !bcmp(ncp->nc_name, cnp->cn_nameptr, ncp->nc_nlen)) break; } /* We failed to find an entry */ if (ncp == NULL) { + rw_runlock(blp); SDT_PROBE3(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr, NULL); - if ((cnp->cn_flags & MAKEENTRY) == 0) { - counter_u64_add(nummisszap, 1); - } else { - counter_u64_add(nummiss, 1); - } - goto unlock; + counter_u64_add(nummiss, 1); + return (0); } - /* We don't want to have an entry, so dump it */ - if ((cnp->cn_flags & MAKEENTRY) == 0) { - counter_u64_add(numposzaps, 1); - goto zap_and_exit; - } - /* We found a "positive" match, return the vnode */ if (!(ncp->nc_flag & NCF_NEGATIVE)) { counter_u64_add(numposhits, 1); *vpp = ncp->nc_vp; CTR4(KTR_VFS, "cache_lookup(%p, %s) found %p via ncp %p", dvp, cnp->cn_nameptr, *vpp, ncp); - SDT_PROBE3(vfs, namecache, lookup, hit, dvp, nc_get_name(ncp), + SDT_PROBE3(vfs, namecache, lookup, hit, dvp, ncp->nc_name, *vpp); cache_out_ts(ncp, tsp, ticksp); goto success; @@ -1251,7 +1328,7 @@ negative_success: if (ncp->nc_flag & NCF_WHITE) cnp->cn_flags |= ISWHITEOUT; SDT_PROBE2(vfs, namecache, lookup, hit__negative, dvp, - nc_get_name(ncp)); + ncp->nc_name); cache_out_ts(ncp, tsp, ticksp); cache_lookup_unlock(blp, dvlp); return (ENOENT); @@ -1289,10 +1366,6 @@ success: } return (-1); -unlock: - cache_lookup_unlock(blp, dvlp); - return (0); - zap_and_exit: if (blp != NULL) error = cache_zap_rlocked_bucket(ncp, blp); @@ -1528,13 +1601,14 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, { struct celockstate cel; struct namecache *ncp, *n2, *ndd; - struct namecache_ts *n3; + struct namecache_ts *ncp_ts, *n2_ts; struct nchashhead *ncpp; struct neglist *neglist; uint32_t hash; int flag; int len; bool neg_locked; + int lnumcache; CTR3(KTR_VFS, "cache_enter(%p, %p, %s)", dvp, vp, cnp->cn_nameptr); VNASSERT(vp == NULL || (vp->v_iflag & VI_DOOMED) == 0, vp, @@ -1619,18 +1693,18 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, ncp->nc_flag |= NCF_NEGATIVE; ncp->nc_dvp = dvp; if (tsp != NULL) { - n3 = (struct namecache_ts *)ncp; - n3->nc_time = *tsp; - n3->nc_ticks = ticks; - n3->nc_flag |= NCF_TS; + ncp_ts = __containerof(ncp, struct namecache_ts, nc_nc); + ncp_ts->nc_time = *tsp; + ncp_ts->nc_ticks = ticks; + ncp_ts->nc_nc.nc_flag |= NCF_TS; if (dtsp != NULL) { - n3->nc_dotdottime = *dtsp; - n3->nc_flag |= NCF_DTS; + ncp_ts->nc_dotdottime = *dtsp; + ncp_ts->nc_nc.nc_flag |= NCF_DTS; } } len = ncp->nc_nlen = cnp->cn_namelen; hash = cache_get_hash(cnp->cn_nameptr, len, dvp); - strlcpy(nc_get_name(ncp), cnp->cn_nameptr, len + 1); + strlcpy(ncp->nc_name, cnp->cn_nameptr, len + 1); cache_enter_lock(&cel, dvp, vp, hash); /* @@ -1642,22 +1716,18 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, LIST_FOREACH(n2, ncpp, nc_hash) { if (n2->nc_dvp == dvp && n2->nc_nlen == cnp->cn_namelen && - !bcmp(nc_get_name(n2), cnp->cn_nameptr, n2->nc_nlen)) { + !bcmp(n2->nc_name, cnp->cn_nameptr, n2->nc_nlen)) { if (tsp != NULL) { KASSERT((n2->nc_flag & NCF_TS) != 0, ("no NCF_TS")); - n3 = (struct namecache_ts *)n2; - n3->nc_time = - ((struct namecache_ts *)ncp)->nc_time; - n3->nc_ticks = - ((struct namecache_ts *)ncp)->nc_ticks; + n2_ts = __containerof(n2, struct namecache_ts, nc_nc); + n2_ts->nc_time = ncp_ts->nc_time; + n2_ts->nc_ticks = ncp_ts->nc_ticks; if (dtsp != NULL) { - n3->nc_dotdottime = - ((struct namecache_ts *)ncp)-> - nc_dotdottime; + n2_ts->nc_dotdottime = ncp_ts->nc_dotdottime; if (ncp->nc_flag & NCF_NEGATIVE) mtx_lock(&ncneg_hot.nl_lock); - n3->nc_flag |= NCF_DTS; + n2_ts->nc_nc.nc_flag |= NCF_DTS; if (ncp->nc_flag & NCF_NEGATIVE) mtx_unlock(&ncneg_hot.nl_lock); } @@ -1678,7 +1748,6 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, dvp->v_cache_dd = ncp; } - atomic_add_rel_long(&numcache, 1); if (vp != NULL) { if (vp->v_type == VDIR) { if (flag != NCF_ISDOTDOT) { @@ -1721,17 +1790,18 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, */ if (vp != NULL) { TAILQ_INSERT_HEAD(&vp->v_cache_dst, ncp, nc_dst); - SDT_PROBE3(vfs, namecache, enter, done, dvp, nc_get_name(ncp), + SDT_PROBE3(vfs, namecache, enter, done, dvp, ncp->nc_name, vp); } else { if (cnp->cn_flags & ISWHITEOUT) ncp->nc_flag |= NCF_WHITE; cache_negative_insert(ncp, false); SDT_PROBE2(vfs, namecache, enter_negative, done, dvp, - nc_get_name(ncp)); + ncp->nc_name); } cache_enter_unlock(&cel); - if (numneg * ncnegfactor > numcache) + lnumcache = atomic_fetchadd_long(&numcache, 1) + 1; + if (numneg * ncnegfactor > lnumcache) cache_negative_zap_one(); cache_free(ndd); return; @@ -1854,7 +1924,7 @@ cache_changesize(int newmaxvnodes) nchash = new_nchash; for (i = 0; i <= old_nchash; i++) { while ((ncp = LIST_FIRST(&old_nchashtbl[i])) != NULL) { - hash = cache_get_hash(nc_get_name(ncp), ncp->nc_nlen, + hash = cache_get_hash(ncp->nc_name, ncp->nc_nlen, ncp->nc_dvp); LIST_REMOVE(ncp, nc_hash); LIST_INSERT_HEAD(NCHHASH(hash), ncp, nc_hash); @@ -1926,6 +1996,8 @@ cache_purge_negative(struct vnode *vp) CTR1(KTR_VFS, "cache_purge_negative(%p)", vp); SDT_PROBE1(vfs, namecache, purge_negative, done, vp); + if (LIST_EMPTY(&vp->v_cache_src)) + return; TAILQ_INIT(&ncps); vlp = VP2VNODELOCK(vp); mtx_lock(vlp); @@ -2181,9 +2253,9 @@ vn_vptocnp(struct vnode **vp, struct ucred *cred, char return (error); } *buflen -= ncp->nc_nlen; - memcpy(buf + *buflen, nc_get_name(ncp), ncp->nc_nlen); + memcpy(buf + *buflen, ncp->nc_name, ncp->nc_nlen); SDT_PROBE3(vfs, namecache, fullpath, hit, ncp->nc_dvp, - nc_get_name(ncp), vp); + ncp->nc_name, vp); dvp = *vp; *vp = ncp->nc_dvp; vref(*vp); @@ -2365,7 +2437,7 @@ vn_commname(struct vnode *vp, char *buf, u_int buflen) return (ENOENT); } l = min(ncp->nc_nlen, buflen - 1); - memcpy(buf, nc_get_name(ncp), l); + memcpy(buf, ncp->nc_name, l); mtx_unlock(vlp); buf[l] = '\0'; return (0); From owner-svn-src-stable-11@freebsd.org Sun Dec 31 05:06:37 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F9B2EA0ACB; Sun, 31 Dec 2017 05:06:37 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F11232438; Sun, 31 Dec 2017 05:06:36 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV56aqP037698; Sun, 31 Dec 2017 05:06:36 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV56aBN037695; Sun, 31 Dec 2017 05:06:36 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310506.vBV56aBN037695@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 05:06:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327413 - in stable/11/sys: kern sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in stable/11/sys: kern sys X-SVN-Commit-Revision: 327413 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 05:06:37 -0000 Author: mjg Date: Sun Dec 31 05:06:35 2017 New Revision: 327413 URL: https://svnweb.freebsd.org/changeset/base/327413 Log: MFC r320561,r323236,r324041,r324314,r324609,r324613,r324778,r324780,r324787, r324803,r324836,r325469,r325706,r325917,r325918,r325919,r325920,r325921, r325922,r325925,r325963,r326106,r326107,r326110,r326111,r326112,r326194, r326195,r326196,r326197,r326198,r326199,r326200,r326237: rwlock: perform the typically false td_rw_rlocks check later Check if the lock is available first instead. ============= Sprinkle __read_frequently on few obvious places. Note that some of annotated variables should probably change their types to something smaller, preferably bit-sized. ============= mtx: drop the tid argument from _mtx_lock_sleep tid must be equal to curthread and the target routine was already reading it anyway, which is not a problem. Not passing it as a parameter allows for a little bit shorter code in callers. ============= locks: partially tidy up waiting on readers spin first instant of instantly re-readoing and don't re-read after spinning is finished - the state is already known. Note the code is subject to significant changes later. ============= locks: take the number of readers into account when waiting Previous code would always spin once before checking the lock. But a lock with e.g. 6 readers is not going to become free in the duration of once spin even if they start draining immediately. Conservatively perform one for each reader. Note that the total number of allowed spins is still extremely small and is subject to change later. ============= mtx: change MTX_UNOWNED from 4 to 0 The value is spread all over the kernel and zeroing a register is cheaper/shorter than setting it up to an arbitrary value. Reduces amd64 GENERIC-NODEBUG .text size by 0.4%. ============= mtx: fix up owner_mtx after r324609 Now that MTX_UNOWNED is 0 the test was alwayas false. ============= mtx: clean up locking spin mutexes 1) shorten the fast path by pushing the lockstat probe to the slow path 2) test for kernel panic only after it turns out we will have to spin, in particular test only after we know we are not recursing ============= mtx: stop testing SCHEDULER_STOPPED in kabi funcs for spin mutexes There is nothing panic-breaking to do in the unlock case and the lock case will fallback to the slow path doing the check already. ============= rwlock: reduce lockstat branches in the slowpath ============= mtx: fix up UP build after r324778 ============= mtx: implement thread lock fastpath ============= rwlock: fix up compilation without KDTRACE_HOOKS after r324787 ============= rwlock: use fcmpset for setting RW_LOCK_WRITE_SPINNER ============= sx: avoid branches if in the slow path if lockstat is disabled ============= rwlock: avoid branches in the slow path if lockstat is disabled ============= locks: pull up PMC_SOFT_CALLs out of slow path loops ============= mtx: unlock before traversing threads to wake up This shortens the lock hold time while not affecting corretness. All the woken up threads end up competing can lose the race against a completely unrelated thread getting the lock anyway. ============= rwlock: unlock before traversing threads to wake up While here perform a minor cleanup of the unlock path. ============= sx: perform a minor cleanup of the unlock slowpath No functional changes. ============= mtx: add missing parts of the diff in r325920 Fixes build breakage. ============= locks: fix compilation issues without SMP or KDTRACE_HOOKS ============= locks: remove the file + line argument from internal primitives when not used The pair is of use only in debug or LOCKPROF kernels, but was passed (zeroed) for many locks even in production kernels. While here whack the tid argument from wlock hard and xlock hard. There is no kbi change of any sort - "external" primitives still accept the pair. ============= locks: pass the found lock value to unlock slow path This avoids an explicit read later. While here whack the cheaply obtainable 'tid' argument. ============= rwlock: don't check for curthread's read lock count in the fast path ============= rwlock: unbreak WITNESS builds after r326110 ============= sx: unbreak debug after r326107 An assertion was modified to use the found value, but it was not updated to handle a race where blocked threads appear after the entrance to the func. Move the assertion down to the area protected with sleepq lock where the lock is read anyway. This does not affect coverage of the assertion and is consistent with what rw locks are doing. ============= rwlock: stop re-reading the owner when going to sleep ============= locks: retry turnstile/sleepq loops on failed cmpset In order to go to sleep threads set waiter flags, but that can spuriously fail e.g. when a new reader arrives. Instead of unlocking everything and looping back, re-evaluate the new state while still holding the lock necessary to go to sleep. ============= sx: change sunlock to wake waiters up if it locked sleepq sleepq is only locked if the curhtread is the last reader. By the time the lock gets acquired new ones could have arrived. The previous code would unlock and loop back. This results spurious relocking of sleepq. This is a step towards xadd-based unlock routine. ============= rwlock: add __rw_try_{r,w}lock_int ============= rwlock: fix up compilation of the previous change commmitted wrong version of the patch ============= Convert in-kernel thread_lock_flags calls to thread_lock when debug is disabled The flags argument is not used in this case. ============= Add the missing lockstat check for thread lock. ============= rw: fix runlock_hard when new readers show up When waiters/writer spinner flags are set no new readers can show up unless they already have a different rw rock read locked. The change in r326195 failed to take that into account - in presence of new readers it would spin until they all drain, which would be lead to trouble if e.g. they go off cpu and can get scheduled because of this thread. Modified: stable/11/sys/kern/kern_mutex.c stable/11/sys/kern/kern_rwlock.c stable/11/sys/kern/kern_sx.c stable/11/sys/sys/lock.h stable/11/sys/sys/mutex.h stable/11/sys/sys/rwlock.h stable/11/sys/sys/sx.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_mutex.c ============================================================================== --- stable/11/sys/kern/kern_mutex.c Sun Dec 31 04:09:40 2017 (r327412) +++ stable/11/sys/kern/kern_mutex.c Sun Dec 31 05:06:35 2017 (r327413) @@ -217,7 +217,7 @@ owner_mtx(const struct lock_object *lock, struct threa m = (const struct mtx *)lock; x = m->mtx_lock; *owner = (struct thread *)(x & ~MTX_FLAGMASK); - return (x != MTX_UNOWNED); + return (*owner != NULL); } #endif @@ -248,7 +248,7 @@ __mtx_lock_flags(volatile uintptr_t *c, int opts, cons tid = (uintptr_t)curthread; v = MTX_UNOWNED; if (!_mtx_obtain_lock_fetch(m, &v, tid)) - _mtx_lock_sleep(m, v, tid, opts, file, line); + _mtx_lock_sleep(m, v, opts, file, line); else LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(adaptive__acquire, m, 0, 0, file, line); @@ -277,7 +277,7 @@ __mtx_unlock_flags(volatile uintptr_t *c, int opts, co mtx_assert(m, MA_OWNED); #ifdef LOCK_PROFILING - __mtx_unlock_sleep(c, opts, file, line); + __mtx_unlock_sleep(c, (uintptr_t)curthread, opts, file, line); #else __mtx_unlock(m, curthread, opts, file, line); #endif @@ -289,10 +289,10 @@ __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, int line) { struct mtx *m; +#ifdef SMP + uintptr_t tid, v; +#endif - if (SCHEDULER_STOPPED()) - return; - m = mtxlock2mtx(c); KASSERT(m->mtx_lock != MTX_DESTROYED, @@ -308,7 +308,18 @@ __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, opts &= ~MTX_RECURSE; WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); +#ifdef SMP + spinlock_enter(); + tid = (uintptr_t)curthread; + v = MTX_UNOWNED; + if (!_mtx_obtain_lock_fetch(m, &v, tid)) + _mtx_lock_spin(m, v, opts, file, line); + else + LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, + m, 0, 0, file, line); +#else __mtx_lock_spin(m, curthread, opts, file, line); +#endif LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); @@ -348,9 +359,6 @@ __mtx_unlock_spin_flags(volatile uintptr_t *c, int opt { struct mtx *m; - if (SCHEDULER_STOPPED()) - return; - m = mtxlock2mtx(c); KASSERT(m->mtx_lock != MTX_DESTROYED, @@ -372,9 +380,8 @@ __mtx_unlock_spin_flags(volatile uintptr_t *c, int opt * is already owned, it will recursively acquire the lock. */ int -_mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int line) +_mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF) { - struct mtx *m; struct thread *td; uintptr_t tid, v; #ifdef LOCK_PROFILING @@ -389,8 +396,6 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, c if (SCHEDULER_STOPPED_TD(td)) return (1); - m = mtxlock2mtx(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td), ("mtx_trylock() by idle thread %p on sleep mutex %s @ %s:%d", curthread, m->lock_object.lo_name, file, line)); @@ -435,6 +440,15 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, c return (rval); } +int +_mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int line) +{ + struct mtx *m; + + m = mtxlock2mtx(c); + return (_mtx_trylock_flags_int(m, opts LOCK_FILE_LINE_ARG)); +} + /* * __mtx_lock_sleep: the tougher part of acquiring an MTX_DEF lock. * @@ -443,18 +457,18 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, c */ #if LOCK_DEBUG > 0 void -__mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, int opts, - const char *file, int line) +__mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, int opts, const char *file, + int line) #else void -__mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid) +__mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v) #endif { + struct thread *td; struct mtx *m; struct turnstile *ts; -#ifdef ADAPTIVE_MUTEXES - volatile struct thread *owner; -#endif + uintptr_t tid; + struct thread *owner; #ifdef KTR int cont_logged = 0; #endif @@ -473,8 +487,9 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, u #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING) int doing_lockprof; #endif - - if (SCHEDULER_STOPPED()) + td = curthread; + tid = (uintptr_t)td; + if (SCHEDULER_STOPPED_TD(td)) return; #if defined(ADAPTIVE_MUTEXES) @@ -486,7 +501,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, u if (__predict_false(v == MTX_UNOWNED)) v = MTX_READ_VALUE(m); - if (__predict_false(lv_mtx_owner(v) == (struct thread *)tid)) { + if (__predict_false(lv_mtx_owner(v) == td)) { KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0 || (opts & MTX_RECURSE) != 0, ("_mtx_lock_sleep: recursed on non-recursive mutex %s @ %s:%d\n", @@ -618,7 +633,11 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, u #ifdef KDTRACE_HOOKS sleep_time -= lockstat_nsecs(&m->lock_object); #endif - turnstile_wait(ts, mtx_owner(m), TS_EXCLUSIVE_QUEUE); +#ifndef ADAPTIVE_MUTEXES + owner = mtx_owner(m); +#endif + MPASS(owner == mtx_owner(m)); + turnstile_wait(ts, owner, TS_EXCLUSIVE_QUEUE); #ifdef KDTRACE_HOOKS sleep_time += lockstat_nsecs(&m->lock_object); sleep_cnt++; @@ -679,12 +698,18 @@ _mtx_lock_spin_failed(struct mtx *m) * This is only called if we need to actually spin for the lock. Recursion * is handled inline. */ +#if LOCK_DEBUG > 0 void -_mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, - int opts, const char *file, int line) +_mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v, int opts, + const char *file, int line) +#else +void +_mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v) +#endif { struct mtx *m; struct lock_delay_arg lda; + uintptr_t tid; #ifdef LOCK_PROFILING int contested = 0; uint64_t waittime = 0; @@ -696,10 +721,7 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t int doing_lockprof; #endif - if (SCHEDULER_STOPPED()) - return; - - lock_delay_arg_init(&lda, &mtx_spin_delay); + tid = (uintptr_t)curthread; m = mtxlock2mtx(c); if (__predict_false(v == MTX_UNOWNED)) @@ -710,6 +732,11 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t return; } + if (SCHEDULER_STOPPED()) + return; + + lock_delay_arg_init(&lda, &mtx_spin_delay); + if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m); KTR_STATE1(KTR_SCHED, "thread", sched_tdname((struct thread *)tid), @@ -772,7 +799,74 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t } #endif /* SMP */ +#ifdef INVARIANTS +static void +thread_lock_validate(struct mtx *m, int opts, const char *file, int line) +{ + + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("thread_lock() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin, + ("thread_lock() of sleep mutex %s @ %s:%d", + m->lock_object.lo_name, file, line)); + if (mtx_owned(m)) + KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0, + ("thread_lock: recursed on non-recursive mutex %s @ %s:%d\n", + m->lock_object.lo_name, file, line)); + WITNESS_CHECKORDER(&m->lock_object, + opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); +} +#else +#define thread_lock_validate(m, opts, file, line) do { } while (0) +#endif + +#ifndef LOCK_PROFILING +#if LOCK_DEBUG > 0 void +_thread_lock(struct thread *td, int opts, const char *file, int line) +#else +void +_thread_lock(struct thread *td) +#endif +{ + struct mtx *m; + uintptr_t tid, v; + + tid = (uintptr_t)curthread; + + if (__predict_false(LOCKSTAT_PROFILE_ENABLED(spin__acquire))) + goto slowpath_noirq; + spinlock_enter(); + m = td->td_lock; + thread_lock_validate(m, 0, file, line); + v = MTX_READ_VALUE(m); + if (__predict_true(v == MTX_UNOWNED)) { + if (__predict_false(!_mtx_obtain_lock(m, tid))) + goto slowpath_unlocked; + } else if (v == tid) { + m->mtx_recurse++; + } else + goto slowpath_unlocked; + if (__predict_true(m == td->td_lock)) { + WITNESS_LOCK(&m->lock_object, LOP_EXCLUSIVE, file, line); + return; + } + if (m->mtx_recurse != 0) + m->mtx_recurse--; + else + _mtx_release_lock_quick(m); +slowpath_unlocked: + spinlock_exit(); +slowpath_noirq: +#if LOCK_DEBUG > 0 + thread_lock_flags_(td, opts, file, line); +#else + thread_lock_flags_(td, 0, 0, 0); +#endif +} +#endif + +void thread_lock_flags_(struct thread *td, int opts, const char *file, int line) { struct mtx *m; @@ -815,17 +909,7 @@ retry: v = MTX_UNOWNED; spinlock_enter(); m = td->td_lock; - KASSERT(m->mtx_lock != MTX_DESTROYED, - ("thread_lock() of destroyed mutex @ %s:%d", file, line)); - KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin, - ("thread_lock() of sleep mutex %s @ %s:%d", - m->lock_object.lo_name, file, line)); - if (mtx_owned(m)) - KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0, - ("thread_lock: recursed on non-recursive mutex %s @ %s:%d\n", - m->lock_object.lo_name, file, line)); - WITNESS_CHECKORDER(&m->lock_object, - opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); + thread_lock_validate(m, opts, file, line); for (;;) { if (_mtx_obtain_lock_fetch(m, &v, tid)) break; @@ -925,24 +1009,27 @@ thread_lock_set(struct thread *td, struct mtx *new) */ #if LOCK_DEBUG > 0 void -__mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, int line) +__mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v, int opts, + const char *file, int line) #else void -__mtx_unlock_sleep(volatile uintptr_t *c) +__mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v) #endif { struct mtx *m; struct turnstile *ts; - uintptr_t tid, v; + uintptr_t tid; if (SCHEDULER_STOPPED()) return; tid = (uintptr_t)curthread; m = mtxlock2mtx(c); - v = MTX_READ_VALUE(m); - if (v & MTX_RECURSED) { + if (__predict_false(v == tid)) + v = MTX_READ_VALUE(m); + + if (__predict_false(v & MTX_RECURSED)) { if (--(m->mtx_recurse) == 0) atomic_clear_ptr(&m->mtx_lock, MTX_RECURSED); if (LOCK_LOG_TEST(&m->lock_object, opts)) @@ -959,12 +1046,12 @@ __mtx_unlock_sleep(volatile uintptr_t *c) * can be removed from the hash list if it is empty. */ turnstile_chain_lock(&m->lock_object); + _mtx_release_lock_quick(m); ts = turnstile_lookup(&m->lock_object); + MPASS(ts != NULL); if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m); - MPASS(ts != NULL); turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE); - _mtx_release_lock_quick(m); /* * This turnstile is now no longer associated with the mutex. We can Modified: stable/11/sys/kern/kern_rwlock.c ============================================================================== --- stable/11/sys/kern/kern_rwlock.c Sun Dec 31 04:09:40 2017 (r327412) +++ stable/11/sys/kern/kern_rwlock.c Sun Dec 31 05:06:35 2017 (r327413) @@ -273,7 +273,7 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *fi tid = (uintptr_t)curthread; v = RW_UNLOCKED; if (!_rw_write_lock_fetch(rw, &v, tid)) - _rw_wlock_hard(rw, v, tid, file, line); + _rw_wlock_hard(rw, v, file, line); else LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(rw__acquire, rw, 0, 0, file, line, LOCKSTAT_WRITER); @@ -284,9 +284,8 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *fi } int -__rw_try_wlock(volatile uintptr_t *c, const char *file, int line) +__rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF) { - struct rwlock *rw; struct thread *td; uintptr_t tid, v; int rval; @@ -297,8 +296,6 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file if (SCHEDULER_STOPPED_TD(td)) return (1); - rw = rwlock2rw(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td), ("rw_try_wlock() by idle thread %p on rwlock %s @ %s:%d", curthread, rw->lock_object.lo_name, file, line)); @@ -334,6 +331,15 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file return (rval); } +int +__rw_try_wlock(volatile uintptr_t *c, const char *file, int line) +{ + struct rwlock *rw; + + rw = rwlock2rw(c); + return (__rw_try_wlock_int(rw LOCK_FILE_LINE_ARG)); +} + void _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line) { @@ -364,14 +370,21 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char * * is unlocked and has no writer waiters or spinners. Failing otherwise * prioritizes writers before readers. */ -#define RW_CAN_READ(td, _rw) \ - (((td)->td_rw_rlocks && (_rw) & RW_LOCK_READ) || ((_rw) & \ - (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER)) == \ - RW_LOCK_READ) +static bool __always_inline +__rw_can_read(struct thread *td, uintptr_t v, bool fp) +{ + if ((v & (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER)) + == RW_LOCK_READ) + return (true); + if (!fp && td->td_rw_rlocks && (v & RW_LOCK_READ)) + return (true); + return (false); +} + static bool __always_inline -__rw_rlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp, - const char *file, int line) +__rw_rlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp, bool fp + LOCK_FILE_LINE_ARG_DEF) { /* @@ -384,7 +397,7 @@ __rw_rlock_try(struct rwlock *rw, struct thread *td, u * completely unlocked rwlock since such a lock is encoded * as a read lock with no waiters. */ - while (RW_CAN_READ(td, *vp)) { + while (__rw_can_read(td, *vp, fp)) { if (atomic_fcmpset_acq_ptr(&rw->rw_lock, vp, *vp + RW_ONE_READER)) { if (LOCK_LOG_TEST(&rw->lock_object, 0)) @@ -400,13 +413,12 @@ __rw_rlock_try(struct rwlock *rw, struct thread *td, u } static void __noinline -__rw_rlock_hard(volatile uintptr_t *c, struct thread *td, uintptr_t v, - const char *file, int line) +__rw_rlock_hard(struct rwlock *rw, struct thread *td, uintptr_t v + LOCK_FILE_LINE_ARG_DEF) { - struct rwlock *rw; struct turnstile *ts; + struct thread *owner; #ifdef ADAPTIVE_RWLOCKS - volatile struct thread *owner; int spintries = 0; int i; #endif @@ -418,11 +430,14 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * struct lock_delay_arg lda; #endif #ifdef KDTRACE_HOOKS - uintptr_t state; u_int sleep_cnt = 0; int64_t sleep_time = 0; int64_t all_time = 0; #endif +#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING) + uintptr_t state; + int doing_lockprof; +#endif if (SCHEDULER_STOPPED()) return; @@ -432,25 +447,30 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * #elif defined(KDTRACE_HOOKS) lock_delay_arg_init(&lda, NULL); #endif - rw = rwlock2rw(c); -#ifdef KDTRACE_HOOKS - all_time -= lockstat_nsecs(&rw->lock_object); +#ifdef HWPMC_HOOKS + PMC_SOFT_CALL( , , lock, failed); #endif -#ifdef KDTRACE_HOOKS + lock_profile_obtain_lock_failed(&rw->lock_object, + &contested, &waittime); + +#ifdef LOCK_PROFILING + doing_lockprof = 1; state = v; +#elif defined(KDTRACE_HOOKS) + doing_lockprof = lockstat_enabled; + if (__predict_false(doing_lockprof)) { + all_time -= lockstat_nsecs(&rw->lock_object); + state = v; + } #endif + for (;;) { - if (__rw_rlock_try(rw, td, &v, file, line)) + if (__rw_rlock_try(rw, td, &v, false LOCK_FILE_LINE_ARG)) break; #ifdef KDTRACE_HOOKS lda.spin_cnt++; #endif -#ifdef HWPMC_HOOKS - PMC_SOFT_CALL( , , lock, failed); -#endif - lock_profile_obtain_lock_failed(&rw->lock_object, - &contested, &waittime); #ifdef ADAPTIVE_RWLOCKS /* @@ -483,12 +503,11 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * "spinning", "lockname:\"%s\"", rw->lock_object.lo_name); for (i = 0; i < rowner_loops; i++) { + cpu_spinwait(); v = RW_READ_VALUE(rw); - if ((v & RW_LOCK_READ) == 0 || RW_CAN_READ(td, v)) + if ((v & RW_LOCK_READ) == 0 || __rw_can_read(td, v, false)) break; - cpu_spinwait(); } - v = RW_READ_VALUE(rw); #ifdef KDTRACE_HOOKS lda.spin_cnt += rowner_loops - i; #endif @@ -512,11 +531,14 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * * recheck its state and restart the loop if needed. */ v = RW_READ_VALUE(rw); - if (RW_CAN_READ(td, v)) { +retry_ts: + if (__rw_can_read(td, v, false)) { turnstile_cancel(ts); continue; } + owner = lv_rw_wowner(v); + #ifdef ADAPTIVE_RWLOCKS /* * The current lock owner might have started executing @@ -525,8 +547,7 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * * chain lock. If so, drop the turnstile lock and try * again. */ - if ((v & RW_LOCK_READ) == 0) { - owner = (struct thread *)RW_OWNER(v); + if (owner != NULL) { if (TD_IS_RUNNING(owner)) { turnstile_cancel(ts); continue; @@ -537,7 +558,7 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * /* * The lock is held in write mode or it already has waiters. */ - MPASS(!RW_CAN_READ(td, v)); + MPASS(!__rw_can_read(td, v, false)); /* * If the RW_LOCK_READ_WAITERS flag is already set, then @@ -546,12 +567,9 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * * lock and restart the loop. */ if (!(v & RW_LOCK_READ_WAITERS)) { - if (!atomic_cmpset_ptr(&rw->rw_lock, v, - v | RW_LOCK_READ_WAITERS)) { - turnstile_cancel(ts); - v = RW_READ_VALUE(rw); - continue; - } + if (!atomic_fcmpset_ptr(&rw->rw_lock, &v, + v | RW_LOCK_READ_WAITERS)) + goto retry_ts; if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p set read waiters flag", __func__, rw); @@ -567,7 +585,8 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * #ifdef KDTRACE_HOOKS sleep_time -= lockstat_nsecs(&rw->lock_object); #endif - turnstile_wait(ts, rw_owner(rw), TS_SHARED_QUEUE); + MPASS(owner == rw_owner(rw)); + turnstile_wait(ts, owner, TS_SHARED_QUEUE); #ifdef KDTRACE_HOOKS sleep_time += lockstat_nsecs(&rw->lock_object); sleep_cnt++; @@ -577,6 +596,10 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * __func__, rw); v = RW_READ_VALUE(rw); } +#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING) + if (__predict_true(!doing_lockprof)) + return; +#endif #ifdef KDTRACE_HOOKS all_time += lockstat_nsecs(&rw->lock_object); if (sleep_time) @@ -600,14 +623,12 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread * } void -__rw_rlock(volatile uintptr_t *c, const char *file, int line) +__rw_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF) { - struct rwlock *rw; struct thread *td; uintptr_t v; td = curthread; - rw = rwlock2rw(c); KASSERT(kdb_active != 0 || SCHEDULER_STOPPED_TD(td) || !TD_IS_IDLETHREAD(td), @@ -622,25 +643,31 @@ __rw_rlock(volatile uintptr_t *c, const char *file, in v = RW_READ_VALUE(rw); if (__predict_false(LOCKSTAT_OOL_PROFILE_ENABLED(rw__acquire) || - !__rw_rlock_try(rw, td, &v, file, line))) - __rw_rlock_hard(c, td, v, file, line); + !__rw_rlock_try(rw, td, &v, true LOCK_FILE_LINE_ARG))) + __rw_rlock_hard(rw, td, v LOCK_FILE_LINE_ARG); LOCK_LOG_LOCK("RLOCK", &rw->lock_object, 0, 0, file, line); WITNESS_LOCK(&rw->lock_object, 0, file, line); TD_LOCKS_INC(curthread); } -int -__rw_try_rlock(volatile uintptr_t *c, const char *file, int line) +void +__rw_rlock(volatile uintptr_t *c, const char *file, int line) { struct rwlock *rw; + + rw = rwlock2rw(c); + __rw_rlock_int(rw LOCK_FILE_LINE_ARG); +} + +int +__rw_try_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF) +{ uintptr_t x; if (SCHEDULER_STOPPED()) return (1); - rw = rwlock2rw(c); - KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), ("rw_try_rlock() by idle thread %p on rwlock %s @ %s:%d", curthread, rw->lock_object.lo_name, file, line)); @@ -667,6 +694,15 @@ __rw_try_rlock(volatile uintptr_t *c, const char *file return (0); } +int +__rw_try_rlock(volatile uintptr_t *c, const char *file, int line) +{ + struct rwlock *rw; + + rw = rwlock2rw(c); + return (__rw_try_rlock_int(rw LOCK_FILE_LINE_ARG)); +} + static bool __always_inline __rw_runlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp) { @@ -712,18 +748,15 @@ __rw_runlock_try(struct rwlock *rw, struct thread *td, } static void __noinline -__rw_runlock_hard(volatile uintptr_t *c, struct thread *td, uintptr_t v, - const char *file, int line) +__rw_runlock_hard(struct rwlock *rw, struct thread *td, uintptr_t v + LOCK_FILE_LINE_ARG_DEF) { - struct rwlock *rw; struct turnstile *ts; uintptr_t x, queue; if (SCHEDULER_STOPPED()) return; - rw = rwlock2rw(c); - for (;;) { if (__rw_runlock_try(rw, td, &v)) break; @@ -733,7 +766,14 @@ __rw_runlock_hard(volatile uintptr_t *c, struct thread * last reader, so grab the turnstile lock. */ turnstile_chain_lock(&rw->lock_object); - v = rw->rw_lock & (RW_LOCK_WAITERS | RW_LOCK_WRITE_SPINNER); + v = RW_READ_VALUE(rw); +retry_ts: + if (__predict_false(RW_READERS(v) > 1)) { + turnstile_chain_unlock(&rw->lock_object); + continue; + } + + v &= (RW_LOCK_WAITERS | RW_LOCK_WRITE_SPINNER); MPASS(v & RW_LOCK_WAITERS); /* @@ -758,12 +798,9 @@ __rw_runlock_hard(volatile uintptr_t *c, struct thread x |= (v & RW_LOCK_READ_WAITERS); } else queue = TS_SHARED_QUEUE; - if (!atomic_cmpset_rel_ptr(&rw->rw_lock, RW_READERS_LOCK(1) | v, - x)) { - turnstile_chain_unlock(&rw->lock_object); - v = RW_READ_VALUE(rw); - continue; - } + v |= RW_READERS_LOCK(1); + if (!atomic_fcmpset_rel_ptr(&rw->rw_lock, &v, x)) + goto retry_ts; if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p last succeeded with waiters", __func__, rw); @@ -787,17 +824,14 @@ __rw_runlock_hard(volatile uintptr_t *c, struct thread } void -_rw_runlock_cookie(volatile uintptr_t *c, const char *file, int line) +_rw_runlock_cookie_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF) { - struct rwlock *rw; struct thread *td; uintptr_t v; - rw = rwlock2rw(c); - KASSERT(rw->rw_lock != RW_DESTROYED, ("rw_runlock() of destroyed rwlock @ %s:%d", file, line)); - __rw_assert(c, RA_RLOCKED, file, line); + __rw_assert(&rw->rw_lock, RA_RLOCKED, file, line); WITNESS_UNLOCK(&rw->lock_object, 0, file, line); LOCK_LOG_LOCK("RUNLOCK", &rw->lock_object, 0, 0, file, line); @@ -806,24 +840,33 @@ _rw_runlock_cookie(volatile uintptr_t *c, const char * if (__predict_false(LOCKSTAT_OOL_PROFILE_ENABLED(rw__release) || !__rw_runlock_try(rw, td, &v))) - __rw_runlock_hard(c, td, v, file, line); + __rw_runlock_hard(rw, td, v LOCK_FILE_LINE_ARG); TD_LOCKS_DEC(curthread); } +void +_rw_runlock_cookie(volatile uintptr_t *c, const char *file, int line) +{ + struct rwlock *rw; + + rw = rwlock2rw(c); + _rw_runlock_cookie_int(rw LOCK_FILE_LINE_ARG); +} + /* * This function is called when we are unable to obtain a write lock on the * first try. This means that at least one other thread holds either a * read or write lock. */ void -__rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, - const char *file, int line) +__rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOCK_FILE_LINE_ARG_DEF) { + uintptr_t tid; struct rwlock *rw; struct turnstile *ts; + struct thread *owner; #ifdef ADAPTIVE_RWLOCKS - volatile struct thread *owner; int spintries = 0; int i; #endif @@ -836,12 +879,16 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui struct lock_delay_arg lda; #endif #ifdef KDTRACE_HOOKS - uintptr_t state; u_int sleep_cnt = 0; int64_t sleep_time = 0; int64_t all_time = 0; #endif +#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING) + uintptr_t state; + int doing_lockprof; +#endif + tid = (uintptr_t)curthread; if (SCHEDULER_STOPPED()) return; @@ -869,10 +916,23 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui CTR5(KTR_LOCK, "%s: %s contested (lock=%p) at %s:%d", __func__, rw->lock_object.lo_name, (void *)rw->rw_lock, file, line); -#ifdef KDTRACE_HOOKS - all_time -= lockstat_nsecs(&rw->lock_object); +#ifdef HWPMC_HOOKS + PMC_SOFT_CALL( , , lock, failed); +#endif + lock_profile_obtain_lock_failed(&rw->lock_object, + &contested, &waittime); + +#ifdef LOCK_PROFILING + doing_lockprof = 1; state = v; +#elif defined(KDTRACE_HOOKS) + doing_lockprof = lockstat_enabled; + if (__predict_false(doing_lockprof)) { + all_time -= lockstat_nsecs(&rw->lock_object); + state = v; + } #endif + for (;;) { if (v == RW_UNLOCKED) { if (_rw_write_lock_fetch(rw, &v, tid)) @@ -882,11 +942,7 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui #ifdef KDTRACE_HOOKS lda.spin_cnt++; #endif -#ifdef HWPMC_HOOKS - PMC_SOFT_CALL( , , lock, failed); -#endif - lock_profile_obtain_lock_failed(&rw->lock_object, - &contested, &waittime); + #ifdef ADAPTIVE_RWLOCKS /* * If the lock is write locked and the owner is @@ -913,9 +969,8 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui if ((v & RW_LOCK_READ) && RW_READERS(v) && spintries < rowner_retries) { if (!(v & RW_LOCK_WRITE_SPINNER)) { - if (!atomic_cmpset_ptr(&rw->rw_lock, v, + if (!atomic_fcmpset_ptr(&rw->rw_lock, &v, v | RW_LOCK_WRITE_SPINNER)) { - v = RW_READ_VALUE(rw); continue; } } @@ -924,13 +979,13 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui "spinning", "lockname:\"%s\"", rw->lock_object.lo_name); for (i = 0; i < rowner_loops; i++) { - if ((rw->rw_lock & RW_LOCK_WRITE_SPINNER) == 0) - break; cpu_spinwait(); + v = RW_READ_VALUE(rw); + if ((v & RW_LOCK_WRITE_SPINNER) == 0) + break; } KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); - v = RW_READ_VALUE(rw); #ifdef KDTRACE_HOOKS lda.spin_cnt += rowner_loops - i; #endif @@ -940,6 +995,8 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui #endif ts = turnstile_trywait(&rw->lock_object); v = RW_READ_VALUE(rw); +retry_ts: + owner = lv_rw_wowner(v); #ifdef ADAPTIVE_RWLOCKS /* @@ -949,8 +1006,7 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui * chain lock. If so, drop the turnstile lock and try * again. */ - if (!(v & RW_LOCK_READ)) { - owner = (struct thread *)RW_OWNER(v); + if (owner != NULL) { if (TD_IS_RUNNING(owner)) { turnstile_cancel(ts); continue; @@ -967,16 +1023,14 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui x = v & (RW_LOCK_WAITERS | RW_LOCK_WRITE_SPINNER); if ((v & ~x) == RW_UNLOCKED) { x &= ~RW_LOCK_WRITE_SPINNER; - if (atomic_cmpset_acq_ptr(&rw->rw_lock, v, tid | x)) { + if (atomic_fcmpset_acq_ptr(&rw->rw_lock, &v, tid | x)) { if (x) turnstile_claim(ts); else turnstile_cancel(ts); break; } - turnstile_cancel(ts); - v = RW_READ_VALUE(rw); - continue; + goto retry_ts; } /* * If the RW_LOCK_WRITE_WAITERS flag isn't set, then try to @@ -984,12 +1038,9 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui * again. */ if (!(v & RW_LOCK_WRITE_WAITERS)) { - if (!atomic_cmpset_ptr(&rw->rw_lock, v, - v | RW_LOCK_WRITE_WAITERS)) { - turnstile_cancel(ts); - v = RW_READ_VALUE(rw); - continue; - } + if (!atomic_fcmpset_ptr(&rw->rw_lock, &v, + v | RW_LOCK_WRITE_WAITERS)) + goto retry_ts; if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p set write waiters flag", __func__, rw); @@ -1004,7 +1055,8 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui #ifdef KDTRACE_HOOKS sleep_time -= lockstat_nsecs(&rw->lock_object); #endif - turnstile_wait(ts, rw_owner(rw), TS_EXCLUSIVE_QUEUE); + MPASS(owner == rw_owner(rw)); + turnstile_wait(ts, owner, TS_EXCLUSIVE_QUEUE); #ifdef KDTRACE_HOOKS sleep_time += lockstat_nsecs(&rw->lock_object); sleep_cnt++; @@ -1017,6 +1069,10 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui #endif v = RW_READ_VALUE(rw); } +#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING) + if (__predict_true(!doing_lockprof)) + return; +#endif #ifdef KDTRACE_HOOKS all_time += lockstat_nsecs(&rw->lock_object); if (sleep_time) @@ -1041,19 +1097,21 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui * on this lock. */ void -__rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid, const char *file, - int line) +__rw_wunlock_hard(volatile uintptr_t *c, uintptr_t v LOCK_FILE_LINE_ARG_DEF) { struct rwlock *rw; struct turnstile *ts; - uintptr_t v; + uintptr_t tid, setv; int queue; + tid = (uintptr_t)curthread; if (SCHEDULER_STOPPED()) return; rw = rwlock2rw(c); - v = RW_READ_VALUE(rw); + if (__predict_false(v == tid)) + v = RW_READ_VALUE(rw); + if (v & RW_LOCK_WRITER_RECURSED) { if (--(rw->rw_recurse) == 0) atomic_clear_ptr(&rw->rw_lock, RW_LOCK_WRITER_RECURSED); @@ -1073,8 +1131,6 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid CTR2(KTR_LOCK, "%s: %p contested", __func__, rw); turnstile_chain_lock(&rw->lock_object); - ts = turnstile_lookup(&rw->lock_object); - MPASS(ts != NULL); /* * Use the same algo as sx locks for now. Prefer waking up shared @@ -1092,19 +1148,23 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid * there that could be worked around either by waking both queues * of waiters or doing some complicated lock handoff gymnastics. */ - v = RW_UNLOCKED; - if (rw->rw_lock & RW_LOCK_WRITE_WAITERS) { + setv = RW_UNLOCKED; + v = RW_READ_VALUE(rw); + queue = TS_SHARED_QUEUE; + if (v & RW_LOCK_WRITE_WAITERS) { queue = TS_EXCLUSIVE_QUEUE; - v |= (rw->rw_lock & RW_LOCK_READ_WAITERS); - } else - queue = TS_SHARED_QUEUE; + setv |= (v & RW_LOCK_READ_WAITERS); + } + atomic_store_rel_ptr(&rw->rw_lock, setv); /* Wake up all waiters for the specific queue. */ if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR3(KTR_LOCK, "%s: %p waking up %s waiters", __func__, rw, queue == TS_SHARED_QUEUE ? "read" : "write"); + + ts = turnstile_lookup(&rw->lock_object); + MPASS(ts != NULL); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Sun Dec 31 05:14:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0BD8EA11B9; Sun, 31 Dec 2017 05:14:41 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B58CD29BF; Sun, 31 Dec 2017 05:14:41 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV5EemW041949; Sun, 31 Dec 2017 05:14:40 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV5EeXT041948; Sun, 31 Dec 2017 05:14:40 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201712310514.vBV5EeXT041948@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 31 Dec 2017 05:14:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327414 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 327414 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 05:14:42 -0000 Author: mjg Date: Sun Dec 31 05:14:40 2017 New Revision: 327414 URL: https://svnweb.freebsd.org/changeset/base/327414 Log: MFC r324328: amd64: remove unused variable from pmap_delayed_invl_genp Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-11@freebsd.org Sun Dec 31 11:15:23 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84D41EB0B3A; Sun, 31 Dec 2017 11:15:23 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5B3A86EF42; Sun, 31 Dec 2017 11:15:22 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id vBVBFLZF080997; Sun, 31 Dec 2017 03:15:21 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id vBVBFLGu080996; Sun, 31 Dec 2017 03:15:21 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201712311115.vBVBFLGu080996@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r327414 - stable/11 In-Reply-To: <201712310514.vBV5EeXT041948@repo.freebsd.org> To: Mateusz Guzik Date: Sun, 31 Dec 2017 03:15:20 -0800 (PST) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 11:15:23 -0000 [ Charset UTF-8 unsupported, converting... ] > Author: mjg > Date: Sun Dec 31 05:14:40 2017 > New Revision: 327414 > URL: https://svnweb.freebsd.org/changeset/base/327414 > > Log: > MFC r324328: > > amd64: remove unused variable from pmap_delayed_invl_genp > > Modified: > Directory Properties: > stable/11/ (props changed) > > I dont see any diff here???? https://www.mail-archive.com/svn-src-all@freebsd.org/msg151169.html shows that 2 lines are deleted by r324328 -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-stable-11@freebsd.org Sun Dec 31 16:52:30 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB56AE86690; Sun, 31 Dec 2017 16:52:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8432979EF3; Sun, 31 Dec 2017 16:52:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBVGqT9c036059; Sun, 31 Dec 2017 16:52:29 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBVGqTKh036057; Sun, 31 Dec 2017 16:52:29 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201712311652.vBVGqTKh036057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sun, 31 Dec 2017 16:52:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327436 - in stable/11: . sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: in stable/11: . sys/sys X-SVN-Commit-Revision: 327436 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 16:52:30 -0000 Author: bz Date: Sun Dec 31 16:52:29 2017 New Revision: 327436 URL: https://svnweb.freebsd.org/changeset/base/327436 Log: MFC r327435: Happy New Year 2018 my friends! Modified: stable/11/COPYRIGHT stable/11/sys/sys/copyright.h Directory Properties: stable/11/ (props changed) Modified: stable/11/COPYRIGHT ============================================================================== --- stable/11/COPYRIGHT Sun Dec 31 16:48:04 2017 (r327435) +++ stable/11/COPYRIGHT Sun Dec 31 16:52:29 2017 (r327436) @@ -4,7 +4,7 @@ The compilation of software known as FreeBSD is distributed under the following terms: -Copyright (c) 1992-2017 The FreeBSD Project. All rights reserved. +Copyright (c) 1992-2018 The FreeBSD Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions Modified: stable/11/sys/sys/copyright.h ============================================================================== --- stable/11/sys/sys/copyright.h Sun Dec 31 16:48:04 2017 (r327435) +++ stable/11/sys/sys/copyright.h Sun Dec 31 16:52:29 2017 (r327436) @@ -1,5 +1,5 @@ /*- - * Copyright (C) 1992-2017 The FreeBSD Project. All rights reserved. + * Copyright (C) 1992-2018 The FreeBSD Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -34,7 +34,7 @@ /* FreeBSD */ #define COPYRIGHT_FreeBSD \ - "Copyright (c) 1992-2017 The FreeBSD Project.\n" + "Copyright (c) 1992-2018 The FreeBSD Project.\n" /* Foundation */ #define TRADEMARK_Foundation \ From owner-svn-src-stable-11@freebsd.org Mon Jan 1 20:24:18 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B738EBAE04; Mon, 1 Jan 2018 20:24:18 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 628D57B7E8; Mon, 1 Jan 2018 20:24:18 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w01KOHPj031011; Mon, 1 Jan 2018 20:24:17 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w01KOH4v031010; Mon, 1 Jan 2018 20:24:17 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201801012024.w01KOH4v031010@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 1 Jan 2018 20:24:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327470 - in stable: 10/sys/cddl/contrib/opensolaris/uts/common/sys 11/sys/cddl/contrib/opensolaris/uts/common/sys 9/sys/cddl/contrib/opensolaris/uts/common/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 10/sys/cddl/contrib/opensolaris/uts/common/sys 11/sys/cddl/contrib/opensolaris/uts/common/sys 9/sys/cddl/contrib/opensolaris/uts/common/sys X-SVN-Commit-Revision: 327470 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jan 2018 20:24:18 -0000 Author: dim Date: Mon Jan 1 20:24:16 2018 New Revision: 327470 URL: https://svnweb.freebsd.org/changeset/base/327470 Log: MFC r327167: Remove obsolete register keyword from opensolaris's sysmacros.h. When compiling zfsd with recent clang, it leads to a warning about the register storage class being incompatible with C++17. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h stable/9/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h Directory Properties: stable/10/ (props changed) stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h Mon Jan 1 19:34:19 2018 (r327469) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h Mon Jan 1 20:24:16 2018 (r327470) @@ -388,7 +388,7 @@ highbit(ulong_t i) #if defined(__FreeBSD__) && defined(_KERNEL) && defined(HAVE_INLINE_FLSL) return (flsl(i)); #else - register int h = 1; + int h = 1; if (i == 0) return (0); From owner-svn-src-stable-11@freebsd.org Mon Jan 1 20:39:16 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2E93CEBB969; Mon, 1 Jan 2018 20:39:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE3567C5FB; Mon, 1 Jan 2018 20:39:15 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w01KdDCb035821; Mon, 1 Jan 2018 20:39:13 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w01KdDE0035819; Mon, 1 Jan 2018 20:39:13 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201801012039.w01KdDE0035819@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 1 Jan 2018 20:39:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327471 - in stable: 10/contrib/binutils/bfd 10/contrib/binutils/include 11/contrib/binutils/bfd 11/contrib/binutils/include 9/contrib/binutils/bfd 9/contrib/binutils/include X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 10/contrib/binutils/bfd 10/contrib/binutils/include 11/contrib/binutils/bfd 11/contrib/binutils/include 9/contrib/binutils/bfd 9/contrib/binutils/include X-SVN-Commit-Revision: 327471 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jan 2018 20:39:16 -0000 Author: dim Date: Mon Jan 1 20:39:12 2018 New Revision: 327471 URL: https://svnweb.freebsd.org/changeset/base/327471 Log: MFC r327164: Fix clang 6.0.0 compiler warnings in binutils Latest clang git has a warning -Wnull-pointer-arithmetic which will trigger a -Werror failure. Addition and subtraction from a null pointer is undefined behaviour and could be optimized into anything. Furthermore, using the difference between two pointers and casting the result back to a pointer is not portable since the size of ptrdiff_t does not necessary have to be the same as size of void* (this happens e.g. on CHERI). Using intptr_t instead fixes this portability issue and the compiler warning. Submitted by; Alexander Richardson Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D12928 Modified: stable/11/contrib/binutils/bfd/elflink.c stable/11/contrib/binutils/include/obstack.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/contrib/binutils/bfd/elflink.c stable/10/contrib/binutils/include/obstack.h stable/9/contrib/binutils/bfd/elflink.c stable/9/contrib/binutils/include/obstack.h Directory Properties: stable/10/ (props changed) stable/9/ (props changed) stable/9/contrib/ (props changed) stable/9/contrib/binutils/ (props changed) Modified: stable/11/contrib/binutils/bfd/elflink.c ============================================================================== --- stable/11/contrib/binutils/bfd/elflink.c Mon Jan 1 20:24:16 2018 (r327470) +++ stable/11/contrib/binutils/bfd/elflink.c Mon Jan 1 20:39:12 2018 (r327471) @@ -4815,7 +4815,7 @@ _bfd_elf_archive_symbol_lookup (bfd *abfd, len = strlen (name); copy = bfd_alloc (abfd, len); if (copy == NULL) - return (struct elf_link_hash_entry *) 0 - 1; + return (struct elf_link_hash_entry *)(intptr_t)-1; first = p - name + 1; memcpy (copy, name, first); @@ -4927,7 +4927,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_li } h = archive_symbol_lookup (abfd, info, symdef->name); - if (h == (struct elf_link_hash_entry *) 0 - 1) + if (h == (struct elf_link_hash_entry *)(intptr_t)-1) goto error_return; if (h == NULL) Modified: stable/11/contrib/binutils/include/obstack.h ============================================================================== --- stable/11/contrib/binutils/include/obstack.h Mon Jan 1 20:24:16 2018 (r327470) +++ stable/11/contrib/binutils/include/obstack.h Mon Jan 1 20:39:12 2018 (r327471) @@ -119,11 +119,11 @@ extern "C" { may ignore the byte-within-word field of the pointer. */ #ifndef __PTR_TO_INT -# define __PTR_TO_INT(P) ((P) - (char *) 0) +# define __PTR_TO_INT(P) ((intptr_t)(P)) #endif #ifndef __INT_TO_PTR -# define __INT_TO_PTR(P) ((P) + (char *) 0) +# define __INT_TO_PTR(P) ((void*)(intptr_t)(P)) #endif /* We need the type of the resulting object. If __PTRDIFF_TYPE__ is @@ -427,7 +427,7 @@ __extension__ \ __o1->maybe_empty_object = 1; \ __o1->next_free \ = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ - & ~ (__o1->alignment_mask)); \ + & ~(intptr_t)(__o1->alignment_mask)); \ if (__o1->next_free - (char *)__o1->chunk \ > __o1->chunk_limit - (char *)__o1->chunk) \ __o1->next_free = __o1->chunk_limit; \ From owner-svn-src-stable-11@freebsd.org Mon Jan 1 23:45:10 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95D8FEA2B0D; Mon, 1 Jan 2018 23:45:10 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A437633C6; Mon, 1 Jan 2018 23:45:10 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w01Nj9Jg016512; Mon, 1 Jan 2018 23:45:09 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w01Nj917016511; Mon, 1 Jan 2018 23:45:09 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201801012345.w01Nj917016511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 1 Jan 2018 23:45:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327477 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 327477 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jan 2018 23:45:10 -0000 Author: mjg Date: Mon Jan 1 23:45:09 2018 New Revision: 327477 URL: https://svnweb.freebsd.org/changeset/base/327477 Log: MFC r327394,r327395: mtx: pre-read the lock value in thread_lock_flags_ Since this function is effectively slow path, if we get here the lock is most likely already taken in which case it is cheaper to not blindly attempt the atomic op. While here move hwpmc probe out of the loop to match other primitives. ============= mtx: deduplicate indefinite wait check in spinlocks and thread lock Modified: stable/11/sys/kern/kern_mutex.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_mutex.c ============================================================================== --- stable/11/sys/kern/kern_mutex.c Mon Jan 1 22:33:57 2018 (r327476) +++ stable/11/sys/kern/kern_mutex.c Mon Jan 1 23:45:09 2018 (r327477) @@ -168,6 +168,8 @@ LOCK_DELAY_SYSINIT_DEFAULT(mtx_spin_delay); struct mtx blocked_lock; struct mtx Giant; +static void _mtx_lock_indefinite_check(struct mtx *, struct lock_delay_arg *); + void assert_mtx(const struct lock_object *lock, int what) { @@ -672,25 +674,6 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v) #endif } -static void -_mtx_lock_spin_failed(struct mtx *m) -{ - struct thread *td; - - td = mtx_owner(m); - - /* If the mutex is unlocked, try again. */ - if (td == NULL) - return; - - printf( "spin lock %p (%s) held by %p (tid %d) too long\n", - m, m->lock_object.lo_name, td, td->td_tid); -#ifdef WITNESS - witness_display_spinlock(&m->lock_object, td, printf); -#endif - panic("spin lock held too long"); -} - #ifdef SMP /* * _mtx_lock_spin_cookie: the tougher part of acquiring an MTX_SPIN lock. @@ -762,16 +745,10 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t /* Give interrupts a chance while we spin. */ spinlock_exit(); do { - if (lda.spin_cnt < 10000000) { + if (__predict_true(lda.spin_cnt < 10000000)) { lock_delay(&lda); } else { - lda.spin_cnt++; - if (lda.spin_cnt < 60000000 || kdb_active || - panicstr != NULL) - DELAY(1); - else - _mtx_lock_spin_failed(m); - cpu_spinwait(); + _mtx_lock_indefinite_check(m, &lda); } v = MTX_READ_VALUE(m); } while (v != MTX_UNOWNED); @@ -897,6 +874,10 @@ thread_lock_flags_(struct thread *td, int opts, const lock_delay_arg_init(&lda, &mtx_spin_delay); +#ifdef HWPMC_HOOKS + PMC_SOFT_CALL( , , lock, failed); +#endif + #ifdef LOCK_PROFILING doing_lockprof = 1; #elif defined(KDTRACE_HOOKS) @@ -906,37 +887,29 @@ thread_lock_flags_(struct thread *td, int opts, const #endif for (;;) { retry: - v = MTX_UNOWNED; spinlock_enter(); m = td->td_lock; thread_lock_validate(m, opts, file, line); + v = MTX_READ_VALUE(m); for (;;) { - if (_mtx_obtain_lock_fetch(m, &v, tid)) - break; - if (v == MTX_UNOWNED) + if (v == MTX_UNOWNED) { + if (_mtx_obtain_lock_fetch(m, &v, tid)) + break; continue; + } if (v == tid) { m->mtx_recurse++; break; } -#ifdef HWPMC_HOOKS - PMC_SOFT_CALL( , , lock, failed); -#endif lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); /* Give interrupts a chance while we spin. */ spinlock_exit(); do { - if (lda.spin_cnt < 10000000) { + if (__predict_true(lda.spin_cnt < 10000000)) { lock_delay(&lda); } else { - lda.spin_cnt++; - if (lda.spin_cnt < 60000000 || - kdb_active || panicstr != NULL) - DELAY(1); - else - _mtx_lock_spin_failed(m); - cpu_spinwait(); + _mtx_lock_indefinite_check(m, &lda); } if (m != td->td_lock) goto retry; @@ -1225,6 +1198,31 @@ mutex_init(void) mtx_init(&proc0.p_profmtx, "pprofl", NULL, MTX_SPIN); mtx_init(&devmtx, "cdev", NULL, MTX_DEF); mtx_lock(&Giant); +} + +static void __noinline +_mtx_lock_indefinite_check(struct mtx *m, struct lock_delay_arg *ldap) +{ + struct thread *td; + + ldap->spin_cnt++; + if (ldap->spin_cnt < 60000000 || kdb_active || panicstr != NULL) + DELAY(1); + else { + td = mtx_owner(m); + + /* If the mutex is unlocked, try again. */ + if (td == NULL) + return; + + printf( "spin lock %p (%s) held by %p (tid %d) too long\n", + m, m->lock_object.lo_name, td, td->td_tid); +#ifdef WITNESS + witness_display_spinlock(&m->lock_object, td, printf); +#endif + panic("spin lock held too long"); + } + cpu_spinwait(); } #ifdef DDB From owner-svn-src-stable-11@freebsd.org Tue Jan 2 00:02:37 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86674EA3C52; Tue, 2 Jan 2018 00:02:37 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4A74B6424E; Tue, 2 Jan 2018 00:02:37 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0202aWi025159; Tue, 2 Jan 2018 00:02:36 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0202agg025156; Tue, 2 Jan 2018 00:02:36 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201801020002.w0202agg025156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 2 Jan 2018 00:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327478 - in stable/11/sys: kern sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in stable/11/sys: kern sys X-SVN-Commit-Revision: 327478 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 00:02:37 -0000 Author: mjg Date: Tue Jan 2 00:02:36 2018 New Revision: 327478 URL: https://svnweb.freebsd.org/changeset/base/327478 Log: MFC r324335,r327393,r327397,r327401,r327402: locks: take the number of readers into account when waiting Previous code would always spin once before checking the lock. But a lock with e.g. 6 readers is not going to become free in the duration of once spin even if they start draining immediately. Conservatively perform one for each reader. Note that the total number of allowed spins is still extremely small and is subject to change later. ============= rwlock: tidy up __rw_runlock_hard similarly to r325921 ============= sx: read the SX_NOADAPTIVE flag and Giant ownership only once These used to be read multiple times when waiting for the lock the become free, which had the potential to issue completely avoidable traffic. ============= locks: re-check the reason to go to sleep after locking sleepq/turnstile In both rw and sx locks we always go to sleep if the lock owner is not running. We do spin for some time if the lock is read-locked. However, if we decide to go to sleep due to the lock owner being off cpu and after sleepq/turnstile gets acquired the lock is read-locked, we should fallback to the aforementioned wait. ============= sx: fix up non-smp compilation after r327397 ============= locks: adjust loop limit check when waiting for readers The check was for the exact value, but since the counter started being incremented by the number of readers it could have jumped over. ============= Return a non-NULL owner only if the lock is exclusively held in owner_sx(). Fix some whitespace bugs while here. Modified: stable/11/sys/kern/kern_rwlock.c stable/11/sys/kern/kern_sx.c stable/11/sys/sys/lock.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_rwlock.c ============================================================================== --- stable/11/sys/kern/kern_rwlock.c Mon Jan 1 23:45:09 2018 (r327477) +++ stable/11/sys/kern/kern_rwlock.c Tue Jan 2 00:02:36 2018 (r327478) @@ -420,7 +420,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, struct thread *owner; #ifdef ADAPTIVE_RWLOCKS int spintries = 0; - int i; + int i, n; #endif #ifdef LOCK_PROFILING uint64_t waittime = 0; @@ -502,8 +502,9 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, KTR_STATE1(KTR_SCHED, "thread", sched_tdname(curthread), "spinning", "lockname:\"%s\"", rw->lock_object.lo_name); - for (i = 0; i < rowner_loops; i++) { - cpu_spinwait(); + for (i = 0; i < rowner_loops; i += n) { + n = RW_READERS(v); + lock_delay_spin(n); v = RW_READ_VALUE(rw); if ((v & RW_LOCK_READ) == 0 || __rw_can_read(td, v, false)) break; @@ -513,7 +514,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, #endif KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); - if (i != rowner_loops) + if (i < rowner_loops) continue; } #endif @@ -752,7 +753,7 @@ __rw_runlock_hard(struct rwlock *rw, struct thread *td LOCK_FILE_LINE_ARG_DEF) { struct turnstile *ts; - uintptr_t x, queue; + uintptr_t setv, queue; if (SCHEDULER_STOPPED()) return; @@ -792,14 +793,14 @@ retry_ts: * acquired a read lock, so drop the turnstile lock and * restart. */ - x = RW_UNLOCKED; + setv = RW_UNLOCKED; + queue = TS_SHARED_QUEUE; if (v & RW_LOCK_WRITE_WAITERS) { queue = TS_EXCLUSIVE_QUEUE; - x |= (v & RW_LOCK_READ_WAITERS); - } else - queue = TS_SHARED_QUEUE; + setv |= (v & RW_LOCK_READ_WAITERS); + } v |= RW_READERS_LOCK(1); - if (!atomic_fcmpset_rel_ptr(&rw->rw_lock, &v, x)) + if (!atomic_fcmpset_rel_ptr(&rw->rw_lock, &v, setv)) goto retry_ts; if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p last succeeded with waiters", @@ -868,7 +869,8 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOC struct thread *owner; #ifdef ADAPTIVE_RWLOCKS int spintries = 0; - int i; + int i, n; + int sleep_reason = 0; #endif uintptr_t x; #ifdef LOCK_PROFILING @@ -949,6 +951,7 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOC * running on another CPU, spin until the owner stops * running or the state of the lock changes. */ + sleep_reason = 1; owner = lv_rw_wowner(v); if (!(v & RW_LOCK_READ) && TD_IS_RUNNING(owner)) { if (LOCK_LOG_TEST(&rw->lock_object, 0)) @@ -978,8 +981,9 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOC KTR_STATE1(KTR_SCHED, "thread", sched_tdname(curthread), "spinning", "lockname:\"%s\"", rw->lock_object.lo_name); - for (i = 0; i < rowner_loops; i++) { - cpu_spinwait(); + for (i = 0; i < rowner_loops; i += n) { + n = RW_READERS(v); + lock_delay_spin(n); v = RW_READ_VALUE(rw); if ((v & RW_LOCK_WRITE_SPINNER) == 0) break; @@ -989,8 +993,9 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOC #ifdef KDTRACE_HOOKS lda.spin_cnt += rowner_loops - i; #endif - if (i != rowner_loops) + if (i < rowner_loops) continue; + sleep_reason = 2; } #endif ts = turnstile_trywait(&rw->lock_object); @@ -1011,6 +1016,9 @@ retry_ts: turnstile_cancel(ts); continue; } + } else if (RW_READERS(v) > 0 && sleep_reason == 1) { + turnstile_cancel(ts); + continue; } #endif /* Modified: stable/11/sys/kern/kern_sx.c ============================================================================== --- stable/11/sys/kern/kern_sx.c Mon Jan 1 23:45:09 2018 (r327477) +++ stable/11/sys/kern/kern_sx.c Tue Jan 2 00:02:36 2018 (r327478) @@ -89,7 +89,7 @@ PMC_SOFT_DECLARE( , , lock, failed); WITNESS_SAVE_DECL(Giant) \ #define GIANT_SAVE(work) do { \ - if (mtx_owned(&Giant)) { \ + if (__predict_false(mtx_owned(&Giant))) { \ work++; \ WITNESS_SAVE(&Giant.lock_object, Giant); \ while (mtx_owned(&Giant)) { \ @@ -198,12 +198,14 @@ unlock_sx(struct lock_object *lock) int owner_sx(const struct lock_object *lock, struct thread **owner) { - const struct sx *sx = (const struct sx *)lock; - uintptr_t x = sx->sx_lock; + const struct sx *sx; + uintptr_t x; - *owner = (struct thread *)SX_OWNER(x); - return ((x & SX_LOCK_SHARED) != 0 ? (SX_SHARERS(x) != 0) : - (*owner != NULL)); + sx = (const struct sx *)lock; + x = sx->sx_lock; + *owner = NULL; + return ((x & SX_LOCK_SHARED) != 0 ? (SX_SHARERS(x) != 0) : + ((*owner = (struct thread *)SX_OWNER(x)) != NULL)); } #endif @@ -528,7 +530,9 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO uintptr_t tid; #ifdef ADAPTIVE_SX volatile struct thread *owner; - u_int i, spintries = 0; + u_int i, n, spintries = 0; + bool adaptive; + int sleep_reason = 0; #endif #ifdef LOCK_PROFILING uint64_t waittime = 0; @@ -577,6 +581,10 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO CTR5(KTR_LOCK, "%s: %s contested (lock=%p) at %s:%d", __func__, sx->lock_object.lo_name, (void *)sx->sx_lock, file, line); +#ifdef ADAPTIVE_SX + adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) != 0); +#endif + #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif @@ -593,6 +601,9 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO state = x; } #endif +#ifndef INVARIANTS + GIANT_SAVE(extra_work); +#endif for (;;) { if (x == SX_LOCK_UNLOCKED) { @@ -600,66 +611,70 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO break; continue; } +#ifdef INVARIANTS + GIANT_SAVE(extra_work); +#endif #ifdef KDTRACE_HOOKS lda.spin_cnt++; #endif #ifdef ADAPTIVE_SX + if (__predict_false(!adaptive)) + goto sleepq; /* * If the lock is write locked and the owner is * running on another CPU, spin until the owner stops * running or the state of the lock changes. */ - if ((sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0) { - if ((x & SX_LOCK_SHARED) == 0) { - owner = lv_sx_owner(x); - if (TD_IS_RUNNING(owner)) { - if (LOCK_LOG_TEST(&sx->lock_object, 0)) - CTR3(KTR_LOCK, - "%s: spinning on %p held by %p", - __func__, sx, owner); - KTR_STATE1(KTR_SCHED, "thread", - sched_tdname(curthread), "spinning", - "lockname:\"%s\"", - sx->lock_object.lo_name); - GIANT_SAVE(extra_work); - do { - lock_delay(&lda); - x = SX_READ_VALUE(sx); - owner = lv_sx_owner(x); - } while (owner != NULL && - TD_IS_RUNNING(owner)); - KTR_STATE0(KTR_SCHED, "thread", - sched_tdname(curthread), "running"); - continue; - } - } else if (SX_SHARERS(x) && spintries < asx_retries) { + if ((x & SX_LOCK_SHARED) == 0) { + owner = lv_sx_owner(x); + if (TD_IS_RUNNING(owner)) { + if (LOCK_LOG_TEST(&sx->lock_object, 0)) + CTR3(KTR_LOCK, + "%s: spinning on %p held by %p", + __func__, sx, owner); KTR_STATE1(KTR_SCHED, "thread", sched_tdname(curthread), "spinning", - "lockname:\"%s\"", sx->lock_object.lo_name); - GIANT_SAVE(extra_work); - spintries++; - for (i = 0; i < asx_loops; i++) { - if (LOCK_LOG_TEST(&sx->lock_object, 0)) - CTR4(KTR_LOCK, - "%s: shared spinning on %p with %u and %u", - __func__, sx, spintries, i); - cpu_spinwait(); + "lockname:\"%s\"", + sx->lock_object.lo_name); + do { + lock_delay(&lda); x = SX_READ_VALUE(sx); - if ((x & SX_LOCK_SHARED) == 0 || - SX_SHARERS(x) == 0) - break; - } -#ifdef KDTRACE_HOOKS - lda.spin_cnt += i; -#endif + owner = lv_sx_owner(x); + } while (owner != NULL && + TD_IS_RUNNING(owner)); KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); - if (i != asx_loops) - continue; + continue; } + sleep_reason = 1; + } else if (SX_SHARERS(x) && spintries < asx_retries) { + KTR_STATE1(KTR_SCHED, "thread", + sched_tdname(curthread), "spinning", + "lockname:\"%s\"", sx->lock_object.lo_name); + spintries++; + for (i = 0; i < asx_loops; i += n) { + if (LOCK_LOG_TEST(&sx->lock_object, 0)) + CTR4(KTR_LOCK, + "%s: shared spinning on %p with %u and %u", + __func__, sx, spintries, i); + n = SX_SHARERS(x); + lock_delay_spin(n); + x = SX_READ_VALUE(sx); + if ((x & SX_LOCK_SHARED) == 0 || + SX_SHARERS(x) == 0) + break; + } +#ifdef KDTRACE_HOOKS + lda.spin_cnt += i; +#endif + KTR_STATE0(KTR_SCHED, "thread", + sched_tdname(curthread), "running"); + if (i < asx_loops) + continue; + sleep_reason = 2; } +sleepq: #endif - sleepq_lock(&sx->lock_object); x = SX_READ_VALUE(sx); retry_sleepq: @@ -681,10 +696,14 @@ retry_sleepq: * chain lock. If so, drop the sleep queue lock and try * again. */ - if (!(x & SX_LOCK_SHARED) && - (sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0) { - owner = (struct thread *)SX_OWNER(x); - if (TD_IS_RUNNING(owner)) { + if (adaptive) { + if (!(x & SX_LOCK_SHARED)) { + owner = (struct thread *)SX_OWNER(x); + if (TD_IS_RUNNING(owner)) { + sleepq_release(&sx->lock_object); + continue; + } + } else if (SX_SHARERS(x) > 0 && sleep_reason == 1) { sleepq_release(&sx->lock_object); continue; } @@ -737,7 +756,6 @@ retry_sleepq: #ifdef KDTRACE_HOOKS sleep_time -= lockstat_nsecs(&sx->lock_object); #endif - GIANT_SAVE(extra_work); sleepq_add(&sx->lock_object, NULL, sx->lock_object.lo_name, SLEEPQ_SX | ((opts & SX_INTERRUPTIBLE) ? SLEEPQ_INTERRUPTIBLE : 0), SQ_EXCLUSIVE_QUEUE); @@ -887,6 +905,7 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO GIANT_DECLARE; #ifdef ADAPTIVE_SX volatile struct thread *owner; + bool adaptive; #endif #ifdef LOCK_PROFILING uint64_t waittime = 0; @@ -915,6 +934,10 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO lock_delay_arg_init(&lda, NULL); #endif +#ifdef ADAPTIVE_SX + adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) != 0); +#endif + #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif @@ -931,6 +954,9 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO state = x; } #endif +#ifndef INVARIANTS + GIANT_SAVE(extra_work); +#endif /* * As with rwlocks, we don't make any attempt to try to block @@ -939,37 +965,40 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO for (;;) { if (__sx_slock_try(sx, &x LOCK_FILE_LINE_ARG)) break; +#ifdef INVARIANTS + GIANT_SAVE(extra_work); +#endif #ifdef KDTRACE_HOOKS lda.spin_cnt++; #endif #ifdef ADAPTIVE_SX + if (__predict_false(!adaptive)) + goto sleepq; /* * If the owner is running on another CPU, spin until * the owner stops running or the state of the lock * changes. */ - if ((sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0) { - owner = lv_sx_owner(x); - if (TD_IS_RUNNING(owner)) { - if (LOCK_LOG_TEST(&sx->lock_object, 0)) - CTR3(KTR_LOCK, - "%s: spinning on %p held by %p", - __func__, sx, owner); - KTR_STATE1(KTR_SCHED, "thread", - sched_tdname(curthread), "spinning", - "lockname:\"%s\"", sx->lock_object.lo_name); - GIANT_SAVE(extra_work); - do { - lock_delay(&lda); - x = SX_READ_VALUE(sx); - owner = lv_sx_owner(x); - } while (owner != NULL && TD_IS_RUNNING(owner)); - KTR_STATE0(KTR_SCHED, "thread", - sched_tdname(curthread), "running"); - continue; - } + owner = lv_sx_owner(x); + if (TD_IS_RUNNING(owner)) { + if (LOCK_LOG_TEST(&sx->lock_object, 0)) + CTR3(KTR_LOCK, + "%s: spinning on %p held by %p", + __func__, sx, owner); + KTR_STATE1(KTR_SCHED, "thread", + sched_tdname(curthread), "spinning", + "lockname:\"%s\"", sx->lock_object.lo_name); + do { + lock_delay(&lda); + x = SX_READ_VALUE(sx); + owner = lv_sx_owner(x); + } while (owner != NULL && TD_IS_RUNNING(owner)); + KTR_STATE0(KTR_SCHED, "thread", + sched_tdname(curthread), "running"); + continue; } +sleepq: #endif /* @@ -994,8 +1023,7 @@ retry_sleepq: * the owner stops running or the state of the lock * changes. */ - if (!(x & SX_LOCK_SHARED) && - (sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0) { + if (!(x & SX_LOCK_SHARED) && adaptive) { owner = (struct thread *)SX_OWNER(x); if (TD_IS_RUNNING(owner)) { sleepq_release(&sx->lock_object); @@ -1030,7 +1058,6 @@ retry_sleepq: #ifdef KDTRACE_HOOKS sleep_time -= lockstat_nsecs(&sx->lock_object); #endif - GIANT_SAVE(extra_work); sleepq_add(&sx->lock_object, NULL, sx->lock_object.lo_name, SLEEPQ_SX | ((opts & SX_INTERRUPTIBLE) ? SLEEPQ_INTERRUPTIBLE : 0), SQ_SHARED_QUEUE); Modified: stable/11/sys/sys/lock.h ============================================================================== --- stable/11/sys/sys/lock.h Mon Jan 1 23:45:09 2018 (r327477) +++ stable/11/sys/sys/lock.h Tue Jan 2 00:02:36 2018 (r327478) @@ -230,6 +230,13 @@ lock_delay_arg_init(struct lock_delay_arg *la, struct la->spin_cnt = 0; } +#define lock_delay_spin(n) do { \ + u_int _i; \ + \ + for (_i = (n); _i > 0; _i--) \ + cpu_spinwait(); \ +} while (0) + #define LOCK_DELAY_SYSINIT(func) \ SYSINIT(func##_ld, SI_SUB_LOCK, SI_ORDER_ANY, func, NULL) From owner-svn-src-stable-11@freebsd.org Tue Jan 2 00:11:58 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 285B1EA45C5; Tue, 2 Jan 2018 00:11:58 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F348D649BA; Tue, 2 Jan 2018 00:11:57 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w020BvAb026511; Tue, 2 Jan 2018 00:11:57 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w020Buhk026508; Tue, 2 Jan 2018 00:11:56 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201801020011.w020Buhk026508@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 2 Jan 2018 00:11:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327480 - in stable/11/sys: cddl/dev/sdt kern sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in stable/11/sys: cddl/dev/sdt kern sys X-SVN-Commit-Revision: 327480 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 00:11:58 -0000 Author: mjg Date: Tue Jan 2 00:11:56 2018 New Revision: 327480 URL: https://svnweb.freebsd.org/changeset/base/327480 Log: MFC r324867,r324869: sdt: whack unused SDT_PROBE_ENABLED ============= sdt: make all sdt probe sites test one variable This saves on cache misses at the expense of a slight grow of .text. Note this is a bandaid for lack of hotpatching. Modified: stable/11/sys/cddl/dev/sdt/sdt.c stable/11/sys/kern/kern_sdt.c stable/11/sys/sys/sdt.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/dev/sdt/sdt.c ============================================================================== --- stable/11/sys/cddl/dev/sdt/sdt.c Tue Jan 2 00:07:28 2018 (r327479) +++ stable/11/sys/cddl/dev/sdt/sdt.c Tue Jan 2 00:11:56 2018 (r327480) @@ -76,6 +76,8 @@ static void sdt_kld_unload_try(void *, struct linker_f static MALLOC_DEFINE(M_SDT, "SDT", "DTrace SDT providers"); +static int sdt_probes_enabled_count; + static dtrace_pattr_t sdt_attr = { { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON }, { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN }, @@ -208,6 +210,9 @@ sdt_enable(void *arg __unused, dtrace_id_t id, void *p probe->sdtp_lf->nenabled++; if (strcmp(probe->prov->name, "lockstat") == 0) lockstat_enabled++; + sdt_probes_enabled_count++; + if (sdt_probes_enabled_count == 1) + sdt_probes_enabled = true; } static void @@ -217,6 +222,9 @@ sdt_disable(void *arg __unused, dtrace_id_t id, void * KASSERT(probe->sdtp_lf->nenabled > 0, ("no probes enabled")); + sdt_probes_enabled_count--; + if (sdt_probes_enabled_count == 0) + sdt_probes_enabled = false; if (strcmp(probe->prov->name, "lockstat") == 0) lockstat_enabled--; probe->id = 0; Modified: stable/11/sys/kern/kern_sdt.c ============================================================================== --- stable/11/sys/kern/kern_sdt.c Tue Jan 2 00:07:28 2018 (r327479) +++ stable/11/sys/kern/kern_sdt.c Tue Jan 2 00:11:56 2018 (r327480) @@ -37,6 +37,7 @@ SDT_PROVIDER_DEFINE(sdt); * dtrace_probe() when it loads. */ sdt_probe_func_t sdt_probe_func = sdt_probe_stub; +volatile bool __read_frequently sdt_probes_enabled; /* * This is a stub for probe calls in case kernel DTrace support isn't Modified: stable/11/sys/sys/sdt.h ============================================================================== --- stable/11/sys/sys/sdt.h Tue Jan 2 00:07:28 2018 (r327479) +++ stable/11/sys/sys/sdt.h Tue Jan 2 00:11:56 2018 (r327480) @@ -80,13 +80,14 @@ #include #include +extern volatile bool sdt_probes_enabled; + #ifndef KDTRACE_HOOKS #define SDT_PROVIDER_DEFINE(prov) #define SDT_PROVIDER_DECLARE(prov) #define SDT_PROBE_DEFINE(prov, mod, func, name) #define SDT_PROBE_DECLARE(prov, mod, func, name) -#define SDT_PROBE_ENABLED(prov, mod, func, name) 0 #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype) @@ -161,14 +162,13 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); #define SDT_PROBE_DECLARE(prov, mod, func, name) \ extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1] -#define SDT_PROBE_ENABLED(prov, mod, func, name) \ - __predict_false((sdt_##prov##_##mod##_##func##_##name->id)) - #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \ - if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \ + if (__predict_false(sdt_probes_enabled)) { \ + if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \ (*sdt_probe_func)(sdt_##prov##_##mod##_##func##_##name->id, \ (uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \ (uintptr_t) arg3, (uintptr_t) arg4); \ + } \ } while (0) #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype) \ From owner-svn-src-stable-11@freebsd.org Tue Jan 2 00:14:47 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FD31EA473B; Tue, 2 Jan 2018 00:14:47 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A35D64B93; Tue, 2 Jan 2018 00:14:47 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w020EkUX029917; Tue, 2 Jan 2018 00:14:46 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w020EkU3029916; Tue, 2 Jan 2018 00:14:46 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201801020014.w020EkU3029916@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 2 Jan 2018 00:14:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327481 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 327481 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 00:14:47 -0000 Author: mjg Date: Tue Jan 2 00:14:46 2018 New Revision: 327481 URL: https://svnweb.freebsd.org/changeset/base/327481 Log: MFC r325924: sched: move panic handling code out of choosethread This avoids jumps in the common case of the kernel not being panicked. Modified: stable/11/sys/kern/kern_switch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_switch.c ============================================================================== --- stable/11/sys/kern/kern_switch.c Tue Jan 2 00:11:56 2018 (r327480) +++ stable/11/sys/kern/kern_switch.c Tue Jan 2 00:14:46 2018 (r327481) @@ -150,24 +150,37 @@ SYSCTL_PROC(_kern_sched_stats, OID_AUTO, reset, CTLTYP /* * Select the thread that will be run next. */ -struct thread * -choosethread(void) + +static __noinline struct thread * +choosethread_panic(struct thread *td) { - struct thread *td; -retry: - td = sched_choose(); - /* * If we are in panic, only allow system threads, * plus the one we are running in, to be run. */ - if (panicstr && ((td->td_proc->p_flag & P_SYSTEM) == 0 && +retry: + if (((td->td_proc->p_flag & P_SYSTEM) == 0 && (td->td_flags & TDF_INPANIC) == 0)) { /* note that it is no longer on the run queue */ TD_SET_CAN_RUN(td); + td = sched_choose(); goto retry; } + + TD_SET_RUNNING(td); + return (td); +} + +struct thread * +choosethread(void) +{ + struct thread *td; + + td = sched_choose(); + + if (__predict_false(panicstr != NULL)) + return (choosethread_panic(td)); TD_SET_RUNNING(td); return (td); From owner-svn-src-stable-11@freebsd.org Tue Jan 2 16:14:37 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6CFDEAD026; Tue, 2 Jan 2018 16:14:37 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE15267183; Tue, 2 Jan 2018 16:14:37 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w02GEagD038158; Tue, 2 Jan 2018 16:14:36 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w02GEalR038157; Tue, 2 Jan 2018 16:14:36 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801021614.w02GEalR038157@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 2 Jan 2018 16:14:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327491 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 327491 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 16:14:38 -0000 Author: markj Date: Tue Jan 2 16:14:36 2018 New Revision: 327491 URL: https://svnweb.freebsd.org/changeset/base/327491 Log: MFC r326919: Unregister the ARC lowmem event handler earlier in arc_fini(). Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Jan 2 14:54:54 2018 (r327490) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Jan 2 16:14:36 2018 (r327491) @@ -6619,6 +6619,11 @@ arc_init(void) void arc_fini(void) { +#ifdef _KERNEL + if (arc_event_lowmem != NULL) + EVENTHANDLER_DEREGISTER(vm_lowmem, arc_event_lowmem); +#endif + mutex_enter(&arc_reclaim_lock); arc_reclaim_thread_exit = B_TRUE; /* @@ -6664,11 +6669,6 @@ arc_fini(void) buf_fini(); ASSERT0(arc_loaned_bytes); - -#ifdef _KERNEL - if (arc_event_lowmem != NULL) - EVENTHANDLER_DEREGISTER(vm_lowmem, arc_event_lowmem); -#endif } /* From owner-svn-src-stable-11@freebsd.org Tue Jan 2 16:15:25 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1E7CEAD0CB; Tue, 2 Jan 2018 16:15:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BAE9567303; Tue, 2 Jan 2018 16:15:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w02GFOvx038252; Tue, 2 Jan 2018 16:15:24 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w02GFOmK038250; Tue, 2 Jan 2018 16:15:24 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801021615.w02GFOmK038250@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 2 Jan 2018 16:15:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327492 - in stable/11/sys/cddl/dev/dtrace: amd64 i386 X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/sys/cddl/dev/dtrace: amd64 i386 X-SVN-Commit-Revision: 327492 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 16:15:26 -0000 Author: markj Date: Tue Jan 2 16:15:24 2018 New Revision: 327492 URL: https://svnweb.freebsd.org/changeset/base/327492 Log: MFC r326935: Avoid CPU migration in dtrace_gethrtime() on x86. Modified: stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c stable/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c ============================================================================== --- stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Tue Jan 2 16:14:36 2018 (r327491) +++ stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Tue Jan 2 16:15:24 2018 (r327492) @@ -353,11 +353,11 @@ SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_AN * Returns nanoseconds since boot. */ uint64_t -dtrace_gethrtime() +dtrace_gethrtime(void) { uint64_t tsc; - uint32_t lo; - uint32_t hi; + uint32_t lo, hi; + register_t rflags; /* * We split TSC value into lower and higher 32-bit halves and separately @@ -365,7 +365,10 @@ dtrace_gethrtime() * (see nsec_scale calculations) taking into account 32-bit shift of * the higher half and finally add. */ + rflags = intr_disable(); tsc = rdtsc() - tsc_skew[curcpu]; + intr_restore(rflags); + lo = tsc; hi = tsc >> 32; return (((lo * nsec_scale) >> SCALE_SHIFT) + Modified: stable/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c ============================================================================== --- stable/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c Tue Jan 2 16:14:36 2018 (r327491) +++ stable/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c Tue Jan 2 16:15:24 2018 (r327492) @@ -355,11 +355,11 @@ SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_AN * Returns nanoseconds since boot. */ uint64_t -dtrace_gethrtime() +dtrace_gethrtime(void) { uint64_t tsc; - uint32_t lo; - uint32_t hi; + uint32_t lo, hi; + register_t eflags; /* * We split TSC value into lower and higher 32-bit halves and separately @@ -367,7 +367,10 @@ dtrace_gethrtime() * (see nsec_scale calculations) taking into account 32-bit shift of * the higher half and finally add. */ + eflags = intr_disable(); tsc = rdtsc() - tsc_skew[curcpu]; + intr_restore(eflags); + lo = tsc; hi = tsc >> 32; return (((lo * nsec_scale) >> SCALE_SHIFT) + From owner-svn-src-stable-11@freebsd.org Tue Jan 2 16:19:43 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43C31EAD3C8; Tue, 2 Jan 2018 16:19:43 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EE6D867705; Tue, 2 Jan 2018 16:19:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w02GJglE038703; Tue, 2 Jan 2018 16:19:42 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w02GJfBM038701; Tue, 2 Jan 2018 16:19:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801021619.w02GJfBM038701@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 2 Jan 2018 16:19:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327493 - stable/11/sys/geom/mirror X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/geom/mirror X-SVN-Commit-Revision: 327493 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 16:19:43 -0000 Author: markj Date: Tue Jan 2 16:19:41 2018 New Revision: 327493 URL: https://svnweb.freebsd.org/changeset/base/327493 Log: MFC r326983: Avoid using bioq_* in gmirror. Modified: stable/11/sys/geom/mirror/g_mirror.c stable/11/sys/geom/mirror/g_mirror.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/11/sys/geom/mirror/g_mirror.c Tue Jan 2 16:15:24 2018 (r327492) +++ stable/11/sys/geom/mirror/g_mirror.c Tue Jan 2 16:19:41 2018 (r327493) @@ -305,7 +305,7 @@ g_mirror_nrequests(struct g_mirror_softc *sc, struct g u_int nreqs = 0; mtx_lock(&sc->sc_queue_mtx); - TAILQ_FOREACH(bp, &sc->sc_queue.queue, bio_queue) { + TAILQ_FOREACH(bp, &sc->sc_queue, bio_queue) { if (bp->bio_from == cp) nreqs++; } @@ -918,7 +918,7 @@ g_mirror_done(struct bio *bp) sc = bp->bio_from->geom->softc; bp->bio_cflags = G_MIRROR_BIO_FLAG_REGULAR; mtx_lock(&sc->sc_queue_mtx); - bioq_insert_tail(&sc->sc_queue, bp); + TAILQ_INSERT_TAIL(&sc->sc_queue, bp, bio_queue); mtx_unlock(&sc->sc_queue_mtx); wakeup(sc); } @@ -963,7 +963,7 @@ g_mirror_regular_request(struct bio *bp) pbp->bio_completed = pbp->bio_length; if (pbp->bio_cmd == BIO_WRITE || pbp->bio_cmd == BIO_DELETE) { - bioq_remove(&sc->sc_inflight, pbp); + TAILQ_REMOVE(&sc->sc_inflight, pbp, bio_queue); /* Release delayed sync requests if possible. */ g_mirror_sync_release(sc); } @@ -1018,7 +1018,7 @@ g_mirror_regular_request(struct bio *bp) else { pbp->bio_error = 0; mtx_lock(&sc->sc_queue_mtx); - bioq_insert_tail(&sc->sc_queue, pbp); + TAILQ_INSERT_TAIL(&sc->sc_queue, pbp, bio_queue); mtx_unlock(&sc->sc_queue_mtx); G_MIRROR_DEBUG(4, "%s: Waking up %p.", __func__, sc); wakeup(sc); @@ -1038,7 +1038,7 @@ g_mirror_regular_request(struct bio *bp) pbp->bio_error = 0; pbp->bio_completed = pbp->bio_length; } - bioq_remove(&sc->sc_inflight, pbp); + TAILQ_REMOVE(&sc->sc_inflight, pbp, bio_queue); /* Release delayed sync requests if possible. */ g_mirror_sync_release(sc); g_io_deliver(pbp, pbp->bio_error); @@ -1058,7 +1058,7 @@ g_mirror_sync_done(struct bio *bp) sc = bp->bio_from->geom->softc; bp->bio_cflags = G_MIRROR_BIO_FLAG_SYNC; mtx_lock(&sc->sc_queue_mtx); - bioq_insert_tail(&sc->sc_queue, bp); + TAILQ_INSERT_TAIL(&sc->sc_queue, bp, bio_queue); mtx_unlock(&sc->sc_queue_mtx); wakeup(sc); } @@ -1115,30 +1115,33 @@ g_mirror_kernel_dump(struct bio *bp) static void g_mirror_flush(struct g_mirror_softc *sc, struct bio *bp) { - struct bio_queue_head queue; + struct bio_queue queue; struct g_mirror_disk *disk; struct g_consumer *cp; struct bio *cbp; - bioq_init(&queue); + TAILQ_INIT(&queue); LIST_FOREACH(disk, &sc->sc_disks, d_next) { if (disk->d_state != G_MIRROR_DISK_STATE_ACTIVE) continue; cbp = g_clone_bio(bp); if (cbp == NULL) { - while ((cbp = bioq_takefirst(&queue)) != NULL) + while ((cbp = TAILQ_FIRST(&queue)) != NULL) { + TAILQ_REMOVE(&queue, cbp, bio_queue); g_destroy_bio(cbp); + } if (bp->bio_error == 0) bp->bio_error = ENOMEM; g_io_deliver(bp, bp->bio_error); return; } - bioq_insert_tail(&queue, cbp); + TAILQ_INSERT_TAIL(&queue, cbp, bio_queue); cbp->bio_done = g_mirror_flush_done; cbp->bio_caller1 = disk; cbp->bio_to = disk->d_consumer->provider; } - while ((cbp = bioq_takefirst(&queue)) != NULL) { + while ((cbp = TAILQ_FIRST(&queue)) != NULL) { + TAILQ_REMOVE(&queue, cbp, bio_queue); G_MIRROR_LOGREQ(3, cbp, "Sending request."); disk = cbp->bio_caller1; cbp->bio_caller1 = NULL; @@ -1192,7 +1195,7 @@ g_mirror_start(struct bio *bp) g_io_deliver(bp, bp->bio_to->error); return; } - bioq_insert_tail(&sc->sc_queue, bp); + TAILQ_INSERT_TAIL(&sc->sc_queue, bp, bio_queue); mtx_unlock(&sc->sc_queue_mtx); G_MIRROR_DEBUG(4, "%s: Waking up %p.", __func__, sc); wakeup(sc); @@ -1244,7 +1247,7 @@ g_mirror_regular_collision(struct g_mirror_softc *sc, return (false); sstart = sbp->bio_offset; send = sbp->bio_offset + sbp->bio_length; - TAILQ_FOREACH(bp, &sc->sc_inflight.queue, bio_queue) { + TAILQ_FOREACH(bp, &sc->sc_inflight, bio_queue) { rstart = bp->bio_offset; rend = bp->bio_offset + bp->bio_length; if (rend > sstart && rstart < send) @@ -1261,7 +1264,7 @@ g_mirror_regular_delay(struct g_mirror_softc *sc, stru { G_MIRROR_LOGREQ(2, bp, "Delaying request."); - bioq_insert_head(&sc->sc_regular_delayed, bp); + TAILQ_INSERT_HEAD(&sc->sc_regular_delayed, bp, bio_queue); } /* @@ -1272,7 +1275,7 @@ g_mirror_sync_delay(struct g_mirror_softc *sc, struct { G_MIRROR_LOGREQ(2, bp, "Delaying synchronization request."); - bioq_insert_tail(&sc->sc_sync_delayed, bp); + TAILQ_INSERT_TAIL(&sc->sc_sync_delayed, bp, bio_queue); } /* @@ -1284,13 +1287,13 @@ g_mirror_regular_release(struct g_mirror_softc *sc) { struct bio *bp, *bp2; - TAILQ_FOREACH_SAFE(bp, &sc->sc_regular_delayed.queue, bio_queue, bp2) { + TAILQ_FOREACH_SAFE(bp, &sc->sc_regular_delayed, bio_queue, bp2) { if (g_mirror_sync_collision(sc, bp)) continue; - bioq_remove(&sc->sc_regular_delayed, bp); + TAILQ_REMOVE(&sc->sc_regular_delayed, bp, bio_queue); G_MIRROR_LOGREQ(2, bp, "Releasing delayed request (%p).", bp); mtx_lock(&sc->sc_queue_mtx); - bioq_insert_head(&sc->sc_queue, bp); + TAILQ_INSERT_HEAD(&sc->sc_queue, bp, bio_queue); mtx_unlock(&sc->sc_queue_mtx); } } @@ -1304,10 +1307,10 @@ g_mirror_sync_release(struct g_mirror_softc *sc) { struct bio *bp, *bp2; - TAILQ_FOREACH_SAFE(bp, &sc->sc_sync_delayed.queue, bio_queue, bp2) { + TAILQ_FOREACH_SAFE(bp, &sc->sc_sync_delayed, bio_queue, bp2) { if (g_mirror_regular_collision(sc, bp)) continue; - bioq_remove(&sc->sc_sync_delayed, bp); + TAILQ_REMOVE(&sc->sc_sync_delayed, bp, bio_queue); G_MIRROR_LOGREQ(2, bp, "Releasing delayed synchronization request."); g_io_request(bp, bp->bio_from); @@ -1613,7 +1616,7 @@ g_mirror_request_load(struct g_mirror_softc *sc, struc static void g_mirror_request_split(struct g_mirror_softc *sc, struct bio *bp) { - struct bio_queue_head queue; + struct bio_queue queue; struct g_mirror_disk *disk; struct g_consumer *cp; struct bio *cbp; @@ -1637,20 +1640,22 @@ g_mirror_request_split(struct g_mirror_softc *sc, stru left = bp->bio_length; offset = bp->bio_offset; data = bp->bio_data; - bioq_init(&queue); + TAILQ_INIT(&queue); LIST_FOREACH(disk, &sc->sc_disks, d_next) { if (disk->d_state != G_MIRROR_DISK_STATE_ACTIVE) continue; cbp = g_clone_bio(bp); if (cbp == NULL) { - while ((cbp = bioq_takefirst(&queue)) != NULL) + while ((cbp = TAILQ_FIRST(&queue)) != NULL) { + TAILQ_REMOVE(&queue, cbp, bio_queue); g_destroy_bio(cbp); + } if (bp->bio_error == 0) bp->bio_error = ENOMEM; g_io_deliver(bp, bp->bio_error); return; } - bioq_insert_tail(&queue, cbp); + TAILQ_INSERT_TAIL(&queue, cbp, bio_queue); cbp->bio_done = g_mirror_done; cbp->bio_caller1 = disk; cbp->bio_to = disk->d_consumer->provider; @@ -1663,7 +1668,8 @@ g_mirror_request_split(struct g_mirror_softc *sc, stru offset += cbp->bio_length; data += cbp->bio_length; } - while ((cbp = bioq_takefirst(&queue)) != NULL) { + while ((cbp = TAILQ_FIRST(&queue)) != NULL) { + TAILQ_REMOVE(&queue, cbp, bio_queue); G_MIRROR_LOGREQ(3, cbp, "Sending request."); disk = cbp->bio_caller1; cbp->bio_caller1 = NULL; @@ -1702,9 +1708,9 @@ g_mirror_register_request(struct bio *bp) case BIO_WRITE: case BIO_DELETE: { + struct bio_queue queue; struct g_mirror_disk *disk; struct g_mirror_disk_sync *sync; - struct bio_queue_head queue; struct g_consumer *cp; struct bio *cbp; @@ -1734,7 +1740,7 @@ g_mirror_register_request(struct bio *bp) * Allocate all bios before sending any request, so we can * return ENOMEM in nice and clean way. */ - bioq_init(&queue); + TAILQ_INIT(&queue); LIST_FOREACH(disk, &sc->sc_disks, d_next) { sync = &disk->d_sync; switch (disk->d_state) { @@ -1752,14 +1758,16 @@ g_mirror_register_request(struct bio *bp) continue; cbp = g_clone_bio(bp); if (cbp == NULL) { - while ((cbp = bioq_takefirst(&queue)) != NULL) + while ((cbp = TAILQ_FIRST(&queue)) != NULL) { + TAILQ_REMOVE(&queue, cbp, bio_queue); g_destroy_bio(cbp); + } if (bp->bio_error == 0) bp->bio_error = ENOMEM; g_io_deliver(bp, bp->bio_error); return; } - bioq_insert_tail(&queue, cbp); + TAILQ_INSERT_TAIL(&queue, cbp, bio_queue); cbp->bio_done = g_mirror_done; cp = disk->d_consumer; cbp->bio_caller1 = cp; @@ -1768,12 +1776,13 @@ g_mirror_register_request(struct bio *bp) ("Consumer %s not opened (r%dw%de%d).", cp->provider->name, cp->acr, cp->acw, cp->ace)); } - if (bioq_first(&queue) == NULL) { + if (TAILQ_EMPTY(&queue)) { g_io_deliver(bp, EOPNOTSUPP); return; } - while ((cbp = bioq_takefirst(&queue)) != NULL) { + while ((cbp = TAILQ_FIRST(&queue)) != NULL) { G_MIRROR_LOGREQ(3, cbp, "Sending request."); + TAILQ_REMOVE(&queue, cbp, bio_queue); cp = cbp->bio_caller1; cbp->bio_caller1 = NULL; cp->index++; @@ -1784,7 +1793,7 @@ g_mirror_register_request(struct bio *bp) * Put request onto inflight queue, so we can check if new * synchronization requests don't collide with it. */ - bioq_insert_tail(&sc->sc_inflight, bp); + TAILQ_INSERT_TAIL(&sc->sc_inflight, bp, bio_queue); return; } default: @@ -1927,8 +1936,10 @@ g_mirror_worker(void *arg) */ /* Get first request from the queue. */ mtx_lock(&sc->sc_queue_mtx); - bp = bioq_takefirst(&sc->sc_queue); - if (bp == NULL) { + bp = TAILQ_FIRST(&sc->sc_queue); + if (bp != NULL) + TAILQ_REMOVE(&sc->sc_queue, bp, bio_queue); + else { if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROY) != 0) { mtx_unlock(&sc->sc_queue_mtx); @@ -1938,7 +1949,7 @@ g_mirror_worker(void *arg) kproc_exit(0); } mtx_lock(&sc->sc_queue_mtx); - if (bioq_first(&sc->sc_queue) != NULL) { + if (!TAILQ_EMPTY(&sc->sc_queue)) { mtx_unlock(&sc->sc_queue_mtx); continue; } @@ -2188,7 +2199,8 @@ g_mirror_destroy_provider(struct g_mirror_softc *sc) g_topology_lock(); g_error_provider(sc->sc_provider, ENXIO); mtx_lock(&sc->sc_queue_mtx); - while ((bp = bioq_takefirst(&sc->sc_queue)) != NULL) { + while ((bp = TAILQ_FIRST(&sc->sc_queue)) != NULL) { + TAILQ_REMOVE(&sc->sc_queue, bp, bio_queue); /* * Abort any pending I/O that wasn't generated by us. * Synchronization requests and requests destined for individual @@ -3007,11 +3019,11 @@ g_mirror_create(struct g_class *mp, const struct g_mir sc->sc_writes = 0; sc->sc_refcnt = 1; sx_init(&sc->sc_lock, "gmirror:lock"); - bioq_init(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); mtx_init(&sc->sc_queue_mtx, "gmirror:queue", NULL, MTX_DEF); - bioq_init(&sc->sc_regular_delayed); - bioq_init(&sc->sc_inflight); - bioq_init(&sc->sc_sync_delayed); + TAILQ_INIT(&sc->sc_regular_delayed); + TAILQ_INIT(&sc->sc_inflight); + TAILQ_INIT(&sc->sc_sync_delayed); LIST_INIT(&sc->sc_disks); TAILQ_INIT(&sc->sc_events); mtx_init(&sc->sc_events_mtx, "gmirror:events", NULL, MTX_DEF); Modified: stable/11/sys/geom/mirror/g_mirror.h ============================================================================== --- stable/11/sys/geom/mirror/g_mirror.h Tue Jan 2 16:15:24 2018 (r327492) +++ stable/11/sys/geom/mirror/g_mirror.h Tue Jan 2 16:19:41 2018 (r327493) @@ -191,17 +191,14 @@ struct g_mirror_softc { uint32_t sc_id; /* Mirror unique ID. */ struct sx sc_lock; - struct bio_queue_head sc_queue; + struct bio_queue sc_queue; struct mtx sc_queue_mtx; struct proc *sc_worker; - struct bio_queue_head sc_regular_delayed; /* Delayed I/O requests due - collision with sync - requests. */ - struct bio_queue_head sc_inflight; /* In-flight regular write - requests. */ - struct bio_queue_head sc_sync_delayed; /* Delayed sync requests due - collision with regular - requests. */ + struct bio_queue sc_inflight; /* In-flight regular write requests. */ + struct bio_queue sc_regular_delayed; /* Delayed I/O requests due to + collision with sync requests. */ + struct bio_queue sc_sync_delayed; /* Delayed sync requests due to + collision with regular requests. */ LIST_HEAD(, g_mirror_disk) sc_disks; u_int sc_ndisks; /* Number of disks. */ From owner-svn-src-stable-11@freebsd.org Tue Jan 2 19:17:58 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 184D9EB461C; Tue, 2 Jan 2018 19:17:58 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7EAD6E325; Tue, 2 Jan 2018 19:17:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (astound-66-234-202-155.ca.astound.net [66.234.202.155]) by mail.baldwin.cx (Postfix) with ESMTPSA id E1C4C10AFC8; Tue, 2 Jan 2018 14:17:56 -0500 (EST) From: John Baldwin To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r327414 - stable/11 Date: Tue, 02 Jan 2018 09:48:27 -0800 Message-ID: <13482268.SAk0YaOX8x@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <201712310514.vBV5EeXT041948@repo.freebsd.org> References: <201712310514.vBV5EeXT041948@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 02 Jan 2018 14:17:57 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 19:17:58 -0000 On Sunday, December 31, 2017 05:14:40 AM Mateusz Guzik wrote: > Author: mjg > Date: Sun Dec 31 05:14:40 2017 > New Revision: 327414 > URL: https://svnweb.freebsd.org/changeset/base/327414 > > Log: > MFC r324328: > > amd64: remove unused variable from pmap_delayed_invl_genp > > Modified: > Directory Properties: > stable/11/ (props changed) Was this already MFC'd and this commit only updated mergeinfo on purpose? -- John Baldwin From owner-svn-src-stable-11@freebsd.org Tue Jan 2 19:49:45 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0A93EEB5B48; Tue, 2 Jan 2018 19:49:45 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D5F916FA70; Tue, 2 Jan 2018 19:49:44 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w02JnZeF092779; Tue, 2 Jan 2018 11:49:35 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w02JnZO2092778; Tue, 2 Jan 2018 11:49:35 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201801021949.w02JnZO2092778@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r327414 - stable/11 In-Reply-To: <13482268.SAk0YaOX8x@ralph.baldwin.cx> To: John Baldwin Date: Tue, 2 Jan 2018 11:49:35 -0800 (PST) CC: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 19:49:45 -0000 > On Sunday, December 31, 2017 05:14:40 AM Mateusz Guzik wrote: > > Author: mjg > > Date: Sun Dec 31 05:14:40 2017 > > New Revision: 327414 > > URL: https://svnweb.freebsd.org/changeset/base/327414 > > > > Log: > > MFC r324328: > > > > amd64: remove unused variable from pmap_delayed_invl_genp > > > > Modified: > > Directory Properties: > > stable/11/ (props changed) > > Was this already MFC'd and this commit only updated mergeinfo on purpose? I sent a similiar query shortly after commit and have no reply. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-stable-11@freebsd.org Tue Jan 2 20:22:32 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E323EB77AC; Tue, 2 Jan 2018 20:22:32 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B45971656; Tue, 2 Jan 2018 20:22:32 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w02KMVRH044812; Tue, 2 Jan 2018 20:22:31 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w02KMVUZ044811; Tue, 2 Jan 2018 20:22:31 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201801022022.w02KMVUZ044811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 2 Jan 2018 20:22:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327501 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 327501 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 20:22:32 -0000 Author: mjg Date: Tue Jan 2 20:22:31 2018 New Revision: 327501 URL: https://svnweb.freebsd.org/changeset/base/327501 Log: MFC r324328: amd64: remove unused variable from pmap_delayed_invl_genp This is take #2. Modified: stable/11/sys/amd64/amd64/pmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/pmap.c ============================================================================== --- stable/11/sys/amd64/amd64/pmap.c Tue Jan 2 19:34:23 2018 (r327500) +++ stable/11/sys/amd64/amd64/pmap.c Tue Jan 2 20:22:31 2018 (r327501) @@ -537,14 +537,12 @@ pmap_delayed_invl_genp(vm_page_t m) static void pmap_delayed_invl_wait(vm_page_t m) { - struct thread *td; struct turnstile *ts; u_long *m_gen; #ifdef PV_STATS bool accounted = false; #endif - td = curthread; m_gen = pmap_delayed_invl_genp(m); while (*m_gen > pmap_invl_gen) { #ifdef PV_STATS From owner-svn-src-stable-11@freebsd.org Tue Jan 2 20:24:11 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B067AEB78D2; Tue, 2 Jan 2018 20:24:11 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qt0-x243.google.com (mail-qt0-x243.google.com [IPv6:2607:f8b0:400d:c0d::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 68567717D2; Tue, 2 Jan 2018 20:24:11 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qt0-x243.google.com with SMTP id u42so64251146qte.7; Tue, 02 Jan 2018 12:24:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=gJvIjEkO9t1uRN+Y1V7hWVHaCLFfWYVWkzyYybPq6yA=; b=fIG1QQIOn35el6K0CnAnMTkhm/4mKNiWA8KkmvP3mTC6oJDGxHa5HHgjX1TisjXOh2 lUrXb57nsJnug0qGy1x8M83ej57DL1SwCtcLi91zAGrN8blxAMse2rYQ/tS2V7oXqwNv kiiJEKkGSH4BxWUWQSde1hbyBwxQ52EU9nJ6TZRUVEsZh3KYm2zg/a34fIY4d0n7GlxL Xq7SuIqu35OTInABzM7irgsUzBLKc5743hZx2Y6xGPrk3FuTSceKg8QXb5zhswsiDjGG dt+aQD+ETSDhDsgt6VZm1ecggdM88IJ+S5/6U6sQPLYP6hXfz2yx3uS/xLcN2TUn5Ukm PCTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=gJvIjEkO9t1uRN+Y1V7hWVHaCLFfWYVWkzyYybPq6yA=; b=BVsJvKdCA+TDKfRuCtxiYUCB+jqXUS4N/VG+rtCMfAZJe4Vsfk67UMuEgonhDcwdyM de+jpaPqwxkccapwXCjKJSn2PfRIEv/genwWLs94E97JbXiNPpncPDCLz6VjzZdQ2AQr ywUz6SsC8uSNMC4ei1jCAx/idIvRQyd9GHein1WvXNuN5YgFHowWw5za7LLqT7BotECx NILEy1+4HLlafAMLpK3e88oVmwzNHJZatYpLEYPEmG7Cu0vysrhYFSYRz5hS7UjVFLQ9 54hDI7tJSU8HnTjrJgwuLUHo3ud7eUWoWaMkb6P7w5eo9wBR1ckgPtp0sI7jCQTyoe6w Kvzw== X-Gm-Message-State: AKGB3mKTsRWoxrgX0wAmVRXIEttVYo5y2hWwaefYjqfAGcgPDMoSFWWb ITNWNldUm/9fMbxL87t3eHZUmZgU44P+9nnBZQwG9Q== X-Google-Smtp-Source: ACJfBouB7B4dgn61c3+0imktNqDFoiaEJEONfI/y80PsWS1WCjysgHCp+pz0a+1uXiMAtaxs8uyKm0U8HKkv5Xm6QtA= X-Received: by 10.55.76.142 with SMTP id z136mr53122619qka.332.1514924650383; Tue, 02 Jan 2018 12:24:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.44.214 with HTTP; Tue, 2 Jan 2018 12:24:09 -0800 (PST) In-Reply-To: <201801021949.w02JnZO2092778@pdx.rh.CN85.dnsmgr.net> References: <13482268.SAk0YaOX8x@ralph.baldwin.cx> <201801021949.w02JnZO2092778@pdx.rh.CN85.dnsmgr.net> From: Mateusz Guzik Date: Tue, 2 Jan 2018 21:24:09 +0100 Message-ID: Subject: Re: svn commit: r327414 - stable/11 To: rgrimes@freebsd.org Cc: John Baldwin , Mateusz Guzik , src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 20:24:11 -0000 On Tue, Jan 2, 2018 at 8:49 PM, Rodney W. Grimes < freebsd@pdx.rh.cn85.dnsmgr.net> wrote: > > On Sunday, December 31, 2017 05:14:40 AM Mateusz Guzik wrote: > > > Author: mjg > > > Date: Sun Dec 31 05:14:40 2017 > > > New Revision: 327414 > > > URL: https://svnweb.freebsd.org/changeset/base/327414 > > > > > > Log: > > > MFC r324328: > > > > > > amd64: remove unused variable from pmap_delayed_invl_genp > > > > > > Modified: > > > Directory Properties: > > > stable/11/ (props changed) > > > > Was this already MFC'd and this commit only updated mergeinfo on purpose? > > I sent a similiar query shortly after commit and have no reply. > Weird, I have no idea what happened to that one. I mfced again and this time it's fine: https://svnweb.freebsd.org/base?view=revision&revision=327501 -- Mateusz Guzik From owner-svn-src-stable-11@freebsd.org Wed Jan 3 11:03:45 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEFEFEB99BE; Wed, 3 Jan 2018 11:03:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7BCF76F054; Wed, 3 Jan 2018 11:03:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w03B3imY013619; Wed, 3 Jan 2018 11:03:44 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w03B3ibO013618; Wed, 3 Jan 2018 11:03:44 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801031103.w03B3ibO013618@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 3 Jan 2018 11:03:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327516 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 327516 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jan 2018 11:03:45 -0000 Author: kib Date: Wed Jan 3 11:03:44 2018 New Revision: 327516 URL: https://svnweb.freebsd.org/changeset/base/327516 Log: MFC r327437: Remove MP SAFE marks and stray register name in comments. Modified: stable/11/sys/amd64/amd64/support.S Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/support.S ============================================================================== --- stable/11/sys/amd64/amd64/support.S Wed Jan 3 09:33:59 2018 (r327515) +++ stable/11/sys/amd64/amd64/support.S Wed Jan 3 11:03:44 2018 (r327516) @@ -214,7 +214,7 @@ END(fillw) */ /* - * copyout(from_kernel, to_user, len) - MP SAFE + * copyout(from_kernel, to_user, len) * %rdi, %rsi, %rdx */ ENTRY(copyout) @@ -277,7 +277,7 @@ copyout_fault: END(copyout) /* - * copyin(from_user, to_kernel, len) - MP SAFE + * copyin(from_user, to_kernel, len) * %rdi, %rsi, %rdx */ ENTRY(copyin) @@ -494,7 +494,7 @@ fusufault: /* * Store a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit byte to - * user memory. All these functions are MPSAFE. + * user memory. * addr = %rdi, value = %rsi */ ALTENTRY(suword64) @@ -569,7 +569,7 @@ ENTRY(subyte) END(subyte) /* - * copyinstr(from, to, maxlen, int *lencopied) - MP SAFE + * copyinstr(from, to, maxlen, int *lencopied) * %rdi, %rsi, %rdx, %rcx * * copy a string from from to to, stop when a 0 character is reached. @@ -640,7 +640,7 @@ cpystrflt_x: END(copyinstr) /* - * copystr(from, to, maxlen, int *lencopied) - MP SAFE + * copystr(from, to, maxlen, int *lencopied) * %rdi, %rsi, %rdx, %rcx */ ENTRY(copystr) @@ -680,7 +680,6 @@ END(copystr) /* * Handling of special amd64 registers and descriptor tables etc - * %rdi */ /* void lgdt(struct region_descriptor *rdp); */ ENTRY(lgdt) From owner-svn-src-stable-11@freebsd.org Wed Jan 3 12:18:57 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48B72EBCADB; Wed, 3 Jan 2018 12:18:57 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1176371962; Wed, 3 Jan 2018 12:18:56 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w03CIuQB043419; Wed, 3 Jan 2018 12:18:56 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w03CIut8043418; Wed, 3 Jan 2018 12:18:56 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201801031218.w03CIut8043418@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 3 Jan 2018 12:18:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327518 - stable/11/sbin/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sbin/ipfw X-SVN-Commit-Revision: 327518 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jan 2018 12:18:57 -0000 Author: ae Date: Wed Jan 3 12:18:55 2018 New Revision: 327518 URL: https://svnweb.freebsd.org/changeset/base/327518 Log: MFC r327140: Fix rule number truncation, use uint16_t type to specify rulenum. Also sort variable declartions by size. PR: 224555 Modified: stable/11/sbin/ipfw/ipfw2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ipfw/ipfw2.c ============================================================================== --- stable/11/sbin/ipfw/ipfw2.c Wed Jan 3 11:23:47 2018 (r327517) +++ stable/11/sbin/ipfw/ipfw2.c Wed Jan 3 12:18:55 2018 (r327518) @@ -2250,12 +2250,13 @@ do_range_cmd(int cmd, ipfw_range_tlv *rt) void ipfw_sets_handler(char *av[]) { - uint32_t masks[2]; - int i; - uint8_t cmd, rulenum; ipfw_range_tlv rt; char *msg; size_t size; + uint32_t masks[2]; + int i; + uint16_t rulenum; + uint8_t cmd; av++; memset(&rt, 0, sizeof(rt)); From owner-svn-src-stable-11@freebsd.org Wed Jan 3 15:01:33 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C0D5E811E7; Wed, 3 Jan 2018 15:01:33 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA57676DAD; Wed, 3 Jan 2018 15:01:32 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w03F1VOb013231; Wed, 3 Jan 2018 15:01:31 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w03F1Voq013230; Wed, 3 Jan 2018 15:01:31 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201801031501.w03F1Voq013230@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Wed, 3 Jan 2018 15:01:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327519 - stable/11/sys/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: smh X-SVN-Commit-Paths: stable/11/sys/netinet X-SVN-Commit-Revision: 327519 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jan 2018 15:01:33 -0000 Author: smh Date: Wed Jan 3 15:01:31 2018 New Revision: 327519 URL: https://svnweb.freebsd.org/changeset/base/327519 Log: MFC r322812: Avoid TCP log messages which are false positives. Sponsored by: Multiplay Modified: stable/11/sys/netinet/tcp_input.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_input.c ============================================================================== --- stable/11/sys/netinet/tcp_input.c Wed Jan 3 12:18:55 2018 (r327518) +++ stable/11/sys/netinet/tcp_input.c Wed Jan 3 15:01:31 2018 (r327519) @@ -1686,25 +1686,6 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru to.to_tsecr = 0; } /* - * If timestamps were negotiated during SYN/ACK they should - * appear on every segment during this session and vice versa. - */ - if ((tp->t_flags & TF_RCVD_TSTMP) && !(to.to_flags & TOF_TS)) { - if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { - log(LOG_DEBUG, "%s; %s: Timestamp missing, " - "no action\n", s, __func__); - free(s, M_TCPLOG); - } - } - if (!(tp->t_flags & TF_RCVD_TSTMP) && (to.to_flags & TOF_TS)) { - if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { - log(LOG_DEBUG, "%s; %s: Timestamp not expected, " - "no action\n", s, __func__); - free(s, M_TCPLOG); - } - } - - /* * Process options only when we get SYN/ACK back. The SYN case * for incoming connections is handled in tcp_syncache. * According to RFC1323 the window field in a SYN (i.e., a @@ -1732,6 +1713,25 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru if ((tp->t_flags & TF_SACK_PERMIT) && (to.to_flags & TOF_SACKPERM) == 0) tp->t_flags &= ~TF_SACK_PERMIT; + } + + /* + * If timestamps were negotiated during SYN/ACK they should + * appear on every segment during this session and vice versa. + */ + if ((tp->t_flags & TF_RCVD_TSTMP) && !(to.to_flags & TOF_TS)) { + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { + log(LOG_DEBUG, "%s; %s: Timestamp missing, " + "no action\n", s, __func__); + free(s, M_TCPLOG); + } + } + if (!(tp->t_flags & TF_RCVD_TSTMP) && (to.to_flags & TOF_TS)) { + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { + log(LOG_DEBUG, "%s; %s: Timestamp not expected, " + "no action\n", s, __func__); + free(s, M_TCPLOG); + } } /* From owner-svn-src-stable-11@freebsd.org Thu Jan 4 11:36:15 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66F7CEABDCA; Thu, 4 Jan 2018 11:36:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31363649C6; Thu, 4 Jan 2018 11:36:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04BaECF033396; Thu, 4 Jan 2018 11:36:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04BaE9i033394; Thu, 4 Jan 2018 11:36:14 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801041136.w04BaE9i033394@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 4 Jan 2018 11:36:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327542 - stable/11/usr.sbin/cpucontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/usr.sbin/cpucontrol X-SVN-Commit-Revision: 327542 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:36:15 -0000 Author: kib Date: Thu Jan 4 11:36:13 2018 New Revision: 327542 URL: https://svnweb.freebsd.org/changeset/base/327542 Log: MFC r327264i (by imp), r327283: Fix returns without cleanups. Modified: stable/11/usr.sbin/cpucontrol/intel.c stable/11/usr.sbin/cpucontrol/via.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/cpucontrol/intel.c ============================================================================== --- stable/11/usr.sbin/cpucontrol/intel.c Thu Jan 4 08:23:23 2018 (r327541) +++ stable/11/usr.sbin/cpucontrol/intel.c Thu Jan 4 11:36:13 2018 (r327542) @@ -145,7 +145,7 @@ intel_update(const char *dev, const char *path) fd = open(path, O_RDONLY, 0); if (fd < 0) { WARN(0, "open(%s)", path); - return; + goto fail; } error = fstat(fd, &st); if (error != 0) { @@ -259,7 +259,7 @@ matched: if (revision >= fw_header->revision) { WARNX(1, "skipping %s of rev %#x: up to date", path, fw_header->revision); - return; + goto fail; } fprintf(stderr, "%s: updating cpu %s from rev %#x to rev %#x... ", path, dev, revision, fw_header->revision); Modified: stable/11/usr.sbin/cpucontrol/via.c ============================================================================== --- stable/11/usr.sbin/cpucontrol/via.c Thu Jan 4 08:23:23 2018 (r327541) +++ stable/11/usr.sbin/cpucontrol/via.c Thu Jan 4 11:36:13 2018 (r327542) @@ -138,7 +138,7 @@ via_update(const char *dev, const char *path) fd = open(path, O_RDONLY, 0); if (fd < 0) { WARN(0, "open(%s)", path); - return; + goto fail; } error = fstat(fd, &st); if (error != 0) { From owner-svn-src-stable-11@freebsd.org Thu Jan 4 11:38:43 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C481EAC050; Thu, 4 Jan 2018 11:38:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3369A64B5C; Thu, 4 Jan 2018 11:38:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04BcgBO033527; Thu, 4 Jan 2018 11:38:42 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04Bcgc5033526; Thu, 4 Jan 2018 11:38:42 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801041138.w04Bcgc5033526@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 4 Jan 2018 11:38:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327543 - stable/11/usr.sbin/cpucontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/usr.sbin/cpucontrol X-SVN-Commit-Revision: 327543 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:38:43 -0000 Author: kib Date: Thu Jan 4 11:38:42 2018 New Revision: 327543 URL: https://svnweb.freebsd.org/changeset/base/327543 Log: MFC r327284: Style. Remove useless return. Modified: stable/11/usr.sbin/cpucontrol/intel.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/cpucontrol/intel.c ============================================================================== --- stable/11/usr.sbin/cpucontrol/intel.c Thu Jan 4 11:36:13 2018 (r327542) +++ stable/11/usr.sbin/cpucontrol/intel.c Thu Jan 4 11:38:42 2018 (r327543) @@ -86,7 +86,7 @@ intel_update(const char *dev, const char *path) intel_fw_header_t *fw_header; intel_cpu_signature_t *ext_table; intel_ext_header_t *ext_header; - uint32_t signature, flags; + uint32_t sig, signature, flags; int32_t revision; ssize_t ext_size; size_t ext_table_size; @@ -229,7 +229,8 @@ intel_update(const char *dev, const char *path) for (i = 0; i < (ext_table_size / sizeof(uint32_t)); i++) sum += *((uint32_t *)ext_header + i); if (sum != 0) { - WARNX(2, "%s: extended signature table checksum invalid", + WARNX(2, + "%s: extended signature table checksum invalid", path); goto no_table; } @@ -244,10 +245,10 @@ no_table: */ if (signature == fw_header->cpu_signature && (flags & fw_header->cpu_flags) != 0) - goto matched; + goto matched; else if (have_ext_table != 0) { for (i = 0; i < ext_header->sig_count; i++) { - uint32_t sig = ext_table[i].cpu_signature; + sig = ext_table[i].cpu_signature; if (signature == sig && (flags & ext_table[i].cpu_flags) != 0) goto matched; @@ -262,14 +263,14 @@ matched: goto fail; } fprintf(stderr, "%s: updating cpu %s from rev %#x to rev %#x... ", - path, dev, revision, fw_header->revision); + path, dev, revision, fw_header->revision); args.data = fw_data; args.size = data_size; error = ioctl(devfd, CPUCTL_UPDATE, &args); if (error < 0) { - error = errno; + error = errno; fprintf(stderr, "failed.\n"); - errno = error; + errno = error; WARN(0, "ioctl()"); goto fail; } @@ -283,5 +284,4 @@ fail: close(devfd); if (fd >= 0) close(fd); - return; } From owner-svn-src-stable-11@freebsd.org Thu Jan 4 11:40:23 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CCB9AEAC1F3; Thu, 4 Jan 2018 11:40:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 94D3664CD6; Thu, 4 Jan 2018 11:40:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04BeMdP033662; Thu, 4 Jan 2018 11:40:22 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04BeMNP033661; Thu, 4 Jan 2018 11:40:22 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801041140.w04BeMNP033661@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 4 Jan 2018 11:40:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327544 - stable/11/sys/x86/include X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/x86/include X-SVN-Commit-Revision: 327544 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:40:23 -0000 Author: kib Date: Thu Jan 4 11:40:22 2018 New Revision: 327544 URL: https://svnweb.freebsd.org/changeset/base/327544 Log: MFC r327469: Add CR4.SMAP control bit. Modified: stable/11/sys/x86/include/specialreg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/x86/include/specialreg.h ============================================================================== --- stable/11/sys/x86/include/specialreg.h Thu Jan 4 11:38:42 2018 (r327543) +++ stable/11/sys/x86/include/specialreg.h Thu Jan 4 11:40:22 2018 (r327544) @@ -74,6 +74,7 @@ #define CR4_PCIDE 0x00020000 /* Enable Context ID */ #define CR4_XSAVE 0x00040000 /* XSETBV/XGETBV */ #define CR4_SMEP 0x00100000 /* Supervisor-Mode Execution Prevention */ +#define CR4_SMAP 0x00200000 /* Supervisor-Mode Access Prevention */ /* * Bits in AMD64 special registers. EFER is 64 bits wide. From owner-svn-src-stable-11@freebsd.org Thu Jan 4 11:43:43 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C237EAC754; Thu, 4 Jan 2018 11:43:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4667D6524A; Thu, 4 Jan 2018 11:43:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04BhgcT038071; Thu, 4 Jan 2018 11:43:42 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04Bhgab038070; Thu, 4 Jan 2018 11:43:42 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801041143.w04Bhgab038070@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 4 Jan 2018 11:43:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327545 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 327545 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:43:43 -0000 Author: kib Date: Thu Jan 4 11:43:42 2018 New Revision: 327545 URL: https://svnweb.freebsd.org/changeset/base/327545 Log: MFC r327319: Clean up the comment. Modified: stable/11/sys/vm/vm_swapout.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_swapout.c ============================================================================== --- stable/11/sys/vm/vm_swapout.c Thu Jan 4 11:40:22 2018 (r327544) +++ stable/11/sys/vm/vm_swapout.c Thu Jan 4 11:43:42 2018 (r327545) @@ -713,8 +713,7 @@ loop: } /* - * We would like to bring someone in. (only if there is space). - * [What checks the space? ] + * We would like to bring someone in. */ faultin(p); PROC_UNLOCK(p); From owner-svn-src-stable-11@freebsd.org Thu Jan 4 11:44:59 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9DABAEAC8C8; Thu, 4 Jan 2018 11:44:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 675ED653C3; Thu, 4 Jan 2018 11:44:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04Biww0038180; Thu, 4 Jan 2018 11:44:58 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04BiwC8038179; Thu, 4 Jan 2018 11:44:58 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801041144.w04BiwC8038179@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 4 Jan 2018 11:44:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327546 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 327546 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:44:59 -0000 Author: kib Date: Thu Jan 4 11:44:58 2018 New Revision: 327546 URL: https://svnweb.freebsd.org/changeset/base/327546 Log: MFC r327316: In vm_swapout_map_deactivate_pages(), it is enough to lock the map for read. Modified: stable/11/sys/vm/vm_swapout.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_swapout.c ============================================================================== --- stable/11/sys/vm/vm_swapout.c Thu Jan 4 11:43:42 2018 (r327545) +++ stable/11/sys/vm/vm_swapout.c Thu Jan 4 11:44:58 2018 (r327546) @@ -261,7 +261,7 @@ vm_swapout_map_deactivate_pages(vm_map_t map, long des vm_object_t obj, bigobj; int nothingwired; - if (!vm_map_trylock(map)) + if (!vm_map_trylock_read(map)) return; bigobj = NULL; @@ -325,7 +325,7 @@ vm_swapout_map_deactivate_pages(vm_map_t map, long des vm_map_max(map)); } - vm_map_unlock(map); + vm_map_unlock_read(map); } /* From owner-svn-src-stable-11@freebsd.org Thu Jan 4 11:49:34 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65502EACEB7; Thu, 4 Jan 2018 11:49:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D2F1656A2; Thu, 4 Jan 2018 11:49:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04BnX0t038388; Thu, 4 Jan 2018 11:49:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04BnXCJ038386; Thu, 4 Jan 2018 11:49:33 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801041149.w04BnXCJ038386@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 4 Jan 2018 11:49:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327547 - in stable/11/sys: kern sys X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: kern sys X-SVN-Commit-Revision: 327547 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:49:34 -0000 Author: kib Date: Thu Jan 4 11:49:32 2018 New Revision: 327547 URL: https://svnweb.freebsd.org/changeset/base/327547 Log: MFC r327285: Make kern_proc_vmmap_resident() externally accesible, and move the vmmap_skip_res_cnt control check inside it. Modified: stable/11/sys/kern/kern_proc.c stable/11/sys/sys/proc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_proc.c ============================================================================== --- stable/11/sys/kern/kern_proc.c Thu Jan 4 11:44:58 2018 (r327546) +++ stable/11/sys/kern/kern_proc.c Thu Jan 4 11:49:32 2018 (r327547) @@ -2256,9 +2256,9 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS) CTASSERT(sizeof(struct kinfo_vmentry) == KINFO_VMENTRY_SIZE); #endif -static void +void kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t entry, - struct kinfo_vmentry *kve) + int *resident_count, bool *super) { vm_object_t obj, tobj; vm_page_t m, m_adv; @@ -2266,6 +2266,11 @@ kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t vm_paddr_t locked_pa; vm_pindex_t pi, pi_adv, pindex; + *super = false; + *resident_count = 0; + if (vmmap_skip_res_cnt) + return; + locked_pa = 0; obj = entry->object.vm_object; addr = entry->start; @@ -2298,7 +2303,7 @@ kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t (addr & (pagesizes[1] - 1)) == 0 && (pmap_mincore(map->pmap, addr, &locked_pa) & MINCORE_SUPER) != 0) { - kve->kve_flags |= KVME_FLAG_SUPER; + *super = true; pi_adv = atop(pagesizes[1]); } else { /* @@ -2310,7 +2315,7 @@ kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t */ pi_adv = 1; } - kve->kve_resident += pi_adv; + *resident_count += pi_adv; next:; } PA_UNLOCK_COND(locked_pa); @@ -2334,6 +2339,7 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s vm_offset_t addr; unsigned int last_timestamp; int error; + bool super; PROC_LOCK_ASSERT(p, MA_OWNED); @@ -2366,8 +2372,10 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s if (obj->backing_object == NULL) kve->kve_private_resident = obj->resident_page_count; - if (!vmmap_skip_res_cnt) - kern_proc_vmmap_resident(map, entry, kve); + kern_proc_vmmap_resident(map, entry, + &kve->kve_resident, &super); + if (super) + kve->kve_flags |= KVME_FLAG_SUPER; for (tobj = obj; tobj != NULL; tobj = tobj->backing_object) { if (tobj != obj && tobj != lobj) @@ -3077,6 +3085,7 @@ resume_all_proc(void) cp = curproc; sx_xlock(&allproc_lock); +again: LIST_REMOVE(cp, p_list); LIST_INSERT_HEAD(&allproc, cp, p_list); for (;;) { @@ -3096,6 +3105,12 @@ resume_all_proc(void) } else { PROC_UNLOCK(p); } + } + /* Did the loop above missed any stopped process ? */ + LIST_FOREACH(p, &allproc, p_list) { + /* No need for proc lock. */ + if ((p->p_flag & P_TOTAL_STOP) != 0) + goto again; } sx_xunlock(&allproc_lock); } Modified: stable/11/sys/sys/proc.h ============================================================================== --- stable/11/sys/sys/proc.h Thu Jan 4 11:44:58 2018 (r327546) +++ stable/11/sys/sys/proc.h Thu Jan 4 11:49:32 2018 (r327547) @@ -182,6 +182,8 @@ struct td_sched; struct thread; struct trapframe; struct turnstile; +struct vm_map; +struct vm_map_entry; /* * XXX: Does this belong in resource.h or resourcevar.h instead? @@ -1002,6 +1004,8 @@ void fork_exit(void (*)(void *, struct trapframe *), v struct trapframe *); void fork_return(struct thread *, struct trapframe *); int inferior(struct proc *p); +void kern_proc_vmmap_resident(struct vm_map *map, struct vm_map_entry *entry, + int *resident_count, bool *super); void kern_yield(int); void kick_proc0(void); void killjobc(void); From owner-svn-src-stable-11@freebsd.org Thu Jan 4 11:51:04 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39F91EAD052; Thu, 4 Jan 2018 11:51:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0EE146586B; Thu, 4 Jan 2018 11:51:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04Bp378039277; Thu, 4 Jan 2018 11:51:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04Bp3wt039276; Thu, 4 Jan 2018 11:51:03 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801041151.w04Bp3wt039276@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 4 Jan 2018 11:51:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327548 - stable/11/sys/fs/procfs X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/fs/procfs X-SVN-Commit-Revision: 327548 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 11:51:04 -0000 Author: kib Date: Thu Jan 4 11:51:02 2018 New Revision: 327548 URL: https://svnweb.freebsd.org/changeset/base/327548 Log: MFC r327286: Reuse kern_proc_vmmap_resident() for procfs_map resident count. Modified: stable/11/sys/fs/procfs/procfs_map.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/procfs/procfs_map.c ============================================================================== --- stable/11/sys/fs/procfs/procfs_map.c Thu Jan 4 11:49:32 2018 (r327547) +++ stable/11/sys/fs/procfs/procfs_map.c Thu Jan 4 11:51:02 2018 (r327548) @@ -82,12 +82,17 @@ procfs_doprocmap(PFS_FILL_ARGS) vm_map_t map; vm_map_entry_t entry, tmp_entry; struct vnode *vp; - char *fullpath, *freepath; + char *fullpath, *freepath, *type; struct ucred *cred; - int error; + vm_object_t obj, tobj, lobj; + int error, privateresident, ref_count, resident, shadow_count, flags; + vm_offset_t e_start, e_end; + vm_eflags_t e_eflags; + vm_prot_t e_prot; unsigned int last_timestamp; + bool super; #ifdef COMPAT_FREEBSD32 - int wrap32 = 0; + bool wrap32; #endif PROC_LOCK(p); @@ -100,11 +105,12 @@ procfs_doprocmap(PFS_FILL_ARGS) return (EOPNOTSUPP); #ifdef COMPAT_FREEBSD32 - if (SV_CURPROC_FLAG(SV_ILP32)) { - if (!(SV_PROC_FLAG(p, SV_ILP32))) - return (EOPNOTSUPP); - wrap32 = 1; - } + wrap32 = false; + if (SV_CURPROC_FLAG(SV_ILP32)) { + if (!(SV_PROC_FLAG(p, SV_ILP32))) + return (EOPNOTSUPP); + wrap32 = true; + } #endif vm = vmspace_acquire_ref(p); @@ -114,14 +120,6 @@ procfs_doprocmap(PFS_FILL_ARGS) vm_map_lock_read(map); for (entry = map->header.next; entry != &map->header; entry = entry->next) { - vm_object_t obj, tobj, lobj; - int ref_count, shadow_count, flags; - vm_offset_t e_start, e_end, addr; - int resident, privateresident; - char *type; - vm_eflags_t e_eflags; - vm_prot_t e_prot; - if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) continue; @@ -130,6 +128,7 @@ procfs_doprocmap(PFS_FILL_ARGS) e_start = entry->start; e_end = entry->end; privateresident = 0; + resident = 0; obj = entry->object.vm_object; if (obj != NULL) { VM_OBJECT_RLOCK(obj); @@ -138,20 +137,17 @@ procfs_doprocmap(PFS_FILL_ARGS) } cred = (entry->cred) ? entry->cred : (obj ? obj->cred : NULL); - resident = 0; - addr = entry->start; - while (addr < entry->end) { - if (pmap_extract(map->pmap, addr)) - resident++; - addr += PAGE_SIZE; - } - - for (lobj = tobj = obj; tobj; tobj = tobj->backing_object) { + for (lobj = tobj = obj; tobj != NULL; + tobj = tobj->backing_object) { if (tobj != obj) VM_OBJECT_RLOCK(tobj); - if (lobj != obj) - VM_OBJECT_RUNLOCK(lobj); lobj = tobj; + } + if (obj != NULL) + kern_proc_vmmap_resident(map, entry, &resident, &super); + for (tobj = obj; tobj != NULL; tobj = tobj->backing_object) { + if (tobj != obj && tobj != lobj) + VM_OBJECT_RUNLOCK(tobj); } last_timestamp = map->timestamp; vm_map_unlock_read(map); From owner-svn-src-stable-11@freebsd.org Thu Jan 4 15:55:29 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16188EBEE9E; Thu, 4 Jan 2018 15:55:29 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D2E366FD35; Thu, 4 Jan 2018 15:55:28 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04FtRbf041948; Thu, 4 Jan 2018 15:55:27 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04FtRTN041947; Thu, 4 Jan 2018 15:55:27 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801041555.w04FtRTN041947@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 4 Jan 2018 15:55:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327549 - stable/11/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/sys/netinet6 X-SVN-Commit-Revision: 327549 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 15:55:29 -0000 Author: pfg Date: Thu Jan 4 15:55:27 2018 New Revision: 327549 URL: https://svnweb.freebsd.org/changeset/base/327549 Log: MFC r327295: Start syncing changes from OpenBSD's ip6_id.c instead of ip_id.c. correct non-repetitive ID code, based on comments from niels provos. - seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x". - skipping number is not needed, so disable it for 16bit generator (makes the repetition period to 30000) Obtained from: OpenBSD (CVS rev. 1.2) Modified: stable/11/sys/netinet6/ip6_id.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/ip6_id.c ============================================================================== --- stable/11/sys/netinet6/ip6_id.c Thu Jan 4 11:51:02 2018 (r327548) +++ stable/11/sys/netinet6/ip6_id.c Thu Jan 4 15:55:27 2018 (r327549) @@ -63,7 +63,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ + * $OpenBSD: ip6_id.c,v 1.2 2003/12/10 07:21:01 itojun Exp $ */ #include @@ -230,15 +230,12 @@ static u_int32_t randomid(struct randomtab *p) { int i, n; - u_int32_t tmp; if (p->ru_counter >= p->ru_max || time_uptime > p->ru_reseed) initid(p); - tmp = arc4random(); - /* Skip a random number of ids */ - n = tmp & 0x3; tmp = tmp >> 2; + n = arc4random() & 0x3; if (p->ru_counter + n >= p->ru_max) initid(p); @@ -249,7 +246,7 @@ randomid(struct randomtab *p) p->ru_counter += i; - return (p->ru_seed ^ pmod(p->ru_g, p->ru_seed2 ^ p->ru_x, p->ru_n)) | + return (p->ru_seed ^ pmod(p->ru_g, p->ru_seed2 + p->ru_x, p->ru_n)) | p->ru_msb; } From owner-svn-src-stable-11@freebsd.org Thu Jan 4 16:17:37 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E3E7EC09C8; Thu, 4 Jan 2018 16:17:37 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A055B7136A; Thu, 4 Jan 2018 16:17:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04GHWE4050736; Thu, 4 Jan 2018 16:17:32 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04GHViu050729; Thu, 4 Jan 2018 16:17:31 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801041617.w04GHViu050729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 4 Jan 2018 16:17:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327551 - in stable/11/sys: amd64/amd64 cddl/contrib/opensolaris/uts/common/sys cddl/contrib/opensolaris/uts/intel/dtrace cddl/contrib/opensolaris/uts/powerpc/dtrace i386/i386 powerpc/p... X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 cddl/contrib/opensolaris/uts/common/sys cddl/contrib/opensolaris/uts/intel/dtrace cddl/contrib/opensolaris/uts/powerpc/dtrace i386/i386 powerpc/powerpc sys X-SVN-Commit-Revision: 327551 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 16:17:37 -0000 Author: markj Date: Thu Jan 4 16:17:31 2018 New Revision: 327551 URL: https://svnweb.freebsd.org/changeset/base/327551 Log: MFC r326774, r326811: Pass the trap frame to fasttrap hooks. Modified: stable/11/sys/amd64/amd64/trap.c stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c stable/11/sys/i386/i386/trap.c stable/11/sys/powerpc/powerpc/trap.c stable/11/sys/sys/dtrace_bsd.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/trap.c ============================================================================== --- stable/11/sys/amd64/amd64/trap.c Thu Jan 4 15:57:49 2018 (r327550) +++ stable/11/sys/amd64/amd64/trap.c Thu Jan 4 16:17:31 2018 (r327551) @@ -162,9 +162,6 @@ SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG void trap(struct trapframe *frame) { -#ifdef KDTRACE_HOOKS - struct reg regs; -#endif ksiginfo_t ksi; struct thread *td; struct proc *p; @@ -276,9 +273,8 @@ trap(struct trapframe *frame) enable_intr(); #ifdef KDTRACE_HOOKS if (type == T_BPTFLT) { - fill_frame_regs(frame, ®s); if (dtrace_pid_probe_ptr != NULL && - dtrace_pid_probe_ptr(®s) == 0) + dtrace_pid_probe_ptr(frame) == 0) return; } #endif @@ -404,9 +400,8 @@ trap(struct trapframe *frame) #ifdef KDTRACE_HOOKS case T_DTRACE_RET: enable_intr(); - fill_frame_regs(frame, ®s); if (dtrace_return_probe_ptr != NULL) - dtrace_return_probe_ptr(®s); + dtrace_return_probe_ptr(frame); return; #endif } Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h Thu Jan 4 15:57:49 2018 (r327550) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h Thu Jan 4 16:17:31 2018 (r327551) @@ -221,9 +221,9 @@ extern int fasttrap_tracepoint_init(proc_t *, fasttrap extern int fasttrap_tracepoint_install(proc_t *, fasttrap_tracepoint_t *); extern int fasttrap_tracepoint_remove(proc_t *, fasttrap_tracepoint_t *); -struct reg; -extern int fasttrap_pid_probe(struct reg *); -extern int fasttrap_return_probe(struct reg *); +struct trapframe; +extern int fasttrap_pid_probe(struct trapframe *); +extern int fasttrap_return_probe(struct trapframe *); extern uint64_t fasttrap_pid_getarg(void *, dtrace_id_t, void *, int, int); extern uint64_t fasttrap_usdt_getarg(void *, dtrace_id_t, void *, int, int); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c Thu Jan 4 15:57:49 2018 (r327550) +++ stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c Thu Jan 4 16:17:31 2018 (r327551) @@ -967,14 +967,12 @@ fasttrap_do_seg(fasttrap_tracepoint_t *tp, struct reg } int -fasttrap_pid_probe(struct reg *rp) +fasttrap_pid_probe(struct trapframe *tf) { - proc_t *p = curproc; -#ifndef illumos + struct reg reg, *rp; + proc_t *p = curproc, *pp; struct rm_priotracker tracker; - proc_t *pp; -#endif - uintptr_t pc = rp->r_rip - 1; + uintptr_t pc; uintptr_t new_pc = 0; fasttrap_bucket_t *bucket; #ifdef illumos @@ -985,6 +983,11 @@ fasttrap_pid_probe(struct reg *rp) dtrace_icookie_t cookie; uint_t is_enabled = 0; + fill_frame_regs(tf, ®); + rp = ® + + pc = rp->r_rip - 1; + /* * It's possible that a user (in a veritable orgy of bad planning) * could redirect this thread's flow of control before it reached the @@ -1796,12 +1799,16 @@ done: } int -fasttrap_return_probe(struct reg *rp) +fasttrap_return_probe(struct trapframe *tf) { + struct reg reg, *rp; proc_t *p = curproc; uintptr_t pc = curthread->t_dtrace_pc; uintptr_t npc = curthread->t_dtrace_npc; + fill_frame_regs(tf, ®); + rp = ® + curthread->t_dtrace_pc = 0; curthread->t_dtrace_npc = 0; curthread->t_dtrace_scrpc = 0; @@ -1821,9 +1828,7 @@ fasttrap_return_probe(struct reg *rp) /* * We set rp->r_rip to the address of the traced instruction so * that it appears to dtrace_probe() that we're on the original - * instruction, and so that the user can't easily detect our - * complex web of lies. dtrace_return_probe() (our caller) - * will correctly set %pc after we return. + * instruction. */ rp->r_rip = pc; Modified: stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c Thu Jan 4 15:57:49 2018 (r327550) +++ stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c Thu Jan 4 16:17:31 2018 (r327551) @@ -328,11 +328,12 @@ fasttrap_branch_taken(int bo, int bi, struct reg *regs int -fasttrap_pid_probe(struct reg *rp) +fasttrap_pid_probe(struct trapframe *frame) { + struct reg reg, *rp; struct rm_priotracker tracker; proc_t *p = curproc; - uintptr_t pc = rp->pc; + uintptr_t pc; uintptr_t new_pc = 0; fasttrap_bucket_t *bucket; fasttrap_tracepoint_t *tp, tp_local; @@ -340,6 +341,10 @@ fasttrap_pid_probe(struct reg *rp) dtrace_icookie_t cookie; uint_t is_enabled = 0; + fill_regs(curthread, ®); + rp = ® + pc = rp->pc; + /* * It's possible that a user (in a veritable orgy of bad planning) * could redirect this thread's flow of control before it reached the @@ -515,8 +520,9 @@ done: } int -fasttrap_return_probe(struct reg *rp) +fasttrap_return_probe(struct trapframe *tf) { + struct reg reg, *rp; proc_t *p = curproc; uintptr_t pc = curthread->t_dtrace_pc; uintptr_t npc = curthread->t_dtrace_npc; @@ -526,12 +532,13 @@ fasttrap_return_probe(struct reg *rp) curthread->t_dtrace_scrpc = 0; curthread->t_dtrace_astpc = 0; + fill_regs(curthread, ®); + rp = ® + /* * We set rp->pc to the address of the traced instruction so * that it appears to dtrace_probe() that we're on the original - * instruction, and so that the user can't easily detect our - * complex web of lies. dtrace_return_probe() (our caller) - * will correctly set %pc after we return. + * instruction. */ rp->pc = pc; @@ -539,4 +546,3 @@ fasttrap_return_probe(struct reg *rp) return (0); } - Modified: stable/11/sys/i386/i386/trap.c ============================================================================== --- stable/11/sys/i386/i386/trap.c Thu Jan 4 15:57:49 2018 (r327550) +++ stable/11/sys/i386/i386/trap.c Thu Jan 4 16:17:31 2018 (r327551) @@ -175,9 +175,6 @@ SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG void trap(struct trapframe *frame) { -#ifdef KDTRACE_HOOKS - struct reg regs; -#endif ksiginfo_t ksi; struct thread *td; struct proc *p; @@ -325,9 +322,8 @@ trap(struct trapframe *frame) enable_intr(); #ifdef KDTRACE_HOOKS if (type == T_BPTFLT) { - fill_frame_regs(frame, ®s); if (dtrace_pid_probe_ptr != NULL && - dtrace_pid_probe_ptr(®s) == 0) + dtrace_pid_probe_ptr(frame) == 0) return; } #endif @@ -495,9 +491,8 @@ user_trctrap_out: #ifdef KDTRACE_HOOKS case T_DTRACE_RET: enable_intr(); - fill_frame_regs(frame, ®s); if (dtrace_return_probe_ptr != NULL) - dtrace_return_probe_ptr(®s); + dtrace_return_probe_ptr(frame); return; #endif } Modified: stable/11/sys/powerpc/powerpc/trap.c ============================================================================== --- stable/11/sys/powerpc/powerpc/trap.c Thu Jan 4 15:57:49 2018 (r327550) +++ stable/11/sys/powerpc/powerpc/trap.c Thu Jan 4 16:17:31 2018 (r327551) @@ -299,9 +299,7 @@ trap(struct trapframe *frame) inst = fuword32((const void *)frame->srr0); if (inst == 0x0FFFDDDD && dtrace_pid_probe_ptr != NULL) { - struct reg regs; - fill_regs(td, ®s); - (*dtrace_pid_probe_ptr)(®s); + (*dtrace_pid_probe_ptr)(frame); break; } #endif Modified: stable/11/sys/sys/dtrace_bsd.h ============================================================================== --- stable/11/sys/sys/dtrace_bsd.h Thu Jan 4 15:57:49 2018 (r327550) +++ stable/11/sys/sys/dtrace_bsd.h Thu Jan 4 16:17:31 2018 (r327551) @@ -37,7 +37,6 @@ struct trapframe; struct thread; struct vattr; struct vnode; -struct reg; int dtrace_trap(struct trapframe *, u_int); @@ -58,9 +57,9 @@ typedef void (*dtrace_doubletrap_func_t)(void); extern dtrace_doubletrap_func_t dtrace_doubletrap_func; /* Pid provider hooks */ -typedef int (*dtrace_pid_probe_ptr_t)(struct reg *); +typedef int (*dtrace_pid_probe_ptr_t)(struct trapframe *); extern dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr; -typedef int (*dtrace_return_probe_ptr_t)(struct reg *); +typedef int (*dtrace_return_probe_ptr_t)(struct trapframe *); extern dtrace_return_probe_ptr_t dtrace_return_probe_ptr; /* Virtual time hook function type. */ From owner-svn-src-stable-11@freebsd.org Thu Jan 4 16:18:31 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D84DCEC0C21; Thu, 4 Jan 2018 16:18:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A1D8871604; Thu, 4 Jan 2018 16:18:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04GIUPc050826; Thu, 4 Jan 2018 16:18:30 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04GIUE5050825; Thu, 4 Jan 2018 16:18:30 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801041618.w04GIUE5050825@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 4 Jan 2018 16:18:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327552 - stable/11/usr.sbin/makefs X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/usr.sbin/makefs X-SVN-Commit-Revision: 327552 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 16:18:31 -0000 Author: markj Date: Thu Jan 4 16:18:30 2018 New Revision: 327552 URL: https://svnweb.freebsd.org/changeset/base/327552 Log: MFC r326912: Fix a logic bug in makefs lazy inode initialization. Modified: stable/11/usr.sbin/makefs/ffs.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/ffs.c ============================================================================== --- stable/11/usr.sbin/makefs/ffs.c Thu Jan 4 16:17:31 2018 (r327551) +++ stable/11/usr.sbin/makefs/ffs.c Thu Jan 4 16:18:30 2018 (r327552) @@ -1134,7 +1134,7 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const * Initialize inode blocks on the fly for UFS2. */ initediblk = ufs_rw32(cgp->cg_initediblk, fsopts->needswap); - if (ffs_opts->version == 2 && cgino + INOPB(fs) > initediblk && + while (ffs_opts->version == 2 && cgino + INOPB(fs) > initediblk && initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) { memset(buf, 0, fs->fs_bsize); dip = (struct ufs2_dinode *)buf; From owner-svn-src-stable-11@freebsd.org Thu Jan 4 16:19:58 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8273CEC0E0D; Thu, 4 Jan 2018 16:19:58 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1D6CD7188D; Thu, 4 Jan 2018 16:19:58 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04GJvMk051089; Thu, 4 Jan 2018 16:19:57 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04GJuSu051079; Thu, 4 Jan 2018 16:19:56 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801041619.w04GJuSu051079@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 4 Jan 2018 16:19:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327553 - in stable/11/tests/sys/geom/class: . mirror X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/tests/sys/geom/class: . mirror X-SVN-Commit-Revision: 327553 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 16:19:58 -0000 Author: markj Date: Thu Jan 4 16:19:56 2018 New Revision: 327553 URL: https://svnweb.freebsd.org/changeset/base/327553 Log: MFC r326861-r326863: Add some gmirror tests and fix indentation in existing tests. Added: stable/11/tests/sys/geom/class/mirror/10_test.sh - copied unchanged from r326861, head/tests/sys/geom/class/mirror/10_test.sh stable/11/tests/sys/geom/class/mirror/11_test.sh - copied unchanged from r326861, head/tests/sys/geom/class/mirror/11_test.sh stable/11/tests/sys/geom/class/mirror/12_test.sh - copied unchanged from r326861, head/tests/sys/geom/class/mirror/12_test.sh stable/11/tests/sys/geom/class/mirror/13_test.sh - copied unchanged from r326861, head/tests/sys/geom/class/mirror/13_test.sh Modified: stable/11/tests/sys/geom/class/geom_subr.sh stable/11/tests/sys/geom/class/mirror/8_test.sh stable/11/tests/sys/geom/class/mirror/9_test.sh stable/11/tests/sys/geom/class/mirror/Makefile stable/11/tests/sys/geom/class/mirror/conf.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/geom/class/geom_subr.sh ============================================================================== --- stable/11/tests/sys/geom/class/geom_subr.sh Thu Jan 4 16:18:30 2018 (r327552) +++ stable/11/tests/sys/geom/class/geom_subr.sh Thu Jan 4 16:19:56 2018 (r327553) @@ -20,6 +20,16 @@ attach_md() echo $test_md } +detach_md() +{ + local test_md unit + + test_md=$1 + unit=${test_md#md} + mdconfig -d -u $unit || exit + sed -i '' "/^${test_md}$/d" $TEST_MDS_FILE || exit +} + geom_test_cleanup() { local test_md @@ -38,6 +48,7 @@ if [ $(id -u) -ne 0 ]; then echo '1..0 # SKIP tests must be run as root' exit 0 fi + # If the geom class isn't already loaded, try loading it. if ! kldstat -q -m g_${class}; then if ! geom ${class} load; then Copied: stable/11/tests/sys/geom/class/mirror/10_test.sh (from r326861, head/tests/sys/geom/class/mirror/10_test.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tests/sys/geom/class/mirror/10_test.sh Thu Jan 4 16:19:56 2018 (r327553, copy of r326861, head/tests/sys/geom/class/mirror/10_test.sh) @@ -0,0 +1,69 @@ +#!/bin/sh +# $FreeBSD$ + +# Test handling of read errors. + +. $(dirname $0)/conf.sh + +echo 1..3 + +set -e + +ddbs=2048 +regreadfp="debug.fail_point.g_mirror_regular_request_read" +m1=$(mktemp $base.XXXXXX) +m2=$(mktemp $base.XXXXXX) + +dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1 +dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1 + +us0=$(attach_md -t vnode -f $m1) +us1=$(attach_md -t vnode -f $m2) + +gmirror label $name /dev/$us0 +gmirror insert $name /dev/$us1 +devwait +syncwait + +tmp1=$(mktemp $base.XXXXXX) +tmp2=$(mktemp $base.XXXXXX) + +EIO=5 +# gmirror should retry a failed read from the other mirror. +sysctl ${regreadfp}="1*return(${EIO})" +dd if=/dev/mirror/$name of=$tmp1 iseek=256 bs=$ddbs count=1 >/dev/null 2>&1 +dd if=/dev/$us1 of=$tmp2 iseek=256 bs=$ddbs count=1 >/dev/null 2>&1 +sysctl ${regreadfp}='off' + +if cmp -s $tmp1 $tmp2; then + echo "ok 1" +else + echo "not ok 1" +fi + +# Make sure that one of the mirrors was marked broken. +genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') +genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') +if [ $genid1 -eq $(($genid2 + 1)) -o $genid2 -eq $(($genid1 + 1)) ]; then + echo "ok 2" +else + echo "not ok 2" +fi + +# Force a retaste of the disconnected component. +if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then + detach_md $us1 + us1=$(attach_md -t vnode -f $m2) +else + detach_md $us0 + us0=$(attach_md -t vnode -f $m1) +fi + +# Make sure that the component wasn't re-added to the gmirror. +if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then + echo "ok 3" +else + echo "not ok 3" +fi + +rm -f $m1 $m2 $tmp1 $tmp2 Copied: stable/11/tests/sys/geom/class/mirror/11_test.sh (from r326861, head/tests/sys/geom/class/mirror/11_test.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tests/sys/geom/class/mirror/11_test.sh Thu Jan 4 16:19:56 2018 (r327553, copy of r326861, head/tests/sys/geom/class/mirror/11_test.sh) @@ -0,0 +1,84 @@ +#!/bin/sh +# $FreeBSD$ + +# Test handling of read errors. + +. $(dirname $0)/conf.sh + +echo 1..4 + +set -e + +ddbs=2048 +regreadfp="debug.fail_point.g_mirror_regular_request_read" +m1=$(mktemp $base.XXXXXX) +m2=$(mktemp $base.XXXXXX) + +dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1 +dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1 + +us0=$(attach_md -t vnode -f $m1) +us1=$(attach_md -t vnode -f $m2) + +gmirror label $name /dev/$us0 +gmirror insert $name /dev/$us1 +devwait +syncwait + +tmp1=$(mktemp $base.XXXXXX) +tmp2=$(mktemp $base.XXXXXX) + +ENXIO=6 +# gmirror has special handling for ENXIO. It does not mark the failed component +# as broken, allowing it to rejoin the mirror automatically when it appears. +sysctl ${regreadfp}="1*return(${ENXIO})" +dd if=/dev/mirror/$name of=$tmp1 iseek=512 bs=$ddbs count=1 >/dev/null 2>&1 +dd if=/dev/$us1 of=$tmp2 iseek=512 bs=$ddbs count=1 >/dev/null 2>&1 +sysctl ${regreadfp}='off' + +if cmp -s $tmp1 $tmp2; then + echo "ok 1" +else + echo "not ok 1" +fi + +# Verify that the genids still match after ENXIO. +genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') +genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') +if [ $genid1 -eq $genid2 ]; then + echo "ok 2" +else + echo "not ok 2" +fi + +# Trigger a syncid bump. +dd if=/dev/zero of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 + +# The ENXIO+write should have caused a syncid bump. +syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}') +syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}') +if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then + echo "ok 3" +else + echo "not ok 3" +fi + +# Force a retaste of the disconnected component. +if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then + detach_md $us1 + us1=$(attach_md -t vnode -f $m2) +else + detach_md $us0 + us0=$(attach_md -t vnode -f $m1) +fi + +# Make sure that the retaste caused the mirror to automatically be re-added. +if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then + echo "ok 4" +else + echo "not ok 4" +fi + +syncwait + +rm -f $m1 $m2 $tmp1 $tmp2 Copied: stable/11/tests/sys/geom/class/mirror/12_test.sh (from r326861, head/tests/sys/geom/class/mirror/12_test.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tests/sys/geom/class/mirror/12_test.sh Thu Jan 4 16:19:56 2018 (r327553, copy of r326861, head/tests/sys/geom/class/mirror/12_test.sh) @@ -0,0 +1,68 @@ +#!/bin/sh +# $FreeBSD$ + +# Test handling of write errors. + +. $(dirname $0)/conf.sh + +echo 1..3 + +set -e + +ddbs=2048 +regwritefp="debug.fail_point.g_mirror_regular_request_write" +m1=$(mktemp $base.XXXXXX) +m2=$(mktemp $base.XXXXXX) + +dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1 +dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1 + +us0=$(attach_md -t vnode -f $m1) +us1=$(attach_md -t vnode -f $m2) + +gmirror label $name /dev/$us0 /dev/$us1 +devwait + +tmp1=$(mktemp $base.XXXXXX) +tmp2=$(mktemp $base.XXXXXX) +dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&1 + +EIO=5 +# gmirror should kick one of the mirrors out after hitting EIO. +sysctl ${regwritefp}="1*return(${EIO})" +dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 +dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&1 +sysctl ${regwritefp}='off' + +if cmp -s $tmp1 $tmp2; then + echo "ok 1" +else + echo "not ok 1" +fi + +# Make sure that one of the mirrors was marked broken. +genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') +genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') +if [ $genid1 -eq $(($genid2 + 1)) -o $genid2 -eq $(($genid1 + 1)) ]; then + echo "ok 2" +else + echo "not ok 2" +fi + +# Force a retaste of the disconnected component. +if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then + detach_md $us1 + us1=$(attach_md -t vnode -f $m2) +else + detach_md $us0 + us0=$(attach_md -t vnode -f $m1) +fi + +# Make sure that the component wasn't re-added to the gmirror. +if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then + echo "ok 3" +else + echo "not ok 3" +fi + +rm -f $m1 $m2 $tmp1 $tmp2 Copied: stable/11/tests/sys/geom/class/mirror/13_test.sh (from r326861, head/tests/sys/geom/class/mirror/13_test.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tests/sys/geom/class/mirror/13_test.sh Thu Jan 4 16:19:56 2018 (r327553, copy of r326861, head/tests/sys/geom/class/mirror/13_test.sh) @@ -0,0 +1,81 @@ +#!/bin/sh +# $FreeBSD$ + +# Test handling of write errors. + +. $(dirname $0)/conf.sh + +echo 1..4 + +set -e + +ddbs=2048 +regwritefp="debug.fail_point.g_mirror_regular_request_write" +m1=$(mktemp $base.XXXXXX) +m2=$(mktemp $base.XXXXXX) + +dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1 +dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1 + +us0=$(attach_md -t vnode -f $m1) +us1=$(attach_md -t vnode -f $m2) + +gmirror label $name /dev/$us0 /dev/$us1 +devwait + +tmp1=$(mktemp $base.XXXXXX) +tmp2=$(mktemp $base.XXXXXX) + +dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&1 + +ENXIO=6 +# gmirror has special handling for ENXIO. It does not mark the failed component +# as broken, allowing it to rejoin the mirror automatically when it appears. +sysctl ${regwritefp}="1*return(${ENXIO})" +dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 +dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&1 +sysctl ${regwritefp}='off' + +if cmp -s $tmp1 $tmp2; then + echo "ok 1" +else + echo "not ok 1" +fi + +# Verify that the genids still match after ENXIO. +genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') +genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') +if [ $genid1 -eq $genid2 ]; then + echo "ok 2" +else + echo "not ok 2" +fi + +# The ENXIO should have caused a syncid bump. +syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}') +syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}') +if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then + echo "ok 3" +else + echo "not ok 3" +fi + +# Force a retaste of the disconnected component. +if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then + detach_md $us1 + us1=$(attach_md -t vnode -f $m2) +else + detach_md $us0 + us0=$(attach_md -t vnode -f $m1) +fi + +# Make sure that the retaste caused the mirror to automatically be re-added. +if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then + echo "ok 4" +else + echo "not ok 4" +fi + +syncwait + +rm -f $m1 $m2 $tmp1 $tmp2 Modified: stable/11/tests/sys/geom/class/mirror/8_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/mirror/8_test.sh Thu Jan 4 16:18:30 2018 (r327552) +++ stable/11/tests/sys/geom/class/mirror/8_test.sh Thu Jan 4 16:19:56 2018 (r327553) @@ -35,9 +35,7 @@ devwait # This will take kern.geom.mirror.timeout seco # Re-attach the second mirror and wait for it to synchronize. us1=$(attach_md -t vnode -f $m2) || exit 1 -while [ $(gmirror status $name | grep ACTIVE | wc -l) -ne 2 ]; do - sleep 1 -done +syncwait # Verify the two mirrors are identical. Destroy the gmirror first so that # the mirror metadata is wiped; otherwise the metadata blocks will fail @@ -45,9 +43,9 @@ done # command instead. gmirror destroy $name if cmp -s ${m1} ${m2}; then - echo "ok 1" + echo "ok 1" else - echo "not ok 1" + echo "not ok 1" fi rm -f $m1 $m2 Modified: stable/11/tests/sys/geom/class/mirror/9_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/mirror/9_test.sh Thu Jan 4 16:18:30 2018 (r327552) +++ stable/11/tests/sys/geom/class/mirror/9_test.sh Thu Jan 4 16:19:56 2018 (r327553) @@ -33,9 +33,7 @@ sysctl debug.fail_point.g_mirror_metadata_write='off' # Replace the broken mirror, and then stop the gmirror. gmirror forget $name || exit 1 gmirror insert $name /dev/$us2 || exit 1 -while [ $(gmirror status $name | grep ACTIVE | wc -l) -ne 2 ]; do - sleep 1 -done +syncwait gmirror stop $name || exit 1 # Restart the gmirror on the original two mirrors. One of them is broken, @@ -49,14 +47,12 @@ dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count= # the metadata blocks will fail the comparison. It would be nice to do this # with a "gmirror verify" command instead. gmirror activate $name /dev/$us2 || exit 1 -while [ $(gmirror status $name | grep ACTIVE | wc -l) -ne 2 ]; do - sleep 1 -done +syncwait gmirror destroy $name || exit 1 if cmp -s $m1 $m3; then - echo "ok 1" + echo "ok 1" else - echo "not ok 1" + echo "not ok 1" fi rm -f $m1 $m2 $m3 Modified: stable/11/tests/sys/geom/class/mirror/Makefile ============================================================================== --- stable/11/tests/sys/geom/class/mirror/Makefile Thu Jan 4 16:18:30 2018 (r327552) +++ stable/11/tests/sys/geom/class/mirror/Makefile Thu Jan 4 16:19:56 2018 (r327553) @@ -13,6 +13,10 @@ TAP_TESTS_SH+= 6_test TAP_TESTS_SH+= 7_test TAP_TESTS_SH+= 8_test TAP_TESTS_SH+= 9_test +TAP_TESTS_SH+= 10_test +TAP_TESTS_SH+= 11_test +TAP_TESTS_SH+= 12_test +TAP_TESTS_SH+= 13_test ${PACKAGE}FILES+= conf.sh Modified: stable/11/tests/sys/geom/class/mirror/conf.sh ============================================================================== --- stable/11/tests/sys/geom/class/mirror/conf.sh Thu Jan 4 16:18:30 2018 (r327552) +++ stable/11/tests/sys/geom/class/mirror/conf.sh Thu Jan 4 16:19:56 2018 (r327553) @@ -12,4 +12,11 @@ gmirror_test_cleanup() } trap gmirror_test_cleanup ABRT EXIT INT TERM +syncwait() +{ + while $(gmirror status -s $name | grep -q SYNCHRONIZING); do + sleep 0.1; + done +} + . `dirname $0`/../geom_subr.sh From owner-svn-src-stable-11@freebsd.org Thu Jan 4 19:35:57 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D384EB0D95; Thu, 4 Jan 2018 19:35:57 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CDBA17B8C9; Thu, 4 Jan 2018 19:35:56 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04JZug9036029; Thu, 4 Jan 2018 19:35:56 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04JZt7K036028; Thu, 4 Jan 2018 19:35:55 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201801041935.w04JZt7K036028@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Thu, 4 Jan 2018 19:35:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327556 - stable/11/sys/dev/acpica/Osd X-SVN-Group: stable-11 X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: stable/11/sys/dev/acpica/Osd X-SVN-Commit-Revision: 327556 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 19:35:57 -0000 Author: jkim Date: Thu Jan 4 19:35:55 2018 New Revision: 327556 URL: https://svnweb.freebsd.org/changeset/base/327556 Log: MFC: r324501 Do not check whether AcpiOsGetTimer() is called during boot. Modified: stable/11/sys/dev/acpica/Osd/OsdSchedule.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/acpica/Osd/OsdSchedule.c ============================================================================== --- stable/11/sys/dev/acpica/Osd/OsdSchedule.c Thu Jan 4 18:14:58 2018 (r327555) +++ stable/11/sys/dev/acpica/Osd/OsdSchedule.c Thu Jan 4 19:35:55 2018 (r327556) @@ -274,9 +274,6 @@ AcpiOsGetTimer(void) struct bintime bt; UINT64 t; - /* XXX During early boot there is no (decent) timer available yet. */ - KASSERT(cold == 0, ("acpi: timer op not yet supported during boot")); - binuptime(&bt); t = (uint64_t)bt.sec * 10000000; t += ((uint64_t)10000000 * (uint32_t)(bt.frac >> 32)) >> 32; From owner-svn-src-stable-11@freebsd.org Thu Jan 4 19:43:45 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 606A3EB15EC; Thu, 4 Jan 2018 19:43:45 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD5807C12B; Thu, 4 Jan 2018 19:43:44 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04Jhi0P040516; Thu, 4 Jan 2018 19:43:44 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04Jhhvp040506; Thu, 4 Jan 2018 19:43:43 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201801041943.w04Jhhvp040506@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Thu, 4 Jan 2018 19:43:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327557 - in stable/11: sys/conf sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/c... X-SVN-Group: stable-11 X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: in stable/11: sys/conf sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/components/disassembler sy... X-SVN-Commit-Revision: 327557 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 19:43:45 -0000 Author: jkim Date: Thu Jan 4 19:43:42 2018 New Revision: 327557 URL: https://svnweb.freebsd.org/changeset/base/327557 Log: MFC: r323076, r324502, r325670, r326866 Merge ACPICA 20171214. Added: stable/11/sys/contrib/dev/acpica/compiler/aslallocate.c - copied unchanged from r324502, head/sys/contrib/dev/acpica/compiler/aslallocate.c stable/11/sys/contrib/dev/acpica/compiler/aslcache.c - copied unchanged from r324502, head/sys/contrib/dev/acpica/compiler/aslcache.c stable/11/sys/contrib/dev/acpica/components/utilities/utstrsuppt.c - copied, changed from r323076, head/sys/contrib/dev/acpica/components/utilities/utstrsuppt.c Modified: stable/11/sys/conf/files stable/11/sys/contrib/dev/acpica/changes.txt stable/11/sys/contrib/dev/acpica/common/adfile.c stable/11/sys/contrib/dev/acpica/common/adisasm.c stable/11/sys/contrib/dev/acpica/common/ahtable.c stable/11/sys/contrib/dev/acpica/common/dmswitch.c stable/11/sys/contrib/dev/acpica/common/dmtable.c stable/11/sys/contrib/dev/acpica/common/dmtables.c stable/11/sys/contrib/dev/acpica/common/dmtbdump.c stable/11/sys/contrib/dev/acpica/common/dmtbinfo.c stable/11/sys/contrib/dev/acpica/compiler/aslcodegen.c stable/11/sys/contrib/dev/acpica/compiler/aslcompile.c stable/11/sys/contrib/dev/acpica/compiler/aslcompiler.h stable/11/sys/contrib/dev/acpica/compiler/aslcompiler.l stable/11/sys/contrib/dev/acpica/compiler/asldebug.c stable/11/sys/contrib/dev/acpica/compiler/asldefine.h stable/11/sys/contrib/dev/acpica/compiler/aslerror.c stable/11/sys/contrib/dev/acpica/compiler/aslfiles.c stable/11/sys/contrib/dev/acpica/compiler/aslhelp.c stable/11/sys/contrib/dev/acpica/compiler/aslload.c stable/11/sys/contrib/dev/acpica/compiler/aslmain.c stable/11/sys/contrib/dev/acpica/compiler/aslmapenter.c stable/11/sys/contrib/dev/acpica/compiler/aslmaputils.c stable/11/sys/contrib/dev/acpica/compiler/aslmessages.c stable/11/sys/contrib/dev/acpica/compiler/aslmessages.h stable/11/sys/contrib/dev/acpica/compiler/aslmethod.c stable/11/sys/contrib/dev/acpica/compiler/asloperands.c stable/11/sys/contrib/dev/acpica/compiler/aslopt.c stable/11/sys/contrib/dev/acpica/compiler/asloptions.c stable/11/sys/contrib/dev/acpica/compiler/aslparseop.c stable/11/sys/contrib/dev/acpica/compiler/aslprintf.c stable/11/sys/contrib/dev/acpica/compiler/aslresource.c stable/11/sys/contrib/dev/acpica/compiler/aslrules.y stable/11/sys/contrib/dev/acpica/compiler/aslstartup.c stable/11/sys/contrib/dev/acpica/compiler/aslsupport.l stable/11/sys/contrib/dev/acpica/compiler/asltree.c stable/11/sys/contrib/dev/acpica/compiler/asltypes.h stable/11/sys/contrib/dev/acpica/compiler/aslutils.c stable/11/sys/contrib/dev/acpica/compiler/cvcompiler.c stable/11/sys/contrib/dev/acpica/compiler/cvdisasm.c stable/11/sys/contrib/dev/acpica/compiler/cvparser.c stable/11/sys/contrib/dev/acpica/compiler/dtcompile.c stable/11/sys/contrib/dev/acpica/compiler/dtcompiler.h stable/11/sys/contrib/dev/acpica/compiler/dtexpress.c stable/11/sys/contrib/dev/acpica/compiler/dtfield.c stable/11/sys/contrib/dev/acpica/compiler/dtio.c stable/11/sys/contrib/dev/acpica/compiler/dtparser.y stable/11/sys/contrib/dev/acpica/compiler/dtsubtable.c stable/11/sys/contrib/dev/acpica/compiler/dttable.c stable/11/sys/contrib/dev/acpica/compiler/dttable1.c stable/11/sys/contrib/dev/acpica/compiler/dttable2.c stable/11/sys/contrib/dev/acpica/compiler/dttemplate.c stable/11/sys/contrib/dev/acpica/compiler/dttemplate.h stable/11/sys/contrib/dev/acpica/compiler/dtutils.c stable/11/sys/contrib/dev/acpica/compiler/prexpress.c stable/11/sys/contrib/dev/acpica/compiler/prmacros.c stable/11/sys/contrib/dev/acpica/compiler/prparser.y stable/11/sys/contrib/dev/acpica/compiler/prscan.c stable/11/sys/contrib/dev/acpica/compiler/prutils.c stable/11/sys/contrib/dev/acpica/components/debugger/dbconvert.c stable/11/sys/contrib/dev/acpica/components/debugger/dbexec.c stable/11/sys/contrib/dev/acpica/components/debugger/dbfileio.c stable/11/sys/contrib/dev/acpica/components/debugger/dbinput.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmresrc.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmwalk.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsfield.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsobject.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dspkginit.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsutils.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dswexec.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dswload.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dswload2.c stable/11/sys/contrib/dev/acpica/components/events/evgpe.c stable/11/sys/contrib/dev/acpica/components/events/evregion.c stable/11/sys/contrib/dev/acpica/components/executer/exconcat.c stable/11/sys/contrib/dev/acpica/components/executer/exconvrt.c stable/11/sys/contrib/dev/acpica/components/executer/exdump.c stable/11/sys/contrib/dev/acpica/components/executer/exmisc.c stable/11/sys/contrib/dev/acpica/components/executer/exresop.c stable/11/sys/contrib/dev/acpica/components/hardware/hwgpe.c stable/11/sys/contrib/dev/acpica/components/hardware/hwregs.c stable/11/sys/contrib/dev/acpica/components/hardware/hwtimer.c stable/11/sys/contrib/dev/acpica/components/hardware/hwvalid.c stable/11/sys/contrib/dev/acpica/components/hardware/hwxface.c stable/11/sys/contrib/dev/acpica/components/namespace/nsaccess.c stable/11/sys/contrib/dev/acpica/components/namespace/nsconvert.c stable/11/sys/contrib/dev/acpica/components/namespace/nsnames.c stable/11/sys/contrib/dev/acpica/components/namespace/nssearch.c stable/11/sys/contrib/dev/acpica/components/namespace/nsxfeval.c stable/11/sys/contrib/dev/acpica/components/parser/psargs.c stable/11/sys/contrib/dev/acpica/components/parser/psobject.c stable/11/sys/contrib/dev/acpica/components/parser/psutils.c stable/11/sys/contrib/dev/acpica/components/tables/tbxface.c stable/11/sys/contrib/dev/acpica/components/utilities/utdebug.c stable/11/sys/contrib/dev/acpica/components/utilities/utdecode.c stable/11/sys/contrib/dev/acpica/components/utilities/uterror.c stable/11/sys/contrib/dev/acpica/components/utilities/utinit.c stable/11/sys/contrib/dev/acpica/components/utilities/utmath.c stable/11/sys/contrib/dev/acpica/components/utilities/utmutex.c stable/11/sys/contrib/dev/acpica/components/utilities/utnonansi.c stable/11/sys/contrib/dev/acpica/components/utilities/utosi.c stable/11/sys/contrib/dev/acpica/components/utilities/utstrtoul64.c stable/11/sys/contrib/dev/acpica/components/utilities/uttrack.c stable/11/sys/contrib/dev/acpica/components/utilities/utxferror.c stable/11/sys/contrib/dev/acpica/include/acapps.h stable/11/sys/contrib/dev/acpica/include/acconfig.h stable/11/sys/contrib/dev/acpica/include/acdebug.h stable/11/sys/contrib/dev/acpica/include/acdisasm.h stable/11/sys/contrib/dev/acpica/include/acexcep.h stable/11/sys/contrib/dev/acpica/include/acglobal.h stable/11/sys/contrib/dev/acpica/include/achware.h stable/11/sys/contrib/dev/acpica/include/acinterp.h stable/11/sys/contrib/dev/acpica/include/aclocal.h stable/11/sys/contrib/dev/acpica/include/acmacros.h stable/11/sys/contrib/dev/acpica/include/acnamesp.h stable/11/sys/contrib/dev/acpica/include/acpixf.h stable/11/sys/contrib/dev/acpica/include/actbl1.h stable/11/sys/contrib/dev/acpica/include/actbl2.h stable/11/sys/contrib/dev/acpica/include/actypes.h stable/11/sys/contrib/dev/acpica/include/acutils.h stable/11/sys/contrib/dev/acpica/os_specific/service_layers/osgendbg.c stable/11/sys/dev/acpica/acpi_cpu.c stable/11/usr.sbin/acpi/acpidb/Makefile stable/11/usr.sbin/acpi/iasl/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/conf/files Thu Jan 4 19:43:42 2018 (r327557) @@ -515,6 +515,7 @@ contrib/dev/acpica/components/utilities/utresdecode.c contrib/dev/acpica/components/utilities/utresrc.c optional acpi contrib/dev/acpica/components/utilities/utstate.c optional acpi contrib/dev/acpica/components/utilities/utstring.c optional acpi +contrib/dev/acpica/components/utilities/utstrsuppt.c optional acpi contrib/dev/acpica/components/utilities/utstrtoul64.c optional acpi contrib/dev/acpica/components/utilities/utuuid.c optional acpi acpi_debug contrib/dev/acpica/components/utilities/utxface.c optional acpi Modified: stable/11/sys/contrib/dev/acpica/changes.txt ============================================================================== --- stable/11/sys/contrib/dev/acpica/changes.txt Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/changes.txt Thu Jan 4 19:43:42 2018 (r327557) @@ -1,4 +1,246 @@ ---------------------------------------- +14 December 2017. Summary of changes for version 20171214: + + +1) ACPICA kernel-resident subsystem: + +Fixed a regression in the external (public) AcpiEvaluateObjectTyped +interface where the optional "pathname" argument had inadvertently become +a required argument returning an error if omitted (NULL pointer +argument). + +Fixed two possible memory leaks related to the recently developed "late +resolution" of reference objects within ASL Package Object definitions. + +Added two recently defined _OSI strings: "Windows 2016" and "Windows +2017". Mario Limonciello. + +Implemented and deployed a safer version of the C library function +strncpy: AcpiUtSafeStrncpy. The intent is to at least prevent the +creation of unterminated strings as a possible result of a standard +strncpy. + +Cleaned up and restructured the global variable file (acglobal.h). There +are many changes, but no functional changes. + + +2) iASL Compiler/Disassembler and Tools: + +iASL Table Compiler: Fixed a problem with the DBG2 ACPI table where the +optional OemData field at the end of the table was incorrectly required +for proper compilation. It is now correctly an optional field. + +ASLTS: The entire suite was converted from standard ASL to the ASL+ +language, using the ASL-to-ASL+ converter which is integrated into the +iASL compiler. A binary compare of all output files has verified the +correctness of the conversion. + +iASL: Fixed the source code build for platforms where "char" is unsigned. +This affected the iASL lexer only. Jung-uk Kim. + +---------------------------------------- +10 November 2017. Summary of changes for version 20171110: + + +1) ACPICA kernel-resident subsystem: + +This release implements full support for ACPI 6.2A: + NFIT - Added a new subtable, "Platform Capabilities Structure" +No other changes to ACPICA were required, since ACPI 6.2A is primarily an +errata release of the specification. + +Other ACPI table changes: + IORT: Added the SMMUv3 Device ID mapping index. Hanjun Guo + PPTT: Added cache attribute flag definitions to actbl1.h. Jeremy +Linton + +Utilities: Modified the string/integer conversion functions to use +internal 64-bit divide support instead of a native divide. On 32-bit +platforms, a 64-bit divide typically requires a library function which +may not be present in the build (kernel or otherwise). + +Implemented a targeted error message for timeouts returned from the +Embedded Controller device driver. This is seen frequently enough to +special-case an AE_TIME returned from an EC operation region access: + "Timeout from EC hardware or EC device driver" + +Changed the "ACPI Exception" message prefix to "ACPI Error" so that all +runtime error messages have the identical prefix. + + +2) iASL Compiler/Disassembler and Tools: + +AcpiXtract: Fixed a problem with table header detection within the +acpidump file. Processing a table could be ended early if a 0x40 (@) +appears in the original binary table, resulting in the @ symbol appearing +in the decoded ASCII field at the end of the acpidump text line. The +symbol caused acpixtract to incorrectly think it had reached the end of +the current table and the beginning of a new table. + +AcpiXtract: Added an option (-f) to ignore some errors during table +extraction. This initial implementation ignores non-ASCII and non- +printable characters found in the acpidump text file. + +TestSuite(ASLTS)/AcpiExec: Fixed and restored the memory usage statistics +for ASLTS. This feature is used to track memory allocations from +different memory caches within the ACPICA code. At the end of an ASLTS +run, these memory statistics are recorded and stored in a log file. + +Debugger (user-space version): Implemented a simple "Background" command. +Creates a new thread to execute a control method in the background, while +control returns to the debugger prompt to allow additional commands. + Syntax: Background [Arguments] + +---------------------------------------- +29 September 2017. Summary of changes for version 20170929: + + +1) ACPICA kernel-resident subsystem: + +Redesigned and implemented an improved ASL While() loop timeout +mechanism. This mechanism is used to prevent infinite loops in the kernel +AML interpreter caused by either non-responsive hardware or incorrect AML +code. The new implementation uses AcpiOsGetTimer instead of a simple +maximum loop count, and is thus more accurate and constant across +different machines. The default timeout is currently 30 seconds, but this +may be adjusted later. + +Renamed the ACPI_AML_INFINITE_LOOP exception to AE_AML_LOOP_TIMEOUT to +better reflect the new implementation of the loop timeout mechanism. + +Updated the AcpiGetTimerDuration interface to cleanup the 64-bit support +and to fix an off-by-one error. Jung-uk Kim. + +Fixed an EFI build problem by updating the makefiles to for a new file +that was added, utstrsuppt.c + + +2) iASL Compiler/Disassembler and Tools: + +Implemented full support for the PDTT, SDEV, and TPM2 ACPI tables. This +includes support in the table disassembler, compiler, and template +generator. + +iASL: Added an exception for an illegal type of recursive method +invocation. If a method creates named objects, the first recursive call +will fail at runtime. This change adds an error detection at compile time +to catch the problem up front. Note: Marking such a method as +"serialized" will not help with this problem, because the same thread can +acquire the method mutex more than once. Example compiler and runtime +output: + + Method (MTH1) + { + Name (INT1, 1) + MTH1 () + } + + dsdt.asl 22: MTH1 () + Error 6152 - ^ Illegal recursive call to method + that creates named objects (MTH1) + +Previous runtime exception: + ACPI Error: [INT1] Namespace lookup failure, + AE_ALREADY_EXISTS (20170831/dswload2-465) + +iASL: Updated support for External() opcodes to improve namespace +management and error detection. These changes are related to issues seen +with multiple-segment namespace pathnames within External declarations, +such as below: + + External(\_SB.PCI0.GFX0, DeviceObj) + External(\_SB.PCI0.GFX0.ALSI) + +iASL: Implemented support for multi-line error/warning messages. This +enables more detailed and helpful error messages as below, from the +initial deployment for the duplicate names error: + + DSDT.iiii 1692: Device(PEG2) { + Error 6074 - ^ Name already exists in scope +(PEG2) + + Original name creation/declaration below: + DSDT.iiii 93: External(\_SB.PCI0.PEG2, DeviceObj) + +AcpiXtract: Added additional flexibility to support differing input hex +dump formats. Specifically, hex dumps that contain partial disassembly +and/or comments within the ACPI table data definition. There exist some +dump utilities seen in the field that create this type of hex dump (such +as Simics). For example: + + DSDT @ 0xdfffd0c0 (10999 bytes) + Signature DSDT + Length 10999 + Revision 1 + Checksum 0xf3 (Ok) + OEM_ID BXPC + OEM_table_id BXDSDT + OEM_revision 1 + Creator_id 1280593481 + Creator_revision 537399345 + 0000: 44 53 44 54 f7 2a 00 00 01 f3 42 58 50 43 00 00 + ... + 2af0: 5f 4c 30 46 00 a4 01 + +Test suite: Miscellaneous changes/fixes: + More cleanup and simplification of makefiles + Continue compilation of test cases after a compile failure + Do not perform binary compare unless both files actually exist + +iASL: Performed some code/module restructuring. Moved all memory +allocation functions to new modules. Two new files, aslallocate.c and +aslcache.c + +---------------------------------------- +31 August 2017. Summary of changes for version 20170831: + + +1) ACPICA kernel-resident subsystem: + +Implemented internal support for full 64-bit addresses that appear in all +Generic Address Structure (GAS) structures. Previously, only the lower 32 +bits were used. Affects the use of GAS structures in the FADT and other +tables, as well as the GAS structures passed to the AcpiRead and +AcpiWrite public external interfaces that are used by drivers. Lv Zheng. + +Added header support for the PDTT ACPI table (Processor Debug Trigger +Table). Full support in the iASL Data Table Compiler and disassembler is +forthcoming. + + +2) iASL Compiler/Disassembler and Tools: + +iASL/Disassembler: Fixed a problem with the PPTT ACPI table (Processor +Properties Topology Table) where a flag bit was specified in the wrong +bit position ("Line Size Valid", bit 6). + +iASL: Implemented support for Octal integer constants as defined by the +ASL language grammar, per the ACPI specification. Any integer constant +that starts with a zero is an octal constant. For example, + Store (037777, Local0) /* Octal constant */ + Store (0x3FFF, Local0) /* Hex equivalent */ + Store (16383, Local0) /* Decimal equivalent */ + +iASL: Improved overflow detection for 64-bit string conversions during +compilation of integer constants. "Overflow" in this case means a string +that represents an integer that is too large to fit into a 64-bit value. +Any 64-bit constants within a 32-bit DSDT or SSDT are still truncated to +the low-order 32 bits with a warning, as previously implemented. Several +new exceptions are defined that indicate a 64-bit overflow, as well as +the base (radix) that was used during the attempted conversion. Examples: + Local0 = 0xAAAABBBBCCCCDDDDEEEEFFFF // AE_HEX_OVERFLOW + Local0 = 01111222233334444555566667777 // AE_OCTAL_OVERFLOW + Local0 = 11112222333344445555666677778888 // AE_DECIMAL_OVERFLOW + +iASL: Added a warning for the case where a ResourceTemplate is declared +with no ResourceDescriptor entries (coded as "ResourceTemplate(){}"). In +this case, the resulting template is created with a single END_TAG +descriptor, which is essentially useless. + +iASL: Expanded the -vw option (ignore specific warnings/remarks) to +include compilation error codes as well. + +---------------------------------------- 28 July 2017. Summary of changes for version 20170728: Modified: stable/11/sys/contrib/dev/acpica/common/adfile.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/adfile.c Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/common/adfile.c Thu Jan 4 19:43:42 2018 (r327557) @@ -314,7 +314,7 @@ FlGenerateFilename ( * Copy the original filename to a new buffer. Leave room for the worst * case where we append the suffix, an added dot and the null terminator. */ - NewFilename = UtStringCacheCalloc ((ACPI_SIZE) + NewFilename = UtLocalCacheCalloc ((ACPI_SIZE) strlen (InputFilename) + strlen (Suffix) + 2); strcpy (NewFilename, InputFilename); @@ -358,7 +358,7 @@ FlStrdup ( char *NewString; - NewString = UtStringCacheCalloc ((ACPI_SIZE) strlen (String) + 1); + NewString = UtLocalCacheCalloc ((ACPI_SIZE) strlen (String) + 1); strcpy (NewString, String); return (NewString); } Modified: stable/11/sys/contrib/dev/acpica/common/adisasm.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/adisasm.c Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/common/adisasm.c Thu Jan 4 19:43:42 2018 (r327557) @@ -457,9 +457,9 @@ AdDisassembleOneTable ( * (.xxx) file produced from the converter in case if * it fails to get deleted. */ - if (Gbl_CaptureComments) + if (AcpiGbl_CaptureComments) { - strncpy (Table->Signature, AcpiGbl_TableSig, 4); + strncpy (Table->Signature, AcpiGbl_TableSig, ACPI_NAME_SIZE); } #endif Modified: stable/11/sys/contrib/dev/acpica/common/ahtable.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/ahtable.c Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/common/ahtable.c Thu Jan 4 19:43:42 2018 (r327557) @@ -232,6 +232,7 @@ const AH_TABLE Gbl_AcpiSupportedTables[] = {ACPI_SIG_MTMR, "MID Timer Table"}, {ACPI_SIG_NFIT, "NVDIMM Firmware Interface Table"}, {ACPI_SIG_PCCT, "Platform Communications Channel Table"}, + {ACPI_SIG_PDTT, "Platform Debug Trigger Table"}, {ACPI_SIG_PMTT, "Platform Memory Topology Table"}, {ACPI_SIG_PPTT, "Processor Properties Topology Table"}, {ACPI_SIG_RASF, "RAS Features Table"}, @@ -240,6 +241,7 @@ const AH_TABLE Gbl_AcpiSupportedTables[] = {ACPI_SIG_S3PT, "S3 Performance Table"}, {ACPI_SIG_SBST, "Smart Battery Specification Table"}, {ACPI_SIG_SDEI, "Software Delegated Exception Interface Table"}, + {ACPI_SIG_SDEV, "Secure Devices table"}, {ACPI_SIG_SLIC, "Software Licensing Description Table"}, {ACPI_SIG_SLIT, "System Locality Information Table"}, {ACPI_SIG_SPCR, "Serial Port Console Redirection table"}, Modified: stable/11/sys/contrib/dev/acpica/common/dmswitch.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/dmswitch.c Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/common/dmswitch.c Thu Jan 4 19:43:42 2018 (r327557) @@ -543,6 +543,10 @@ AcpiDmIsSwitchBlock ( * statement, so check for it. */ CurrentOp = StoreOp->Common.Next->Common.Next; + if (!CurrentOp) + { + return (FALSE); + } if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP) { CurrentOp = CurrentOp->Common.Next; Modified: stable/11/sys/contrib/dev/acpica/common/dmtable.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/dmtable.c Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/common/dmtable.c Thu Jan 4 19:43:42 2018 (r327557) @@ -154,7 +154,6 @@ #include #include #include -#include /* This module used for application-level code only */ @@ -290,9 +289,9 @@ static const char *AcpiDmHestSubnames[] = "IA-32 Machine Check Exception", "IA-32 Corrected Machine Check", "IA-32 Non-Maskable Interrupt", - "Unknown SubTable Type", /* 3 - Reserved */ - "Unknown SubTable Type", /* 4 - Reserved */ - "Unknown SubTable Type", /* 5 - Reserved */ + "Unknown Subtable Type", /* 3 - Reserved */ + "Unknown Subtable Type", /* 4 - Reserved */ + "Unknown Subtable Type", /* 5 - Reserved */ "PCI Express Root Port AER", "PCI Express AER (AER Endpoint)", "PCI Express/PCI-X Bridge AER", @@ -357,6 +356,7 @@ static const char *AcpiDmNfitSubnames[] = "NVDIMM Control Region", /* ACPI_NFIT_TYPE_CONTROL_REGION */ "NVDIMM Block Data Window Region", /* ACPI_NFIT_TYPE_DATA_REGION */ "Flush Hint Address", /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */ + "Platform Capabilities", /* ACPI_NFIT_TYPE_CAPABILITIES */ "Unknown Subtable Type" /* Reserved */ }; @@ -374,7 +374,7 @@ static const char *AcpiDmPmttSubnames[] = { "Socket", /* ACPI_PMTT_TYPE_SOCKET */ "Memory Controller", /* ACPI_PMTT_TYPE_CONTROLLER */ - "Physical Component (DIMM)", /* ACPI_PMTT_TYPE_DIMM */ + "Physical Component (DIMM)", /* ACPI_PMTT_TYPE_DIMM */ "Unknown Subtable Type" /* Reserved */ }; @@ -382,10 +382,17 @@ static const char *AcpiDmPpttSubnames[] = { "Processor Hierarchy Node", /* ACPI_PPTT_TYPE_PROCESSOR */ "Cache Type", /* ACPI_PPTT_TYPE_CACHE */ - "ID", /* ACPI_PMTT_TYPE_ID */ + "ID", /* ACPI_PPTT_TYPE_ID */ "Unknown Subtable Type" /* Reserved */ }; +static const char *AcpiDmSdevSubnames[] = +{ + "Namespace Device", /* ACPI_SDEV_TYPE_NAMESPACE_DEVICE */ + "PCIe Endpoint Device", /* ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE */ + "Unknown Subtable Type" /* Reserved */ +}; + static const char *AcpiDmSratSubnames[] = { "Processor Local APIC/SAPIC Affinity", @@ -396,6 +403,23 @@ static const char *AcpiDmSratSubnames[] = "Unknown Subtable Type" /* Reserved */ }; +static const char *AcpiDmTpm2Subnames[] = +{ + "Illegal Start Method value", + "Reserved", + "ACPI Start Method", + "Reserved", + "Reserved", + "Reserved", + "Memory Mapped I/O", + "Command Response Buffer", + "Command Response Buffer with ACPI Start Method", + "Reserved", + "Reserved", + "Command Response Buffer with ARM SMC", + "Unknown Subtable Type" /* Reserved */ +}; + static const char *AcpiDmIvrsSubnames[] = { "Hardware Definition Block", @@ -487,6 +511,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_MTMR, NULL, AcpiDmDumpMtmr, DtCompileMtmr, TemplateMtmr}, {ACPI_SIG_NFIT, AcpiDmTableInfoNfit, AcpiDmDumpNfit, DtCompileNfit, TemplateNfit}, {ACPI_SIG_PCCT, AcpiDmTableInfoPcct, AcpiDmDumpPcct, DtCompilePcct, TemplatePcct}, + {ACPI_SIG_PDTT, AcpiDmTableInfoPdtt, AcpiDmDumpPdtt, DtCompilePdtt, TemplatePdtt}, {ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt}, {ACPI_SIG_PPTT, NULL, AcpiDmDumpPptt, DtCompilePptt, TemplatePptt}, {ACPI_SIG_RASF, AcpiDmTableInfoRasf, NULL, NULL, TemplateRasf}, @@ -494,6 +519,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt}, {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst}, {ACPI_SIG_SDEI, AcpiDmTableInfoSdei, NULL, NULL, TemplateSdei}, + {ACPI_SIG_SDEV, AcpiDmTableInfoSdev, AcpiDmDumpSdev, DtCompileSdev, TemplateSdev}, {ACPI_SIG_SLIC, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateSlic}, {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, DtCompileSlit, TemplateSlit}, {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, NULL, TemplateSpcr}, @@ -501,7 +527,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, DtCompileSrat, TemplateSrat}, {ACPI_SIG_STAO, NULL, AcpiDmDumpStao, DtCompileStao, TemplateStao}, {ACPI_SIG_TCPA, NULL, AcpiDmDumpTcpa, DtCompileTcpa, TemplateTcpa}, - {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2, NULL, NULL, TemplateTpm2}, + {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2, AcpiDmDumpTpm2, DtCompileTpm2, TemplateTpm2}, {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, DtCompileUefi, TemplateUefi}, {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc, AcpiDmDumpVrtc, DtCompileVrtc, TemplateVrtc}, {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, NULL, TemplateWaet}, @@ -917,6 +943,7 @@ AcpiDmDumpTable ( case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: case ACPI_DMT_PPTT: + case ACPI_DMT_SDEV: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: case ACPI_DMT_HESTNTYP: @@ -948,6 +975,7 @@ AcpiDmDumpTable ( case ACPI_DMT_NAME4: case ACPI_DMT_SIG: case ACPI_DMT_LPIT: + case ACPI_DMT_TPM2: ByteLength = 4; break; @@ -1583,6 +1611,20 @@ AcpiDmDumpTable ( CurrentOffset, NULL); break; + case ACPI_DMT_SDEV: + + /* SDEV subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_SDEV_TYPE_RESERVED) + { + Temp8 = ACPI_SDEV_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, + AcpiDmSdevSubnames[Temp8]); + break; + case ACPI_DMT_SRAT: /* SRAT subtable types */ @@ -1596,6 +1638,21 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmSratSubnames[Temp8]); break; + + case ACPI_DMT_TPM2: + + /* TPM2 Start Method types */ + + Temp8 = *Target; + if (Temp8 > ACPI_TPM2_RESERVED) + { + Temp8 = ACPI_TPM2_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, + AcpiDmTpm2Subnames[Temp8]); + break; + case ACPI_DMT_FADTPM: Modified: stable/11/sys/contrib/dev/acpica/common/dmtables.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/dmtables.c Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/common/dmtables.c Thu Jan 4 19:43:42 2018 (r327557) @@ -314,7 +314,7 @@ AdCreateTableHeader ( /* * Print comments that come before this definition block. */ - if (Gbl_CaptureComments) + if (AcpiGbl_CaptureComments) { ASL_CV_PRINT_ONE_COMMENT(AcpiGbl_ParseOpRoot,AML_COMMENT_STANDARD, NULL, 0); } @@ -517,7 +517,7 @@ AdParseTable ( } #ifdef ACPI_ASL_COMPILER - if (Gbl_CaptureComments) + if (AcpiGbl_CaptureComments) { AcpiGbl_ParseOpRoot->Common.CvFilename = AcpiGbl_FileTreeRoot->Filename; } Modified: stable/11/sys/contrib/dev/acpica/common/dmtbdump.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/dmtbdump.c Thu Jan 4 19:35:55 2018 (r327556) +++ stable/11/sys/contrib/dev/acpica/common/dmtbdump.c Thu Jan 4 19:43:42 2018 (r327557) @@ -623,7 +623,7 @@ AcpiDmDumpAsf ( { ACPI_STATUS Status; UINT32 Offset = sizeof (ACPI_TABLE_HEADER); - ACPI_ASF_INFO *SubTable; + ACPI_ASF_INFO *Subtable; ACPI_DMTABLE_INFO *InfoTable; ACPI_DMTABLE_INFO *DataInfoTable = NULL; UINT8 *DataTable = NULL; @@ -636,13 +636,13 @@ AcpiDmDumpAsf ( /* No main table, only subtables */ - SubTable = ACPI_ADD_PTR (ACPI_ASF_INFO, Table, Offset); + Subtable = ACPI_ADD_PTR (ACPI_ASF_INFO, Table, Offset); while (Offset < Table->Length) { /* Common subtable header */ - Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoAsfHdr); + Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, + Subtable->Header.Length, AcpiDmTableInfoAsfHdr); if (ACPI_FAILURE (Status)) { return; @@ -650,7 +650,7 @@ AcpiDmDumpAsf ( /* The actual type is the lower 7 bits of Type */ - Type = (UINT8) (SubTable->Header.Type & 0x7F); + Type = (UINT8) (Subtable->Header.Type & 0x7F); switch (Type) { @@ -663,9 +663,9 @@ AcpiDmDumpAsf ( InfoTable = AcpiDmTableInfoAsf1; DataInfoTable = AcpiDmTableInfoAsf1a; - DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ALERT)); - DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->Alerts; - DataLength = ACPI_CAST_PTR (ACPI_ASF_ALERT, SubTable)->DataLength; + DataTable = ACPI_ADD_PTR (UINT8, Subtable, sizeof (ACPI_ASF_ALERT)); + DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, Subtable)->Alerts; + DataLength = ACPI_CAST_PTR (ACPI_ASF_ALERT, Subtable)->DataLength; DataOffset = Offset + sizeof (ACPI_ASF_ALERT); break; @@ -673,9 +673,9 @@ AcpiDmDumpAsf ( InfoTable = AcpiDmTableInfoAsf2; DataInfoTable = AcpiDmTableInfoAsf2a; - DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_REMOTE)); - DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->Controls; - DataLength = ACPI_CAST_PTR (ACPI_ASF_REMOTE, SubTable)->DataLength; + DataTable = ACPI_ADD_PTR (UINT8, Subtable, sizeof (ACPI_ASF_REMOTE)); + DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, Subtable)->Controls; + DataLength = ACPI_CAST_PTR (ACPI_ASF_REMOTE, Subtable)->DataLength; DataOffset = Offset + sizeof (ACPI_ASF_REMOTE); break; @@ -687,20 +687,20 @@ AcpiDmDumpAsf ( case ACPI_ASF_TYPE_ADDRESS: InfoTable = AcpiDmTableInfoAsf4; - DataTable = ACPI_ADD_PTR (UINT8, SubTable, sizeof (ACPI_ASF_ADDRESS)); - DataLength = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, SubTable)->Devices; + DataTable = ACPI_ADD_PTR (UINT8, Subtable, sizeof (ACPI_ASF_ADDRESS)); + DataLength = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, Subtable)->Devices; DataOffset = Offset + sizeof (ACPI_ASF_ADDRESS); break; default: AcpiOsPrintf ("\n**** Unknown ASF subtable type 0x%X\n", - SubTable->Header.Type); + Subtable->Header.Type); return; } - Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, - SubTable->Header.Length, InfoTable); + Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, + Subtable->Header.Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -762,15 +762,15 @@ AcpiDmDumpAsf ( /* Point to next subtable */ - if (!SubTable->Header.Length) + if (!Subtable->Header.Length) { AcpiOsPrintf ("Invalid zero subtable header length\n"); return; } - Offset += SubTable->Header.Length; - SubTable = ACPI_ADD_PTR (ACPI_ASF_INFO, SubTable, - SubTable->Header.Length); + Offset += Subtable->Header.Length; + Subtable = ACPI_ADD_PTR (ACPI_ASF_INFO, Subtable, + Subtable->Header.Length); } } @@ -793,7 +793,7 @@ AcpiDmDumpCpep ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_CPEP_POLLING *SubTable; + ACPI_CPEP_POLLING *Subtable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_CPEP); @@ -808,12 +808,12 @@ AcpiDmDumpCpep ( /* Subtables */ - SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Table, Offset); + Subtable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Table, Offset); while (Offset < Table->Length) { AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoCpep0); + Status = AcpiDmDumpTable (Length, Offset, Subtable, + Subtable->Header.Length, AcpiDmTableInfoCpep0); if (ACPI_FAILURE (Status)) { return; @@ -821,9 +821,9 @@ AcpiDmDumpCpep ( /* Point to next subtable */ - Offset += SubTable->Header.Length; - SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, - SubTable->Header.Length); + Offset += Subtable->Header.Length; + Subtable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Subtable, + Subtable->Header.Length); } } @@ -846,9 +846,9 @@ AcpiDmDumpCsrt ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_CSRT_GROUP *SubTable; + ACPI_CSRT_GROUP *Subtable; ACPI_CSRT_SHARED_INFO *SharedInfoTable; - ACPI_CSRT_DESCRIPTOR *SubSubTable; + ACPI_CSRT_DESCRIPTOR *SubSubtable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_CSRT); UINT32 SubOffset; @@ -860,14 +860,14 @@ AcpiDmDumpCsrt ( /* Subtables (Resource Groups) */ - SubTable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset); + Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset); while (Offset < Table->Length) { /* Resource group subtable */ AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoCsrt0); + Status = AcpiDmDumpTable (Length, Offset, Subtable, + Subtable->Length, AcpiDmTableInfoCsrt0); if (ACPI_FAILURE (Status)) { return; @@ -887,19 +887,19 @@ AcpiDmDumpCsrt ( return; } - SubOffset += SubTable->SharedInfoLength; + SubOffset += Subtable->SharedInfoLength; /* Sub-Subtables (Resource Descriptors) */ - SubSubTable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, Table, + SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, Table, Offset + SubOffset); - while ((SubOffset < SubTable->Length) && + while ((SubOffset < Subtable->Length) && ((Offset + SubOffset) < Table->Length)) { AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubTable, - SubSubTable->Length, AcpiDmTableInfoCsrt2); + Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubtable, + SubSubtable->Length, AcpiDmTableInfoCsrt2); if (ACPI_FAILURE (Status)) { return; @@ -909,7 +909,7 @@ AcpiDmDumpCsrt ( /* Resource-specific info buffer */ - InfoLength = SubSubTable->Length - SubSubOffset; + InfoLength = SubSubtable->Length - SubSubOffset; if (InfoLength) { Status = AcpiDmDumpTable (Length, @@ -924,16 +924,16 @@ AcpiDmDumpCsrt ( /* Point to next sub-subtable */ - SubOffset += SubSubTable->Length; - SubSubTable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, SubSubTable, - SubSubTable->Length); + SubOffset += SubSubtable->Length; + SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, SubSubtable, + SubSubtable->Length); } /* Point to next subtable */ - Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, SubTable, - SubTable->Length); + Offset += Subtable->Length; + Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Subtable, + Subtable->Length); } } @@ -956,7 +956,7 @@ AcpiDmDumpDbg2 ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_DBG2_DEVICE *SubTable; + ACPI_DBG2_DEVICE *Subtable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_DBG2); UINT32 i; @@ -975,12 +975,12 @@ AcpiDmDumpDbg2 ( /* Subtables */ - SubTable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Table, Offset); + Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Table, Offset); while (Offset < Table->Length) { AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoDbg2Device); + Status = AcpiDmDumpTable (Length, Offset, Subtable, + Subtable->Length, AcpiDmTableInfoDbg2Device); if (ACPI_FAILURE (Status)) { return; @@ -988,15 +988,15 @@ AcpiDmDumpDbg2 ( /* Dump the BaseAddress array */ - for (i = 0; i < SubTable->RegisterCount; i++) + for (i = 0; i < Subtable->RegisterCount; i++) { - ArrayOffset = SubTable->BaseAddressOffset + + ArrayOffset = Subtable->BaseAddressOffset + (sizeof (ACPI_GENERIC_ADDRESS) * i); AbsoluteOffset = Offset + ArrayOffset; - Array = (UINT8 *) SubTable + ArrayOffset; + Array = (UINT8 *) Subtable + ArrayOffset; Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array, - SubTable->Length, AcpiDmTableInfoDbg2Addr); + Subtable->Length, AcpiDmTableInfoDbg2Addr); if (ACPI_FAILURE (Status)) { return; @@ -1005,15 +1005,15 @@ AcpiDmDumpDbg2 ( /* Dump the AddressSize array */ - for (i = 0; i < SubTable->RegisterCount; i++) + for (i = 0; i < Subtable->RegisterCount; i++) { - ArrayOffset = SubTable->AddressSizeOffset + + ArrayOffset = Subtable->AddressSizeOffset + (sizeof (UINT32) * i); AbsoluteOffset = Offset + ArrayOffset; - Array = (UINT8 *) SubTable + ArrayOffset; + Array = (UINT8 *) Subtable + ArrayOffset; Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array, - SubTable->Length, AcpiDmTableInfoDbg2Size); + Subtable->Length, AcpiDmTableInfoDbg2Size); if (ACPI_FAILURE (Status)) { return; @@ -1023,12 +1023,12 @@ AcpiDmDumpDbg2 ( /* Dump the Namestring (required) */ AcpiOsPrintf ("\n"); - ArrayOffset = SubTable->NamepathOffset; + ArrayOffset = Subtable->NamepathOffset; AbsoluteOffset = Offset + ArrayOffset; - Array = (UINT8 *) SubTable + ArrayOffset; + Array = (UINT8 *) Subtable + ArrayOffset; Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array, - SubTable->Length, AcpiDmTableInfoDbg2Name); + Subtable->Length, AcpiDmTableInfoDbg2Name); if (ACPI_FAILURE (Status)) { return; @@ -1036,10 +1036,10 @@ AcpiDmDumpDbg2 ( /* Dump the OemData (optional) */ - if (SubTable->OemDataOffset) + if (Subtable->OemDataOffset) { - Status = AcpiDmDumpTable (Length, Offset + SubTable->OemDataOffset, - Table, SubTable->OemDataLength, + Status = AcpiDmDumpTable (Length, Offset + Subtable->OemDataOffset, + Table, Subtable->OemDataLength, AcpiDmTableInfoDbg2OemData); if (ACPI_FAILURE (Status)) { @@ -1049,9 +1049,9 @@ AcpiDmDumpDbg2 ( /* Point to next subtable */ - Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, SubTable, - SubTable->Length); + Offset += Subtable->Length; + Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Subtable, + Subtable->Length); } } @@ -1074,7 +1074,7 @@ AcpiDmDumpDmar ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_DMAR_HEADER *SubTable; + ACPI_DMAR_HEADER *Subtable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_DMAR); ACPI_DMTABLE_INFO *InfoTable; @@ -1094,14 +1094,14 @@ AcpiDmDumpDmar ( /* Subtables */ - SubTable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset); + Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset); while (Offset < Table->Length) { /* Common subtable header */ AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, AcpiDmTableInfoDmarHdr); + Status = AcpiDmDumpTable (Length, Offset, Subtable, + Subtable->Length, AcpiDmTableInfoDmarHdr); if (ACPI_FAILURE (Status)) { return; @@ -1109,7 +1109,7 @@ AcpiDmDumpDmar ( AcpiOsPrintf ("\n"); - switch (SubTable->Type) + switch (Subtable->Type) { case ACPI_DMAR_TYPE_HARDWARE_UNIT: @@ -1144,12 +1144,12 @@ AcpiDmDumpDmar ( default: AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n", - SubTable->Type); + Subtable->Type); return; } - Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Length, InfoTable); + Status = AcpiDmDumpTable (Length, Offset, Subtable, + Subtable->Length, InfoTable); if (ACPI_FAILURE (Status)) { return; @@ -1158,16 +1158,16 @@ AcpiDmDumpDmar ( /* * Dump the optional device scope entries */ - if ((SubTable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || - (SubTable->Type == ACPI_DMAR_TYPE_NAMESPACE)) + if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE)) { /* These types do not support device scopes */ goto NextSubtable; } - ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, SubTable, ScopeOffset); - while (ScopeOffset < SubTable->Length) + ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset); + while (ScopeOffset < Subtable->Length) { AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable, @@ -1208,9 +1208,9 @@ AcpiDmDumpDmar ( NextSubtable: /* Point to next subtable */ - Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, SubTable, - SubTable->Length); + Offset += Subtable->Length; + Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable, + Subtable->Length); } } @@ -1343,7 +1343,7 @@ AcpiDmDumpEinj ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_WHEA_HEADER *SubTable; + ACPI_WHEA_HEADER *Subtable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_EINJ); @@ -1358,11 +1358,11 @@ AcpiDmDumpEinj ( /* Subtables */ - SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset); + Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset); while (Offset < Table->Length) { AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Length, Offset, SubTable, + Status = AcpiDmDumpTable (Length, Offset, Subtable, sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0); if (ACPI_FAILURE (Status)) { @@ -1372,7 +1372,7 @@ AcpiDmDumpEinj ( /* Point to next subtable (each subtable is of fixed length) */ Offset += sizeof (ACPI_WHEA_HEADER); - SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, SubTable, + Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Subtable, sizeof (ACPI_WHEA_HEADER)); } } @@ -1396,7 +1396,7 @@ AcpiDmDumpErst ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_WHEA_HEADER *SubTable; + ACPI_WHEA_HEADER *Subtable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_ERST); @@ -1411,11 +1411,11 @@ AcpiDmDumpErst ( /* Subtables */ - SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset); + Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset); while (Offset < Table->Length) { AcpiOsPrintf ("\n"); - Status = AcpiDmDumpTable (Length, Offset, SubTable, + Status = AcpiDmDumpTable (Length, Offset, Subtable, sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoErst0); if (ACPI_FAILURE (Status)) { @@ -1425,7 +1425,7 @@ AcpiDmDumpErst ( /* Point to next subtable (each subtable is of fixed length) */ Offset += sizeof (ACPI_WHEA_HEADER); - SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, SubTable, + Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Subtable, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Fri Jan 5 02:15:06 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB575EA7046; Fri, 5 Jan 2018 02:15:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 84F226E09E; Fri, 5 Jan 2018 02:15:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w052F5aF007970; Fri, 5 Jan 2018 02:15:05 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w052F53G007968; Fri, 5 Jan 2018 02:15:05 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201801050215.w052F53G007968@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 5 Jan 2018 02:15:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327568 - in stable/11/sys/dev: ahci usb/controller X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys/dev: ahci usb/controller X-SVN-Commit-Revision: 327568 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 02:15:06 -0000 Author: mav Date: Fri Jan 5 02:15:05 2018 New Revision: 327568 URL: https://svnweb.freebsd.org/changeset/base/327568 Log: MFC r327094: Add AHCI/XHCI device IDs found on AMD Ryzen+B350 system. Modified: stable/11/sys/dev/ahci/ahci_pci.c stable/11/sys/dev/usb/controller/xhci_pci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ahci/ahci_pci.c ============================================================================== --- stable/11/sys/dev/ahci/ahci_pci.c Fri Jan 5 01:46:41 2018 (r327567) +++ stable/11/sys/dev/ahci/ahci_pci.c Fri Jan 5 02:15:05 2018 (r327568) @@ -68,6 +68,7 @@ static const struct { AHCI_Q_ATI_PMP_BUG | AHCI_Q_1MSI}, /* Not sure SB8x0/SB9x0 needs this quirk. Be conservative though */ {0x43951002, 0x00, "AMD SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG}, + {0x43b71022, 0x00, "AMD 300 Series", 0}, {0x78001022, 0x00, "AMD Hudson-2", 0}, {0x78011022, 0x00, "AMD Hudson-2", 0}, {0x78021022, 0x00, "AMD Hudson-2", 0}, Modified: stable/11/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- stable/11/sys/dev/usb/controller/xhci_pci.c Fri Jan 5 01:46:41 2018 (r327567) +++ stable/11/sys/dev/usb/controller/xhci_pci.c Fri Jan 5 02:15:05 2018 (r327568) @@ -95,6 +95,10 @@ xhci_pci_match(device_t self) uint32_t device_id = pci_get_devid(self); switch (device_id) { + case 0x145c1022: + return ("AMD KERNCZ USB 3.0 controller"); + case 0x43bb1022: + return ("AMD 300 Series USB 3.0 controller"); case 0x78141022: return ("AMD FCH USB 3.0 controller"); From owner-svn-src-stable-11@freebsd.org Fri Jan 5 10:04:15 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8CD1EC198B; Fri, 5 Jan 2018 10:04:15 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 27B4D14C0; Fri, 5 Jan 2018 10:04:14 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05A4Dgf005986; Fri, 5 Jan 2018 10:04:13 GMT (envelope-from fsu@FreeBSD.org) Received: (from fsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05A4DC3005985; Fri, 5 Jan 2018 10:04:13 GMT (envelope-from fsu@FreeBSD.org) Message-Id: <201801051004.w05A4DC3005985@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fsu set sender to fsu@FreeBSD.org using -f From: Fedor Uporov Date: Fri, 5 Jan 2018 10:04:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327585 - stable/11/sys/fs/ext2fs X-SVN-Group: stable-11 X-SVN-Commit-Author: fsu X-SVN-Commit-Paths: stable/11/sys/fs/ext2fs X-SVN-Commit-Revision: 327585 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 10:04:16 -0000 Author: fsu Date: Fri Jan 5 10:04:13 2018 New Revision: 327585 URL: https://svnweb.freebsd.org/changeset/base/327585 Log: MFC r326807: Fix extattr getters in case of neither uio nor buffer was not passed to VOP_*. Approved by: pfg (mentor) Differential Revision: https://reviews.freebsd.org/D13359 Modified: stable/11/sys/fs/ext2fs/ext2_extattr.c Modified: stable/11/sys/fs/ext2fs/ext2_extattr.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_extattr.c Fri Jan 5 10:04:01 2018 (r327584) +++ stable/11/sys/fs/ext2fs/ext2_extattr.c Fri Jan 5 10:04:13 2018 (r327585) @@ -218,9 +218,10 @@ ext2_extattr_inode_list(struct inode *ip, int attrname return (ENOTSUP); } - if (uio == NULL) + if (size != NULL) *size += name_len + 1; - else { + + if (uio != NULL) { char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); name[0] = name_len; memcpy(&name[1], attr_name, name_len); @@ -284,9 +285,10 @@ ext2_extattr_block_list(struct inode *ip, int attrname return (ENOTSUP); } - if (uio == NULL) + if (size != NULL) *size += name_len + 1; - else { + + if (uio != NULL) { char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); name[0] = name_len; memcpy(&name[1], attr_name, name_len); @@ -359,12 +361,12 @@ ext2_extattr_inode_get(struct inode *ip, int attrnames if (strlen(name) == name_len && 0 == strncmp(attr_name, name, name_len)) { - if (uio == NULL) + if (size != NULL) *size += entry->e_value_size; - else { + + if (uio != NULL) error = uiomove(((char *)EXT2_IFIRST(header)) + entry->e_value_offs, entry->e_value_size, uio); - } brelse(bp); return (error); @@ -426,12 +428,12 @@ ext2_extattr_block_get(struct inode *ip, int attrnames if (strlen(name) == name_len && 0 == strncmp(attr_name, name, name_len)) { - if (uio == NULL) + if (size != NULL) *size += entry->e_value_size; - else { + + if (uio != NULL) error = uiomove(bp->b_data + entry->e_value_offs, entry->e_value_size, uio); - } brelse(bp); return (error); From owner-svn-src-stable-11@freebsd.org Fri Jan 5 11:45:41 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66C0CEC5D1B; Fri, 5 Jan 2018 11:45:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E6CE643FD; Fri, 5 Jan 2018 11:45:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05BjeDm048171; Fri, 5 Jan 2018 11:45:40 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05Bjeio048170; Fri, 5 Jan 2018 11:45:40 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801051145.w05Bjeio048170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 5 Jan 2018 11:45:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327586 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 327586 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 11:45:41 -0000 Author: kib Date: Fri Jan 5 11:45:40 2018 New Revision: 327586 URL: https://svnweb.freebsd.org/changeset/base/327586 Log: MFC r327354: Style. Modified: stable/11/sys/vm/vm_swapout.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_swapout.c ============================================================================== --- stable/11/sys/vm/vm_swapout.c Fri Jan 5 10:04:13 2018 (r327585) +++ stable/11/sys/vm/vm_swapout.c Fri Jan 5 11:45:40 2018 (r327586) @@ -554,16 +554,14 @@ vm_thread_swapin(struct thread *td) { vm_object_t ksobj; vm_page_t ma[KSTACK_MAX_PAGES]; - int pages; + int a, count, i, j, pages, rv; pages = td->td_kstack_pages; ksobj = td->td_kstack_obj; VM_OBJECT_WLOCK(ksobj); (void)vm_page_grab_pages(ksobj, 0, VM_ALLOC_NORMAL | VM_ALLOC_WIRED, ma, pages); - for (int i = 0; i < pages;) { - int j, a, count, rv; - + for (i = 0; i < pages;) { vm_page_assert_xbusied(ma[i]); if (ma[i]->valid == VM_PAGE_BITS_ALL) { vm_page_xunbusy(ma[i]); @@ -640,13 +638,9 @@ faultin(struct proc *p) void swapper(void) { - struct proc *p; + struct proc *p, *pp; struct thread *td; - struct proc *pp; - int slptime; - int swtime; - int ppri; - int pri; + int ppri, pri, slptime, swtime; loop: if (vm_page_count_min()) { @@ -733,15 +727,15 @@ swapout_procs(int action) { struct proc *p; struct thread *td; - int didswap = 0; + struct vmspace *vm; + int minslptime, slptime; + bool didswap; + minslptime = 100000; + didswap = false; retry: sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { - struct vmspace *vm; - int minslptime = 100000; - int slptime; - PROC_LOCK(p); /* * Watch out for a process in @@ -791,17 +785,20 @@ retry: goto nextproc; /* - * only aiod changes vmspace, however it will be + * Only aiod changes vmspace. However, it will be * skipped because of the if statement above checking - * for P_SYSTEM + * for P_SYSTEM. */ - if ((p->p_flag & (P_INMEM|P_SWAPPINGOUT|P_SWAPPINGIN)) != P_INMEM) + if ((p->p_flag & (P_INMEM | P_SWAPPINGOUT | P_SWAPPINGIN)) != + P_INMEM) goto nextproc; switch (p->p_state) { default: - /* Don't swap out processes in any sort - * of 'special' state. */ + /* + * Don't swap out processes in any sort + * of 'special' state. + */ break; case PRS_NORMAL: @@ -844,9 +841,9 @@ retry: * idle processes >= swap_idle_threshold2, * then swap the process out. */ - if (((action & VM_SWAP_NORMAL) == 0) && - (((action & VM_SWAP_IDLE) == 0) || - (slptime < swap_idle_threshold2))) { + if ((action & VM_SWAP_NORMAL) == 0 && + ((action & VM_SWAP_IDLE) == 0 || + slptime < swap_idle_threshold2)) { thread_unlock(td); goto nextproc; } @@ -861,12 +858,12 @@ retry: * or if this process is idle and the system is * configured to swap proactively, swap it out. */ - if ((action & VM_SWAP_NORMAL) || - ((action & VM_SWAP_IDLE) && - (minslptime > swap_idle_threshold2))) { + if ((action & VM_SWAP_NORMAL) != 0 || + ((action & VM_SWAP_IDLE) != 0 && + minslptime > swap_idle_threshold2)) { _PRELE(p); if (swapout(p) == 0) - didswap++; + didswap = true; PROC_UNLOCK(p); vm_map_unlock(&vm->vm_map); vmspace_free(vm); @@ -936,9 +933,10 @@ swapout(struct proc *p) P_INMEM, ("swapout: lost a swapout race?")); /* - * remember the process resident count + * Remember the resident count. */ p->p_vmspace->vm_swrss = vmspace_resident_count(p->p_vmspace); + /* * Check and mark all threads before we proceed. */ From owner-svn-src-stable-11@freebsd.org Fri Jan 5 11:46:46 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9533EC5DF5; Fri, 5 Jan 2018 11:46:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 73C6664543; Fri, 5 Jan 2018 11:46:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05BkjZ0048263; Fri, 5 Jan 2018 11:46:45 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05BkjOQ048262; Fri, 5 Jan 2018 11:46:45 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801051146.w05BkjOQ048262@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 5 Jan 2018 11:46:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327587 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 327587 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 11:46:46 -0000 Author: kib Date: Fri Jan 5 11:46:45 2018 New Revision: 327587 URL: https://svnweb.freebsd.org/changeset/base/327587 Log: MFC r327359: Do not lock vm map in swapout_procs(). Modified: stable/11/sys/vm/vm_swapout.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_swapout.c ============================================================================== --- stable/11/sys/vm/vm_swapout.c Fri Jan 5 11:45:40 2018 (r327586) +++ stable/11/sys/vm/vm_swapout.c Fri Jan 5 11:46:45 2018 (r327587) @@ -727,7 +727,6 @@ swapout_procs(int action) { struct proc *p; struct thread *td; - struct vmspace *vm; int minslptime, slptime; bool didswap; @@ -761,24 +760,6 @@ retry: PROC_UNLOCK(p); sx_sunlock(&allproc_lock); - /* - * Do not swapout a process that - * is waiting for VM data - * structures as there is a possible - * deadlock. Test this first as - * this may block. - * - * Lock the map until swapout - * finishes, or a thread of this - * process may attempt to alter - * the map. - */ - vm = vmspace_acquire_ref(p); - if (vm == NULL) - goto nextproc2; - if (!vm_map_trylock(&vm->vm_map)) - goto nextproc1; - PROC_LOCK(p); if (p->p_lock != 1 || (p->p_flag & (P_STOPPED_SINGLE | P_TRACED | P_SYSTEM)) != 0) @@ -865,17 +846,11 @@ retry: if (swapout(p) == 0) didswap = true; PROC_UNLOCK(p); - vm_map_unlock(&vm->vm_map); - vmspace_free(vm); goto retry; } } nextproc: PROC_UNLOCK(p); - vm_map_unlock(&vm->vm_map); -nextproc1: - vmspace_free(vm); -nextproc2: sx_slock(&allproc_lock); PRELE(p); } From owner-svn-src-stable-11@freebsd.org Fri Jan 5 16:04:58 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16A11EB18FF; Fri, 5 Jan 2018 16:04:58 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E0A286FCE3; Fri, 5 Jan 2018 16:04:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05G4uOg058127; Fri, 5 Jan 2018 16:04:56 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05G4uRi058124; Fri, 5 Jan 2018 16:04:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201801051604.w05G4uRi058124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 5 Jan 2018 16:04:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327588 - in stable/11/sys/dev: hpt27xx hptnr hptrr X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in stable/11/sys/dev: hpt27xx hptnr hptrr X-SVN-Commit-Revision: 327588 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 16:04:58 -0000 Author: emaste Date: Fri Jan 5 16:04:56 2018 New Revision: 327588 URL: https://svnweb.freebsd.org/changeset/base/327588 Log: MFC r327497, r327498: fix memory disclosure in hpt* ioctls r327497: hpt27xx: plug info leak in hpt_ioctl The hpt27xx ioctl handler allocates a buffer without M_ZERO and calls hpt_do_ioctl(), which might not overwrite the entire buffer. Also zero bytesReturned in case it is not written by hpt_do_ioctl(). The hpt27xx device has permissions only for root so this is not urgent, and the fix can be MFCd and considered for a future EN. Reported by: Ilja van Sprundel Submitted by: Domagoj Stolfa (M_ZERO) r327498: hpt{nr,rr}: plug info leak in hpt_ioctl The hpt{nr,rr} ioctl handler allocates a buffer without M_ZERO and calls hpt_do_ioctl(), which might not overwrite the entire buffer. Also zero bytesReturned in case it is not written by hpt_do_ioctl(). The hpt27{nr,rr} device has permissions only for root so this is not urgent, and the fix can be MFCd and considered for a future EN. The same issue was reported in the hpt27xx driver by Ilja Van Sprundel. Security: memory disclosure in root-only ioctls Sponsored by: The FreeBSD Foundation Modified: stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c stable/11/sys/dev/hptnr/hptnr_osm_bsd.c stable/11/sys/dev/hptrr/hptrr_osm_bsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c ============================================================================== --- stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c Fri Jan 5 11:46:45 2018 (r327587) +++ stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c Fri Jan 5 16:04:56 2018 (r327588) @@ -1402,7 +1402,7 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, cad { PHPT_IOCTL_PARAM piop=(PHPT_IOCTL_PARAM)data; IOCTL_ARG ioctl_args; - HPT_U32 bytesReturned; + HPT_U32 bytesReturned = 0; switch (cmd){ case HPT_DO_IOCONTROL: @@ -1432,7 +1432,7 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, cad } if (ioctl_args.nOutBufferSize) { - ioctl_args.lpOutBuffer = malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK); + ioctl_args.lpOutBuffer = malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK | M_ZERO); if (!ioctl_args.lpOutBuffer) goto invalid; } Modified: stable/11/sys/dev/hptnr/hptnr_osm_bsd.c ============================================================================== --- stable/11/sys/dev/hptnr/hptnr_osm_bsd.c Fri Jan 5 11:46:45 2018 (r327587) +++ stable/11/sys/dev/hptnr/hptnr_osm_bsd.c Fri Jan 5 16:04:56 2018 (r327588) @@ -1584,7 +1584,7 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, cad { PHPT_IOCTL_PARAM piop=(PHPT_IOCTL_PARAM)data; IOCTL_ARG ioctl_args; - HPT_U32 bytesReturned; + HPT_U32 bytesReturned = 0; switch (cmd){ case HPT_DO_IOCONTROL: @@ -1614,7 +1614,7 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, cad } if (ioctl_args.nOutBufferSize) { - ioctl_args.lpOutBuffer = malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK); + ioctl_args.lpOutBuffer = malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK | M_ZERO); if (!ioctl_args.lpOutBuffer) goto invalid; } Modified: stable/11/sys/dev/hptrr/hptrr_osm_bsd.c ============================================================================== --- stable/11/sys/dev/hptrr/hptrr_osm_bsd.c Fri Jan 5 11:46:45 2018 (r327587) +++ stable/11/sys/dev/hptrr/hptrr_osm_bsd.c Fri Jan 5 16:04:56 2018 (r327588) @@ -1231,7 +1231,7 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, cad { PHPT_IOCTL_PARAM piop=(PHPT_IOCTL_PARAM)data; IOCTL_ARG ioctl_args; - HPT_U32 bytesReturned; + HPT_U32 bytesReturned = 0; switch (cmd){ case HPT_DO_IOCONTROL: @@ -1261,7 +1261,7 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, cad } if (ioctl_args.nOutBufferSize) { - ioctl_args.lpOutBuffer = malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK); + ioctl_args.lpOutBuffer = malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK | M_ZERO); if (!ioctl_args.lpOutBuffer) goto invalid; } From owner-svn-src-stable-11@freebsd.org Fri Jan 5 17:21:53 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 34D12EB5453; Fri, 5 Jan 2018 17:21:53 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F2E237356F; Fri, 5 Jan 2018 17:21:52 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05HLqY4089710; Fri, 5 Jan 2018 17:21:52 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05HLqAR089708; Fri, 5 Jan 2018 17:21:52 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801051721.w05HLqAR089708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Fri, 5 Jan 2018 17:21:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327589 - stable/11/sys/dev/txp X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/sys/dev/txp X-SVN-Commit-Revision: 327589 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 17:21:53 -0000 Author: pfg Date: Fri Jan 5 17:21:51 2018 New Revision: 327589 URL: https://svnweb.freebsd.org/changeset/base/327589 Log: MFC r327329: dev/txp: Update if_txpreg.h to match OpenBSD's version. Resolve a minor mismatch: TXP_CMD_READ_VERSION instead of TXP_CMD_VERSIONS_READ. Curiously the later is defined but not used in OpenBSD. Obtained from: OpenBSD (CVS 1.31-1.34) Modified: stable/11/sys/dev/txp/if_txp.c stable/11/sys/dev/txp/if_txpreg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/txp/if_txp.c ============================================================================== --- stable/11/sys/dev/txp/if_txp.c Fri Jan 5 16:04:56 2018 (r327588) +++ stable/11/sys/dev/txp/if_txp.c Fri Jan 5 17:21:51 2018 (r327589) @@ -371,7 +371,7 @@ txp_attach(device_t dev) * diagnose sleep image specific issues. */ rsp = NULL; - if (txp_ext_command(sc, TXP_CMD_READ_VERSION, 0, 0, 0, NULL, 0, + if (txp_ext_command(sc, TXP_CMD_VERSIONS_READ, 0, 0, 0, NULL, 0, &rsp, TXP_CMD_WAIT)) { device_printf(dev, "can not read sleep image version\n"); error = ENXIO; Modified: stable/11/sys/dev/txp/if_txpreg.h ============================================================================== --- stable/11/sys/dev/txp/if_txpreg.h Fri Jan 5 16:04:56 2018 (r327588) +++ stable/11/sys/dev/txp/if_txpreg.h Fri Jan 5 17:21:51 2018 (r327589) @@ -1,4 +1,4 @@ -/* $OpenBSD: if_txpreg.h,v 1.30 2001/06/23 04:18:02 jason Exp $ */ +/* $OpenBSD: if_txpreg.h,v 1.34 2001/11/05 17:25:58 art Exp $ */ /* $FreeBSD$ */ /*- @@ -164,7 +164,7 @@ #define TXP_CMD_FILTER_TABLE_MODE_WRITE 0x3d #define TXP_CMD_FILTER_TCL_WRITE 0x3e #define TXP_CMD_FILTER_TBL_READ 0x3f -#define TXP_CMD_READ_VERSION 0x43 +#define TXP_CMD_VERSIONS_READ 0x43 #define TXP_CMD_FILTER_DEFINE 0x45 #define TXP_CMD_ADD_WAKEUP_PKT 0x46 #define TXP_CMD_ADD_SLEEP_PKT 0x47 @@ -382,6 +382,7 @@ struct txp_frag_desc { #define FRAG_FLAGS_TYPE_OPT 0x03 /* type: options */ #define FRAG_FLAGS_TYPE_RX 0x04 /* type: command */ #define FRAG_FLAGS_TYPE_RESP 0x05 /* type: response */ +#define FRAG_FLAGS_VALID 0x80 /* valid descriptor */ struct txp_opt_desc { uint8_t opt_desctype:3, From owner-svn-src-stable-11@freebsd.org Fri Jan 5 19:12:38 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A82D3EBA9EC; Fri, 5 Jan 2018 19:12:38 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6193A78C2B; Fri, 5 Jan 2018 19:12:38 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05JCbJH038709; Fri, 5 Jan 2018 19:12:37 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05JCb9g038703; Fri, 5 Jan 2018 19:12:37 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801051912.w05JCb9g038703@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Fri, 5 Jan 2018 19:12:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327592 - in stable/11: etc etc/defaults sbin/mdmfs X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11: etc etc/defaults sbin/mdmfs X-SVN-Commit-Revision: 327592 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 19:12:38 -0000 Author: ian Date: Fri Jan 5 19:12:36 2018 New Revision: 327592 URL: https://svnweb.freebsd.org/changeset/base/327592 Log: MFC r319987, r324107-r324108 r319987 (MFC'd just to make following changes apply cleanly): Replace md(4) usage in diskless(8) script rc.initdiskless with tmpfs(5). Need to multiply the size of the disk passed to mount_md by 512 as mdmfs expects number of 512-byte blocks while tmpfs size option wants number of bytes. r324107: Enhance mdmfs(8) to work with tmpfs(5). Existing scripts and associated config such as rc.initdiskless, rc.d/var, and others, use mdmfs to create memory filesystems. That program accepts a size argument which allows SI suffixes and treats an unsuffixed number as a count of 512 byte sectors. That makes it difficult to convert existing scripts to use tmpfs instead of mdmfs, because tmpfs treats unsuffixed numbers as a count of bytes. The script logic to deal with existing user config that might include suffixed and unsuffixed numbers is... unpleasant. Also, there is no g'tee that tmpfs will be available. It is sometimes configured out of small-resource embedded systems to save memory and flash storage space. These changes enhance mdmfs(8) so that it accepts two new values for the 'md-device' arg: 'tmpfs' and 'auto'. With tmpfs, the program always uses tmpfs(5) (and fails if it's not available). With 'auto' the program prefers tmpfs, but falls back to using md(4) if tmpfs isn't available. It also handles the -s argument so that the mdconfig interpetation of unsuffixed numbers applies when tmpfs is used as well, so that existing user config keeps working after a switch to tmpfs. A new rc setting, mfs_type, is added to etc/defaults/rc.conf to let users force the use of tmpfs or md; the default value is "auto". Differential Revision: https://reviews.freebsd.org/D12301 r324108: Remove spurious $flags; it's a paste-o from copying the line from rc.subr. Also, add a comment documenting the args passed to mount_md(). Modified: stable/11/etc/defaults/rc.conf stable/11/etc/rc.initdiskless stable/11/etc/rc.subr stable/11/sbin/mdmfs/mdmfs.8 stable/11/sbin/mdmfs/mdmfs.c Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/defaults/rc.conf ============================================================================== --- stable/11/etc/defaults/rc.conf Fri Jan 5 18:32:46 2018 (r327591) +++ stable/11/etc/defaults/rc.conf Fri Jan 5 19:12:36 2018 (r327592) @@ -51,6 +51,7 @@ tmpmfs_flags="-S" # Extra mdmfs options for the mfs /t varmfs="AUTO" # Set to YES to always create an mfs /var, NO to never varsize="32m" # Size of mfs /var if created varmfs_flags="-S" # Extra mount options for the mfs /var +mfs_type="auto" # "md", "tmpfs", "auto" to prefer tmpfs with md as fallback populate_var="AUTO" # Set to YES to always (re)populate /var, NO to never cleanvar_enable="YES" # Clean the /var directory local_startup="/usr/local/etc/rc.d" # startup script dirs. Modified: stable/11/etc/rc.initdiskless ============================================================================== --- stable/11/etc/rc.initdiskless Fri Jan 5 18:32:46 2018 (r327591) +++ stable/11/etc/rc.initdiskless Fri Jan 5 19:12:36 2018 (r327592) @@ -195,10 +195,11 @@ handle_remount() { # $1 = mount point to_umount="$b ${to_umount}" } -# Create a generic memory disk -# +# Create a generic memory disk. +# The 'auto' parameter will attempt to use tmpfs(5), falls back to md(4). +# $1 is size in 512-byte sectors, $2 is the mount point. mount_md() { - /sbin/mdmfs -S -i 4096 -s $1 -M md $2 + /sbin/mdmfs -s $1 auto $2 } # Create the memory filesystem if it has not already been created Modified: stable/11/etc/rc.subr ============================================================================== --- stable/11/etc/rc.subr Fri Jan 5 18:32:46 2018 (r327591) +++ stable/11/etc/rc.subr Fri Jan 5 19:12:36 2018 (r327592) @@ -1834,7 +1834,7 @@ mount_md() if [ -n "$3" ]; then flags="$3" fi - /sbin/mdmfs $flags -s $1 md $2 + /sbin/mdmfs $flags -s $1 ${mfs_type} $2 } # Code common to scripts that need to load a kernel module Modified: stable/11/sbin/mdmfs/mdmfs.8 ============================================================================== --- stable/11/sbin/mdmfs/mdmfs.8 Fri Jan 5 18:32:46 2018 (r327591) +++ stable/11/sbin/mdmfs/mdmfs.8 Fri Jan 5 19:12:36 2018 (r327592) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 9, 2016 +.Dd September 9, 2017 .Dt MDMFS 8 .Os .Sh NAME @@ -33,7 +33,9 @@ .Nm mount_mfs .Nd configure and mount an in-memory file system using the .Xr md 4 -driver +driver or the +.Xr tmpfs 5 +filesystem .Sh SYNOPSIS .Nm .Op Fl DLlMNnPStTUX @@ -63,9 +65,13 @@ utility is designed to be a work-alike and look-alike .Xr mount_mfs 8 . The end result is essentially the same, but is accomplished in a completely different way. -The +Based on +.Ar md-device , +the .Nm -utility configures an +utility either creates a +.Xr tmpfs 5 +filesystem, or it configures an .Xr md 4 disk using .Xr mdconfig 8 , @@ -81,6 +87,44 @@ compressed disk images, as long as the kernel supports All the command line options are passed to the appropriate program at the appropriate stage in order to achieve the desired effect. .Pp +When +.Ar md-device +is `auto', +.Nm +uses +.Xr tmpfs 5 +if it is present in the kernel or can be loaded as a module, +otherwise it falls back to using +.Xr md 4 +auto-unit as if `md' had been specified. +.Pp +When +.Ar md-device +is `tmpfs', +.Nm +mounts a +.Xr tmpfs 5 +filesystem, translating the +.Fl s +size option, if present, into a `-o size=' mount option. +Any +.Fl o +options on the command line are passed through to the +.Xr tmpfs 5 +mount. +Options specific to +.Xr mdconfig 8 +or +.Xr newfs 8 +are ignored. +.Pp +When +.Ar md-device +does not result in +.Xr tmpfs 5 +being used, then an +.Xr md 4 +device is configured instead. By default, .Nm creates a swap-based @@ -218,14 +262,10 @@ is .Em not specified. That is, -this will work for the default swap-backed -.Pq Dv MD_SWAP -disks, -and the optional -.Pq Fl M -.Xr malloc 9 -backed disks -.Pq Dv MD_MALLOC . +this will work when the backing storage is some form of +memory, as opposed to a fixed-size file. +The size may include the usual SI suffixes (k, m, g, t, p). +A number without a suffix is interpreted as a count of 512-byte sectors. .It Fl t Turn on the TRIM enable flag for .Xr newfs 8 . @@ -391,6 +431,7 @@ was given on the command line. .Sh SEE ALSO .Xr md 4 , .Xr fstab 5 , +.Xr tmpfs 5 , .Xr mdconfig 8 , .Xr mount 8 , .Xr newfs 8 Modified: stable/11/sbin/mdmfs/mdmfs.c ============================================================================== --- stable/11/sbin/mdmfs/mdmfs.c Fri Jan 5 18:32:46 2018 (r327591) +++ stable/11/sbin/mdmfs/mdmfs.c Fri Jan 5 19:12:36 2018 (r327592) @@ -34,15 +34,19 @@ __FBSDID("$FreeBSD$"); #include +#include #include +#include #include #include #include #include #include +#include #include #include +#include #include #include #include @@ -78,7 +82,8 @@ static void debugprintf(const char *, ...) __printfli static void do_mdconfig_attach(const char *, const enum md_types); static void do_mdconfig_attach_au(const char *, const enum md_types); static void do_mdconfig_detach(void); -static void do_mount(const char *, const char *); +static void do_mount_md(const char *, const char *); +static void do_mount_tmpfs(const char *, const char *); static void do_mtptsetup(const char *, struct mtpt_info *); static void do_newfs(const char *); static void extract_ugid(const char *, struct mtpt_info *); @@ -89,14 +94,15 @@ int main(int argc, char **argv) { struct mtpt_info mi; /* Mountpoint info. */ + intmax_t mdsize; char *mdconfig_arg, *newfs_arg, /* Args to helper programs. */ *mount_arg; enum md_types mdtype; /* The type of our memory disk. */ - bool have_mdtype; + bool have_mdtype, mlmac; bool detach, softdep, autounit, newfs; - char *mtpoint, *unitstr; + const char *mtpoint, *size_arg, *unitstr; char *p; - int ch; + int ch, idx; void *set; unsigned long ul; @@ -105,6 +111,7 @@ main(int argc, char **argv) detach = true; softdep = true; autounit = false; + mlmac = false; newfs = true; have_mdtype = false; mdtype = MD_SWAP; @@ -119,6 +126,7 @@ main(int argc, char **argv) mdconfig_arg = strdup(""); newfs_arg = strdup(""); mount_arg = strdup(""); + size_arg = NULL; /* If we were started as mount_mfs or mfs, imply -C. */ if (strcmp(getprogname(), "mount_mfs") == 0 || @@ -175,6 +183,7 @@ main(int argc, char **argv) loudsubs = true; break; case 'l': + mlmac = true; argappend(&newfs_arg, "-l"); break; case 'M': @@ -213,7 +222,7 @@ main(int argc, char **argv) softdep = false; break; case 's': - argappend(&mdconfig_arg, "-s %s", optarg); + size_arg = optarg; break; case 't': argappend(&newfs_arg, "-t"); @@ -242,42 +251,107 @@ main(int argc, char **argv) if (argc < 2) usage(); - /* Derive 'unit' (global). */ - unitstr = argv[0]; - if (strncmp(unitstr, "/dev/", 5) == 0) - unitstr += 5; - if (strncmp(unitstr, mdname, mdnamelen) == 0) - unitstr += mdnamelen; - if (!isdigit(*unitstr)) { - autounit = true; - unit = -1; - mdsuffix = unitstr; - } else { - ul = strtoul(unitstr, &p, 10); - if (ul == ULONG_MAX) - errx(1, "bad device unit: %s", unitstr); - unit = ul; - mdsuffix = p; /* can be empty */ + /* + * Historically our size arg was passed directly to mdconfig, which + * treats a number without a suffix as a count of 512-byte sectors; + * tmpfs would treat it as a count of bytes. To get predictable + * behavior for 'auto' we document that the size always uses mdconfig + * rules. To make that work, decode the size here so it can be passed + * to either tmpfs or mdconfig as a count of bytes. + */ + if (size_arg != NULL) { + mdsize = (intmax_t)strtoumax(size_arg, &p, 0); + if (p == size_arg || (p[0] != 0 && p[1] != 0) || mdsize < 0) + errx(1, "invalid size '%s'", size_arg); + switch (*p) { + case 'p': + case 'P': + mdsize *= 1024; + case 't': + case 'T': + mdsize *= 1024; + case 'g': + case 'G': + mdsize *= 1024; + case 'm': + case 'M': + mdsize *= 1024; + case 'k': + case 'K': + mdsize *= 1024; + case 'b': + case 'B': + break; + case '\0': + mdsize *= 512; + break; + default: + errx(1, "invalid size suffix on '%s'", size_arg); + } } + /* + * Based on the command line 'md-device' either mount a tmpfs filesystem + * or configure the md device then format and mount a filesystem on it. + * If the device is 'auto' use tmpfs if it is available and there is no + * request for multilabel MAC (which tmpfs does not support). + */ + unitstr = argv[0]; mtpoint = argv[1]; - if (!have_mdtype) - mdtype = MD_SWAP; - if (softdep) - argappend(&newfs_arg, "-U"); - if (mdtype != MD_VNODE && !newfs) - errx(1, "-P requires a vnode-backed disk"); - /* Do the work. */ - if (detach && !autounit) - do_mdconfig_detach(); - if (autounit) - do_mdconfig_attach_au(mdconfig_arg, mdtype); - else - do_mdconfig_attach(mdconfig_arg, mdtype); - if (newfs) - do_newfs(newfs_arg); - do_mount(mount_arg, mtpoint); + if (strcmp(unitstr, "auto") == 0) { + if (mlmac) + idx = -1; /* Must use md for mlmac. */ + else if ((idx = modfind("tmpfs")) == -1) + idx = kldload("tmpfs"); + if (idx == -1) + unitstr = "md"; + else + unitstr = "tmpfs"; + } + + if (strcmp(unitstr, "tmpfs") == 0) { + if (size_arg != NULL && mdsize != 0) + argappend(&mount_arg, "-o size=%jd", mdsize); + do_mount_tmpfs(mount_arg, mtpoint); + } else { + if (size_arg != NULL) + argappend(&mdconfig_arg, "-s %jdB", mdsize); + if (strncmp(unitstr, "/dev/", 5) == 0) + unitstr += 5; + if (strncmp(unitstr, mdname, mdnamelen) == 0) + unitstr += mdnamelen; + if (!isdigit(*unitstr)) { + autounit = true; + unit = -1; + mdsuffix = unitstr; + } else { + ul = strtoul(unitstr, &p, 10); + if (ul == ULONG_MAX) + errx(1, "bad device unit: %s", unitstr); + unit = ul; + mdsuffix = p; /* can be empty */ + } + + if (!have_mdtype) + mdtype = MD_SWAP; + if (softdep) + argappend(&newfs_arg, "-U"); + if (mdtype != MD_VNODE && !newfs) + errx(1, "-P requires a vnode-backed disk"); + + /* Do the work. */ + if (detach && !autounit) + do_mdconfig_detach(); + if (autounit) + do_mdconfig_attach_au(mdconfig_arg, mdtype); + else + do_mdconfig_attach(mdconfig_arg, mdtype); + if (newfs) + do_newfs(newfs_arg); + do_mount_md(mount_arg, mtpoint); + } + do_mtptsetup(mtpoint, &mi); return (0); @@ -434,7 +508,7 @@ do_mdconfig_detach(void) * Mount the configured memory disk. */ static void -do_mount(const char *args, const char *mtpoint) +do_mount_md(const char *args, const char *mtpoint) { int rv; @@ -442,6 +516,19 @@ do_mount(const char *args, const char *mtpoint) mdname, unit, mdsuffix, mtpoint); if (rv) errx(1, "mount exited with error code %d", rv); +} + +/* + * Mount the configured tmpfs. + */ +static void +do_mount_tmpfs(const char *args, const char *mtpoint) +{ + int rv; + + rv = run(NULL, "%s -t tmpfs %s tmp %s", _PATH_MOUNT, args, mtpoint); + if (rv) + errx(1, "tmpfs mount exited with error code %d", rv); } /* From owner-svn-src-stable-11@freebsd.org Fri Jan 5 19:21:46 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D3B9EBB38D; Fri, 5 Jan 2018 19:21:46 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 42511796FA; Fri, 5 Jan 2018 19:21:46 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05JLjrs041017; Fri, 5 Jan 2018 19:21:45 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05JLjs9041014; Fri, 5 Jan 2018 19:21:45 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801051921.w05JLjs9041014@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Fri, 5 Jan 2018 19:21:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327594 - stable/11/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/arm/broadcom/bcm2835 X-SVN-Commit-Revision: 327594 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 19:21:46 -0000 Author: ian Date: Fri Jan 5 19:21:45 2018 New Revision: 327594 URL: https://svnweb.freebsd.org/changeset/base/327594 Log: MFC r324169: Work around bcm283x silicon bugs to make i2c repeat-start work for the most common case where it's needed -- a write followed by a read to the same slave. The i2c controller in this chip only performs complete transfers, it does not provide control over start/repeat-start/stop operations on the bus. Thus, we have gotten a full stop/start sequence rather than a repeat-start when doing a typical i2c slave access of "write address, read data". Some i2c slave devices require a repeat-start to work correctly. These changes cause the controller to do a repeat-start by pre-staging the read parameters in the controller registers immediate after the controller has latched the values for the initial write operation, but before any bytes are actually written. With the values pre-staged, when the write portion of the transfer completes, the state machine in the silicon sees a new start operation already staged and that causes it to perform a repeat-start. The key to tricking the buggy hardware into doing this is to avoid prefilling any output data in the transmit FIFO so that it is possible to catch the silicon in the state where transmit values are latched but the transmit isn't completed yet. Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscreg.h stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Fri Jan 5 19:15:24 2018 (r327593) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Fri Jan 5 19:21:45 2018 (r327594) @@ -2,6 +2,7 @@ * Copyright (c) 2001 Tsubai Masanari. * Copyright (c) 2012 Oleksandr Tymoshenko * Copyright (c) 2013 Luiz Otavio O Souza + * Copyright (c) 2017 Ian Lepore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,6 +30,57 @@ #include __FBSDID("$FreeBSD$"); +/* + * Driver for bcm2835 i2c-compatible two-wire bus, named 'BSC' on this SoC. + * + * This controller can only perform complete transfers, it does not provide + * low-level control over sending start/repeat-start/stop sequences on the bus. + * In addition, bugs in the silicon make it somewhat difficult to perform a + * repeat-start, and limit the repeat-start to a read following a write on + * the same slave device. (The i2c protocol allows a repeat start to change + * direction or not, and change slave address or not at any time.) + * + * The repeat-start bug and workaround are described in a problem report at + * https://github.com/raspberrypi/linux/issues/254 with the crucial part being + * in a comment block from a fragment of a GPU i2c driver, containing this: + * + * ----------------------------------------------------------------------------- + * - See i2c.v: The I2C peripheral samples the values for rw_bit and xfer_count + * - in the IDLE state if start is set. + * - + * - We want to generate a ReSTART not a STOP at the end of the TX phase. In + * - order to do that we must ensure the state machine goes RACK1 -> RACK2 -> + * - SRSTRT1 (not RACK1 -> RACK2 -> SSTOP1). + * - + * - So, in the RACK2 state when (TX) xfer_count==0 we must therefore have + * - already set, ready to be sampled: + * - READ ; rw_bit <= I2CC bit 0 -- must be "read" + * - ST; start <= I2CC bit 7 -- must be "Go" in order to not issue STOP + * - DLEN; xfer_count <= I2CDLEN -- must be equal to our read amount + * - + * - The plan to do this is: + * - 1. Start the sub-address write, but don't let it finish + * - (keep xfer_count > 0) + * - 2. Populate READ, DLEN and ST in preparation for ReSTART read sequence + * - 3. Let TX finish (write the rest of the data) + * - 4. Read back data as it arrives + * ----------------------------------------------------------------------------- + * + * The transfer function below scans the list of messages passed to it, looking + * for a read following a write to the same slave. When it finds that, it + * starts the write without prefilling the tx fifo, which holds xfer_count>0, + * then presets the direction, length, and start command for the following read, + * as described above. Then the tx fifo is filled and the rest of the transfer + * proceeds as normal, with the controller automatically supplying a + * repeat-start on the bus when the write operation finishes. + * + * XXX I suspect the controller may be able to do a repeat-start on any + * write->read or write->write transition, even when the slave addresses differ. + * It's unclear whether the slave address can be prestaged along with the + * direction and length while the write xfer_count is being held at zero. In + * fact, if it can't do this, then it couldn't be used to read EDID data. + */ + #include #include #include @@ -58,6 +110,14 @@ static struct ofw_compat_data compat_data[] = { {NULL, 0} }; +#define DEVICE_DEBUGF(sc, lvl, fmt, args...) \ + if ((lvl) <= (sc)->sc_debug) \ + device_printf((sc)->sc_dev, fmt, ##args) + +#define DEBUGF(sc, lvl, fmt, args...) \ + if ((lvl) <= (sc)->sc_debug) \ + printf(fmt, ##args) + static void bcm_bsc_intr(void *); static int bcm_bsc_detach(device_t); @@ -197,6 +257,9 @@ bcm_bsc_sysctl_init(struct bcm_bsc_softc *sc) SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "rise_edge_delay", CTLFLAG_RW | CTLTYPE_UINT, sc, sizeof(*sc), bcm_bsc_rise_proc, "IU", "I2C BUS rising edge delay"); + SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "debug", + CTLFLAG_RWTUN, &sc->sc_debug, 0, + "Enable debug; 1=reads/writes, 2=add starts/stops"); } static void @@ -322,6 +385,8 @@ bcm_bsc_detach(device_t dev) bus_generic_detach(dev); sc = device_get_softc(dev); + if (sc->sc_iicbus != NULL) + device_delete_child(dev, sc->sc_iicbus); mtx_destroy(&sc->sc_mtx); if (sc->sc_intrhand) bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand); @@ -334,6 +399,76 @@ bcm_bsc_detach(device_t dev) } static void +bcm_bsc_empty_rx_fifo(struct bcm_bsc_softc *sc) +{ + uint32_t status; + + /* Assumes sc_totlen > 0 and BCM_BSC_STATUS_RXD is asserted on entry. */ + do { + if (sc->sc_resid == 0) { + sc->sc_data = sc->sc_curmsg->buf; + sc->sc_dlen = sc->sc_curmsg->len; + sc->sc_resid = sc->sc_dlen; + ++sc->sc_curmsg; + } + do { + *sc->sc_data = BCM_BSC_READ(sc, BCM_BSC_DATA); + DEBUGF(sc, 1, "0x%02x ", *sc->sc_data); + ++sc->sc_data; + --sc->sc_resid; + --sc->sc_totlen; + status = BCM_BSC_READ(sc, BCM_BSC_STATUS); + } while (sc->sc_resid > 0 && (status & BCM_BSC_STATUS_RXD)); + } while (sc->sc_totlen > 0 && (status & BCM_BSC_STATUS_RXD)); +} + +static void +bcm_bsc_fill_tx_fifo(struct bcm_bsc_softc *sc) +{ + uint32_t status; + + /* Assumes sc_totlen > 0 and BCM_BSC_STATUS_TXD is asserted on entry. */ + do { + if (sc->sc_resid == 0) { + sc->sc_data = sc->sc_curmsg->buf; + sc->sc_dlen = sc->sc_curmsg->len; + sc->sc_resid = sc->sc_dlen; + ++sc->sc_curmsg; + } + do { + BCM_BSC_WRITE(sc, BCM_BSC_DATA, *sc->sc_data); + DEBUGF(sc, 1, "0x%02x ", *sc->sc_data); + ++sc->sc_data; + --sc->sc_resid; + --sc->sc_totlen; + status = BCM_BSC_READ(sc, BCM_BSC_STATUS); + } while (sc->sc_resid > 0 && (status & BCM_BSC_STATUS_TXD)); + /* + * If a repeat-start was pending and we just hit the end of a tx + * buffer, see if it's also the end of the writes that preceeded + * the repeat-start. If so, log the repeat-start and the start + * of the following read, and return because we're not writing + * anymore (and TXD will be true because there's room to write + * in the fifo). + */ + if (sc->sc_replen > 0 && sc->sc_resid == 0) { + sc->sc_replen -= sc->sc_dlen; + if (sc->sc_replen == 0) { + DEBUGF(sc, 1, " err=0\n"); + DEVICE_DEBUGF(sc, 2, "rstart 0x%02x\n", + sc->sc_curmsg->slave | 0x01); + DEVICE_DEBUGF(sc, 1, + "read 0x%02x len %d: ", + sc->sc_curmsg->slave | 0x01, + sc->sc_totlen); + sc->sc_flags |= BCM_I2C_READ; + return; + } + } + } while (sc->sc_totlen > 0 && (status & BCM_BSC_STATUS_TXD)); +} + +static void bcm_bsc_intr(void *arg) { struct bcm_bsc_softc *sc; @@ -350,35 +485,28 @@ bcm_bsc_intr(void *arg) } status = BCM_BSC_READ(sc, BCM_BSC_STATUS); + DEBUGF(sc, 4, " ", status); - /* Check for errors. */ - if (status & (BCM_BSC_STATUS_CLKT | BCM_BSC_STATUS_ERR)) { - /* Disable interrupts. */ - bcm_bsc_reset(sc); - sc->sc_flags |= BCM_I2C_ERROR; - wakeup(sc->sc_dev); - BCM_BSC_UNLOCK(sc); - return; - } + /* RXD and DONE can assert together, empty fifo before checking done. */ + if ((sc->sc_flags & BCM_I2C_READ) && (status & BCM_BSC_STATUS_RXD)) + bcm_bsc_empty_rx_fifo(sc); - if (sc->sc_flags & BCM_I2C_READ) { - while (sc->sc_resid > 0 && (status & BCM_BSC_STATUS_RXD)) { - *sc->sc_data++ = BCM_BSC_READ(sc, BCM_BSC_DATA); - sc->sc_resid--; - status = BCM_BSC_READ(sc, BCM_BSC_STATUS); - } - } else { - while (sc->sc_resid > 0 && (status & BCM_BSC_STATUS_TXD)) { - BCM_BSC_WRITE(sc, BCM_BSC_DATA, *sc->sc_data++); - sc->sc_resid--; - status = BCM_BSC_READ(sc, BCM_BSC_STATUS); - } - } - - if (status & BCM_BSC_STATUS_DONE) { + /* Check for completion. */ + if (status & (BCM_BSC_STATUS_ERRBITS | BCM_BSC_STATUS_DONE)) { + sc->sc_flags |= BCM_I2C_DONE; + if (status & BCM_BSC_STATUS_ERRBITS) + sc->sc_flags |= BCM_I2C_ERROR; /* Disable interrupts. */ bcm_bsc_reset(sc); - wakeup(sc->sc_dev); + wakeup(sc); + } else if (!(sc->sc_flags & BCM_I2C_READ)) { + /* + * Don't check for TXD until after determining whether the + * transfer is complete; TXD will be asserted along with ERR or + * DONE if there is room in the fifo. + */ + if (status & BCM_BSC_STATUS_TXD) + bcm_bsc_fill_tx_fifo(sc); } BCM_BSC_UNLOCK(sc); @@ -388,8 +516,11 @@ static int bcm_bsc_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) { struct bcm_bsc_softc *sc; - uint32_t intr, read, status; - int i, err; + struct iic_msg *endmsgs, *nxtmsg; + uint32_t readctl, status; + int err; + uint16_t curlen; + uint8_t curisread, curslave, nxtisread, nxtslave; sc = device_get_softc(dev); BCM_BSC_LOCK(sc); @@ -401,53 +532,156 @@ bcm_bsc_transfer(device_t dev, struct iic_msg *msgs, u /* Now we have control over the BSC controller. */ sc->sc_flags = BCM_I2C_BUSY; + DEVICE_DEBUGF(sc, 3, "Transfer %d msgs\n", nmsgs); + /* Clear the FIFO and the pending interrupts. */ bcm_bsc_reset(sc); + /* + * Perform all the transfers requested in the array of msgs. Note that + * it is bcm_bsc_empty_rx_fifo() and bcm_bsc_fill_tx_fifo() that advance + * sc->sc_curmsg through the array of messages, as the data from each + * message is fully consumed, but it is this loop that notices when we + * have no more messages to process. + */ err = 0; - for (i = 0; i < nmsgs; i++) { + sc->sc_resid = 0; + sc->sc_curmsg = msgs; + endmsgs = &msgs[nmsgs]; + while (sc->sc_curmsg < endmsgs) { + readctl = 0; + curslave = sc->sc_curmsg->slave >> 1; + curisread = sc->sc_curmsg->flags & IIC_M_RD; + sc->sc_replen = 0; + sc->sc_totlen = sc->sc_curmsg->len; + /* + * Scan for scatter/gather IO (same slave and direction) or + * repeat-start (read following write for the same slave). + */ + for (nxtmsg = sc->sc_curmsg + 1; nxtmsg < endmsgs; ++nxtmsg) { + nxtslave = nxtmsg->slave >> 1; + if (curslave == nxtslave) { + nxtisread = nxtmsg->flags & IIC_M_RD; + if (curisread == nxtisread) { + /* + * Same slave and direction, this + * message will be part of the same + * transfer as the previous one. + */ + sc->sc_totlen += nxtmsg->len; + continue; + } else if (curisread == IIC_M_WR) { + /* + * Read after write to same slave means + * repeat-start, remember how many bytes + * come before the repeat-start, switch + * the direction to IIC_M_RD, and gather + * up following reads to the same slave. + */ + curisread = IIC_M_RD; + sc->sc_replen = sc->sc_totlen; + sc->sc_totlen += nxtmsg->len; + continue; + } + } + break; + } + /* + * curslave and curisread temporaries from above may refer to + * the after-repstart msg, reset them to reflect sc_curmsg. + */ + curisread = (sc->sc_curmsg->flags & IIC_M_RD) ? 1 : 0; + curslave = sc->sc_curmsg->slave | curisread; + /* Write the slave address. */ - BCM_BSC_WRITE(sc, BCM_BSC_SLAVE, msgs[i].slave >> 1); + BCM_BSC_WRITE(sc, BCM_BSC_SLAVE, curslave >> 1); - /* Write the data length. */ - BCM_BSC_WRITE(sc, BCM_BSC_DLEN, msgs[i].len); + DEVICE_DEBUGF(sc, 2, "start 0x%02x\n", curslave); - sc->sc_data = msgs[i].buf; - sc->sc_resid = msgs[i].len; - if ((msgs[i].flags & IIC_M_RD) == 0) { - /* Fill up the TX FIFO. */ - status = BCM_BSC_READ(sc, BCM_BSC_STATUS); - while (sc->sc_resid > 0 && - (status & BCM_BSC_STATUS_TXD)) { - BCM_BSC_WRITE(sc, BCM_BSC_DATA, *sc->sc_data); - sc->sc_data++; - sc->sc_resid--; - status = BCM_BSC_READ(sc, BCM_BSC_STATUS); + /* + * Either set up read length and direction variables for a + * simple transfer or get the hardware started on the first + * piece of a transfer that involves a repeat-start and set up + * the read length and direction vars for the second piece. + */ + if (sc->sc_replen == 0) { + DEVICE_DEBUGF(sc, 1, "%-6s 0x%02x len %d: ", + (curisread) ? "readctl" : "write", curslave, + sc->sc_totlen); + curlen = sc->sc_totlen; + if (curisread) { + readctl = BCM_BSC_CTRL_READ; + sc->sc_flags |= BCM_I2C_READ; + } else { + readctl = 0; + sc->sc_flags &= ~BCM_I2C_READ; } - read = 0; - intr = BCM_BSC_CTRL_INTT; - sc->sc_flags &= ~BCM_I2C_READ; } else { - sc->sc_flags |= BCM_I2C_READ; - read = BCM_BSC_CTRL_READ; - intr = BCM_BSC_CTRL_INTR; + DEVICE_DEBUGF(sc, 1, "%-6s 0x%02x len %d: ", + (curisread) ? "readctl" : "write", curslave, + sc->sc_replen); + + /* + * Start the write transfer with an empty fifo and wait + * for the 'transfer active' status bit to light up; + * that indicates that the hardware has latched the + * direction and length for the write, and we can safely + * reload those registers and issue the start for the + * following read; interrupts are not enabled here. + */ + BCM_BSC_WRITE(sc, BCM_BSC_DLEN, sc->sc_replen); + BCM_BSC_WRITE(sc, BCM_BSC_CTRL, BCM_BSC_CTRL_I2CEN | + BCM_BSC_CTRL_ST); + do { + status = BCM_BSC_READ(sc, BCM_BSC_STATUS); + if (status & BCM_BSC_STATUS_ERR) { + /* no ACK on slave addr */ + err = EIO; + goto xfer_done; + } + } while ((status & BCM_BSC_STATUS_TA) == 0); + /* + * Set curlen and readctl for the repeat-start read that + * we need to set up below, but set sc_flags to write, + * because that is the operation in progress right now. + */ + curlen = sc->sc_totlen - sc->sc_replen; + readctl = BCM_BSC_CTRL_READ; + sc->sc_flags &= ~BCM_I2C_READ; } - intr |= BCM_BSC_CTRL_INTD; - /* Start the transfer. */ - BCM_BSC_WRITE(sc, BCM_BSC_CTRL, BCM_BSC_CTRL_I2CEN | - BCM_BSC_CTRL_ST | read | intr); + /* + * Start the transfer with interrupts enabled, then if doing a + * write, fill the tx fifo. Not prefilling the fifo until after + * this start command is the key workaround for making + * repeat-start work, and it's harmless to do it in this order + * for a regular write too. + */ + BCM_BSC_WRITE(sc, BCM_BSC_DLEN, curlen); + BCM_BSC_WRITE(sc, BCM_BSC_CTRL, readctl | BCM_BSC_CTRL_I2CEN | + BCM_BSC_CTRL_ST | BCM_BSC_CTRL_INT_ALL); - /* Wait for the transaction to complete. */ - err = mtx_sleep(dev, &sc->sc_mtx, 0, "bsciow", hz); + if (!(sc->sc_curmsg->flags & IIC_M_RD)) { + bcm_bsc_fill_tx_fifo(sc); + } + /* Wait for the transaction to complete. */ + while (err == 0 && !(sc->sc_flags & BCM_I2C_DONE)) { + err = mtx_sleep(sc, &sc->sc_mtx, 0, "bsciow", hz); + } /* Check for errors. */ if (err == 0 && (sc->sc_flags & BCM_I2C_ERROR)) err = EIO; +xfer_done: + DEBUGF(sc, 1, " err=%d\n", err); + DEVICE_DEBUGF(sc, 2, "stop\n"); if (err != 0) break; } + + /* Disable interrupts, clean fifo, etc. */ + bcm_bsc_reset(sc); /* Clean the controller flags. */ sc->sc_flags = 0; Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscreg.h ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscreg.h Fri Jan 5 19:15:24 2018 (r327593) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscreg.h Fri Jan 5 19:21:45 2018 (r327594) @@ -40,6 +40,9 @@ #define BCM_BSC_CTRL_CLEAR1 (1 << 5) #define BCM_BSC_CTRL_CLEAR0 (1 << 4) #define BCM_BSC_CTRL_READ (1 << 0) +#define BCM_BSC_CTRL_INT_ALL \ + (BCM_BSC_CTRL_INTR | BCM_BSC_CTRL_INTT | BCM_BSC_CTRL_INTD) + #define BCM_BSC_STATUS 0x04 #define BCM_BSC_STATUS_CLKT (1 << 9) #define BCM_BSC_STATUS_ERR (1 << 8) @@ -51,6 +54,9 @@ #define BCM_BSC_STATUS_TXW (1 << 2) #define BCM_BSC_STATUS_DONE (1 << 1) #define BCM_BSC_STATUS_TA (1 << 0) +#define BCM_BSC_STATUS_ERRBITS \ + (BCM_BSC_STATUS_CLKT | BCM_BSC_STATUS_ERR) + #define BCM_BSC_DLEN 0x08 #define BCM_BSC_SLAVE 0x0c #define BCM_BSC_DATA 0x10 Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h Fri Jan 5 19:15:24 2018 (r327593) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h Fri Jan 5 19:21:45 2018 (r327594) @@ -40,23 +40,31 @@ struct { }; #define BCM_BSC_BASE_MASK 0x00ffffff +struct iic_msg; + struct bcm_bsc_softc { device_t sc_dev; device_t sc_iicbus; struct mtx sc_mtx; struct resource * sc_mem_res; struct resource * sc_irq_res; + void * sc_intrhand; + struct iic_msg * sc_curmsg; bus_space_tag_t sc_bst; bus_space_handle_t sc_bsh; + int sc_debug; + uint16_t sc_replen; + uint16_t sc_totlen; uint16_t sc_resid; - uint8_t *sc_data; + uint16_t sc_dlen; + uint8_t * sc_data; uint8_t sc_flags; - void * sc_intrhand; }; #define BCM_I2C_BUSY 0x01 #define BCM_I2C_READ 0x02 #define BCM_I2C_ERROR 0x04 +#define BCM_I2C_DONE 0x08 #define BCM_BSC_WRITE(_sc, _off, _val) \ bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, _off, _val) From owner-svn-src-stable-11@freebsd.org Fri Jan 5 19:28:14 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A012BEBBA3C; Fri, 5 Jan 2018 19:28:14 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53D1979EFE; Fri, 5 Jan 2018 19:28:14 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w05JSDP2043668; Fri, 5 Jan 2018 19:28:13 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w05JSDEL043666; Fri, 5 Jan 2018 19:28:13 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801051928.w05JSDEL043666@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Fri, 5 Jan 2018 19:28:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327595 - stable/11/sys/arm/ti X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/arm/ti X-SVN-Commit-Revision: 327595 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 19:28:14 -0000 Author: ian Date: Fri Jan 5 19:28:13 2018 New Revision: 327595 URL: https://svnweb.freebsd.org/changeset/base/327595 Log: MFC r324185: Enhance the interrupt capabilities of ti_pruss driver. The existing ti_pruss driver for the PRUSS Hardware provided by the AM335x ARM CPU has basic interrupt capabilities. This updated driver provides some more options: - Sysctl based configuration for the interrupts (for some examples, see the test plan in the phabricator review cited below). - A device file (/dev/pruss0.irqN) for each enabled interrupt. This file can be read and the device blocks if no irq has happened or returns an uint64_t timestamp based on nanouptime(). - Each interrupt device file provides kqueue-based event notification, blocking read(), or select(). Submitted by: Manuel Stuhn Differential Revision: https://reviews.freebsd.org/D11959 Modified: stable/11/sys/arm/ti/ti_pruss.c stable/11/sys/arm/ti/ti_pruss.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/ti/ti_pruss.c ============================================================================== --- stable/11/sys/arm/ti/ti_pruss.c Fri Jan 5 19:21:45 2018 (r327594) +++ stable/11/sys/arm/ti/ti_pruss.c Fri Jan 5 19:28:13 2018 (r327595) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2013 Rui Paulo + * Copyright (c) 2017 Manuel Stuehn * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,28 +27,33 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include #include +#include #include #include #include #include #include #include +#include +#include #include #include #include #include #include #include +#include #include #include #include #include -#include - #include #include @@ -60,27 +66,72 @@ __FBSDID("$FreeBSD$"); #define DPRINTF(fmt, ...) #endif +static d_open_t ti_pruss_irq_open; +static d_read_t ti_pruss_irq_read; +static d_poll_t ti_pruss_irq_poll; + static device_probe_t ti_pruss_probe; static device_attach_t ti_pruss_attach; static device_detach_t ti_pruss_detach; static void ti_pruss_intr(void *); static d_open_t ti_pruss_open; static d_mmap_t ti_pruss_mmap; -static void ti_pruss_kq_read_detach(struct knote *); -static int ti_pruss_kq_read_event(struct knote *, long); -static d_kqfilter_t ti_pruss_kqfilter; +static void ti_pruss_irq_kqread_detach(struct knote *); +static int ti_pruss_irq_kqevent(struct knote *, long); +static d_kqfilter_t ti_pruss_irq_kqfilter; +static void ti_pruss_privdtor(void *data); -#define TI_PRUSS_IRQS 8 +#define TI_PRUSS_PRU_IRQS 2 +#define TI_PRUSS_HOST_IRQS 8 +#define TI_PRUSS_IRQS (TI_PRUSS_HOST_IRQS+TI_PRUSS_PRU_IRQS) +#define TI_PRUSS_EVENTS 64 +#define NOT_SET_STR "NONE" +#define TI_TS_ARRAY 16 +struct ctl +{ + size_t cnt; + size_t idx; +}; + +struct ts_ring_buf +{ + struct ctl ctl; + uint64_t ts[TI_TS_ARRAY]; +}; + +struct ti_pruss_irqsc +{ + struct mtx sc_mtx; + struct cdev *sc_pdev; + struct selinfo sc_selinfo; + int8_t channel; + int8_t last; + int8_t event; + bool enable; + struct ts_ring_buf tstamps; +}; + +static struct cdevsw ti_pruss_cdevirq = { + .d_version = D_VERSION, + .d_name = "ti_pruss_irq", + .d_open = ti_pruss_irq_open, + .d_read = ti_pruss_irq_read, + .d_poll = ti_pruss_irq_poll, + .d_kqfilter = ti_pruss_irq_kqfilter, +}; + struct ti_pruss_softc { struct mtx sc_mtx; struct resource *sc_mem_res; - struct resource *sc_irq_res[TI_PRUSS_IRQS]; - void *sc_intr[TI_PRUSS_IRQS]; + struct resource *sc_irq_res[TI_PRUSS_HOST_IRQS]; + void *sc_intr[TI_PRUSS_HOST_IRQS]; + struct ti_pruss_irqsc sc_irq_devs[TI_PRUSS_IRQS]; bus_space_tag_t sc_bt; bus_space_handle_t sc_bh; struct cdev *sc_pdev; struct selinfo sc_selinfo; + bool sc_glob_irqen; }; static struct cdevsw ti_pruss_cdevsw = { @@ -88,7 +139,6 @@ static struct cdevsw ti_pruss_cdevsw = { .d_name = "ti_pruss", .d_open = ti_pruss_open, .d_mmap = ti_pruss_mmap, - .d_kqfilter = ti_pruss_kqfilter, }; static device_method_t ti_pruss_methods[] = { @@ -108,6 +158,7 @@ static driver_t ti_pruss_driver = { static devclass_t ti_pruss_devclass; DRIVER_MODULE(ti_pruss, simplebus, ti_pruss_driver, ti_pruss_devclass, 0, 0); +MODULE_DEPEND(ti_pruss, ti_prcm, 1, 1, 1); static struct resource_spec ti_pruss_irq_spec[] = { { SYS_RES_IRQ, 0, RF_ACTIVE }, @@ -120,8 +171,112 @@ static struct resource_spec ti_pruss_irq_spec[] = { { SYS_RES_IRQ, 7, RF_ACTIVE }, { -1, 0, 0 } }; -CTASSERT(TI_PRUSS_IRQS == nitems(ti_pruss_irq_spec) - 1); +CTASSERT(TI_PRUSS_HOST_IRQS == nitems(ti_pruss_irq_spec) - 1); +static int +ti_pruss_irq_open(struct cdev *dev, int oflags, int devtype, struct thread *td) +{ + struct ctl* irqs; + struct ti_pruss_irqsc *sc; + sc = dev->si_drv1; + + irqs = malloc(sizeof(struct ctl), M_DEVBUF, M_WAITOK); + if (!irqs) + return (ENOMEM); + + irqs->cnt = sc->tstamps.ctl.cnt; + irqs->idx = sc->tstamps.ctl.idx; + + return devfs_set_cdevpriv(irqs, ti_pruss_privdtor); +} + +static void +ti_pruss_privdtor(void *data) +{ + free(data, M_DEVBUF); +} + +static int +ti_pruss_irq_poll(struct cdev *dev, int events, struct thread *td) +{ + struct ctl* irqs; + struct ti_pruss_irqsc *sc; + sc = dev->si_drv1; + + devfs_get_cdevpriv((void**)&irqs); + + if (events & (POLLIN | POLLRDNORM)) { + if (sc->tstamps.ctl.cnt != irqs->cnt) + return events & (POLLIN | POLLRDNORM); + else + selrecord(td, &sc->sc_selinfo); + } + return 0; +} + +static int +ti_pruss_irq_read(struct cdev *cdev, struct uio *uio, int ioflag) +{ + const size_t ts_len = sizeof(uint64_t); + struct ti_pruss_irqsc* irq; + struct ctl* priv; + int error = 0; + size_t idx; + ssize_t level; + + irq = cdev->si_drv1; + + if (uio->uio_resid < ts_len) + return (EINVAL); + + error = devfs_get_cdevpriv((void**)&priv); + if (error) + return (error); + + mtx_lock(&irq->sc_mtx); + + if (irq->tstamps.ctl.cnt - priv->cnt > TI_TS_ARRAY) + { + priv->cnt = irq->tstamps.ctl.cnt; + priv->idx = irq->tstamps.ctl.idx; + mtx_unlock(&irq->sc_mtx); + return (ENXIO); + } + + do { + idx = priv->idx; + level = irq->tstamps.ctl.idx - idx; + if (level < 0) + level += TI_TS_ARRAY; + + if (level == 0) { + if (ioflag & O_NONBLOCK) { + mtx_unlock(&irq->sc_mtx); + return (EWOULDBLOCK); + } + + error = msleep(irq, &irq->sc_mtx, PCATCH | PDROP, + "pruirq", 0); + if (error) + return error; + + mtx_lock(&irq->sc_mtx); + } + }while(level == 0); + + mtx_unlock(&irq->sc_mtx); + + error = uiomove(&irq->tstamps.ts[idx], ts_len, uio); + + if (++idx == TI_TS_ARRAY) + idx = 0; + priv->idx = idx; + + atomic_add_32(&priv->cnt, 1); + + return (error); +} + static struct ti_pruss_irq_arg { int irq; struct ti_pruss_softc *sc; @@ -139,7 +294,205 @@ ti_pruss_reg_write(struct ti_pruss_softc *sc, uint32_t bus_space_write_4(sc->sc_bt, sc->sc_bh, reg, val); } +static __inline void +ti_pruss_interrupts_clear(struct ti_pruss_softc *sc) +{ + /* disable global interrupt */ + ti_pruss_reg_write(sc, PRUSS_INTC_GER, 0 ); + + /* clear all events */ + ti_pruss_reg_write(sc, PRUSS_INTC_SECR0, 0xFFFFFFFF); + ti_pruss_reg_write(sc, PRUSS_INTC_SECR1, 0xFFFFFFFF); + + /* disable all host interrupts */ + ti_pruss_reg_write(sc, PRUSS_INTC_HIER, 0); +} + +static __inline int +ti_pruss_interrupts_enable(struct ti_pruss_softc *sc, int8_t irq, bool enable) +{ + if (enable && ((sc->sc_irq_devs[irq].channel == -1) || + (sc->sc_irq_devs[irq].event== -1))) + { + device_printf( sc->sc_pdev->si_drv1, + "Interrupt chain not fully configured, not possible to enable\n" ); + return (EINVAL); + } + + sc->sc_irq_devs[irq].enable = enable; + + if (sc->sc_irq_devs[irq].sc_pdev) { + destroy_dev(sc->sc_irq_devs[irq].sc_pdev); + sc->sc_irq_devs[irq].sc_pdev = NULL; + } + + if (enable) { + sc->sc_irq_devs[irq].sc_pdev = make_dev(&ti_pruss_cdevirq, 0, UID_ROOT, GID_WHEEL, + 0600, "pruss%d.irq%d", device_get_unit(sc->sc_pdev->si_drv1), irq); + sc->sc_irq_devs[irq].sc_pdev->si_drv1 = &sc->sc_irq_devs[irq]; + + sc->sc_irq_devs[irq].tstamps.ctl.idx = 0; + } + + uint32_t reg = enable ? PRUSS_INTC_HIEISR : PRUSS_INTC_HIDISR; + ti_pruss_reg_write(sc, reg, sc->sc_irq_devs[irq].channel); + + reg = enable ? PRUSS_INTC_EISR : PRUSS_INTC_EICR; + ti_pruss_reg_write(sc, reg, sc->sc_irq_devs[irq].event ); + + return (0); +} + +static __inline void +ti_pruss_map_write(struct ti_pruss_softc *sc, uint32_t basereg, uint8_t index, uint8_t content) +{ + const size_t regadr = basereg + index & ~0x03; + const size_t bitpos = (index & 0x03) * 8; + uint32_t rmw = ti_pruss_reg_read(sc, regadr); + rmw = (rmw & ~( 0xF << bitpos)) | ( (content & 0xF) << bitpos); + ti_pruss_reg_write(sc, regadr, rmw); +} + static int +ti_pruss_event_map( SYSCTL_HANDLER_ARGS ) +{ + struct ti_pruss_softc *sc; + const int8_t irq = arg2; + int err; + char event[sizeof(NOT_SET_STR)]; + + sc = arg1; + + if(sc->sc_irq_devs[irq].event == -1) + bcopy(NOT_SET_STR, event, sizeof(event)); + else + snprintf(event, sizeof(event), "%d", sc->sc_irq_devs[irq].event); + + err = sysctl_handle_string(oidp, event, sizeof(event), req); + if(err != 0) + return (err); + + if (req->newptr) { // write event + if (strcmp(NOT_SET_STR, event) == 0) { + ti_pruss_interrupts_enable(sc, irq, false); + sc->sc_irq_devs[irq].event = -1; + } else { + if (sc->sc_irq_devs[irq].channel == -1) { + device_printf( sc->sc_pdev->si_drv1, + "corresponding channel not configured\n"); + return (ENXIO); + } + + const int8_t channelnr = sc->sc_irq_devs[irq].channel; + const int8_t eventnr = strtol( event, NULL, 10 ); // TODO: check if strol is valid + if (eventnr > TI_PRUSS_EVENTS || eventnr < 0) { + device_printf( sc->sc_pdev->si_drv1, + "Event number %d not valid (0 - %d)", + channelnr, TI_PRUSS_EVENTS -1); + return (EINVAL); + } + + sc->sc_irq_devs[irq].channel = channelnr; + sc->sc_irq_devs[irq].event = eventnr; + + // event[nr] <= channel + ti_pruss_map_write(sc, PRUSS_INTC_CMR_BASE, + eventnr, channelnr); + } + } + return (err); +} + +static int +ti_pruss_channel_map(SYSCTL_HANDLER_ARGS) +{ + struct ti_pruss_softc *sc; + int err; + char channel[sizeof(NOT_SET_STR)]; + const int8_t irq = arg2; + + sc = arg1; + + if (sc->sc_irq_devs[irq].channel == -1) + bcopy(NOT_SET_STR, channel, sizeof(channel)); + else + snprintf(channel, sizeof(channel), "%d", sc->sc_irq_devs[irq].channel); + + err = sysctl_handle_string(oidp, channel, sizeof(channel), req); + if (err != 0) + return (err); + + if (req->newptr) { // write event + if (strcmp(NOT_SET_STR, channel) == 0) { + ti_pruss_interrupts_enable(sc, irq, false); + ti_pruss_reg_write(sc, PRUSS_INTC_HIDISR, + sc->sc_irq_devs[irq].channel); + sc->sc_irq_devs[irq].channel = -1; + } else { + const int8_t channelnr = strtol(channel, NULL, 10); // TODO: check if strol is valid + if (channelnr > TI_PRUSS_IRQS || channelnr < 0) + { + device_printf(sc->sc_pdev->si_drv1, + "Channel number %d not valid (0 - %d)", + channelnr, TI_PRUSS_IRQS-1); + return (EINVAL); + } + + sc->sc_irq_devs[irq].channel = channelnr; + sc->sc_irq_devs[irq].last = -1; + + // channel[nr] <= irqnr + ti_pruss_map_write(sc, PRUSS_INTC_HMR_BASE, + irq, channelnr); + } + } + + return (err); +} + +static int +ti_pruss_interrupt_enable(SYSCTL_HANDLER_ARGS) +{ + struct ti_pruss_softc *sc; + int err; + bool irqenable; + const int8_t irq = arg2; + + sc = arg1; + irqenable = sc->sc_irq_devs[arg2].enable; + + err = sysctl_handle_bool(oidp, &irqenable, arg2, req); + if (err != 0) + return (err); + + if (req->newptr) // write enable + return ti_pruss_interrupts_enable(sc, irq, irqenable); + + return (err); +} + +static int +ti_pruss_global_interrupt_enable(SYSCTL_HANDLER_ARGS) +{ + struct ti_pruss_softc *sc; + int err; + bool glob_irqen; + + sc = arg1; + glob_irqen = sc->sc_glob_irqen; + + err = sysctl_handle_bool(oidp, &glob_irqen, arg2, req); + if (err != 0) + return (err); + + if (req->newptr) { + sc->sc_glob_irqen = glob_irqen; + ti_pruss_reg_write(sc, PRUSS_INTC_GER, glob_irqen); + } + + return (err); +} +static int ti_pruss_probe(device_t dev) { @@ -168,13 +521,31 @@ ti_pruss_attach(device_t dev) sc = device_get_softc(dev); rid = 0; mtx_init(&sc->sc_mtx, "TI PRUSS", NULL, MTX_DEF); - knlist_init_mtx(&sc->sc_selinfo.si_note, &sc->sc_mtx); sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->sc_mem_res == NULL) { device_printf(dev, "could not allocate memory resource\n"); return (ENXIO); } + + struct sysctl_ctx_list *clist = device_get_sysctl_ctx(dev); + if (!clist) + return (EINVAL); + + struct sysctl_oid *poid; + poid = device_get_sysctl_tree( dev ); + if (!poid) + return (EINVAL); + + sc->sc_glob_irqen = false; + struct sysctl_oid *irq_root = SYSCTL_ADD_NODE(clist, SYSCTL_CHILDREN(poid), + OID_AUTO, "irq", CTLFLAG_RD, 0, + "PRUSS Host Interrupts"); + SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(poid), OID_AUTO, + "global_interrupt_enable", CTLFLAG_RW | CTLTYPE_U8, + sc, 0, ti_pruss_global_interrupt_enable, + "CU", "Global interrupt enable"); + sc->sc_bt = rman_get_bustag(sc->sc_mem_res); sc->sc_bh = rman_get_bushandle(sc->sc_mem_res); if (bus_alloc_resources(dev, ti_pruss_irq_spec, sc->sc_irq_res) != 0) { @@ -182,48 +553,91 @@ ti_pruss_attach(device_t dev) ti_pruss_detach(dev); return (ENXIO); } + + ti_pruss_interrupts_clear(sc); + for (i = 0; i < TI_PRUSS_IRQS; i++) { - ti_pruss_irq_args[i].irq = i; - ti_pruss_irq_args[i].sc = sc; - if (bus_setup_intr(dev, sc->sc_irq_res[i], - INTR_MPSAFE | INTR_TYPE_MISC, - NULL, ti_pruss_intr, &ti_pruss_irq_args[i], - &sc->sc_intr[i]) != 0) { - device_printf(dev, - "unable to setup the interrupt handler\n"); - ti_pruss_detach(dev); - return (ENXIO); + char name[8]; + snprintf(name, sizeof(name), "%d", i); + + struct sysctl_oid *irq_nodes = SYSCTL_ADD_NODE(clist, SYSCTL_CHILDREN(irq_root), + OID_AUTO, name, CTLFLAG_RD, 0, + "PRUSS Interrupts"); + SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(irq_nodes), OID_AUTO, + "channel", CTLFLAG_RW | CTLTYPE_STRING, sc, i, ti_pruss_channel_map, + "A", "Channel attached to this irq"); + SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(irq_nodes), OID_AUTO, + "event", CTLFLAG_RW | CTLTYPE_STRING, sc, i, ti_pruss_event_map, + "A", "Event attached to this irq"); + SYSCTL_ADD_PROC(clist, SYSCTL_CHILDREN(irq_nodes), OID_AUTO, + "enable", CTLFLAG_RW | CTLTYPE_U8, sc, i, ti_pruss_interrupt_enable, + "CU", "Enable/Disable interrupt"); + + sc->sc_irq_devs[i].event = -1; + sc->sc_irq_devs[i].channel = -1; + sc->sc_irq_devs[i].tstamps.ctl.idx = 0; + + if (i < TI_PRUSS_HOST_IRQS) { + ti_pruss_irq_args[i].irq = i; + ti_pruss_irq_args[i].sc = sc; + if (bus_setup_intr(dev, sc->sc_irq_res[i], + INTR_MPSAFE | INTR_TYPE_MISC, + NULL, ti_pruss_intr, &ti_pruss_irq_args[i], + &sc->sc_intr[i]) != 0) { + device_printf(dev, + "unable to setup the interrupt handler\n"); + ti_pruss_detach(dev); + + return (ENXIO); + } + mtx_init(&sc->sc_irq_devs[i].sc_mtx, "TI PRUSS IRQ", NULL, MTX_DEF); + knlist_init_mtx(&sc->sc_irq_devs[i].sc_selinfo.si_note, &sc->sc_irq_devs[i].sc_mtx); } } - if (ti_pruss_reg_read(sc, PRUSS_AM18XX_INTC) == PRUSS_AM18XX_REV) - device_printf(dev, "AM18xx PRU-ICSS\n"); - else if (ti_pruss_reg_read(sc, PRUSS_AM33XX_INTC) == PRUSS_AM33XX_REV) + + if (ti_pruss_reg_read(sc, PRUSS_AM33XX_INTC) == PRUSS_AM33XX_REV) device_printf(dev, "AM33xx PRU-ICSS\n"); sc->sc_pdev = make_dev(&ti_pruss_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "pruss%d", device_get_unit(dev)); sc->sc_pdev->si_drv1 = dev; + /* Acc. to datasheet always write 1 to polarity registers */ + ti_pruss_reg_write(sc, PRUSS_INTC_SIPR0, 0xFFFFFFFF); + ti_pruss_reg_write(sc, PRUSS_INTC_SIPR1, 0xFFFFFFFF); + + /* Acc. to datasheet always write 0 to event type registers */ + ti_pruss_reg_write(sc, PRUSS_INTC_SITR0, 0); + ti_pruss_reg_write(sc, PRUSS_INTC_SITR1, 0); + return (0); } static int ti_pruss_detach(device_t dev) { - struct ti_pruss_softc *sc; - int i; + struct ti_pruss_softc *sc = device_get_softc(dev); - sc = device_get_softc(dev); - for (i = 0; i < TI_PRUSS_IRQS; i++) { + ti_pruss_interrupts_clear(sc); + + for (int i = 0; i < TI_PRUSS_HOST_IRQS; i++) { + ti_pruss_interrupts_enable( sc, i, false ); + if (sc->sc_intr[i]) bus_teardown_intr(dev, sc->sc_irq_res[i], sc->sc_intr[i]); if (sc->sc_irq_res[i]) bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->sc_irq_res[i]), sc->sc_irq_res[i]); + knlist_clear(&sc->sc_irq_devs[i].sc_selinfo.si_note, 0); + mtx_lock(&sc->sc_irq_devs[i].sc_mtx); + if (!knlist_empty(&sc->sc_irq_devs[i].sc_selinfo.si_note)) + printf("IRQ %d KQueue not empty!\n", i ); + mtx_unlock(&sc->sc_irq_devs[i].sc_mtx); + knlist_destroy(&sc->sc_irq_devs[i].sc_selinfo.si_note); + mtx_destroy(&sc->sc_irq_devs[i].sc_mtx); } - knlist_clear(&sc->sc_selinfo.si_note, 0); - knlist_destroy(&sc->sc_selinfo.si_note); + mtx_destroy(&sc->sc_mtx); if (sc->sc_mem_res) bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(sc->sc_mem_res), @@ -241,19 +655,38 @@ ti_pruss_intr(void *arg) struct ti_pruss_irq_arg *iap = arg; struct ti_pruss_softc *sc = iap->sc; /* - * Interrupts pr1_host_intr[0:7] are mapped to + * Interrupts pr1_host_intr[0:7] are mapped to * Host-2 to Host-9 of PRU-ICSS IRQ-controller. */ - const int pru_int = iap->irq + 2; + const int pru_int = iap->irq + TI_PRUSS_PRU_IRQS; const int pru_int_mask = (1 << pru_int); + const int pru_channel = sc->sc_irq_devs[pru_int].channel; + const int pru_event = sc->sc_irq_devs[pru_channel].event; - val = ti_pruss_reg_read(sc, PRUSS_AM33XX_INTC + PRUSS_INTC_HIER); - DPRINTF("interrupt %p, %d", sc, pru_int); + val = ti_pruss_reg_read(sc, PRUSS_INTC_HIER); if (!(val & pru_int_mask)) return; - ti_pruss_reg_write(sc, PRUSS_AM33XX_INTC + PRUSS_INTC_HIDISR, - pru_int); - KNOTE_UNLOCKED(&sc->sc_selinfo.si_note, pru_int); + + ti_pruss_reg_write(sc, PRUSS_INTC_HIDISR, pru_int); + ti_pruss_reg_write(sc, PRUSS_INTC_SICR, pru_event); + ti_pruss_reg_write(sc, PRUSS_INTC_HIEISR, pru_int); + + struct ti_pruss_irqsc* irq = &sc->sc_irq_devs[pru_channel]; + size_t wr = irq->tstamps.ctl.idx; + + struct timespec ts; + nanouptime(&ts); + irq->tstamps.ts[wr] = ts.tv_sec * 1000000000 + ts.tv_nsec; + + if (++wr == TI_TS_ARRAY) + wr = 0; + atomic_add_32(&irq->tstamps.ctl.cnt, 1); + + irq->tstamps.ctl.idx = wr; + + KNOTE_UNLOCKED(&irq->sc_selinfo.si_note, pru_int); + wakeup(irq); + selwakeup(&irq->sc_selinfo); } static int @@ -271,7 +704,7 @@ ti_pruss_mmap(struct cdev *cdev, vm_ooffset_t offset, struct ti_pruss_softc *sc = device_get_softc(dev); if (offset > rman_get_size(sc->sc_mem_res)) - return (-1); + return (ENOSPC); *paddr = rman_get_start(sc->sc_mem_res) + offset; *memattr = VM_MEMATTR_UNCACHEABLE; @@ -280,31 +713,43 @@ ti_pruss_mmap(struct cdev *cdev, vm_ooffset_t offset, static struct filterops ti_pruss_kq_read = { .f_isfd = 1, - .f_detach = ti_pruss_kq_read_detach, - .f_event = ti_pruss_kq_read_event, + .f_detach = ti_pruss_irq_kqread_detach, + .f_event = ti_pruss_irq_kqevent, }; static void -ti_pruss_kq_read_detach(struct knote *kn) +ti_pruss_irq_kqread_detach(struct knote *kn) { - struct ti_pruss_softc *sc = kn->kn_hook; + struct ti_pruss_irqsc *sc = kn->kn_hook; knlist_remove(&sc->sc_selinfo.si_note, kn, 0); } static int -ti_pruss_kq_read_event(struct knote *kn, long hint) +ti_pruss_irq_kqevent(struct knote *kn, long hint) { - kn->kn_data = hint; + struct ti_pruss_irqsc* irq_sc; + int notify; - return (hint); + irq_sc = kn->kn_hook; + + if (hint > 0) + kn->kn_data = hint - 2; + + if (hint > 0 || irq_sc->last > 0) + notify = 1; + else + notify = 0; + + irq_sc->last = hint; + + return (notify); } static int -ti_pruss_kqfilter(struct cdev *cdev, struct knote *kn) +ti_pruss_irq_kqfilter(struct cdev *cdev, struct knote *kn) { - device_t dev = cdev->si_drv1; - struct ti_pruss_softc *sc = device_get_softc(dev); + struct ti_pruss_irqsc *sc = cdev->si_drv1; switch (kn->kn_filter) { case EVFILT_READ: Modified: stable/11/sys/arm/ti/ti_pruss.h ============================================================================== --- stable/11/sys/arm/ti/ti_pruss.h Fri Jan 5 19:21:45 2018 (r327594) +++ stable/11/sys/arm/ti/ti_pruss.h Fri Jan 5 19:28:13 2018 (r327595) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2013 Rui Paulo + * Copyright (c) 2017 Manuel Stuehn * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,8 +34,22 @@ #define PRUSS_AM33XX_REV 0x4e82A900 #define PRUSS_AM33XX_INTC 0x20000 -#define PRUSS_INTC_HIER 0x1500 -#define PRUSS_INTC_HIDISR 0x0038 -#define PRUSS_INTC_HIPIR_BASE 0x0900 +#define PRUSS_INTC_GER (PRUSS_AM33XX_INTC + 0x0010) +#define PRUSS_INTC_SISR (PRUSS_AM33XX_INTC + 0x0020) +#define PRUSS_INTC_SICR (PRUSS_AM33XX_INTC + 0x0024) +#define PRUSS_INTC_EISR (PRUSS_AM33XX_INTC + 0x0028) +#define PRUSS_INTC_EICR (PRUSS_AM33XX_INTC + 0x002C) +#define PRUSS_INTC_HIEISR (PRUSS_AM33XX_INTC + 0x0034) +#define PRUSS_INTC_HIDISR (PRUSS_AM33XX_INTC + 0x0038) +#define PRUSS_INTC_SECR0 (PRUSS_AM33XX_INTC + 0x0280) +#define PRUSS_INTC_SECR1 (PRUSS_AM33XX_INTC + 0x0284) +#define PRUSS_INTC_CMR_BASE (PRUSS_AM33XX_INTC + 0x0400) +#define PRUSS_INTC_HMR_BASE (PRUSS_AM33XX_INTC + 0x0800) +#define PRUSS_INTC_HIPIR_BASE (PRUSS_AM33XX_INTC + 0x0900) +#define PRUSS_INTC_SIPR0 (PRUSS_AM33XX_INTC + 0x0D00) +#define PRUSS_INTC_SIPR1 (PRUSS_AM33XX_INTC + 0x0D04) +#define PRUSS_INTC_SITR0 (PRUSS_AM33XX_INTC + 0x0D80) +#define PRUSS_INTC_SITR1 (PRUSS_AM33XX_INTC + 0x0D84) +#define PRUSS_INTC_HIER (PRUSS_AM33XX_INTC + 0x1500) #endif /* _TI_PRUSS_H_ */ From owner-svn-src-stable-11@freebsd.org Sat Jan 6 05:00:38 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02833EB99E5; Sat, 6 Jan 2018 05:00:38 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D161373770; Sat, 6 Jan 2018 05:00:37 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 039A7AE02; Sat, 6 Jan 2018 05:00:37 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0650aHO086761; Sat, 6 Jan 2018 05:00:36 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0650aqm086759; Sat, 6 Jan 2018 05:00:36 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201801060500.w0650aqm086759@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 6 Jan 2018 05:00:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327609 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 327609 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 05:00:38 -0000 Author: eadler Date: Sat Jan 6 05:00:36 2018 New Revision: 327609 URL: https://svnweb.freebsd.org/changeset/base/327609 Log: MFC r327183: .git*: add gitattributes and gitignore For users of the git mirrors, lets provide useful git configuration files. Added: stable/11/.gitattributes - copied unchanged from r327183, head/.gitattributes stable/11/.gitignore - copied unchanged from r327183, head/.gitignore Modified: Directory Properties: stable/11/ (props changed) Copied: stable/11/.gitattributes (from r327183, head/.gitattributes) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/.gitattributes Sat Jan 6 05:00:36 2018 (r327609, copy of r327183, head/.gitattributes) @@ -0,0 +1,5 @@ +*.c diff=cpp +*.h diff=cpp +*.cpp diff=cpp +*.hpp diff=cpp +*.py diff=python Copied: stable/11/.gitignore (from r327183, head/.gitignore) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/.gitignore Sat Jan 6 05:00:36 2018 (r327609, copy of r327183, head/.gitignore) @@ -0,0 +1,18 @@ +_.tinderbox.* +_.amd64.* +_.arm.* +_.arm64.* +_.i386.* +_.ia64.* +_.mips.* +_.pc98.* +_.powerpc.* +_.riscv.* +_.sparc64.* +_.sun4v.* +GPATH +GRTAGS +GTAGS +ID +cscope.out +?cscope.out From owner-svn-src-stable-11@freebsd.org Sat Jan 6 06:34:50 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 950DAEC3450; Sat, 6 Jan 2018 06:34:50 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7116B783DF; Sat, 6 Jan 2018 06:34:50 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8B81BE46; Sat, 6 Jan 2018 06:34:49 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w066Yndv030135; Sat, 6 Jan 2018 06:34:49 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w066Ynsc030134; Sat, 6 Jan 2018 06:34:49 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201801060634.w066Ynsc030134@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 6 Jan 2018 06:34:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327613 - stable/11/usr.bin/pathchk X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/usr.bin/pathchk X-SVN-Commit-Revision: 327613 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 06:34:50 -0000 Author: eadler Date: Sat Jan 6 06:34:49 2018 New Revision: 327613 URL: https://svnweb.freebsd.org/changeset/base/327613 Log: MFC r302480: Add -P to pathchk usage Modified: stable/11/usr.bin/pathchk/pathchk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/pathchk/pathchk.c ============================================================================== --- stable/11/usr.bin/pathchk/pathchk.c Sat Jan 6 06:00:45 2018 (r327612) +++ stable/11/usr.bin/pathchk/pathchk.c Sat Jan 6 06:34:49 2018 (r327613) @@ -89,7 +89,7 @@ static void usage(void) { - fprintf(stderr, "usage: pathchk [-p] pathname ...\n"); + fprintf(stderr, "usage: pathchk [-Pp] pathname ...\n"); exit(1); } From owner-svn-src-stable-11@freebsd.org Sat Jan 6 17:21:00 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E33FEC3126; Sat, 6 Jan 2018 17:21:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2839B7797F; Sat, 6 Jan 2018 17:21:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 77538154E1; Sat, 6 Jan 2018 17:20:59 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06HKx8g051233; Sat, 6 Jan 2018 17:20:59 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06HKxRS051229; Sat, 6 Jan 2018 17:20:59 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801061720.w06HKxRS051229@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 17:20:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327626 - in stable/11: share/man/man9 sys/kern sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11: share/man/man9 sys/kern sys/sys X-SVN-Commit-Revision: 327626 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 17:21:00 -0000 Author: ian Date: Sat Jan 6 17:20:58 2018 New Revision: 327626 URL: https://svnweb.freebsd.org/changeset/base/327626 Log: MFC r324413, r324415 r324413: Restore the ability to deregister an eventhandler from within the callback. When the EVENTHANDLER(9) subsystem was created, it was a documented feature that an eventhandler callback function could safely deregister itself. In r200652 that feature was inadvertantly broken by adding drain-wait logic to eventhandler_deregister(), so that it would be safe to unload a module upon return from deregistering its event handlers. There are now 145 callers of EVENTHANDLER_DEREGISTER(), and it's likely many of them are depending on the drain-wait logic that has been in place for 8 years. So instead of creating a separate eventhandler_drain() and adding it to some or all of those 145 call sites, this creates a separate eventhandler_drain_nowait() function for the specific purpose of deregistering a callback from within the running callback. Differential Revision: https://reviews.freebsd.org/D12561 r324415: Add eventhandler notifications for newbus device attach/detach. The detach case is slightly complicated by the fact that some in-kernel consumers may want to know before a device detaches (so they can release related resources, stop using the device, etc), but the detach can fail. So there are pre- and post-detach notifications for those consumers who need to handle all cases. A couple salient comments from the review, they amount to some helpful documentation about these events, but there's currently no good place for such documentation... Note that in the current newbus locking model, DETACH_BEGIN and DETACH_COMPLETE/FAILED sequence of event handler invocation might interweave with other attach/detach events arbitrarily. The handlers should be prepared for such situations. Also should note that detach may be called after the parent bus knows the hardware has left the building. In-kernel consumers have to be prepared to cope with this race. Differential Revision: https://reviews.freebsd.org/D12557 Modified: stable/11/share/man/man9/EVENTHANDLER.9 stable/11/sys/kern/subr_bus.c stable/11/sys/kern/subr_eventhandler.c stable/11/sys/sys/eventhandler.h Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man9/EVENTHANDLER.9 ============================================================================== --- stable/11/share/man/man9/EVENTHANDLER.9 Sat Jan 6 16:29:00 2018 (r327625) +++ stable/11/share/man/man9/EVENTHANDLER.9 Sat Jan 6 17:20:58 2018 (r327626) @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" $FreeBSD$ .\" -.Dd March 27, 2017 +.Dd October 1, 2017 .Dt EVENTHANDLER 9 .Os .Sh NAME @@ -37,6 +37,7 @@ .Ft eventhandler_tag .Fn EVENTHANDLER_REGISTER name func arg priority .Fn EVENTHANDLER_DEREGISTER name tag +.Fn EVENTHANDLER_DEREGISTER_NOWAIT name tag .Ft eventhandler_tag .Fo eventhandler_register .Fa "struct eventhandler_list *list" @@ -50,6 +51,11 @@ .Fa "struct eventhandler_list *list" .Fa "eventhandler_tag tag" .Fc +.Ft void +.Fo eventhandler_deregister_nowait +.Fa "struct eventhandler_list *list" +.Fa "eventhandler_tag tag" +.Fc .Ft "struct eventhandler_list *" .Fn eventhandler_find_list "const char *name" .Ft void @@ -121,6 +127,18 @@ This macro removes a previously registered callback as .Fa tag from the event handler named by argument .Fa name . +It waits until no threads are running handlers for this event before +returning, making it safe to unload a module immediately upon return +from this function. +.It Fn EVENTHANDLER_DEREGISTER_NOWAIT +This macro removes a previously registered callback associated with tag +.Fa tag +from the event handler named by argument +.Fa name . +Upon return, one or more threads could still be running the removed +function(s), but no new calls will be made. +To remove a handler function from within that function, use this +version of deregister, to avoid a deadlock. .It Fn EVENTHANDLER_INVOKE This macro is used to invoke all the callbacks associated with event handler @@ -176,6 +194,21 @@ that can later be used with .Fn eventhandler_deregister to remove the particular callback function. .It Fn eventhandler_deregister +The +.Fn eventhandler_deregister +function removes the callback associated with tag +.Fa tag +from the event handler list pointed to by +.Fa list . +If +.Fa tag +is +.Va NULL , +all callback functions for the event are removed. +This function will not return until all threads have exited from the +removed handler callback function(s). +This function is not safe to call from inside an event handler callback. +.It Fn eventhandler_deregister_nowait The .Fn eventhandler_deregister function removes the callback associated with tag Modified: stable/11/sys/kern/subr_bus.c ============================================================================== --- stable/11/sys/kern/subr_bus.c Sat Jan 6 16:29:00 2018 (r327625) +++ stable/11/sys/kern/subr_bus.c Sat Jan 6 17:20:58 2018 (r327626) @@ -2934,6 +2934,7 @@ device_attach(device_t dev) else dev->state = DS_ATTACHED; dev->flags &= ~DF_DONENOMATCH; + EVENTHANDLER_INVOKE(device_attach, dev); devadded(dev); return (0); } @@ -2967,8 +2968,13 @@ device_detach(device_t dev) if (dev->state != DS_ATTACHED) return (0); - if ((error = DEVICE_DETACH(dev)) != 0) + EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_BEGIN); + if ((error = DEVICE_DETACH(dev)) != 0) { + EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_FAILED); return (error); + } else { + EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_COMPLETE); + } devremoved(dev); if (!device_is_quiet(dev)) device_printf(dev, "detached\n"); Modified: stable/11/sys/kern/subr_eventhandler.c ============================================================================== --- stable/11/sys/kern/subr_eventhandler.c Sat Jan 6 16:29:00 2018 (r327625) +++ stable/11/sys/kern/subr_eventhandler.c Sat Jan 6 17:20:58 2018 (r327626) @@ -180,8 +180,9 @@ vimage_eventhandler_register(struct eventhandler_list } #endif -void -eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) +static void +_eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag, + bool wait) { struct eventhandler_entry *ep = tag; @@ -215,9 +216,24 @@ eventhandler_deregister(struct eventhandler_list *list ep->ee_priority = EHE_DEAD_PRIORITY; } } - while (list->el_runcount > 0) + while (wait && list->el_runcount > 0) mtx_sleep(list, &list->el_lock, 0, "evhrm", 0); EHL_UNLOCK(list); +} + +void +eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) +{ + + _eventhandler_deregister(list, tag, true); +} + +void +eventhandler_deregister_nowait(struct eventhandler_list *list, + eventhandler_tag tag) +{ + + _eventhandler_deregister(list, tag, false); } /* Modified: stable/11/sys/sys/eventhandler.h ============================================================================== --- stable/11/sys/sys/eventhandler.h Sat Jan 6 16:29:00 2018 (r327625) +++ stable/11/sys/sys/eventhandler.h Sat Jan 6 17:20:58 2018 (r327626) @@ -141,12 +141,21 @@ do { \ if ((_el = eventhandler_find_list(#name)) != NULL) \ eventhandler_deregister(_el, tag); \ } while(0) - +#define EVENTHANDLER_DEREGISTER_NOWAIT(name, tag) \ +do { \ + struct eventhandler_list *_el; \ + \ + if ((_el = eventhandler_find_list(#name)) != NULL) \ + eventhandler_deregister_nowait(_el, tag); \ +} while(0) + eventhandler_tag eventhandler_register(struct eventhandler_list *list, const char *name, void *func, void *arg, int priority); void eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag); +void eventhandler_deregister_nowait(struct eventhandler_list *list, + eventhandler_tag tag); struct eventhandler_list *eventhandler_find_list(const char *name); void eventhandler_prune_list(struct eventhandler_list *list); @@ -276,5 +285,16 @@ struct ata_params; typedef void (*ada_probe_veto_fn)(void *, struct cam_path *, struct ata_params *, int *); EVENTHANDLER_DECLARE(ada_probe_veto, ada_probe_veto_fn); + +/* newbus device events */ +enum evhdev_detach { + EVHDEV_DETACH_BEGIN, /* Before detach() is called */ + EVHDEV_DETACH_COMPLETE, /* After detach() returns 0 */ + EVHDEV_DETACH_FAILED /* After detach() returns err */ +}; +typedef void (*device_attach_fn)(void *, device_t); +typedef void (*device_detach_fn)(void *, device_t, enum evhdev_detach); +EVENTHANDLER_DECLARE(device_attach, device_attach_fn); +EVENTHANDLER_DECLARE(device_detach, device_detach_fn); #endif /* _SYS_EVENTHANDLER_H_ */ From owner-svn-src-stable-11@freebsd.org Sat Jan 6 19:24:50 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9EC3EC7930; Sat, 6 Jan 2018 19:24:50 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 959CC7BDA1; Sat, 6 Jan 2018 19:24:50 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D7598169C8; Sat, 6 Jan 2018 19:24:49 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06JOn5h004255; Sat, 6 Jan 2018 19:24:49 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06JOnlF004254; Sat, 6 Jan 2018 19:24:49 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801061924.w06JOnlF004254@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 19:24:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327633 - stable/11/sys/arm/freescale/imx X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/arm/freescale/imx X-SVN-Commit-Revision: 327633 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 19:24:50 -0000 Author: ian Date: Sat Jan 6 19:24:49 2018 New Revision: 327633 URL: https://svnweb.freebsd.org/changeset/base/327633 Log: Fix imx6 hdmi init after r323553. This is a direct commit to 11-stable because major architectural changes in 12 prevent a direct MFC of the affected code. Conceptually, this is... MFC r324416: Fix imx6 hdmi init after r323553, which used a config_intrhook to defer the attachment of i2c devices needed by hdmi. The hdmi init also uses an intrhook callback to defer initialization, and if the hdmi callback runs first, the i2c devices will not yet have registered their device_t in association with their FDT phandle, which allows cross- device references on FDT systems. Now the hdmi deferred init checks for the i2c device registration, and if it's not complete yet, it registers as an eventhandler watching for newbus attach events. When the i2c device eventually attaches, the hdmi driver unregisters from watching further events, and continues with the hdmi init. Because the function signatures for an intrhook callback and an event handler callback are the same, a single function is used for both callbacks. Reported by: Russell Haley Modified: stable/11/sys/arm/freescale/imx/imx6_hdmi.c Modified: stable/11/sys/arm/freescale/imx/imx6_hdmi.c ============================================================================== --- stable/11/sys/arm/freescale/imx/imx6_hdmi.c Sat Jan 6 18:42:17 2018 (r327632) +++ stable/11/sys/arm/freescale/imx/imx6_hdmi.c Sat Jan 6 19:24:49 2018 (r327633) @@ -63,11 +63,11 @@ struct imx_hdmi_softc { device_t sc_dev; struct resource *sc_mem_res; int sc_mem_rid; - struct intr_config_hook sc_mode_hook; struct videomode sc_mode; uint8_t *sc_edid; uint8_t sc_edid_len; phandle_t sc_i2c_xref; + eventhandler_tag eh_tag; }; static struct ofw_compat_data compat_data[] = { @@ -626,15 +626,51 @@ hdmi_edid_read(struct imx_hdmi_softc *sc, uint8_t **ed return (result); } +/* + * Deferred HDMI init. dwc_hdmi_init() does i2c transfers for DDC/EDID. The imx + * i2c devices also use a config_intrhook function to finish their init, because + * they require interrupts to perform transfers. There is no way to control + * whether the i2c or our hdmi intrhook function runs first. If we go first we + * have to continue waiting until after the i2c driver is ready to do transfers + * and has registered its phandle. + * + * This function is used as both a config_intrhook function and after that as an + * eventhandler callback function (if necessary), to see if our i2c device is + * ready yet. When it is, continue with hdmi init. When first called as an + * intrhook function the i2c devices might be ready, in which case we never + * register as an eventhandler at all. Otherwise we register to see newbus + * attach events, and as each device attaches we check to see whether it was the + * i2c device we care about. Once we have our i2c device we unregister from + * seeing further attach events. + */ static void -imx_hdmi_detect_cable(void *arg) +imx_hdmi_init(void *dev) { struct imx_hdmi_softc *sc; - sc = arg; - EVENTHANDLER_INVOKE(hdmi_event, sc->sc_dev, HDMI_EVENT_CONNECTED); - /* Finished with the interrupt hook */ - config_intrhook_disestablish(&sc->sc_mode_hook); + sc = device_get_softc((device_t)dev); + + if (OF_device_from_xref(sc->sc_i2c_xref) != NULL) { + if (sc->eh_tag != NULL) { + EVENTHANDLER_DEREGISTER_NOWAIT(device_attach, + sc->eh_tag); + } + WR1(sc, HDMI_PHY_POL0, HDMI_PHY_HPD); + WR1(sc, HDMI_IH_PHY_STAT0, HDMI_IH_PHY_STAT0_HPD); + if ((RD1(sc, HDMI_IH_PHY_STAT0) & HDMI_IH_PHY_STAT0_HPD) != 0) { + EVENTHANDLER_INVOKE(hdmi_event, sc->sc_dev, + HDMI_EVENT_CONNECTED); + } + return; + } + + if (bootverbose) + device_printf((device_t)dev, "Waiting for DDC i2c device\n"); + + if (sc->eh_tag == NULL) { + sc->eh_tag = EVENTHANDLER_REGISTER(device_attach, + imx_hdmi_init, dev, EVENTHANDLER_PRI_ANY); + } } static int @@ -673,14 +709,6 @@ imx_hdmi_attach(device_t dev) goto out; } - sc->sc_mode_hook.ich_func = imx_hdmi_detect_cable; - sc->sc_mode_hook.ich_arg = sc; - - if (config_intrhook_establish(&sc->sc_mode_hook) != 0) { - err = ENOMEM; - goto out; - } - node = ofw_bus_get_node(dev); if (OF_getencprop(node, "ddc-i2c-bus", &i2c_xref, sizeof(i2c_xref)) == -1) sc->sc_i2c_xref = 0; @@ -702,8 +730,8 @@ imx_hdmi_attach(device_t dev) gpr3 |= IOMUXC_GPR3_HDMI_IPU1_DI0; imx_iomux_gpr_set(IOMUXC_GPR3, gpr3); - WR1(sc, HDMI_PHY_POL0, HDMI_PHY_HPD); - WR1(sc, HDMI_IH_PHY_STAT0, HDMI_IH_PHY_STAT0_HPD); + /* Further HDMI init requires interrupts for i2c transfers. */ + config_intrhook_oneshot(imx_hdmi_init, dev); out: From owner-svn-src-stable-11@freebsd.org Sat Jan 6 20:22:34 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F518DDB530; Sat, 6 Jan 2018 20:22:34 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ED6497DE9A; Sat, 6 Jan 2018 20:22:33 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 36131173AC; Sat, 6 Jan 2018 20:22:33 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06KMXfk029468; Sat, 6 Jan 2018 20:22:33 GMT (envelope-from bryanv@FreeBSD.org) Received: (from bryanv@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06KMXP1029467; Sat, 6 Jan 2018 20:22:33 GMT (envelope-from bryanv@FreeBSD.org) Message-Id: <201801062022.w06KMXP1029467@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bryanv set sender to bryanv@FreeBSD.org using -f From: Bryan Venteicher Date: Sat, 6 Jan 2018 20:22:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327635 - stable/11/sbin/ifconfig X-SVN-Group: stable-11 X-SVN-Commit-Author: bryanv X-SVN-Commit-Paths: stable/11/sbin/ifconfig X-SVN-Commit-Revision: 327635 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 20:22:34 -0000 Author: bryanv Date: Sat Jan 6 20:22:32 2018 New Revision: 327635 URL: https://svnweb.freebsd.org/changeset/base/327635 Log: MFC r326654: Use consistent name for the vxlan VNI parameter name and provide shorthand Modified: stable/11/sbin/ifconfig/ifvxlan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ifconfig/ifvxlan.c ============================================================================== --- stable/11/sbin/ifconfig/ifvxlan.c Sat Jan 6 19:36:29 2018 (r327634) +++ stable/11/sbin/ifconfig/ifvxlan.c Sat Jan 6 20:22:32 2018 (r327635) @@ -594,6 +594,7 @@ setvxlan_flush(const char *val, int d, int s, const st static struct cmd vxlan_cmds[] = { + DEF_CLONE_CMD_ARG("vni", setvxlan_vni), DEF_CLONE_CMD_ARG("vxlanid", setvxlan_vni), DEF_CLONE_CMD_ARG("vxlanlocal", setvxlan_local), DEF_CLONE_CMD_ARG("vxlanremote", setvxlan_remote), @@ -608,7 +609,8 @@ static struct cmd vxlan_cmds[] = { DEF_CLONE_CMD("vxlanlearn", 1, setvxlan_learn), DEF_CLONE_CMD("-vxlanlearn", 0, setvxlan_learn), - DEF_CMD_ARG("vxlanvni", setvxlan_vni), + DEF_CMD_ARG("vni", setvxlan_vni), + DEF_CMD_ARG("vxlanid", setvxlan_vni), DEF_CMD_ARG("vxlanlocal", setvxlan_local), DEF_CMD_ARG("vxlanremote", setvxlan_remote), DEF_CMD_ARG("vxlangroup", setvxlan_group), From owner-svn-src-stable-11@freebsd.org Sat Jan 6 20:52:31 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF5BADEF025; Sat, 6 Jan 2018 20:52:31 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CAA037F156; Sat, 6 Jan 2018 20:52:31 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFE4D17892; Sat, 6 Jan 2018 20:52:30 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06KqUnq041939; Sat, 6 Jan 2018 20:52:30 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06KqUDd041938; Sat, 6 Jan 2018 20:52:30 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801062052.w06KqUDd041938@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 20:52:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327637 - stable/11/sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/sys X-SVN-Commit-Revision: 327637 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 20:52:32 -0000 Author: ian Date: Sat Jan 6 20:52:30 2018 New Revision: 327637 URL: https://svnweb.freebsd.org/changeset/base/327637 Log: MFC r325060: Add a #define RESOURCE_SPEC_END. Similar to DEVMETHOD_END and KOBJMETHOD_END, this is to serve as the end marker in an array of resource_spec structures. Modified: stable/11/sys/sys/bus.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/sys/bus.h ============================================================================== --- stable/11/sys/sys/bus.h Sat Jan 6 20:32:14 2018 (r327636) +++ stable/11/sys/sys/bus.h Sat Jan 6 20:52:30 2018 (r327637) @@ -491,6 +491,7 @@ struct resource_spec { int rid; int flags; }; +#define RESOURCE_SPEC_END {-1, 0, 0} int bus_alloc_resources(device_t dev, struct resource_spec *rs, struct resource **res); From owner-svn-src-stable-11@freebsd.org Sat Jan 6 21:19:53 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA83BDF0617; Sat, 6 Jan 2018 21:19:53 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B665780025; Sat, 6 Jan 2018 21:19:53 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 09C2017BDA; Sat, 6 Jan 2018 21:19:53 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06LJrDQ050562; Sat, 6 Jan 2018 21:19:53 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06LJqLi050559; Sat, 6 Jan 2018 21:19:52 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801062119.w06LJqLi050559@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 21:19:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327638 - in stable/11/sys/dev: ffec sdhci X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/sys/dev: ffec sdhci X-SVN-Commit-Revision: 327638 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 21:19:54 -0000 Author: ian Date: Sat Jan 6 21:19:52 2018 New Revision: 327638 URL: https://svnweb.freebsd.org/changeset/base/327638 Log: MFC r325045, r325054-r325056, r325061, r325063, r325065 r325045: Actually release resources in detach() rather than just returning EBUSY. This will enable use of 'devctl disable', allow creation of a module, etc. r325054: Increase the alignment of the rx/tx descriptor ring buffers to 64 bytes. 16 was the correct alignment for older hardware, but the imx7 requires 64-byte alignment, which is a fine value to use on all systems. PR: 222634 Submitted by: sebastian.huber@embedded-brains.de r325055: Add FECFLAG_AVB variant flag to support new features on imx7. This flag is analogous to the Linux driver FEC_QUIRK_HAS_AVB. It indicates an FEC with support for Audio Video Bridging (AVB). This indicator is used for various other parts in the Linux driver (drivers/net/ethernet/freescale/fec_main.c). Use it to customize the receive/transmit buffer alignment. The receive buffer alignment increased to 64-bytes on the i.MX 6SoloX and i.MX 7Dual. There are no hard alignment restrictions for transmit buffers on these chips. Fix the ffec_softc::fectype type to provide enough storage for the feature flags. PR: 222634 Submitted by: sebastian.huber@embedded-brains.de r325056: Avoid AXI bus issues due to a MAC reset on imx6sx and imx7. When the FEC is connected to the AXI bus (indicated by AVB flag), a MAC reset while a bus transaction is pending can hang the bus. Instead of resetting, turn off the ENABLE bit, which allows the hardware to complete any in-progress transfers (appending a bad CRC to any partial packet) and release the AXI bus. This could probably be done unconditionally for all hardware variants, but that hasn't been tested. PR: 222634 Submitted by: sebastian.huber@embedded-brains.de r325061: Support up to 3 IRQs in the ffec driver. Newer hardware splits the interrupts onto 3 different irq lines, but the docs barely mention that there are multiple interrupts, and do not detail how they're split up. The code now supports 1-3 irqs, and uses the same interrupt service routine to handle all of them. I modified the submitted changes to use bus_alloc_resources() instead of using loops to allocate each irq separately. Thus, blame any bugs on me (I can't actually test on imx7 hardware). PR: 222634 Submitted by: sebastian.huber@embedded-brains.de r325063: Use the 16-bit receive shift feature in ffec hardware that supports it. When available, enabling this feature causes the hardware to write data to the receive buffer starting at a 16-bit offset from the start address. This eliminates the need to copy the data after receiving to re-align the protocol headers to a 32-bit boundary. PR: 222634 Submitted by: sebastian.huber@embedded-brains.de r325065: Split the hardware type enum and the hw feature flags bits into separate fields in the softc; they're ORed together in the ofw_compat_data. I already caught myself doing 'sc->fectype == ' without masking out the feature bits in one place, and that's sure to happen again. Glomming them together is convenient for storing them in the ofw_compat_data array, but there's no reason to keep them together in the softc. Modified: stable/11/sys/dev/ffec/if_ffec.c stable/11/sys/dev/ffec/if_ffecreg.h stable/11/sys/dev/sdhci/fsl_sdhci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ffec/if_ffec.c ============================================================================== --- stable/11/sys/dev/ffec/if_ffec.c Sat Jan 6 20:52:30 2018 (r327637) +++ stable/11/sys/dev/ffec/if_ffec.c Sat Jan 6 21:19:52 2018 (r327638) @@ -97,16 +97,21 @@ enum { FECTYPE_NONE, FECTYPE_GENERIC, FECTYPE_IMX53, - FECTYPE_IMX6, + FECTYPE_IMX6, /* imx6 and imx7 */ FECTYPE_MVF, }; /* * Flags that describe general differences between the FEC hardware in various - * SoCs. These are ORed into the FECTYPE enum values. + * SoCs. These are ORed into the FECTYPE enum values in the ofw_compat_data, so + * the low 8 bits are reserved for the type enum. In the softc, the type and + * flags are put into separate members, so that you don't need to mask the flags + * out of the type to compare it. */ -#define FECTYPE_MASK 0x0000ffff -#define FECFLAG_GBE (0x0001 << 16) +#define FECTYPE_MASK 0x000000ff +#define FECFLAG_GBE (1 << 8) +#define FECFLAG_AVB (1 << 9) +#define FECFLAG_RACC (1 << 10) /* * Table of supported FDT compat strings and their associated FECTYPE values. @@ -114,9 +119,11 @@ enum { static struct ofw_compat_data compat_data[] = { {"fsl,imx51-fec", FECTYPE_GENERIC}, {"fsl,imx53-fec", FECTYPE_IMX53}, - {"fsl,imx6q-fec", FECTYPE_IMX6 | FECFLAG_GBE}, - {"fsl,imx6ul-fec", FECTYPE_IMX6}, - {"fsl,mvf600-fec", FECTYPE_MVF}, + {"fsl,imx6q-fec", FECTYPE_IMX6 | FECFLAG_RACC | FECFLAG_GBE }, + {"fsl,imx6ul-fec", FECTYPE_IMX6 | FECFLAG_RACC }, + {"fsl,imx7d-fec", FECTYPE_IMX6 | FECFLAG_RACC | FECFLAG_GBE | + FECFLAG_AVB }, + {"fsl,mvf600-fec", FECTYPE_MVF | FECFLAG_RACC }, {"fsl,mvf-fec", FECTYPE_MVF}, {NULL, FECTYPE_NONE}, }; @@ -131,6 +138,8 @@ static struct ofw_compat_data compat_data[] = { #define WATCHDOG_TIMEOUT_SECS 5 +#define MAX_IRQ_COUNT 3 + struct ffec_bufmap { struct mbuf *mbuf; bus_dmamap_t map; @@ -143,16 +152,19 @@ struct ffec_softc { struct ifnet *ifp; int if_flags; struct mtx mtx; - struct resource *irq_res; + struct resource *irq_res[MAX_IRQ_COUNT]; struct resource *mem_res; - void * intr_cookie; + void * intr_cookie[MAX_IRQ_COUNT]; struct callout ffec_callout; mii_contype_t phy_conn_type; + uint32_t fecflags; uint8_t fectype; boolean_t link_is_up; boolean_t is_attached; boolean_t is_detaching; int tx_watchdog_count; + int rxbuf_align; + int txbuf_align; bus_dma_tag_t rxdesc_tag; bus_dmamap_t rxdesc_map; @@ -173,6 +185,13 @@ struct ffec_softc { int txcount; }; +static struct resource_spec irq_res_spec[MAX_IRQ_COUNT + 1] = { + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 1, RF_ACTIVE | RF_OPTIONAL }, + { SYS_RES_IRQ, 2, RF_ACTIVE | RF_OPTIONAL }, + RESOURCE_SPEC_END +}; + #define FFEC_LOCK(sc) mtx_lock(&(sc)->mtx) #define FFEC_UNLOCK(sc) mtx_unlock(&(sc)->mtx) #define FFEC_LOCK_INIT(sc) mtx_init(&(sc)->mtx, \ @@ -246,7 +265,7 @@ ffec_miigasket_setup(struct ffec_softc *sc) * We only need the gasket for MII and RMII connections on certain SoCs. */ - switch (sc->fectype & FECTYPE_MASK) + switch (sc->fectype) { case FECTYPE_IMX53: break; @@ -747,14 +766,17 @@ ffec_setup_rxbuf(struct ffec_softc *sc, int idx, struc int error, nsegs; struct bus_dma_segment seg; - /* - * We need to leave at least ETHER_ALIGN bytes free at the beginning of - * the buffer to allow the data to be re-aligned after receiving it (by - * copying it backwards ETHER_ALIGN bytes in the same buffer). We also - * have to ensure that the beginning of the buffer is aligned to the - * hardware's requirements. - */ - m_adj(m, roundup(ETHER_ALIGN, FEC_RXBUF_ALIGN)); + if (!(sc->fecflags & FECFLAG_RACC)) { + /* + * The RACC[SHIFT16] feature is not available. So, we need to + * leave at least ETHER_ALIGN bytes free at the beginning of the + * buffer to allow the data to be re-aligned after receiving it + * (by copying it backwards ETHER_ALIGN bytes in the same + * buffer). We also have to ensure that the beginning of the + * buffer is aligned to the hardware's requirements. + */ + m_adj(m, roundup(ETHER_ALIGN, sc->rxbuf_align)); + } error = bus_dmamap_load_mbuf_sg(sc->rxbuf_tag, sc->rxbuf_map[idx].map, m, &seg, &nsegs, 0); @@ -802,23 +824,6 @@ ffec_rxfinish_onebuf(struct ffec_softc *sc, int len) return; } - /* - * Unfortunately, the protocol headers need to be aligned on a 32-bit - * boundary for the upper layers. The hardware requires receive - * buffers to be 16-byte aligned. The ethernet header is 14 bytes, - * leaving the protocol header unaligned. We used m_adj() after - * allocating the buffer to leave empty space at the start of the - * buffer, now we'll use the alignment agnostic bcopy() routine to - * shuffle all the data backwards 2 bytes and adjust m_data. - * - * XXX imx6 hardware is able to do this 2-byte alignment by setting the - * SHIFT16 bit in the RACC register. Older hardware doesn't have that - * feature, but for them could we speed this up by copying just the - * protocol headers into their own small mbuf then chaining the cluster - * to it? That way we'd only need to copy like 64 bytes or whatever - * the biggest header is, instead of the whole 1530ish-byte frame. - */ - FFEC_UNLOCK(sc); bmap = &sc->rxbuf_map[sc->rx_idx]; @@ -831,10 +836,24 @@ ffec_rxfinish_onebuf(struct ffec_softc *sc, int len) m->m_pkthdr.len = len; m->m_pkthdr.rcvif = sc->ifp; - src = mtod(m, uint8_t*); - dst = src - ETHER_ALIGN; - bcopy(src, dst, len); - m->m_data = dst; + /* + * Align the protocol headers in the receive buffer on a 32-bit + * boundary. Newer hardware does the alignment for us. On hardware + * that doesn't support this feature, we have to copy-align the data. + * + * XXX for older hardware, could we speed this up by copying just the + * protocol headers into their own small mbuf then chaining the cluster + * to it? That way we'd only need to copy like 64 bytes or whatever the + * biggest header is, instead of the whole 1530ish-byte frame. + */ + if (sc->fecflags & FECFLAG_RACC) { + m->m_data = mtod(m, uint8_t *) + 2; + } else { + src = mtod(m, uint8_t*); + dst = src - ETHER_ALIGN; + bcopy(src, dst, len); + m->m_data = dst; + } sc->ifp->if_input(sc->ifp, m); FFEC_LOCK(sc); @@ -1098,7 +1117,7 @@ ffec_init_locked(struct ffec_softc *sc) * when we support jumbo frames and receiving fragments of them into * separate buffers. */ - maxbuf = MCLBYTES - roundup(ETHER_ALIGN, FEC_RXBUF_ALIGN); + maxbuf = MCLBYTES - roundup(ETHER_ALIGN, sc->rxbuf_align); maxfl = min(maxbuf, 0x7ff); if (ifp->if_drv_flags & IFF_DRV_RUNNING) @@ -1208,6 +1227,14 @@ ffec_init_locked(struct ffec_softc *sc) ffec_clear_stats(sc); WR4(sc, FEC_MIBC_REG, regval & ~FEC_MIBC_DIS); + if (sc->fecflags & FECFLAG_RACC) { + /* + * RACC - Receive Accelerator Function Configuration. + */ + regval = RD4(sc, FEC_RACC_REG); + WR4(sc, FEC_RACC_REG, regval | FEC_RACC_SHIFT16); + } + /* * ECR - Ethernet control register. * @@ -1360,7 +1387,7 @@ ffec_detach(device_t dev) { struct ffec_softc *sc; bus_dmamap_t map; - int idx; + int idx, irq; /* * NB: This function can be called internally to unwind a failure to @@ -1411,15 +1438,17 @@ ffec_detach(device_t dev) bus_dmamap_destroy(sc->txdesc_tag, sc->txdesc_map); } if (sc->txdesc_tag != NULL) - bus_dma_tag_destroy(sc->txdesc_tag); + bus_dma_tag_destroy(sc->txdesc_tag); /* Release bus resources. */ - if (sc->intr_cookie) - bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie); + for (irq = 0; irq < MAX_IRQ_COUNT; ++irq) { + if (sc->intr_cookie[irq] != NULL) { + bus_teardown_intr(dev, sc->irq_res[irq], + sc->intr_cookie[irq]); + } + } + bus_release_resources(dev, irq_res_spec, sc->irq_res); - if (sc->irq_res != NULL) - bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); - if (sc->mem_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); @@ -1434,10 +1463,11 @@ ffec_attach(device_t dev) struct ifnet *ifp = NULL; struct mbuf *m; void *dummy; + uintptr_t typeflags; phandle_t ofw_node; - int error, phynum, rid; - uint8_t eaddr[ETHER_ADDR_LEN]; uint32_t idx, mscr; + int error, phynum, rid, irq; + uint8_t eaddr[ETHER_ADDR_LEN]; sc = device_get_softc(dev); sc->dev = dev; @@ -1448,8 +1478,18 @@ ffec_attach(device_t dev) * There are differences in the implementation and features of the FEC * hardware on different SoCs, so figure out what type we are. */ - sc->fectype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + typeflags = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + sc->fectype = (uint8_t)(typeflags & FECTYPE_MASK); + sc->fecflags = (uint32_t)(typeflags & ~FECTYPE_MASK); + if (sc->fecflags & FECFLAG_AVB) { + sc->rxbuf_align = 64; + sc->txbuf_align = 1; + } else { + sc->rxbuf_align = 16; + sc->txbuf_align = 16; + } + /* * We have to be told what kind of electrical connection exists between * the MAC and PHY or we can't operate correctly. @@ -1478,12 +1518,10 @@ ffec_attach(device_t dev) error = ENOMEM; goto out; } - rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE); - if (sc->irq_res == NULL) { - device_printf(dev, "could not allocate interrupt resources.\n"); - error = ENOMEM; + + error = bus_alloc_resources(dev, irq_res_spec, sc->irq_res); + if (error != 0) { + device_printf(dev, "could not allocate interrupt resources\n"); goto out; } @@ -1525,7 +1563,7 @@ ffec_attach(device_t dev) error = bus_dma_tag_create( bus_get_dma_tag(dev), /* Parent tag. */ - FEC_TXBUF_ALIGN, 0, /* alignment, boundary */ + sc->txbuf_align, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -1627,15 +1665,34 @@ ffec_attach(device_t dev) /* Try to get the MAC address from the hardware before resetting it. */ ffec_get_hwaddr(sc, eaddr); - /* Reset the hardware. Disables all interrupts. */ - WR4(sc, FEC_ECR_REG, FEC_ECR_RESET); + /* + * Reset the hardware. Disables all interrupts. + * + * When the FEC is connected to the AXI bus (indicated by AVB flag), a + * MAC reset while a bus transaction is pending can hang the bus. + * Instead of resetting, turn off the ENABLE bit, which allows the + * hardware to complete any in-progress transfers (appending a bad CRC + * to any partial packet) and release the AXI bus. This could probably + * be done unconditionally for all hardware variants, but that hasn't + * been tested. + */ + if (sc->fecflags & FECFLAG_AVB) + WR4(sc, FEC_ECR_REG, 0); + else + WR4(sc, FEC_ECR_REG, FEC_ECR_RESET); /* Setup interrupt handler. */ - error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, - NULL, ffec_intr, sc, &sc->intr_cookie); - if (error != 0) { - device_printf(dev, "could not setup interrupt handler.\n"); - goto out; + for (irq = 0; irq < MAX_IRQ_COUNT; ++irq) { + if (sc->irq_res[irq] != NULL) { + error = bus_setup_intr(dev, sc->irq_res[irq], + INTR_TYPE_NET | INTR_MPSAFE, NULL, ffec_intr, sc, + &sc->intr_cookie[irq]); + if (error != 0) { + device_printf(dev, + "could not setup interrupt handler.\n"); + goto out; + } + } } /* @@ -1701,7 +1758,7 @@ ffec_attach(device_t dev) } error = mii_attach(dev, &sc->miibus, ifp, ffec_media_change, ffec_media_status, BMSR_DEFCAPMASK, phynum, MII_OFFSET_ANY, - (sc->fectype & FECTYPE_MVF) ? MIIF_FORCEANEG : 0); + (sc->fecflags & FECTYPE_MVF) ? MIIF_FORCEANEG : 0); if (error != 0) { device_printf(dev, "PHY attach failed\n"); goto out; Modified: stable/11/sys/dev/ffec/if_ffecreg.h ============================================================================== --- stable/11/sys/dev/ffec/if_ffecreg.h Sat Jan 6 20:52:30 2018 (r327637) +++ stable/11/sys/dev/ffec/if_ffecreg.h Sat Jan 6 21:19:52 2018 (r327638) @@ -317,8 +317,6 @@ struct ffec_hwdesc * The hardware imposes alignment restrictions on various objects involved in * DMA transfers. These values are expressed in bytes (not bits). */ -#define FEC_DESC_RING_ALIGN 16 -#define FEC_RXBUF_ALIGN 16 -#define FEC_TXBUF_ALIGN 16 +#define FEC_DESC_RING_ALIGN 64 #endif /* IF_FFECREG_H */ Modified: stable/11/sys/dev/sdhci/fsl_sdhci.c ============================================================================== --- stable/11/sys/dev/sdhci/fsl_sdhci.c Sat Jan 6 20:52:30 2018 (r327637) +++ stable/11/sys/dev/sdhci/fsl_sdhci.c Sat Jan 6 21:19:52 2018 (r327638) @@ -807,9 +807,26 @@ fsl_sdhci_get_platform_clock(device_t dev) static int fsl_sdhci_detach(device_t dev) { + struct fsl_sdhci_softc *sc = device_get_softc(dev); - /* sdhci_fdt_gpio_teardown(sc->gpio); */ - return (EBUSY); + if (sc->gpio != NULL) + sdhci_fdt_gpio_teardown(sc->gpio); + + callout_drain(&sc->r1bfix_callout); + + if (sc->intr_cookie != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie); + if (sc->irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(sc->irq_res), sc->irq_res); + + if (sc->mem_res != NULL) { + sdhci_cleanup_slot(&sc->slot); + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->mem_res), sc->mem_res); + } + + return (0); } static int @@ -922,13 +939,7 @@ fsl_sdhci_attach(device_t dev) return (0); fail: - if (sc->intr_cookie) - bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie); - if (sc->irq_res) - bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); - + fsl_sdhci_detach(dev); return (err); } @@ -936,7 +947,7 @@ static int fsl_sdhci_probe(device_t dev) { - if (!ofw_bus_status_okay(dev)) + if (!ofw_bus_status_okay(dev)) return (ENXIO); switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) { From owner-svn-src-stable-11@freebsd.org Sat Jan 6 22:56:49 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A54C5DF7F85; Sat, 6 Jan 2018 22:56:49 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 80CB23606; Sat, 6 Jan 2018 22:56:49 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA66318BD7; Sat, 6 Jan 2018 22:56:48 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06MumWQ001561; Sat, 6 Jan 2018 22:56:48 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06MumgA001560; Sat, 6 Jan 2018 22:56:48 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801062256.w06MumgA001560@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 22:56:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327651 - stable/11/sys/amd64/vmm/io X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/amd64/vmm/io X-SVN-Commit-Revision: 327651 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 22:56:49 -0000 Author: ian Date: Sat Jan 6 22:56:48 2018 New Revision: 327651 URL: https://svnweb.freebsd.org/changeset/base/327651 Log: MFC r325108: Improve the performance of the hpet timer in bhyve guests by making the timer frequency a power of two. This changes the frequency from 10 to 16.7 MHz (2 ^ 24 HZ). Using a power of two avoids roundoff errors when doing arithmetic in sbintime_t units. Testing shows this can fix erratic ntpd behavior in guests using the hpet timer (which is the default for multicore guests). Modified: stable/11/sys/amd64/vmm/io/vhpet.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/vmm/io/vhpet.c ============================================================================== --- stable/11/sys/amd64/vmm/io/vhpet.c Sat Jan 6 21:37:23 2018 (r327650) +++ stable/11/sys/amd64/vmm/io/vhpet.c Sat Jan 6 22:56:48 2018 (r327651) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_VHPET, "vhpet", "bhyve virtual hpet"); -#define HPET_FREQ 10000000 /* 10.0 Mhz */ +#define HPET_FREQ 16777216 /* 16.7 (2^24) Mhz */ #define FS_PER_S 1000000000000000ul /* Timer N Configuration and Capabilities Register */ From owner-svn-src-stable-11@freebsd.org Sat Jan 6 22:59:12 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CFF0DF8179; Sat, 6 Jan 2018 22:59:12 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D91DA3785; Sat, 6 Jan 2018 22:59:11 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 16F9418BD9; Sat, 6 Jan 2018 22:59:11 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06MxAFb001697; Sat, 6 Jan 2018 22:59:10 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06MxAjp001695; Sat, 6 Jan 2018 22:59:10 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201801062259.w06MxAjp001695@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sat, 6 Jan 2018 22:59:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327652 - stable/11/usr.sbin/nandtool X-SVN-Group: stable-11 X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: stable/11/usr.sbin/nandtool X-SVN-Commit-Revision: 327652 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 22:59:12 -0000 Author: jilles Date: Sat Jan 6 22:59:10 2018 New Revision: 327652 URL: https://svnweb.freebsd.org/changeset/base/327652 Log: MFC r327211: nandtool: Add missing mode for open() with O_CREAT If O_CREAT is given, open() needs a mode argument. Follow the umask by passing 0666. Modified: stable/11/usr.sbin/nandtool/nand_read.c stable/11/usr.sbin/nandtool/nand_readoob.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/nandtool/nand_read.c ============================================================================== --- stable/11/usr.sbin/nandtool/nand_read.c Sat Jan 6 22:56:48 2018 (r327651) +++ stable/11/usr.sbin/nandtool/nand_read.c Sat Jan 6 22:59:10 2018 (r327652) @@ -50,7 +50,7 @@ int nand_read(struct cmd_param *params) } if ((out = param_get_string(params, "out"))) { - out_fd = open(out, O_WRONLY|O_CREAT); + out_fd = open(out, O_WRONLY|O_CREAT, 0666); if (out_fd == -1) { perrorf("Cannot open %s for writing", out); return (1); Modified: stable/11/usr.sbin/nandtool/nand_readoob.c ============================================================================== --- stable/11/usr.sbin/nandtool/nand_readoob.c Sat Jan 6 22:56:48 2018 (r327651) +++ stable/11/usr.sbin/nandtool/nand_readoob.c Sat Jan 6 22:59:10 2018 (r327652) @@ -57,7 +57,7 @@ int nand_read_oob(struct cmd_param *params) } if ((out = param_get_string(params, "out"))) { - if ((fd_out = open(out, O_WRONLY | O_CREAT)) == -1) { + if ((fd_out = open(out, O_WRONLY | O_CREAT, 0666)) == -1) { perrorf("Cannot open %s", out); ret = 1; goto out; From owner-svn-src-stable-11@freebsd.org Sat Jan 6 23:04:15 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FA1DDF8643; Sat, 6 Jan 2018 23:04:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49CC63D24; Sat, 6 Jan 2018 23:04:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6189718D80; Sat, 6 Jan 2018 23:04:14 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06N4E9q005848; Sat, 6 Jan 2018 23:04:14 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06N4EFI005847; Sat, 6 Jan 2018 23:04:14 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801062304.w06N4EFI005847@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 23:04:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327653 - stable/11/sys/dev/iicbus X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/dev/iicbus X-SVN-Commit-Revision: 327653 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 23:04:15 -0000 Author: ian Date: Sat Jan 6 23:04:14 2018 New Revision: 327653 URL: https://svnweb.freebsd.org/changeset/base/327653 Log: MFC r326750: Do not give up if writing to the chip's control and status registers fails during startup. When a brand new chip leaves the factory, it is in a special power-saving mode that disables most functions on the chip to save battery power. The chip is stuck in this mode until the first write to the time registers, which automatically clears the special power-saving mode and starts the oscillator. Also, the day-of-week register in this chip counts 1-7, not 0-6, so write the values accordingly. These changes are based on the patch submitted by Brian Scott, but I elimated warnings since this condition is expected, and added some comments, and so in general blame me for any mistakes. PR: 223642 Modified: stable/11/sys/dev/iicbus/ds3231.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/iicbus/ds3231.c ============================================================================== --- stable/11/sys/dev/iicbus/ds3231.c Sat Jan 6 22:59:10 2018 (r327652) +++ stable/11/sys/dev/iicbus/ds3231.c Sat Jan 6 23:04:14 2018 (r327653) @@ -427,13 +427,19 @@ ds3231_start(void *xdev) device_printf(sc->sc_dev, "WARNING: RTC clock stopped, check the battery.\n"); } - /* Ack any pending alarm interrupt. */ - if (ds3231_status_write(sc, 1, 1) != 0) - return; - /* Always enable the oscillator. */ - if (ds3231_ctrl_write(sc) != 0) - return; + /* + * Ack any pending alarm interrupts and clear the EOSC bit to ensure the + * clock runs even when on battery power. Do not give up if these + * writes fail, because a factory-fresh chip is in a special mode that + * disables much of the chip to save battery power, and the only thing + * that gets it out of that mode is writing to the time registers. In + * these pristine chips, the EOSC and alarm bits are zero already, so + * the first valid write of time will get everything running properly. + */ + ds3231_status_write(sc, 1, 1); + ds3231_ctrl_write(sc); + /* Temperature. */ SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, @@ -568,7 +574,7 @@ ds3231_settime(device_t dev, struct timespec *ts) data[DS3231_MINS] = TOBCD(ct.min); data[DS3231_HOUR] = TOBCD(ct.hour) | pmflags; data[DS3231_DATE] = TOBCD(ct.day); - data[DS3231_WEEKDAY] = ct.dow; + data[DS3231_WEEKDAY] = ct.dow + 1; data[DS3231_MONTH] = TOBCD(ct.mon); data[DS3231_YEAR] = TOBCD(ct.year % 100); if (sc->sc_last_c) From owner-svn-src-stable-11@freebsd.org Sat Jan 6 23:12:34 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00BDADF8CE3; Sat, 6 Jan 2018 23:12:34 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CE89363515; Sat, 6 Jan 2018 23:12:33 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E6D5F18F0E; Sat, 6 Jan 2018 23:12:32 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06NCWIj009813; Sat, 6 Jan 2018 23:12:32 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06NCWY4009812; Sat, 6 Jan 2018 23:12:32 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801062312.w06NCWY4009812@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 23:12:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327654 - stable/11/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/arm/broadcom/bcm2835 X-SVN-Commit-Revision: 327654 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 23:12:34 -0000 Author: ian Date: Sat Jan 6 23:12:32 2018 New Revision: 327654 URL: https://svnweb.freebsd.org/changeset/base/327654 Log: MFC r326924-r326925 r326924: Fix debugging output, fallout from something like s/read/readctl/g while renaming variables in a previous change. r326925: Do not attempt to refill the TX fifo if there is no data left to transfer. A comment in bcm_bsc_fill_tx_fifo() even lists sc_totlen > 0 as a precondition for calling the routine. I apparently forgot to make the code do what my comment said. Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sat Jan 6 23:04:14 2018 (r327653) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sat Jan 6 23:12:32 2018 (r327654) @@ -505,7 +505,7 @@ bcm_bsc_intr(void *arg) * transfer is complete; TXD will be asserted along with ERR or * DONE if there is room in the fifo. */ - if (status & BCM_BSC_STATUS_TXD) + if ((status & BCM_BSC_STATUS_TXD) && sc->sc_totlen > 0) bcm_bsc_fill_tx_fifo(sc); } @@ -607,7 +607,7 @@ bcm_bsc_transfer(device_t dev, struct iic_msg *msgs, u */ if (sc->sc_replen == 0) { DEVICE_DEBUGF(sc, 1, "%-6s 0x%02x len %d: ", - (curisread) ? "readctl" : "write", curslave, + (curisread) ? "read" : "write", curslave, sc->sc_totlen); curlen = sc->sc_totlen; if (curisread) { @@ -619,7 +619,7 @@ bcm_bsc_transfer(device_t dev, struct iic_msg *msgs, u } } else { DEVICE_DEBUGF(sc, 1, "%-6s 0x%02x len %d: ", - (curisread) ? "readctl" : "write", curslave, + (curisread) ? "read" : "write", curslave, sc->sc_replen); /* From owner-svn-src-stable-11@freebsd.org Sat Jan 6 23:20:36 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C51B4DF9309; Sat, 6 Jan 2018 23:20:36 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F44F6398E; Sat, 6 Jan 2018 23:20:36 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D48CE18F23; Sat, 6 Jan 2018 23:20:35 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06NKZMA010362; Sat, 6 Jan 2018 23:20:35 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06NKZkl010357; Sat, 6 Jan 2018 23:20:35 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801062320.w06NKZkl010357@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 23:20:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327655 - in stable/11: share/man/man4 sys/conf sys/dev/md X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11: share/man/man4 sys/conf sys/dev/md X-SVN-Commit-Revision: 327655 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 23:20:36 -0000 Author: ian Date: Sat Jan 6 23:20:35 2018 New Revision: 327655 URL: https://svnweb.freebsd.org/changeset/base/327655 Log: MFC r327032: Add a new kernel config option, MD_ROOT_READONLY, which forces on the MD_READONLY flag for the md device automatically instantiated during kernel init for an mdroot filesystem. Note that there is specifically and by design no tunable or sysctl control over this feature. Without this option, you already have control over whether the mdroot fs is writeable using vfs.root.mountfrom.options from loader(8), the root_rw_mount rcvar, and by using "mount -u[rw] /" or equivelent on the fly. This option is being added to provide a way to make the mdroot fs truly immutable before userland code begins running. Differential Revision: https://reviews.freebsd.org/D13411 Modified: stable/11/share/man/man4/md.4 stable/11/sys/conf/NOTES stable/11/sys/conf/options stable/11/sys/dev/md/md.c Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/md.4 ============================================================================== --- stable/11/share/man/man4/md.4 Sat Jan 6 23:12:32 2018 (r327654) +++ stable/11/share/man/man4/md.4 Sat Jan 6 23:20:35 2018 (r327655) @@ -7,7 +7,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 5, 2017 +.Dd December 7, 2017 .Dt MD 4 .Os .Sh NAME @@ -79,7 +79,8 @@ To create a kernel with a ramdisk or MD file system, y needs the following options: .Bd -literal -offset indent options MD_ROOT # MD is a potential root device -options MD_ROOT_SIZE=8192 # 8MB ram disk +options MD_ROOT_READONLY # disallow mounting root writeable +options MD_ROOT_SIZE=8192 # 8MB ram disk makeoptions MFS_IMAGE=/h/foo/ARM-MD options ROOTDEVNAME=\\"ufs:md0\\" .Ed Modified: stable/11/sys/conf/NOTES ============================================================================== --- stable/11/sys/conf/NOTES Sat Jan 6 23:12:32 2018 (r327654) +++ stable/11/sys/conf/NOTES Sat Jan 6 23:20:35 2018 (r327655) @@ -1102,6 +1102,9 @@ options MD_ROOT_SIZE=10 # images of type mfs_root or md_root. options MD_ROOT +# Write-protect the md root device so that it may not be mounted writeable. +options MD_ROOT_READONLY + # Disk quotas are supported when this option is enabled. options QUOTA #enable disk quotas Modified: stable/11/sys/conf/options ============================================================================== --- stable/11/sys/conf/options Sat Jan 6 23:12:32 2018 (r327654) +++ stable/11/sys/conf/options Sat Jan 6 23:20:35 2018 (r327655) @@ -165,6 +165,7 @@ MAC_STUB opt_dontuse.h MAC_TEST opt_dontuse.h MD_ROOT opt_md.h MD_ROOT_FSTYPE opt_md.h +MD_ROOT_READONLY opt_md.h MD_ROOT_SIZE opt_md.h MFI_DEBUG opt_mfi.h MFI_DECODE_LOG opt_mfi.h Modified: stable/11/sys/dev/md/md.c ============================================================================== --- stable/11/sys/dev/md/md.c Sat Jan 6 23:12:32 2018 (r327654) +++ stable/11/sys/dev/md/md.c Sat Jan 6 23:20:35 2018 (r327655) @@ -1755,9 +1755,15 @@ md_preloaded(u_char *image, size_t length, const char sc->pl_ptr = image; sc->pl_len = length; sc->start = mdstart_preload; -#if defined(MD_ROOT) && !defined(ROOTDEVNAME) - if (sc->unit == 0) +#ifdef MD_ROOT + if (sc->unit == 0) { +#ifndef ROOTDEVNAME rootdevnames[0] = MD_ROOT_FSTYPE ":/dev/md0"; +#endif +#ifdef MD_ROOT_READONLY + sc->flags |= MD_READONLY; +#endif + } #endif mdinit(sc); if (name != NULL) { From owner-svn-src-stable-11@freebsd.org Sat Jan 6 23:24:54 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 407C5DF971B; Sat, 6 Jan 2018 23:24:54 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A8BF63DB3; Sat, 6 Jan 2018 23:24:54 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4FAFB190AB; Sat, 6 Jan 2018 23:24:53 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w06NOrxk014477; Sat, 6 Jan 2018 23:24:53 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w06NOrgQ014475; Sat, 6 Jan 2018 23:24:53 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801062324.w06NOrgQ014475@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 6 Jan 2018 23:24:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327656 - stable/11/sys/arm/arm X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/arm/arm X-SVN-Commit-Revision: 327656 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 23:24:54 -0000 Author: ian Date: Sat Jan 6 23:24:52 2018 New Revision: 327656 URL: https://svnweb.freebsd.org/changeset/base/327656 Log: MFC r327048-r327050 r327048: Restore the ability to use EARLY_PRINTF support during most of initarm(). The real kernel page tables are set up much earlier in initarm() now than they were when early printf support was first added, and they end up undoing the mapping made in locore.S for early printf support. This re-adds the mapping after switching to the new/real kernel page tables, making early printf work again right after switching to them. r327049: Allow pmap_kremove() to remove 1MB section mappings as well as 4K pages. This will allow it to undo temporary device mappings such as those made with pmap_preboot_map_attr(). Reviewed by: cognet r327050: If a temporary mapping is made to support EARLY_PRINTF, undo that mapping after cninit() runs, otherwise we leave a bogus device-memory mapping in userspace VA in the kernel pmap forever. Pointed out by: cognet Modified: stable/11/sys/arm/arm/machdep.c stable/11/sys/arm/arm/pmap-v6.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/machdep.c ============================================================================== --- stable/11/sys/arm/arm/machdep.c Sat Jan 6 23:20:35 2018 (r327655) +++ stable/11/sys/arm/arm/machdep.c Sat Jan 6 23:24:52 2018 (r327656) @@ -1115,6 +1115,19 @@ initarm(struct arm_boot_params *abp) pmap_bootstrap_prepare(lastaddr); /* + * If EARLY_PRINTF support is enabled, we need to re-establish the + * mapping after pmap_bootstrap_prepare() switches to new page tables. + * Note that we can only do the remapping if the VA is outside the + * kernel, now that we have real virtual (not VA=PA) mappings in effect. + * Early printf does not work between the time pmap_set_tex() does + * cp15_prrr_set() and this code remaps the VA. + */ +#if defined(EARLY_PRINTF) && defined(SOCDEV_PA) && defined(SOCDEV_VA) && SOCDEV_VA < KERNBASE + pmap_preboot_map_attr(SOCDEV_PA, SOCDEV_VA, 1024 * 1024, + VM_PROT_READ | VM_PROT_WRITE, VM_MEMATTR_DEVICE); +#endif + + /* * Now that proper page tables are installed, call cpu_setup() to enable * instruction and data caches and other chip-specific features. */ @@ -1176,6 +1189,14 @@ initarm(struct arm_boot_params *abp) OF_interpret("perform-fixup", 0); platform_gpio_init(); cninit(); + + /* + * If we made a mapping for EARLY_PRINTF after pmap_bootstrap_prepare(), + * undo it now that the normal console printf works. + */ +#if defined(EARLY_PRINTF) && defined(SOCDEV_PA) && defined(SOCDEV_VA) && SOCDEV_VA < KERNBASE + pmap_kremove(SOCDEV_VA); +#endif debugf("initarm: console initialized\n"); debugf(" arg1 kmdp = 0x%08x\n", (uint32_t)kmdp); Modified: stable/11/sys/arm/arm/pmap-v6.c ============================================================================== --- stable/11/sys/arm/arm/pmap-v6.c Sat Jan 6 23:20:35 2018 (r327655) +++ stable/11/sys/arm/arm/pmap-v6.c Sat Jan 6 23:24:52 2018 (r327656) @@ -1312,10 +1312,16 @@ pmap_kenter(vm_offset_t va, vm_paddr_t pa) PMAP_INLINE void pmap_kremove(vm_offset_t va) { + pt1_entry_t *pte1p; pt2_entry_t *pte2p; - pte2p = pt2map_entry(va); - pte2_clear(pte2p); + pte1p = kern_pte1(va); + if (pte1_is_section(pte1_load(pte1p))) { + pte1_clear(pte1p); + } else { + pte2p = pt2map_entry(va); + pte2_clear(pte2p); + } } /*