Date: Sat, 22 Feb 2020 09:58:11 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r358239 - in projects/clang1000-import: . bin/sh lib/libc/sys lib/libfetch sys/cam/scsi sys/compat/linuxkpi/common/include/linux sys/compat/linuxkpi/common/src sys/conf sys/dev/acpica s... Message-ID: <202002220958.01M9wBuX036063@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sat Feb 22 09:58:11 2020 New Revision: 358239 URL: https://svnweb.freebsd.org/changeset/base/358239 Log: Merge r358179 through r358238. PR: 244251 Added: projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/shmem_fs.h - copied unchanged from r358238, head/sys/compat/linuxkpi/common/include/linux/shmem_fs.h projects/clang1000-import/sys/compat/linuxkpi/common/src/linux_shmemfs.c - copied unchanged from r358238, head/sys/compat/linuxkpi/common/src/linux_shmemfs.c Modified: projects/clang1000-import/UPDATING projects/clang1000-import/bin/sh/miscbltin.c projects/clang1000-import/lib/libc/sys/truncate.2 projects/clang1000-import/lib/libfetch/common.c projects/clang1000-import/sys/cam/scsi/scsi_da.c projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/fs.h projects/clang1000-import/sys/compat/linuxkpi/common/src/linux_page.c projects/clang1000-import/sys/conf/files projects/clang1000-import/sys/dev/acpica/acpi_lid.c projects/clang1000-import/sys/dev/ath/ah_osdep.c projects/clang1000-import/sys/dev/ath/ath_rate/sample/sample.c projects/clang1000-import/sys/dev/ath/if_ath_sysctl.c projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib.h projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib_cong.c projects/clang1000-import/sys/dev/otus/if_otus.c projects/clang1000-import/sys/kern/subr_compressor.c projects/clang1000-import/sys/kern/subr_smr.c projects/clang1000-import/sys/kern/subr_trap.c projects/clang1000-import/sys/kern/vfs_lookup.c projects/clang1000-import/sys/modules/linuxkpi/Makefile projects/clang1000-import/sys/net80211/ieee80211_alq.c projects/clang1000-import/sys/net80211/ieee80211_amrr.c projects/clang1000-import/sys/net80211/ieee80211_freebsd.c projects/clang1000-import/sys/net80211/ieee80211_ht.c projects/clang1000-import/sys/net80211/ieee80211_hwmp.c projects/clang1000-import/sys/net80211/ieee80211_mesh.c projects/clang1000-import/sys/net80211/ieee80211_rssadapt.c projects/clang1000-import/sys/net80211/ieee80211_superg.c projects/clang1000-import/sys/netgraph/ng_socket.c projects/clang1000-import/sys/netinet/ip_carp.c projects/clang1000-import/sys/netpfil/pf/if_pfsync.c projects/clang1000-import/sys/netpfil/pf/pf.c projects/clang1000-import/sys/powerpc/booke/pmap.c projects/clang1000-import/sys/security/audit/audit.h projects/clang1000-import/sys/security/audit/audit_arg.c projects/clang1000-import/sys/security/audit/audit_bsm_klib.c projects/clang1000-import/sys/security/audit/audit_private.h projects/clang1000-import/sys/sys/_smr.h projects/clang1000-import/sys/sys/param.h projects/clang1000-import/sys/sys/smr.h projects/clang1000-import/sys/vm/uma_core.c projects/clang1000-import/sys/x86/x86/identcpu.c projects/clang1000-import/tools/bsdbox/Makefile.base projects/clang1000-import/usr.bin/dtc/dtc.cc projects/clang1000-import/usr.sbin/bhyve/iov.c projects/clang1000-import/usr.sbin/bhyve/iov.h projects/clang1000-import/usr.sbin/bhyve/net_backends.c projects/clang1000-import/usr.sbin/bhyve/net_backends.h projects/clang1000-import/usr.sbin/bhyve/pci_virtio_net.c projects/clang1000-import/usr.sbin/iostat/iostat.c projects/clang1000-import/usr.sbin/pstat/pstat.c Directory Properties: projects/clang1000-import/ (props changed) Modified: projects/clang1000-import/UPDATING ============================================================================== --- projects/clang1000-import/UPDATING Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/UPDATING Sat Feb 22 09:58:11 2020 (r358239) @@ -33,7 +33,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: using clang 3.5.0 or higher. 20200220: - ncurses has been updated to a newer version (6.1-20200118). Given the ABI + ncurses has been updated to a newer version (6.2-20200215). Given the ABI has changed, users will have to rebuild all the ports that are linked to ncurses. Modified: projects/clang1000-import/bin/sh/miscbltin.c ============================================================================== --- projects/clang1000-import/bin/sh/miscbltin.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/bin/sh/miscbltin.c Sat Feb 22 09:58:11 2020 (r358239) @@ -117,7 +117,7 @@ fdgetc(struct fdctx *fdc, char *c) static void fdctx_destroy(struct fdctx *fdc) { - size_t residue; + off_t residue; if (fdc->buflen > 1) { /* Modified: projects/clang1000-import/lib/libc/sys/truncate.2 ============================================================================== --- projects/clang1000-import/lib/libc/sys/truncate.2 Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/lib/libc/sys/truncate.2 Sat Feb 22 09:58:11 2020 (r358239) @@ -28,7 +28,7 @@ .\" @(#)truncate.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd May 4, 2015 +.Dd January 24, 2020 .Dt TRUNCATE 2 .Os .Sh NAME @@ -160,6 +160,9 @@ system calls appeared in These calls should be generalized to allow ranges of bytes in a file to be discarded. .Pp -Use of +Historically, the use of .Fn truncate -to extend a file is not portable. +or +.Fn ftruncate +to extend a file was not portable, but this behavior became required in +.St -p1003.1-2008 . Modified: projects/clang1000-import/lib/libfetch/common.c ============================================================================== --- projects/clang1000-import/lib/libfetch/common.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/lib/libfetch/common.c Sat Feb 22 09:58:11 2020 (r358239) @@ -677,6 +677,7 @@ fetch_connect(const char *host, int port, int af, int if (sockshost) if (!fetch_socks5_init(conn, host, port, verbose)) goto fail; + free(sockshost); if (cais != NULL) freeaddrinfo(cais); if (sais != NULL) @@ -686,7 +687,10 @@ syserr: fetch_syserr(); fail: free(sockshost); - if (sd >= 0) + /* Fully close if it was opened; otherwise just don't leak the fd. */ + if (conn != NULL) + fetch_close(conn); + else if (sd >= 0) close(sd); if (cais != NULL) freeaddrinfo(cais); Modified: projects/clang1000-import/sys/cam/scsi/scsi_da.c ============================================================================== --- projects/clang1000-import/sys/cam/scsi/scsi_da.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/cam/scsi/scsi_da.c Sat Feb 22 09:58:11 2020 (r358239) @@ -342,7 +342,7 @@ struct da_softc { LIST_HEAD(, ccb_hdr) pending_ccbs; int refcount; /* Active xpt_action() calls */ da_state state; - da_flags flags; + u_int flags; da_quirks quirks; int minimum_cmd_size; int error_inject; @@ -2335,11 +2335,11 @@ dasysctlinit(void *context, int pending) "Flags for drive"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "rotating", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, - &softc->flags, DA_FLAG_ROTATING, dabitsysctl, "I", + &softc->flags, (u_int)DA_FLAG_ROTATING, dabitsysctl, "I", "Rotating media *DEPRECATED* gone in FreeBSD 14"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "unmapped_io", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, - &softc->flags, DA_FLAG_UNMAPPEDIO, dabitsysctl, "I", + &softc->flags, (u_int)DA_FLAG_UNMAPPEDIO, dabitsysctl, "I", "Unmapped I/O support *DEPRECATED* gone in FreeBSD 14"); #ifdef CAM_TEST_FAILURE @@ -2619,11 +2619,11 @@ dadeletemethodchoose(struct da_softc *softc, da_delete static int dabitsysctl(SYSCTL_HANDLER_ARGS) { - int flags = (intptr_t)arg1; - int test = arg2; + u_int *flags = arg1; + u_int test = arg2; int tmpout, error; - tmpout = !!(flags & test); + tmpout = !!(*flags & test); error = SYSCTL_OUT(req, &tmpout, sizeof(tmpout)); if (error || !req->newptr) return (error); Modified: projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/fs.h ============================================================================== --- projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/fs.h Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/fs.h Sat Feb 22 09:58:11 2020 (r358239) @@ -302,25 +302,4 @@ call_mmap(struct linux_file *file, struct vm_area_stru return (file->f_op->mmap(file, vma)); } -/* Shared memory support */ -unsigned long linux_invalidate_mapping_pages(vm_object_t, pgoff_t, pgoff_t); -struct page *linux_shmem_read_mapping_page_gfp(vm_object_t, int, gfp_t); -struct linux_file *linux_shmem_file_setup(const char *, loff_t, unsigned long); -void linux_shmem_truncate_range(vm_object_t, loff_t, loff_t); - -#define invalidate_mapping_pages(...) \ - linux_invalidate_mapping_pages(__VA_ARGS__) - -#define shmem_read_mapping_page(...) \ - linux_shmem_read_mapping_page_gfp(__VA_ARGS__, 0) - -#define shmem_read_mapping_page_gfp(...) \ - linux_shmem_read_mapping_page_gfp(__VA_ARGS__) - -#define shmem_file_setup(...) \ - linux_shmem_file_setup(__VA_ARGS__) - -#define shmem_truncate_range(...) \ - linux_shmem_truncate_range(__VA_ARGS__) - #endif /* _LINUX_FS_H_ */ Copied: projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/shmem_fs.h (from r358238, head/sys/compat/linuxkpi/common/include/linux/shmem_fs.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/shmem_fs.h Sat Feb 22 09:58:11 2020 (r358239, copy of r358238, head/sys/compat/linuxkpi/common/include/linux/shmem_fs.h) @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2010 iX Systems, Inc. + * Copyright (c) 2010 Panasas, Inc. + * Copyright (c) 2013-2018 Mellanox Technologies, Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ +#ifndef _LINUX_SHMEM_FS_H_ +#define _LINUX_SHMEM_FS_H_ + +/* Shared memory support */ +unsigned long linux_invalidate_mapping_pages(vm_object_t, pgoff_t, pgoff_t); +struct page *linux_shmem_read_mapping_page_gfp(vm_object_t, int, gfp_t); +struct linux_file *linux_shmem_file_setup(const char *, loff_t, unsigned long); +void linux_shmem_truncate_range(vm_object_t, loff_t, loff_t); + +#define invalidate_mapping_pages(...) \ + linux_invalidate_mapping_pages(__VA_ARGS__) + +#define shmem_read_mapping_page(...) \ + linux_shmem_read_mapping_page_gfp(__VA_ARGS__, 0) + +#define shmem_read_mapping_page_gfp(...) \ + linux_shmem_read_mapping_page_gfp(__VA_ARGS__) + +#define shmem_file_setup(...) \ + linux_shmem_file_setup(__VA_ARGS__) + +#define shmem_truncate_range(...) \ + linux_shmem_truncate_range(__VA_ARGS__) + +#endif /* _LINUX_SHMEM_FS_H_ */ Modified: projects/clang1000-import/sys/compat/linuxkpi/common/src/linux_page.c ============================================================================== --- projects/clang1000-import/sys/compat/linuxkpi/common/src/linux_page.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/compat/linuxkpi/common/src/linux_page.c Sat Feb 22 09:58:11 2020 (r358239) @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include <linux/mm.h> #include <linux/preempt.h> #include <linux/fs.h> +#include <linux/shmem_fs.h> void si_meminfo(struct sysinfo *si) @@ -274,87 +275,4 @@ int is_vmalloc_addr(const void *addr) { return (vtoslab((vm_offset_t)addr & ~UMA_SLAB_MASK) != NULL); -} - -struct page * -linux_shmem_read_mapping_page_gfp(vm_object_t obj, int pindex, gfp_t gfp) -{ - vm_page_t page; - int rv; - - if ((gfp & GFP_NOWAIT) != 0) - panic("GFP_NOWAIT is unimplemented"); - - VM_OBJECT_WLOCK(obj); - rv = vm_page_grab_valid(&page, obj, pindex, VM_ALLOC_NORMAL | - VM_ALLOC_NOBUSY | VM_ALLOC_WIRED); - VM_OBJECT_WUNLOCK(obj); - if (rv != VM_PAGER_OK) - return (ERR_PTR(-EINVAL)); - return (page); -} - -struct linux_file * -linux_shmem_file_setup(const char *name, loff_t size, unsigned long flags) -{ - struct fileobj { - struct linux_file file __aligned(sizeof(void *)); - struct vnode vnode __aligned(sizeof(void *)); - }; - struct fileobj *fileobj; - struct linux_file *filp; - struct vnode *vp; - int error; - - fileobj = kzalloc(sizeof(*fileobj), GFP_KERNEL); - if (fileobj == NULL) { - error = -ENOMEM; - goto err_0; - } - filp = &fileobj->file; - vp = &fileobj->vnode; - - filp->f_count = 1; - filp->f_vnode = vp; - filp->f_shmem = vm_pager_allocate(OBJT_DEFAULT, NULL, size, - VM_PROT_READ | VM_PROT_WRITE, 0, curthread->td_ucred); - if (filp->f_shmem == NULL) { - error = -ENOMEM; - goto err_1; - } - return (filp); -err_1: - kfree(filp); -err_0: - return (ERR_PTR(error)); -} - -static vm_ooffset_t -linux_invalidate_mapping_pages_sub(vm_object_t obj, vm_pindex_t start, - vm_pindex_t end, int flags) -{ - int start_count, end_count; - - VM_OBJECT_WLOCK(obj); - start_count = obj->resident_page_count; - vm_object_page_remove(obj, start, end, flags); - end_count = obj->resident_page_count; - VM_OBJECT_WUNLOCK(obj); - return (start_count - end_count); -} - -unsigned long -linux_invalidate_mapping_pages(vm_object_t obj, pgoff_t start, pgoff_t end) -{ - - return (linux_invalidate_mapping_pages_sub(obj, start, end, OBJPR_CLEANONLY)); -} - -void -linux_shmem_truncate_range(vm_object_t obj, loff_t lstart, loff_t lend) -{ - vm_pindex_t start = OFF_TO_IDX(lstart + PAGE_SIZE - 1); - vm_pindex_t end = OFF_TO_IDX(lend + 1); - - (void) linux_invalidate_mapping_pages_sub(obj, start, end, 0); } Copied: projects/clang1000-import/sys/compat/linuxkpi/common/src/linux_shmemfs.c (from r358238, head/sys/compat/linuxkpi/common/src/linux_shmemfs.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/clang1000-import/sys/compat/linuxkpi/common/src/linux_shmemfs.c Sat Feb 22 09:58:11 2020 (r358239, copy of r358238, head/sys/compat/linuxkpi/common/src/linux_shmemfs.c) @@ -0,0 +1,128 @@ +/*- + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2016 Matthew Macy (mmacy@mattmacy.io) + * Copyright (c) 2017 Mellanox Technologies, Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, 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 ``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 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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/rwlock.h> + +#include <vm/vm.h> +#include <vm/pmap.h> +#include <vm/vm_object.h> +#include <vm/vm_map.h> +#include <vm/vm_page.h> +#include <vm/vm_pager.h> + +#include <linux/fs.h> +#include <linux/mm.h> +#include <linux/shmem_fs.h> + +struct page * +linux_shmem_read_mapping_page_gfp(vm_object_t obj, int pindex, gfp_t gfp) +{ + vm_page_t page; + int rv; + + if ((gfp & GFP_NOWAIT) != 0) + panic("GFP_NOWAIT is unimplemented"); + + VM_OBJECT_WLOCK(obj); + rv = vm_page_grab_valid(&page, obj, pindex, VM_ALLOC_NORMAL | + VM_ALLOC_NOBUSY | VM_ALLOC_WIRED); + VM_OBJECT_WUNLOCK(obj); + if (rv != VM_PAGER_OK) + return (ERR_PTR(-EINVAL)); + return (page); +} + +struct linux_file * +linux_shmem_file_setup(const char *name, loff_t size, unsigned long flags) +{ + struct fileobj { + struct linux_file file __aligned(sizeof(void *)); + struct vnode vnode __aligned(sizeof(void *)); + }; + struct fileobj *fileobj; + struct linux_file *filp; + struct vnode *vp; + int error; + + fileobj = kzalloc(sizeof(*fileobj), GFP_KERNEL); + if (fileobj == NULL) { + error = -ENOMEM; + goto err_0; + } + filp = &fileobj->file; + vp = &fileobj->vnode; + + filp->f_count = 1; + filp->f_vnode = vp; + filp->f_shmem = vm_pager_allocate(OBJT_DEFAULT, NULL, size, + VM_PROT_READ | VM_PROT_WRITE, 0, curthread->td_ucred); + if (filp->f_shmem == NULL) { + error = -ENOMEM; + goto err_1; + } + return (filp); +err_1: + kfree(filp); +err_0: + return (ERR_PTR(error)); +} + +static vm_ooffset_t +linux_invalidate_mapping_pages_sub(vm_object_t obj, vm_pindex_t start, + vm_pindex_t end, int flags) +{ + int start_count, end_count; + + VM_OBJECT_WLOCK(obj); + start_count = obj->resident_page_count; + vm_object_page_remove(obj, start, end, flags); + end_count = obj->resident_page_count; + VM_OBJECT_WUNLOCK(obj); + return (start_count - end_count); +} + +unsigned long +linux_invalidate_mapping_pages(vm_object_t obj, pgoff_t start, pgoff_t end) +{ + + return (linux_invalidate_mapping_pages_sub(obj, start, end, OBJPR_CLEANONLY)); +} + +void +linux_shmem_truncate_range(vm_object_t obj, loff_t lstart, loff_t lend) +{ + vm_pindex_t start = OFF_TO_IDX(lstart + PAGE_SIZE - 1); + vm_pindex_t end = OFF_TO_IDX(lend + 1); + + (void) linux_invalidate_mapping_pages_sub(obj, start, end, 0); +} Modified: projects/clang1000-import/sys/conf/files ============================================================================== --- projects/clang1000-import/sys/conf/files Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/conf/files Sat Feb 22 09:58:11 2020 (r358239) @@ -4476,6 +4476,8 @@ compat/linuxkpi/common/src/linux_rcu.c optional compa compile-with "${LINUXKPI_C} -I$S/contrib/ck/include" compat/linuxkpi/common/src/linux_schedule.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" +compat/linuxkpi/common/src/linux_shmemfs.c optional compat_linuxkpi \ + compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_slab.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_usb.c optional compat_linuxkpi usb \ Modified: projects/clang1000-import/sys/dev/acpica/acpi_lid.c ============================================================================== --- projects/clang1000-import/sys/dev/acpica/acpi_lid.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/dev/acpica/acpi_lid.c Sat Feb 22 09:58:11 2020 (r358239) @@ -124,13 +124,16 @@ acpi_lid_attach(device_t dev) if (acpi_parse_prw(sc->lid_handle, &prw) == 0) AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit); + /* Get the initial lid status, ignore failures */ + (void) acpi_GetInteger(sc->lid_handle, "_LID", &sc->lid_status); + /* * Export the lid status */ SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "state", CTLFLAG_RD, &sc->lid_status, 0, - "Device set to wake the system"); + "Device state (0 = closed, 1 = open)"); return (0); } @@ -144,6 +147,13 @@ acpi_lid_suspend(device_t dev) static int acpi_lid_resume(device_t dev) { + struct acpi_lid_softc *sc; + + sc = device_get_softc(dev); + + /* Get lid status after resume, ignore failures */ + (void) acpi_GetInteger(sc->lid_handle, "_LID", &sc->lid_status); + return (0); } Modified: projects/clang1000-import/sys/dev/ath/ah_osdep.c ============================================================================== --- projects/clang1000-import/sys/dev/ath/ah_osdep.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/dev/ath/ah_osdep.c Sat Feb 22 09:58:11 2020 (r358239) @@ -93,8 +93,9 @@ extern void DO_HALDEBUG(struct ath_hal *ah, u_int mask #endif /* AH_DEBUG */ /* NB: put this here instead of the driver to avoid circular references */ -SYSCTL_NODE(_hw, OID_AUTO, ath, CTLFLAG_RD, 0, "Atheros driver parameters"); -static SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, +SYSCTL_NODE(_hw, OID_AUTO, ath, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, + "Atheros driver parameters"); +static SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Atheros HAL parameters"); #ifdef AH_DEBUG @@ -236,8 +237,10 @@ sysctl_hw_ath_hal_log(SYSCTL_HANDLER_ARGS) else return (ath_hal_setlogging(enable)); } -SYSCTL_PROC(_hw_ath_hal, OID_AUTO, alq, CTLTYPE_INT|CTLFLAG_RW, - 0, 0, sysctl_hw_ath_hal_log, "I", "Enable HAL register logging"); +SYSCTL_PROC(_hw_ath_hal, OID_AUTO, alq, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, 0, sysctl_hw_ath_hal_log, "I", + "Enable HAL register logging"); SYSCTL_INT(_hw_ath_hal, OID_AUTO, alq_size, CTLFLAG_RW, &ath_hal_alq_qsize, 0, "In-memory log size (#records)"); SYSCTL_INT(_hw_ath_hal, OID_AUTO, alq_lost, CTLFLAG_RW, Modified: projects/clang1000-import/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- projects/clang1000-import/sys/dev/ath/ath_rate/sample/sample.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/dev/ath/ath_rate/sample/sample.c Sat Feb 22 09:58:11 2020 (r358239) @@ -1364,17 +1364,17 @@ ath_rate_sysctlattach(struct ath_softc *sc, struct sam struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "smoothing_rate", CTLTYPE_INT | CTLFLAG_RW, ssc, 0, - ath_rate_sysctl_smoothing_rate, "I", + "smoothing_rate", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + ssc, 0, ath_rate_sysctl_smoothing_rate, "I", "sample: smoothing rate for avg tx time (%%)"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "sample_rate", CTLTYPE_INT | CTLFLAG_RW, ssc, 0, - ath_rate_sysctl_sample_rate, "I", + "sample_rate", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + ssc, 0, ath_rate_sysctl_sample_rate, "I", "sample: percent air time devoted to sampling new rates (%%)"); /* XXX max_successive_failures, stale_failure_timeout, min_switch */ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "sample_stats", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_rate_sysctl_stats, "I", "sample: print statistics"); + "sample_stats", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + sc, 0, ath_rate_sysctl_stats, "I", "sample: print statistics"); } struct ath_ratectrl * Modified: projects/clang1000-import/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- projects/clang1000-import/sys/dev/ath/if_ath_sysctl.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/dev/ath/if_ath_sysctl.c Sat Feb 22 09:58:11 2020 (r358239) @@ -786,16 +786,17 @@ ath_sysctl_alq_attach(struct ath_softc *sc) struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree); - tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "alq", CTLFLAG_RD, - NULL, "Atheros ALQ logging parameters"); + tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "alq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, + "Atheros ALQ logging parameters"); child = SYSCTL_CHILDREN(tree); SYSCTL_ADD_STRING(ctx, child, OID_AUTO, "filename", CTLFLAG_RW, sc->sc_alq.sc_alq_filename, 0, "ALQ filename"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "enable", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_alq_log, "I", ""); + "enable", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_alq_log, "I", ""); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "debugmask", CTLFLAG_RW, &sc->sc_alq.sc_alq_debug, 0, @@ -831,21 +832,21 @@ ath_sysctlattach(struct ath_softc *sc) "control debugging KTR"); #endif /* ATH_DEBUG_ALQ */ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "slottime", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_slottime, "I", "802.11 slot time (us)"); + "slottime", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_slottime, "I", "802.11 slot time (us)"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "acktimeout", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_acktimeout, "I", "802.11 ACK timeout (us)"); + "acktimeout", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_acktimeout, "I", "802.11 ACK timeout (us)"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "ctstimeout", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)"); + "ctstimeout", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "softled", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_softled, "I", "enable/disable software LED support"); + "softled", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_softled, "I", "enable/disable software LED support"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "ledpin", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_ledpin, "I", "GPIO pin connected to LED"); + "ledpin", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_ledpin, "I", "GPIO pin connected to LED"); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "ledon", CTLFLAG_RW, &sc->sc_ledon, 0, "setting to turn LED on"); @@ -854,8 +855,8 @@ ath_sysctlattach(struct ath_softc *sc) "idle time for inactivity LED (ticks)"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "hardled", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_hardled, "I", "enable/disable hardware LED support"); + "hardled", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_hardled, "I", "enable/disable hardware LED support"); /* XXX Laziness - configure pins, then flip hardled off/on */ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "led_net_pin", CTLFLAG_RW, &sc->sc_led_net_pin, 0, @@ -865,61 +866,61 @@ ath_sysctlattach(struct ath_softc *sc) "MAC Power LED pin, or -1 to disable"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "txantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_txantenna, "I", "antenna switch"); + "txantenna", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_txantenna, "I", "antenna switch"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "rxantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_rxantenna, "I", "default/rx antenna"); + "rxantenna", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_rxantenna, "I", "default/rx antenna"); if (ath_hal_hasdiversity(ah)) SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "diversity", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_diversity, "I", "antenna diversity"); + "diversity", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + sc, 0, ath_sysctl_diversity, "I", "antenna diversity"); sc->sc_txintrperiod = ATH_TXINTR_PERIOD; SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "txintrperiod", CTLFLAG_RW, &sc->sc_txintrperiod, 0, "tx descriptor batching"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "diag", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_diag, "I", "h/w diagnostic control"); + "diag", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_diag, "I", "h/w diagnostic control"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "tpscale", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_tpscale, "I", "tx power scaling"); + "tpscale", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_tpscale, "I", "tx power scaling"); if (ath_hal_hastpc(ah)) { SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "tpc", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_tpc, "I", "enable/disable per-packet TPC"); + "tpc", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_tpc, "I", "enable/disable per-packet TPC"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "tpack", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_tpack, "I", "tx power for ack frames"); + "tpack", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, + 0, ath_sysctl_tpack, "I", "tx power for ack frames"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "tpcts", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_tpcts, "I", "tx power for cts frames"); + "tpcts", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, + 0, ath_sysctl_tpcts, "I", "tx power for cts frames"); } if (ath_hal_hasrfsilent(ah)) { SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "rfsilent", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_rfsilent, "I", "h/w RF silent config"); + "rfsilent", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + sc, 0, ath_sysctl_rfsilent, "I", "h/w RF silent config"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "rfkill", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_rfkill, "I", "enable/disable RF kill switch"); + "rfkill", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, + 0, ath_sysctl_rfkill, "I", "enable/disable RF kill switch"); } SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "txagg", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_txagg, "I", ""); + "txagg", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_txagg, "I", ""); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "forcebstuck", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_forcebstuck, "I", ""); + "forcebstuck", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, + 0, ath_sysctl_forcebstuck, "I", ""); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "hangcheck", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_hangcheck, "I", ""); + "hangcheck", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + ath_sysctl_hangcheck, "I", ""); if (ath_hal_hasintmit(ah)) { SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "intmit", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_intmit, "I", "interference mitigation"); + "intmit", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, + 0, ath_sysctl_intmit, "I", "interference mitigation"); } sc->sc_monpass = HAL_RXERR_DECRYPT | HAL_RXERR_MIC; SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, @@ -989,8 +990,8 @@ ath_sysctlattach(struct ath_softc *sc) "superframe", CTLFLAG_RD, &sc->sc_tdmabintval, 0, "TDMA calculated super frame"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "setcca", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_setcca, "I", "enable CCA control"); + "setcca", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + sc, 0, ath_sysctl_setcca, "I", "enable CCA control"); } #endif @@ -1028,7 +1029,8 @@ ath_sysctl_stats_attach_rxphyerr(struct ath_softc *sc, int i; char sn[8]; - tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx_phy_err", CTLFLAG_RD, NULL, "Per-code RX PHY Errors"); + tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx_phy_err", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Per-code RX PHY Errors"); child = SYSCTL_CHILDREN(tree); for (i = 0; i < 64; i++) { snprintf(sn, sizeof(sn), "%d", i); @@ -1047,7 +1049,7 @@ ath_sysctl_stats_attach_intr(struct ath_softc *sc, char sn[8]; tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "sync_intr", - CTLFLAG_RD, NULL, "Sync interrupt statistics"); + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Sync interrupt statistics"); child = SYSCTL_CHILDREN(tree); for (i = 0; i < 32; i++) { snprintf(sn, sizeof(sn), "%d", i); @@ -1065,12 +1067,12 @@ ath_sysctl_stats_attach(struct ath_softc *sc) /* Create "clear" node */ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "clear_stats", CTLTYPE_INT | CTLFLAG_RW, sc, 0, - ath_sysctl_clearstats, "I", "clear stats"); + "clear_stats", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, + 0, ath_sysctl_clearstats, "I", "clear stats"); /* Create stats node */ - tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD, - NULL, "Statistics"); + tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Statistics"); child = SYSCTL_CHILDREN(tree); /* This was generated from if_athioctl.h */ @@ -1315,8 +1317,8 @@ ath_sysctl_hal_attach(struct ath_softc *sc) struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree); - tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "hal", CTLFLAG_RD, - NULL, "Atheros HAL parameters"); + tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "hal", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Atheros HAL parameters"); child = SYSCTL_CHILDREN(tree); sc->sc_ah->ah_config.ah_debug = 0; Modified: projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib.h ============================================================================== --- projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib.h Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib.h Sat Feb 22 09:58:11 2020 (r358239) @@ -650,9 +650,13 @@ struct mlx5_ib_congestion { struct sysctl_ctx_list ctx; struct sx lock; struct delayed_work dwork; - u64 arg [0]; - MLX5_IB_CONG_PARAMS(MLX5_IB_STATS_VAR) - MLX5_IB_CONG_STATS(MLX5_IB_STATS_VAR) + union { + u64 arg[1]; + struct { + MLX5_IB_CONG_PARAMS(MLX5_IB_STATS_VAR) + MLX5_IB_CONG_STATS(MLX5_IB_STATS_VAR) + }; + }; }; struct mlx5_ib_dev { Modified: projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib_cong.c ============================================================================== --- projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib_cong.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/dev/mlx5/mlx5_ib/mlx5_ib_cong.c Sat Feb 22 09:58:11 2020 (r358239) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved. + * Copyright (c) 2013-2020, Mellanox Technologies, Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -37,7 +37,9 @@ static const char *mlx5_ib_cong_stats_desc[] = { MLX5_IB_CONG_STATS(MLX5_IB_STATS_DESC) }; -#define MLX5_IB_INDEX(field) (__offsetof(struct mlx5_ib_congestion, field) / sizeof(u64)) +#define MLX5_IB_INDEX(field) ( \ + (__offsetof(struct mlx5_ib_congestion, field) - \ + __offsetof(struct mlx5_ib_congestion, arg[0])) / sizeof(u64)) #define MLX5_IB_FLD_MAX(type, field) ((1ULL << __mlx5_bit_sz(type, field)) - 1ULL) #define MLX5_IB_SET_CLIPPED(type, ptr, field, var) do { \ /* rangecheck */ \ Modified: projects/clang1000-import/sys/dev/otus/if_otus.c ============================================================================== --- projects/clang1000-import/sys/dev/otus/if_otus.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/dev/otus/if_otus.c Sat Feb 22 09:58:11 2020 (r358239) @@ -75,7 +75,8 @@ __FBSDID("$FreeBSD$"); #include "if_otusreg.h" static int otus_debug = 0; -static SYSCTL_NODE(_hw_usb, OID_AUTO, otus, CTLFLAG_RW, 0, "USB otus"); +static SYSCTL_NODE(_hw_usb, OID_AUTO, otus, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "USB otus"); SYSCTL_INT(_hw_usb_otus, OID_AUTO, debug, CTLFLAG_RWTUN, &otus_debug, 0, "Debug level"); #define OTUS_DEBUG_XMIT 0x00000001 Modified: projects/clang1000-import/sys/kern/subr_compressor.c ============================================================================== --- projects/clang1000-import/sys/kern/subr_compressor.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/kern/subr_compressor.c Sat Feb 22 09:58:11 2020 (r358239) @@ -117,6 +117,13 @@ gz_init(size_t maxiosize, int level) s->gz_stream.next_in = Z_NULL; s->gz_stream.avail_in = 0; + if (level != Z_DEFAULT_COMPRESSION) { + if (level < Z_BEST_SPEED) + level = Z_BEST_SPEED; + else if (level > Z_BEST_COMPRESSION) + level = Z_BEST_COMPRESSION; + } + error = deflateInit2(&s->gz_stream, level, Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); if (error != 0) Modified: projects/clang1000-import/sys/kern/subr_smr.c ============================================================================== --- projects/clang1000-import/sys/kern/subr_smr.c Sat Feb 22 04:49:32 2020 (r358238) +++ projects/clang1000-import/sys/kern/subr_smr.c Sat Feb 22 09:58:11 2020 (r358239) @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); #include <vm/uma.h> /* + * Global Unbounded Sequences (GUS) + * * This is a novel safe memory reclamation technique inspired by * epoch based reclamation from Samy Al Bahra's concurrency kit which * in turn was based on work described in: @@ -53,7 +55,8 @@ __FBSDID("$FreeBSD$"); * This is not an implementation of hazard pointers or related * techniques. The term safe memory reclamation is used as a * generic descriptor for algorithms that defer frees to avoid - * use-after-free errors with lockless datastructures. + * use-after-free errors with lockless datastructures or as + * a mechanism to detect quiescence for writer synchronization. * * The basic approach is to maintain a monotonic write sequence * number that is updated on some application defined granularity. @@ -67,7 +70,7 @@ __FBSDID("$FreeBSD$"); * a global write clock that is used to mark memory on free. * * The write and read sequence numbers can be thought of as a two - * handed clock with readers always advancing towards writers. SMR + * handed clock with readers always advancing towards writers. GUS * maintains the invariant that all readers can safely access memory * that was visible at the time they loaded their copy of the sequence * number. Periodically the read sequence or hand is polled and @@ -80,9 +83,12 @@ __FBSDID("$FreeBSD$"); * A stored sequence number that falls outside of this range has expired * and needs no scan to reclaim. * - * A notable distinction between this SMR and Epoch, qsbr, rcu, etc. is + * A notable distinction between GUS and Epoch, qsbr, rcu, etc. is * that advancing the sequence number is decoupled from detecting its - * observation. This results in a more granular assignment of sequence + * observation. That is to say, the delta between read and write + * sequence numbers is not bound. This can be thought of as a more + * generalized form of epoch which requires them at most one step + * apart. This results in a more granular assignment of sequence * numbers even as read latencies prohibit all or some expiration. * It also allows writers to advance the sequence number and save the * poll for expiration until a later time when it is likely to @@ -164,60 +170,145 @@ static uma_zone_t smr_zone; #define SMR_SEQ_MAX_ADVANCE SMR_SEQ_MAX_DELTA / 2 #endif +/* + * The grace period for lazy (tick based) SMR. + * + * Hardclock is responsible for advancing ticks on a single CPU while every + * CPU receives a regular clock interrupt. The clock interrupts are flushing + * the store buffers and any speculative loads that may violate our invariants. + * Because these interrupts are not synchronized we must wait one additional + * tick in the future to be certain that all processors have had their state + * synchronized by an interrupt. + * + * This assumes that the clock interrupt will only be delayed by other causes + * that will flush the store buffer or prevent access to the section protected + * data. For example, an idle processor, or an system management interrupt, + * or a vm exit. + * + * We must wait one additional tick if we are around the wrap condition + * because the write seq will move forward by two with one interrupt. + */ +#define SMR_LAZY_GRACE 2 +#define SMR_LAZY_GRACE_MAX (SMR_LAZY_GRACE + 1) + +/* + * The maximum sequence number ahead of wr_seq that may still be valid. The + * sequence may not be advanced on write for lazy or deferred SMRs. In this + * case poll needs to attempt to forward the sequence number if the goal is + * within wr_seq + SMR_SEQ_ADVANCE. + */ +#define SMR_SEQ_ADVANCE MAX(SMR_SEQ_INCR, SMR_LAZY_GRACE_MAX) + static SYSCTL_NODE(_debug, OID_AUTO, smr, CTLFLAG_RW, NULL, "SMR Stats"); static counter_u64_t advance = EARLY_COUNTER; -SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance, CTLFLAG_RD, &advance, ""); +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance, CTLFLAG_RW, &advance, ""); static counter_u64_t advance_wait = EARLY_COUNTER; -SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance_wait, CTLFLAG_RD, &advance_wait, ""); +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance_wait, CTLFLAG_RW, &advance_wait, ""); static counter_u64_t poll = EARLY_COUNTER; -SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll, CTLFLAG_RD, &poll, ""); +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll, CTLFLAG_RW, &poll, ""); static counter_u64_t poll_scan = EARLY_COUNTER; -SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll_scan, CTLFLAG_RD, &poll_scan, ""); +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll_scan, CTLFLAG_RW, &poll_scan, ""); +static counter_u64_t poll_fail = EARLY_COUNTER; +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll_fail, CTLFLAG_RW, &poll_fail, ""); - /* - * Advance the write sequence and return the new value for use as the - * wait goal. This guarantees that any changes made by the calling - * thread prior to this call will be visible to all threads after - * rd_seq meets or exceeds the return value. + * Advance a lazy write sequence number. These move forward at the rate of + * ticks. Grace is two ticks in the future. lazy write sequence numbers can + * be even but not SMR_SEQ_INVALID so we pause time for a tick when we wrap. * - * This function may busy loop if the readers are roughly 1 billion - * sequence numbers behind the writers. + * This returns the _current_ write sequence number. The lazy goal sequence + * number is SMR_LAZY_GRACE ticks ahead. */ -smr_seq_t -smr_advance(smr_t smr) +static smr_seq_t +smr_lazy_advance(smr_t smr, smr_shared_t s) { - smr_shared_t s; - smr_seq_t goal, s_rd_seq; + smr_seq_t s_rd_seq, s_wr_seq, goal; + int t; + CRITICAL_ASSERT(curthread); + /* - * It is illegal to enter while in an smr section. + * Load s_wr_seq prior to ticks to ensure that the thread that + * observes the largest value wins. */ - SMR_ASSERT_NOT_ENTERED(smr); + s_wr_seq = atomic_load_acq_int(&s->s_wr_seq); /* - * Modifications not done in a smr section need to be visible - * before advancing the seq. + * We must not allow a zero tick value. We go back in time one tick + * and advance the grace period forward one tick around zero. */ - atomic_thread_fence_rel(); + t = ticks; + if (t == SMR_SEQ_INVALID) + t--; /* - * Load the current read seq before incrementing the goal so - * we are guaranteed it is always < goal. + * The most probable condition that the update already took place. */ - s = zpcpu_get(smr)->c_shared; - s_rd_seq = atomic_load_acq_int(&s->s_rd_seq); + if (__predict_true(t == s_wr_seq)) + goto out; /* - * Increment the shared write sequence by 2. Since it is - * initialized to 1 this means the only valid values are - * odd and an observed value of 0 in a particular CPU means - * it is not currently in a read section. + * After long idle periods the read sequence may fall too far + * behind write. Prevent poll from ever seeing this condition + * by updating the stale rd_seq. This assumes that there can + * be no valid section 2bn ticks old. The rd_seq update must + * be visible before wr_seq to avoid races with other advance + * callers. */ - goal = atomic_fetchadd_int(&s->s_wr_seq, SMR_SEQ_INCR) + SMR_SEQ_INCR; + s_rd_seq = atomic_load_int(&s->s_rd_seq); + if (SMR_SEQ_GT(s_rd_seq, t)) + atomic_cmpset_rel_int(&s->s_rd_seq, s_rd_seq, t); + + /* + * Release to synchronize with the wr_seq load above. Ignore + * cmpset failures from simultaneous updates. + */ + atomic_cmpset_rel_int(&s->s_wr_seq, s_wr_seq, t); counter_u64_add(advance, 1); + /* If we lost either update race another thread did it. */ + s_wr_seq = t; +out: + goal = s_wr_seq + SMR_LAZY_GRACE; + /* Skip over the SMR_SEQ_INVALID tick. */ + if (goal < SMR_LAZY_GRACE) + goal++; + return (goal); +} +/* + * Increment the shared write sequence by 2. Since it is initialized + * to 1 this means the only valid values are odd and an observed value + * of 0 in a particular CPU means it is not currently in a read section. + */ +static smr_seq_t +smr_shared_advance(smr_shared_t s) +{ + + return (atomic_fetchadd_int(&s->s_wr_seq, SMR_SEQ_INCR) + SMR_SEQ_INCR); +} + +/* + * Advance the write sequence number for a normal smr section. If the + * write sequence is too far behind the read sequence we have to poll *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002220958.01M9wBuX036063>