Re: svn commit: r339386 - in head/sys/amd64: amd64 include
On 10/16/18, Konstantin Belousov wrote: > Author: kib > Date: Tue Oct 16 17:28:10 2018 > New Revision: 339386 > URL: https://svnweb.freebsd.org/changeset/base/339386 > > Log: > Provide pmap_large_map() KPI on amd64. > > The KPI allows to map very large contigous physical memory regions > into KVA, which are not covered by DMAP. > > I see both with QEMU and with some real hardware started shipping, the > regions for NVDIMMs might be very far apart from the normal RAM, and > we expect that at least initial users of NVDIMM could install very > large amount of such memory. IMO it is not reasonable to extend DMAP > to cover that far-away regions both because it could overflow existing > 4T window for DMAP in KVA, and because it costs in page table pages > allocations, for gap and for possibly unused NV RAM. > > Also, KPI provides some special functionality for fast cache flushing > based on the knowledge of the NVRAM mapping use. > > Reviewed by:alc, markj > Sponsored by: The FreeBSD Foundation > Approved by:re (gjb) > MFC after: 1 week > Differential revision: https://reviews.freebsd.org/D17070 > > Modified: > head/sys/amd64/amd64/pmap.c > head/sys/amd64/include/pmap.h > head/sys/amd64/include/vmparam.h > > Modified: head/sys/amd64/amd64/pmap.c > == > --- head/sys/amd64/amd64/pmap.c Tue Oct 16 17:17:11 2018 > (r339385) > +++ head/sys/amd64/amd64/pmap.c Tue Oct 16 17:28:10 2018 > (r339386) > @@ -409,6 +409,9 @@ static struct mtx qframe_mtx; > > static int pmap_flags = PMAP_PDE_SUPERPAGE; /* flags for x86 pmaps */ > > +static vmem_t *large_vmem; > +static u_int lm_ents; > + > int pmap_pcid_enabled = 1; > SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | > CTLFLAG_NOFETCH, > _pcid_enabled, 0, "Is TLB Context ID enabled ?"); > @@ -655,6 +658,7 @@ static void pmap_invalidate_cache_range_all(vm_offset_ > static void pmap_invalidate_pde_page(pmap_t pmap, vm_offset_t va, > pd_entry_t pde); > static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); > +static vm_page_t pmap_large_map_getptp_unlocked(void); > static void pmap_pde_attr(pd_entry_t *pde, int cache_bits, int mask); > #if VM_NRESERVLEVEL > 0 > static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, > @@ -1313,7 +1317,7 @@ void > pmap_init(void) > { > struct pmap_preinit_mapping *ppim; > - vm_page_t mpte; > + vm_page_t m, mpte; > vm_size_t s; > int error, i, pv_npg, ret, skz63; > > @@ -1440,6 +1444,28 @@ pmap_init(void) > (vmem_addr_t *)); > if (error != 0) > panic("qframe allocation failed"); > + > + lm_ents = 8; > + TUNABLE_INT_FETCH("vm.pmap.large_map_pml4_entries", _ents); > + if (lm_ents > LMEPML4I - LMSPML4I + 1) > + lm_ents = LMEPML4I - LMSPML4I + 1; > + if (bootverbose) > + printf("pmap: large map %u PML4 slots (%lu Gb)\n", Isn't this GB (GigaByte instead of Gigabit?) > + lm_ents, (u_long)lm_ents * (NBPML4 / 1024 / 1024 / 1024)); > + if (lm_ents != 0) { > + large_vmem = vmem_create("large", LARGEMAP_MIN_ADDRESS, > + (vmem_size_t)lm_ents * NBPML4, PAGE_SIZE, 0, M_WAITOK); > + if (large_vmem == NULL) { > + printf("pmap: cannot create large map\n"); > + lm_ents = 0; > + } > + for (i = 0; i < lm_ents; i++) { > + m = pmap_large_map_getptp_unlocked(); > + kernel_pmap->pm_pml4[LMSPML4I + i] = X86_PG_V | > + X86_PG_RW | X86_PG_A | X86_PG_M | pg_nx | > + VM_PAGE_TO_PHYS(m); > + } > + } > } > > static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0, > @@ -2315,14 +2341,6 @@ pmap_force_invalidate_cache_range(vm_offset_t sva, > vm_ > { > > sva &= ~(vm_offset_t)(cpu_clflush_line_size - 1); > - if (eva - sva >= PMAP_CLFLUSH_THRESHOLD) { > - /* > - * The supplied range is bigger than 2MB. > - * Globally invalidate cache. > - */ > - pmap_invalidate_cache(); > - return; > - } > > /* >* XXX: Some CPUs fault, hang, or trash the local APIC > @@ -2406,6 +2424,64 @@ pmap_invalidate_cache_pages(vm_page_t *pages, int > coun > } > } > > +void > +pmap_flush_cache_range(vm_offset_t sva, vm_offset_t eva) > +{ > + > + pmap_invalidate_cache_range_check_align(sva, eva); > + > + if ((cpu_stdext_feature & CPUID_STDEXT_CLWB) == 0) { > + pmap_force_invalidate_cache_range(sva, eva); > + return; > + } > + > + /* See comment in pmap_force_invalidate_cache_range(). */ > + if (pmap_kextract(sva) == lapic_paddr) > + return; > + > + sfence(); > +
svn commit: r339391 - in head/sys: dev/nvdimm modules modules/nvdimm
Author: kib Date: Tue Oct 16 20:12:35 2018 New Revision: 339391 URL: https://svnweb.freebsd.org/changeset/base/339391 Log: Add initial driver for ACPI NFIT-enumerated NVDIMMs. Driver enumerates NVDIMMs. Besides, for each found System Physical Address (SPA) range, spaN geom provider is created, which allows formatting and mounting the region as the normal volume. Also, /dev/nvdimm_spaN node is created, which can be read/written/mapped by userspace, the mapping is zero-copy. No support for block access methods implemented, labels are not parsed. No management interfaces are provided. Tested by:Intel, NetApp Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after:2 weeks Added: head/sys/dev/nvdimm/ head/sys/dev/nvdimm/nvdimm.c (contents, props changed) head/sys/dev/nvdimm/nvdimm_spa.c (contents, props changed) head/sys/dev/nvdimm/nvdimm_var.h (contents, props changed) head/sys/modules/nvdimm/ head/sys/modules/nvdimm/Makefile (contents, props changed) Modified: head/sys/modules/Makefile Added: head/sys/dev/nvdimm/nvdimm.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/nvdimm/nvdimm.cTue Oct 16 20:12:35 2018 (r339391) @@ -0,0 +1,423 @@ +/*- + * Copyright (c) 2017 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_acpi.h" +#include "opt_ddb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define _COMPONENT ACPI_OEM +ACPI_MODULE_NAME("NVDIMM") + +static devclass_t nvdimm_devclass; +static device_t *nvdimm_devs; +static int nvdimm_devcnt; +MALLOC_DEFINE(M_NVDIMM, "nvdimm", "NVDIMM driver memory"); + +struct nvdimm_dev * +nvdimm_find_by_handle(nfit_handle_t nv_handle) +{ + device_t dev; + struct nvdimm_dev *res, *nv; + int i; + + res = NULL; + for (i = 0; i < nvdimm_devcnt; i++) { + dev = nvdimm_devs[i]; + if (dev == NULL) + continue; + nv = device_get_softc(dev); + if (nv->nv_handle == nv_handle) { + res = nv; + break; + } + } + return (res); +} + +static int +nvdimm_parse_flush_addr(void *nfitsubtbl, void *arg) +{ + ACPI_NFIT_FLUSH_ADDRESS *nfitflshaddr; + struct nvdimm_dev *nv; + int i; + + nfitflshaddr = nfitsubtbl; + nv = arg; + if (nfitflshaddr->DeviceHandle != nv->nv_handle) + return (0); + + MPASS(nv->nv_flush_addr == NULL && nv->nv_flush_addr_cnt == 0); + nv->nv_flush_addr = malloc(nfitflshaddr->HintCount * sizeof(uint64_t *), + M_NVDIMM, M_WAITOK); + for (i = 0; i < nfitflshaddr->HintCount; i++) + nv->nv_flush_addr[i] = (uint64_t *)nfitflshaddr->HintAddress[i]; + nv->nv_flush_addr_cnt = nfitflshaddr->HintCount; + return (0); +} + +int +nvdimm_iterate_nfit(ACPI_TABLE_NFIT *nfitbl, enum AcpiNfitType type, +int (*cb)(void *, void *), void *arg) +{ + ACPI_NFIT_HEADER *nfithdr; + ACPI_NFIT_SYSTEM_ADDRESS *nfitaddr; + ACPI_NFIT_MEMORY_MAP *nfitmap; + ACPI_NFIT_INTERLEAVE *nfitintrl; + ACPI_NFIT_SMBIOS *nfitsmbios; + ACPI_NFIT_CONTROL_REGION *nfitctlreg; + ACPI_NFIT_DATA_REGION *nfitdtreg; + ACPI_NFIT_FLUSH_ADDRESS
svn commit: r339390 - in head: sys/kern tests/sys/kern
Author: markj Date: Tue Oct 16 20:06:56 2018 New Revision: 339390 URL: https://svnweb.freebsd.org/changeset/base/339390 Log: Reparent a child of pdfork(2) to its reaper when the procdesc is closed. Unconditionally reparenting to PID 1 breaks the procctl(2) reaper functionality. Add a regression test for this case. Reviewed by: kib Approved by: re (gjb) MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D17589 Modified: head/sys/kern/sys_procdesc.c head/tests/sys/kern/reaper.c Modified: head/sys/kern/sys_procdesc.c == --- head/sys/kern/sys_procdesc.cTue Oct 16 19:26:04 2018 (r339389) +++ head/sys/kern/sys_procdesc.cTue Oct 16 20:06:56 2018 (r339390) @@ -312,8 +312,8 @@ procdesc_exit(struct proc *p) pd = p->p_procdesc; PROCDESC_LOCK(pd); - KASSERT((pd->pd_flags & PDF_CLOSED) == 0 || p->p_pptr == initproc, - ("procdesc_exit: closed && parent not init")); + KASSERT((pd->pd_flags & PDF_CLOSED) == 0 || p->p_pptr == p->p_reaper, + ("procdesc_exit: closed && parent not reaper")); pd->pd_flags |= PDF_EXITED; pd->pd_xstat = KW_EXITCODE(p->p_xexit, p->p_xsig); @@ -361,7 +361,8 @@ procdesc_reap(struct proc *p) /* * procdesc_close() - last close on a process descriptor. If the process is * still running, terminate with SIGKILL (unless PDF_DAEMON is set) and let - * init(8) clean up the mess; if not, we have to clean up the zombie ourselves. + * its reaper clean up the mess; if not, we have to clean up the zombie + * ourselves. */ static int procdesc_close(struct file *fp, struct thread *td) @@ -410,12 +411,12 @@ procdesc_close(struct file *fp, struct thread *td) procdesc_free(pd); /* -* Next, reparent it to init(8) so that there's someone -* to pick up the pieces; finally, terminate with -* prejudice. +* Next, reparent it to its reaper (usually init(8)) so +* that there's someone to pick up the pieces; finally, +* terminate with prejudice. */ p->p_sigparent = SIGCHLD; - proc_reparent(p, initproc); + proc_reparent(p, p->p_reaper); if ((pd->pd_flags & PDF_DAEMON) == 0) kern_psignal(p, SIGKILL); PROC_UNLOCK(p); Modified: head/tests/sys/kern/reaper.c == --- head/tests/sys/kern/reaper.cTue Oct 16 19:26:04 2018 (r339389) +++ head/tests/sys/kern/reaper.cTue Oct 16 20:06:56 2018 (r339390) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -740,6 +741,40 @@ ATF_TC_BODY(reaper_kill_subtree, tc) ATF_REQUIRE_EQ(0, r); } +ATF_TC_WITHOUT_HEAD(reaper_pdfork); +ATF_TC_BODY(reaper_pdfork, tc) +{ + struct procctl_reaper_status st; + pid_t child, grandchild, parent, pid; + int pd, r, status; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(r, 0); + + child = pdfork(, 0); + ATF_REQUIRE(child != -1); + if (child == 0) { + grandchild = pdfork(, 0); + if (grandchild == -1) + _exit(1); + if (grandchild == 0) + pause(); + _exit(0); + } + pid = waitpid(child, , 0); + ATF_REQUIRE_EQ(pid, child); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_REQUIRE_EQ(r, 0); + + r = procctl(P_PID, parent, PROC_REAP_STATUS, ); + ATF_REQUIRE_EQ(r, 0); + ATF_CHECK((st.rs_flags & REAPER_STATUS_OWNED) != 0); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK(st.rs_children == 1); + ATF_CHECK(st.rs_descendants == 1); +} + ATF_TP_ADD_TCS(tp) { @@ -754,5 +789,6 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, reaper_kill_empty); ATF_TP_ADD_TC(tp, reaper_kill_normal); ATF_TP_ADD_TC(tp, reaper_kill_subtree); + ATF_TP_ADD_TC(tp, reaper_pdfork); return (atf_no_error()); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339388 - head/sys/dev/usb/controller
Author: hselasky Date: Tue Oct 16 18:47:13 2018 New Revision: 339388 URL: https://svnweb.freebsd.org/changeset/base/339388 Log: Fix for reception of large full speed isochronous frames via the transaction translator, when using the DWC OTG USB controller driver. Make sure to re-try getting the complete split packets until a DATA0 packet is received. Larger isochronous frames may be split into multiple MDATA packets terminated by a single DATA0 packet. PR: 230434 MFC after:3 days Approved by: re (gjb) Sponsored by: Mellanox Technologies Modified: head/sys/dev/usb/controller/dwc_otg.c Modified: head/sys/dev/usb/controller/dwc_otg.c == --- head/sys/dev/usb/controller/dwc_otg.c Tue Oct 16 18:17:07 2018 (r339387) +++ head/sys/dev/usb/controller/dwc_otg.c Tue Oct 16 18:47:13 2018 (r339388) @@ -1458,6 +1458,8 @@ dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct /* check if we are complete */ if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN) { goto complete; + } else if (td->hcsplt != 0) { + goto receive_pkt; } else { /* get more packets */ goto busy; @@ -1516,8 +1518,10 @@ receive_pkt: if (td->hcsplt != 0) { delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { - td->state = DWC_CHAN_ST_WAIT_C_PKT; - goto busy; + if (td->ep_type != UE_ISOCHRONOUS) { + td->state = DWC_CHAN_ST_WAIT_C_PKT; + goto busy; + } } delta = sc->sc_last_frame_num - td->tt_start_slot; if (delta > DWC_OTG_TT_SLOT_MAX) { @@ -1563,12 +1567,23 @@ receive_pkt: hcchar = td->hcchar; hcchar |= HCCHAR_EPDIR_IN; - /* receive complete split ASAP */ - if ((sc->sc_last_frame_num & 1) != 0 && - td->ep_type == UE_ISOCHRONOUS) - hcchar |= HCCHAR_ODDFRM; - else + if (td->ep_type == UE_ISOCHRONOUS) { + if (td->hcsplt != 0) { + /* continously buffer */ + if (sc->sc_last_frame_num & 1) + hcchar &= ~HCCHAR_ODDFRM; + else + hcchar |= HCCHAR_ODDFRM; + } else { + /* multi buffer, if any */ + if (sc->sc_last_frame_num & 1) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; + } + } else { hcchar &= ~HCCHAR_ODDFRM; + } /* must enable channel before data can be received */ DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339387 - head/lib/libc/gen
Author: trasz Date: Tue Oct 16 18:17:07 2018 New Revision: 339387 URL: https://svnweb.freebsd.org/changeset/base/339387 Log: Get rid unneccessary useless calls to lseek(2) from getgrent(3). Looks like this: fstatat(AT_FDCWD,"/etc/nsswitch.conf",{ mode=-rw-r--r-- ,inode=2167001,size=390,blksize=32768 },0x0) = 0 (0x0) open("/etc/group",O_RDONLY|O_CLOEXEC,0666) = 3 (0x3) fstat(3,{ mode=-rw-r--r-- ,inode=2166927,size=919,blksize=32768 }) = 0 (0x0) -lseek(3,0x0,SEEK_CUR) = 0 (0x0) -lseek(3,0x0,SEEK_SET) = 0 (0x0) read(3,"# $FreeBSD: release/10.0.0/etc/g"...,32768) = 919 (0x397) close(3)= 0 (0x0) Reviewed by: kib Approved by: re (gjb) MFC after:2 weeks Sponsored by: DARPA, AFRL Differential Revision:https://reviews.freebsd.org/D17571 Modified: head/lib/libc/gen/getgrent.c Modified: head/lib/libc/gen/getgrent.c == --- head/lib/libc/gen/getgrent.cTue Oct 16 17:28:10 2018 (r339386) +++ head/lib/libc/gen/getgrent.cTue Oct 16 18:17:07 2018 (r339387) @@ -836,8 +836,9 @@ files_group(void *retval, void *mdata, va_list ap) char*buffer; size_t bufsize, linesize; off_tpos; - int rv, stayopen, *errnop; + int fresh, rv, stayopen, *errnop; + fresh = 0; name = NULL; gid = (gid_t)-1; how = (enum nss_lookup_type)mdata; @@ -860,19 +861,24 @@ files_group(void *retval, void *mdata, va_list ap) *errnop = files_getstate(); if (*errnop != 0) return (NS_UNAVAIL); - if (st->fp == NULL && - ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) { - *errnop = errno; - return (NS_UNAVAIL); + if (st->fp == NULL) { + st->fp = fopen(_PATH_GROUP, "re"); + if (st->fp == NULL) { + *errnop = errno; + return (NS_UNAVAIL); + } + fresh = 1; } if (how == nss_lt_all) stayopen = 1; else { - rewind(st->fp); + if (!fresh) + rewind(st->fp); stayopen = st->stayopen; } rv = NS_NOTFOUND; - pos = ftello(st->fp); + if (stayopen) + pos = ftello(st->fp); while ((line = fgetln(st->fp, )) != NULL) { if (line[linesize-1] == '\n') linesize--; @@ -894,7 +900,8 @@ files_group(void *retval, void *mdata, va_list ap) [linesize + 1], bufsize - linesize - 1, errnop); if (rv & NS_TERMINATE) break; - pos = ftello(st->fp); + if (stayopen) + pos = ftello(st->fp); } if (st->fp != NULL && !stayopen) { fclose(st->fp); @@ -1304,7 +1311,7 @@ compat_group(void *retval, void *mdata, va_list ap) void*discard; size_t bufsize, linesize; off_tpos; - int rv, stayopen, *errnop; + int fresh, rv, stayopen, *errnop; #define set_lookup_type(x, y) do { \ int i; \ @@ -1312,6 +1319,7 @@ compat_group(void *retval, void *mdata, va_list ap) x[i].mdata = (void *)y; \ } while (0) + fresh = 0; name = NULL; gid = (gid_t)-1; how = (enum nss_lookup_type)mdata; @@ -1334,16 +1342,20 @@ compat_group(void *retval, void *mdata, va_list ap) *errnop = compat_getstate(); if (*errnop != 0) return (NS_UNAVAIL); - if (st->fp == NULL && - ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) { - *errnop = errno; - rv = NS_UNAVAIL; - goto fin; + if (st->fp == NULL) { + st->fp = fopen(_PATH_GROUP, "re"); + if (st->fp == NULL) { + *errnop = errno; + rv = NS_UNAVAIL; + goto fin; + } + fresh = 1; } if (how == nss_lt_all) stayopen = 1; else { - rewind(st->fp); + if (!fresh) + rewind(st->fp); stayopen = st->stayopen; } docompat: @@ -1406,7 +1418,8 @@ docompat: break; } rv = NS_NOTFOUND; - pos = ftello(st->fp); + if (stayopen) + pos = ftello(st->fp); while ((line = fgetln(st->fp, )) != NULL) { if
svn commit: r339386 - in head/sys/amd64: amd64 include
Author: kib Date: Tue Oct 16 17:28:10 2018 New Revision: 339386 URL: https://svnweb.freebsd.org/changeset/base/339386 Log: Provide pmap_large_map() KPI on amd64. The KPI allows to map very large contigous physical memory regions into KVA, which are not covered by DMAP. I see both with QEMU and with some real hardware started shipping, the regions for NVDIMMs might be very far apart from the normal RAM, and we expect that at least initial users of NVDIMM could install very large amount of such memory. IMO it is not reasonable to extend DMAP to cover that far-away regions both because it could overflow existing 4T window for DMAP in KVA, and because it costs in page table pages allocations, for gap and for possibly unused NV RAM. Also, KPI provides some special functionality for fast cache flushing based on the knowledge of the NVRAM mapping use. Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after:1 week Differential revision:https://reviews.freebsd.org/D17070 Modified: head/sys/amd64/amd64/pmap.c head/sys/amd64/include/pmap.h head/sys/amd64/include/vmparam.h Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Tue Oct 16 17:17:11 2018(r339385) +++ head/sys/amd64/amd64/pmap.c Tue Oct 16 17:28:10 2018(r339386) @@ -409,6 +409,9 @@ static struct mtx qframe_mtx; static int pmap_flags = PMAP_PDE_SUPERPAGE;/* flags for x86 pmaps */ +static vmem_t *large_vmem; +static u_int lm_ents; + int pmap_pcid_enabled = 1; SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, _pcid_enabled, 0, "Is TLB Context ID enabled ?"); @@ -655,6 +658,7 @@ static void pmap_invalidate_cache_range_all(vm_offset_ static void pmap_invalidate_pde_page(pmap_t pmap, vm_offset_t va, pd_entry_t pde); static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); +static vm_page_t pmap_large_map_getptp_unlocked(void); static void pmap_pde_attr(pd_entry_t *pde, int cache_bits, int mask); #if VM_NRESERVLEVEL > 0 static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, @@ -1313,7 +1317,7 @@ void pmap_init(void) { struct pmap_preinit_mapping *ppim; - vm_page_t mpte; + vm_page_t m, mpte; vm_size_t s; int error, i, pv_npg, ret, skz63; @@ -1440,6 +1444,28 @@ pmap_init(void) (vmem_addr_t *)); if (error != 0) panic("qframe allocation failed"); + + lm_ents = 8; + TUNABLE_INT_FETCH("vm.pmap.large_map_pml4_entries", _ents); + if (lm_ents > LMEPML4I - LMSPML4I + 1) + lm_ents = LMEPML4I - LMSPML4I + 1; + if (bootverbose) + printf("pmap: large map %u PML4 slots (%lu Gb)\n", + lm_ents, (u_long)lm_ents * (NBPML4 / 1024 / 1024 / 1024)); + if (lm_ents != 0) { + large_vmem = vmem_create("large", LARGEMAP_MIN_ADDRESS, + (vmem_size_t)lm_ents * NBPML4, PAGE_SIZE, 0, M_WAITOK); + if (large_vmem == NULL) { + printf("pmap: cannot create large map\n"); + lm_ents = 0; + } + for (i = 0; i < lm_ents; i++) { + m = pmap_large_map_getptp_unlocked(); + kernel_pmap->pm_pml4[LMSPML4I + i] = X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M | pg_nx | + VM_PAGE_TO_PHYS(m); + } + } } static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0, @@ -2315,14 +2341,6 @@ pmap_force_invalidate_cache_range(vm_offset_t sva, vm_ { sva &= ~(vm_offset_t)(cpu_clflush_line_size - 1); - if (eva - sva >= PMAP_CLFLUSH_THRESHOLD) { - /* -* The supplied range is bigger than 2MB. -* Globally invalidate cache. -*/ - pmap_invalidate_cache(); - return; - } /* * XXX: Some CPUs fault, hang, or trash the local APIC @@ -2406,6 +2424,64 @@ pmap_invalidate_cache_pages(vm_page_t *pages, int coun } } +void +pmap_flush_cache_range(vm_offset_t sva, vm_offset_t eva) +{ + + pmap_invalidate_cache_range_check_align(sva, eva); + + if ((cpu_stdext_feature & CPUID_STDEXT_CLWB) == 0) { + pmap_force_invalidate_cache_range(sva, eva); + return; + } + + /* See comment in pmap_force_invalidate_cache_range(). */ + if (pmap_kextract(sva) == lapic_paddr) + return; + + sfence(); + for (; sva < eva; sva += cpu_clflush_line_size) + clwb(sva); + sfence(); +} + +void +pmap_flush_cache_phys_range(vm_paddr_t spa, vm_paddr_t epa, vm_memattr_t mattr) +{ + pt_entry_t *pte; + vm_offset_t vaddr; + int
svn commit: r339385 - head/contrib/mandoc
Author: yuripv Date: Tue Oct 16 17:17:11 2018 New Revision: 339385 URL: https://svnweb.freebsd.org/changeset/base/339385 Log: apropos/whatis: use output of manpath(1) to set defpaths if -M is not specified. This fixes searching the paths specified in /usr/local/etc/man.d/*.conf, as currently apropos/whatis from mandoc suite aren't aware about them. PR: 227922 Reviewed by: bapt Approved by: re (gjb), kib (mentor) Differential Revision:https://reviews.freebsd.org/D17454 Modified: head/contrib/mandoc/main.c Modified: head/contrib/mandoc/main.c == --- head/contrib/mandoc/main.c Tue Oct 16 17:00:42 2018(r339384) +++ head/contrib/mandoc/main.c Tue Oct 16 17:17:11 2018(r339385) @@ -248,7 +248,13 @@ main(int argc, char *argv[]) outmode = OUTMODE_ALL; break; case 'M': +#ifdef __FreeBSD__ + defpaths = strdup(optarg); + if (defpaths == NULL) + err(1, "strdup"); +#else defpaths = optarg; +#endif break; case 'm': auxpaths = optarg; @@ -380,9 +386,34 @@ main(int argc, char *argv[]) outmode == OUTMODE_ONE) search.firstmatch = 1; +#ifdef __FreeBSD__ + /* +* Use manpath(1) to populate defpaths if -M is not specified. +* Don't treat any failures as fatal. +*/ + if (defpaths == NULL) { + FILE *fp; + size_t linecap = 0; + ssize_t linelen; + + if ((fp = popen("/usr/bin/manpath -q", "r")) != NULL) { + if ((linelen = getline(, + , fp)) > 0) { + /* Strip trailing newline */ + defpaths[linelen - 1] = '\0'; + } + pclose(fp); + } + } +#endif + /* Access the mandoc database. */ manconf_parse(, conf_file, defpaths, auxpaths); +#ifdef __FreeBSD__ + free(defpaths); +#endif + if ( ! mansearch(, , argc, argv, , )) usage(search.argmode); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339384 - head/sys/amd64/include
Author: kib Date: Tue Oct 16 17:00:42 2018 New Revision: 339384 URL: https://svnweb.freebsd.org/changeset/base/339384 Log: Add clwb(). Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after:3 days Differential revision:https://reviews.freebsd.org/D17070 Modified: head/sys/amd64/include/cpufunc.h Modified: head/sys/amd64/include/cpufunc.h == --- head/sys/amd64/include/cpufunc.hTue Oct 16 16:45:21 2018 (r339383) +++ head/sys/amd64/include/cpufunc.hTue Oct 16 17:00:42 2018 (r339384) @@ -116,6 +116,13 @@ clflushopt(u_long addr) } static __inline void +clwb(u_long addr) +{ + + __asm __volatile("clwb %0" : : "m" (*(char *)addr)); +} + +static __inline void clts(void) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339381 - head/sys/riscv/riscv
Author: br Date: Tue Oct 16 16:03:17 2018 New Revision: 339381 URL: https://svnweb.freebsd.org/changeset/base/339381 Log: Invalidate TLB on a local hart. This was missed in r339367 ("Various fixes for TLB management on RISC-V."). This fixes operation on lowRISC. Reviewed by: jhb Approved by: re (gjb) Sponsored by: DARPA, AFRL Differential Revision:https://reviews.freebsd.org/D17583 Modified: head/sys/riscv/riscv/pmap.c Modified: head/sys/riscv/riscv/pmap.c == --- head/sys/riscv/riscv/pmap.c Tue Oct 16 16:00:41 2018(r339380) +++ head/sys/riscv/riscv/pmap.c Tue Oct 16 16:03:17 2018(r339381) @@ -804,6 +804,7 @@ pmap_invalidate_all(pmap_t pmap) * all sfence_vma requests as global however. */ sbi_remote_sfence_vma(mask.__bits, 0, 0); + sfence_vma(); sched_unpin(); } #else ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339380 - head/usr.sbin/pw
Author: yuripv Date: Tue Oct 16 16:00:41 2018 New Revision: 339380 URL: https://svnweb.freebsd.org/changeset/base/339380 Log: pw: (file == NULL) check is always false in read_userconfig(), remove it. Drop the now unused _PATH_PW_CONF definition. [1] While here, change the last remaining hardcoded "/etc" to _PATH_PWD. Noted by: glebius [1] Reviewed by: eugen Approved by: re (gjb), kib (mentor) Differential Revision:https://reviews.freebsd.org/D17575 Modified: head/usr.sbin/pw/pw.c head/usr.sbin/pw/pw.h head/usr.sbin/pw/pw_conf.c Modified: head/usr.sbin/pw/pw.c == --- head/usr.sbin/pw/pw.c Tue Oct 16 15:57:16 2018(r339379) +++ head/usr.sbin/pw/pw.c Tue Oct 16 16:00:41 2018(r339380) @@ -162,7 +162,8 @@ main(int argc, char *argv[]) PWF._altdir = PWF_ROOTDIR; } snprintf(conf.etcpath, sizeof(conf.etcpath), - "%s%s", optarg, arg == 'R' ? "/etc" : ""); + "%s%s", optarg, arg == 'R' ? + _PATH_PWD : ""); } else break; } Modified: head/usr.sbin/pw/pw.h == --- head/usr.sbin/pw/pw.h Tue Oct 16 15:57:16 2018(r339379) +++ head/usr.sbin/pw/pw.h Tue Oct 16 16:00:41 2018(r339380) @@ -65,7 +65,6 @@ enum _which #define_DEF_DIRMODE(S_IRWXU | S_IRWXG | S_IRWXO) #define_PW_CONF"pw.conf" -#define _PATH_PW_CONF "/etc/pw.conf" #define _UC_MAXLINE1024 #define _UC_MAXSHELLS 32 Modified: head/usr.sbin/pw/pw_conf.c == --- head/usr.sbin/pw/pw_conf.c Tue Oct 16 15:57:16 2018(r339379) +++ head/usr.sbin/pw/pw_conf.c Tue Oct 16 16:00:41 2018(r339380) @@ -255,9 +255,6 @@ read_userconfig(char const * file) buf = NULL; linecap = 0; - if (file == NULL) - file = _PATH_PW_CONF; - if ((fp = fopen(file, "r")) == NULL) return (); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339379 - head/sys/kern
Author: glebius Date: Tue Oct 16 15:57:16 2018 New Revision: 339379 URL: https://svnweb.freebsd.org/changeset/base/339379 Log: Plug sendfile(2) on a listening socket with proper error code. Reported by: ngie Reviewed by: ngie Approved by: re (delphij) Modified: head/sys/kern/kern_sendfile.c Modified: head/sys/kern/kern_sendfile.c == --- head/sys/kern/kern_sendfile.c Tue Oct 16 14:41:09 2018 (r339378) +++ head/sys/kern/kern_sendfile.c Tue Oct 16 15:57:16 2018 (r339379) @@ -526,6 +526,8 @@ sendfile_getsock(struct thread *td, int s, struct file *so = (*sock_fp)->f_data; if ((*so)->so_type != SOCK_STREAM) return (EINVAL); + if (SOLISTENING(*so)) + return (ENOTCONN); return (0); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339378 - head/sys/netinet
Author: jtl Date: Tue Oct 16 14:41:09 2018 New Revision: 339378 URL: https://svnweb.freebsd.org/changeset/base/339378 Log: In r338102, the TCP reassembly code was substantially restructured. Prior to this change, the code sometimes used a temporary stack variable to hold details of a TCP segment. r338102 stopped using the variable to hold segments, but did not actually remove the variable. Because the variable is no longer used, we can safely remove it. Approved by: re (gjb) Modified: head/sys/netinet/tcp_reass.c Modified: head/sys/netinet/tcp_reass.c == --- head/sys/netinet/tcp_reass.cTue Oct 16 14:16:39 2018 (r339377) +++ head/sys/netinet/tcp_reass.cTue Oct 16 14:41:09 2018 (r339378) @@ -528,7 +528,6 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, tcp_seq struct tseg_qent *p = NULL; struct tseg_qent *nq = NULL; struct tseg_qent *te = NULL; - struct tseg_qent tqs; struct mbuf *mlast = NULL; struct sockbuf *sb; struct socket *so = tp->t_inpcb->inp_socket; @@ -1053,8 +1052,7 @@ present: KASSERT(tp->t_segqmbuflen >= q->tqe_mbuf_cnt, ("tp:%p seg queue goes negative", tp)); tp->t_segqmbuflen -= q->tqe_mbuf_cnt; - if (q != ) - uma_zfree(tcp_reass_zone, q); + uma_zfree(tcp_reass_zone, q); tp->t_segqlen--; q = nq; } while (q && q->tqe_start == tp->rcv_nxt); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r339377 - head/sys/conf
Author: gjb Date: Tue Oct 16 14:16:39 2018 New Revision: 339377 URL: https://svnweb.freebsd.org/changeset/base/339377 Log: Update head from ALPHA9 to ALPHA10 as part of the 12.0-RELEASE cycle. This is expected to be the final ALPHA build of this release cycle, prior to branching stable/12. Approved by: re (implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/conf/newvers.sh Modified: head/sys/conf/newvers.sh == --- head/sys/conf/newvers.shTue Oct 16 03:18:57 2018(r339376) +++ head/sys/conf/newvers.shTue Oct 16 14:16:39 2018(r339377) @@ -46,7 +46,7 @@ TYPE="FreeBSD" REVISION="12.0" -BRANCH="ALPHA9" +BRANCH="ALPHA10" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r339350 - head/contrib/elftoolchain/elfcopy
On Tue, Oct 16, 2018 at 10:26:14AM +0300, Konstantin Belousov wrote: > On Tue, Oct 16, 2018 at 07:39:32AM +0200, Antoine Brodin wrote: > > On Mon, Oct 15, 2018 at 3:53 PM Ed Maste wrote: > > > On Mon, 15 Oct 2018 at 07:13, Ed Maste wrote: > > > > Hi Antoine, did you bisect to this rev or does it just look like the > > > > most probable candidate? Can you copy a pair of differing .o files > > > > (say, gcc/cc1plus-checksum.o) from the work dir to freefall? > > > > > > Antoine provided a tarball of the work dir to me, and pointed out that > > > the *-checksum.o files are not interesting - they are warnings only > > > and are present prior to the identified change. > > > > > > Comparing one of the other differing files, e.g. > > > stage{2,3}-gcc/expmed.o, demonstrates the problem. Gcc's build > > > machinery is reasonably obfuscated so I'm not sure of the exact set of > > > operations, but I can infer that the stage2/stage3 comparison is > > > running strip on the object files and then comparing the result. Gcc > > > is encountering this part of my strip/objcopy change: > > > > > > > Stripping binaries with relocations > > > > referencing removed symbols was already broken, and after this change > > > > may still be broken in a different way. > > > > > > Stripping symbols and relocations from an object file is not a > > > particularly useful operation, since the object then can't be linked > > > or otherwise used. But it seems Gcc's stage comparison relies on this. > > > I did try running "strip --strip-debug" on stage{2,3}-gcc/expmed.o (a > > > reasonable operation on object files) and that produced identical > > > output. > > > > > > It may well be that a further change to ELF Tool Chain's strip is > > > warranted, but I suspect the most straightforward and reliable fix > > > here will be to just have gcc use GNU strip. > > > > The attached patch for the gcc ports fixes the failures for me. > > > > Antoine > > > Index: lang/gcc48/Makefile > > === > > --- lang/gcc48/Makefile (revision 482165) > > +++ lang/gcc48/Makefile (working copy) > > @@ -33,6 +33,7 @@ > > SUFFIX=${PORTVERSION:C/([0-9]+).([0-9]+).*/\1\2/} > > USES= compiler cpe gmake iconv libtool makeinfo perl5 > > tar:bzip2 > > USE_BINUTILS= yes > > +BINARY_ALIAS= strip=${LOCALBASE}/bin/strip > Shouldn't USE_BINUTILS automatically prefer all binaries from there to be > used, instead of the base system variants ? > Strip is not in the list of binaries to override, probably something to fix. Plus it expects the build system to respect the "classic" env var, which imho should be replaced by BINARY_ALIAS when possible Best regards, Bapt signature.asc Description: PGP signature
Re: svn commit: r339350 - head/contrib/elftoolchain/elfcopy
On Tue, Oct 16, 2018 at 07:39:32AM +0200, Antoine Brodin wrote: > On Mon, Oct 15, 2018 at 3:53 PM Ed Maste wrote: > > On Mon, 15 Oct 2018 at 07:13, Ed Maste wrote: > > > Hi Antoine, did you bisect to this rev or does it just look like the > > > most probable candidate? Can you copy a pair of differing .o files > > > (say, gcc/cc1plus-checksum.o) from the work dir to freefall? > > > > Antoine provided a tarball of the work dir to me, and pointed out that > > the *-checksum.o files are not interesting - they are warnings only > > and are present prior to the identified change. > > > > Comparing one of the other differing files, e.g. > > stage{2,3}-gcc/expmed.o, demonstrates the problem. Gcc's build > > machinery is reasonably obfuscated so I'm not sure of the exact set of > > operations, but I can infer that the stage2/stage3 comparison is > > running strip on the object files and then comparing the result. Gcc > > is encountering this part of my strip/objcopy change: > > > > > Stripping binaries with relocations > > > referencing removed symbols was already broken, and after this change > > > may still be broken in a different way. > > > > Stripping symbols and relocations from an object file is not a > > particularly useful operation, since the object then can't be linked > > or otherwise used. But it seems Gcc's stage comparison relies on this. > > I did try running "strip --strip-debug" on stage{2,3}-gcc/expmed.o (a > > reasonable operation on object files) and that produced identical > > output. > > > > It may well be that a further change to ELF Tool Chain's strip is > > warranted, but I suspect the most straightforward and reliable fix > > here will be to just have gcc use GNU strip. > > The attached patch for the gcc ports fixes the failures for me. > > Antoine > Index: lang/gcc48/Makefile > === > --- lang/gcc48/Makefile (revision 482165) > +++ lang/gcc48/Makefile (working copy) > @@ -33,6 +33,7 @@ > SUFFIX= ${PORTVERSION:C/([0-9]+).([0-9]+).*/\1\2/} > USES=compiler cpe gmake iconv libtool makeinfo perl5 > tar:bzip2 > USE_BINUTILS=yes > +BINARY_ALIAS=strip=${LOCALBASE}/bin/strip Shouldn't USE_BINUTILS automatically prefer all binaries from there to be used, instead of the base system variants ? ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"