CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Tue Mar 17 22:38:14 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: - Change some expensive checks DEBUG -> DIAGNOSTIC. - Mark some small functions inline. - Add an assertion. To generate a diff of this commit: cvs rdiff -u -r1.375 -r1.376 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Tue Mar 17 22:37:05 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: - pmap_enter(): under low memory conditions, if PTP allocation succeeded and then PV entry allocation failed, PTP pages were being freed without their struct pmap_page being reset back to the non-PTP setup, which then caused havoc with pmap_page_removed(). Fix it. - pmap_enter_pv(): don't do the PV check if memory allocation failed. Reported-by: syzbot+d9b42238107c155ca...@syzkaller.appspotmail.com Reported-by: syzbot+80cf4850dc1cf2990...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.374 -r1.375 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.374 src/sys/arch/x86/x86/pmap.c:1.375 --- src/sys/arch/x86/x86/pmap.c:1.374 Tue Mar 17 22:29:19 2020 +++ src/sys/arch/x86/x86/pmap.c Tue Mar 17 22:37:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.374 2020/03/17 22:29:19 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.375 2020/03/17 22:37:05 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.374 2020/03/17 22:29:19 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.375 2020/03/17 22:37:05 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -635,30 +635,6 @@ pmap_compare_key(void *context, const vo } /* - * pmap_ptp_init: initialize new page table page - */ -static inline void -pmap_ptp_init(struct vm_page *ptp) -{ - - ptp->uanon = (struct vm_anon *)(vaddr_t)~0L; - rb_tree_init(_PAGE_TO_PP(ptp)->pp_rb, _rbtree_ops); - PMAP_CHECK_PP(VM_PAGE_TO_PP(ptp)); -} - -/* - * pmap_ptp_fini: finalize a page table page - */ -static inline void -pmap_ptp_fini(struct vm_page *ptp) -{ - - KASSERT(RB_TREE_MIN(_PAGE_TO_PP(ptp)->pp_rb) == NULL); - PMAP_CHECK_PP(VM_PAGE_TO_PP(ptp)); - ptp->uanon = NULL; -} - -/* * pmap_ptp_range_set: abuse ptp->uanon to record minimum VA of PTE */ static inline void @@ -2158,7 +2134,9 @@ pmap_enter_pv(struct pmap *pmap, struct LIST_INSERT_HEAD(>pp_pvlist, pve, pve_list); } mutex_spin_exit(>pp_lock); - pmap_check_pv(pmap, ptp, pp, va, true); + if (error == 0) { + pmap_check_pv(pmap, ptp, pp, va, true); + } return error; } @@ -2252,13 +2230,15 @@ pmap_freepage(struct pmap *pmap, struct int lidx; KASSERT(ptp->wire_count == 1); + PMAP_CHECK_PP(VM_PAGE_TO_PP(ptp)); lidx = level - 1; pmap_stats_update(pmap, -1, 0); if (pmap->pm_ptphint[lidx] == ptp) pmap->pm_ptphint[lidx] = NULL; ptp->wire_count = 0; - pmap_ptp_fini(ptp); + ptp->uanon = NULL; + KASSERT(RB_TREE_MIN(_PAGE_TO_PP(ptp)->pp_rb) == NULL); /* * Enqueue the PTP to be freed by pmap_update(). We can't remove @@ -2357,19 +2337,21 @@ pmap_get_ptp(struct pmap *pmap, struct p if (pt->pg[i] == NULL) { pt->pg[i] = uvm_pagealloc(obj, off, NULL, aflags); - pt->alloced[i] = true; - if (pt->pg[i] != NULL) { -pmap_ptp_init(pt->pg[i]); - } + pt->alloced[i] = (pt->pg[i] != NULL); } else if (pt->pg[i]->wire_count == 0) { /* This page was queued to be freed; dequeue it. */ LIST_REMOVE(pt->pg[i], mdpage.mp_pp.pp_link); - pmap_ptp_init(pt->pg[i]); + pt->alloced[i] = true; } PMAP_DUMMY_UNLOCK(pmap); if (pt->pg[i] == NULL) { pmap_unget_ptp(pmap, pt); return ENOMEM; + } else { + pt->pg[i]->uanon = (struct vm_anon *)(vaddr_t)~0L; + rb_tree_init(_PAGE_TO_PP(pt->pg[i])->pp_rb, + _rbtree_ops); + PMAP_CHECK_PP(VM_PAGE_TO_PP(pt->pg[i])); } } ptp = pt->pg[2]; @@ -2464,22 +2446,12 @@ pmap_unget_ptp(struct pmap *pmap, struct KASSERT(mutex_owned(>pm_lock)); for (i = PTP_LEVELS; i > 1; i--) { - if (pt->pg[i] == NULL) { - break; - } if (!pt->alloced[i]) { continue; } KASSERT(pt->pg[i]->wire_count == 0); PMAP_CHECK_PP(VM_PAGE_TO_PP(pt->pg[i])); - /* pmap zeros all pages before freeing. */ - pt->pg[i]->flags |= PG_ZERO; - pmap_ptp_fini(pt->pg[i]); - PMAP_DUMMY_LOCK(pmap); - uvm_pagefree(pt->pg[i]); - PMAP_DUMMY_UNLOCK(pmap); - pt->pg[i] = NULL; - pmap->pm_ptphint[0] = NULL; + pmap_freepage(pmap, pt->pg[i], i - 1); } } @@ -5232,6 +5204,7 @@ pmap_update(struct pmap *pmap) mutex_enter(>pm_lock); while ((ptp = LIST_FIRST(>pm_gc_ptp)) != NULL) { KASSERT(ptp->wire_count == 0); + KASSERT(ptp->uanon == NULL); LIST_REMOVE(ptp, mdpage.mp_pp.pp_link); pp = VM_PAGE_TO_PP(ptp); LIST_INIT(>pp_pvlist);
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Tue Mar 17 22:37:05 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: - pmap_enter(): under low memory conditions, if PTP allocation succeeded and then PV entry allocation failed, PTP pages were being freed without their struct pmap_page being reset back to the non-PTP setup, which then caused havoc with pmap_page_removed(). Fix it. - pmap_enter_pv(): don't do the PV check if memory allocation failed. Reported-by: syzbot+d9b42238107c155ca...@syzkaller.appspotmail.com Reported-by: syzbot+80cf4850dc1cf2990...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.374 -r1.375 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Tue Mar 17 22:29:19 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: Hallelujah, the bug has been found. Resurrect prior changes, to be fixed with following commit. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.373 -r1.374 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.114 src/sys/arch/x86/include/pmap.h:1.115 --- src/sys/arch/x86/include/pmap.h:1.114 Tue Mar 17 21:02:56 2020 +++ src/sys/arch/x86/include/pmap.h Tue Mar 17 22:29:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.114 2020/03/17 21:02:56 ad Exp $ */ +/* $NetBSD: pmap.h,v 1.115 2020/03/17 22:29:19 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -248,6 +248,8 @@ extern struct pool_cache pmap_cache; * (the other object locks are only used when uvm_pagealloc is called) */ +struct pv_page; + struct pmap { struct uvm_object pm_obj[PTP_LEVELS-1];/* objects for lvl >= 1) */ LIST_ENTRY(pmap) pm_list; /* list of all pmaps */ @@ -256,11 +258,11 @@ struct pmap { struct vm_page *pm_ptphint[PTP_LEVELS-1]; /* pointer to a PTP in our pmap */ struct pmap_statistics pm_stats; /* pmap stats */ + struct pv_entry *pm_pve; /* spare pv_entry */ #if !defined(__x86_64__) vaddr_t pm_hiexec; /* highest executable mapping */ #endif /* !defined(__x86_64__) */ - struct lwp *pm_remove_all; /* who's emptying the pmap */ union descriptor *pm_ldt; /* user-set LDT */ size_t pm_ldt_len; /* size of LDT in bytes */ Index: src/sys/arch/x86/include/pmap_pv.h diff -u src/sys/arch/x86/include/pmap_pv.h:1.16 src/sys/arch/x86/include/pmap_pv.h:1.17 --- src/sys/arch/x86/include/pmap_pv.h:1.16 Tue Mar 17 21:02:56 2020 +++ src/sys/arch/x86/include/pmap_pv.h Tue Mar 17 22:29:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_pv.h,v 1.16 2020/03/17 21:02:56 ad Exp $ */ +/* $NetBSD: pmap_pv.h,v 1.17 2020/03/17 22:29:19 ad Exp $ */ /*- * Copyright (c)2008 YAMAMOTO Takashi, @@ -34,6 +34,7 @@ #include struct vm_page; +struct pmap_page; /* * structures to track P->V mapping @@ -51,14 +52,14 @@ struct pv_pte { }; /* - * pv_entry: plug pv_pte into lists. + * pv_entry: plug pv_pte into lists. 32 bytes on i386, 64 on amd64. */ struct pv_entry { struct pv_pte pve_pte; /* should be the first member */ LIST_ENTRY(pv_entry) pve_list; /* on pmap_page::pp_pvlist */ rb_node_t pve_rb; /* red-black tree node */ - uintptr_t pve_padding; /* unused */ + struct pmap_page *pve_pp; /* backpointer to mapped page */ }; #define pve_next pve_list.le_next @@ -71,16 +72,13 @@ struct pmap_page { /* PTPs */ rb_tree_t rb; - /* PTPs */ + /* PTPs, when being freed */ LIST_ENTRY(vm_page) link; - /* Non-PTPs */ + /* Non-PTPs (i.e. normal pages) */ struct { - /* PP_EMBEDDED */ struct pv_pte pte; - LIST_HEAD(, pv_entry) pvlist; - uint8_t flags; uint8_t attrs; } s; } pp_u; @@ -89,7 +87,6 @@ struct pmap_page { #define pp_link pp_u.link #define pp_pte pp_u.s.pte #define pp_pvlist pp_u.s.pvlist -#define pp_pflags pp_u.s.flags #define pp_attrs pp_u.s.attrs }; @@ -97,10 +94,6 @@ struct pmap_page { #define PP_ATTRS_A 0x02 /* Accessed */ #define PP_ATTRS_W 0x04 /* Writable */ -/* pp_flags */ -#define PP_EMBEDDED 1 -#define PP_FREEING 2 - #define PMAP_PAGE_INIT(pp) \ do { \ LIST_INIT(&(pp)->pp_pvlist); \ Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.373 src/sys/arch/x86/x86/pmap.c:1.374 --- src/sys/arch/x86/x86/pmap.c:1.373 Tue Mar 17 21:02:56 2020 +++ src/sys/arch/x86/x86/pmap.c Tue Mar 17 22:29:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.373 2020/03/17 21:02:56 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.374 2020/03/17 22:29:19 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.373 2020/03/17 21:02:56 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.374 2020/03/17 22:29:19 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -139,6 +139,8 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.3 #include "opt_svs.h" #include "opt_kaslr.h" +#define __MUTEX_PRIVATE /* for assertions */ + #include #include #include @@ -224,23 +226,39 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.3 /* * Locking * - * We have the following locks that we must contend with, listed in the - * order that they must be acquired: + * We have the following locks that we must deal with, listed in the order + * that they are acquired: + * + * pg->uobject->vmobjlock, pg->uanon->an_lock * - *
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Tue Mar 17 22:29:19 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: Hallelujah, the bug has been found. Resurrect prior changes, to be fixed with following commit. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.373 -r1.374 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Tue Mar 17 21:02:56 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: Back out the recent pmap changes until I can figure out what is going on with pmap_page_remove() (to pmap.c rev 1.365). To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.372 -r1.373 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.113 src/sys/arch/x86/include/pmap.h:1.114 --- src/sys/arch/x86/include/pmap.h:1.113 Sat Mar 14 18:24:10 2020 +++ src/sys/arch/x86/include/pmap.h Tue Mar 17 21:02:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.113 2020/03/14 18:24:10 ad Exp $ */ +/* $NetBSD: pmap.h,v 1.114 2020/03/17 21:02:56 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -248,8 +248,6 @@ extern struct pool_cache pmap_cache; * (the other object locks are only used when uvm_pagealloc is called) */ -struct pv_page; - struct pmap { struct uvm_object pm_obj[PTP_LEVELS-1];/* objects for lvl >= 1) */ LIST_ENTRY(pmap) pm_list; /* list of all pmaps */ @@ -258,11 +256,11 @@ struct pmap { struct vm_page *pm_ptphint[PTP_LEVELS-1]; /* pointer to a PTP in our pmap */ struct pmap_statistics pm_stats; /* pmap stats */ - struct pv_entry *pm_pve; /* spare pv_entry */ #if !defined(__x86_64__) vaddr_t pm_hiexec; /* highest executable mapping */ #endif /* !defined(__x86_64__) */ + struct lwp *pm_remove_all; /* who's emptying the pmap */ union descriptor *pm_ldt; /* user-set LDT */ size_t pm_ldt_len; /* size of LDT in bytes */ Index: src/sys/arch/x86/include/pmap_pv.h diff -u src/sys/arch/x86/include/pmap_pv.h:1.15 src/sys/arch/x86/include/pmap_pv.h:1.16 --- src/sys/arch/x86/include/pmap_pv.h:1.15 Sun Mar 15 15:58:24 2020 +++ src/sys/arch/x86/include/pmap_pv.h Tue Mar 17 21:02:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_pv.h,v 1.15 2020/03/15 15:58:24 ad Exp $ */ +/* $NetBSD: pmap_pv.h,v 1.16 2020/03/17 21:02:56 ad Exp $ */ /*- * Copyright (c)2008 YAMAMOTO Takashi, @@ -34,7 +34,6 @@ #include struct vm_page; -struct pmap_page; /* * structures to track P->V mapping @@ -52,14 +51,14 @@ struct pv_pte { }; /* - * pv_entry: plug pv_pte into lists. 32 bytes on i386, 64 on amd64. + * pv_entry: plug pv_pte into lists. */ struct pv_entry { struct pv_pte pve_pte; /* should be the first member */ LIST_ENTRY(pv_entry) pve_list; /* on pmap_page::pp_pvlist */ rb_node_t pve_rb; /* red-black tree node */ - struct pmap_page *pve_pp; /* backpointer to mapped page */ + uintptr_t pve_padding; /* unused */ }; #define pve_next pve_list.le_next @@ -72,13 +71,16 @@ struct pmap_page { /* PTPs */ rb_tree_t rb; - /* PTPs, when being freed */ + /* PTPs */ LIST_ENTRY(vm_page) link; - /* Non-PTPs (i.e. normal pages) */ + /* Non-PTPs */ struct { + /* PP_EMBEDDED */ struct pv_pte pte; + LIST_HEAD(, pv_entry) pvlist; + uint8_t flags; uint8_t attrs; } s; } pp_u; @@ -87,6 +89,7 @@ struct pmap_page { #define pp_link pp_u.link #define pp_pte pp_u.s.pte #define pp_pvlist pp_u.s.pvlist +#define pp_pflags pp_u.s.flags #define pp_attrs pp_u.s.attrs }; @@ -94,6 +97,10 @@ struct pmap_page { #define PP_ATTRS_A 0x02 /* Accessed */ #define PP_ATTRS_W 0x04 /* Writable */ +/* pp_flags */ +#define PP_EMBEDDED 1 +#define PP_FREEING 2 + #define PMAP_PAGE_INIT(pp) \ do { \ LIST_INIT(&(pp)->pp_pvlist); \ Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.372 src/sys/arch/x86/x86/pmap.c:1.373 --- src/sys/arch/x86/x86/pmap.c:1.372 Tue Mar 17 18:40:35 2020 +++ src/sys/arch/x86/x86/pmap.c Tue Mar 17 21:02:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.372 2020/03/17 18:40:35 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.373 2020/03/17 21:02:56 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.372 2020/03/17 18:40:35 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.373 2020/03/17 21:02:56 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -139,8 +139,6 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.3 #include "opt_svs.h" #include "opt_kaslr.h" -#define __MUTEX_PRIVATE /* for assertions */ - #include #include #include @@ -226,39 +224,23 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.3 /* * Locking * - * We have the following locks that we must deal with, listed in the order - * that they are acquired: - * - * pg->uobject->vmobjlock, pg->uanon->an_lock + * We have the following locks that we must contend with, listed in the + * order that they
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Tue Mar 17 21:02:56 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: Back out the recent pmap changes until I can figure out what is going on with pmap_page_remove() (to pmap.c rev 1.365). To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.372 -r1.373 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Tue Mar 17 18:40:35 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: - Add more assertions. - Range clipping for pmap_remove(): only need to keep track of the lowest VA in PTP, as ptp->wire_count provides an upper bound. D'oh. Move set of range to where there is already a writeback to the PTP. - pmap_pp_remove(): panic if pmap_sync_pv() returns an error, because it means something has gone very wrong. The PTE should not change here since the pmap is locked. - pmap_pp_clear_attrs(): wait for the competing V->P operation by acquiring and releasing the pmap's lock, rather than busy looping. - pmap_test_attrs(): this needs to wait for any competing operations, otherwise it could return without all necessary updates reflected in pp_attrs. - pmap_enter(): fix cut-n-paste screwup in an error path for Xen. To generate a diff of this commit: cvs rdiff -u -r1.371 -r1.372 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.371 src/sys/arch/x86/x86/pmap.c:1.372 --- src/sys/arch/x86/x86/pmap.c:1.371 Tue Mar 17 13:34:50 2020 +++ src/sys/arch/x86/x86/pmap.c Tue Mar 17 18:40:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.371 2020/03/17 13:34:50 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.372 2020/03/17 18:40:35 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2020/03/17 13:34:50 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.372 2020/03/17 18:40:35 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -640,13 +640,8 @@ pmap_compare_key(void *context, const vo static inline void pmap_ptp_init(struct vm_page *ptp) { - uint16_t *minidx, *maxidx; - minidx = (uint16_t *)>uanon; - maxidx = (uint16_t *)>uanon + 1; - - *minidx = UINT16_MAX; - *maxidx = 0; + ptp->uanon = (struct vm_anon *)(vaddr_t)~0L; rb_tree_init(_PAGE_TO_PP(ptp)->pp_rb, _rbtree_ops); PMAP_CHECK_PP(VM_PAGE_TO_PP(ptp)); } @@ -664,24 +659,15 @@ pmap_ptp_fini(struct vm_page *ptp) } /* - * pmap_ptp_range_set: abuse ptp->uanon to record min/max idx of PTE + * pmap_ptp_range_set: abuse ptp->uanon to record minimum VA of PTE */ static inline void pmap_ptp_range_set(struct vm_page *ptp, vaddr_t va) { - uint16_t *minidx, *maxidx; - u_int idx; - - idx = pl1_pi(va); - KASSERT(idx < UINT16_MAX); - minidx = (uint16_t *)>uanon; - maxidx = (uint16_t *)>uanon + 1; + vaddr_t *min = (vaddr_t *)>uanon; - if (idx < *minidx) { - *minidx = idx; - } - if (idx > *maxidx) { - *maxidx = idx; + if (va < *min) { + *min = va; } } @@ -689,27 +675,18 @@ pmap_ptp_range_set(struct vm_page *ptp, * pmap_ptp_range_clip: abuse ptp->uanon to clip range of PTEs to remove */ static inline void -pmap_ptp_range_clip(struct vm_page *ptp, vaddr_t *startva, vaddr_t *endva, -pt_entry_t **pte) +pmap_ptp_range_clip(struct vm_page *ptp, vaddr_t *startva, pt_entry_t **pte) { - vaddr_t sclip, eclip; + vaddr_t sclip; if (ptp == NULL) { return; } - sclip = (*startva & L2_FRAME) + - x86_ptob(*(uint16_t *)>uanon); - eclip = (*startva & L2_FRAME) + - x86_ptob(*((uint16_t *)>uanon + 1) + 1); - - KASSERT(sclip < eclip); - + sclip = (vaddr_t)ptp->uanon; sclip = (*startva < sclip ? sclip : *startva); - eclip = (*endva > eclip ? eclip : *endva); *pte += (sclip - *startva) / PAGE_SIZE; *startva = sclip; - *endva = eclip; } /* @@ -2966,7 +2943,7 @@ pmap_remove_all(struct pmap *pmap) blkendva, _tofree); /* PTP should now be unused - free it. */ - KASSERT(ptps[i]->wire_count <= 1); + KASSERT(ptps[i]->wire_count == 1); pmap_free_ptp(pmap, ptps[i], va, ptes, pdes); } pmap_unmap_ptes(pmap, pmap2); @@ -2982,6 +2959,9 @@ pmap_remove_all(struct pmap *pmap) /* Verify that the pmap is now completely empty. */ pmap_check_ptps(pmap); + KASSERTMSG(pmap->pm_stats.resident_count == PDP_SIZE, + "pmap %p not empty", pmap); + return true; } @@ -3817,7 +3797,7 @@ pmap_remove_ptes(struct pmap *pmap, stru * mappings are very often sparse, so clip the given range to the * range of PTEs that are known present in the PTP. */ - pmap_ptp_range_clip(ptp, , , ); + pmap_ptp_range_clip(ptp, , ); /* * note that ptpva points to the PTE that maps startva. this may @@ -4168,9 +4148,9 @@ pmap_pp_remove(struct pmap_page *pp, pad { struct pv_pte *pvpte; struct vm_page *ptp; + uintptr_t sum; uint8_t oattrs; bool locked; - int count; /* * Do an unlocked check to see if the page has no mappings, eg when @@ -4179,20 +4159,19 @@ pmap_pp_remove(struct pmap_page *pp, pad * out, so we don't have to worry about concurrent attempts to enter * it (otherwise the caller either doesn't care or has
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Tue Mar 17 18:40:35 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: - Add more assertions. - Range clipping for pmap_remove(): only need to keep track of the lowest VA in PTP, as ptp->wire_count provides an upper bound. D'oh. Move set of range to where there is already a writeback to the PTP. - pmap_pp_remove(): panic if pmap_sync_pv() returns an error, because it means something has gone very wrong. The PTE should not change here since the pmap is locked. - pmap_pp_clear_attrs(): wait for the competing V->P operation by acquiring and releasing the pmap's lock, rather than busy looping. - pmap_test_attrs(): this needs to wait for any competing operations, otherwise it could return without all necessary updates reflected in pp_attrs. - pmap_enter(): fix cut-n-paste screwup in an error path for Xen. To generate a diff of this commit: cvs rdiff -u -r1.371 -r1.372 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ad Date: Tue Mar 17 18:31:39 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c src/sys/rump/librump/rumpkern: vm.c src/sys/ufs/lfs: lfs_pages.c src/sys/uvm: uvm_aobj.c uvm_bio.c uvm_fault.c uvm_loan.c uvm_page.c uvm_page.h src/tests/rump/kernspace: busypage.c Log Message: Tweak the March 14th change to make page waits interlocked by pg->interlock. Remove unneeded changes and only deal with the PQ_WANTED flag, to exclude possible bugs. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.186 -r1.187 src/sys/rump/librump/rumpkern/vm.c cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/lfs_pages.c cvs rdiff -u -r1.137 -r1.138 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.105 -r1.106 src/sys/uvm/uvm_bio.c cvs rdiff -u -r1.218 -r1.219 src/sys/uvm/uvm_fault.c cvs rdiff -u -r1.97 -r1.98 src/sys/uvm/uvm_loan.c cvs rdiff -u -r1.233 -r1.234 src/sys/uvm/uvm_page.c cvs rdiff -u -r1.101 -r1.102 src/sys/uvm/uvm_page.h cvs rdiff -u -r1.7 -r1.8 src/tests/rump/kernspace/busypage.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ad Date: Tue Mar 17 18:31:39 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c src/sys/rump/librump/rumpkern: vm.c src/sys/ufs/lfs: lfs_pages.c src/sys/uvm: uvm_aobj.c uvm_bio.c uvm_fault.c uvm_loan.c uvm_page.c uvm_page.h src/tests/rump/kernspace: busypage.c Log Message: Tweak the March 14th change to make page waits interlocked by pg->interlock. Remove unneeded changes and only deal with the PQ_WANTED flag, to exclude possible bugs. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.186 -r1.187 src/sys/rump/librump/rumpkern/vm.c cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/lfs_pages.c cvs rdiff -u -r1.137 -r1.138 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.105 -r1.106 src/sys/uvm/uvm_bio.c cvs rdiff -u -r1.218 -r1.219 src/sys/uvm/uvm_fault.c cvs rdiff -u -r1.97 -r1.98 src/sys/uvm/uvm_loan.c cvs rdiff -u -r1.233 -r1.234 src/sys/uvm/uvm_page.c cvs rdiff -u -r1.101 -r1.102 src/sys/uvm/uvm_page.h cvs rdiff -u -r1.7 -r1.8 src/tests/rump/kernspace/busypage.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.93 src/sys/miscfs/genfs/genfs_io.c:1.94 --- src/sys/miscfs/genfs/genfs_io.c:1.93 Sat Mar 14 20:45:23 2020 +++ src/sys/miscfs/genfs/genfs_io.c Tue Mar 17 18:31:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.93 2020/03/14 20:45:23 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.94 2020/03/17 18:31:38 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.93 2020/03/14 20:45:23 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.94 2020/03/17 18:31:38 ad Exp $"); #include #include @@ -516,9 +516,9 @@ out: } uvm_pagelock(pg); uvm_pageenqueue(pg); - uvm_pageunbusy(pg); + uvm_pagewakeup(pg); uvm_pageunlock(pg); - pg->flags &= ~PG_FAKE; + pg->flags &= ~(PG_BUSY|PG_FAKE); UVM_PAGE_OWN(pg, NULL); } else if (memwrite && !overwrite && uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN) { Index: src/sys/rump/librump/rumpkern/vm.c diff -u src/sys/rump/librump/rumpkern/vm.c:1.186 src/sys/rump/librump/rumpkern/vm.c:1.187 --- src/sys/rump/librump/rumpkern/vm.c:1.186 Sat Mar 14 20:23:51 2020 +++ src/sys/rump/librump/rumpkern/vm.c Tue Mar 17 18:31:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm.c,v 1.186 2020/03/14 20:23:51 ad Exp $ */ +/* $NetBSD: vm.c,v 1.187 2020/03/17 18:31:38 ad Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.186 2020/03/14 20:23:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.187 2020/03/17 18:31:38 ad Exp $"); #include #include @@ -689,8 +689,9 @@ uvm_page_unbusy(struct vm_page **pgs, in if (pg->flags & PG_RELEASED) { uvm_pagefree(pg); } else { + pg->flags &= ~PG_BUSY; uvm_pagelock(pg); - uvm_pageunbusy(pg); + uvm_pagewakeup(pg); uvm_pageunlock(pg); } } @@ -710,17 +711,15 @@ uvm_pagewait(struct vm_page *pg, krwlock } void -uvm_pageunbusy(struct vm_page *pg) +uvm_pagewakeup(struct vm_page *pg) { - KASSERT((pg->flags & PG_BUSY) != 0); KASSERT(mutex_owned(>interlock)); if ((pg->pqflags & PQ_WANTED) != 0) { pg->pqflags &= ~PQ_WANTED; wakeup(pg); } - pg->flags &= ~PG_BUSY; } void Index: src/sys/ufs/lfs/lfs_pages.c diff -u src/sys/ufs/lfs/lfs_pages.c:1.24 src/sys/ufs/lfs/lfs_pages.c:1.25 --- src/sys/ufs/lfs/lfs_pages.c:1.24 Sat Mar 14 20:45:23 2020 +++ src/sys/ufs/lfs/lfs_pages.c Tue Mar 17 18:31:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_pages.c,v 1.24 2020/03/14 20:45:23 ad Exp $ */ +/* $NetBSD: lfs_pages.c,v 1.25 2020/03/17 18:31:38 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2019 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.24 2020/03/14 20:45:23 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.25 2020/03/17 18:31:38 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -348,8 +348,9 @@ check_dirty(struct lfs *fs, struct vnode pg->flags |= PG_DELWRI; } } + pg->flags &= ~PG_BUSY; uvm_pagelock(pg); - uvm_pageunbusy(pg); + uvm_pagewakeup(pg); uvm_pageunlock(pg); UVM_PAGE_OWN(pg, NULL); } Index: src/sys/uvm/uvm_aobj.c diff -u src/sys/uvm/uvm_aobj.c:1.137 src/sys/uvm/uvm_aobj.c:1.138 --- src/sys/uvm/uvm_aobj.c:1.137 Sat Mar 14 20:23:51 2020 +++ src/sys/uvm/uvm_aobj.c Tue Mar 17 18:31:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_aobj.c,v 1.137 2020/03/14 20:23:51 ad Exp $ */ +/* $NetBSD: uvm_aobj.c,v 1.138 2020/03/17 18:31:39 ad Exp $ */ /* * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD:
CVS commit: src/sys/arch
Module Name:src Committed By: ad Date: Tue Mar 17 18:17:07 UTC 2020 Modified Files: src/sys/arch/amd64/include: pmap.h src/sys/arch/i386/include: pmap.h Log Message: Always set PTEs using atomics. There are too many assumptions to go wrong. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/arch/amd64/include/pmap.h cvs rdiff -u -r1.123 -r1.124 src/sys/arch/i386/include/pmap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: ad Date: Tue Mar 17 18:17:07 UTC 2020 Modified Files: src/sys/arch/amd64/include: pmap.h src/sys/arch/i386/include: pmap.h Log Message: Always set PTEs using atomics. There are too many assumptions to go wrong. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/arch/amd64/include/pmap.h cvs rdiff -u -r1.123 -r1.124 src/sys/arch/i386/include/pmap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/include/pmap.h diff -u src/sys/arch/amd64/include/pmap.h:1.64 src/sys/arch/amd64/include/pmap.h:1.65 --- src/sys/arch/amd64/include/pmap.h:1.64 Thu Nov 14 16:23:52 2019 +++ src/sys/arch/amd64/include/pmap.h Tue Mar 17 18:17:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.64 2019/11/14 16:23:52 maxv Exp $ */ +/* $NetBSD: pmap.h,v 1.65 2020/03/17 18:17:07 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -202,7 +202,8 @@ extern bool svs_pcid; #ifndef XENPV #define pmap_pa2pte(a) (a) #define pmap_pte2pa(a) ((a) & PTE_FRAME) -#define pmap_pte_set(p, n) do { *(p) = (n); } while (0) +#define pmap_pte_set(p, n) \ +(void)atomic_swap_ulong((volatile unsigned long *)p, n) #define pmap_pte_cas(p, o, n) atomic_cas_64((p), (o), (n)) #define pmap_pte_testset(p, n) \ atomic_swap_ulong((volatile unsigned long *)p, n) Index: src/sys/arch/i386/include/pmap.h diff -u src/sys/arch/i386/include/pmap.h:1.123 src/sys/arch/i386/include/pmap.h:1.124 --- src/sys/arch/i386/include/pmap.h:1.123 Sat Mar 9 09:09:56 2019 +++ src/sys/arch/i386/include/pmap.h Tue Mar 17 18:17:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.123 2019/03/09 09:09:56 maxv Exp $ */ +/* $NetBSD: pmap.h,v 1.124 2020/03/17 18:17:07 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -294,10 +294,11 @@ #ifndef XENPV #define pmap_pa2pte(a) (a) #define pmap_pte2pa(a) ((a) & PTE_FRAME) -#define pmap_pte_set(p, n) do { *(p) = (n); } while (0) #define pmap_pte_flush() /* nothing */ #ifdef PAE +#define pmap_pte_set(p, n) \ +(void)atomic_swap_64((volatile uint64_t *)p, n) #define pmap_pte_cas(p, o, n) atomic_cas_64((p), (o), (n)) #define pmap_pte_testset(p, n) \ atomic_swap_64((volatile uint64_t *)p, n) @@ -306,6 +307,8 @@ #define pmap_pte_clearbits(p, b) \ atomic_and_64((volatile uint64_t *)p, ~(b)) #else /* PAE */ +#define pmap_pte_set(p, n) \ +(void)atomic_swap_ulong((volatile unsigned long *)p, n) #define pmap_pte_cas(p, o, n) atomic_cas_32((p), (o), (n)) #define pmap_pte_testset(p, n) \ atomic_swap_ulong((volatile unsigned long *)p, n)
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Tue Mar 17 13:34:51 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Add a bunch of assertions. To generate a diff of this commit: cvs rdiff -u -r1.370 -r1.371 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.370 src/sys/arch/x86/x86/pmap.c:1.371 --- src/sys/arch/x86/x86/pmap.c:1.370 Sun Mar 15 19:41:04 2020 +++ src/sys/arch/x86/x86/pmap.c Tue Mar 17 13:34:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.370 2020/03/15 19:41:04 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.371 2020/03/17 13:34:50 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2020/03/15 19:41:04 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2020/03/17 13:34:50 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -139,6 +139,8 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.3 #include "opt_svs.h" #include "opt_kaslr.h" +#define __MUTEX_PRIVATE /* for assertions */ + #include #include #include @@ -333,6 +335,8 @@ paddr_t pmap_pa_end; /* PA of last phy #endif #define VM_PAGE_TO_PP(pg) (&(pg)->mdpage.mp_pp) +#define PMAP_CHECK_PP(pp) \ +KASSERTMSG((pp)->pp_lock.mtx_ipl._ipl == IPL_VM, "bad pmap_page %p", pp) /* * Other data structures @@ -644,6 +648,7 @@ pmap_ptp_init(struct vm_page *ptp) *minidx = UINT16_MAX; *maxidx = 0; rb_tree_init(_PAGE_TO_PP(ptp)->pp_rb, _rbtree_ops); + PMAP_CHECK_PP(VM_PAGE_TO_PP(ptp)); } /* @@ -654,6 +659,7 @@ pmap_ptp_fini(struct vm_page *ptp) { KASSERT(RB_TREE_MIN(_PAGE_TO_PP(ptp)->pp_rb) == NULL); + PMAP_CHECK_PP(VM_PAGE_TO_PP(ptp)); ptp->uanon = NULL; } @@ -1982,6 +1988,34 @@ pmap_free_pvs(struct pmap *pmap, struct } /* + * pmap_check_pv: verify {VA, PTP} pair is either tracked/untracked by page + */ +static void +pmap_check_pv(struct pmap *pmap, struct vm_page *ptp, struct pmap_page *pp, +vaddr_t va, bool tracked) +{ +#ifdef DIAGNOSTIC /* XXX too slow make this DEBUG before April 2020 */ + struct pv_pte *pvpte; + + PMAP_CHECK_PP(pp); + + mutex_spin_enter(>pp_lock); + for (pvpte = pv_pte_first(pp); pvpte; pvpte = pv_pte_next(pp, pvpte)) { + if (pvpte->pte_ptp == ptp && pvpte->pte_va == va) { + break; + } + } + mutex_spin_exit(>pp_lock); + + if (pvpte && !tracked) { + panic("pmap_check_pv: %p/%lx found on pp %p", ptp, va, pp); + } else if (!pvpte && tracked) { + panic("pmap_check_pv: %p/%lx missing on pp %p", ptp, va, pp); + } +#endif +} + +/* * pmap_treelookup_pv: search the PV tree for a dynamic entry * * => pmap must be locked @@ -2010,6 +2044,7 @@ pmap_treelookup_pv(const struct pmap *pm node = node->rb_nodes[pve->pve_pte.pte_va < va]; } } + /* * pmap_lookup_pv: look up a non-embedded pv entry for the given pmap * @@ -2083,6 +2118,7 @@ pmap_enter_pv(struct pmap *pmap, struct KASSERT(ptp_to_pmap(ptp) == pmap); KASSERT(ptp == NULL || ptp->uobject != NULL); KASSERT(ptp == NULL || ptp_va2o(va, 1) == ptp->offset); + PMAP_CHECK_PP(pp); /* * If entering the same page and it's already tracked with an @@ -2093,6 +2129,7 @@ pmap_enter_pv(struct pmap *pmap, struct if (atomic_load_relaxed(>pp_pte.pte_ptp) == ptp && atomic_load_relaxed(>pp_pte.pte_va) == va) { *samepage = true; + pmap_check_pv(pmap, ptp, pp, va, true); return 0; } @@ -2104,6 +2141,7 @@ pmap_enter_pv(struct pmap *pmap, struct *old_pve = pmap_treelookup_pv(pmap, ptp, tree, va); if (*old_pve != NULL && (*old_pve)->pve_pp == pp) { *samepage = true; + pmap_check_pv(pmap, ptp, pp, va, true); return 0; } @@ -2116,6 +2154,7 @@ pmap_enter_pv(struct pmap *pmap, struct } error = 0; + pmap_check_pv(pmap, ptp, pp, va, false); mutex_spin_enter(>pp_lock); if (!pv_pte_embedded(pp)) { /* @@ -2142,6 +2181,7 @@ pmap_enter_pv(struct pmap *pmap, struct LIST_INSERT_HEAD(>pp_pvlist, pve, pve_list); } mutex_spin_exit(>pp_lock); + pmap_check_pv(pmap, ptp, pp, va, true); return error; } @@ -2157,7 +2197,8 @@ static void pmap_remove_pv(struct pmap *pmap, struct pmap_page *pp, struct vm_page *ptp, vaddr_t va, struct pv_entry *pve, uint8_t oattrs) { - rb_tree_t *tree; + rb_tree_t *tree = (ptp != NULL ? + _PAGE_TO_PP(ptp)->pp_rb : _kernel_rb); KASSERT(mutex_owned(>pm_lock)); KASSERT(ptp_to_pmap(ptp) == pmap); @@ -2165,6 +2206,8 @@ pmap_remove_pv(struct pmap *pmap, struct KASSERT(ptp == NULL || ptp_va2o(va, 1) == ptp->offset); KASSERT(ptp != NULL || pmap == pmap_kernel()); + pmap_check_pv(pmap, ptp, pp, va, true); + mutex_spin_enter(>pp_lock); pp->pp_attrs |= oattrs; if (pve == NULL) { @@ -2174,16 +2217,23 @@ pmap_remove_pv(struct pmap *pmap, struct pp->pp_pte.pte_va = 0;
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Tue Mar 17 13:34:51 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Add a bunch of assertions. To generate a diff of this commit: cvs rdiff -u -r1.370 -r1.371 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Tue Mar 17 00:30:18 UTC 2020 Modified Files: src/sys/uvm: uvm_page_array.c Log Message: Fix a comment. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/uvm/uvm_page_array.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Tue Mar 17 00:30:18 UTC 2020 Modified Files: src/sys/uvm: uvm_page_array.c Log Message: Fix a comment. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/uvm/uvm_page_array.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_page_array.c diff -u src/sys/uvm/uvm_page_array.c:1.4 src/sys/uvm/uvm_page_array.c:1.5 --- src/sys/uvm/uvm_page_array.c:1.4 Sun Feb 23 15:46:43 2020 +++ src/sys/uvm/uvm_page_array.c Tue Mar 17 00:30:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_page_array.c,v 1.4 2020/02/23 15:46:43 ad Exp $ */ +/* $NetBSD: uvm_page_array.c,v 1.5 2020/03/17 00:30:17 ad Exp $ */ /*- * Copyright (c)2011 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_page_array.c,v 1.4 2020/02/23 15:46:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_page_array.c,v 1.5 2020/03/17 00:30:17 ad Exp $"); #include #include @@ -139,7 +139,7 @@ uvm_page_array_fill(struct uvm_page_arra maxpages = nwant; } #if 0 /* called from DDB for "show obj/f" without lock */ - KASSERT(rw_write_held(uobj->vmobjlock)); + KASSERT(rw_lock_held(uobj->vmobjlock)); #endif KASSERT(uvm_page_array_peek(ar) == NULL); if ((flags & UVM_PAGE_ARRAY_FILL_DIRTY) != 0) {
CVS commit: src/sys/uvm/pmap
Module Name:src Committed By: ad Date: Mon Mar 16 20:07:44 UTC 2020 Modified Files: src/sys/uvm/pmap: pmap_pvt.c Log Message: Use C99-ism to reduce ifdefs. Pointed out by christos@. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/uvm/pmap/pmap_pvt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/pmap/pmap_pvt.c diff -u src/sys/uvm/pmap/pmap_pvt.c:1.9 src/sys/uvm/pmap/pmap_pvt.c:1.10 --- src/sys/uvm/pmap/pmap_pvt.c:1.9 Mon Mar 16 19:56:39 2020 +++ src/sys/uvm/pmap/pmap_pvt.c Mon Mar 16 20:07:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_pvt.c,v 1.9 2020/03/16 19:56:39 ad Exp $ */ +/* $NetBSD: pmap_pvt.c,v 1.10 2020/03/16 20:07:44 ad Exp $ */ /*- * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: pmap_pvt.c,v 1.9 2020/03/16 19:56:39 ad Exp $"); +__RCSID("$NetBSD: pmap_pvt.c,v 1.10 2020/03/16 20:07:44 ad Exp $"); #include #include @@ -77,9 +77,6 @@ pmap_pv_track(paddr_t start, psize_t siz { struct pv_track *pvt; size_t npages; -#ifdef PMAP_PAGE_INIT - size_t i; -#endif KASSERT(start == trunc_page(start)); KASSERT(size == trunc_page(size)); @@ -94,7 +91,7 @@ pmap_pv_track(paddr_t start, psize_t siz pvt->pvt_size = size; #ifdef PMAP_PAGE_INIT - for (i = 0; i < npages; i++) + for (size_t i = 0; i < npages; i++) PMAP_PAGE_INIT(>pvt_pages[i]); #endif
CVS commit: src/sys/uvm/pmap
Module Name:src Committed By: ad Date: Mon Mar 16 20:07:44 UTC 2020 Modified Files: src/sys/uvm/pmap: pmap_pvt.c Log Message: Use C99-ism to reduce ifdefs. Pointed out by christos@. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/uvm/pmap/pmap_pvt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm/pmap
Module Name:src Committed By: ad Date: Mon Mar 16 19:56:39 UTC 2020 Modified Files: src/sys/uvm/pmap: pmap_pvt.c Log Message: pmap_pv_track(): use PMAP_PAGE_INIT() otherwise the x86 pmap pukes. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/uvm/pmap/pmap_pvt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm/pmap
Module Name:src Committed By: ad Date: Mon Mar 16 19:56:39 UTC 2020 Modified Files: src/sys/uvm/pmap: pmap_pvt.c Log Message: pmap_pv_track(): use PMAP_PAGE_INIT() otherwise the x86 pmap pukes. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/uvm/pmap/pmap_pvt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/pmap/pmap_pvt.c diff -u src/sys/uvm/pmap/pmap_pvt.c:1.8 src/sys/uvm/pmap/pmap_pvt.c:1.9 --- src/sys/uvm/pmap/pmap_pvt.c:1.8 Wed Jan 1 16:50:41 2020 +++ src/sys/uvm/pmap/pmap_pvt.c Mon Mar 16 19:56:39 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: pmap_pvt.c,v 1.8 2020/01/01 16:50:41 martin Exp $ */ +/* $NetBSD: pmap_pvt.c,v 1.9 2020/03/16 19:56:39 ad Exp $ */ /*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. + * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: pmap_pvt.c,v 1.8 2020/01/01 16:50:41 martin Exp $"); +__RCSID("$NetBSD: pmap_pvt.c,v 1.9 2020/03/16 19:56:39 ad Exp $"); #include #include @@ -77,6 +77,9 @@ pmap_pv_track(paddr_t start, psize_t siz { struct pv_track *pvt; size_t npages; +#ifdef PMAP_PAGE_INIT + size_t i; +#endif KASSERT(start == trunc_page(start)); KASSERT(size == trunc_page(size)); @@ -90,6 +93,11 @@ pmap_pv_track(paddr_t start, psize_t siz pvt->pvt_start = start; pvt->pvt_size = size; +#ifdef PMAP_PAGE_INIT + for (i = 0; i < npages; i++) + PMAP_PAGE_INIT(>pvt_pages[i]); +#endif + mutex_enter(_unmanaged.lock); pvt->pvt_next = pv_unmanaged.list; atomic_store_release(_unmanaged.list, pvt);
Re: CVS commit: src/sys/arch/sparc/sparc
On Sun, Mar 15, 2020 at 11:38:03AM +1100, matthew green wrote: > "Andrew Doran" writes: > > Module Name:src > > Committed By: ad > > Date: Sat Mar 14 13:34:44 UTC 2020 > > > > Modified Files: > > src/sys/arch/sparc/sparc: intr.c > > > > Log Message: > > sparc cpu_intr_p(): try to work around l_cpu not being set early on by > > using curcpu(). > > ah, good idea. this will involve one fewer deref, curcpu() > is mapped at a fixed address, so it might even be faster now > than it used to be. Oh, hm.. Given that it's a fixed address is there a way the compiler can screw this up in the face of a kernel preemption (theoretical right now for sparc*)? I don't think so.. None of the fanciness is required then. bool cpu_intr_p(void) { return curcpu()->ci_idepth != 0; } Andrew
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sun Mar 15 21:06:30 UTC 2020 Modified Files: src/sys/uvm: uvm_physseg.c Log Message: uvm_physseg: cluster fields used during RB tree lookup for PHYS_TO_VM_PAGE(). To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/uvm/uvm_physseg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_physseg.c diff -u src/sys/uvm/uvm_physseg.c:1.13 src/sys/uvm/uvm_physseg.c:1.14 --- src/sys/uvm/uvm_physseg.c:1.13 Sat Dec 21 14:41:44 2019 +++ src/sys/uvm/uvm_physseg.c Sun Mar 15 21:06:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_physseg.c,v 1.13 2019/12/21 14:41:44 ad Exp $ */ +/* $NetBSD: uvm_physseg.c,v 1.14 2020/03/15 21:06:30 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -87,12 +87,15 @@ * uvm_physseg: describes one segment of physical memory */ struct uvm_physseg { + /* used during RB tree lookup for PHYS_TO_VM_PAGE(). */ struct rb_node rb_node; /* tree information */ paddr_t start; /* PF# of first page in segment */ paddr_t end; /* (PF# of last page in segment) + 1 */ + struct vm_page *pgs; /* vm_page structures (from start) */ + + /* less performance sensitive fields. */ paddr_t avail_start; /* PF# of first free page in segment */ paddr_t avail_end; /* (PF# of last free page in segment) +1 */ - struct vm_page *pgs; /* vm_page structures (from start) */ struct extent *ext; /* extent(9) structure to manage pgs[] */ int free_list; /* which free list they belong on */ u_int start_hint; /* start looking for free pages here */ @@ -121,9 +124,9 @@ struct vm_page *uvm_physseg_seg_alloc_fr struct uvm_physseg_graph { struct rb_tree rb_tree; /* Tree for entries */ intnentries; /* Number of entries */ -}; +} __aligned(COHERENCY_UNIT); -static struct uvm_physseg_graph uvm_physseg_graph; +static struct uvm_physseg_graph uvm_physseg_graph __read_mostly; /* * Note on kmem(9) allocator usage:
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sun Mar 15 21:06:30 UTC 2020 Modified Files: src/sys/uvm: uvm_physseg.c Log Message: uvm_physseg: cluster fields used during RB tree lookup for PHYS_TO_VM_PAGE(). To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/uvm/uvm_physseg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Sun Mar 15 19:41:05 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Fix a comment. To generate a diff of this commit: cvs rdiff -u -r1.369 -r1.370 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.369 src/sys/arch/x86/x86/pmap.c:1.370 --- src/sys/arch/x86/x86/pmap.c:1.369 Sun Mar 15 15:58:24 2020 +++ src/sys/arch/x86/x86/pmap.c Sun Mar 15 19:41:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.369 2020/03/15 15:58:24 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.370 2020/03/15 19:41:04 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.369 2020/03/15 15:58:24 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2020/03/15 19:41:04 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -2032,7 +2032,7 @@ pmap_lookup_pv(const struct pmap *pmap, * * If the page is tracked with an embedded entry then the tree * lookup can be avoided. It's safe to check for this specific - * set of values without pp_lock because all 3 will only ever be + * set of values without pp_lock because both will only ever be * set together for this pmap. * */ @@ -2088,7 +2088,7 @@ pmap_enter_pv(struct pmap *pmap, struct * If entering the same page and it's already tracked with an * embedded entry, we can avoid the expense below. It's safe * to check for this very specific set of values without a lock - * because all 3 will only ever be set together for this pmap. + * because both will only ever be set together for this pmap. */ if (atomic_load_relaxed(>pp_pte.pte_ptp) == ptp && atomic_load_relaxed(>pp_pte.pte_va) == va) {
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Sun Mar 15 19:41:05 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Fix a comment. To generate a diff of this commit: cvs rdiff -u -r1.369 -r1.370 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Sun Mar 15 15:58:24 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: - pmap_enter(): Remove cosmetic differences between the EPT & native cases. Remove old code to free PVEs that should not be there that caused panics (merge error moving between source trees on my part). - pmap_destroy(): pmap_remove_all() doesn't work for EPT yet, so need to catch up on deferred PTP frees manually in the EPT case. - pp_embedded: Remove it. It's one more variable to go wrong and another store to be made. Just check for non-zero PTP pointer & non-zero VA instead. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.368 -r1.369 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap_pv.h diff -u src/sys/arch/x86/include/pmap_pv.h:1.14 src/sys/arch/x86/include/pmap_pv.h:1.15 --- src/sys/arch/x86/include/pmap_pv.h:1.14 Sat Mar 14 18:24:10 2020 +++ src/sys/arch/x86/include/pmap_pv.h Sun Mar 15 15:58:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_pv.h,v 1.14 2020/03/14 18:24:10 ad Exp $ */ +/* $NetBSD: pmap_pv.h,v 1.15 2020/03/15 15:58:24 ad Exp $ */ /*- * Copyright (c)2008 YAMAMOTO Takashi, @@ -79,7 +79,6 @@ struct pmap_page { struct { struct pv_pte pte; LIST_HEAD(, pv_entry) pvlist; - uint8_t embedded; uint8_t attrs; } s; } pp_u; @@ -88,7 +87,6 @@ struct pmap_page { #define pp_link pp_u.link #define pp_pte pp_u.s.pte #define pp_pvlist pp_u.s.pvlist -#define pp_embedded pp_u.s.embedded #define pp_attrs pp_u.s.attrs }; Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.368 src/sys/arch/x86/x86/pmap.c:1.369 --- src/sys/arch/x86/x86/pmap.c:1.368 Sun Mar 15 15:14:22 2020 +++ src/sys/arch/x86/x86/pmap.c Sun Mar 15 15:58:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.368 2020/03/15 15:14:22 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.369 2020/03/15 15:58:24 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.368 2020/03/15 15:14:22 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.369 2020/03/15 15:58:24 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -539,6 +539,17 @@ pvpte_to_pve(struct pv_pte *pvpte) } /* + * Return true if the pmap page has an embedded PV entry. + */ +static inline bool +pv_pte_embedded(struct pmap_page *pp) +{ + + KASSERT(mutex_owned(>pp_lock)); + return (bool)((vaddr_t)pp->pp_pte.pte_ptp | pp->pp_pte.pte_va); +} + +/* * pv_pte_first, pv_pte_next: PV list iterator. */ static struct pv_pte * @@ -546,7 +557,7 @@ pv_pte_first(struct pmap_page *pp) { KASSERT(mutex_owned(>pp_lock)); - if (pp->pp_embedded) { + if (pv_pte_embedded(pp)) { return >pp_pte; } return pve_to_pvpte(LIST_FIRST(>pp_pvlist)); @@ -2025,8 +2036,7 @@ pmap_lookup_pv(const struct pmap *pmap, * set together for this pmap. * */ - if (atomic_load_relaxed(_pp->pp_embedded) && - atomic_load_relaxed(_pp->pp_pte.pte_ptp) == ptp && + if (atomic_load_relaxed(_pp->pp_pte.pte_ptp) == ptp && atomic_load_relaxed(_pp->pp_pte.pte_va) == va) { return NULL; } @@ -2080,8 +2090,7 @@ pmap_enter_pv(struct pmap *pmap, struct * to check for this very specific set of values without a lock * because all 3 will only ever be set together for this pmap. */ - if (atomic_load_relaxed(>pp_embedded) && - atomic_load_relaxed(>pp_pte.pte_ptp) == ptp && + if (atomic_load_relaxed(>pp_pte.pte_ptp) == ptp && atomic_load_relaxed(>pp_pte.pte_va) == va) { *samepage = true; return 0; @@ -2108,13 +2117,12 @@ pmap_enter_pv(struct pmap *pmap, struct error = 0; mutex_spin_enter(>pp_lock); - if (!pp->pp_embedded) { + if (!pv_pte_embedded(pp)) { /* * Embedded PV tracking available - easy. */ pp->pp_pte.pte_ptp = ptp; pp->pp_pte.pte_va = va; - pp->pp_embedded = true; *new_embedded = true; } else if (__predict_false(pmap->pm_pve == NULL)) { /* @@ -2160,14 +2168,10 @@ pmap_remove_pv(struct pmap *pmap, struct mutex_spin_enter(>pp_lock); pp->pp_attrs |= oattrs; if (pve == NULL) { - KASSERT(pp->pp_embedded); KASSERT(pp->pp_pte.pte_ptp == ptp); KASSERT(pp->pp_pte.pte_va == va); - pp->pp_embedded = false; -#ifdef DIAGNOSTIC pp->pp_pte.pte_ptp = NULL; pp->pp_pte.pte_va = 0; -#endif mutex_spin_exit(>pp_lock); } else { KASSERT(pve == pmap_lookup_pv(pmap, ptp, pp, va)); @@ -2786,16 +2790,24 @@ pmap_destroy(struct pmap *pmap) int i; /* - * drop reference count + * drop reference count and verify not in use. */ if (atomic_dec_uint_nv(>pm_obj[0].uo_refs) > 0) { return; } - pmap_check_inuse(pmap); /* + * XXX handle deferred
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Sun Mar 15 15:58:24 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: - pmap_enter(): Remove cosmetic differences between the EPT & native cases. Remove old code to free PVEs that should not be there that caused panics (merge error moving between source trees on my part). - pmap_destroy(): pmap_remove_all() doesn't work for EPT yet, so need to catch up on deferred PTP frees manually in the EPT case. - pp_embedded: Remove it. It's one more variable to go wrong and another store to be made. Just check for non-zero PTP pointer & non-zero VA instead. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.368 -r1.369 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Sun Mar 15 15:14:23 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: pmap_enter(): look directly in the tree for old PVE when installing an unmanaged mapping, because there is no existing pmap_page to check in the shortcut path (it traps). pv_pte_next(): don't assert pp_embedded because it could have been removed (during pmap_pp_remove()). To generate a diff of this commit: cvs rdiff -u -r1.367 -r1.368 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.367 src/sys/arch/x86/x86/pmap.c:1.368 --- src/sys/arch/x86/x86/pmap.c:1.367 Sat Mar 14 20:48:40 2020 +++ src/sys/arch/x86/x86/pmap.c Sun Mar 15 15:14:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.367 2020/03/14 20:48:40 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.368 2020/03/15 15:14:22 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.367 2020/03/14 20:48:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.368 2020/03/15 15:14:22 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -559,7 +559,6 @@ pv_pte_next(struct pmap_page *pp, struct KASSERT(mutex_owned(>pp_lock)); KASSERT(pvpte != NULL); if (pvpte == >pp_pte) { - KASSERT(pp->pp_embedded); return pve_to_pvpte(LIST_FIRST(>pp_pvlist)); } return pve_to_pvpte(LIST_NEXT(pvpte_to_pve(pvpte), pve_list)); @@ -4668,7 +4667,7 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t panic("%s: alloc pve failed", __func__); } } else { - old_pve = pmap_lookup_pv(pmap, ptp, NULL, va); + old_pve = pmap_treelookup_pv(pmap, ptp, tree, va); } /* Map PTEs into address space. */ @@ -4773,6 +4772,7 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t pmap_remove_pv(pmap, old_pp, ptp, va, old_pve, pmap_pte_to_pp_attrs(opte)); if (old_pve != NULL) { + KASSERT(old_pve->pve_pp == old_pp); if (pmap->pm_pve == NULL) { pmap->pm_pve = old_pve; } else { @@ -5584,7 +5584,7 @@ pmap_ept_enter(struct pmap *pmap, vaddr_ panic("%s: alloc pve failed", __func__); } } else { - old_pve = pmap_lookup_pv(pmap, ptp, NULL, va); + old_pve = pmap_treelookup_pv(pmap, ptp, tree, va); } /* Map PTEs into address space. */ @@ -5654,6 +5654,7 @@ pmap_ept_enter(struct pmap *pmap, vaddr_ pmap_remove_pv(pmap, old_pp, ptp, va, old_pve, pmap_ept_to_pp_attrs(opte)); if (old_pve != NULL) { + KASSERT(old_pve->pve_pp == old_pp); if (pmap->pm_pve == NULL) { pmap->pm_pve = old_pve; } else {
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Sun Mar 15 15:14:23 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: pmap_enter(): look directly in the tree for old PVE when installing an unmanaged mapping, because there is no existing pmap_page to check in the shortcut path (it traps). pv_pte_next(): don't assert pp_embedded because it could have been removed (during pmap_pp_remove()). To generate a diff of this commit: cvs rdiff -u -r1.367 -r1.368 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 21:47:41 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_node.h Log Message: Update a comment. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/miscfs/genfs/genfs_node.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_node.h diff -u src/sys/miscfs/genfs/genfs_node.h:1.23 src/sys/miscfs/genfs/genfs_node.h:1.24 --- src/sys/miscfs/genfs/genfs_node.h:1.23 Wed Jan 15 17:55:44 2020 +++ src/sys/miscfs/genfs/genfs_node.h Sat Mar 14 21:47:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_node.h,v 1.23 2020/01/15 17:55:44 ad Exp $ */ +/* $NetBSD: genfs_node.h,v 1.24 2020/03/14 21:47:41 ad Exp $ */ /* * Copyright (c) 2001 Chuck Silvers. @@ -61,7 +61,7 @@ struct genfs_ops { /* * GOP_MARKUPDATE: mark vnode's timestamps for update. * - * => called with v_interlock (and possibly other locks) held. + * => called with vmobjlock (and possibly other locks) held. * => used for accesses via mmap. */
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 21:47:41 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_node.h Log Message: Update a comment. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/miscfs/genfs/genfs_node.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 21:06:35 UTC 2020 Modified Files: src/sys/uvm: uvm_page.c Log Message: Don't require a write lock for page enqueue/activate/deactivate. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/uvm/uvm_page.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_page.c diff -u src/sys/uvm/uvm_page.c:1.231 src/sys/uvm/uvm_page.c:1.232 --- src/sys/uvm/uvm_page.c:1.231 Sat Mar 14 20:23:51 2020 +++ src/sys/uvm/uvm_page.c Sat Mar 14 21:06:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_page.c,v 1.231 2020/03/14 20:23:51 ad Exp $ */ +/* $NetBSD: uvm_page.c,v 1.232 2020/03/14 21:06:35 ad Exp $ */ /*- * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.231 2020/03/14 20:23:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.232 2020/03/14 21:06:35 ad Exp $"); #include "opt_ddb.h" #include "opt_uvm.h" @@ -1908,7 +1908,7 @@ void uvm_pagedeactivate(struct vm_page *pg) { - KASSERT(uvm_page_owner_locked_p(pg, true)); + KASSERT(uvm_page_owner_locked_p(pg, false)); KASSERT(mutex_owned(>interlock)); if (pg->wire_count == 0) { KASSERT(uvmpdpol_pageisqueued_p(pg)); @@ -1927,7 +1927,7 @@ void uvm_pageactivate(struct vm_page *pg) { - KASSERT(uvm_page_owner_locked_p(pg, true)); + KASSERT(uvm_page_owner_locked_p(pg, false)); KASSERT(mutex_owned(>interlock)); #if defined(READAHEAD_STATS) if ((pg->flags & PG_READAHEAD) != 0) { @@ -1968,7 +1968,7 @@ void uvm_pageenqueue(struct vm_page *pg) { - KASSERT(uvm_page_owner_locked_p(pg, true)); + KASSERT(uvm_page_owner_locked_p(pg, false)); KASSERT(mutex_owned(>interlock)); if (pg->wire_count == 0 && !uvmpdpol_pageisqueued_p(pg)) { uvmpdpol_pageenqueue(pg);
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 21:06:35 UTC 2020 Modified Files: src/sys/uvm: uvm_page.c Log Message: Don't require a write lock for page enqueue/activate/deactivate. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/uvm/uvm_page.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Sat Mar 14 20:48:40 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Re: kern/55071 (Panic shortly after running X11 due to kernel diagnostic assertion "mutex_owned(>pp_lock)") pmap_pp_remove(): get rid of a "goto" to make it clearer what's going on. To generate a diff of this commit: cvs rdiff -u -r1.366 -r1.367 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: ad Date: Sat Mar 14 20:48:40 UTC 2020 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Re: kern/55071 (Panic shortly after running X11 due to kernel diagnostic assertion "mutex_owned(>pp_lock)") pmap_pp_remove(): get rid of a "goto" to make it clearer what's going on. To generate a diff of this commit: cvs rdiff -u -r1.366 -r1.367 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.366 src/sys/arch/x86/x86/pmap.c:1.367 --- src/sys/arch/x86/x86/pmap.c:1.366 Sat Mar 14 18:24:10 2020 +++ src/sys/arch/x86/x86/pmap.c Sat Mar 14 20:48:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.366 2020/03/14 18:24:10 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.367 2020/03/14 20:48:40 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.366 2020/03/14 18:24:10 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.367 2020/03/14 20:48:40 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -4115,15 +4115,19 @@ pmap_pp_remove(struct pmap_page *pp, pad count = SPINLOCK_BACKOFF_MIN; kpreempt_disable(); -startover: - mutex_spin_enter(>pp_lock); - while ((pvpte = pv_pte_first(pp)) != NULL) { + for (;;) { struct pmap *pmap; struct pv_entry *pve; pt_entry_t opte; vaddr_t va; int error; + mutex_spin_enter(>pp_lock); + if ((pvpte = pv_pte_first(pp)) == NULL) { + mutex_spin_exit(>pp_lock); + break; + } + /* * Add a reference to the pmap before clearing the pte. * Otherwise the pmap can disappear behind us. @@ -4150,7 +4154,7 @@ startover: if (ptp != NULL) { pmap_destroy(pmap); } - goto startover; + continue; } error = pmap_sync_pv(pvpte, pa, ~0, , ); @@ -4167,7 +4171,7 @@ startover: } SPINLOCK_BACKOFF(count); KERNEL_LOCK(hold_count, curlwp); - goto startover; + continue; } va = pvpte->pte_va; @@ -4196,9 +4200,7 @@ startover: if (ptp != NULL) { pmap_destroy(pmap); } - mutex_spin_enter(>pp_lock); } - mutex_spin_exit(>pp_lock); kpreempt_enable(); }
CVS commit: src
Module Name:src Committed By: ad Date: Sat Mar 14 20:45:24 UTC 2020 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c src/sys/kern: vfs_subr.c src/sys/miscfs/genfs: genfs_io.c src/sys/sys: vnode.h src/sys/ufs/lfs: lfs_pages.c src/sys/uvm: uvm_object.h uvm_page_status.c uvm_pager.h uvm_vnode.c Log Message: Make uvm_pagemarkdirty() responsible for putting vnodes onto the syncer work list. Proposed on tech-kern@. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c cvs rdiff -u -r1.483 -r1.484 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.92 -r1.93 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.292 -r1.293 src/sys/sys/vnode.h cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/lfs/lfs_pages.c cvs rdiff -u -r1.37 -r1.38 src/sys/uvm/uvm_object.h cvs rdiff -u -r1.3 -r1.4 src/sys/uvm/uvm_page_status.c cvs rdiff -u -r1.45 -r1.46 src/sys/uvm/uvm_pager.h cvs rdiff -u -r1.109 -r1.110 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ad Date: Sat Mar 14 20:45:24 UTC 2020 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c src/sys/kern: vfs_subr.c src/sys/miscfs/genfs: genfs_io.c src/sys/sys: vnode.h src/sys/ufs/lfs: lfs_pages.c src/sys/uvm: uvm_object.h uvm_page_status.c uvm_pager.h uvm_vnode.c Log Message: Make uvm_pagemarkdirty() responsible for putting vnodes onto the syncer work list. Proposed on tech-kern@. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c cvs rdiff -u -r1.483 -r1.484 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.92 -r1.93 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.292 -r1.293 src/sys/sys/vnode.h cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/lfs/lfs_pages.c cvs rdiff -u -r1.37 -r1.38 src/sys/uvm/uvm_object.h cvs rdiff -u -r1.3 -r1.4 src/sys/uvm/uvm_page_status.c cvs rdiff -u -r1.45 -r1.46 src/sys/uvm/uvm_pager.h cvs rdiff -u -r1.109 -r1.110 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.63 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.64 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.63 Sun Mar 8 19:59:45 2020 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Sat Mar 14 20:45:23 2020 @@ -6028,19 +6028,9 @@ zfs_netbsd_getpages(void *v) pg->flags &= ~(PG_FAKE); } - if (memwrite) { - if (uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN) { - /* For write faults, start dirtiness tracking. */ - uvm_pagemarkdirty(pg, UVM_PAGE_STATUS_UNKNOWN); - } - mutex_enter(vp->v_interlock); - if ((vp->v_iflag & VI_ONWORKLST) == 0) { - vn_syncer_add_to_worklist(vp, filedelay); - } - if ((vp->v_iflag & (VI_WRMAP|VI_WRMAPDIRTY)) == VI_WRMAP) { - vp->v_iflag |= VI_WRMAPDIRTY; - } - mutex_exit(vp->v_interlock); + if (memwrite && uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN) { + /* For write faults, start dirtiness tracking. */ + uvm_pagemarkdirty(pg, UVM_PAGE_STATUS_UNKNOWN); } rw_exit(rw); ap->a_m[ap->a_centeridx] = pg; Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.483 src/sys/kern/vfs_subr.c:1.484 --- src/sys/kern/vfs_subr.c:1.483 Sun Mar 1 21:39:07 2020 +++ src/sys/kern/vfs_subr.c Sat Mar 14 20:45:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.483 2020/03/01 21:39:07 ad Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.484 2020/03/14 20:45:23 ad Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008, 2019, 2020 @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.483 2020/03/01 21:39:07 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.484 2020/03/14 20:45:23 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -422,10 +422,8 @@ brelvp(struct buf *bp) bufremvn(bp); if ((vp->v_iflag & (VI_ONWORKLST | VI_PAGES)) == VI_ONWORKLST && - LIST_FIRST(>v_dirtyblkhd) == NULL) { - KASSERT((vp->v_iflag & VI_WRMAPDIRTY) == 0); + LIST_FIRST(>v_dirtyblkhd) == NULL) vn_syncer_remove_from_worklist(vp); - } bp->b_objlock = _lock; bp->b_vp = NULL; @@ -463,10 +461,8 @@ reassignbuf(struct buf *bp, struct vnode listheadp = >v_cleanblkhd; if ((vp->v_iflag & (VI_ONWORKLST | VI_PAGES)) == VI_ONWORKLST && - LIST_FIRST(>v_dirtyblkhd) == NULL) { - KASSERT((vp->v_iflag & VI_WRMAPDIRTY) == 0); + LIST_FIRST(>v_dirtyblkhd) == NULL) vn_syncer_remove_from_worklist(vp); - } } else { listheadp = >v_dirtyblkhd; if ((vp->v_iflag & VI_ONWORKLST) == 0) { Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.92 src/sys/miscfs/genfs/genfs_io.c:1.93 --- src/sys/miscfs/genfs/genfs_io.c:1.92 Sat Mar 14 20:23:51 2020 +++ src/sys/miscfs/genfs/genfs_io.c Sat Mar 14 20:45:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.92 2020/03/14 20:23:51 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.93 2020/03/14 20:45:23 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.92 2020/03/14 20:23:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.93 2020/03/14 20:45:23 ad Exp $"); #include #include @@ -61,7 +61,6 @@ static int genfs_getpages_read(struct vn static int genfs_do_io(struct vnode *, off_t, vaddr_t, size_t, int, enum uio_rw, void (*)(struct buf *)); static void genfs_rel_pages(struct vm_page **, unsigned int); -static void genfs_markdirty(struct vnode *); int genfs_maxdio = MAXPHYS; @@ -83,22 +82,6 @@ genfs_rel_pages(struct vm_page **pgs, un uvm_page_unbusy(pgs, npages); } -static void -genfs_markdirty(struct vnode *vp) -{ - - KASSERT(rw_write_held(vp->v_uobj.vmobjlock)); - - mutex_enter(vp->v_interlock); - if
CVS commit: src/tests/rump/kernspace
Module Name:src Committed By: ad Date: Sat Mar 14 20:25:47 UTC 2020 Modified Files: src/tests/rump/kernspace: busypage.c Log Message: Catch up with reality. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/rump/kernspace/busypage.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/rump/kernspace/busypage.c diff -u src/tests/rump/kernspace/busypage.c:1.6 src/tests/rump/kernspace/busypage.c:1.7 --- src/tests/rump/kernspace/busypage.c:1.6 Sun Feb 23 15:46:43 2020 +++ src/tests/rump/kernspace/busypage.c Sat Mar 14 20:25:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: busypage.c,v 1.6 2020/02/23 15:46:43 ad Exp $ */ +/* $NetBSD: busypage.c,v 1.7 2020/03/14 20:25:46 ad Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: busypage.c,v 1.6 2020/02/23 15:46:43 ad Exp $"); +__RCSID("$NetBSD: busypage.c,v 1.7 2020/03/14 20:25:46 ad Exp $"); #endif /* !lint */ #include @@ -52,15 +52,14 @@ static void thread(void *arg) { - rw_enter(uobj->vmobjlock, RW_WRITER); + mutex_enter(>interlock); threadrun = true; -#ifdef notyet cv_signal(); -#else - wakeup(); -#endif - testpg->flags |= PG_WANTED; - UVM_UNLOCK_AND_WAIT_RW(testpg, uobj->vmobjlock, false, "tw", 0); + mutex_exit(>interlock); + + rw_enter(uobj->vmobjlock, RW_READER); + uvm_pagewait(testpg, uobj->vmobjlock, "tw"); + kthread_exit(0); } @@ -84,16 +83,17 @@ rumptest_busypage() if (rv) panic("thread creation failed: %d", rv); - rw_enter(uobj->vmobjlock, RW_WRITER); -#ifdef notyet - while (!threadrun) - cv_wait(, uobj->vmobjlock); -#else + kpause("lolgic", false, mstohz(100), NULL); + + mutex_enter(>interlock); while (!threadrun) - rwtsleep(, 0, "nutter", 0, uobj->vmobjlock); -#endif + cv_wait(, >interlock); + mutex_exit(>interlock); - uvm_page_unbusy(, 1); + rw_enter(uobj->vmobjlock, RW_WRITER); + mutex_enter(>interlock); + uvm_pageunbusy(testpg); + mutex_exit(>interlock); rw_exit(uobj->vmobjlock); rv = kthread_join(newl);
CVS commit: src/tests/rump/kernspace
Module Name:src Committed By: ad Date: Sat Mar 14 20:25:47 UTC 2020 Modified Files: src/tests/rump/kernspace: busypage.c Log Message: Catch up with reality. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/rump/kernspace/busypage.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Sat Mar 14 20:23:51 UTC 2020 Modified Files: src/sys/kern: kern_synch.c src/sys/miscfs/genfs: genfs_io.c src/sys/rump/librump/rumpkern: ltsleep.c vm.c src/sys/sys: proc.h src/sys/ufs/lfs: lfs_pages.c lfs_vfsops.c src/sys/uvm: uvm.h uvm_amap.c uvm_anon.c uvm_aobj.c uvm_bio.c uvm_fault.c uvm_km.c uvm_loan.c uvm_page.c uvm_page.h uvm_vnode.c Log Message: Make page waits (WANTED vs BUSY) interlocked by pg->interlock. Gets RW locks out of the equation for sleep/wakeup, and allows observing+waiting for busy pages when holding only a read lock. Proposed on tech-kern. To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/sys/kern/kern_synch.c cvs rdiff -u -r1.91 -r1.92 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.35 -r1.36 src/sys/rump/librump/rumpkern/ltsleep.c cvs rdiff -u -r1.185 -r1.186 src/sys/rump/librump/rumpkern/vm.c cvs rdiff -u -r1.359 -r1.360 src/sys/sys/proc.h cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/lfs_pages.c cvs rdiff -u -r1.375 -r1.376 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.75 -r1.76 src/sys/uvm/uvm.h cvs rdiff -u -r1.117 -r1.118 src/sys/uvm/uvm_amap.c cvs rdiff -u -r1.74 -r1.75 src/sys/uvm/uvm_anon.c cvs rdiff -u -r1.136 -r1.137 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.104 -r1.105 src/sys/uvm/uvm_bio.c cvs rdiff -u -r1.217 -r1.218 src/sys/uvm/uvm_fault.c cvs rdiff -u -r1.156 -r1.157 src/sys/uvm/uvm_km.c cvs rdiff -u -r1.96 -r1.97 src/sys/uvm/uvm_loan.c cvs rdiff -u -r1.230 -r1.231 src/sys/uvm/uvm_page.c cvs rdiff -u -r1.99 -r1.100 src/sys/uvm/uvm_page.h cvs rdiff -u -r1.108 -r1.109 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_synch.c diff -u src/sys/kern/kern_synch.c:1.343 src/sys/kern/kern_synch.c:1.344 --- src/sys/kern/kern_synch.c:1.343 Sat Mar 14 18:08:39 2020 +++ src/sys/kern/kern_synch.c Sat Mar 14 20:23:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_synch.c,v 1.343 2020/03/14 18:08:39 ad Exp $ */ +/* $NetBSD: kern_synch.c,v 1.344 2020/03/14 20:23:51 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019, 2020 @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.343 2020/03/14 18:08:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.344 2020/03/14 20:23:51 ad Exp $"); #include "opt_kstack.h" #include "opt_dtrace.h" @@ -220,46 +220,6 @@ mtsleep(wchan_t ident, pri_t priority, c } /* - * XXXAD Temporary - for use of UVM only. PLEASE DO NOT USE ELSEWHERE. - * Will go once there is a better solution, eg waits interlocked by - * pg->interlock. To wake an LWP sleeping with this, you need to hold a - * write lock. - */ -int -rwtsleep(wchan_t ident, pri_t priority, const char *wmesg, int timo, - krwlock_t *rw) -{ - struct lwp *l = curlwp; - sleepq_t *sq; - kmutex_t *mp; - int error; - krw_t op; - - KASSERT((l->l_pflag & LP_INTR) == 0); - KASSERT(ident != ); - - if (sleepq_dontsleep(l)) { - (void)sleepq_abort(NULL, (priority & PNORELOCK) != 0); - if ((priority & PNORELOCK) != 0) - rw_exit(rw); - return 0; - } - - l->l_kpriority = true; - sq = sleeptab_lookup(, ident, ); - sleepq_enter(sq, l, mp); - sleepq_enqueue(sq, ident, wmesg, _syncobj); - op = rw_lock_op(rw); - rw_exit(rw); - error = sleepq_block(timo, priority & PCATCH); - - if ((priority & PNORELOCK) == 0) - rw_enter(rw, op); - - return error; -} - -/* * General sleep call for situations where a wake-up is not expected. */ int Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.91 src/sys/miscfs/genfs/genfs_io.c:1.92 --- src/sys/miscfs/genfs/genfs_io.c:1.91 Sat Mar 14 19:07:22 2020 +++ src/sys/miscfs/genfs/genfs_io.c Sat Mar 14 20:23:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.92 2020/03/14 20:23:51 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.92 2020/03/14 20:23:51 ad Exp $"); #include #include @@ -524,9 +524,6 @@ out: if (i < ridx || i >= ridx + orignmempages || async) { UVMHIST_LOG(ubchist, "unbusy pg %#jx offset 0x%jx", (uintptr_t)pg, pg->offset,0,0); - if (pg->flags & PG_WANTED) { -wakeup(pg); - } if (pg->flags & PG_FAKE) { KASSERT(overwrite); uvm_pagezero(pg); @@ -537,8 +534,9 @@ out: } uvm_pagelock(pg); uvm_pageenqueue(pg); + uvm_pageunbusy(pg); uvm_pageunlock(pg); - pg->flags &= ~(PG_WANTED|PG_BUSY|PG_FAKE); + pg->flags &= ~PG_FAKE; UVM_PAGE_OWN(pg, NULL); } else if (memwrite && !overwrite && uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN) { @@ -1093,8 +1091,7 @@ retry: continue; } nextoff = pg->offset; /* visit this
CVS commit: src/sys
Module Name:src Committed By: ad Date: Sat Mar 14 20:23:51 UTC 2020 Modified Files: src/sys/kern: kern_synch.c src/sys/miscfs/genfs: genfs_io.c src/sys/rump/librump/rumpkern: ltsleep.c vm.c src/sys/sys: proc.h src/sys/ufs/lfs: lfs_pages.c lfs_vfsops.c src/sys/uvm: uvm.h uvm_amap.c uvm_anon.c uvm_aobj.c uvm_bio.c uvm_fault.c uvm_km.c uvm_loan.c uvm_page.c uvm_page.h uvm_vnode.c Log Message: Make page waits (WANTED vs BUSY) interlocked by pg->interlock. Gets RW locks out of the equation for sleep/wakeup, and allows observing+waiting for busy pages when holding only a read lock. Proposed on tech-kern. To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/sys/kern/kern_synch.c cvs rdiff -u -r1.91 -r1.92 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.35 -r1.36 src/sys/rump/librump/rumpkern/ltsleep.c cvs rdiff -u -r1.185 -r1.186 src/sys/rump/librump/rumpkern/vm.c cvs rdiff -u -r1.359 -r1.360 src/sys/sys/proc.h cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/lfs_pages.c cvs rdiff -u -r1.375 -r1.376 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.75 -r1.76 src/sys/uvm/uvm.h cvs rdiff -u -r1.117 -r1.118 src/sys/uvm/uvm_amap.c cvs rdiff -u -r1.74 -r1.75 src/sys/uvm/uvm_anon.c cvs rdiff -u -r1.136 -r1.137 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.104 -r1.105 src/sys/uvm/uvm_bio.c cvs rdiff -u -r1.217 -r1.218 src/sys/uvm/uvm_fault.c cvs rdiff -u -r1.156 -r1.157 src/sys/uvm/uvm_km.c cvs rdiff -u -r1.96 -r1.97 src/sys/uvm/uvm_loan.c cvs rdiff -u -r1.230 -r1.231 src/sys/uvm/uvm_page.c cvs rdiff -u -r1.99 -r1.100 src/sys/uvm/uvm_page.h cvs rdiff -u -r1.108 -r1.109 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: ad Date: Sat Mar 14 19:54:06 UTC 2020 Modified Files: src/sys/rump/librump/rumpkern: vm.c Log Message: rump - page/object dirtyness tracking corrections. To generate a diff of this commit: cvs rdiff -u -r1.184 -r1.185 src/sys/rump/librump/rumpkern/vm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/vm.c diff -u src/sys/rump/librump/rumpkern/vm.c:1.184 src/sys/rump/librump/rumpkern/vm.c:1.185 --- src/sys/rump/librump/rumpkern/vm.c:1.184 Sun Feb 23 15:46:42 2020 +++ src/sys/rump/librump/rumpkern/vm.c Sat Mar 14 19:54:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm.c,v 1.184 2020/02/23 15:46:42 ad Exp $ */ +/* $NetBSD: vm.c,v 1.185 2020/03/14 19:54:06 ad Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.184 2020/02/23 15:46:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.185 2020/03/14 19:54:06 ad Exp $"); #include #include @@ -172,9 +172,11 @@ uvm_pagealloc_strat(struct uvm_object *u pg->offset = off; pg->uobject = uobj; - pg->flags = PG_CLEAN|PG_BUSY|PG_FAKE; - if (flags & UVM_PGA_ZERO) { - uvm_pagezero(pg); + if (UVM_OBJ_IS_VNODE(uobj) && uobj->uo_npages == 0) { + struct vnode *vp = (struct vnode *)uobj; + mutex_enter(vp->v_interlock); + vp->v_iflag |= VI_PAGES; + mutex_exit(vp->v_interlock); } if (radix_tree_insert_node(>uo_pages, off >> PAGE_SHIFT, @@ -182,6 +184,12 @@ uvm_pagealloc_strat(struct uvm_object *u pool_cache_put(, pg); return NULL; } + uobj->uo_npages++; + + pg->flags = PG_CLEAN|PG_BUSY|PG_FAKE; + if (flags & UVM_PGA_ZERO) { + uvm_pagezero(pg); + } /* * Don't put anons on the LRU page queue. We can't flush them @@ -195,8 +203,6 @@ uvm_pagealloc_strat(struct uvm_object *u mutex_exit(_lruqueue_lock); } - uobj->uo_npages++; - return pg; } @@ -227,6 +233,13 @@ uvm_pagefree(struct vm_page *pg) atomic_dec_uint(_onqueue); } + if (UVM_OBJ_IS_VNODE(uobj) && uobj->uo_npages == 0) { + struct vnode *vp = (struct vnode *)uobj; + mutex_enter(vp->v_interlock); + vp->v_iflag &= ~VI_PAGES; + mutex_exit(vp->v_interlock); + } + mutex_destroy(>interlock); pool_cache_put(, pg); }
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: ad Date: Sat Mar 14 19:54:06 UTC 2020 Modified Files: src/sys/rump/librump/rumpkern: vm.c Log Message: rump - page/object dirtyness tracking corrections. To generate a diff of this commit: cvs rdiff -u -r1.184 -r1.185 src/sys/rump/librump/rumpkern/vm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 19:07:22 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Unused variable. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.90 src/sys/miscfs/genfs/genfs_io.c:1.91 --- src/sys/miscfs/genfs/genfs_io.c:1.90 Sat Mar 14 18:08:39 2020 +++ src/sys/miscfs/genfs/genfs_io.c Sat Mar 14 19:07:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.90 2020/03/14 18:08:39 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.90 2020/03/14 18:08:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $"); #include #include @@ -884,7 +884,6 @@ genfs_do_putpages(struct vnode *vp, off_ bool wasclean, needs_clean; bool async = (origflags & PGO_SYNCIO) == 0; bool pagedaemon = curlwp == uvm.pagedaemon_lwp; - struct lwp * const l = curlwp ? curlwp : struct mount *trans_mp; int flags; bool modified; /* if we write out any pages */
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 19:07:22 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Unused variable. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Sat Mar 14 18:24:10 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: PR kern/55071 (Panic shortly after running X11 due to kernel diagnostic assertion "mutex_owned(>pp_lock)") - Fix a locking bug in pmap_pp_clear_attrs() and in pmap_pp_remove() do the TLB shootdown while still holding the target pmap's lock. Also: - Finish PV list locking for x86 & update comments around same. - Keep track of the min/max index of PTEs inserted into each PTP, and use that to clip ranges of VAs passed to pmap_remove_ptes(). - Based on the above, implement a pmap_remove_all() for x86 that clears out the pmap in a single pass. Makes exit() / fork() much cheaper. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.365 -r1.366 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.112 src/sys/arch/x86/include/pmap.h:1.113 --- src/sys/arch/x86/include/pmap.h:1.112 Sat Mar 14 14:05:44 2020 +++ src/sys/arch/x86/include/pmap.h Sat Mar 14 18:24:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.112 2020/03/14 14:05:44 ad Exp $ */ +/* $NetBSD: pmap.h,v 1.113 2020/03/14 18:24:10 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -248,6 +248,8 @@ extern struct pool_cache pmap_cache; * (the other object locks are only used when uvm_pagealloc is called) */ +struct pv_page; + struct pmap { struct uvm_object pm_obj[PTP_LEVELS-1];/* objects for lvl >= 1) */ LIST_ENTRY(pmap) pm_list; /* list of all pmaps */ @@ -256,11 +258,11 @@ struct pmap { struct vm_page *pm_ptphint[PTP_LEVELS-1]; /* pointer to a PTP in our pmap */ struct pmap_statistics pm_stats; /* pmap stats */ + struct pv_entry *pm_pve; /* spare pv_entry */ #if !defined(__x86_64__) vaddr_t pm_hiexec; /* highest executable mapping */ #endif /* !defined(__x86_64__) */ - struct lwp *pm_remove_all; /* who's emptying the pmap */ union descriptor *pm_ldt; /* user-set LDT */ size_t pm_ldt_len; /* size of LDT in bytes */ Index: src/sys/arch/x86/include/pmap_pv.h diff -u src/sys/arch/x86/include/pmap_pv.h:1.13 src/sys/arch/x86/include/pmap_pv.h:1.14 --- src/sys/arch/x86/include/pmap_pv.h:1.13 Tue Mar 10 22:38:41 2020 +++ src/sys/arch/x86/include/pmap_pv.h Sat Mar 14 18:24:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_pv.h,v 1.13 2020/03/10 22:38:41 ad Exp $ */ +/* $NetBSD: pmap_pv.h,v 1.14 2020/03/14 18:24:10 ad Exp $ */ /*- * Copyright (c)2008 YAMAMOTO Takashi, @@ -34,6 +34,7 @@ #include struct vm_page; +struct pmap_page; /* * structures to track P->V mapping @@ -51,14 +52,14 @@ struct pv_pte { }; /* - * pv_entry: plug pv_pte into lists. + * pv_entry: plug pv_pte into lists. 32 bytes on i386, 64 on amd64. */ struct pv_entry { struct pv_pte pve_pte; /* should be the first member */ LIST_ENTRY(pv_entry) pve_list; /* on pmap_page::pp_pvlist */ rb_node_t pve_rb; /* red-black tree node */ - uintptr_t pve_padding; /* unused */ + struct pmap_page *pve_pp; /* backpointer to mapped page */ }; #define pve_next pve_list.le_next @@ -71,16 +72,14 @@ struct pmap_page { /* PTPs */ rb_tree_t rb; - /* PTPs */ + /* PTPs, when being freed */ LIST_ENTRY(vm_page) link; - /* Non-PTPs */ + /* Non-PTPs (i.e. normal pages) */ struct { - /* PP_EMBEDDED */ struct pv_pte pte; - LIST_HEAD(, pv_entry) pvlist; - uint8_t flags; + uint8_t embedded; uint8_t attrs; } s; } pp_u; @@ -89,7 +88,7 @@ struct pmap_page { #define pp_link pp_u.link #define pp_pte pp_u.s.pte #define pp_pvlist pp_u.s.pvlist -#define pp_pflags pp_u.s.flags +#define pp_embedded pp_u.s.embedded #define pp_attrs pp_u.s.attrs }; @@ -97,10 +96,6 @@ struct pmap_page { #define PP_ATTRS_A 0x02 /* Accessed */ #define PP_ATTRS_W 0x04 /* Writable */ -/* pp_flags */ -#define PP_EMBEDDED 1 -#define PP_FREEING 2 - #define PMAP_PAGE_INIT(pp) \ do { \ LIST_INIT(&(pp)->pp_pvlist); \ Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.365 src/sys/arch/x86/x86/pmap.c:1.366 --- src/sys/arch/x86/x86/pmap.c:1.365 Sat Mar 14 14:05:44 2020 +++ src/sys/arch/x86/x86/pmap.c Sat Mar 14 18:24:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.365 2020/03/14 14:05:44 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.366 2020/03/14 18:24:10 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.365 2020/03/14 14:05:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.366 2020/03/14 18:24:10 ad Exp $"); #include "opt_user_ldt.h" #include
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Sat Mar 14 18:24:10 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: PR kern/55071 (Panic shortly after running X11 due to kernel diagnostic assertion "mutex_owned(>pp_lock)") - Fix a locking bug in pmap_pp_clear_attrs() and in pmap_pp_remove() do the TLB shootdown while still holding the target pmap's lock. Also: - Finish PV list locking for x86 & update comments around same. - Keep track of the min/max index of PTEs inserted into each PTP, and use that to clip ranges of VAs passed to pmap_remove_ptes(). - Based on the above, implement a pmap_remove_all() for x86 that clears out the pmap in a single pass. Makes exit() / fork() much cheaper. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.365 -r1.366 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Sat Mar 14 18:08:40 UTC 2020 Modified Files: src/sys/arch/arm/arm32: bus_dma.c src/sys/arch/mips/mips: bus_dma.c src/sys/arch/x86/x86: bus_dma.c src/sys/compat/linux/common: linux_futex.c src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c src/sys/dev/pci/qat: qatvar.h src/sys/external/bsd/drm2/include/linux: sched.h src/sys/kern: kern_ktrace.c kern_synch.c subr_copy.c vfs_bio.c src/sys/miscfs/genfs: genfs_io.c src/sys/nfs: nfs_syscalls.c src/sys/rump/librump/rumpkern: scheduler.c src/sys/sys: sched.h src/sys/ufs/ext2fs: ext2fs_lookup.c src/sys/ufs/lfs: ulfs_dirhash.c ulfs_lookup.c src/sys/ufs/ufs: ufs_dirhash.c ufs_lookup.c src/sys/uvm: uvm_amap.c Log Message: - Hide the details of SPCF_SHOULDYIELD and related behind a couple of small functions: preempt_point() and preempt_needed(). - preempt(): if the LWP has exceeded its timeslice in kernel, strip it of any priority boost gained earlier from blocking. To generate a diff of this commit: cvs rdiff -u -r1.120 -r1.121 src/sys/arch/arm/arm32/bus_dma.c cvs rdiff -u -r1.39 -r1.40 src/sys/arch/mips/mips/bus_dma.c cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/x86/bus_dma.c cvs rdiff -u -r1.37 -r1.38 src/sys/compat/linux/common/linux_futex.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.50 -r1.51 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/qat/qatvar.h cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/sched.h cvs rdiff -u -r1.175 -r1.176 src/sys/kern/kern_ktrace.c cvs rdiff -u -r1.342 -r1.343 src/sys/kern/kern_synch.c cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_copy.c cvs rdiff -u -r1.289 -r1.290 src/sys/kern/vfs_bio.c cvs rdiff -u -r1.89 -r1.90 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.161 -r1.162 src/sys/nfs/nfs_syscalls.c cvs rdiff -u -r1.50 -r1.51 src/sys/rump/librump/rumpkern/scheduler.c cvs rdiff -u -r1.87 -r1.88 src/sys/sys/sched.h cvs rdiff -u -r1.88 -r1.89 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/lfs/ulfs_dirhash.c cvs rdiff -u -r1.41 -r1.42 src/sys/ufs/lfs/ulfs_lookup.c cvs rdiff -u -r1.38 -r1.39 src/sys/ufs/ufs/ufs_dirhash.c cvs rdiff -u -r1.150 -r1.151 src/sys/ufs/ufs/ufs_lookup.c cvs rdiff -u -r1.116 -r1.117 src/sys/uvm/uvm_amap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Sat Mar 14 18:08:40 UTC 2020 Modified Files: src/sys/arch/arm/arm32: bus_dma.c src/sys/arch/mips/mips: bus_dma.c src/sys/arch/x86/x86: bus_dma.c src/sys/compat/linux/common: linux_futex.c src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c src/sys/dev/pci/qat: qatvar.h src/sys/external/bsd/drm2/include/linux: sched.h src/sys/kern: kern_ktrace.c kern_synch.c subr_copy.c vfs_bio.c src/sys/miscfs/genfs: genfs_io.c src/sys/nfs: nfs_syscalls.c src/sys/rump/librump/rumpkern: scheduler.c src/sys/sys: sched.h src/sys/ufs/ext2fs: ext2fs_lookup.c src/sys/ufs/lfs: ulfs_dirhash.c ulfs_lookup.c src/sys/ufs/ufs: ufs_dirhash.c ufs_lookup.c src/sys/uvm: uvm_amap.c Log Message: - Hide the details of SPCF_SHOULDYIELD and related behind a couple of small functions: preempt_point() and preempt_needed(). - preempt(): if the LWP has exceeded its timeslice in kernel, strip it of any priority boost gained earlier from blocking. To generate a diff of this commit: cvs rdiff -u -r1.120 -r1.121 src/sys/arch/arm/arm32/bus_dma.c cvs rdiff -u -r1.39 -r1.40 src/sys/arch/mips/mips/bus_dma.c cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/x86/bus_dma.c cvs rdiff -u -r1.37 -r1.38 src/sys/compat/linux/common/linux_futex.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.50 -r1.51 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/qat/qatvar.h cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/sched.h cvs rdiff -u -r1.175 -r1.176 src/sys/kern/kern_ktrace.c cvs rdiff -u -r1.342 -r1.343 src/sys/kern/kern_synch.c cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_copy.c cvs rdiff -u -r1.289 -r1.290 src/sys/kern/vfs_bio.c cvs rdiff -u -r1.89 -r1.90 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.161 -r1.162 src/sys/nfs/nfs_syscalls.c cvs rdiff -u -r1.50 -r1.51 src/sys/rump/librump/rumpkern/scheduler.c cvs rdiff -u -r1.87 -r1.88 src/sys/sys/sched.h cvs rdiff -u -r1.88 -r1.89 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/lfs/ulfs_dirhash.c cvs rdiff -u -r1.41 -r1.42 src/sys/ufs/lfs/ulfs_lookup.c cvs rdiff -u -r1.38 -r1.39 src/sys/ufs/ufs/ufs_dirhash.c cvs rdiff -u -r1.150 -r1.151 src/sys/ufs/ufs/ufs_lookup.c cvs rdiff -u -r1.116 -r1.117 src/sys/uvm/uvm_amap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/arm32/bus_dma.c diff -u src/sys/arch/arm/arm32/bus_dma.c:1.120 src/sys/arch/arm/arm32/bus_dma.c:1.121 --- src/sys/arch/arm/arm32/bus_dma.c:1.120 Sat Feb 22 08:22:09 2020 +++ src/sys/arch/arm/arm32/bus_dma.c Sat Mar 14 18:08:38 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: bus_dma.c,v 1.120 2020/02/22 08:22:09 skrll Exp $ */ +/* $NetBSD: bus_dma.c,v 1.121 2020/03/14 18:08:38 ad Exp $ */ /*- - * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1996, 1997, 1998, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -36,7 +36,7 @@ #include "opt_cputypes.h" #include -__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.120 2020/02/22 08:22:09 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.121 2020/03/14 18:08:38 ad Exp $"); #include #include @@ -1790,10 +1790,8 @@ _bus_dma_uiomove(void *buf, struct uio * continue; cnt = MIN(resid, iov->iov_len); - if (!VMSPACE_IS_KERNEL_P(vm) && - (curlwp->l_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) - != 0) { - preempt(); + if (!VMSPACE_IS_KERNEL_P(vm)) { + preempt_point(); } if (direction == UIO_READ) { error = copyout_vmspace(vm, cp, iov->iov_base, cnt); Index: src/sys/arch/mips/mips/bus_dma.c diff -u src/sys/arch/mips/mips/bus_dma.c:1.39 src/sys/arch/mips/mips/bus_dma.c:1.40 --- src/sys/arch/mips/mips/bus_dma.c:1.39 Fri Mar 13 03:49:39 2020 +++ src/sys/arch/mips/mips/bus_dma.c Sat Mar 14 18:08:38 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: bus_dma.c,v 1.39 2020/03/13 03:49:39 thorpej Exp $ */ +/* $NetBSD: bus_dma.c,v 1.40 2020/03/14 18:08:38 ad Exp $ */ /*- - * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc. + * Copyright (c) 1997, 1998, 2001, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -32,7 +32,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.39 2020/03/13 03:49:39 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.40 2020/03/14 18:08:38 ad Exp $"); #define _MIPS_BUS_DMA_PRIVATE @@ -1291,10 +1291,8 @@ _bus_dma_uiomove(void *buf, struct uio * continue; cnt = MIN(resid, iov->iov_len); - if (!VMSPACE_IS_KERNEL_P(vm) && - (curlwp->l_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) - != 0) { -
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 17:29:53 UTC 2020 Modified Files: src/sys/uvm: uvm_map.c Log Message: uvm_map_lookup_entry(): save the hint even on failure, since code elsewhere relies on it pointing to the previous entry. To generate a diff of this commit: cvs rdiff -u -r1.373 -r1.374 src/sys/uvm/uvm_map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_map.c diff -u src/sys/uvm/uvm_map.c:1.373 src/sys/uvm/uvm_map.c:1.374 --- src/sys/uvm/uvm_map.c:1.373 Sat Mar 14 14:15:43 2020 +++ src/sys/uvm/uvm_map.c Sat Mar 14 17:29:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_map.c,v 1.373 2020/03/14 14:15:43 ad Exp $ */ +/* $NetBSD: uvm_map.c,v 1.374 2020/03/14 17:29:53 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.373 2020/03/14 14:15:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.374 2020/03/14 17:29:53 ad Exp $"); #include "opt_ddb.h" #include "opt_pax.h" @@ -1719,6 +1719,7 @@ uvm_map_lookup_entry(struct vm_map *map, return (true); } + SAVE_HINT(map, map->hint, *entry); UVMHIST_LOG(maphist,"<- failed!",0,0,0,0); KDASSERT((*entry) == >header || (*entry)->end <= address); KDASSERT((*entry)->next == >header ||
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 17:29:53 UTC 2020 Modified Files: src/sys/uvm: uvm_map.c Log Message: uvm_map_lookup_entry(): save the hint even on failure, since code elsewhere relies on it pointing to the previous entry. To generate a diff of this commit: cvs rdiff -u -r1.373 -r1.374 src/sys/uvm/uvm_map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/hppa/hppa
Module Name:src Committed By: ad Date: Sat Mar 14 16:55:17 UTC 2020 Modified Files: src/sys/arch/hppa/hppa: genassym.cf Log Message: Remove unused RW lock defs. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hppa/hppa/genassym.cf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/hppa/hppa/genassym.cf diff -u src/sys/arch/hppa/hppa/genassym.cf:1.3 src/sys/arch/hppa/hppa/genassym.cf:1.4 --- src/sys/arch/hppa/hppa/genassym.cf:1.3 Thu Feb 20 08:27:38 2020 +++ src/sys/arch/hppa/hppa/genassym.cf Sat Mar 14 16:55:17 2020 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.3 2020/02/20 08:27:38 skrll Exp $ +# $NetBSD: genassym.cf,v 1.4 2020/03/14 16:55:17 ad Exp $ # $OpenBSD: genassym.cf,v 1.18 2001/09/20 18:31:14 mickey Exp $ @@ -38,7 +38,6 @@ include "opt_multiprocessor.h" endif quote #define __MUTEX_PRIVATE -quote #define __RWLOCK_PRIVATE include include @@ -48,7 +47,6 @@ include include include include -include include include @@ -108,15 +106,6 @@ define MTX_LOCK offsetof(struct kmutex, define MTX_OWNER offsetof(struct kmutex, mtx_owner) define MTX_WAITERS offsetof(struct kmutex, mtx_waiters) -define RW_OWNER offsetof(struct krwlock, rw_owner) -define RW_WRITE_LOCKED RW_WRITE_LOCKED -define RW_WRITE_WANTED RW_WRITE_WANTED -define RW_READ_INCR RW_READ_INCR -define RW_HAS_WAITERS RW_HAS_WAITERS -define RW_THREAD RW_THREAD -define RW_READER RW_READER -define RW_WRITER RW_WRITER - # saved state fields struct trapframe member TF_FLAGS tf_flags
CVS commit: src/sys/arch/hppa/hppa
Module Name:src Committed By: ad Date: Sat Mar 14 16:55:17 UTC 2020 Modified Files: src/sys/arch/hppa/hppa: genassym.cf Log Message: Remove unused RW lock defs. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hppa/hppa/genassym.cf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: ad Date: Sat Mar 14 15:35:35 UTC 2020 Modified Files: src/sys/ufs/lfs: lfs_bio.c lfs_vfsops.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/sys/ufs/lfs/lfs_bio.c cvs rdiff -u -r1.374 -r1.375 src/sys/ufs/lfs/lfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: ad Date: Sat Mar 14 15:35:35 UTC 2020 Modified Files: src/sys/ufs/lfs: lfs_bio.c lfs_vfsops.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/sys/ufs/lfs/lfs_bio.c cvs rdiff -u -r1.374 -r1.375 src/sys/ufs/lfs/lfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/lfs/lfs_bio.c diff -u src/sys/ufs/lfs/lfs_bio.c:1.146 src/sys/ufs/lfs/lfs_bio.c:1.147 --- src/sys/ufs/lfs/lfs_bio.c:1.146 Sun Feb 23 08:39:28 2020 +++ src/sys/ufs/lfs/lfs_bio.c Sat Mar 14 15:35:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_bio.c,v 1.146 2020/02/23 08:39:28 riastradh Exp $ */ +/* $NetBSD: lfs_bio.c,v 1.147 2020/03/14 15:35:35 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.146 2020/02/23 08:39:28 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.147 2020/03/14 15:35:35 ad Exp $"); #include #include @@ -735,7 +735,7 @@ lfs_newbuf(struct lfs *fs, struct vnode bp->b_error = 0; bp->b_resid = 0; bp->b_iodone = lfs_free_aiodone; - bp->b_cflags = BC_BUSY | BC_NOCACHE; + bp->b_cflags |= BC_BUSY | BC_NOCACHE; bp->b_private = fs; mutex_enter(_lock); Index: src/sys/ufs/lfs/lfs_vfsops.c diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.374 src/sys/ufs/lfs/lfs_vfsops.c:1.375 --- src/sys/ufs/lfs/lfs_vfsops.c:1.374 Sun Feb 23 15:46:42 2020 +++ src/sys/ufs/lfs/lfs_vfsops.c Sat Mar 14 15:35:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vfsops.c,v 1.374 2020/02/23 15:46:42 ad Exp $ */ +/* $NetBSD: lfs_vfsops.c,v 1.375 2020/03/14 15:35:35 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007 @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.374 2020/02/23 15:46:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.375 2020/03/14 15:35:35 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_lfs.h" @@ -2127,7 +2127,7 @@ lfs_gop_write(struct vnode *vp, struct v mbp->b_bufsize = npages << PAGE_SHIFT; mbp->b_data = (void *)kva; mbp->b_resid = mbp->b_bcount = bytes; - mbp->b_cflags = BC_BUSY|BC_AGE; + mbp->b_cflags |= BC_BUSY|BC_AGE; mbp->b_iodone = uvm_aio_aiodone; bp = NULL;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 15:34:24 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.88 src/sys/miscfs/genfs/genfs_io.c:1.89 --- src/sys/miscfs/genfs/genfs_io.c:1.88 Thu Feb 27 22:12:54 2020 +++ src/sys/miscfs/genfs/genfs_io.c Sat Mar 14 15:34:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.88 2020/02/27 22:12:54 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.89 2020/03/14 15:34:24 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.88 2020/02/27 22:12:54 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.89 2020/03/14 15:34:24 ad Exp $"); #include #include @@ -615,7 +615,7 @@ genfs_getpages_read(struct vnode *vp, st mbp->b_bufsize = totalbytes; mbp->b_data = (void *)kva; mbp->b_resid = mbp->b_bcount = bytes; - mbp->b_cflags = BC_BUSY; + mbp->b_cflags |= BC_BUSY; if (async) { mbp->b_flags = B_READ | B_ASYNC; mbp->b_iodone = uvm_aio_aiodone; @@ -1497,7 +1497,7 @@ genfs_do_io(struct vnode *vp, off_t off, mbp->b_bufsize = len; mbp->b_data = (void *)kva; mbp->b_resid = mbp->b_bcount = bytes; - mbp->b_cflags = BC_BUSY | BC_AGE; + mbp->b_cflags |= BC_BUSY | BC_AGE; if (async) { mbp->b_flags = brw | B_ASYNC; mbp->b_iodone = iodone; @@ -1735,7 +1735,7 @@ genfs_compat_gop_write(struct vnode *vp, mutex_exit(vp->v_interlock); bp = getiobuf(vp, true); - bp->b_cflags = BC_BUSY | BC_AGE; + bp->b_cflags |= BC_BUSY | BC_AGE; bp->b_lblkno = offset >> vp->v_mount->mnt_fs_bshift; bp->b_data = (char *)kva; bp->b_bcount = npages << PAGE_SHIFT;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 15:34:24 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sat Mar 14 15:32:51 UTC 2020 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_wapbl.c diff -u src/sys/kern/vfs_wapbl.c:1.104 src/sys/kern/vfs_wapbl.c:1.105 --- src/sys/kern/vfs_wapbl.c:1.104 Sun Mar 8 18:26:59 2020 +++ src/sys/kern/vfs_wapbl.c Sat Mar 14 15:32:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_wapbl.c,v 1.104 2020/03/08 18:26:59 ad Exp $ */ +/* $NetBSD: vfs_wapbl.c,v 1.105 2020/03/14 15:32:51 ad Exp $ */ /*- * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #define WAPBL_INTERNAL #include -__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.104 2020/03/08 18:26:59 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.105 2020/03/14 15:32:51 ad Exp $"); #include #include @@ -922,7 +922,7 @@ wapbl_doio(void *data, size_t len, struc bp = getiobuf(devvp, true); bp->b_flags = flags; - bp->b_cflags = BC_BUSY; /* mandatory, asserted by biowait() */ + bp->b_cflags |= BC_BUSY; /* mandatory, asserted by biowait() */ bp->b_dev = devvp->v_rdev; bp->b_data = data; bp->b_bufsize = bp->b_resid = bp->b_bcount = len; @@ -997,7 +997,7 @@ wapbl_buffered_write_async(struct wapbl TAILQ_REMOVE(>wl_iobufs, bp, b_wapbllist); bp->b_flags |= B_WRITE; - bp->b_cflags = BC_BUSY; /* mandatory, asserted by biowait() */ + bp->b_cflags |= BC_BUSY; /* mandatory, asserted by biowait() */ bp->b_oflags = 0; bp->b_bcount = bp->b_resid; BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sat Mar 14 15:32:51 UTC 2020 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sat Mar 14 15:31:29 UTC 2020 Modified Files: src/sys/kern: kern_physio.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/kern/kern_physio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_physio.c diff -u src/sys/kern/kern_physio.c:1.97 src/sys/kern/kern_physio.c:1.98 --- src/sys/kern/kern_physio.c:1.97 Sun Dec 8 19:52:37 2019 +++ src/sys/kern/kern_physio.c Sat Mar 14 15:31:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_physio.c,v 1.97 2019/12/08 19:52:37 ad Exp $ */ +/* $NetBSD: kern_physio.c,v 1.98 2020/03/14 15:31:29 ad Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993 @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.97 2019/12/08 19:52:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.98 2020/03/14 15:31:29 ad Exp $"); #include #include @@ -283,7 +283,7 @@ physio(void (*strategy)(struct buf *), s bp = obp; } else { bp = getiobuf(NULL, true); -bp->b_cflags = BC_BUSY; +bp->b_cflags |= BC_BUSY; } bp->b_dev = dev; bp->b_proc = p; @@ -296,7 +296,7 @@ physio(void (*strategy)(struct buf *), s * raw transfers". */ bp->b_oflags = 0; - bp->b_cflags = BC_BUSY; + bp->b_cflags |= BC_BUSY; bp->b_flags = flags | B_PHYS | B_RAW; bp->b_iodone = physio_biodone;
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sat Mar 14 15:31:29 UTC 2020 Modified Files: src/sys/kern: kern_physio.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/kern/kern_physio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 14:15:43 UTC 2020 Modified Files: src/sys/uvm: uvm_map.c uvm_map.h Log Message: - uvmspace_exec(), uvmspace_free(): if pmap_remove_all() returns true the pmap is emptied. Pass UVM_FLAG_VAONLY when clearing out the map and avoid needless extra work to tear down each mapping individually. - uvm_map_lookup_entry(): remove the code to do a linear scan of map entries for small maps, in preference to using the RB tree. It's questionable, and I think the code is almost never triggered because the average number of map entries has probably exceeded the hard-coded threshold for quite some time. - vm_map_entry: get it aligned on a cacheline boundary, and cluster fields used during rbtree lookup at the beginning. To generate a diff of this commit: cvs rdiff -u -r1.372 -r1.373 src/sys/uvm/uvm_map.c cvs rdiff -u -r1.78 -r1.79 src/sys/uvm/uvm_map.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_map.c diff -u src/sys/uvm/uvm_map.c:1.372 src/sys/uvm/uvm_map.c:1.373 --- src/sys/uvm/uvm_map.c:1.372 Sun Feb 23 15:46:43 2020 +++ src/sys/uvm/uvm_map.c Sat Mar 14 14:15:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_map.c,v 1.372 2020/02/23 15:46:43 ad Exp $ */ +/* $NetBSD: uvm_map.c,v 1.373 2020/03/14 14:15:43 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.372 2020/02/23 15:46:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.373 2020/03/14 14:15:43 ad Exp $"); #include "opt_ddb.h" #include "opt_pax.h" @@ -141,10 +141,8 @@ UVMMAP_EVCNT_DEFINE(knomerge) UVMMAP_EVCNT_DEFINE(map_call) UVMMAP_EVCNT_DEFINE(mlk_call) UVMMAP_EVCNT_DEFINE(mlk_hint) -UVMMAP_EVCNT_DEFINE(mlk_list) UVMMAP_EVCNT_DEFINE(mlk_tree) UVMMAP_EVCNT_DEFINE(mlk_treeloop) -UVMMAP_EVCNT_DEFINE(mlk_listloop) const char vmmapbsy[] = "vmmapbsy"; @@ -823,8 +821,8 @@ static inline void uvm_mapent_copy(struct vm_map_entry *src, struct vm_map_entry *dst) { - memcpy(dst, src, ((char *)>uvm_map_entry_stop_copy) - - ((char *)src)); + memcpy(dst, src, sizeof(*dst)); + dst->flags = 0; } #if defined(DEBUG) @@ -940,7 +938,7 @@ uvm_map_init_caches(void) */ pool_cache_bootstrap(_map_entry_cache, sizeof(struct vm_map_entry), - 0, 0, 0, "vmmpepl", NULL, IPL_NONE, NULL, NULL, NULL); + coherency_unit, 0, 0, "vmmpepl", NULL, IPL_NONE, NULL, NULL, NULL); pool_cache_bootstrap(_vmspace_cache, sizeof(struct vmspace), 0, 0, 0, "vmsppl", NULL, IPL_NONE, NULL, NULL, NULL); } @@ -1679,7 +1677,6 @@ uvm_map_lookup_entry(struct vm_map *map, struct vm_map_entry **entry /* OUT */) { struct vm_map_entry *cur; - bool use_tree = false; UVMHIST_FUNC("uvm_map_lookup_entry"); UVMHIST_CALLED(maphist); @@ -1687,95 +1684,41 @@ uvm_map_lookup_entry(struct vm_map *map, (uintptr_t)map, address, (uintptr_t)entry, 0); /* - * start looking either from the head of the - * list, or from the hint. + * make a quick check to see if we are already looking at + * the entry we want (which is usually the case). note also + * that we don't need to save the hint here... it is the + * same hint (unless we are at the header, in which case the + * hint didn't buy us anything anyway). */ cur = map->hint; - - if (cur == >header) - cur = cur->next; - UVMMAP_EVCNT_INCR(mlk_call); - if (address >= cur->start) { - - /* - * go from hint to end of list. - * - * but first, make a quick check to see if - * we are already looking at the entry we - * want (which is usually the case). - * note also that we don't need to save the hint - * here... it is the same hint (unless we are - * at the header, in which case the hint didn't - * buy us anything anyway). - */ - - if (cur != >header && cur->end > address) { - UVMMAP_EVCNT_INCR(mlk_hint); - *entry = cur; - UVMHIST_LOG(maphist,"<- got it via hint (%#jx)", - (uintptr_t)cur, 0, 0, 0); - uvm_mapent_check(*entry); - return (true); - } - - if (map->nentries > 15) - use_tree = true; - } else { - - /* - * invalid hint. use tree. - */ - use_tree = true; + if (cur != >header && + address >= cur->start && cur->end > address) { + UVMMAP_EVCNT_INCR(mlk_hint); + *entry = cur; + UVMHIST_LOG(maphist,"<- got it via hint (%#jx)", + (uintptr_t)cur, 0, 0, 0); + uvm_mapent_check(*entry); + return (true); } - uvm_map_check(map, __func__); - if (use_tree) { - /* - * Simple lookup in the tree. Happens when the hint is - * invalid, or nentries reach a threshold. - */ - UVMMAP_EVCNT_INCR(mlk_tree); - if (uvm_map_lookup_entry_bytree(map, address, entry)) { - goto got; - } else { - goto failed; - } - } - /* - * search linearly + * lookup in the tree. */ - UVMMAP_EVCNT_INCR(mlk_list); - while (cur != >header) { -
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 14:15:43 UTC 2020 Modified Files: src/sys/uvm: uvm_map.c uvm_map.h Log Message: - uvmspace_exec(), uvmspace_free(): if pmap_remove_all() returns true the pmap is emptied. Pass UVM_FLAG_VAONLY when clearing out the map and avoid needless extra work to tear down each mapping individually. - uvm_map_lookup_entry(): remove the code to do a linear scan of map entries for small maps, in preference to using the RB tree. It's questionable, and I think the code is almost never triggered because the average number of map entries has probably exceeded the hard-coded threshold for quite some time. - vm_map_entry: get it aligned on a cacheline boundary, and cluster fields used during rbtree lookup at the beginning. To generate a diff of this commit: cvs rdiff -u -r1.372 -r1.373 src/sys/uvm/uvm_map.c cvs rdiff -u -r1.78 -r1.79 src/sys/uvm/uvm_map.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ad Date: Sat Mar 14 14:05:44 UTC 2020 Modified Files: src/share/man/man9: pmap.9 src/sys/arch/aarch64/aarch64: pmap.c src/sys/arch/alpha/include: pmap.h src/sys/arch/arm/arm32: pmap.c src/sys/arch/arm/include/arm32: pmap.h src/sys/arch/hppa/include: pmap.h src/sys/arch/ia64/ia64: pmap.c src/sys/arch/m68k/include: pmap_motorola.h src/sys/arch/powerpc/include/ibm4xx: pmap.h src/sys/arch/powerpc/include/oea: pmap.h src/sys/arch/sh3/include: pmap.h src/sys/arch/sparc/include: pmap.h src/sys/arch/sparc/sparc: pmap.c src/sys/arch/sparc64/sparc64: pmap.c src/sys/arch/sun2/include: pmap.h src/sys/arch/sun3/include: pmap3.h pmap3x.h src/sys/arch/usermode/usermode: pmap.c src/sys/arch/vax/include: pmap.h src/sys/arch/x86/include: pmap.h src/sys/arch/x86/x86: pmap.c src/sys/uvm: uvm_pmap.h src/sys/uvm/pmap: pmap.c Log Message: pmap_remove_all(): Return a boolean value to indicate the behaviour. If true, all mappings have been removed, the pmap is totally cleared out, and UVM can then avoid doing the work to call pmap_remove() for each map entry. If false, either nothing has been done, or some helpful arch-specific voodoo has taken place. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/share/man/man9/pmap.9 cvs rdiff -u -r1.67 -r1.68 src/sys/arch/aarch64/aarch64/pmap.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/alpha/include/pmap.h cvs rdiff -u -r1.398 -r1.399 src/sys/arch/arm/arm32/pmap.c cvs rdiff -u -r1.163 -r1.164 src/sys/arch/arm/include/arm32/pmap.h cvs rdiff -u -r1.39 -r1.40 src/sys/arch/hppa/include/pmap.h cvs rdiff -u -r1.39 -r1.40 src/sys/arch/ia64/ia64/pmap.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/m68k/include/pmap_motorola.h cvs rdiff -u -r1.20 -r1.21 src/sys/arch/powerpc/include/ibm4xx/pmap.h cvs rdiff -u -r1.29 -r1.30 src/sys/arch/powerpc/include/oea/pmap.h cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sh3/include/pmap.h cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sparc/include/pmap.h cvs rdiff -u -r1.366 -r1.367 src/sys/arch/sparc/sparc/pmap.c cvs rdiff -u -r1.311 -r1.312 src/sys/arch/sparc64/sparc64/pmap.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sun2/include/pmap.h cvs rdiff -u -r1.50 -r1.51 src/sys/arch/sun3/include/pmap3.h cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sun3/include/pmap3x.h cvs rdiff -u -r1.114 -r1.115 src/sys/arch/usermode/usermode/pmap.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/vax/include/pmap.h cvs rdiff -u -r1.111 -r1.112 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.364 -r1.365 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.39 -r1.40 src/sys/uvm/uvm_pmap.h cvs rdiff -u -r1.47 -r1.48 src/sys/uvm/pmap/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/pmap.9 diff -u src/share/man/man9/pmap.9:1.46 src/share/man/man9/pmap.9:1.47 --- src/share/man/man9/pmap.9:1.46 Mon Jan 14 15:56:06 2019 +++ src/share/man/man9/pmap.9 Sat Mar 14 14:05:42 2020 @@ -1,6 +1,6 @@ -.\" $NetBSD: pmap.9,v 1.46 2019/01/14 15:56:06 wiz Exp $ +.\" $NetBSD: pmap.9,v 1.47 2020/03/14 14:05:42 ad Exp $ .\" -.\" Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc. +.\" Copyright (c) 2000, 2001, 2002, 2020 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 13, 2019 +.Dd March 14, 2020 .Dt PMAP 9 .Os .Sh NAME @@ -63,7 +63,7 @@ "u_int flags" .Ft void .Fn "pmap_remove" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva" -.Ft void +.Ft bool .Fn "pmap_remove_all" "pmap_t pmap" .Ft void .Fn "pmap_protect" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva" "vm_prot_t prot" @@ -549,7 +549,7 @@ Remove mappings from the virtual address to .Fa eva from the specified physical map. -.It void Fn "pmap_remove_all" "pmap_t pmap" +.It bool Fn "pmap_remove_all" "pmap_t pmap" This function is a hint to the .Nm pmap implementation that all entries in @@ -581,6 +581,21 @@ mappings immediately in or to use the knowledge of the upcoming .Fn pmap_remove calls to optimize the removals (or to just ignore this call). +.Pp +If all mappings in the address space have been removed, +.Fn pmap_remove_all +should return +.Dv true +to indicate that that the pmap is now empty. +In this case UVM will skip all subsequent calls to +.Fn pmap_remove +and +.Fn pmap_update +for the pmap, that would otherwise be required to clean it out. +If any mappings could possibly remain, +.Fn pmap_remove_all +must return +.Dv false . .It void Fn "pmap_protect" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva" \ "vm_prot_t prot" Set the protection of the mappings in the virtual address range Index:
CVS commit: src
Module Name:src Committed By: ad Date: Sat Mar 14 14:05:44 UTC 2020 Modified Files: src/share/man/man9: pmap.9 src/sys/arch/aarch64/aarch64: pmap.c src/sys/arch/alpha/include: pmap.h src/sys/arch/arm/arm32: pmap.c src/sys/arch/arm/include/arm32: pmap.h src/sys/arch/hppa/include: pmap.h src/sys/arch/ia64/ia64: pmap.c src/sys/arch/m68k/include: pmap_motorola.h src/sys/arch/powerpc/include/ibm4xx: pmap.h src/sys/arch/powerpc/include/oea: pmap.h src/sys/arch/sh3/include: pmap.h src/sys/arch/sparc/include: pmap.h src/sys/arch/sparc/sparc: pmap.c src/sys/arch/sparc64/sparc64: pmap.c src/sys/arch/sun2/include: pmap.h src/sys/arch/sun3/include: pmap3.h pmap3x.h src/sys/arch/usermode/usermode: pmap.c src/sys/arch/vax/include: pmap.h src/sys/arch/x86/include: pmap.h src/sys/arch/x86/x86: pmap.c src/sys/uvm: uvm_pmap.h src/sys/uvm/pmap: pmap.c Log Message: pmap_remove_all(): Return a boolean value to indicate the behaviour. If true, all mappings have been removed, the pmap is totally cleared out, and UVM can then avoid doing the work to call pmap_remove() for each map entry. If false, either nothing has been done, or some helpful arch-specific voodoo has taken place. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/share/man/man9/pmap.9 cvs rdiff -u -r1.67 -r1.68 src/sys/arch/aarch64/aarch64/pmap.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/alpha/include/pmap.h cvs rdiff -u -r1.398 -r1.399 src/sys/arch/arm/arm32/pmap.c cvs rdiff -u -r1.163 -r1.164 src/sys/arch/arm/include/arm32/pmap.h cvs rdiff -u -r1.39 -r1.40 src/sys/arch/hppa/include/pmap.h cvs rdiff -u -r1.39 -r1.40 src/sys/arch/ia64/ia64/pmap.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/m68k/include/pmap_motorola.h cvs rdiff -u -r1.20 -r1.21 src/sys/arch/powerpc/include/ibm4xx/pmap.h cvs rdiff -u -r1.29 -r1.30 src/sys/arch/powerpc/include/oea/pmap.h cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sh3/include/pmap.h cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sparc/include/pmap.h cvs rdiff -u -r1.366 -r1.367 src/sys/arch/sparc/sparc/pmap.c cvs rdiff -u -r1.311 -r1.312 src/sys/arch/sparc64/sparc64/pmap.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sun2/include/pmap.h cvs rdiff -u -r1.50 -r1.51 src/sys/arch/sun3/include/pmap3.h cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sun3/include/pmap3x.h cvs rdiff -u -r1.114 -r1.115 src/sys/arch/usermode/usermode/pmap.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/vax/include/pmap.h cvs rdiff -u -r1.111 -r1.112 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.364 -r1.365 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.39 -r1.40 src/sys/uvm/uvm_pmap.h cvs rdiff -u -r1.47 -r1.48 src/sys/uvm/pmap/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 13:53:26 UTC 2020 Modified Files: src/sys/uvm: uvm_pdpolicy_clock.c uvm_pdpolicy_clockpro.c Log Message: uvm_pdpolicy: Require a write lock on the object only for dequeue. No sense in requiring that for enqueue/activate/deactivate. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/uvm/uvm_pdpolicy_clock.c cvs rdiff -u -r1.23 -r1.24 src/sys/uvm/uvm_pdpolicy_clockpro.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sat Mar 14 13:53:26 UTC 2020 Modified Files: src/sys/uvm: uvm_pdpolicy_clock.c uvm_pdpolicy_clockpro.c Log Message: uvm_pdpolicy: Require a write lock on the object only for dequeue. No sense in requiring that for enqueue/activate/deactivate. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/uvm/uvm_pdpolicy_clock.c cvs rdiff -u -r1.23 -r1.24 src/sys/uvm/uvm_pdpolicy_clockpro.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_pdpolicy_clock.c diff -u src/sys/uvm/uvm_pdpolicy_clock.c:1.34 src/sys/uvm/uvm_pdpolicy_clock.c:1.35 --- src/sys/uvm/uvm_pdpolicy_clock.c:1.34 Sun Mar 8 15:01:50 2020 +++ src/sys/uvm/uvm_pdpolicy_clock.c Sat Mar 14 13:53:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pdpolicy_clock.c,v 1.34 2020/03/08 15:01:50 ad Exp $ */ +/* $NetBSD: uvm_pdpolicy_clock.c,v 1.35 2020/03/14 13:53:26 ad Exp $ */ /* NetBSD: uvm_pdaemon.c,v 1.72 2006/01/05 10:47:33 yamt Exp $ */ /*- @@ -98,7 +98,7 @@ #else /* defined(PDSIM) */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.34 2020/03/08 15:01:50 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.35 2020/03/14 13:53:26 ad Exp $"); #include #include @@ -463,7 +463,7 @@ void uvmpdpol_pagedeactivate(struct vm_page *pg) { - KASSERT(uvm_page_owner_locked_p(pg, true)); + KASSERT(uvm_page_owner_locked_p(pg, false)); KASSERT(mutex_owned(>interlock)); /* @@ -495,7 +495,7 @@ void uvmpdpol_pageactivate(struct vm_page *pg) { - KASSERT(uvm_page_owner_locked_p(pg, true)); + KASSERT(uvm_page_owner_locked_p(pg, false)); KASSERT(mutex_owned(>interlock)); uvmpdpol_set_intent(pg, PQ_INTENT_A); @@ -536,7 +536,7 @@ void uvmpdpol_pageenqueue(struct vm_page *pg) { - KASSERT(uvm_page_owner_locked_p(pg, true)); + KASSERT(uvm_page_owner_locked_p(pg, false)); KASSERT(mutex_owned(>interlock)); uvmpdpol_set_intent(pg, PQ_INTENT_E); Index: src/sys/uvm/uvm_pdpolicy_clockpro.c diff -u src/sys/uvm/uvm_pdpolicy_clockpro.c:1.23 src/sys/uvm/uvm_pdpolicy_clockpro.c:1.24 --- src/sys/uvm/uvm_pdpolicy_clockpro.c:1.23 Thu Jan 30 12:28:51 2020 +++ src/sys/uvm/uvm_pdpolicy_clockpro.c Sat Mar 14 13:53:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pdpolicy_clockpro.c,v 1.23 2020/01/30 12:28:51 ad Exp $ */ +/* $NetBSD: uvm_pdpolicy_clockpro.c,v 1.24 2020/03/14 13:53:26 ad Exp $ */ /*- * Copyright (c)2005, 2006 YAMAMOTO Takashi, @@ -43,7 +43,7 @@ #else /* defined(PDSIM) */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clockpro.c,v 1.23 2020/01/30 12:28:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clockpro.c,v 1.24 2020/03/14 13:53:26 ad Exp $"); #include "opt_ddb.h" @@ -645,7 +645,7 @@ clockpro_movereferencebit(struct vm_page bool referenced; KASSERT(mutex_owned()); - KASSERT(!locked || uvm_page_owner_locked_p(pg)); + KASSERT(!locked || uvm_page_owner_locked_p(pg, false)); if (!locked) { /* * acquire interlock to stablize page identity.
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: ad Date: Sat Mar 14 13:50:46 UTC 2020 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Put ACPI idle under ACPICPU_ENABLE_C3 until the wrinkles are ironed out. This seems well written and basically all good, but currently doesn't enter a low power state, and imposes a big performance penalty. Proposed on port-i386 & port-amd64. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.81 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.82 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.81 Tue Nov 5 20:21:34 2019 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Mar 14 13:50:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.81 2019/11/05 20:21:34 maxv Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.82 2020/03/14 13:50:46 ad Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.81 2019/11/05 20:21:34 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.82 2020/03/14 13:50:46 ad Exp $"); #include #include @@ -103,8 +103,10 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md. #define FID_TO_VCO_FID(fidd) (((fid) < 8) ? (8 + ((fid) << 1)) : (fid)) +#ifdef ACPICPU_ENABLE_C3 static char native_idle_text[16]; void (*native_idle)(void) = NULL; +#endif static int acpicpu_md_quirk_piix4(const struct pci_attach_args *); static void acpicpu_md_pstate_hwf_reset(void *, void *); @@ -348,6 +350,12 @@ acpicpu_md_quirk_c1e(void) int acpicpu_md_cstate_start(struct acpicpu_softc *sc) { +#ifdef ACPICPU_ENABLE_C3 + /* + * XXX There are performance problems with the ACPI idle loop, and + * it does not enter deep sleep. Once those are resolved it'll be + * re-enabled. + */ const size_t size = sizeof(native_idle_text); struct acpicpu_cstate *cs; bool ipi = false; @@ -369,6 +377,7 @@ acpicpu_md_cstate_start(struct acpicpu_s } x86_cpu_idle_set(acpicpu_cstate_idle, "acpi", ipi); +#endif /* ACPICPU_ENABLE_C3 */ return 0; } @@ -376,6 +385,12 @@ acpicpu_md_cstate_start(struct acpicpu_s int acpicpu_md_cstate_stop(void) { +#ifdef ACPICPU_ENABLE_C3 + /* + * XXX There are performance problems with the ACPI idle loop, and + * it does not enter deep sleep. Once those are resolved it'll be + * re-enabled. + */ static char text[16]; void (*func)(void); bool ipi; @@ -393,6 +408,7 @@ acpicpu_md_cstate_stop(void) * out from the ACPI idle-loop before detachment. */ xc_barrier(0); +#endif /* ACPICPU_ENABLE_C3 */ return 0; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: ad Date: Sat Mar 14 13:50:46 UTC 2020 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Put ACPI idle under ACPICPU_ENABLE_C3 until the wrinkles are ironed out. This seems well written and basically all good, but currently doesn't enter a low power state, and imposes a big performance penalty. Proposed on port-i386 & port-amd64. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:39:36 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_inactive(): do like other file systems and truncate the file if it has been deleted. Otherwise VFS will try to write cached data "back to disc", which in the case of a UAO means needless page deactivations and the resulting TLB shootdowns. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.134 src/sys/fs/tmpfs/tmpfs_vnops.c:1.135 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.134 Sun Feb 23 15:46:40 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sat Mar 14 13:39:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.134 2020/02/23 15:46:40 ad Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.134 2020/02/23 15:46:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $"); #include #include @@ -1040,6 +1040,7 @@ tmpfs_inactive(void *v) } */ *ap = v; vnode_t *vp = ap->a_vp; tmpfs_node_t *node; + int error = 0; KASSERT(VOP_ISLOCKED(vp)); @@ -1049,12 +1050,21 @@ tmpfs_inactive(void *v) * Mark node as dead by setting its generation to zero. */ atomic_and_32(>tn_gen, ~TMPFS_NODE_GEN_MASK); + + /* + * If the file has been deleted, truncate it, otherwise VFS + * will quite rightly try to write back dirty data, which in + * the case of tmpfs/UAO means needless page deactivations. + */ + if (vp->v_type == VREG) { + error = tmpfs_reg_resize(vp, 0); + } *ap->a_recycle = true; } else { *ap->a_recycle = false; } - return 0; + return error; } int
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:39:36 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_inactive(): do like other file systems and truncate the file if it has been deleted. Otherwise VFS will try to write cached data "back to disc", which in the case of a UAO means needless page deactivations and the resulting TLB shootdowns. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:37:49 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_reg_resize(): do nothing if newsize == oldsize. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:37:49 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_reg_resize(): do nothing if newsize == oldsize. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.106 src/sys/fs/tmpfs/tmpfs_subr.c:1.107 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.106 Sun Feb 23 15:46:40 2020 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sat Mar 14 13:37:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.106 2020/02/23 15:46:40 ad Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.107 2020/03/14 13:37:49 ad Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.106 2020/02/23 15:46:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.107 2020/03/14 13:37:49 ad Exp $"); #include #include @@ -914,6 +914,10 @@ tmpfs_reg_resize(struct vnode *vp, off_t newpages = round_page(newsize) >> PAGE_SHIFT; KASSERT(oldpages == node->tn_spec.tn_reg.tn_aobj_pages); + if (newsize == oldsize) { + return 0; + } + if (newpages > oldpages) { /* Increase the used-memory counter if getting extra pages. */ if (!tmpfs_mem_incr(tmp, (newpages - oldpages) << PAGE_SHIFT)) {
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: ad Date: Sat Mar 14 13:34:44 UTC 2020 Modified Files: src/sys/arch/sparc/sparc: intr.c Log Message: sparc cpu_intr_p(): try to work around l_cpu not being set early on by using curcpu(). To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/arch/sparc/sparc/intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/intr.c diff -u src/sys/arch/sparc/sparc/intr.c:1.123 src/sys/arch/sparc/sparc/intr.c:1.124 --- src/sys/arch/sparc/sparc/intr.c:1.123 Tue Dec 3 15:20:59 2019 +++ src/sys/arch/sparc/sparc/intr.c Sat Mar 14 13:34:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.123 2019/12/03 15:20:59 riastradh Exp $ */ +/* $NetBSD: intr.c,v 1.124 2020/03/14 13:34:43 ad Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.123 2019/12/03 15:20:59 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.124 2020/03/14 13:34:43 ad Exp $"); #include "opt_multiprocessor.h" #include "opt_sparc_arch.h" @@ -897,7 +897,7 @@ cpu_intr_p(void) do { ncsw = l->l_ncsw; __insn_barrier(); - idepth = l->l_cpu->ci_idepth; + idepth = curcpu()->ci_idepth; __insn_barrier(); } while (__predict_false(ncsw != l->l_ncsw));
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: ad Date: Sat Mar 14 13:34:44 UTC 2020 Modified Files: src/sys/arch/sparc/sparc: intr.c Log Message: sparc cpu_intr_p(): try to work around l_cpu not being set early on by using curcpu(). To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/arch/sparc/sparc/intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Mar 12 10:44:00 UTC 2020 Modified Files: src/sys/kern: sched_4bsd.c Log Message: Put back missing set of SPCF_SHOULDYIELD. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/kern/sched_4bsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sched_4bsd.c diff -u src/sys/kern/sched_4bsd.c:1.42 src/sys/kern/sched_4bsd.c:1.43 --- src/sys/kern/sched_4bsd.c:1.42 Thu Jan 9 16:35:03 2020 +++ src/sys/kern/sched_4bsd.c Thu Mar 12 10:44:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sched_4bsd.c,v 1.42 2020/01/09 16:35:03 ad Exp $ */ +/* $NetBSD: sched_4bsd.c,v 1.43 2020/03/12 10:44:00 ad Exp $ */ /* * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2019, 2020 @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.42 2020/01/09 16:35:03 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.43 2020/03/12 10:44:00 ad Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -147,6 +147,7 @@ sched_tick(struct cpu_info *ci) * Indicate that the process should yield. */ pri = MAXPRI_KTHREAD; + spc->spc_flags |= SPCF_SHOULDYIELD; } else if ((spc->spc_flags & SPCF_1STCLASS) == 0) { /* * For SMT or assymetric systems push a little @@ -154,6 +155,7 @@ sched_tick(struct cpu_info *ci) * find a better one to run this LWP. */ pri = MAXPRI_KTHREAD; + spc->spc_flags |= SPCF_SHOULDYIELD; } else { spc->spc_flags |= SPCF_SEENRR; }
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Mar 12 10:44:00 UTC 2020 Modified Files: src/sys/kern: sched_4bsd.c Log Message: Put back missing set of SPCF_SHOULDYIELD. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/kern/sched_4bsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Tue Mar 10 22:38:42 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: - pmap_check_inuse() is expensive so make it DEBUG not DIAGNOSTIC. - Put PV locking back in place with only a minor performance impact. pmap_enter() still needs more work - it's not easy to satisfy all the competing requirements so I'll do that with another change. - Use pmap_find_ptp() (lookup only) in preference to pmap_get_ptp() (alloc). Make pm_ptphint indexed by VA not PA. Replace the per-pmap radixtree for dynamic PV entries with a per-PTP rbtree. Cuts system time during kernel build by ~10% for me. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.362 -r1.363 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Tue Mar 10 22:38:42 UTC 2020 Modified Files: src/sys/arch/x86/include: pmap.h pmap_pv.h src/sys/arch/x86/x86: pmap.c Log Message: - pmap_check_inuse() is expensive so make it DEBUG not DIAGNOSTIC. - Put PV locking back in place with only a minor performance impact. pmap_enter() still needs more work - it's not easy to satisfy all the competing requirements so I'll do that with another change. - Use pmap_find_ptp() (lookup only) in preference to pmap_get_ptp() (alloc). Make pm_ptphint indexed by VA not PA. Replace the per-pmap radixtree for dynamic PV entries with a per-PTP rbtree. Cuts system time during kernel build by ~10% for me. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/include/pmap_pv.h cvs rdiff -u -r1.362 -r1.363 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.110 src/sys/arch/x86/include/pmap.h:1.111 --- src/sys/arch/x86/include/pmap.h:1.110 Sun Feb 23 15:46:39 2020 +++ src/sys/arch/x86/include/pmap.h Tue Mar 10 22:38:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.110 2020/02/23 15:46:39 ad Exp $ */ +/* $NetBSD: pmap.h,v 1.111 2020/03/10 22:38:41 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -67,8 +67,6 @@ #ifndef _X86_PMAP_H_ #define _X86_PMAP_H_ -#include - /* * pl*_pi: index in the ptp page for a pde mapping a VA. * (pl*_i below is the index in the virtual array of all pdes per level) @@ -257,7 +255,6 @@ struct pmap { paddr_t pm_pdirpa[PDP_SIZE]; /* PA of PDs (read-only after create) */ struct vm_page *pm_ptphint[PTP_LEVELS-1]; /* pointer to a PTP in our pmap */ - struct radix_tree pm_pvtree; /* tree of non-embedded pv entries */ struct pmap_statistics pm_stats; /* pmap stats */ #if !defined(__x86_64__) Index: src/sys/arch/x86/include/pmap_pv.h diff -u src/sys/arch/x86/include/pmap_pv.h:1.12 src/sys/arch/x86/include/pmap_pv.h:1.13 --- src/sys/arch/x86/include/pmap_pv.h:1.12 Sun Feb 23 22:28:53 2020 +++ src/sys/arch/x86/include/pmap_pv.h Tue Mar 10 22:38:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_pv.h,v 1.12 2020/02/23 22:28:53 ad Exp $ */ +/* $NetBSD: pmap_pv.h,v 1.13 2020/03/10 22:38:41 ad Exp $ */ /*- * Copyright (c)2008 YAMAMOTO Takashi, @@ -31,6 +31,7 @@ #include #include +#include struct vm_page; @@ -56,6 +57,8 @@ struct pv_pte { struct pv_entry { struct pv_pte pve_pte; /* should be the first member */ LIST_ENTRY(pv_entry) pve_list; /* on pmap_page::pp_pvlist */ + rb_node_t pve_rb; /* red-black tree node */ + uintptr_t pve_padding; /* unused */ }; #define pve_next pve_list.le_next @@ -65,26 +68,43 @@ struct pv_entry { struct pmap_page { union { - /* PP_EMBEDDED */ - struct pv_pte u_pte; + /* PTPs */ + rb_tree_t rb; /* PTPs */ - LIST_ENTRY(vm_page) u_link; + LIST_ENTRY(vm_page) link; + + /* Non-PTPs */ + struct { + /* PP_EMBEDDED */ + struct pv_pte pte; + + LIST_HEAD(, pv_entry) pvlist; + uint8_t flags; + uint8_t attrs; + } s; } pp_u; - LIST_HEAD(, pv_entry) pp_pvlist; -#define pp_pte pp_u.u_pte -#define pp_link pp_u.u_link - uint8_t pp_flags; - uint8_t pp_attrs; + kmutex_t pp_lock; +#define pp_rb pp_u.rb +#define pp_link pp_u.link +#define pp_pte pp_u.s.pte +#define pp_pvlist pp_u.s.pvlist +#define pp_pflags pp_u.s.flags +#define pp_attrs pp_u.s.attrs +}; + #define PP_ATTRS_D 0x01 /* Dirty */ #define PP_ATTRS_A 0x02 /* Accessed */ #define PP_ATTRS_W 0x04 /* Writable */ -}; /* pp_flags */ #define PP_EMBEDDED 1 #define PP_FREEING 2 -#define PMAP_PAGE_INIT(pp) LIST_INIT(&(pp)->pp_pvlist) +#define PMAP_PAGE_INIT(pp) \ +do { \ + LIST_INIT(&(pp)->pp_pvlist); \ + mutex_init(&(pp)->pp_lock, MUTEX_NODEBUG, IPL_VM); \ +} while (/* CONSTCOND */ 0); #endif /* !_X86_PMAP_PV_H_ */ Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.362 src/sys/arch/x86/x86/pmap.c:1.363 --- src/sys/arch/x86/x86/pmap.c:1.362 Wed Mar 4 22:00:03 2020 +++ src/sys/arch/x86/x86/pmap.c Tue Mar 10 22:38:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.362 2020/03/04 22:00:03 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.363 2020/03/10 22:38:41 ad Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.362 2020/03/04 22:00:03 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.363 2020/03/10 22:38:41 ad Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -293,6 +293,7 @@ static bool cpu_pat_enabled __read_mostl static struct pmap kernel_pmap_store __cacheline_aligned; /* kernel's pmap */ struct pmap *const kernel_pmap_ptr = _pmap_store; +static rb_tree_t
CVS commit: [ad-namecache] src/sys/kern
Module Name:src Committed By: ad Date: Tue Mar 10 21:53:46 UTC 2020 Modified Files: src/sys/kern [ad-namecache]: vfs_cache.c Log Message: __read_mostly -> const in one place To generate a diff of this commit: cvs rdiff -u -r1.126.2.12 -r1.126.2.13 src/sys/kern/vfs_cache.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [ad-namecache] src/sys/kern
Module Name:src Committed By: ad Date: Tue Mar 10 21:53:46 UTC 2020 Modified Files: src/sys/kern [ad-namecache]: vfs_cache.c Log Message: __read_mostly -> const in one place To generate a diff of this commit: cvs rdiff -u -r1.126.2.12 -r1.126.2.13 src/sys/kern/vfs_cache.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_cache.c diff -u src/sys/kern/vfs_cache.c:1.126.2.12 src/sys/kern/vfs_cache.c:1.126.2.13 --- src/sys/kern/vfs_cache.c:1.126.2.12 Sun Feb 16 22:00:53 2020 +++ src/sys/kern/vfs_cache.c Tue Mar 10 21:53:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_cache.c,v 1.126.2.12 2020/02/16 22:00:53 ad Exp $ */ +/* $NetBSD: vfs_cache.c,v 1.126.2.13 2020/03/10 21:53:45 ad Exp $ */ /*- * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc. @@ -171,7 +171,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.126.2.12 2020/02/16 22:00:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.126.2.13 2020/03/10 21:53:45 ad Exp $"); #define __NAMECACHE_PRIVATE #ifdef _KERNEL_OPT @@ -242,7 +242,7 @@ static int doingcache = 1; /* 1 => ena static struct sysctllog *cache_sysctllog; /* Read-black tree */ -static rb_tree_ops_t cache_rbtree_ops __read_mostly = { +static const rb_tree_ops_t cache_rbtree_ops = { .rbto_compare_nodes = cache_compare_nodes, .rbto_compare_key = cache_compare_key, .rbto_node_offset = offsetof(struct namecache, nc_tree),
Re: CVS commit: src/sys/kern
On Sun, Mar 08, 2020 at 08:34:29AM +0100, Maxime Villard wrote: > Le 08/03/2020 ? 01:31, Andrew Doran a ?crit?: > > Module Name:src > > Committed By: ad > > Date: Sun Mar 8 00:31:19 UTC 2020 > > > > Modified Files: > > src/sys/kern: subr_kmem.c > > > > Log Message: > > KMEM_SIZE: append the size_t to the allocated buffer, rather than > > prepending, so it doesn't screw up the alignment of the buffer. > > > > Reported-by: syzbot+c024c50570cccac51...@syzkaller.appspotmail.com > > > > > > To generate a diff of this commit: > > cvs rdiff -u -r1.78 -r1.79 src/sys/kern/subr_kmem.c > > > > Please note that diffs are not public domain; they are subject to the > > copyright notices on the relevant files. > > This is wrong. The point of KMEM_SIZE is to store at a reliable location > the size of the buffer, in order to then verify that the 'size' argument > given to kmem_free() is correct. > > Here, you are using that size argument to compute the location, which > breaks the whole point of the check. Sure I understand the frustration, but it's still correct according to the parameters I set for it 10+ years ago, which were for it to be a quick-n-dirty diagnostic aid. > Also it probably collides with the KASAN shadow. Hmm, is that purely an alignment issue then, because it works in 8 byte cells? Otherwise it sounds like this should not be enabled with KASAN at all. Andrew > Please revert this change. > > As said previously, if cacheline alignment is expected this way, then it > should clearly be part of the kmem contract, and documented to be so.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sun Mar 8 18:40:30 UTC 2020 Modified Files: src/sys/uvm: uvm_readahead.c Log Message: Only need a read lock for uvm_pagelookup(). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/uvm/uvm_readahead.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sun Mar 8 18:40:30 UTC 2020 Modified Files: src/sys/uvm: uvm_readahead.c Log Message: Only need a read lock for uvm_pagelookup(). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/uvm/uvm_readahead.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_readahead.c diff -u src/sys/uvm/uvm_readahead.c:1.11 src/sys/uvm/uvm_readahead.c:1.12 --- src/sys/uvm/uvm_readahead.c:1.11 Sun Feb 23 15:46:43 2020 +++ src/sys/uvm/uvm_readahead.c Sun Mar 8 18:40:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_readahead.c,v 1.11 2020/02/23 15:46:43 ad Exp $ */ +/* $NetBSD: uvm_readahead.c,v 1.12 2020/03/08 18:40:29 ad Exp $ */ /*- * Copyright (c)2003, 2005, 2009 YAMAMOTO Takashi, @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_readahead.c,v 1.11 2020/02/23 15:46:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_readahead.c,v 1.12 2020/03/08 18:40:29 ad Exp $"); #include #include @@ -133,7 +133,7 @@ ra_startio(struct uvm_object *uobj, off_ * too. This speeds up I/O using cache, since it avoids lookups and temporary * allocations done by full pgo_get. */ - rw_enter(uobj->vmobjlock, RW_WRITER); + rw_enter(uobj->vmobjlock, RW_READER); struct vm_page *pg = uvm_pagelookup(uobj, trunc_page(endoff - 1)); rw_exit(uobj->vmobjlock); if (pg != NULL) {
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 18:26:59 UTC 2020 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: Typo. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_wapbl.c diff -u src/sys/kern/vfs_wapbl.c:1.103 src/sys/kern/vfs_wapbl.c:1.104 --- src/sys/kern/vfs_wapbl.c:1.103 Mon Dec 10 21:19:33 2018 +++ src/sys/kern/vfs_wapbl.c Sun Mar 8 18:26:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_wapbl.c,v 1.103 2018/12/10 21:19:33 jdolecek Exp $ */ +/* $NetBSD: vfs_wapbl.c,v 1.104 2020/03/08 18:26:59 ad Exp $ */ /*- * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #define WAPBL_INTERNAL #include -__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.103 2018/12/10 21:19:33 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.104 2020/03/08 18:26:59 ad Exp $"); #include #include @@ -356,7 +356,7 @@ wapbl_sysctl_init(void) rv = sysctl_createv(_sysctl, 0, , , CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "allow_dpofua", - SYSCTL_DESCR("allow use of FUA/DPO instead of cash flush if available"), + SYSCTL_DESCR("allow use of FUA/DPO instead of cache flush if available"), NULL, 0, _allow_dpofua, 0, CTL_CREATE, CTL_EOL); if (rv)
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 18:26:59 UTC 2020 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: Typo. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 17:04:46 UTC 2020 Modified Files: src/sys/kern: kern_lwp.c Log Message: PR kern/55020: dbregs_dr?_dont_inherit_lwp test cases fail on real hardware lwp_wait(): make the check for deadlock much more permissive. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/sys/kern/kern_lwp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.228 src/sys/kern/kern_lwp.c:1.229 --- src/sys/kern/kern_lwp.c:1.228 Thu Feb 27 20:52:25 2020 +++ src/sys/kern/kern_lwp.c Sun Mar 8 17:04:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.228 2020/02/27 20:52:25 ad Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.229 2020/03/08 17:04:45 ad Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020 @@ -211,7 +211,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.228 2020/02/27 20:52:25 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.229 2020/03/08 17:04:45 ad Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -677,12 +677,13 @@ lwp_wait(struct lwp *l, lwpid_t lid, lwp } /* - * If all other LWPs are waiting for exits or suspends - * and the supply of zombies and potential zombies is - * exhausted, then we are about to deadlock. + * Break out if the process is exiting, or if all LWPs are + * in _lwp_wait(). There are other ways to hang the process + * with _lwp_wait(), but the sleep is interruptable so + * little point checking for them. */ if ((p->p_sflag & PS_WEXIT) != 0 || - p->p_nrlwps + p->p_nzlwps - p->p_ndlwps <= p->p_nlwpwait) { + p->p_nlwpwait == p->p_nlwps) { error = EDEADLK; break; }
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 17:04:46 UTC 2020 Modified Files: src/sys/kern: kern_lwp.c Log Message: PR kern/55020: dbregs_dr?_dont_inherit_lwp test cases fail on real hardware lwp_wait(): make the check for deadlock much more permissive. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/sys/kern/kern_lwp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Sun Mar 8 15:05:18 UTC 2020 Modified Files: src/sys/kern: kern_exit.c kern_lock.c kern_softint.c src/sys/sys: lock.h Log Message: Kill off kernel_lock_plug_leak(), and go back to dropping kernel_lock in exit1(), since there seems little hope of finding the leaking code any time soon. Can still be caught with LOCKDEBUG. To generate a diff of this commit: cvs rdiff -u -r1.284 -r1.285 src/sys/kern/kern_exit.c cvs rdiff -u -r1.169 -r1.170 src/sys/kern/kern_lock.c cvs rdiff -u -r1.61 -r1.62 src/sys/kern/kern_softint.c cvs rdiff -u -r1.88 -r1.89 src/sys/sys/lock.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Sun Mar 8 15:05:18 UTC 2020 Modified Files: src/sys/kern: kern_exit.c kern_lock.c kern_softint.c src/sys/sys: lock.h Log Message: Kill off kernel_lock_plug_leak(), and go back to dropping kernel_lock in exit1(), since there seems little hope of finding the leaking code any time soon. Can still be caught with LOCKDEBUG. To generate a diff of this commit: cvs rdiff -u -r1.284 -r1.285 src/sys/kern/kern_exit.c cvs rdiff -u -r1.169 -r1.170 src/sys/kern/kern_lock.c cvs rdiff -u -r1.61 -r1.62 src/sys/kern/kern_softint.c cvs rdiff -u -r1.88 -r1.89 src/sys/sys/lock.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_exit.c diff -u src/sys/kern/kern_exit.c:1.284 src/sys/kern/kern_exit.c:1.285 --- src/sys/kern/kern_exit.c:1.284 Sat Feb 22 21:07:46 2020 +++ src/sys/kern/kern_exit.c Sun Mar 8 15:05:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.284 2020/02/22 21:07:46 ad Exp $ */ +/* $NetBSD: kern_exit.c,v 1.285 2020/03/08 15:05:18 ad Exp $ */ /*- * Copyright (c) 1998, 1999, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.284 2020/02/22 21:07:46 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.285 2020/03/08 15:05:18 ad Exp $"); #include "opt_ktrace.h" #include "opt_dtrace.h" @@ -206,12 +206,12 @@ exit1(struct lwp *l, int exitcode, int s p = l->l_proc; - /* XXX Temporary. */ - kernel_lock_plug_leak(); - /* Verify that we hold no locks other than p->p_lock. */ LOCKDEBUG_BARRIER(p->p_lock, 0); - KASSERTMSG(curcpu()->ci_biglock_count == 0, "kernel_lock leaked"); + + /* XXX Temporary: something is leaking kernel_lock. */ + KERNEL_UNLOCK_ALL(l, NULL); + KASSERT(mutex_owned(p->p_lock)); KASSERT(p->p_vmspace != NULL); Index: src/sys/kern/kern_lock.c diff -u src/sys/kern/kern_lock.c:1.169 src/sys/kern/kern_lock.c:1.170 --- src/sys/kern/kern_lock.c:1.169 Mon Feb 10 22:11:09 2020 +++ src/sys/kern/kern_lock.c Sun Mar 8 15:05:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lock.c,v 1.169 2020/02/10 22:11:09 christos Exp $ */ +/* $NetBSD: kern_lock.c,v 1.170 2020/03/08 15:05:18 ad Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2020 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.169 2020/02/10 22:11:09 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.170 2020/03/08 15:05:18 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_lockdebug.h" @@ -343,23 +343,3 @@ _kernel_locked_p(void) { return __SIMPLELOCK_LOCKED_P(kernel_lock); } - -void -kernel_lock_plug_leak(void) -{ -#ifndef LOCKDEBUG -# ifdef DIAGNOSTIC - int biglocks = 0; - KERNEL_UNLOCK_ALL(curlwp, ); - if (biglocks != 0) { - const char *sym = "(unknown)"; - ksyms_getname(NULL, , (vaddr_t)curlwp->l_ld_wanted, - KSYMS_CLOSEST|KSYMS_PROC|KSYMS_ANY); - printf("kernel_lock leak detected. last acquired: %s / %p\n", - sym, curlwp->l_ld_wanted); - } -# else - KERNEL_UNLOCK_ALL(curlwp, NULL); -# endif -#endif -} Index: src/sys/kern/kern_softint.c diff -u src/sys/kern/kern_softint.c:1.61 src/sys/kern/kern_softint.c:1.62 --- src/sys/kern/kern_softint.c:1.61 Mon Feb 17 21:44:42 2020 +++ src/sys/kern/kern_softint.c Sun Mar 8 15:05:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_softint.c,v 1.61 2020/02/17 21:44:42 ad Exp $ */ +/* $NetBSD: kern_softint.c,v 1.62 2020/03/08 15:05:18 ad Exp $ */ /*- * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc. @@ -170,7 +170,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.61 2020/02/17 21:44:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.62 2020/03/08 15:05:18 ad Exp $"); #include #include @@ -890,9 +890,6 @@ softint_dispatch(lwp_t *pinned, int s) l->l_pflag &= ~LP_TIMEINTR; } - /* XXX temporary */ - kernel_lock_plug_leak(); - /* * If we blocked while handling the interrupt, the pinned LWP is * gone so switch to the idle LWP. It will select a new LWP to Index: src/sys/sys/lock.h diff -u src/sys/sys/lock.h:1.88 src/sys/sys/lock.h:1.89 --- src/sys/sys/lock.h:1.88 Mon Jan 27 21:05:43 2020 +++ src/sys/sys/lock.h Sun Mar 8 15:05:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lock.h,v 1.88 2020/01/27 21:05:43 ad Exp $ */ +/* $NetBSD: lock.h,v 1.89 2020/03/08 15:05:18 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2006, 2007 The NetBSD Foundation, Inc. @@ -109,8 +109,6 @@ do {\ extern __cpu_simple_lock_t kernel_lock[]; -void kernel_lock_plug_leak(void); - #endif /* _KERNEL */ #endif /* _SYS_LOCK_H_ */
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sun Mar 8 15:01:50 UTC 2020 Modified Files: src/sys/uvm: uvm_pdpolicy_clock.c Log Message: Don't zap the non-pdpolicy bits in pg->pqflags. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/uvm/uvm_pdpolicy_clock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_pdpolicy_clock.c diff -u src/sys/uvm/uvm_pdpolicy_clock.c:1.33 src/sys/uvm/uvm_pdpolicy_clock.c:1.34 --- src/sys/uvm/uvm_pdpolicy_clock.c:1.33 Sun Feb 23 15:46:43 2020 +++ src/sys/uvm/uvm_pdpolicy_clock.c Sun Mar 8 15:01:50 2020 @@ -1,8 +1,8 @@ -/* $NetBSD: uvm_pdpolicy_clock.c,v 1.33 2020/02/23 15:46:43 ad Exp $ */ +/* $NetBSD: uvm_pdpolicy_clock.c,v 1.34 2020/03/08 15:01:50 ad Exp $ */ /* NetBSD: uvm_pdaemon.c,v 1.72 2006/01/05 10:47:33 yamt Exp $ */ /*- - * Copyright (c) 2019 The NetBSD Foundation, Inc. + * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -98,7 +98,7 @@ #else /* defined(PDSIM) */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.33 2020/02/23 15:46:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.34 2020/03/08 15:01:50 ad Exp $"); #include #include @@ -455,7 +455,8 @@ uvmpdpol_pagedeactivate_locked(struct vm TAILQ_INSERT_TAIL(_state.s_inactiveq, pg, pdqueue); pdpol_state.s_inactive++; } - pg->pqflags = (pg->pqflags & PQ_INTENT_QUEUED) | PQ_INACTIVE; + pg->pqflags &= ~(PQ_ACTIVE | PQ_INTENT_SET); + pg->pqflags |= PQ_INACTIVE; } void @@ -486,7 +487,8 @@ uvmpdpol_pageactivate_locked(struct vm_p uvmpdpol_pagedequeue_locked(pg); TAILQ_INSERT_TAIL(_state.s_activeq, pg, pdqueue); pdpol_state.s_active++; - pg->pqflags = (pg->pqflags & PQ_INTENT_QUEUED) | PQ_ACTIVE; + pg->pqflags &= ~(PQ_INACTIVE | PQ_INTENT_SET); + pg->pqflags |= PQ_ACTIVE; } void @@ -517,7 +519,7 @@ uvmpdpol_pagedequeue_locked(struct vm_pa KASSERT(pdpol_state.s_inactive > 0); pdpol_state.s_inactive--; } - pg->pqflags &= PQ_INTENT_QUEUED; + pg->pqflags &= ~(PQ_ACTIVE | PQ_INACTIVE | PQ_INTENT_SET); } void
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Sun Mar 8 15:01:50 UTC 2020 Modified Files: src/sys/uvm: uvm_pdpolicy_clock.c Log Message: Don't zap the non-pdpolicy bits in pg->pqflags. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/uvm/uvm_pdpolicy_clock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 15:00:31 UTC 2020 Modified Files: src/sys/kern: kern_runq.c Log Message: sched_preempted(): always clear LP_TELEPORT. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/kern/kern_runq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_runq.c diff -u src/sys/kern/kern_runq.c:1.62 src/sys/kern/kern_runq.c:1.63 --- src/sys/kern/kern_runq.c:1.62 Sat Jan 25 15:09:54 2020 +++ src/sys/kern/kern_runq.c Sun Mar 8 15:00:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_runq.c,v 1.62 2020/01/25 15:09:54 ad Exp $ */ +/* $NetBSD: kern_runq.c,v 1.63 2020/03/08 15:00:31 ad Exp $ */ /*- * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.62 2020/01/25 15:09:54 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.63 2020/03/08 15:00:31 ad Exp $"); #include "opt_dtrace.h" @@ -908,6 +908,7 @@ sched_preempted(struct lwp *l) if ((tspc->spc_flags & flags) == flags && sched_migratable(l, tci)) { l->l_target_cpu = tci; + l->l_pflag &= ~LP_TELEPORT; return; } tci = tci->ci_sibling[CPUREL_CORE];
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 15:00:31 UTC 2020 Modified Files: src/sys/kern: kern_runq.c Log Message: sched_preempted(): always clear LP_TELEPORT. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/kern/kern_runq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src
On Sat, Mar 07, 2020 at 12:24:21PM +0100, Maxime Villard wrote: > Can we revert the "__aligned(COHERENCY_UNIT)" for now? There is no particular > hurry to fix this bug, however the KUBSAN instance has been down for more than > two months because of this, and it needs to be addressed. That should be quelled now. > Similarly, the KASAN instance is currently crashing hard on: > > https://syzkaller.appspot.com/bug?id=1aa3f789d356bf04644bcef632bf8c2373398ba2 > Dozens of thousands of times each day. This has been the case for two weeks, > and it too needs to be addressed. That's been there since I started looking last year. I guess it's a false positive because the sanitiser probably thinks objects are gone once pool_cache_put() is called, but the actual point of disposal is the pool_cache dtor. Andrew
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 00:31:19 UTC 2020 Modified Files: src/sys/kern: subr_kmem.c Log Message: KMEM_SIZE: append the size_t to the allocated buffer, rather than prepending, so it doesn't screw up the alignment of the buffer. Reported-by: syzbot+c024c50570cccac51...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/kern/subr_kmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_kmem.c diff -u src/sys/kern/subr_kmem.c:1.78 src/sys/kern/subr_kmem.c:1.79 --- src/sys/kern/subr_kmem.c:1.78 Sat Jan 25 15:08:40 2020 +++ src/sys/kern/subr_kmem.c Sun Mar 8 00:31:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_kmem.c,v 1.78 2020/01/25 15:08:40 ad Exp $ */ +/* $NetBSD: subr_kmem.c,v 1.79 2020/03/08 00:31:19 ad Exp $ */ /* * Copyright (c) 2009-2020 The NetBSD Foundation, Inc. @@ -62,23 +62,23 @@ /* * KMEM_SIZE: detect alloc/free size mismatch bugs. - * Prefix each allocations with a fixed-sized, aligned header and record - * the exact user-requested allocation size in it. When freeing, compare - * it with kmem_free's "size" argument. + * Append to each allocation a fixed-sized footer and record the exact + * user-requested allocation size in it. When freeing, compare it with + * kmem_free's "size" argument. * * This option is enabled on DIAGNOSTIC. * - * |CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK| - * +-+-+-+-+-+-+-+-+-+---+-+ - * |/| | | | | | | | | |U| - * |/HSZ/| | | | | | | | | |U| - * |/| | | | | | | | | |U| - * +-+-+-+-+-+-+-+-+-+---+-+ - * |Size |Buffer usable by the caller (requested size) |Unused\ + * |CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK|CHUNK| | + * +-+-+-+-+-+-+-+-+-+-+ + * | | | | | | | | |/|U| + * | | | | | | | | |/HSZ/|U| + * | | | | | | | | |/|U| + * +-+-+-+-+-+-+-+-+-+-+ + * | Buffer usable by the caller (requested size) |Size |Unused */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.78 2020/01/25 15:08:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.79 2020/03/08 00:31:19 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_kmem.h" @@ -168,10 +168,7 @@ static void *kmem_freecheck; #endif #if defined(KMEM_SIZE) -struct kmem_header { - size_t size; -} __aligned(KMEM_ALIGN); -#define SIZE_SIZE sizeof(struct kmem_header) +#define SIZE_SIZE sizeof(size_t) static void kmem_size_set(void *, size_t); static void kmem_size_check(void *, size_t); #else @@ -229,7 +226,6 @@ kmem_intr_alloc(size_t requested_size, k if (__predict_true(p != NULL)) { FREECHECK_OUT(_freecheck, p); kmem_size_set(p, requested_size); - p += SIZE_SIZE; kasan_mark(p, origsize, size, KASAN_KMEM_REDZONE); return p; } @@ -283,7 +279,6 @@ kmem_intr_free(void *p, size_t requested kasan_mark(p, size, size, 0); - p = (uint8_t *)p - SIZE_SIZE; kmem_size_check(p, requested_size); FREECHECK_IN(_freecheck, p); LOCKDEBUG_MEM_CHECK(p, size); @@ -485,25 +480,21 @@ kmem_strfree(char *str) static void kmem_size_set(void *p, size_t sz) { - struct kmem_header *hd; - hd = (struct kmem_header *)p; - hd->size = sz; + memcpy((size_t *)((uintptr_t)p + sz), , sizeof(size_t)); } static void kmem_size_check(void *p, size_t sz) { - struct kmem_header *hd; size_t hsz; - hd = (struct kmem_header *)p; - hsz = hd->size; + memcpy(, (size_t *)((uintptr_t)p + sz), sizeof(size_t)); if (hsz != sz) { - panic("kmem_free(%p, %zu) != allocated size %zu", - (const uint8_t *)p + SIZE_SIZE, sz, hsz); + panic("kmem_free(%p, %zu) != allocated size %zu; overwrote?", + p, sz, hsz); } - hd->size = -1; + memset((size_t *)((uintptr_t)p + sz), 0xff, sizeof(size_t)); } #endif /* defined(KMEM_SIZE) */
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Sun Mar 8 00:31:19 UTC 2020 Modified Files: src/sys/kern: subr_kmem.c Log Message: KMEM_SIZE: append the size_t to the allocated buffer, rather than prepending, so it doesn't screw up the alignment of the buffer. Reported-by: syzbot+c024c50570cccac51...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/kern/subr_kmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Fri Mar 6 20:46:12 UTC 2020 Modified Files: src/sys/uvm: uvm_init.c Log Message: Fix a comment. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/uvm/uvm_init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_init.c diff -u src/sys/uvm/uvm_init.c:1.52 src/sys/uvm/uvm_init.c:1.53 --- src/sys/uvm/uvm_init.c:1.52 Fri Dec 27 12:51:57 2019 +++ src/sys/uvm/uvm_init.c Fri Mar 6 20:46:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_init.c,v 1.52 2019/12/27 12:51:57 ad Exp $ */ +/* $NetBSD: uvm_init.c,v 1.53 2020/03/06 20:46:12 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.52 2019/12/27 12:51:57 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.53 2020/03/06 20:46:12 ad Exp $"); #include #include @@ -164,9 +164,7 @@ uvm_init(void) uvm_loan_init(); /* - * The VM system is now up! Now that kmem is up we can resize the - * => hash table for general use and enable paging - * of kernel objects. + * Enable paging of kernel objects. */ uao_create(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS,
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Fri Mar 6 20:46:12 UTC 2020 Modified Files: src/sys/uvm: uvm_init.c Log Message: Fix a comment. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/uvm/uvm_init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.