Re: svn commit: r368769 - head/sys/net
On Tue, Dec 22, 2020 at 10:31 AM Mateusz Guzik wrote: > > this makes NOIP kernels fail to compile: > > /usr/src/sys/net/rtsock.c:802:11: error: unused variable 'scopeid' > [-Werror,-Wunused-variable] > uint32_t scopeid = 0; > > Fix in progress: https://reviews.freebsd.org/D27730 > On 12/18/20, Alexander V. Chernikov wrote: > > Author: melifaro > > Date: Fri Dec 18 22:00:57 2020 > > New Revision: 368769 > > URL: https://svnweb.freebsd.org/changeset/base/368769 > > > > Log: > > Switch direct rt fields access in rtsock.c to newly-create field > > acessors. > > > > rtsock code was build around the assumption that each rtentry record > >in the system radix tree is a ready-to-use sockaddr. This assumptions > >turned out to be not quite true: > > * masks have their length tweaked, so we have rtsock_fix_netmask() hack > > * IPv6 addresses have their scope embedded, so we have another explicit > >deembedding hack. > > > > Change the code to decouple rtentry internals from rtsock code using > >newly-created rtentry accessors. This will allow to eventually eliminate > >both of the hacks and change rtentry dst/mask format. > > > > Differential Revision: https://reviews.freebsd.org/D27451 > > > > Modified: > > head/sys/net/rtsock.c > > > > Modified: head/sys/net/rtsock.c > > == > > --- head/sys/net/rtsock.c Fri Dec 18 20:41:23 2020(r368768) > > +++ head/sys/net/rtsock.c Fri Dec 18 22:00:57 2020(r368769) > > @@ -158,10 +158,13 @@ MTX_SYSINIT(rtsock, _mtx, "rtsock route_cb > > lock > > SYSCTL_NODE(_net, OID_AUTO, route, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); > > > > struct walkarg { > > + int family; > > int w_tmemsize; > > int w_op, w_arg; > > caddr_t w_tmem; > > struct sysctl_req *w_req; > > + struct sockaddr *dst; > > + struct sockaddr *mask; > > }; > > > > static void rts_input(struct mbuf *m); > > @@ -170,7 +173,7 @@ static intrtsock_msg_buffer(int type, struct > > rt_addri > > struct walkarg *w, int *plen); > > static int rt_xaddrs(caddr_t cp, caddr_t cplim, > > struct rt_addrinfo *rtinfo); > > -static int sysctl_dumpentry(struct radix_node *rn, void *vw); > > +static int sysctl_dumpentry(struct rtentry *rt, void *vw); > > static int sysctl_dumpnhop(struct rtentry *rt, struct nhop_object *nh, > > uint32_t weight, struct walkarg *w); > > static int sysctl_iflist(int af, struct walkarg *w); > > @@ -187,7 +190,8 @@ static intupdate_rtm_from_rc(struct rt_addrinfo > > *info > > static void send_rtm_reply(struct socket *so, struct rt_msghdr *rtm, > > struct mbuf *m, sa_family_t saf, u_int fibnum, > > int rtm_errno); > > -static int can_export_rte(struct ucred *td_ucred, const struct rtentry > > *rt); > > +static bool can_export_rte(struct ucred *td_ucred, bool rt_is_host, > > + const struct sockaddr *rt_dst); > > > > static struct netisr_handler rtsock_nh = { > > .nh_name = "rtsock", > > @@ -707,7 +711,7 @@ handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, > > return (ESRCH); > > } > > > > - nh = select_nhop(rc->rc_rt->rt_nhop, info->rti_info[RTAX_GATEWAY]); > > + nh = select_nhop(rt_get_raw_nhop(rc->rc_rt), > > info->rti_info[RTAX_GATEWAY]); > > if (nh == NULL) { > > RIB_RUNLOCK(rnh); > > return (ESRCH); > > @@ -721,9 +725,7 @@ handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, > >*/ > > if (rtm->rtm_flags & RTF_ANNOUNCE) { > > struct sockaddr laddr; > > - struct nhop_object *nh; > > > > - nh = rc->rc_rt->rt_nhop; > > if (nh->nh_ifp != NULL && > > nh->nh_ifp->if_type == IFT_PROPVIRTUAL) { > > struct ifaddr *ifa; > > @@ -747,7 +749,7 @@ handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, > > RIB_RUNLOCK(rnh); > > return (ESRCH); > > } > > - nh = select_nhop(rc->rc_rt->rt_nhop, > > info->rti_info[RTAX_GATEWAY]); > > + nh = select_nhop(rt_get_raw_nhop(rc->rc_rt), > > info->rti_info[RTAX_GATEWAY]); > > if (nh == NULL) { > > RIB_RUNLOCK(rnh); > > return (ESRCH); > > @@ -760,6 +762,66 @@ handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, > > return (0); > > } > > > > +static void > > +init_sockaddrs_family(int family, struct sockaddr *dst, struct sockaddr > > *mask) > > +{ > > +#ifdef INET > > + if (family == AF_INET) { > > + struct sockaddr_in *dst4 = (struct sockaddr_in *)dst; > > + struct sockaddr_in *mask4 = (struct sockaddr_in *)mask; > > + > > + bzero(dst4, sizeof(struct sockaddr_in));
Re: svn commit: r368789 - head/libexec/rtld-elf/rtld-libc
On Sat, Dec 19, 2020 at 7:23 PM John Baldwin wrote: > > On 12/19/20 12:38 AM, Ryan Libby wrote: > > Author: rlibby > > Date: Sat Dec 19 08:38:31 2020 > > New Revision: 368789 > > URL: https://svnweb.freebsd.org/changeset/base/368789 > > > > Log: > > rtld-elf: link udivmoddi4 from compiler_rt > > > > This fixes the gcc9 build of rtld-elf32 on amd64, which needed an > > implementation of udivmoddi4. > > > > rtld-elf uses certain functions normally found in libc, and so it > > includes certain files from libc in its own build. It has two > > mechanisms to include files from libc: one that rebuilds source files in > > the rtld-elf environment, and one that extracts object files from a > > purpose-built no-SSP PIC archive. > > > > In addition to libc functions, rtld-elf may need to link functions > > normally found in libcompiler_rt (formerly libgcc). Now, add an ability > > to rebuild libcompiler_rt source files in the rtld-elf environment. We > > don't yet have a need for an object file extraction mechanism. > > > > libcompiler_rt could also supply udivdi3 and umoddi3, but leave them > > alone for now. > > > > Reviewed by:arichardson, kib > > Sponsored by: Dell EMC Isilon > > Differential Revision: https://reviews.freebsd.org/D27665 > > Hmm, I had just linked against libcompiler_rt directly as we do on arm: > > https://reviews.freebsd.org/D26199 > > It was stuck waiting for review feedback. > > Given libcompiler_rt is a static archive, we could probably safely link > against it directly unlike libc where we have to pick specific object > files. > > -- > John Baldwin Sorry, I wasn't aware of your review. Do you want this backed out? I did see the arm path. I think it is not quite right, because libcompiler_rt is compiled with -fstack-protector-strong, which is not compatible with rtld. However, it will work in practice if stack protection doesn't actually get used on any linked function. We could build a special libcompiler_rt with no stack protection like we do just for rtld with libc, but since we'd only want this no-SSP library for rtld, that's not much different from just rebuilding its source files in rtld. In addition, by rebuilding specific files we avoid overlinking--although that may not be a big deal (?), and there may be other cleaner ways to avoid that (?). On a tangent, it might be neat to split out an rtld_bootstrap (everything through init_rtld()) so that only the bootstrap code needs to be compiled and linked with no-SSP. I looked at this some but I figured there might not be appetite for a bunch of reorganization of rtld just to enable SSP. Anyway the bootstrap code would still need these particular libcompiler_rt functions to be no-SSP, as they get used in the printf procedure, which I am guessing the bootstrap may need. Ryan ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368789 - head/libexec/rtld-elf/rtld-libc
Author: rlibby Date: Sat Dec 19 08:38:31 2020 New Revision: 368789 URL: https://svnweb.freebsd.org/changeset/base/368789 Log: rtld-elf: link udivmoddi4 from compiler_rt This fixes the gcc9 build of rtld-elf32 on amd64, which needed an implementation of udivmoddi4. rtld-elf uses certain functions normally found in libc, and so it includes certain files from libc in its own build. It has two mechanisms to include files from libc: one that rebuilds source files in the rtld-elf environment, and one that extracts object files from a purpose-built no-SSP PIC archive. In addition to libc functions, rtld-elf may need to link functions normally found in libcompiler_rt (formerly libgcc). Now, add an ability to rebuild libcompiler_rt source files in the rtld-elf environment. We don't yet have a need for an object file extraction mechanism. libcompiler_rt could also supply udivdi3 and umoddi3, but leave them alone for now. Reviewed by: arichardson, kib Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27665 Modified: head/libexec/rtld-elf/rtld-libc/Makefile.inc Modified: head/libexec/rtld-elf/rtld-libc/Makefile.inc == --- head/libexec/rtld-elf/rtld-libc/Makefile.incSat Dec 19 08:38:27 2020(r368788) +++ head/libexec/rtld-elf/rtld-libc/Makefile.incSat Dec 19 08:38:31 2020(r368789) @@ -51,8 +51,12 @@ _libc_other_objects= sigsetjmp lstat stat fstat fstata getdirentries _getdirentries _close _fcntl _open _openat _read \ _sigprocmask _write readlink __realpathat _setjmp setjmp setjmperr +# Allow building files from libcompiler_rt. Beware, there are some name +# collisions between libcompiler_rt files and libc files. +CRTSRC=${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins +.PATH: ${CRTSRC} -# Finally add additional architecture-dependent libc dependencies +# Finally add additional architecture-dependent dependencies .if ${LIBC_ARCH} == "arm" # ARM needs aeabi_unwind_cpp for _setjmp _libc_other_objects+=aeabi_unwind_cpp @@ -60,6 +64,7 @@ _libc_other_objects+=aeabi_unwind_cpp # __udivdi3 is needed by kvprintf() in rtld_printf.c # i386 also needs i386_set_gsbase for allocate_initial_tls() _libc_other_objects+=umoddi3 udivdi3 qdivrem i386_set_gsbase +SRCS+= udivmoddi4.c .elif ${LIBC_ARCH} == "powerpc" || ${LIBC_ARCH} == "powerpcspe" # ppc needs __syncicache for reloc.c and __umoddi3+__udivdi3 for rtld_printf.c _libc_other_objects+=syncicache umoddi3 udivdi3 qdivrem ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368788 - head/libexec/rtld-elf/rtld-libc
Author: rlibby Date: Sat Dec 19 08:38:27 2020 New Revision: 368788 URL: https://svnweb.freebsd.org/changeset/base/368788 Log: rtld-libc: fix incremental build ar cr is an update of an archive, not a creation of a new one. During incremental builds (e.g. with meta mode) the archive was not getting cleaned, and so could retain now-deleted objects from previous builds. Now, delete the archive before creating/updating it. Reviewed by: arichardson, bdrewery, kib Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27663 Modified: head/libexec/rtld-elf/rtld-libc/Makefile.inc Modified: head/libexec/rtld-elf/rtld-libc/Makefile.inc == --- head/libexec/rtld-elf/rtld-libc/Makefile.incSat Dec 19 08:16:33 2020(r368787) +++ head/libexec/rtld-elf/rtld-libc/Makefile.incSat Dec 19 08:38:27 2020(r368788) @@ -89,8 +89,9 @@ CLEANFILES+=${_obj}.nossppico # We insert all the .o files from libc_nossp_pic.a into a new rtld_libc.a file # to ensure that only .o files that are actually used end up being included. rtld_libc.a: ${LIBC_NOSSP_PIC} ${SRCTOP}/libexec/rtld-elf/rtld-libc/Makefile.inc + @rm -f ${.TARGET} ${AR} x ${LIBC_NOSSP_PIC} ${_rtld_libc_objs} - ${AR} cr ${.OBJDIR}/${.TARGET} ${_rtld_libc_objs} + ${AR} cr ${.TARGET} ${_rtld_libc_objs} CLEANFILES+=rtld_libc.a LDADD+=${.OBJDIR}/rtld_libc.a beforelinking: rtld_libc.a ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368787 - stable/12/tests/sys/sys
Author: rlibby Date: Sat Dec 19 08:16:33 2020 New Revision: 368787 URL: https://svnweb.freebsd.org/changeset/base/368787 Log: MFC r354991-r354992 (by lwhsu) r354991: Fix GCC build. Sponsored by: The FreeBSD Foundation r354992: Initialize variable bitstr r354991 removed variable-sized object initializing on defining. For the safe reason, manually initialize the members to 0. Sponsored by: The FreeBSD Foundation Modified: stable/12/tests/sys/sys/bitstring_test.c Directory Properties: stable/12/ (props changed) Modified: stable/12/tests/sys/sys/bitstring_test.c == --- stable/12/tests/sys/sys/bitstring_test.cSat Dec 19 04:28:25 2020 (r368786) +++ stable/12/tests/sys/sys/bitstring_test.cSat Dec 19 08:16:33 2020 (r368787) @@ -347,9 +347,11 @@ ATF_TC_WITHOUT_HEAD(bit_ffs_area); ATF_TC_BODY(bit_ffs_area, tc) { const int nbits = 72; - bitstr_t bit_decl(bitstr, nbits) = {}; + bitstr_t bit_decl(bitstr, nbits); int location; + memset(bitstr, 0, bitstr_size(nbits)); + bit_set(bitstr, 5); bit_set(bitstr, 6); @@ -416,7 +418,7 @@ ATF_TC_WITHOUT_HEAD(bit_ffc_area); ATF_TC_BODY(bit_ffc_area, tc) { const int nbits = 80; - bitstr_t bit_decl(bitstr, nbits) = {}; + bitstr_t bit_decl(bitstr, nbits); int location; /* set all bits */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368786 - stable/12/sys/dev/superio
Author: rlibby Date: Sat Dec 19 04:28:25 2020 New Revision: 368786 URL: https://svnweb.freebsd.org/changeset/base/368786 Log: MFC r349848 (by lwhsu): - Fix gcc build for superio(4) - Change string mapping of SUPERIO_DEV_NONE to distinguish from SUPERIO_DEV_MAX Reviewed by: imp Discussed with: avg, imp, jhb Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D20880 Modified: stable/12/sys/dev/superio/superio.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/superio/superio.c == --- stable/12/sys/dev/superio/superio.c Sat Dec 19 04:24:05 2020 (r368785) +++ stable/12/sys/dev/superio/superio.c Sat Dec 19 04:28:25 2020 (r368786) @@ -419,7 +419,7 @@ devtype_to_str(superio_dev_type_t type) { switch (type) { case SUPERIO_DEV_NONE: - return ("invalid"); + return ("none"); case SUPERIO_DEV_HWM: return ("HWM"); case SUPERIO_DEV_WDT: @@ -429,6 +429,7 @@ devtype_to_str(superio_dev_type_t type) case SUPERIO_DEV_MAX: return ("invalid"); } + return ("invalid"); } static int ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368785 - stable/12/sys/dev/ice
Author: rlibby Date: Sat Dec 19 04:24:05 2020 New Revision: 368785 URL: https://svnweb.freebsd.org/changeset/base/368785 Log: MFC r368745: ice: quiet -Wredundant-decls Reapply r364240 after driver update in r365617. Reviewed by: lwhsu Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27561 Modified: stable/12/sys/dev/ice/ice_common.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ice/ice_common.h == --- stable/12/sys/dev/ice/ice_common.h Sat Dec 19 04:22:26 2020 (r368784) +++ stable/12/sys/dev/ice/ice_common.h Sat Dec 19 04:24:05 2020 (r368785) @@ -46,15 +46,6 @@ enum ice_fw_modes { ICE_FW_MODE_ROLLBACK }; -/* prototype for functions used for SW locks */ -void ice_free_list(struct LIST_HEAD_TYPE *list); -void ice_init_lock(struct ice_lock *lock); -void ice_acquire_lock(struct ice_lock *lock); -void ice_release_lock(struct ice_lock *lock); -void ice_destroy_lock(struct ice_lock *lock); -void *ice_alloc_dma_mem(struct ice_hw *hw, struct ice_dma_mem *m, u64 size); -void ice_free_dma_mem(struct ice_hw *hw, struct ice_dma_mem *m); - void ice_idle_aq(struct ice_hw *hw, struct ice_ctl_q_info *cq); bool ice_sq_done(struct ice_hw *hw, struct ice_ctl_q_info *cq); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368784 - stable/12/sys/dev/qat
Author: rlibby Date: Sat Dec 19 04:22:26 2020 New Revision: 368784 URL: https://svnweb.freebsd.org/changeset/base/368784 Log: MFC r368564: qat: quiet -Wredundant-decls Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27554 Modified: stable/12/sys/dev/qat/qat_ae.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/qat/qat_ae.c == --- stable/12/sys/dev/qat/qat_ae.c Sat Dec 19 04:21:15 2020 (r368783) +++ stable/12/sys/dev/qat/qat_ae.c Sat Dec 19 04:22:26 2020 (r368784) @@ -82,8 +82,6 @@ static intqat_ae_write_4(struct qat_softc *, u_char, uint32_t); static int qat_ae_read_4(struct qat_softc *, u_char, bus_size_t, uint32_t *); -static int qat_ae_write_4(struct qat_softc *, u_char, bus_size_t, - uint32_t); static voidqat_ae_ctx_indr_write(struct qat_softc *, u_char, uint32_t, bus_size_t, uint32_t); static int qat_ae_ctx_indr_read(struct qat_softc *, u_char, uint32_t, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368783 - stable/12/sys/dev/ntb/ntb_hw
Author: rlibby Date: Sat Dec 19 04:21:15 2020 New Revision: 368783 URL: https://svnweb.freebsd.org/changeset/base/368783 Log: MFC r368563: ntb: quiet gcc -Wreturn-type Reviewed by: cem, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27553 Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c == --- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Sat Dec 19 04:18:49 2020 (r368782) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Sat Dec 19 04:21:15 2020 (r368783) @@ -1305,6 +1305,7 @@ db_ioread(struct ntb_softc *ntb, uint64_t regoff) case NTB_XEON_GEN1: return (intel_ntb_reg_read(2, regoff)); } + __assert_unreachable(); } static inline void ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368782 - in stable/12/sys: amd64/amd64 i386/i386
Author: rlibby Date: Sat Dec 19 04:18:49 2020 New Revision: 368782 URL: https://svnweb.freebsd.org/changeset/base/368782 Log: MFC r347628: x86: spell vpxor %zmm0 as vpxord Fix gcc/gas amd64 & i386 build after r347566. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20264 Modified: stable/12/sys/amd64/amd64/support.S stable/12/sys/i386/i386/support.s Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/support.S == --- stable/12/sys/amd64/amd64/support.S Sat Dec 19 04:09:21 2020 (r368781) +++ stable/12/sys/amd64/amd64/support.S Sat Dec 19 04:18:49 2020 (r368782) @@ -1905,7 +1905,7 @@ ENTRY(mds_handler_skl_avx512) 1: movqPCPU(MDS_BUF), %rdi movqPCPU(MDS_BUF64), %rdx vmovdqa64 %zmm0, PCPU(MDS_TMP) - vpxor %zmm0, %zmm0, %zmm0 + vpxord %zmm0, %zmm0, %zmm0 lfence vorpd (%rdx), %zmm0, %zmm0 Modified: stable/12/sys/i386/i386/support.s == --- stable/12/sys/i386/i386/support.s Sat Dec 19 04:09:21 2020 (r368781) +++ stable/12/sys/i386/i386/support.s Sat Dec 19 04:18:49 2020 (r368782) @@ -632,7 +632,7 @@ ENTRY(mds_handler_skl_avx512) 1: movlPCPU(MDS_BUF), %edi movlPCPU(MDS_BUF64), %edx vmovdqa64 %zmm0, PCPU(MDS_TMP) - vpxor %zmm0, %zmm0, %zmm0 + vpxord %zmm0, %zmm0, %zmm0 lfence vorpd (%edx), %zmm0, %zmm0 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368781 - stable/12/libexec/rtld-elf/i386
Author: rlibby Date: Sat Dec 19 04:09:21 2020 New Revision: 368781 URL: https://svnweb.freebsd.org/changeset/base/368781 Log: MFC r343672 (by vangyzen): rtld: pacify -Wmaybe-uninitialized from gcc6 Sponsored by: Dell EMC Isilon Modified: stable/12/libexec/rtld-elf/i386/reloc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rtld-elf/i386/reloc.c == --- stable/12/libexec/rtld-elf/i386/reloc.c Sat Dec 19 04:05:08 2020 (r368780) +++ stable/12/libexec/rtld-elf/i386/reloc.c Sat Dec 19 04:09:21 2020 (r368781) @@ -146,6 +146,10 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int } else cache = NULL; + /* Appease some compilers. */ + symval = 0; + def = NULL; + rellim = (const Elf_Rel *)((const char *)obj->rel + obj->relsize); for (rel = obj->rel; rel < rellim; rel++) { switch (ELF_R_TYPE(rel->r_info)) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368780 - stable/12/lib/msun
Author: rlibby Date: Sat Dec 19 04:05:08 2020 New Revision: 368780 URL: https://svnweb.freebsd.org/changeset/base/368780 Log: MFC r343671 (by vangyzen): libm: squelch -Woverflow from gcc6 Sponsored by: Dell EMC Isilon Modified: stable/12/lib/msun/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/msun/Makefile == --- stable/12/lib/msun/Makefile Sat Dec 19 03:30:06 2020(r368779) +++ stable/12/lib/msun/Makefile Sat Dec 19 04:05:08 2020(r368780) @@ -108,6 +108,15 @@ COMMON_SRCS+= catrigl.c \ s_nextafterl.c s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c \ s_scalbnl.c s_sinl.c s_sincosl.c \ s_tanhl.c s_tanl.c s_truncl.c w_cabsl.c +# Work around this warning from gcc 6: +# lib/msun/ld80/e_powl.c:275:1: error: floating constant exceeds range of +# 'long double' [-Werror=overflow] +# if( y >= LDBL_MAX ) +# See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=130067 +.include +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 6 +CFLAGS.e_powl.c+= -Wno-error=overflow +.endif .endif # C99 complex functions ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368753 - in stable/12: share/mk sys/conf
Author: rlibby Date: Fri Dec 18 08:40:33 2020 New Revision: 368753 URL: https://svnweb.freebsd.org/changeset/base/368753 Log: MFC r350739-r350740 (by cem) r350739: Disable useless -Wformat-zero-length It is part of -Wformat, which is enabled by -Wall. Empty format strings are well defined and it is perfectly reasonable to expect them in a formatting interface. r350740: r350739 try #2 For some inexplicable reason, C++ compilers reject the -Wno- flag, and also (ab)use CWARNFLAGS. Reported by: imp Modified: stable/12/share/mk/bsd.sys.mk stable/12/sys/conf/kern.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/share/mk/bsd.sys.mk == --- stable/12/share/mk/bsd.sys.mk Fri Dec 18 08:29:38 2020 (r368752) +++ stable/12/share/mk/bsd.sys.mk Fri Dec 18 08:40:33 2020 (r368753) @@ -201,6 +201,9 @@ FORMAT_EXTENSIONS= -fformat-extensions CWARNFLAGS+= -Wno-unknown-pragmas .endif # IGNORE_PRAGMA +# This warning is utter nonsense +CFLAGS+= -Wno-format-zero-length + # We need this conditional because many places that use it # only enable it for some files with CLFAGS.$FILE+=${CLANG_NO_IAS}. # unconditionally, and can't easily use the CFLAGS.clang= Modified: stable/12/sys/conf/kern.mk == --- stable/12/sys/conf/kern.mk Fri Dec 18 08:29:38 2020(r368752) +++ stable/12/sys/conf/kern.mk Fri Dec 18 08:40:33 2020(r368753) @@ -86,6 +86,9 @@ NO_WCAST_QUAL= -Wno-cast-qual .endif .endif +# This warning is utter nonsense +CWARNFLAGS+= -Wno-format-zero-length + # External compilers may not support our format extensions. Allow them # to be disabled. WARNING: format checking is disabled in this case. .if ${MK_FORMAT_EXTENSIONS} == "no" ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368752 - stable/12/sys/vm
Author: rlibby Date: Fri Dec 18 08:29:38 2020 New Revision: 368752 URL: https://svnweb.freebsd.org/changeset/base/368752 Log: MFC r357019: uma: fix zone domain overlaying pcpu cache with disabled cpus UMA zone structures have two arrays at the end which are sized according to the machine: an array of CPU count length, and an array of NUMA domain count length. The CPU counting was wrong in the case where some CPUs are disabled (when mp_ncpus != mp_maxid + 1), and this caused the second array to be overlaid with the first. Reported by: olivier Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23318 Modified: stable/12/sys/vm/uma_core.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/uma_core.c == --- stable/12/sys/vm/uma_core.c Fri Dec 18 04:23:20 2020(r368751) +++ stable/12/sys/vm/uma_core.c Fri Dec 18 08:29:38 2020(r368752) @@ -1782,7 +1782,8 @@ zone_ctor(void *mem, int size, void *udata, int flags) zone->uz_flags = 0; zone->uz_warning = NULL; /* The domain structures follow the cpu structures. */ - zone->uz_domain = (struct uma_zone_domain *)>uz_cpu[mp_ncpus]; + zone->uz_domain = + (struct uma_zone_domain *)>uz_cpu[mp_maxid + 1]; timevalclear(>uz_ratecheck); keg = arg->keg; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368745 - head/sys/dev/ice
Author: rlibby Date: Thu Dec 17 22:53:45 2020 New Revision: 368745 URL: https://svnweb.freebsd.org/changeset/base/368745 Log: ice: quiet -Wredundant-decls Reapply r364240 after driver update in r365617. Reviewed by: lwhsu Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27561 Modified: head/sys/dev/ice/ice_common.h Modified: head/sys/dev/ice/ice_common.h == --- head/sys/dev/ice/ice_common.h Thu Dec 17 21:58:10 2020 (r368744) +++ head/sys/dev/ice/ice_common.h Thu Dec 17 22:53:45 2020 (r368745) @@ -46,15 +46,6 @@ enum ice_fw_modes { ICE_FW_MODE_ROLLBACK }; -/* prototype for functions used for SW locks */ -void ice_free_list(struct LIST_HEAD_TYPE *list); -void ice_init_lock(struct ice_lock *lock); -void ice_acquire_lock(struct ice_lock *lock); -void ice_release_lock(struct ice_lock *lock); -void ice_destroy_lock(struct ice_lock *lock); -void *ice_alloc_dma_mem(struct ice_hw *hw, struct ice_dma_mem *m, u64 size); -void ice_free_dma_mem(struct ice_hw *hw, struct ice_dma_mem *m); - void ice_idle_aq(struct ice_hw *hw, struct ice_ctl_q_info *cq); bool ice_sq_done(struct ice_hw *hw, struct ice_ctl_q_info *cq); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364761 - in head: share/mk sys/conf sys/modules/cloudabi32 sys/modules/cloudabi64 sys/modules/linux sys/modules/linux64
On Mon, Dec 14, 2020 at 2:33 AM Alexander Richardson wrote: > > On Sun, 13 Dec 2020 at 19:22, Ryan Libby wrote: > > > > On Tue, Aug 25, 2020 at 6:30 AM Alex Richardson > > wrote: > > > > > > Author: arichardson > > > Date: Tue Aug 25 13:30:03 2020 > > > New Revision: 364761 > > > URL: https://svnweb.freebsd.org/changeset/base/364761 > > > > > > Log: > > > Pass -fuse-ld=/path/to/ld if ${LD} != "ld" > > > > > > This is needed so that setting LD/XLD is not ignored when linking with > > > $CC > > > instead of directly using $LD. Currently only clang accepts an absolute > > > path for -fuse-ld= (Clang 12+ will add a new --ld-path flag), so we now > > > warn when building with GCC and $LD != "ld" since that might result in > > > the > > > wrong linker being used. > > > > > > We have been setting XLD=/path/to/cheri/ld.lld in CheriBSD for a long > > > time and > > > used a similar version of this patch to avoid linking with /usr/bin/ld. > > > This change is also required when building FreeBSD on an Ubuntu with > > > Clang: > > > In that case we set XCC=/usr/lib/llvm-10/bin/clang and since > > > /usr/lib/llvm-10/bin/ does not contain a "ld" binary the build fails > > > with > > > `clang: error: unable to execute command: Executable "ld" doesn't > > > exist!` > > > unless we pass -fuse-ld=/usr/lib/llvm-10/bin/ld.lld. > > > > > > This change passes -fuse-ld instead of copying ${XLD} to WOLRDTMP/bin/ld > > > since then we would have to ensure that this file does not exist while > > > building the bootstrap tools. The cross-linker might not be compatible > > > with > > > the host linker (e.g. when building on macos: host-linker= Mach-O > > > /usr/bin/ld, > > > cross-linker=LLVM ld.lld). > > > > > > Reviewed By: brooks, emaste > > > Differential Revision: https://reviews.freebsd.org/D26055 > > > > > > Modified: > > > head/share/mk/bsd.sys.mk > > > head/sys/conf/kern.mk > > > head/sys/conf/kern.post.mk > > > head/sys/modules/cloudabi32/Makefile > > > head/sys/modules/cloudabi64/Makefile > > > head/sys/modules/linux/Makefile > > > head/sys/modules/linux64/Makefile > > > > > > Modified: head/share/mk/bsd.sys.mk > > > == > > > --- head/share/mk/bsd.sys.mkTue Aug 25 13:29:57 2020(r364760) > > > +++ head/share/mk/bsd.sys.mkTue Aug 25 13:30:03 2020(r364761) > > > @@ -284,6 +284,19 @@ CFLAGS+= ERROR-tried-to-rebuild-during-make-install > > > .endif > > > .endif > > > > > > +# Please keep this if in sync with kern.mk > > > +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") > > > +# Add -fuse-ld=${LD} if $LD is in a different directory or not called > > > "ld". > > > +# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=. > > > +.if ${COMPILER_TYPE} == "clang" > > > +LDFLAGS+= -fuse-ld=${LD:[1]} > > > +.else > > > +# GCC does not support an absolute path for -fuse-ld so we just print > > > this > > > +# warning instead and let the user add the required symlinks. > > > +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is > > > not supported > > > > FYI: This causes a huge amount of wrong and irrelevant warnings in the > > build log for gcc cross compilers with XLD set, such as the toolchain > > from pkg install amd64-xtoolchain-gcc. That causes XLD to be set (via > > CROSS_BINUTILS_PREFIX in Makefile.inc1) to a path which is indeed the > > default linker for the cross compiler. The warnings are harmless, but > > annoying. Sorry, I don't have a suggestion for a better method. > > > > You can see an example in the build log from a gcc build in CI here > > (although note that the build currently fails for unrelated reasons): > > https://ci.freebsd.org/job/FreeBSD-head-amd64-gcc6_build/3131 > > > Hi Ryan, > > I think there are (at least) 3 options to fix/silence this warning: > > 1) The easiest option would be to turn off this warning for GCC builds > and hope that the user-supplied LD matches the one that GCC will > invoke. > Thanks for looking at it. I don't have a strong feeling abou
Re: svn commit: r364761 - in head: share/mk sys/conf sys/modules/cloudabi32 sys/modules/cloudabi64 sys/modules/linux sys/modules/linux64
On Tue, Aug 25, 2020 at 6:30 AM Alex Richardson wrote: > > Author: arichardson > Date: Tue Aug 25 13:30:03 2020 > New Revision: 364761 > URL: https://svnweb.freebsd.org/changeset/base/364761 > > Log: > Pass -fuse-ld=/path/to/ld if ${LD} != "ld" > > This is needed so that setting LD/XLD is not ignored when linking with $CC > instead of directly using $LD. Currently only clang accepts an absolute > path for -fuse-ld= (Clang 12+ will add a new --ld-path flag), so we now > warn when building with GCC and $LD != "ld" since that might result in the > wrong linker being used. > > We have been setting XLD=/path/to/cheri/ld.lld in CheriBSD for a long time > and > used a similar version of this patch to avoid linking with /usr/bin/ld. > This change is also required when building FreeBSD on an Ubuntu with Clang: > In that case we set XCC=/usr/lib/llvm-10/bin/clang and since > /usr/lib/llvm-10/bin/ does not contain a "ld" binary the build fails with > `clang: error: unable to execute command: Executable "ld" doesn't exist!` > unless we pass -fuse-ld=/usr/lib/llvm-10/bin/ld.lld. > > This change passes -fuse-ld instead of copying ${XLD} to WOLRDTMP/bin/ld > since then we would have to ensure that this file does not exist while > building the bootstrap tools. The cross-linker might not be compatible with > the host linker (e.g. when building on macos: host-linker= Mach-O > /usr/bin/ld, > cross-linker=LLVM ld.lld). > > Reviewed By: brooks, emaste > Differential Revision: https://reviews.freebsd.org/D26055 > > Modified: > head/share/mk/bsd.sys.mk > head/sys/conf/kern.mk > head/sys/conf/kern.post.mk > head/sys/modules/cloudabi32/Makefile > head/sys/modules/cloudabi64/Makefile > head/sys/modules/linux/Makefile > head/sys/modules/linux64/Makefile > > Modified: head/share/mk/bsd.sys.mk > == > --- head/share/mk/bsd.sys.mkTue Aug 25 13:29:57 2020(r364760) > +++ head/share/mk/bsd.sys.mkTue Aug 25 13:30:03 2020(r364761) > @@ -284,6 +284,19 @@ CFLAGS+= ERROR-tried-to-rebuild-during-make-install > .endif > .endif > > +# Please keep this if in sync with kern.mk > +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") > +# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld". > +# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=. > +.if ${COMPILER_TYPE} == "clang" > +LDFLAGS+= -fuse-ld=${LD:[1]} > +.else > +# GCC does not support an absolute path for -fuse-ld so we just print this > +# warning instead and let the user add the required symlinks. > +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not > supported FYI: This causes a huge amount of wrong and irrelevant warnings in the build log for gcc cross compilers with XLD set, such as the toolchain from pkg install amd64-xtoolchain-gcc. That causes XLD to be set (via CROSS_BINUTILS_PREFIX in Makefile.inc1) to a path which is indeed the default linker for the cross compiler. The warnings are harmless, but annoying. Sorry, I don't have a suggestion for a better method. You can see an example in the build log from a gcc build in CI here (although note that the build currently fails for unrelated reasons): https://ci.freebsd.org/job/FreeBSD-head-amd64-gcc6_build/3131 > +.endif > +.endif > + > # Tell bmake not to mistake standard targets for things to be searched for > # or expect to ever be up-to-date. > PHONY_NOTMAIN = analyze afterdepend afterinstall all beforedepend > beforeinstall \ > > Modified: head/sys/conf/kern.mk > == > --- head/sys/conf/kern.mk Tue Aug 25 13:29:57 2020(r364760) > +++ head/sys/conf/kern.mk Tue Aug 25 13:30:03 2020(r364761) > @@ -270,6 +270,22 @@ CFLAGS+=-std=iso9899:1999 > CFLAGS+=-std=${CSTD} > .endif # CSTD > > +# Please keep this if in sync with bsd.sys.mk > +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") > +# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld". > +# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=. > +.if ${COMPILER_TYPE} == "clang" > +# Note: unlike bsd.sys.mk we can't use LDFLAGS here since that is used for > the > +# flags required when linking the kernel. We don't need those flags when > +# building the vdsos. However, we do need -fuse-ld, so use ${CCLDFLAGS} > instead. > +CCLDFLAGS+=-fuse-ld=${LD:[1]} > +.else > +# GCC does not support an absolute path for -fuse-ld so we just print this > +# warning instead and let the user add the required symlinks. > +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not > supported > +.endif > +.endif > + > # Set target-specific linker emulation name. > LD_EMULATION_aarch64=aarch64elf > LD_EMULATION_amd64=elf_x86_64_fbsd > > Modified:
svn commit: r368569 - head/tests/sys/kern
Author: rlibby Date: Fri Dec 11 22:52:16 2020 New Revision: 368569 URL: https://svnweb.freebsd.org/changeset/base/368569 Log: fdgrowtable_test.c: appease gcc Work around bogus gcc -Wreturn-type. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44511 Reviewed by: kevans, rew Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27563 Modified: head/tests/sys/kern/fdgrowtable_test.c Modified: head/tests/sys/kern/fdgrowtable_test.c == --- head/tests/sys/kern/fdgrowtable_test.c Fri Dec 11 22:52:12 2020 (r368568) +++ head/tests/sys/kern/fdgrowtable_test.c Fri Dec 11 22:52:16 2020 (r368569) @@ -151,7 +151,7 @@ ATF_TC_BODY(free_oldtables, tc) ATF_CHECK(old_tables(kd,kp) == 0); } -static void * +static _Noreturn void * exec_thread(void *args) { for (;;) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368567 - head/sys/modules/zfs
Author: rlibby Date: Fri Dec 11 22:52:08 2020 New Revision: 368567 URL: https://svnweb.freebsd.org/changeset/base/368567 Log: zfs: quiet gcc -Wmissing-include-dirs Don't tell it to look for headers in a non-existent directory. Reviewed by: imp, mmacy Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27565 Modified: head/sys/modules/zfs/Makefile Modified: head/sys/modules/zfs/Makefile == --- head/sys/modules/zfs/Makefile Fri Dec 11 22:52:03 2020 (r368566) +++ head/sys/modules/zfs/Makefile Fri Dec 11 22:52:08 2020 (r368567) @@ -18,7 +18,6 @@ KMOD= zfs CFLAGS+= -I${INCDIR} -CFLAGS+= -I${INCDIR}/spl CFLAGS+= -I${INCDIR}/os/freebsd CFLAGS+= -I${INCDIR}/os/freebsd/spl CFLAGS+= -I${INCDIR}/os/freebsd/zfs ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368565 - head/sys/ufs/ffs
Author: rlibby Date: Fri Dec 11 22:51:57 2020 New Revision: 368565 URL: https://svnweb.freebsd.org/changeset/base/368565 Log: ffs: quiet -Wstrict-prototypes Reviewed by: kib, markj, mckusick Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27558 Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c == --- head/sys/ufs/ffs/ffs_softdep.c Fri Dec 11 22:51:53 2020 (r368564) +++ head/sys/ufs/ffs/ffs_softdep.c Fri Dec 11 22:51:57 2020 (r368565) @@ -758,6 +758,7 @@ static struct malloc_type *memtype[] = { */ static void check_clear_deps(struct mount *); static void softdep_error(char *, int); +static int softdep_prerename_vnode(struct ufsmount *, struct vnode *); static int softdep_process_worklist(struct mount *, int); static int softdep_waitidle(struct mount *, int); static void drain_output(struct vnode *); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368570 - head/tests/sys/posixshm
Author: rlibby Date: Fri Dec 11 22:52:20 2020 New Revision: 368570 URL: https://svnweb.freebsd.org/changeset/base/368570 Log: posixshm_test.c: remove tautological checks Reviewed by: kib, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27564 Modified: head/tests/sys/posixshm/posixshm_test.c Modified: head/tests/sys/posixshm/posixshm_test.c == --- head/tests/sys/posixshm/posixshm_test.c Fri Dec 11 22:52:16 2020 (r368569) +++ head/tests/sys/posixshm/posixshm_test.c Fri Dec 11 22:52:20 2020 (r368570) @@ -1322,7 +1322,6 @@ ATF_TC_BODY(largepage_mlock, tc) error = sysctlbyname("vm.max_user_wired", _wired, , NULL, 0); ATF_REQUIRE_MSG(error == 0, "sysctlbyname(vm.max_user_wired) failed; error=%d", errno); - ATF_REQUIRE(max_wired >= 0); sz = sizeof(wired); error = sysctlbyname("vm.stats.vm.v_user_wire_count", , , NULL, @@ -1330,7 +1329,6 @@ ATF_TC_BODY(largepage_mlock, tc) ATF_REQUIRE_MSG(error == 0, "sysctlbyname(vm.stats.vm.v_user_wire_count) failed; error=%d", errno); - ATF_REQUIRE(wired >= 0); pscnt = pagesizes(ps); for (int i = 1; i < pscnt; i++) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368564 - head/sys/dev/qat
Author: rlibby Date: Fri Dec 11 22:51:53 2020 New Revision: 368564 URL: https://svnweb.freebsd.org/changeset/base/368564 Log: qat: quiet -Wredundant-decls Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27554 Modified: head/sys/dev/qat/qat_ae.c Modified: head/sys/dev/qat/qat_ae.c == --- head/sys/dev/qat/qat_ae.c Fri Dec 11 22:51:48 2020(r368563) +++ head/sys/dev/qat/qat_ae.c Fri Dec 11 22:51:53 2020(r368564) @@ -82,8 +82,6 @@ static intqat_ae_write_4(struct qat_softc *, u_char, uint32_t); static int qat_ae_read_4(struct qat_softc *, u_char, bus_size_t, uint32_t *); -static int qat_ae_write_4(struct qat_softc *, u_char, bus_size_t, - uint32_t); static voidqat_ae_ctx_indr_write(struct qat_softc *, u_char, uint32_t, bus_size_t, uint32_t); static int qat_ae_ctx_indr_read(struct qat_softc *, u_char, uint32_t, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368568 - head/sbin/savecore
Author: rlibby Date: Fri Dec 11 22:52:12 2020 New Revision: 368568 URL: https://svnweb.freebsd.org/changeset/base/368568 Log: savecore: bail on write error even when decompressing Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27560 Modified: head/sbin/savecore/savecore.c Modified: head/sbin/savecore/savecore.c == --- head/sbin/savecore/savecore.c Fri Dec 11 22:52:08 2020 (r368567) +++ head/sbin/savecore/savecore.c Fri Dec 11 22:52:12 2020 (r368568) @@ -491,12 +491,12 @@ sparsefwrite(const char *buf, size_t nr, FILE *fp) static char *zbuf; static size_t zbufsize; -static size_t +static ssize_t GunzipWrite(z_stream *z, char *in, size_t insize, FILE *fp) { static bool firstblock = true; /* XXX not re-entrable/usable */ const size_t hdrlen = 10; - size_t nw = 0; + size_t nw = 0, w; int rv; z->next_in = in; @@ -520,18 +520,21 @@ GunzipWrite(z_stream *z, char *in, size_t insize, FILE logmsg(LOG_ERR, "decompression failed: %s", z->msg); return (-1); } - nw += sparsefwrite(zbuf, zbufsize - z->avail_out, fp); + w = sparsefwrite(zbuf, zbufsize - z->avail_out, fp); + if (w < zbufsize - z->avail_out) + return (-1); + nw += w; } while (z->avail_in > 0 && rv != Z_STREAM_END); return (nw); } -static size_t +static ssize_t ZstdWrite(ZSTD_DCtx *Zctx, char *in, size_t insize, FILE *fp) { ZSTD_inBuffer Zin; ZSTD_outBuffer Zout; - size_t nw = 0; + size_t nw = 0, w; int rv; Zin.src = in; @@ -547,7 +550,10 @@ ZstdWrite(ZSTD_DCtx *Zctx, char *in, size_t insize, FI ZSTD_getErrorName(rv)); return (-1); } - nw += sparsefwrite(zbuf, Zout.pos, fp); + w = sparsefwrite(zbuf, Zout.pos, fp); + if (w < Zout.pos) + return (-1); + nw += w; } while (Zin.pos < Zin.size && rv != 0); return (nw); @@ -558,7 +564,8 @@ DoRegularFile(int fd, off_t dumpsize, u_int sectorsize uint8_t compression, char *buf, const char *device, const char *filename, FILE *fp) { - size_t nr, nw, wl; + size_t nr, wl; + ssize_t nw; off_t dmpcnt, origsize; z_stream z; /* gzip */ ZSTD_DCtx *Zctx;/* zstd */ @@ -609,8 +616,8 @@ DoRegularFile(int fd, off_t dumpsize, u_int sectorsize nw = fwrite(buf, 1, wl, fp); else nw = sparsefwrite(buf, wl, fp); - if ((compression == KERNELDUMP_COMP_NONE && nw != wl) || - (compression != KERNELDUMP_COMP_NONE && nw < 0)) { + if (nw < 0 || (compression == KERNELDUMP_COMP_NONE && +(size_t)nw != wl)) { logmsg(LOG_ERR, "write error on %s file: %m", filename); logmsg(LOG_WARNING, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368563 - head/sys/dev/ntb/ntb_hw
Author: rlibby Date: Fri Dec 11 22:51:48 2020 New Revision: 368563 URL: https://svnweb.freebsd.org/changeset/base/368563 Log: ntb: quiet gcc -Wreturn-type Reviewed by: cem, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27553 Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c == --- head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Fri Dec 11 22:51:44 2020 (r368562) +++ head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Fri Dec 11 22:51:48 2020 (r368563) @@ -1309,6 +1309,7 @@ db_ioread(struct ntb_softc *ntb, uint64_t regoff) case NTB_XEON_GEN1: return (intel_ntb_reg_read(2, regoff)); } + __assert_unreachable(); } static inline void ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368566 - in head/sys: dev/if_wg/include/sys dev/if_wg/module modules/if_wg
Author: rlibby Date: Fri Dec 11 22:52:03 2020 New Revision: 368566 URL: https://svnweb.freebsd.org/changeset/base/368566 Log: if_wg: appease gcc - remove -ferror-limit option - quiet -Wredundant-decls Reviewed by: mmacy Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27559 Modified: head/sys/dev/if_wg/include/sys/if_wg_session_vars.h head/sys/dev/if_wg/include/sys/wg_module.h head/sys/dev/if_wg/module/if_wg_session.c head/sys/modules/if_wg/Makefile Modified: head/sys/dev/if_wg/include/sys/if_wg_session_vars.h == --- head/sys/dev/if_wg/include/sys/if_wg_session_vars.h Fri Dec 11 22:51:57 2020(r368565) +++ head/sys/dev/if_wg/include/sys/if_wg_session_vars.h Fri Dec 11 22:52:03 2020(r368566) @@ -274,9 +274,6 @@ struct wg_tag { int t_mtu; }; -int wg_route_add(struct wg_route_table *tbl, struct wg_peer *peer, -const struct wg_allowedip *cidr_); - struct wg_peer *wg_route_lookup(struct wg_route_table *, struct mbuf *, enum route_direction); Modified: head/sys/dev/if_wg/include/sys/wg_module.h == --- head/sys/dev/if_wg/include/sys/wg_module.h Fri Dec 11 22:51:57 2020 (r368565) +++ head/sys/dev/if_wg/include/sys/wg_module.h Fri Dec 11 22:52:03 2020 (r368566) @@ -47,8 +47,6 @@ #include #include -MALLOC_DECLARE(M_WG); - enum noise_lengths { NOISE_PUBLIC_KEY_LEN = CURVE25519_KEY_SIZE, Modified: head/sys/dev/if_wg/module/if_wg_session.c == --- head/sys/dev/if_wg/module/if_wg_session.c Fri Dec 11 22:51:57 2020 (r368565) +++ head/sys/dev/if_wg/module/if_wg_session.c Fri Dec 11 22:52:03 2020 (r368566) @@ -113,7 +113,6 @@ SYSCTL_INT(_net_wg, OID_AUTO, debug, CTLFLAG_RWTUN, #define DPRINTF(sc, ...) if (wireguard_debug) if_printf(sc->sc_ifp, ##__VA_ARGS__) /* Socket */ -intwg_socket_close(struct wg_socket *); static int wg_socket_bind(struct wg_softc *sc, struct wg_socket *); static int wg_send(struct wg_softc *, struct wg_endpoint *, struct mbuf *); @@ -145,9 +144,6 @@ static void wg_timers_disable(struct wg_timers *); /* Queue */ static int wg_queue_in(struct wg_peer *, struct mbuf *); static struct mbuf *wg_queue_dequeue(struct wg_queue *, struct wg_tag **); - -/* Route */ -void wg_route_destroy(struct wg_route_table *); /* Cookie */ Modified: head/sys/modules/if_wg/Makefile == --- head/sys/modules/if_wg/Makefile Fri Dec 11 22:51:57 2020 (r368565) +++ head/sys/modules/if_wg/Makefile Fri Dec 11 22:52:03 2020 (r368566) @@ -14,7 +14,6 @@ ZINCDIR= ${SRCTOP}/sys/dev/if_wg/module/crypto/zinc CFLAGS+= -I${INCDIR} CFLAGS+= -D__KERNEL__ -CFLAGS+= -ferror-limit=7 DEBUG_FLAGS=-g ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368562 - head/sys/kern
Author: rlibby Date: Fri Dec 11 22:51:44 2020 New Revision: 368562 URL: https://svnweb.freebsd.org/changeset/base/368562 Log: cache_fplookup: quiet gcc -Wreturn-type Reviewed by: markj, mjg Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27555 Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c == --- head/sys/kern/vfs_cache.c Fri Dec 11 21:51:50 2020(r368561) +++ head/sys/kern/vfs_cache.c Fri Dec 11 22:51:44 2020(r368562) @@ -4603,6 +4603,7 @@ out: cache_fpl_cleanup_cnp(cnp); return (error); } + __assert_unreachable(); } /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r368490 - in head/sys: dev/iommu x86/iommu
Author: rlibby Date: Wed Dec 9 18:43:58 2020 New Revision: 368490 URL: https://svnweb.freebsd.org/changeset/base/368490 Log: dmar: reserve memory windows of PCIe root port PCI memory address space is shared between memory-mapped devices (MMIO) and host memory (which may be remapped by an IOMMU). Device accesses to an address within a memory aperture in a PCIe root port will be treated as peer-to-peer and not forwarded to an IOMMU. To avoid this, reserve the address space of the root port's memory apertures in the address space used by the IOMMU for remapping. Reviewed by: kib, tychon Discussed with: Anton Rang Tested by:tychon Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D27503 Modified: head/sys/dev/iommu/iommu.h head/sys/dev/iommu/iommu_gas.c head/sys/x86/iommu/intel_ctx.c Modified: head/sys/dev/iommu/iommu.h == --- head/sys/dev/iommu/iommu.h Wed Dec 9 18:37:43 2020(r368489) +++ head/sys/dev/iommu/iommu.h Wed Dec 9 18:43:58 2020(r368490) @@ -199,6 +199,8 @@ int iommu_gas_map_region(struct iommu_domain *domain, struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma); int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start, iommu_gaddr_t end, struct iommu_map_entry **entry0); +int iommu_gas_reserve_region_extend(struct iommu_domain *domain, +iommu_gaddr_t start, iommu_gaddr_t end); void iommu_set_buswide_ctx(struct iommu_unit *unit, u_int busno); bool iommu_is_buswide_ctx(struct iommu_unit *unit, u_int busno); Modified: head/sys/dev/iommu/iommu_gas.c == --- head/sys/dev/iommu/iommu_gas.c Wed Dec 9 18:37:43 2020 (r368489) +++ head/sys/dev/iommu/iommu_gas.c Wed Dec 9 18:43:58 2020 (r368490) @@ -677,6 +677,22 @@ iommu_gas_map_region(struct iommu_domain *domain, stru return (0); } +static int +iommu_gas_reserve_region_locked(struct iommu_domain *domain, +iommu_gaddr_t start, iommu_gaddr_t end, struct iommu_map_entry *entry) +{ + int error; + + IOMMU_DOMAIN_ASSERT_LOCKED(domain); + + entry->start = start; + entry->end = end; + error = iommu_gas_alloc_region(domain, entry, IOMMU_MF_CANWAIT); + if (error == 0) + entry->flags |= IOMMU_MAP_ENTRY_UNMAPPED; + return (error); +} + int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start, iommu_gaddr_t end, struct iommu_map_entry **entry0) @@ -685,17 +701,63 @@ iommu_gas_reserve_region(struct iommu_domain *domain, int error; entry = iommu_gas_alloc_entry(domain, IOMMU_PGF_WAITOK); - entry->start = start; - entry->end = end; IOMMU_DOMAIN_LOCK(domain); - error = iommu_gas_alloc_region(domain, entry, IOMMU_MF_CANWAIT); - if (error == 0) - entry->flags |= IOMMU_MAP_ENTRY_UNMAPPED; + error = iommu_gas_reserve_region_locked(domain, start, end, entry); IOMMU_DOMAIN_UNLOCK(domain); if (error != 0) iommu_gas_free_entry(domain, entry); else if (entry0 != NULL) *entry0 = entry; + return (error); +} + +/* + * As in iommu_gas_reserve_region, reserve [start, end), but allow for existing + * entries. + */ +int +iommu_gas_reserve_region_extend(struct iommu_domain *domain, +iommu_gaddr_t start, iommu_gaddr_t end) +{ + struct iommu_map_entry *entry, *next, *prev, key = {}; + iommu_gaddr_t entry_start, entry_end; + int error; + + error = 0; + entry = NULL; + end = ummin(end, domain->end); + while (start < end) { + /* Preallocate an entry. */ + if (entry == NULL) + entry = iommu_gas_alloc_entry(domain, + IOMMU_PGF_WAITOK); + /* Calculate the free region from here to the next entry. */ + key.start = key.end = start; + IOMMU_DOMAIN_LOCK(domain); + next = RB_NFIND(iommu_gas_entries_tree, >rb_root, ); + KASSERT(next != NULL, ("domain %p with end %#jx has no entry " + "after %#jx", domain, (uintmax_t)domain->end, + (uintmax_t)start)); + entry_end = ummin(end, next->start); + prev = RB_PREV(iommu_gas_entries_tree, >rb_root, next); + if (prev != NULL) + entry_start = ummax(start, prev->end); + else + entry_start = start; + start = next->end; + /* Reserve the region if non-empty. */ + if (entry_start != entry_end) { + error = iommu_gas_reserve_region_locked(domain, + entry_start, entry_end, entry); +
Re: svn commit: r358439 - head/sys/amd64/include
On Wed, Mar 4, 2020 at 10:28 AM Brooks Davis wrote: > > On Wed, Mar 04, 2020 at 12:27:08PM +0100, Guido Falsi wrote: > > On 02/03/20 18:13, Ryan Libby wrote: > > > On Mon, Mar 2, 2020 at 12:45 AM Alexander V. Chernikov > > > wrote: > > >> > > >> 28.02.2020, 18:32, "Ryan Libby" : > > >>> Author: rlibby > > >>> Date: Fri Feb 28 18:32:36 2020 > > >>> New Revision: 358439 > > >>> URL: https://svnweb.freebsd.org/changeset/base/358439 > > >>> > > >>> Log: > > >>> amd64 atomic.h: minor codegen optimization in flag access > > >>> > > >>> Previously the pattern to extract status flags from inline assembly > > >>> blocks was to use setcc in the block to write the flag to a register. > > >>> This was suboptimal in a few ways: > > >>>- It would lead to code like: sete %cl; test %cl; jne, i.e. a flag > > >>> would just be loaded into a register and then reloaded to a flag. > > >>>- The setcc would force the block to use an additional register. > > >>>- If the client code didn't care for the flag value then the setcc > > >>> would be entirely pointless but could not be eliminated by the > > >>> optimizer. > > >>> > > >>> A more modern inline asm construct (since gcc 6 and clang 9) allows > > >>> for > > >> This effectively restricts kernel builds by all older compilers. > > >> Is there any chance of making it conditional depending on the compiler > > >> version/features? > > > > > > Yes, it is possible to test for __GCC_ASM_FLAG_OUTPUTS__. It is more > > > maintenance effort going forward. If building current with an old cross > > > compiler is an important scenario, we can either revert this and the > > > following revision or work up a patch to make it conditional. I'll see > > > what that might look like. > > > > > > > Actually this causes emulators/virtualbox-ose port to fail to build: > > > > In file included from /usr/src/sys/sys/systm.h:44: > > /usr/include/machine/atomic.h:230:1: error: invalid output constraint > > '=@cce' in asm > > ATOMIC_CMPSET(char); > > ^ > > /usr/include/machine/atomic.h:205:4: note: expanded from macro > > 'ATOMIC_CMPSET' > > : "=@cce" (res),/* 0 */ \ > > ^ > > /usr/include/machine/atomic.h:230:1: error: invalid output constraint > > '=@cce' in asm > > > > (and so on) > > > > > > the virtualbox-ose port is forced to use an older clang version due to > > crashes when compiled with newer ones. > > > > Not sure whose responsibility is to fix this. > > I suspect that now that we don't care about gcc 4.2.1, we should > restructure machine/atomic.h to use __atomic compiler builtins in nearly > all cases. We could then conditionalize small sets of mircooptimized > assembly versions based on the availability of compiler features if they > add any value. > > On CheriBSD we've switched the RISC-V to use the C versions and are > overdue to do the same to MIPS. Reworking things to make this the > default would decrease our maintenance burden and it seems unlikely that > most of our platforms would benefit from handcode assembly (given the > general level of optimization in our lower-tier platforms). > > -- Brooks There's further discussion on that topic in the original review (D23869) and in D23661. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r358439 - head/sys/amd64/include
On Wed, Mar 4, 2020 at 3:27 AM Guido Falsi wrote: > > On 02/03/20 18:13, Ryan Libby wrote: > > On Mon, Mar 2, 2020 at 12:45 AM Alexander V. Chernikov > > wrote: > >> > >> 28.02.2020, 18:32, "Ryan Libby" : > >>> Author: rlibby > >>> Date: Fri Feb 28 18:32:36 2020 > >>> New Revision: 358439 > >>> URL: https://svnweb.freebsd.org/changeset/base/358439 > >>> > >>> Log: > >>> amd64 atomic.h: minor codegen optimization in flag access > >>> > >>> Previously the pattern to extract status flags from inline assembly > >>> blocks was to use setcc in the block to write the flag to a register. > >>> This was suboptimal in a few ways: > >>>- It would lead to code like: sete %cl; test %cl; jne, i.e. a flag > >>> would just be loaded into a register and then reloaded to a flag. > >>>- The setcc would force the block to use an additional register. > >>>- If the client code didn't care for the flag value then the setcc > >>> would be entirely pointless but could not be eliminated by the > >>> optimizer. > >>> > >>> A more modern inline asm construct (since gcc 6 and clang 9) allows for > >> This effectively restricts kernel builds by all older compilers. > >> Is there any chance of making it conditional depending on the compiler > >> version/features? > > > > Yes, it is possible to test for __GCC_ASM_FLAG_OUTPUTS__. It is more > > maintenance effort going forward. If building current with an old cross > > compiler is an important scenario, we can either revert this and the > > following revision or work up a patch to make it conditional. I'll see > > what that might look like. > > > > Actually this causes emulators/virtualbox-ose port to fail to build: > > In file included from /usr/src/sys/sys/systm.h:44: > /usr/include/machine/atomic.h:230:1: error: invalid output constraint > '=@cce' in asm > ATOMIC_CMPSET(char); > ^ > /usr/include/machine/atomic.h:205:4: note: expanded from macro > 'ATOMIC_CMPSET' > : "=@cce" (res),/* 0 */ \ > ^ > /usr/include/machine/atomic.h:230:1: error: invalid output constraint > '=@cce' in asm > > (and so on) > > > the virtualbox-ose port is forced to use an older clang version due to > crashes when compiled with newer ones. > > Not sure whose responsibility is to fix this. > > Should I file a bug report on bugzilla? > > -- > Guido Falsi We've discussed whether to provide compatibility code for older compilers here: https://reviews.freebsd.org/D23937 There's a bug tracking virtualbox-ose being pinned to an old compiler here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236616 I see you have commented on that bug. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r358439 - head/sys/amd64/include
On Mon, Mar 2, 2020 at 12:45 AM Alexander V. Chernikov wrote: > > 28.02.2020, 18:32, "Ryan Libby" : > > Author: rlibby > > Date: Fri Feb 28 18:32:36 2020 > > New Revision: 358439 > > URL: https://svnweb.freebsd.org/changeset/base/358439 > > > > Log: > > amd64 atomic.h: minor codegen optimization in flag access > > > > Previously the pattern to extract status flags from inline assembly > > blocks was to use setcc in the block to write the flag to a register. > > This was suboptimal in a few ways: > >- It would lead to code like: sete %cl; test %cl; jne, i.e. a flag > > would just be loaded into a register and then reloaded to a flag. > >- The setcc would force the block to use an additional register. > >- If the client code didn't care for the flag value then the setcc > > would be entirely pointless but could not be eliminated by the > > optimizer. > > > > A more modern inline asm construct (since gcc 6 and clang 9) allows for > This effectively restricts kernel builds by all older compilers. > Is there any chance of making it conditional depending on the compiler > version/features? Yes, it is possible to test for __GCC_ASM_FLAG_OUTPUTS__. It is more maintenance effort going forward. If building current with an old cross compiler is an important scenario, we can either revert this and the following revision or work up a patch to make it conditional. I'll see what that might look like. > > "flag output operands", where a C variable can be written directly from > > a flag. The optimizer can then use this to produce direct code where > > the flag does not take a trip through a register. > > > > In practice this makes each affected operation sequence shorter by five > > bytes of instructions. It's unlikely this has a measurable performance > > impact. > > > > Reviewed by: kib, markj, mjg > > Sponsored by: Dell EMC Isilon > > Differential Revision: https://reviews.freebsd.org/D23869 > > > > Modified: > > head/sys/amd64/include/atomic.h > > > > Modified: head/sys/amd64/include/atomic.h > > == > > --- head/sys/amd64/include/atomic.h Fri Feb 28 17:41:46 2020 (r358438) > > +++ head/sys/amd64/include/atomic.h Fri Feb 28 18:32:36 2020 (r358439) > > @@ -201,9 +201,8 @@ atomic_cmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE > > __asm __volatile( \ > > " " MPLOCKED " " \ > > " cmpxchg %3,%1 ; " \ > > - " sete %0 ; " \ > > "# atomic_cmpset_" #TYPE " " \ > > - : "=q" (res), /* 0 */ \ > > + : "=@cce" (res), /* 0 */ \ > >"+m" (*dst), /* 1 */ \ > >"+a" (expect) /* 2 */ \ > > : "r" (src) /* 3 */ \ > > @@ -219,9 +218,8 @@ atomic_fcmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE > > __asm __volatile( \ > > " " MPLOCKED " " \ > > " cmpxchg %3,%1 ; " \ > > - " sete %0 ; " \ > > "# atomic_fcmpset_" #TYPE " " \ > > - : "=q" (res), /* 0 */ \ > > + : "=@cce" (res), /* 0 */ \ > >"+m" (*dst), /* 1 */ \ > >"+a" (*expect) /* 2 */ \ > > : "r" (src) /* 3 */ \ > > @@ -278,9 +276,8 @@ atomic_testandset_int(volatile u_int *p, u_int v) > > __asm __volatile( > > " " MPLOCKED " " > > " btsl %2,%1 ; " > > - " setc %0 ; " > > "# atomic_testandset_int" > > - : "=q" (res), /* 0 */ > > + : "=@ccc" (res), /* 0 */ > >"+m" (*p) /* 1 */ > > : "Ir" (v & 0x1f) /* 2 */ > > : "cc"); > > @@ -295,9 +292,8 @@ atomic_testandset_long(volatile u_long *p, u_int v) > > __asm __volatile( > > " " MPLOCKED " " > > " btsq %2,%1 ; " > > - " setc %0 ; " > > "# atomic_testandset_long" > > - : "=q" (res), /* 0 */ > > + : "=@ccc" (res), /* 0 */ > >"+m" (*p) /* 1 */ > > : "Jr" ((u_long)(v & 0x3f)) /* 2 */ > > : "cc"); > > @@ -312,9 +308,8 @@ atomic_testandclear_int(volatile u_int *p, u_int v) > > __asm __volatile( > > " " MPLOCKED " " > > " btrl %2,%1 ; " > > - " setc %0 ; " > > "# atomic_testandclear_int" > > - : "=q" (res), /* 0 */ > > + : "=@ccc" (res), /* 0 */ > >"+m" (*p) /* 1 */ > > : "Ir" (v & 0x1f) /* 2 */ > > : "cc"); > > @@ -329,9 +324,8 @@ atomic_testandclear_long(volatile u_long *p, u_int v) > > __asm __volatile( > > " " MPLOCKED " " > > " btrq %2,%1 ; " > > - " setc %0 ; " > > "# atomic_testandclear_long" > > - : "=q" (res), /* 0 */ > > + : "=@ccc" (res), /* 0 */ > >"+m" (*p) /* 1 */ > > : "Jr" ((u_long)(v & 0x3f)) /* 2 */ > > : "cc"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358440 - head/sys/amd64/amd64
Author: rlibby Date: Fri Feb 28 18:32:40 2020 New Revision: 358440 URL: https://svnweb.freebsd.org/changeset/base/358440 Log: amd64 pmap.c: minor codegen optimization in flag access Following previous revision, apply the same minor optimization to hand-rolled atomic_fcmpset_128 in pmap.c. Reviewed by: kib, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23870 Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Fri Feb 28 18:32:36 2020(r358439) +++ head/sys/amd64/amd64/pmap.c Fri Feb 28 18:32:40 2020(r358440) @@ -714,8 +714,8 @@ pmap_di_load_invl(struct pmap_invl_gen *ptr, struct pm old_low = new_low = 0; old_high = new_high = (uintptr_t)0; - __asm volatile("lock;cmpxchg16b\t%1;sete\t%0" - : "=r" (res), "+m" (*ptr), "+a" (old_low), "+d" (old_high) + __asm volatile("lock;cmpxchg16b\t%1" + : "=@cce" (res), "+m" (*ptr), "+a" (old_low), "+d" (old_high) : "b"(new_low), "c" (new_high) : "memory", "cc"); if (res == 0) { @@ -742,8 +742,8 @@ pmap_di_store_invl(struct pmap_invl_gen *ptr, struct p old_low = old_val->gen; old_high = (uintptr_t)old_val->next; - __asm volatile("lock;cmpxchg16b\t%1;sete\t%0" - : "=r" (res), "+m" (*ptr), "+a" (old_low), "+d" (old_high) + __asm volatile("lock;cmpxchg16b\t%1" + : "=@cce" (res), "+m" (*ptr), "+a" (old_low), "+d" (old_high) : "b"(new_low), "c" (new_high) : "memory", "cc"); return (res); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358439 - head/sys/amd64/include
Author: rlibby Date: Fri Feb 28 18:32:36 2020 New Revision: 358439 URL: https://svnweb.freebsd.org/changeset/base/358439 Log: amd64 atomic.h: minor codegen optimization in flag access Previously the pattern to extract status flags from inline assembly blocks was to use setcc in the block to write the flag to a register. This was suboptimal in a few ways: - It would lead to code like: sete %cl; test %cl; jne, i.e. a flag would just be loaded into a register and then reloaded to a flag. - The setcc would force the block to use an additional register. - If the client code didn't care for the flag value then the setcc would be entirely pointless but could not be eliminated by the optimizer. A more modern inline asm construct (since gcc 6 and clang 9) allows for "flag output operands", where a C variable can be written directly from a flag. The optimizer can then use this to produce direct code where the flag does not take a trip through a register. In practice this makes each affected operation sequence shorter by five bytes of instructions. It's unlikely this has a measurable performance impact. Reviewed by: kib, markj, mjg Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23869 Modified: head/sys/amd64/include/atomic.h Modified: head/sys/amd64/include/atomic.h == --- head/sys/amd64/include/atomic.h Fri Feb 28 17:41:46 2020 (r358438) +++ head/sys/amd64/include/atomic.h Fri Feb 28 18:32:36 2020 (r358439) @@ -201,9 +201,8 @@ atomic_cmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE __asm __volatile( \ " " MPLOCKED "" \ " cmpxchg %3,%1 ; " \ - " sete%0 ;" \ "# atomic_cmpset_" #TYPE " " \ - : "=q" (res), /* 0 */ \ + : "=@cce" (res),/* 0 */ \ "+m" (*dst), /* 1 */ \ "+a" (expect) /* 2 */ \ : "r" (src) /* 3 */ \ @@ -219,9 +218,8 @@ atomic_fcmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE __asm __volatile( \ " " MPLOCKED "" \ " cmpxchg %3,%1 ; " \ - " sete%0 ;" \ "# atomic_fcmpset_" #TYPE " " \ - : "=q" (res), /* 0 */ \ + : "=@cce" (res),/* 0 */ \ "+m" (*dst), /* 1 */ \ "+a" (*expect)/* 2 */ \ : "r" (src) /* 3 */ \ @@ -278,9 +276,8 @@ atomic_testandset_int(volatile u_int *p, u_int v) __asm __volatile( " " MPLOCKED "" " btsl%2,%1 ; " - " setc%0 ;" "# atomic_testandset_int" - : "=q" (res), /* 0 */ + : "=@ccc" (res),/* 0 */ "+m" (*p) /* 1 */ : "Ir" (v & 0x1f) /* 2 */ : "cc"); @@ -295,9 +292,8 @@ atomic_testandset_long(volatile u_long *p, u_int v) __asm __volatile( " " MPLOCKED "" " btsq%2,%1 ; " - " setc%0 ;" "# atomic_testandset_long" - : "=q" (res), /* 0 */ + : "=@ccc" (res),/* 0 */ "+m" (*p) /* 1 */ : "Jr" ((u_long)(v & 0x3f)) /* 2 */ : "cc"); @@ -312,9 +308,8 @@ atomic_testandclear_int(volatile u_int *p, u_int v) __asm __volatile( " " MPLOCKED "" " btrl%2,%1 ; " - " setc%0 ;" "# atomic_testandclear_int" - : "=q" (res), /* 0 */ + : "=@ccc" (res),/* 0 */ "+m" (*p) /* 1 */ : "Ir" (v & 0x1f) /* 2 */ : "cc"); @@ -329,9 +324,8 @@ atomic_testandclear_long(volatile u_long *p, u_int v) __asm __volatile( " " MPLOCKED "" " btrq%2,%1 ; " - " setc%0 ;" "# atomic_testandclear_long" - : "=q" (res), /* 0 */ + : "=@ccc" (res),/* 0 */ "+m" (*p) /* 1 */ : "Jr" ((u_long)(v & 0x3f)) /* 2 */ : "cc"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to
Re: svn commit: r358377 - head/sys/vm
On Thu, Feb 27, 2020 at 12:23 AM Jeff Roberson wrote: > > Author: jeff > Date: Thu Feb 27 08:23:10 2020 > New Revision: 358377 > URL: https://svnweb.freebsd.org/changeset/base/358377 > > Log: > A pair of performance improvements. > > Swap buckets on free as well as alloc so that alloc is always the most > cache-hot data. > > When selecting a zone domain for the round-robin bucket cache use the > local domain unless there is a severe imbalance. This does not affinitize > memory, only locks and queues. > > Reviewed by: markj, rlibby > Differential Revision:https://reviews.freebsd.org/D23824 > > Modified: > head/sys/vm/uma_core.c > > Modified: head/sys/vm/uma_core.c > == > --- head/sys/vm/uma_core.c Thu Feb 27 07:02:33 2020(r358376) > +++ head/sys/vm/uma_core.c Thu Feb 27 08:23:10 2020(r358377) > @@ -564,26 +564,29 @@ zone_domain_lock(uma_zone_t zone, int domain) > } > > /* > - * Search for the domain with the least cached items and return it, breaking > - * ties with a preferred domain by returning it. > + * Search for the domain with the least cached items and return it if it > + * is out of balance with the preferred domain. > */ > static __noinline int > zone_domain_lowest(uma_zone_t zone, int pref) > { > - long least, nitems; > + long least, nitems, prefitems; > int domain; > int i; > > - least = LONG_MAX; > + prefitems = least = LONG_MAX; > domain = 0; > for (i = 0; i < vm_ndomains; i++) { > nitems = ZDOM_GET(zone, i)->uzd_nitems; > if (nitems < least) { > domain = i; > least = nitems; > - } else if (nitems == least && (i == pref || domain == pref)) > - domain = pref; > + } > + if (domain == pref) > + prefitems = nitems; > } > + if (prefitems < least * 2) > + return (pref); If think this does need to be <=, not <, for the case where prefitems=0, but it wasn't the first domain. So e.g. if all domains nitems are 0, but pref=1, then with < we return domain=0. > > return (domain); > } > @@ -4102,8 +4105,11 @@ uma_zfree_arg(uma_zone_t zone, void *item, void *udata > bucket = >uc_crossbucket; > } else > #endif > - if (bucket->ucb_cnt >= bucket->ucb_entries) > - bucket = >uc_freebucket; > + if (bucket->ucb_cnt == bucket->ucb_entries && > + cache->uc_freebucket.ucb_cnt < > + cache->uc_freebucket.ucb_entries) > + cache_bucket_swap(>uc_freebucket, > + >uc_allocbucket); > if (__predict_true(bucket->ucb_cnt < bucket->ucb_entries)) { > cache_bucket_push(cache, bucket, item); > critical_exit(); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r358257 - in head/sys: kern sys
On Sat, Feb 22, 2020 at 7:53 PM Kyle Evans wrote: > > On Sat, Feb 22, 2020 at 9:32 PM Ryan Libby wrote: > > > > Author: rlibby > > Date: Sun Feb 23 03:32:11 2020 > > New Revision: 358257 > > URL: https://svnweb.freebsd.org/changeset/base/358257 > > > > Log: > > vfs: quiet -Wwrite-strings > > > > Reviewed by: kib, markj > > Differential Revision:https://reviews.freebsd.org/D23797 > > > > Only tangentially related to this, I have a patch in one of my WIP > branches that const-poisons vn_fullpath()'s retbuf parameter, if > that's of any interest. Many consumers will set a default value to a > statically allocated string before passing it in as the retbuf -- I > had a use-case where I'd be trying to do similar but with a function > that actually returns a const char *, but that particular case may not > get committed. > > I can post the patch to phabricator if anyone cares about this -- the > impact on callers isn't actually all that bad, basically just > shuffling around declarations. There's only one case where it ends up > introducing some __DECONST ugliness because the caller writes it out > with uiomove(). > > Thanks, > > Kyle Evans I did notice vn_fullpath when I tried out the build with -Wwrite-strings, and I decided to stay far away from it! Feel free to add me to a review if you decide to post it. In general there was a lot more that was triggered by -Wwrite-strings, and I only touched the stuff that was in sys/kern or sys/vm and that I thought would have quick and non-controversial resolutions. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358258 - in head/sys: kern sys
Author: rlibby Date: Sun Feb 23 03:32:16 2020 New Revision: 358258 URL: https://svnweb.freebsd.org/changeset/base/358258 Log: sys/kern: quiet -Wwrite-strings Quiet a variety of Wwrite-strings warnings in sys/kern at low-impact sites. This patch avoids addressing certain others which would need to plumb const through structure definitions. Reviewed by: kib, markj Differential Revision:https://reviews.freebsd.org/D23798 Modified: head/sys/kern/kern_cons.c head/sys/kern/kern_linker.c head/sys/kern/kern_shutdown.c head/sys/kern/kern_sig.c head/sys/kern/link_elf.c head/sys/sys/bufobj.h head/sys/sys/conf.h head/sys/sys/cons.h head/sys/sys/signalvar.h Modified: head/sys/kern/kern_cons.c == --- head/sys/kern/kern_cons.c Sun Feb 23 03:32:11 2020(r358257) +++ head/sys/kern/kern_cons.c Sun Feb 23 03:32:16 2020(r358258) @@ -98,7 +98,7 @@ static char *consbuf; /* buffer used by `consmsgbuf' static struct callout conscallout; /* callout for outputting to constty */ struct msgbuf consmsgbuf; /* message buffer for console tty */ static u_char console_pausing; /* pause after each line during probe */ -static char *console_pausestr= +static const char console_pausestr[] = ""; struct tty *constty; /* pointer to console "window" tty */ static struct mtx cnputs_mtx; /* Mutex for cnputs(). */ @@ -510,7 +510,7 @@ cnputc(int c) { struct cn_device *cnd; struct consdev *cn; - char *cp; + const char *cp; #ifdef EARLY_PRINTF if (early_putc != NULL) { @@ -571,7 +571,7 @@ cnputsn(const char *p, size_t n) } void -cnputs(char *p) +cnputs(const char *p) { cnputsn(p, strlen(p)); } Modified: head/sys/kern/kern_linker.c == --- head/sys/kern/kern_linker.c Sun Feb 23 03:32:11 2020(r358257) +++ head/sys/kern/kern_linker.c Sun Feb 23 03:32:16 2020(r358258) @@ -1765,7 +1765,7 @@ SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW TUNABLE_STR("module_path", linker_path, sizeof(linker_path)); -static char *linker_ext_list[] = { +static const char * const linker_ext_list[] = { "", ".ko", NULL @@ -1782,7 +1782,8 @@ linker_lookup_file(const char *path, int pathlen, cons { struct nameidata nd; struct thread *td = curthread; /* XXX */ - char *result, **cpp, *sep; + const char * const *cpp, *sep; + char *result; int error, len, extlen, reclen, flags; enum vtype type; @@ -1838,8 +1839,9 @@ linker_hints_lookup(const char *path, int pathlen, con struct ucred *cred = td ? td->td_ucred : NULL; struct nameidata nd; struct vattr vattr, mattr; + const char *best, *sep; u_char *hints = NULL; - u_char *cp, *recptr, *bufend, *result, *best, *pathbuf, *sep; + u_char *cp, *recptr, *bufend, *result, *pathbuf; int error, ival, bestver, *intp, found, flags, clen, blen; ssize_t reclen; Modified: head/sys/kern/kern_shutdown.c == --- head/sys/kern/kern_shutdown.c Sun Feb 23 03:32:11 2020 (r358257) +++ head/sys/kern/kern_shutdown.c Sun Feb 23 03:32:16 2020 (r358258) @@ -1714,7 +1714,7 @@ dump_finish(struct dumperinfo *di, struct kerneldumphe void dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh, -char *magic, uint32_t archver, uint64_t dumplen) +const char *magic, uint32_t archver, uint64_t dumplen) { size_t dstsize; Modified: head/sys/kern/kern_sig.c == --- head/sys/kern/kern_sig.cSun Feb 23 03:32:11 2020(r358257) +++ head/sys/kern/kern_sig.cSun Feb 23 03:32:16 2020(r358258) @@ -3181,7 +3181,7 @@ proc_wkilled(struct proc *p) * Kill the current process for stated reason. */ void -killproc(struct proc *p, char *why) +killproc(struct proc *p, const char *why) { PROC_LOCK_ASSERT(p, MA_OWNED); Modified: head/sys/kern/link_elf.c == --- head/sys/kern/link_elf.cSun Feb 23 03:32:11 2020(r358257) +++ head/sys/kern/link_elf.cSun Feb 23 03:32:16 2020(r358258) @@ -405,7 +405,7 @@ link_elf_init(void* arg) Elf_Size *ctors_sizep; caddr_t modptr, baseptr, sizeptr; elf_file_t ef; - char *modname; + const char *modname; linker_add_class(_elf_class); Modified: head/sys/sys/bufobj.h == --- head/sys/sys/bufobj.h Sun Feb 23 03:32:11 2020(r358257) +++ head/sys/sys/bufobj.h Sun
svn commit: r358257 - in head/sys: kern sys
Author: rlibby Date: Sun Feb 23 03:32:11 2020 New Revision: 358257 URL: https://svnweb.freebsd.org/changeset/base/358257 Log: vfs: quiet -Wwrite-strings Reviewed by: kib, markj Differential Revision:https://reviews.freebsd.org/D23797 Modified: head/sys/kern/vfs_subr.c head/sys/kern/vfs_vnops.c head/sys/kern/vnode_if.src head/sys/sys/vnode.h Modified: head/sys/kern/vfs_subr.c == --- head/sys/kern/vfs_subr.cSun Feb 23 03:32:04 2020(r358256) +++ head/sys/kern/vfs_subr.cSun Feb 23 03:32:11 2020(r358257) @@ -4040,7 +4040,7 @@ vcount(struct vnode *vp) /* * Print out a description of a vnode. */ -static char *typename[] = +static const char * const typename[] = {"VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD", "VMARKER"}; Modified: head/sys/kern/vfs_vnops.c == --- head/sys/kern/vfs_vnops.c Sun Feb 23 03:32:04 2020(r358256) +++ head/sys/kern/vfs_vnops.c Sun Feb 23 03:32:11 2020(r358257) @@ -1566,7 +1566,8 @@ vn_poll(struct file *fp, int events, struct ucred *act * permits vn_lock to return doomed vnodes. */ static int __noinline -_vn_lock_fallback(struct vnode *vp, int flags, char *file, int line, int error) +_vn_lock_fallback(struct vnode *vp, int flags, const char *file, int line, +int error) { KASSERT((flags & LK_RETRY) == 0 || error == 0, @@ -1602,7 +1603,7 @@ _vn_lock_fallback(struct vnode *vp, int flags, char *f } int -_vn_lock(struct vnode *vp, int flags, char *file, int line) +_vn_lock(struct vnode *vp, int flags, const char *file, int line) { int error; Modified: head/sys/kern/vnode_if.src == --- head/sys/kern/vnode_if.src Sun Feb 23 03:32:04 2020(r358256) +++ head/sys/kern/vnode_if.src Sun Feb 23 03:32:11 2020(r358257) @@ -380,7 +380,7 @@ vop_reclaim { vop_lock1 { IN struct vnode *vp; IN int flags; - IN char *file; + IN const char *file; IN int line; }; Modified: head/sys/sys/vnode.h == --- head/sys/sys/vnode.hSun Feb 23 03:32:04 2020(r358256) +++ head/sys/sys/vnode.hSun Feb 23 03:32:11 2020(r358257) @@ -689,7 +689,7 @@ int vn_generic_copy_file_range(struct vnode *invp, off struct thread *fsize_td); intvn_need_pageq_flush(struct vnode *vp); intvn_isdisk(struct vnode *vp, int *errp); -int_vn_lock(struct vnode *vp, int flags, char *file, int line); +int_vn_lock(struct vnode *vp, int flags, const char *file, int line); #define vn_lock(vp, flags) _vn_lock(vp, flags, __FILE__, __LINE__) intvn_open(struct nameidata *ndp, int *flagp, int cmode, struct file *fp); intvn_open_cred(struct nameidata *ndp, int *flagp, int cmode, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358256 - in head/sys: kern sys vm
Author: rlibby Date: Sun Feb 23 03:32:04 2020 New Revision: 358256 URL: https://svnweb.freebsd.org/changeset/base/358256 Log: sys/vm: quiet -Wwrite-strings Discussed with: kib Reviewed by: markj Differential Revision:https://reviews.freebsd.org/D23796 Modified: head/sys/kern/kern_malloc.c head/sys/sys/buf.h head/sys/vm/uma_core.c head/sys/vm/vm_map.c head/sys/vm/vm_object.c head/sys/vm/vm_object.h head/sys/vm/vm_page.c head/sys/vm/vm_pager.c Modified: head/sys/kern/kern_malloc.c == --- head/sys/kern/kern_malloc.c Sun Feb 23 03:13:38 2020(r358255) +++ head/sys/kern/kern_malloc.c Sun Feb 23 03:32:04 2020(r358256) @@ -153,7 +153,7 @@ static int numzones = MALLOC_DEBUG_MAXZONES; */ struct { int kz_size; - char *kz_name; + const char *kz_name; uma_zone_t kz_zone[MALLOC_DEBUG_MAXZONES]; } kmemzones[] = { {16, "16", }, @@ -1091,7 +1091,7 @@ mallocinit(void *dummy) UMA_ALIGN_PTR, UMA_ZONE_MALLOC); for (i = 0, indx = 0; kmemzones[indx].kz_size != 0; indx++) { int size = kmemzones[indx].kz_size; - char *name = kmemzones[indx].kz_name; + const char *name = kmemzones[indx].kz_name; int subzone; for (subzone = 0; subzone < numzones; subzone++) { Modified: head/sys/sys/buf.h == --- head/sys/sys/buf.h Sun Feb 23 03:13:38 2020(r358255) +++ head/sys/sys/buf.h Sun Feb 23 03:32:04 2020(r358256) @@ -554,7 +554,7 @@ voidbufdone(struct buf *); void bd_speedup(void); extern uma_zone_t pbuf_zone; -uma_zone_t pbuf_zsecond_create(char *name, int max); +uma_zone_t pbuf_zsecond_create(const char *name, int max); intcluster_read(struct vnode *, u_quad_t, daddr_t, long, struct ucred *, long, int, int, struct buf **); Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Sun Feb 23 03:13:38 2020(r358255) +++ head/sys/vm/uma_core.c Sun Feb 23 03:32:04 2020(r358256) @@ -223,7 +223,7 @@ struct uma_kctor_args { struct uma_bucket_zone { uma_zone_t ubz_zone; - char*ubz_name; + const char *ubz_name; int ubz_entries;/* Number of items it can hold. */ int ubz_maxsize;/* Maximum allocation size per-item. */ }; Modified: head/sys/vm/vm_map.c == --- head/sys/vm/vm_map.cSun Feb 23 03:13:38 2020(r358255) +++ head/sys/vm/vm_map.cSun Feb 23 03:32:04 2020(r358256) @@ -5108,7 +5108,7 @@ vm_map_print(vm_map_t map) (void *)entry, (void *)entry->start, (void *)entry->end, entry->eflags); { - static char *inheritance_name[4] = + static const char * const inheritance_name[4] = {"share", "copy", "none", "donate_copy"}; db_iprintf(" prot=%x/%x/%s", Modified: head/sys/vm/vm_object.c == --- head/sys/vm/vm_object.c Sun Feb 23 03:13:38 2020(r358255) +++ head/sys/vm/vm_object.c Sun Feb 23 03:32:04 2020(r358256) @@ -386,7 +386,7 @@ vm_object_pip_wakeupn(vm_object_t object, short i) * re-acquired on return. */ static void -vm_object_pip_sleep(vm_object_t object, char *waitid) +vm_object_pip_sleep(vm_object_t object, const char *waitid) { refcount_sleep_interlock(>paging_in_progress, @@ -394,7 +394,7 @@ vm_object_pip_sleep(vm_object_t object, char *waitid) } void -vm_object_pip_wait(vm_object_t object, char *waitid) +vm_object_pip_wait(vm_object_t object, const char *waitid) { VM_OBJECT_ASSERT_WLOCKED(object); @@ -406,7 +406,7 @@ vm_object_pip_wait(vm_object_t object, char *waitid) } void -vm_object_pip_wait_unlocked(vm_object_t object, char *waitid) +vm_object_pip_wait_unlocked(vm_object_t object, const char *waitid) { VM_OBJECT_ASSERT_UNLOCKED(object); Modified: head/sys/vm/vm_object.h == --- head/sys/vm/vm_object.h Sun Feb 23 03:13:38 2020(r358255) +++ head/sys/vm/vm_object.h Sun Feb 23 03:32:04 2020(r358256) @@ -337,8 +337,8 @@ void vm_object_clear_flag(vm_object_t object, u_short void vm_object_pip_add(vm_object_t object, short i); void vm_object_pip_wakeup(vm_object_t object); void vm_object_pip_wakeupn(vm_object_t object, short i); -void vm_object_pip_wait(vm_object_t object, char *waitid); -void vm_object_pip_wait_unlocked(vm_object_t object, char *waitid);
svn commit: r358094 - head/sys/powerpc/aim
Author: rlibby Date: Wed Feb 19 04:46:41 2020 New Revision: 358094 URL: https://svnweb.freebsd.org/changeset/base/358094 Log: powerpc: unconditionally mark SLB zones UMA_ZONE_CONTIG PR: 244118 Reported by: Francis Little Tested by:Francis Little, Mark Millard Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23729 Modified: head/sys/powerpc/aim/slb.c Modified: head/sys/powerpc/aim/slb.c == --- head/sys/powerpc/aim/slb.c Wed Feb 19 03:39:11 2020(r358093) +++ head/sys/powerpc/aim/slb.c Wed Feb 19 04:46:41 2020(r358094) @@ -523,18 +523,12 @@ slb_uma_real_alloc(uma_zone_t zone, vm_size_t bytes, i static void slb_zone_init(void *dummy) { - uint32_t allocf_flags; - - allocf_flags = 0; - if (platform_real_maxaddr() != VM_MAX_ADDRESS) - allocf_flags = UMA_ZONE_CONTIG; - slbt_zone = uma_zcreate("SLB tree node", sizeof(struct slbtnode), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, - allocf_flags | UMA_ZONE_VM); + UMA_ZONE_CONTIG | UMA_ZONE_VM); slb_cache_zone = uma_zcreate("SLB cache", (n_slbs + 1)*sizeof(struct slb *), NULL, NULL, NULL, NULL, - UMA_ALIGN_PTR, allocf_flags | UMA_ZONE_VM); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG | UMA_ZONE_VM); if (platform_real_maxaddr() != VM_MAX_ADDRESS) { uma_zone_set_allocf(slb_cache_zone, slb_uma_real_alloc); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357644 - head/sys/sys
Author: rlibby Date: Fri Feb 7 00:47:58 2020 New Revision: 357644 URL: https://svnweb.freebsd.org/changeset/base/357644 Log: smr.h: fix build after r357641 r357641 missed committing the change to sys/sys/smr.h. Reported by: jkim Submitted by: jeff Reviewed by: rlibby Differential Revision:https://reviews.freebsd.org/D23464 Modified: head/sys/sys/smr.h Modified: head/sys/sys/smr.h == --- head/sys/sys/smr.h Thu Feb 6 21:46:15 2020(r357643) +++ head/sys/sys/smr.h Fri Feb 7 00:47:58 2020(r357644) @@ -49,6 +49,7 @@ #defineSMR_SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) #defineSMR_SEQ_GT(a, b)((int32_t)((a)-(b)) > 0) #defineSMR_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) +#defineSMR_SEQ_DELTA(a, b) ((int32_t)((a)-(b))) #defineSMR_SEQ_INVALID 0 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357611 - head/libexec/rc/rc.d
Author: rlibby Date: Thu Feb 6 08:32:30 2020 New Revision: 357611 URL: https://svnweb.freebsd.org/changeset/base/357611 Log: auditd_stop: wait_for_pids instead of sleeping It's faster and more reliable to wait_for_pids than to sleep 1. cem@ suggested just to remove auditd_stop() and use the rc.subr default stop action (SIGTERM instead of audit -t), which has a built-in wait_for_pids. That may be a better solution. Discussed with: cem Reviewed by: asomers Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23223 Modified: head/libexec/rc/rc.d/auditd Modified: head/libexec/rc/rc.d/auditd == --- head/libexec/rc/rc.d/auditd Thu Feb 6 08:32:25 2020(r357610) +++ head/libexec/rc/rc.d/auditd Thu Feb 6 08:32:30 2020(r357611) @@ -26,7 +26,9 @@ auditd_stop() { /usr/sbin/audit -t - sleep 1 + if [ -n "$rc_pid" ]; then + wait_for_pids $rc_pid + fi } load_rc_config $name ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357610 - head/sys/vm
Author: rlibby Date: Thu Feb 6 08:32:25 2020 New Revision: 357610 URL: https://svnweb.freebsd.org/changeset/base/357610 Log: uma: remove UMA_ZFLAG_CACHEONLY flag UMA_ZFLAG_CACHEONLY was essentially the same thing as UMA_ZONE_VM, but with a more confusing name. Remove the flag, make UMA_ZONE_VM an inherit flag, and replace all references. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23516 Modified: head/sys/vm/uma.h head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/sys/vm/uma.h == --- head/sys/vm/uma.h Thu Feb 6 07:47:28 2020(r357609) +++ head/sys/vm/uma.h Thu Feb 6 08:32:25 2020(r357610) @@ -288,8 +288,8 @@ uma_zone_t uma_zcache_create(char *name, int size, uma */ #defineUMA_ZONE_INHERIT \ (UMA_ZONE_NOTOUCH | UMA_ZONE_MALLOC | UMA_ZONE_NOFREE |\ - UMA_ZONE_NOTPAGE | UMA_ZONE_PCPU | UMA_ZONE_FIRSTTOUCH | \ - UMA_ZONE_ROUNDROBIN) + UMA_ZONE_VM | UMA_ZONE_NOTPAGE | UMA_ZONE_PCPU | \ + UMA_ZONE_FIRSTTOUCH | UMA_ZONE_ROUNDROBIN) /* Definitions for align */ #define UMA_ALIGN_PTR (sizeof(void *) - 1)/* Alignment fit for ptr */ Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Thu Feb 6 07:47:28 2020(r357609) +++ head/sys/vm/uma_core.c Thu Feb 6 08:32:25 2020(r357610) @@ -493,7 +493,7 @@ bucket_alloc(uma_zone_t zone, void *udata, int flags) return (NULL); udata = (void *)((uintptr_t)udata | UMA_ZFLAG_BUCKET); } - if ((uintptr_t)udata & UMA_ZFLAG_CACHEONLY) + if (((uintptr_t)udata & UMA_ZONE_VM) != 0) flags |= M_NOVM; ubz = bucket_zone_lookup(zone->uz_bucket_size); if (ubz->ubz_zone == zone && (ubz + 1)->ubz_entries != 0) @@ -1897,8 +1897,7 @@ keg_layout(uma_keg_t keg) ("%s: cannot configure for PCPU: keg=%s, size=%u, flags=0x%b", __func__, keg->uk_name, keg->uk_size, keg->uk_flags, PRINT_UMA_ZFLAGS)); - KASSERT((keg->uk_flags & - (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY)) == 0 || + KASSERT((keg->uk_flags & (UMA_ZFLAG_INTERNAL | UMA_ZONE_VM)) == 0 || (keg->uk_flags & (UMA_ZONE_NOTOUCH | UMA_ZONE_PCPU)) == 0, ("%s: incompatible flags 0x%b", __func__, keg->uk_flags, PRINT_UMA_ZFLAGS)); @@ -1947,16 +1946,16 @@ keg_layout(uma_keg_t keg) /* * We can't do OFFPAGE if we're internal or if we've been * asked to not go to the VM for buckets. If we do this we -* may end up going to the VM for slabs which we do not -* want to do if we're UMA_ZFLAG_CACHEONLY as a result -* of UMA_ZONE_VM, which clearly forbids it. In those cases, -* evaluate a pseudo-format called INTERNAL which has an inline -* slab header and one extra page to guarantee that it fits. +* may end up going to the VM for slabs which we do not want +* to do if we're UMA_ZONE_VM, which clearly forbids it. +* In those cases, evaluate a pseudo-format called INTERNAL +* which has an inline slab header and one extra page to +* guarantee that it fits. * * Otherwise, see if using an OFFPAGE slab will improve our * efficiency. */ - if ((keg->uk_flags & (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY)) != 0) + if ((keg->uk_flags & (UMA_ZFLAG_INTERNAL | UMA_ZONE_VM)) != 0) fmts[nfmt++] = UMA_ZFLAG_INTERNAL; else fmts[nfmt++] = UMA_ZFLAG_OFFPAGE; @@ -2073,9 +2072,6 @@ keg_ctor(void *mem, int size, void *udata, int flags) zone = arg->zone; keg->uk_name = zone->uz_name; - if (arg->flags & UMA_ZONE_VM) - keg->uk_flags |= UMA_ZFLAG_CACHEONLY; - if (arg->flags & UMA_ZONE_ZINIT) keg->uk_init = zero_init; @@ -2461,8 +2457,6 @@ zone_ctor(void *mem, int size, void *udata, int flags) if (arg->import) { KASSERT((arg->flags & UMA_ZFLAG_CACHE) != 0, ("zone_ctor: Import specified for non-cache zone.")); - if (arg->flags & UMA_ZONE_VM) - arg->flags |= UMA_ZFLAG_CACHEONLY; zone->uz_flags = arg->flags; zone->uz_size = arg->size; zone->uz_import = arg->import; Modified: head/sys/vm/uma_int.h == --- head/sys/vm/uma_int.h Thu Feb 6 07:47:28 2020(r357609) +++ head/sys/vm/uma_int.h Thu Feb 6 08:32:25 2020(r357610) @@ -166,14 +166,12 @@ #defineUMA_ZFLAG_BUCKET0x1000
svn commit: r357548 - in head/sys: i386/i386 kern powerpc/aim
Author: rlibby Date: Tue Feb 4 22:40:23 2020 New Revision: 357548 URL: https://svnweb.freebsd.org/changeset/base/357548 Log: uma: convert mbuf_jumbo_alloc to UMA_ZONE_CONTIG & tag others Remove mbuf_jumbo_alloc and let large mbuf zones use the new uma default contig allocator (a copy of mbuf_jumbo_alloc). Tag other zones which require contiguous objects, even if they don't use the new default contig allocator, so that uma knows about their constraints. Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23238 Modified: head/sys/i386/i386/pmap.c head/sys/kern/kern_mbuf.c head/sys/powerpc/aim/slb.c Modified: head/sys/i386/i386/pmap.c == --- head/sys/i386/i386/pmap.c Tue Feb 4 22:40:11 2020(r357547) +++ head/sys/i386/i386/pmap.c Tue Feb 4 22:40:23 2020(r357548) @@ -1064,7 +1064,7 @@ __CONCAT(PMTYPE, init)(void) #ifdef PMAP_PAE_COMP pdptzone = uma_zcreate("PDPT", NPGPTD * sizeof(pdpt_entry_t), NULL, NULL, NULL, NULL, (NPGPTD * sizeof(pdpt_entry_t)) - 1, - UMA_ZONE_VM | UMA_ZONE_NOFREE); + UMA_ZONE_CONTIG | UMA_ZONE_VM | UMA_ZONE_NOFREE); uma_zone_set_allocf(pdptzone, pmap_pdpt_allocf); #endif Modified: head/sys/kern/kern_mbuf.c == --- head/sys/kern/kern_mbuf.c Tue Feb 4 22:40:11 2020(r357547) +++ head/sys/kern/kern_mbuf.c Tue Feb 4 22:40:23 2020(r357548) @@ -303,7 +303,6 @@ static void mb_dtor_pack(void *, int, void *); static int mb_zinit_pack(void *, int, int); static voidmb_zfini_pack(void *, int); static voidmb_reclaim(uma_zone_t, int); -static void*mbuf_jumbo_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int); /* Ensure that MSIZE is a power of 2. */ CTASSERTMSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE); @@ -323,7 +322,7 @@ mbuf_init(void *dummy) */ zone_mbuf = uma_zcreate(MBUF_MEM_NAME, MSIZE, mb_ctor_mbuf, mb_dtor_mbuf, NULL, NULL, - MSIZE - 1, UMA_ZONE_MAXBUCKET); + MSIZE - 1, UMA_ZONE_CONTIG | UMA_ZONE_MAXBUCKET); if (nmbufs > 0) nmbufs = uma_zone_set_max(zone_mbuf, nmbufs); uma_zone_set_warning(zone_mbuf, "kern.ipc.nmbufs limit reached"); @@ -331,7 +330,7 @@ mbuf_init(void *dummy) zone_clust = uma_zcreate(MBUF_CLUSTER_MEM_NAME, MCLBYTES, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbclusters > 0) nmbclusters = uma_zone_set_max(zone_clust, nmbclusters); uma_zone_set_warning(zone_clust, "kern.ipc.nmbclusters limit reached"); @@ -343,7 +342,7 @@ mbuf_init(void *dummy) /* Make jumbo frame zone too. Page size, 9k and 16k. */ zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbjumbop > 0) nmbjumbop = uma_zone_set_max(zone_jumbop, nmbjumbop); uma_zone_set_warning(zone_jumbop, "kern.ipc.nmbjumbop limit reached"); @@ -351,8 +350,7 @@ mbuf_init(void *dummy) zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); - uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbjumbo9 > 0) nmbjumbo9 = uma_zone_set_max(zone_jumbo9, nmbjumbo9); uma_zone_set_warning(zone_jumbo9, "kern.ipc.nmbjumbo9 limit reached"); @@ -360,8 +358,7 @@ mbuf_init(void *dummy) zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); - uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbjumbo16 > 0) nmbjumbo16 = uma_zone_set_max(zone_jumbo16, nmbjumbo16); uma_zone_set_warning(zone_jumbo16, "kern.ipc.nmbjumbo16 limit reached"); @@ -613,24 +610,6 @@ debugnet_mbuf_reinit(int nmbuf, int nclust, int clsize } } #endif /* DEBUGNET */ - -/* - * UMA backend page allocator for the jumbo frame zones. - * - * Allocates kernel virtual memory that is backed by contiguous physical - * pages. - */ -static void * -mbuf_jumbo_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *flags, -int wait) -{ - - /* Inform UMA that this allocator uses kernel_map/object. */ - *flags = UMA_SLAB_KERNEL; - return ((void *)kmem_alloc_contig_domainset(DOMAINSET_FIXED(domain), - bytes, wait, (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0, - VM_MEMATTR_DEFAULT)); -} /* * Constructor for Mbuf master zone. Modified:
svn commit: r357547 - in head: share/man/man9 sys/vm
Author: rlibby Date: Tue Feb 4 22:40:11 2020 New Revision: 357547 URL: https://svnweb.freebsd.org/changeset/base/357547 Log: uma: add UMA_ZONE_CONTIG, and a default contig_alloc For now, copy the mbuf allocator. Reviewed by: jeff, markj (previous version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23237 Modified: head/share/man/man9/zone.9 head/sys/vm/uma.h head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/share/man/man9/zone.9 == --- head/share/man/man9/zone.9 Tue Feb 4 22:39:58 2020(r357546) +++ head/share/man/man9/zone.9 Tue Feb 4 22:40:11 2020(r357547) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 8, 2020 +.Dd February 4, 2020 .Dt UMA 9 .Os .Sh NAME @@ -340,6 +340,10 @@ was allocated will cause mixing in per-CPU caches. See .Xr numa 4 for more details. +.It Dv UMA_ZONE_CONTIG +Items in this zone must be contiguous in physical address space. +Items will follow normal alignment constraints and may span page boundaries +between pages with contiguous physical addresses. .El .Pp Zones can be destroyed using @@ -465,12 +469,8 @@ and .Fn uma_zone_set_freef functions allow a zone's default slab allocation and free functions to be overridden. -This is useful if the zone's items have special memory allocation constraints. -For example, if multi-page objects are required to be physically contiguous, -an -.Fa allocf -function which requests contiguous memory from the kernel's page allocator -may be used. +This is useful if memory with special constraints such as attributes, +alignment, or address ranges must be used. .Pp The .Fn uma_zone_set_max Modified: head/sys/vm/uma.h == --- head/sys/vm/uma.h Tue Feb 4 22:39:58 2020(r357546) +++ head/sys/vm/uma.h Tue Feb 4 22:40:11 2020(r357547) @@ -236,6 +236,10 @@ uma_zone_t uma_zcache_create(char *name, int size, uma * overlap when adding new features. */ #define UMA_ZONE_ZINIT 0x0002 /* Initialize with zeros */ +#define UMA_ZONE_CONTIG0x0004 /* +* Physical memory underlying an object +* must be contiguous. +*/ #define UMA_ZONE_NOTOUCH 0x0008 /* UMA may not access the memory */ #define UMA_ZONE_MALLOC0x0010 /* For use by malloc(9) only! */ #define UMA_ZONE_NOFREE0x0020 /* Do not free slabs of this type! */ @@ -639,8 +643,7 @@ smr_t uma_zone_get_smr(uma_zone_t zone); #define UMA_SLAB_BOOT 0x01/* Slab alloced from boot pages */ #define UMA_SLAB_KERNEL0x04/* Slab alloced from kmem */ #define UMA_SLAB_PRIV 0x08/* Slab alloced from priv allocator */ -#define UMA_SLAB_OFFP 0x10/* Slab is managed separately */ -/* 0x02, 0x40, and 0x80 are available */ +/* 0x02, 0x10, 0x40, and 0x80 are available */ /* * Used to pre-fill a zone with some number of items Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Tue Feb 4 22:39:58 2020(r357546) +++ head/sys/vm/uma_core.c Tue Feb 4 22:40:11 2020(r357547) @@ -271,6 +271,7 @@ static void *noobj_alloc(uma_zone_t, vm_size_t, int, u static void *page_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int); static void *pcpu_page_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int); static void *startup_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int); +static void *contig_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int); static void page_free(void *, vm_size_t, uint8_t); static void pcpu_page_free(void *, vm_size_t, uint8_t); static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int, int, int); @@ -1660,6 +1661,19 @@ noobj_alloc(uma_zone_t zone, vm_size_t bytes, int doma } /* + * Allocate physically contiguous pages. + */ +static void * +contig_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *pflag, +int wait) +{ + + *pflag = UMA_SLAB_KERNEL; + return ((void *)kmem_alloc_contig_domainset(DOMAINSET_FIXED(domain), + bytes, wait, 0, ~(vm_paddr_t)0, 1, 0, VM_MEMATTR_DEFAULT)); +} + +/* * Frees a number of pages to the system * * Arguments: @@ -1679,8 +1693,8 @@ page_free(void *mem, vm_size_t size, uint8_t flags) return; } - if ((flags & UMA_SLAB_KERNEL) == 0) - panic("UMA: page_free used with invalid flags %x", flags); + KASSERT((flags & UMA_SLAB_KERNEL) != 0, + ("UMA: page_free used with invalid flags %x", flags)); kmem_free((vm_offset_t)mem, size); } @@ -2044,6 +2058,8 @@ keg_ctor(void *mem, int size, void *udata, int flags)
svn commit: r357549 - head/sys/vm
Author: rlibby Date: Tue Feb 4 22:40:34 2020 New Revision: 357549 URL: https://svnweb.freebsd.org/changeset/base/357549 Log: uma: grow slabs to enforce minimum memory efficiency Memory efficiency can be poor with awkward item sizes (e.g. 1/2 or 1 page size + epsilon). In order to achieve a minimum memory efficiency, select a slab size with a potentially larger number of pages if it yields a lower portion of waste. This may mean using page_alloc instead of uma_small_alloc, which could be more costly. Discussed with: jeff, mckusick Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23239 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Tue Feb 4 22:40:23 2020(r357548) +++ head/sys/vm/uma_core.c Tue Feb 4 22:40:34 2020(r357549) @@ -1830,6 +1830,39 @@ slab_ipers(size_t size, int align) return (slab_ipers_hdr(size, rsize, UMA_SLAB_SIZE, true)); } +struct keg_layout_result { + u_int format; + u_int slabsize; + u_int ipers; + u_int eff; +}; + +static void +keg_layout_one(uma_keg_t keg, u_int rsize, u_int slabsize, u_int fmt, +struct keg_layout_result *kl) +{ + u_int total; + + kl->format = fmt; + kl->slabsize = slabsize; + + /* Handle INTERNAL as inline with an extra page. */ + if ((fmt & UMA_ZFLAG_INTERNAL) != 0) { + kl->format &= ~UMA_ZFLAG_INTERNAL; + kl->slabsize += PAGE_SIZE; + } + + kl->ipers = slab_ipers_hdr(keg->uk_size, rsize, kl->slabsize, + (fmt & UMA_ZFLAG_OFFPAGE) == 0); + + /* Account for memory used by an offpage slab header. */ + total = kl->slabsize; + if ((fmt & UMA_ZFLAG_OFFPAGE) != 0) + total += slabzone(kl->ipers)->uz_keg->uk_rsize; + + kl->eff = UMA_FRAC_FIXPT(kl->ipers * rsize, total); +} + /* * Determine the format of a uma keg. This determines where the slab header * will be placed (inline or offpage) and calculates ipers, rsize, and ppera. @@ -1843,15 +1876,14 @@ slab_ipers(size_t size, int align) static void keg_layout(uma_keg_t keg) { + struct keg_layout_result kl = {}, kl_tmp; + u_int fmts[2]; u_int alignsize; - u_int eff; - u_int eff_offpage; - u_int format; - u_int ipers; - u_int ipers_offpage; + u_int nfmt; u_int pages; u_int rsize; u_int slabsize; + u_int i, j; KASSERT((keg->uk_flags & UMA_ZONE_PCPU) == 0 || (keg->uk_size <= UMA_PCPU_ALLOC_SIZE && @@ -1866,8 +1898,6 @@ keg_layout(uma_keg_t keg) PRINT_UMA_ZFLAGS)); alignsize = keg->uk_align + 1; - format = 0; - ipers = 0; /* * Calculate the size of each allocation (rsize) according to @@ -1877,10 +1907,7 @@ keg_layout(uma_keg_t keg) rsize = MAX(keg->uk_size, UMA_SMALLEST_UNIT); rsize = roundup2(rsize, alignsize); - if ((keg->uk_flags & UMA_ZONE_PCPU) != 0) { - slabsize = UMA_PCPU_ALLOC_SIZE; - pages = mp_maxid + 1; - } else if ((keg->uk_flags & UMA_ZONE_CACHESPREAD) != 0) { + if ((keg->uk_flags & UMA_ZONE_CACHESPREAD) != 0) { /* * We want one item to start on every align boundary in a page. * To do this we will span pages. We will also extend the item @@ -1892,23 +1919,22 @@ keg_layout(uma_keg_t keg) slabsize = rsize * (PAGE_SIZE / alignsize); slabsize = MIN(slabsize, rsize * SLAB_MAX_SETSIZE); slabsize = MIN(slabsize, UMA_CACHESPREAD_MAX_SIZE); - pages = howmany(slabsize, PAGE_SIZE); - slabsize = ptoa(pages); + slabsize = round_page(slabsize); } else { /* -* Choose a slab size of as many pages as it takes to represent -* a single item. We will then try to fit as many additional -* items into the slab as possible. At some point, we may want -* to increase the slab size for awkward item sizes in order to -* increase efficiency. +* Start with a slab size of as many pages as it takes to +* represent a single item. We will try to fit as many +* additional items into the slab as possible. */ - pages = howmany(keg->uk_size, PAGE_SIZE); - slabsize = ptoa(pages); + slabsize = round_page(keg->uk_size); } + /* Build a list of all of the available formats for this keg. */ + nfmt = 0; + /* Evaluate an inline slab layout. */ if ((keg->uk_flags & (UMA_ZONE_NOTOUCH | UMA_ZONE_PCPU)) == 0) - ipers = slab_ipers_hdr(keg->uk_size, rsize,
svn commit: r357550 - head/sys/vm
Author: rlibby Date: Tue Feb 4 22:40:45 2020 New Revision: 357550 URL: https://svnweb.freebsd.org/changeset/base/357550 Log: uma: multipage chicken switch Add a switch to allow disabling multipage slabs, in order to facilitate measuring memory usage and performance effects. The tunable vm.debug.uma_multipage_slabs defaults to 1 and can be set to 0 to disable. The name may change soon. Reviewed by: markj (previous version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23487 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Tue Feb 4 22:40:34 2020(r357549) +++ head/sys/vm/uma_core.c Tue Feb 4 22:40:45 2020(r357550) @@ -323,6 +323,9 @@ static int sysctl_handle_uma_zone_items(SYSCTL_HANDLER static uint64_t uma_zone_get_allocs(uma_zone_t zone); +static SYSCTL_NODE(_vm, OID_AUTO, debug, CTLFLAG_RD, 0, +"Memory allocation debugging"); + #ifdef INVARIANTS static uint64_t uma_keg_get_allocs(uma_keg_t zone); static inline struct noslabbits *slab_dbg_bits(uma_slab_t slab, uma_keg_t keg); @@ -332,9 +335,6 @@ static bool uma_dbg_zskip(uma_zone_t zone, void *mem); static void uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *item); static void uma_dbg_alloc(uma_zone_t zone, uma_slab_t slab, void *item); -static SYSCTL_NODE(_vm, OID_AUTO, debug, CTLFLAG_RD, 0, -"Memory allocation debugging"); - static u_int dbg_divisor = 1; SYSCTL_UINT(_vm_debug, OID_AUTO, divisor, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, _divisor, 0, @@ -362,6 +362,12 @@ static int zone_warnings = 1; SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RWTUN, _warnings, 0, "Warn when UMA zones becomes full"); +static int multipage_slabs = 1; +TUNABLE_INT("vm.debug.uma_multipage_slabs", _slabs); +SYSCTL_INT(_vm_debug, OID_AUTO, uma_multipage_slabs, +CTLFLAG_RDTUN | CTLFLAG_NOFETCH, _slabs, 0, +"UMA may choose larger slab sizes for better efficiency"); + /* * Select the slab zone for an offpage slab with the given maximum item count. */ @@ -1993,7 +1999,7 @@ keg_layout(uma_keg_t keg) break; } - if (kl.eff >= UMA_MIN_EFF || + if (kl.eff >= UMA_MIN_EFF || !multipage_slabs || slabsize >= SLAB_MAX_SETSIZE * rsize || (keg->uk_flags & (UMA_ZONE_PCPU | UMA_ZONE_CONTIG)) != 0) break; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357546 - head/sys/vm
Author: rlibby Date: Tue Feb 4 22:39:58 2020 New Revision: 357546 URL: https://svnweb.freebsd.org/changeset/base/357546 Log: uma: pcpu_page_free needs to startup_free pages from startup_alloc After r357392, it is apparent that we do have some early-boot PCPU zones. Make it so we can safely free pages from them if they are actually used during early boot. Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23496 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Tue Feb 4 21:43:39 2020(r357545) +++ head/sys/vm/uma_core.c Tue Feb 4 22:39:58 2020(r357546) @@ -1704,6 +1704,12 @@ pcpu_page_free(void *mem, vm_size_t size, uint8_t flag vm_page_t m; MPASS(size == (mp_maxid+1)*PAGE_SIZE); + + if ((flags & UMA_SLAB_BOOT) != 0) { + startup_free(mem, size); + return; + } + sva = (vm_offset_t)mem; for (curva = sva; curva < sva + size; curva += PAGE_SIZE) { paddr = pmap_kextract(curva); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357019 - head/sys/vm
Author: rlibby Date: Thu Jan 23 04:56:38 2020 New Revision: 357019 URL: https://svnweb.freebsd.org/changeset/base/357019 Log: uma: fix zone domain overlaying pcpu cache with disabled cpus UMA zone structures have two arrays at the end which are sized according to the machine: an array of CPU count length, and an array of NUMA domain count length. The CPU counting was wrong in the case where some CPUs are disabled (when mp_ncpus != mp_maxid + 1), and this caused the second array to be overlaid with the first. Reported by: olivier Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23318 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Thu Jan 23 04:56:34 2020(r357018) +++ head/sys/vm/uma_core.c Thu Jan 23 04:56:38 2020(r357019) @@ -2297,7 +2297,8 @@ zone_ctor(void *mem, int size, void *udata, int flags) zone->uz_flags = 0; zone->uz_warning = NULL; /* The domain structures follow the cpu structures. */ - zone->uz_domain = (struct uma_zone_domain *)>uz_cpu[mp_ncpus]; + zone->uz_domain = + (struct uma_zone_domain *)>uz_cpu[mp_maxid + 1]; zone->uz_bkt_max = ULONG_MAX; timevalclear(>uz_ratecheck); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357018 - head/sys/vm
Author: rlibby Date: Thu Jan 23 04:56:34 2020 New Revision: 357018 URL: https://svnweb.freebsd.org/changeset/base/357018 Log: uma: report leaks more accurately Previously UMA had some false negatives in the leak report at keg destruction time, where it only reported leaks if there were free items in the slab layer (rather than allocated items), which notably would not be true for single-item slabs (large items). Now, report a leak if there are any allocated pages, and calculate and report the number of allocated items rather than free items. Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23275 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Thu Jan 23 04:54:49 2020(r357017) +++ head/sys/vm/uma_core.c Thu Jan 23 04:56:34 2020(r357018) @@ -2440,11 +2440,11 @@ keg_dtor(void *arg, int size, void *udata) pages += keg->uk_domain[i].ud_pages; KEG_LOCK_FINI(keg, i); } - if (free != 0) + if (pages != 0) printf("Freed UMA keg (%s) was not empty (%u items). " " Lost %u pages of memory.\n", keg->uk_name ? keg->uk_name : "", - free, pages); + pages / keg->uk_ppera * keg->uk_ipers - free, pages); hash_free(>uk_hash); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r356919 - head/sys/x86/x86
On Mon, Jan 20, 2020 at 9:23 AM Konstantin Belousov wrote: > > Author: kib > Date: Mon Jan 20 17:23:03 2020 > New Revision: 356919 > URL: https://svnweb.freebsd.org/changeset/base/356919 > > Log: > x86: Wait for curthread to be set up as an indicator that the boot stack > is no longer used. > > pc_curthread is set by cpu_switch after it stopped using the old > thread (or boot) stack. This makes the smp_after_idle_runnable() > function not dependent on the internals of the scheduler operations. > > Reviewed by: markj > Sponsored by: The FreeBSD Foundation > MFC after:1 week > Differential revision:https://reviews.freebsd.org/D23276 > > Modified: > head/sys/x86/x86/mp_x86.c > > Modified: head/sys/x86/x86/mp_x86.c > == > --- head/sys/x86/x86/mp_x86.c Mon Jan 20 16:59:39 2020(r356918) > +++ head/sys/x86/x86/mp_x86.c Mon Jan 20 17:23:03 2020(r356919) > @@ -1092,13 +1092,12 @@ init_secondary_tail(void) > static void > smp_after_idle_runnable(void *arg __unused) > { > - struct thread *idle_td; > + struct pcpu *pc; > int cpu; > > for (cpu = 1; cpu < mp_ncpus; cpu++) { > - idle_td = pcpu_find(cpu)->pc_idlethread; > - while (atomic_load_int(_td->td_lastcpu) == NOCPU && > - atomic_load_int(_td->td_oncpu) == NOCPU) > + pc = pcpu_find(cpu); > + while (atomic_load_ptr(>pc_curthread) == (uintptr_t)NULL) > cpu_spinwait(); > kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages * > PAGE_SIZE); > ___ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org" I'm hitting a boot panic on a KVM VM that I think is because of this. I don't think this works as advertised, because init_secondary_tail sets curthread to its idlethread *itself* before it calls sched_switch. So I think the current check is not enough to know that we're actually off the bootstack. My panic is an AP page faults in the middle of init_secondary_tail, after curthread is set. Weirdly, I only seem to hit it when I have disabled some CPUs (to test D23318). I think this must just be affecting some aspect of the timing. Ryan ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356716 - head/sys/kern
Author: rlibby Date: Tue Jan 14 02:14:02 2020 New Revision: 356716 URL: https://svnweb.freebsd.org/changeset/base/356716 Log: malloc: remove assumptions about MINALLOCSIZE Remove assumptions about the minimum MINALLOCSIZE, in order to allow testing of smaller MINALLOCSIZE. A following patch will lower the MINALLOCSIZE, but not so much that the present patch is required for correctness at these sites. Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Modified: head/sys/kern/kern_prot.c head/sys/kern/subr_bus.c Modified: head/sys/kern/kern_prot.c == --- head/sys/kern/kern_prot.c Tue Jan 14 02:13:46 2020(r356715) +++ head/sys/kern/kern_prot.c Tue Jan 14 02:14:02 2020(r356716) @@ -2054,7 +2054,7 @@ crextend(struct ucred *cr, int n) */ if ( n < PAGE_SIZE / sizeof(gid_t) ) { if (cr->cr_agroups == 0) - cnt = MINALLOCSIZE / sizeof(gid_t); + cnt = MAX(1, MINALLOCSIZE / sizeof(gid_t)); else cnt = cr->cr_agroups * 2; Modified: head/sys/kern/subr_bus.c == --- head/sys/kern/subr_bus.cTue Jan 14 02:13:46 2020(r356715) +++ head/sys/kern/subr_bus.cTue Jan 14 02:14:02 2020(r356716) @@ -1686,7 +1686,8 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int * int newsize; oldlist = dc->devices; - newsize = roundup((unit + 1), MINALLOCSIZE / sizeof(device_t)); + newsize = roundup((unit + 1), + MAX(1, MINALLOCSIZE / sizeof(device_t))); newlist = malloc(sizeof(device_t) * newsize, M_BUS, M_NOWAIT); if (!newlist) return (ENOMEM); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356717 - head/sys/vm
Author: rlibby Date: Tue Jan 14 02:14:15 2020 New Revision: 356717 URL: https://svnweb.freebsd.org/changeset/base/356717 Log: uma: split slabzone into two sizes By allowing more items per slab, we can improve memory efficiency for small allocs. If we were just to increase the bitmap size of the slabzone, we would then waste slabzone memory. So, split slabzone into two zones, one especially for 8-byte allocs (512 per slab). The practical effect should be reduced memory usage for counter(9). Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23149 Modified: head/sys/vm/uma.h head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/sys/vm/uma.h == --- head/sys/vm/uma.h Tue Jan 14 02:14:02 2020(r356716) +++ head/sys/vm/uma.h Tue Jan 14 02:14:15 2020(r356717) @@ -42,7 +42,7 @@ #include /* For M_* */ /* User visible parameters */ -#define UMA_SMALLEST_UNIT (PAGE_SIZE / 256) /* Smallest item allocated */ +#defineUMA_SMALLEST_UNIT 8 /* Smallest item allocated */ /* Types and type defs */ Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Tue Jan 14 02:14:02 2020(r356716) +++ head/sys/vm/uma_core.c Tue Jan 14 02:14:15 2020(r356717) @@ -107,8 +107,21 @@ __FBSDID("$FreeBSD$"); static uma_zone_t kegs; static uma_zone_t zones; -/* This is the zone from which all offpage uma_slab_ts are allocated. */ -static uma_zone_t slabzone; +/* + * These are the two zones from which all offpage uma_slab_ts are allocated. + * + * One zone is for slab headers that can represent a larger number of items, + * making the slabs themselves more efficient, and the other zone is for + * headers that are smaller and represent fewer items, making the headers more + * efficient. + */ +#defineSLABZONE_SIZE(setsize) \ +(sizeof(struct uma_hash_slab) + BITSET_SIZE(setsize) * SLAB_BITSETS) +#defineSLABZONE0_SETSIZE (PAGE_SIZE / 16) +#defineSLABZONE1_SETSIZE SLAB_MAX_SETSIZE +#defineSLABZONE0_SIZE SLABZONE_SIZE(SLABZONE0_SETSIZE) +#defineSLABZONE1_SIZE SLABZONE_SIZE(SLABZONE1_SETSIZE) +static uma_zone_t slabzones[2]; /* * The initial hash tables come out of this zone so they can be allocated @@ -341,6 +354,16 @@ SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RWTUN "Warn when UMA zones becomes full"); /* + * Select the slab zone for an offpage slab with the given maximum item count. + */ +static inline uma_zone_t +slabzone(int ipers) +{ + + return (slabzones[ipers > SLABZONE0_SETSIZE]); +} + +/* * This routine checks to see whether or not it's safe to enable buckets. */ static void @@ -1169,7 +1192,8 @@ keg_free_slab(uma_keg_t keg, uma_slab_t slab, int star keg->uk_fini(slab_item(slab, keg, i), keg->uk_size); } if (keg->uk_flags & UMA_ZFLAG_OFFPAGE) - zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE); + zone_free_item(slabzone(keg->uk_ipers), slab_tohashslab(slab), + NULL, SKIP_NONE); keg->uk_freef(mem, PAGE_SIZE * keg->uk_ppera, flags); uma_total_dec(PAGE_SIZE * keg->uk_ppera); } @@ -1302,9 +1326,12 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom slab = NULL; mem = NULL; if (keg->uk_flags & UMA_ZFLAG_OFFPAGE) { - slab = zone_alloc_item(keg->uk_slabzone, NULL, domain, aflags); - if (slab == NULL) + uma_hash_slab_t hslab; + hslab = zone_alloc_item(slabzone(keg->uk_ipers), NULL, + domain, aflags); + if (hslab == NULL) goto fail; + slab = >uhs_slab; } /* @@ -1327,7 +1354,8 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom mem = allocf(zone, size, domain, , aflags); if (mem == NULL) { if (keg->uk_flags & UMA_ZFLAG_OFFPAGE) - zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE); + zone_free_item(slabzone(keg->uk_ipers), + slab_tohashslab(slab), NULL, SKIP_NONE); goto fail; } uma_total_inc(size); @@ -1340,7 +1368,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom if (!(keg->uk_flags & UMA_ZFLAG_OFFPAGE)) slab = (uma_slab_t )(mem + keg->uk_pgoff); else - ((uma_hash_slab_t)slab)->uhs_data = mem; + slab_tohashslab(slab)->uhs_data = mem; if (keg->uk_flags & UMA_ZFLAG_VTOSLAB) for (i = 0; i < keg->uk_ppera; i++) @@ -1769,7 +1797,7 @@ keg_layout(uma_keg_t keg) *
svn commit: r356715 - head/sys/vm
Author: rlibby Date: Tue Jan 14 02:13:46 2020 New Revision: 356715 URL: https://svnweb.freebsd.org/changeset/base/356715 Log: uma: fixup some ktr messages Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23148 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Tue Jan 14 02:00:24 2020(r356714) +++ head/sys/vm/uma_core.c Tue Jan 14 02:13:46 2020(r356715) @@ -1841,7 +1841,7 @@ keg_layout(uma_keg_t keg) if (ipers == 0 || (eff < UMA_MIN_EFF && eff < eff_offpage)) { CTR5(KTR_UMA, "UMA decided we need offpage slab headers for " "keg: %s(%p), minimum efficiency allowed = %u%%, " - "old efficiency = %u%%, offpage efficiency = %u%%\n", + "old efficiency = %u%%, offpage efficiency = %u%%", keg->uk_name, keg, UMA_FIXPT_PCT(UMA_MIN_EFF), UMA_FIXPT_PCT(eff), UMA_FIXPT_PCT(eff_offpage)); format = UMA_ZFLAG_OFFPAGE; @@ -1865,7 +1865,7 @@ out: keg->uk_rsize = rsize; keg->uk_flags |= format; keg->uk_ppera = pages; - CTR6(KTR_UMA, "%s: keg=%s, flags=%#x, rsize=%u, ipers=%u, ppera=%u\n", + CTR6(KTR_UMA, "%s: keg=%s, flags=%#x, rsize=%u, ipers=%u, ppera=%u", __func__, keg->uk_name, keg->uk_flags, rsize, ipers, pages); KASSERT(keg->uk_ipers > 0 && keg->uk_ipers <= SLAB_MAX_SETSIZE, ("%s: keg=%s, flags=0x%b, rsize=%u, ipers=%u, ppera=%u", __func__, @@ -1999,7 +1999,7 @@ keg_ctor(void *mem, int size, void *udata, int flags) if (keg->uk_flags & UMA_ZFLAG_HASH) hash_alloc(>uk_hash, 0); - CTR3(KTR_UMA, "keg_ctor %p zone %s(%p)\n", keg, zone->uz_name, zone); + CTR3(KTR_UMA, "keg_ctor %p zone %s(%p)", keg, zone->uz_name, zone); LIST_INSERT_HEAD(>uk_zones, zone, uz_link); @@ -2935,8 +2935,8 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags random_harvest_fast_uma(, sizeof(zone), RANDOM_UMA); /* This is the fast path allocation */ - CTR4(KTR_UMA, "uma_zalloc_arg thread %x zone %s(%p) flags %d", - curthread, zone->uz_name, zone, flags); + CTR3(KTR_UMA, "uma_zalloc_arg zone %s(%p) flags %d", zone->uz_name, + zone, flags); #ifdef WITNESS if (flags & M_WAITOK) { @@ -3151,9 +3151,8 @@ uma_zalloc_domain(uma_zone_t zone, void *udata, int do random_harvest_fast_uma(, sizeof(zone), RANDOM_UMA); /* This is the fast path allocation */ - CTR5(KTR_UMA, - "uma_zalloc_domain thread %x zone %s(%p) domain %d flags %d", - curthread, zone->uz_name, zone, domain, flags); + CTR4(KTR_UMA, "uma_zalloc_domain zone %s(%p) domain %d flags %d", + zone->uz_name, zone, domain, flags); if (flags & M_WAITOK) { WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, @@ -3523,7 +3522,8 @@ zone_alloc_bucket(uma_zone_t zone, void *udata, int do uma_bucket_t bucket; int maxbucket, cnt; - CTR1(KTR_UMA, "zone_alloc:_bucket domain %d)", domain); + CTR3(KTR_UMA, "zone_alloc_bucket zone %s(%p) domain %d", zone->uz_name, + zone, domain); /* Avoid allocs targeting empty domains. */ if (domain != UMA_ANYDOMAIN && VM_DOMAIN_EMPTY(domain)) @@ -3658,8 +3658,7 @@ uma_zfree_arg(uma_zone_t zone, void *item, void *udata /* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */ random_harvest_fast_uma(, sizeof(zone), RANDOM_UMA); - CTR2(KTR_UMA, "uma_zfree_arg thread %x zone %s", curthread, - zone->uz_name); + CTR2(KTR_UMA, "uma_zfree_arg zone %s(%p)", zone->uz_name, zone); KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(), ("uma_zfree_arg: called with spinlock or critical section held")); @@ -3960,8 +3959,7 @@ uma_zfree_domain(uma_zone_t zone, void *item, void *ud /* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */ random_harvest_fast_uma(, sizeof(zone), RANDOM_UMA); - CTR2(KTR_UMA, "uma_zfree_domain thread %x zone %s", curthread, - zone->uz_name); + CTR2(KTR_UMA, "uma_zfree_domain zone %s(%p)", zone->uz_name, zone); KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(), ("uma_zfree_domain: called with spinlock or critical section held")); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r356613 - head/sys/dev/virtio/network
On Fri, Jan 10, 2020 at 1:22 PM Gleb Smirnoff wrote: > > Author: glebius > Date: Fri Jan 10 21:22:03 2020 > New Revision: 356613 > URL: https://svnweb.freebsd.org/changeset/base/356613 > > Log: > Add pfil(9) hook to vtnet(4). > > The patch could be simplier, using only the second chunk to > vtnet_rxq_eof(), that passes full mbufs to pfil(9). Packet > filter would m_free() them in case of returning PFIL_DROPPED. > > However, we pretend to be a hardware driver, so we first try > to pass a memory buffer via PFIL_MEMPTR feature. This is mostly > done for debugging purposes, so that one can experiment in bhyve > with packet filters utilizing same features as a true driver. > > Modified: > head/sys/dev/virtio/network/if_vtnet.c > head/sys/dev/virtio/network/if_vtnetvar.h > > Modified: head/sys/dev/virtio/network/if_vtnet.c > == > --- head/sys/dev/virtio/network/if_vtnet.c Fri Jan 10 20:53:58 2020 > (r356612) > +++ head/sys/dev/virtio/network/if_vtnet.c Fri Jan 10 21:22:03 2020 > (r356613) > @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); > > #include > #include > +#include > #include > #include > #include > @@ -935,6 +936,7 @@ static int > vtnet_setup_interface(struct vtnet_softc *sc) > { > device_t dev; > + struct pfil_head_args pa; > struct ifnet *ifp; > > dev = sc->vtnet_dev; > @@ -1038,6 +1040,12 @@ vtnet_setup_interface(struct vtnet_softc *sc) > > DEBUGNET_SET(ifp, vtnet); > > + pa.pa_version = PFIL_VERSION; > + pa.pa_flags = PFIL_IN; > + pa.pa_type = PFIL_TYPE_ETHERNET; > + pa.pa_headname = ifp->if_xname; > + sc->vtnet_pfil = pfil_head_register(); > + > return (0); > } > > @@ -1773,9 +1781,11 @@ vtnet_rxq_eof(struct vtnet_rxq *rxq) > struct vtnet_softc *sc; > struct ifnet *ifp; > struct virtqueue *vq; > - struct mbuf *m; > + struct mbuf *m, *mr; > struct virtio_net_hdr_mrg_rxbuf *mhdr; > int len, deq, nbufs, adjsz, count; > + pfil_return_t pfil; > + bool pfil_done; > > sc = rxq->vtnrx_sc; > vq = rxq->vtnrx_vq; > @@ -1812,6 +1822,35 @@ vtnet_rxq_eof(struct vtnet_rxq *rxq) > adjsz = sizeof(struct virtio_net_hdr_mrg_rxbuf); > } > > + /* > +* If we have enough data in first mbuf, run it through > +* pfil as a memory buffer before dequeueing the rest. > +*/ > + if (PFIL_HOOKED_IN(sc->vtnet_pfil) && > + len - adjsz >= ETHER_HDR_LEN + max_protohdr) { > + pfil = pfil_run_hooks(sc->vtnet_pfil, > + m->m_data + adjsz, ifp, > + len - adjsz | PFIL_MEMPTR | PFIL_IN, NULL); Hi Gleb, gcc wants (len - adjsz) paranthesized. https://ci.freebsd.org/job/FreeBSD-head-amd64-gcc/12838/ --- if_vtnet.o --- /workspace/src/sys/dev/virtio/network/if_vtnet.c: In function 'vtnet_rxq_eof': /workspace/src/sys/dev/virtio/network/if_vtnet.c:1833:12: error: suggest parentheses around arithmetic in operand of '|' [-Werror=parentheses] len - adjsz | PFIL_MEMPTR | PFIL_IN, NULL); ^~~ > + switch (pfil) { > + case PFIL_REALLOCED: > + mr = pfil_mem2mbuf(m->m_data + adjsz); > + vtnet_rxq_input(rxq, mr, hdr); > + /* FALLTHROUGH */ > + case PFIL_DROPPED: > + case PFIL_CONSUMED: > + vtnet_rxq_discard_buf(rxq, m); > + if (nbufs > 1) > + vtnet_rxq_discard_merged_bufs(rxq, > + nbufs); > + continue; > + default: > + KASSERT(pfil == PFIL_PASS, > + ("Filter returned %d!\n", pfil)); > + }; > + pfil_done = true; > + } else > + pfil_done = false; > + > if (vtnet_rxq_replace_buf(rxq, m, len) != 0) { > rxq->vtnrx_stats.vrxs_iqdrops++; > vtnet_rxq_discard_buf(rxq, m); > @@ -1841,6 +1880,19 @@ vtnet_rxq_eof(struct vtnet_rxq *rxq) > */ > memcpy(hdr, mtod(m, void *), sizeof(struct virtio_net_hdr)); > m_adj(m, adjsz); > + > + if (PFIL_HOOKED_IN(sc->vtnet_pfil) && pfil_done == false) { > + pfil = pfil_run_hooks(sc->vtnet_pfil, , ifp, > PFIL_IN, > + NULL); > + switch (pfil) { > + case PFIL_DROPPED: > + case
svn commit: r356534 - in head: share/man/man9 sys/arm/arm sys/vm
Author: rlibby Date: Thu Jan 9 02:03:03 2020 New Revision: 356534 URL: https://svnweb.freebsd.org/changeset/base/356534 Log: uma: reorganize flags - Garbage collect UMA_ZONE_PAGEABLE & UMA_ZONE_STATIC. - Move flag VTOSLAB from public to private. - Introduce public NOTPAGE flag and make HASH private. - Introduce public NOTOUCH flag and make OFFPAGE private. - Update man page. The net effect of this should be to make the contract with clients more clear. Clients should choose constraints, UMA will figure out how to implement them. This also breaks the confusing double meaning of OFFPAGE. Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23016 Modified: head/share/man/man9/zone.9 head/sys/arm/arm/busdma_machdep-v6.c head/sys/vm/uma.h head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/share/man/man9/zone.9 == --- head/share/man/man9/zone.9 Thu Jan 9 01:17:01 2020(r356533) +++ head/share/man/man9/zone.9 Thu Jan 9 02:03:03 2020(r356534) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 22, 2019 +.Dd January 8, 2020 .Dt UMA 9 .Os .Sh NAME @@ -292,18 +292,12 @@ To obtain zeroed memory from a PCPU zone, use the .Fn uma_zalloc_pcpu function and its variants instead, and pass .Dv M_ZERO . -.It Dv UMA_ZONE_OFFPAGE -By default book-keeping of items within a slab is done in the slab page itself. -This flag explicitly tells subsystem that book-keeping structure should be -allocated separately from special internal zone. -This flag requires either -.Dv UMA_ZONE_VTOSLAB -or -.Dv UMA_ZONE_HASH , -since subsystem requires a mechanism to find a book-keeping structure -to an item being freed. -The subsystem may choose to prefer offpage book-keeping for certain zones -implicitly. +.It Dv UMA_ZONE_NOTOUCH +The UMA subsystem may not directly touch (i.e. read or write) the slab memory. +Otherwise, by default, book-keeping of items within a slab may be done in the +slab page itself, and +.Dv INVARIANTS +kernels may also do use-after-free checking by accessing the slab memory. .It Dv UMA_ZONE_ZINIT The zone will have its .Ft uma_init @@ -317,13 +311,11 @@ A zone with .Dv UMA_ZONE_ZINIT flag would not return zeroed memory on every .Fn uma_zalloc . -.It Dv UMA_ZONE_HASH -The zone should use an internal hash table to find slab book-keeping -structure where an allocation being freed belongs to. -.It Dv UMA_ZONE_VTOSLAB -The zone should use special field of -.Vt vm_page_t -to find slab book-keeping structure where an allocation being freed belongs to. +.It Dv UMA_ZONE_NOTPAGE +An allocator function will be supplied with +.Fn uma_zone_set_allocf +and the memory that it returns may not be kernel virtual memory backed by VM +pages in the page array. .It Dv UMA_ZONE_MALLOC The zone is for the .Xr malloc 9 Modified: head/sys/arm/arm/busdma_machdep-v6.c == --- head/sys/arm/arm/busdma_machdep-v6.cThu Jan 9 01:17:01 2020 (r356533) +++ head/sys/arm/arm/busdma_machdep-v6.cThu Jan 9 02:03:03 2020 (r356534) @@ -244,7 +244,7 @@ busdma_init(void *dummy) * atomic ops on uma_slab_t fields and safety of this * operation is not guaranteed for write-back caches */ - uma_flags = UMA_ZONE_OFFPAGE; + uma_flags = UMA_ZONE_NOTOUCH; #endif /* * Create a cache of buffers in uncacheable memory, to implement the Modified: head/sys/vm/uma.h == --- head/sys/vm/uma.h Thu Jan 9 01:17:01 2020(r356533) +++ head/sys/vm/uma.h Thu Jan 9 02:03:03 2020(r356534) @@ -232,14 +232,10 @@ uma_zone_t uma_zcache_create(char *name, int size, uma * Definitions for uma_zcreate flags * * These flags share space with UMA_ZFLAGs in uma_int.h. Be careful not to - * overlap when adding new features. 0xff00 is in use by uma_int.h. + * overlap when adding new features. */ -#define UMA_ZONE_PAGEABLE 0x0001 /* Return items not fully backed by - physical memory XXX Not yet */ #define UMA_ZONE_ZINIT 0x0002 /* Initialize with zeros */ -#define UMA_ZONE_STATIC0x0004 /* Statically sized zone */ -#define UMA_ZONE_OFFPAGE 0x0008 /* Force the slab structure allocation - off of the real memory */ +#define UMA_ZONE_NOTOUCH 0x0008 /* UMA may not access the memory */ #define UMA_ZONE_MALLOC0x0010 /* For use by malloc(9) only! */ #define UMA_ZONE_NOFREE0x0020 /* Do not free slabs of this type! */ #define UMA_ZONE_MTXCLASS 0x0040 /* Create a new lock class */ @@ -247,20 +243,17 @@ uma_zone_t uma_zcache_create(char
svn commit: r356535 - head/sys/vm
Author: rlibby Date: Thu Jan 9 02:03:17 2020 New Revision: 356535 URL: https://svnweb.freebsd.org/changeset/base/356535 Log: uma: unify layout paths and improve efficiency Unify the keg layout selection paths (keg_small_init, keg_large_init, keg_cachespread_init), and slightly improve memory efficiecy by: - using the padding of the final item to store the slab header, - not going OFFPAGE if we have a choice unless it improves efficiency. Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D23048 Modified: head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Thu Jan 9 02:03:03 2020(r356534) +++ head/sys/vm/uma_core.c Thu Jan 9 02:03:17 2020(r356535) @@ -258,8 +258,6 @@ static void keg_dtor(void *, int, void *); static int zone_ctor(void *, int, void *, int); static void zone_dtor(void *, int, void *); static int zero_init(void *, int, int); -static void keg_small_init(uma_keg_t keg); -static void keg_large_init(uma_keg_t keg); static void zone_foreach(void (*zfunc)(uma_zone_t, void *), void *); static void zone_timeout(uma_zone_t zone, void *); static int hash_alloc(struct uma_hash *, u_int); @@ -1669,27 +1667,61 @@ slab_space(int nitems) return (UMA_SLAB_SIZE - slab_sizeof(nitems)); } +#defineUMA_FIXPT_SHIFT 31 +#defineUMA_FRAC_FIXPT(n, d) \ + ((uint32_t)(((uint64_t)(n) << UMA_FIXPT_SHIFT) / (d))) +#defineUMA_FIXPT_PCT(f) \ + ((u_int)(((uint64_t)100 * (f)) >> UMA_FIXPT_SHIFT)) +#defineUMA_PCT_FIXPT(pct) UMA_FRAC_FIXPT((pct), 100) +#defineUMA_MIN_EFF UMA_PCT_FIXPT(100 - UMA_MAX_WASTE) + /* - * Compute the number of items that will fit in an embedded (!OFFPAGE) slab - * with a given size and alignment. + * Compute the number of items that will fit in a slab. If hdr is true, the + * item count may be limited to provide space in the slab for an inline slab + * header. Otherwise, all slab space will be provided for item storage. */ +static u_int +slab_ipers_hdr(u_int size, u_int rsize, u_int slabsize, bool hdr) +{ + u_int ipers; + u_int padpi; + + /* The padding between items is not needed after the last item. */ + padpi = rsize - size; + + if (hdr) { + /* +* Start with the maximum item count and remove items until +* the slab header first alongside the allocatable memory. +*/ + for (ipers = MIN(SLAB_MAX_SETSIZE, + (slabsize + padpi - slab_sizeof(1)) / rsize); + ipers > 0 && + ipers * rsize - padpi + slab_sizeof(ipers) > slabsize; + ipers--) + continue; + } else { + ipers = MIN((slabsize + padpi) / rsize, SLAB_MAX_SETSIZE); + } + + return (ipers); +} + +/* + * Compute the number of items that will fit in a slab for a startup zone. + */ int slab_ipers(size_t size, int align) { int rsize; - int nitems; -/* - * Compute the ideal number of items that will fit in a page and - * then compute the actual number based on a bitset nitems wide. - */ - rsize = roundup(size, align + 1); -nitems = UMA_SLAB_SIZE / rsize; - return (slab_space(nitems) / rsize); + rsize = roundup(size, align + 1); /* Assume no CACHESPREAD */ + return (slab_ipers_hdr(size, rsize, UMA_SLAB_SIZE, true)); } /* - * Finish creating a small uma keg. This calculates ipers, and the keg size. + * Determine the format of a uma keg. This determines where the slab header + * will be placed (inline or offpage) and calculates ipers, rsize, and ppera. * * Arguments * keg The zone we should initialize @@ -1698,66 +1730,77 @@ slab_ipers(size_t size, int align) * Nothing */ static void -keg_small_init(uma_keg_t keg) +keg_layout(uma_keg_t keg) { + u_int alignsize; + u_int eff; + u_int eff_offpage; + u_int format; + u_int ipers; + u_int ipers_offpage; + u_int pages; u_int rsize; - u_int memused; - u_int wastedspace; - u_int shsize; u_int slabsize; - if (keg->uk_flags & UMA_ZONE_PCPU) { - u_int ncpus = (mp_maxid + 1) ? (mp_maxid + 1) : MAXCPU; + KASSERT((keg->uk_flags & UMA_ZONE_PCPU) == 0 || + (keg->uk_size <= UMA_PCPU_ALLOC_SIZE && +(keg->uk_flags & UMA_ZONE_CACHESPREAD) == 0), + ("%s: cannot configure for PCPU: keg=%s, size=%u, flags=0x%b", +__func__, keg->uk_name, keg->uk_size, keg->uk_flags, +PRINT_UMA_ZFLAGS)); + KASSERT((keg->uk_flags & +
svn commit: r355976 - head/contrib/googletest/googlemock/include/gmock/internal
Author: rlibby Date: Sat Dec 21 02:44:50 2019 New Revision: 355976 URL: https://svnweb.freebsd.org/changeset/base/355976 Log: googletest: pick from upstream: Don't allow signed/unsigned wchar_t in gcc 9 and later Pick 711fccf8317b4fb7adc21c00fc1e20823c5d875f from upstream googletest: Don't allow signed/unsigned wchar_t in gcc 9 and later Upstream pull request:https://github.com/google/googletest/pull/2270 Sponsored by: Dell EMC Isilon Modified: head/contrib/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h Modified: head/contrib/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h == --- head/contrib/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h Sat Dec 21 02:44:38 2019(r355975) +++ head/contrib/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h Sat Dec 21 02:44:50 2019(r355976) @@ -125,8 +125,11 @@ struct LinkedPtrLessThan { // // To gcc, // wchar_t == signed wchar_t != unsigned wchar_t == unsigned int +// +// gcc-9 appears to treat signed/unsigned wchar_t as ill-formed +// regardless of the signage of its underlying type. #ifdef __GNUC__ -#if !defined(__WCHAR_UNSIGNED__) +#if !defined(__WCHAR_UNSIGNED__) && (__GNUC__ < 9) // signed/unsigned wchar_t are valid types. # define GMOCK_HAS_SIGNED_WCHAR_T_ 1 #endif ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355975 - head/contrib/jemalloc/src
Author: rlibby Date: Sat Dec 21 02:44:38 2019 New Revision: 355975 URL: https://svnweb.freebsd.org/changeset/base/355975 Log: jemalloc: pick from upstream: Fix GCC-9.1 warning with macro GET_ARG_NUMERIC Pick 2d6d099fed05b1509e81e54458516528bfbbf38d from upstream jemalloc: Fix GCC-9.1 warning with macro GET_ARG_NUMERIC GCC-9.1 reports following error when trying to compile file src/malloc_io.c and with CFLAGS='-Werror' : src/malloc_io.c: In function ‘malloc_vsnprintf’: src/malloc_io.c:369:2: error: case label value exceeds maximum value for type [-Werror] 369 | case '?' | 0x80: \ | ^~~~ src/malloc_io.c:581:5: note: in expansion of macro ‘GET_ARG_NUMERIC’ 581 | GET_ARG_NUMERIC(val, 'p'); | ^~~ ... cc1: all warnings being treated as errors make: *** [Makefile:388: src/malloc_io.sym.o] Error 1 The warning is reported as by default the type 'char' is 'signed char' and or-ing 0x80 will turn the case label char negative which will be beyond the printable ascii range (0 - 127). The patch fixes this by explicitly casting the 'len' variable as unsigned char' inside the 'switch' statement so that value of expression " '?' | 0x80 " falls within the legal values of the variable 'len'. Discussed with: jasone (maintainer) Sponsored by: Dell EMC Isilon Modified: head/contrib/jemalloc/src/malloc_io.c Modified: head/contrib/jemalloc/src/malloc_io.c == --- head/contrib/jemalloc/src/malloc_io.c Sat Dec 21 02:44:26 2019 (r355974) +++ head/contrib/jemalloc/src/malloc_io.c Sat Dec 21 02:44:38 2019 (r355975) @@ -376,7 +376,7 @@ malloc_vsnprintf(char *str, size_t size, const char *f } \ } while (0) #define GET_ARG_NUMERIC(val, len) do { \ - switch (len) { \ + switch ((unsigned char)len) { \ case '?': \ val = va_arg(ap, int); \ break; \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355974 - head/lib/libdevdctl
Author: rlibby Date: Sat Dec 21 02:44:26 2019 New Revision: 355974 URL: https://svnweb.freebsd.org/changeset/base/355974 Log: libdevdctl: g++9 avoid Wdeprecated-copy g++9 now warns about having defined an assignment operator but using the default copy constructor, or vice versa. Avoid the issue in libdevdctl by just using the default assignment operator too. Reviewed by: asomers, dim Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22887 Modified: head/lib/libdevdctl/guid.h Modified: head/lib/libdevdctl/guid.h == --- head/lib/libdevdctl/guid.h Sat Dec 21 02:44:13 2019(r355973) +++ head/lib/libdevdctl/guid.h Sat Dec 21 02:44:26 2019(r355974) @@ -70,9 +70,6 @@ class Guid (public) Guid(const std::string ); static Guid InvalidGuid(); - /* Assignment */ - Guid& operator=(const Guid& rhs); - /* Test the validity of this guid. */ bool IsValid() const; @@ -108,13 +105,6 @@ inline Guid Guid::InvalidGuid() { return (Guid(INVALID_GUID)); -} - -inline Guid& -Guid::operator=(const Guid ) -{ - m_GUID = rhs.m_GUID; - return (*this); } inline bool ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355971 - head/share/mk
Author: rlibby Date: Sat Dec 21 02:43:49 2019 New Revision: 355971 URL: https://svnweb.freebsd.org/changeset/base/355971 Log: gcc9: quiet Waddress-of-packed-member for user build Disable the warning for WARNS <= 3. This is lame, but it's what we already do for the clang build. Reviewed by: dim Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22889 Modified: head/share/mk/bsd.sys.mk Modified: head/share/mk/bsd.sys.mk == --- head/share/mk/bsd.sys.mkSat Dec 21 02:43:37 2019(r355970) +++ head/share/mk/bsd.sys.mkSat Dec 21 02:43:49 2019(r355971) @@ -94,6 +94,9 @@ CWARNFLAGS.clang+=-Wno-unused-local-typedef .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 4 CWARNFLAGS.clang+= -Wno-address-of-packed-member .endif +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 90100 +CWARNFLAGS.gcc+= -Wno-address-of-packed-member +.endif .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 7 && \ ${MACHINE_CPUARCH} == "arm" && !${MACHINE_ARCH:Marmv[67]*} CWARNFLAGS.clang+= -Wno-atomic-alignment ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355970 - head/sys/conf
Author: rlibby Date: Sat Dec 21 02:43:37 2019 New Revision: 355970 URL: https://svnweb.freebsd.org/changeset/base/355970 Log: gcc9: quiet Waddress-of-packed-member for kernel build This is lame, but it's what we already do for the clang build. We take misaligned pointers into network header structures in many places. Reviewed by: ian Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22876 Modified: head/sys/conf/kern.mk Modified: head/sys/conf/kern.mk == --- head/sys/conf/kern.mk Sat Dec 21 02:43:20 2019(r355969) +++ head/sys/conf/kern.mk Sat Dec 21 02:43:37 2019(r355970) @@ -70,6 +70,9 @@ CWARNEXTRA+= -Wno-error=memset-elt-size .if ${COMPILER_VERSION} >= 8 CWARNEXTRA+= -Wno-error=packed-not-aligned .endif +.if ${COMPILER_VERSION} >= 90100 +CWARNEXTRA+= -Wno-address-of-packed-member +.endif .else # For gcc 4.2, eliminate the too-often-wrong warnings about uninitialized vars. CWARNEXTRA?= -Wno-uninitialized ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355973 - head/cddl/contrib/opensolaris/lib/libdtrace/common
Author: rlibby Date: Sat Dec 21 02:44:13 2019 New Revision: 355973 URL: https://svnweb.freebsd.org/changeset/base/355973 Log: dtrace: avoid gcc9 Walloca-larger-than gcc9 grew a new warning for unbounded allocas, such as the one in dt_options_load. Remove both uses of alloca in dt_options.c. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22880 Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c == --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c Sat Dec 21 02:44:00 2019(r355972) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c Sat Dec 21 02:44:13 2019(r355973) @@ -38,9 +38,6 @@ #include #include #include -#ifdef illumos -#include -#endif #include #include @@ -162,26 +159,40 @@ dt_opt_cpp_path(dtrace_hdl_t *dtp, const char *arg, ui static int dt_opt_cpp_opts(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) { - char *buf; + char *buf = NULL; size_t len; const char *opt = (const char *)option; + int ret; - if (opt == NULL || arg == NULL) - return (dt_set_errno(dtp, EDT_BADOPTVAL)); + if (opt == NULL || arg == NULL) { + ret = dt_set_errno(dtp, EDT_BADOPTVAL); + goto out; + } - if (dtp->dt_pcb != NULL) - return (dt_set_errno(dtp, EDT_BADOPTCTX)); + if (dtp->dt_pcb != NULL) { + ret = dt_set_errno(dtp, EDT_BADOPTCTX); + goto out; + } len = strlen(opt) + strlen(arg) + 1; - buf = alloca(len); + if ((buf = dt_alloc(dtp, len)) == NULL) { + ret = dt_set_errno(dtp, EDT_NOMEM); + goto out; + } (void) strcpy(buf, opt); (void) strcat(buf, arg); - if (dt_cpp_add_arg(dtp, buf) == NULL) - return (dt_set_errno(dtp, EDT_NOMEM)); + if (dt_cpp_add_arg(dtp, buf) == NULL) { + ret = dt_set_errno(dtp, EDT_NOMEM); + goto out; + } - return (0); + ret = 0; +out: + if (buf != NULL) + dt_free(dtp, buf); + return (ret); } /*ARGSUSED*/ @@ -885,27 +896,35 @@ dt_options_load(dtrace_hdl_t *dtp) dof_hdr_t hdr, *dof; dof_sec_t *sec; size_t offs; - int i; + int i, ret; /* * To load the option values, we need to ask the kernel to provide its * DOF, which we'll sift through to look for OPTDESC sections. */ + dof = bzero(, sizeof (dof_hdr_t)); hdr.dofh_loadsz = sizeof (dof_hdr_t); #ifdef illumos - if (dt_ioctl(dtp, DTRACEIOC_DOFGET, ) == -1) + if (dt_ioctl(dtp, DTRACEIOC_DOFGET, dof) == -1) #else - dof = if (dt_ioctl(dtp, DTRACEIOC_DOFGET, ) == -1) #endif - return (dt_set_errno(dtp, errno)); + { + ret = dt_set_errno(dtp, errno); + goto out; + } - if (hdr.dofh_loadsz < sizeof (dof_hdr_t)) - return (dt_set_errno(dtp, EINVAL)); + if (hdr.dofh_loadsz < sizeof (dof_hdr_t)) { + ret = dt_set_errno(dtp, EINVAL); + goto out; + } - dof = alloca(hdr.dofh_loadsz); + if ((dof = dt_alloc(dtp, hdr.dofh_loadsz)) == NULL) { + ret = dt_set_errno(dtp, EDT_NOMEM); + goto out; + } bzero(dof, sizeof (dof_hdr_t)); dof->dofh_loadsz = hdr.dofh_loadsz; @@ -917,7 +936,10 @@ dt_options_load(dtrace_hdl_t *dtp) #else if (dt_ioctl(dtp, DTRACEIOC_DOFGET, ) == -1) #endif - return (dt_set_errno(dtp, errno)); + { + ret = dt_set_errno(dtp, errno); + goto out; + } for (i = 0; i < dof->dofh_secnum; i++) { sec = (dof_sec_t *)(uintptr_t)((uintptr_t)dof + @@ -942,7 +964,11 @@ dt_options_load(dtrace_hdl_t *dtp) dtp->dt_options[opt->dofo_option] = opt->dofo_value; } - return (0); + ret = 0; +out: + if (dof != NULL && dof != ) + dt_free(dtp, dof); + return (ret); } typedef struct dt_option { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355972 - in head: sbin/camcontrol sys/sys
Author: rlibby Date: Sat Dec 21 02:44:00 2019 New Revision: 355972 URL: https://svnweb.freebsd.org/changeset/base/355972 Log: Declare packed struct ata_params as 2-byte-aligned This avoids gcc9 warning about unaligned access to the structure when casting to uint16_t pointer type. Submitted by: imp Reviewed by: imp Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22888 Modified: head/sbin/camcontrol/camcontrol.c head/sys/sys/ata.h Modified: head/sbin/camcontrol/camcontrol.c == --- head/sbin/camcontrol/camcontrol.c Sat Dec 21 02:43:49 2019 (r355971) +++ head/sbin/camcontrol/camcontrol.c Sat Dec 21 02:44:00 2019 (r355972) @@ -2355,7 +2355,7 @@ ataidentify(struct cam_device *device, int retry_count if (arglist & CAM_ARG_VERBOSE) { printf("%s%d: Raw identify data:\n", device->device_name, device->dev_unit_num); - dump_data((void*)ident_buf, sizeof(struct ata_params)); + dump_data((uint16_t *)ident_buf, sizeof(struct ata_params)); } if (ident_buf->support.command1 & ATA_SUPPORT_PROTECTED) { Modified: head/sys/sys/ata.h == --- head/sys/sys/ata.h Sat Dec 21 02:43:49 2019(r355971) +++ head/sys/sys/ata.h Sat Dec 21 02:44:00 2019(r355972) @@ -311,7 +311,7 @@ struct ata_params { /*223*/ u_int16_t transport_minor; u_int16_t reserved224[31]; /*255*/ u_int16_t integrity; -} __packed; +} __packed __aligned(2); /* ATA Dataset Management */ #define ATA_DSM_BLK_SIZE 512 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355969 - head/sys/sys
Author: rlibby Date: Sat Dec 21 02:43:20 2019 New Revision: 355969 URL: https://svnweb.freebsd.org/changeset/base/355969 Log: gcc: quiet Wattribute for no_sanitize("address") This is an unfortunate instance where the __has_attribute check does not function usefully. Gcc does have the attribute, but for gcc it only applies to functions, not variables, and trying to apply it to a variable generates Wattribute. So far we only apply the attribute to variables. Only enable the attribute for clang, for now. Reviewed by: Anton Rang Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22875 Modified: head/sys/sys/cdefs.h Modified: head/sys/sys/cdefs.h == --- head/sys/sys/cdefs.hSat Dec 21 02:40:40 2019(r355968) +++ head/sys/sys/cdefs.hSat Dec 21 02:43:20 2019(r355969) @@ -873,8 +873,12 @@ /* Function should not be analyzed. */ #define__no_lock_analysis __lock_annotate(no_thread_safety_analysis) -/* Function or variable should not be sanitized, ie. by AddressSanitizer */ -#if __has_attribute(no_sanitize) +/* + * Function or variable should not be sanitized, i.e. by AddressSanitizer. + * GCC has the nosanitize attribute, but as a function attribute only, and + * warns on use as a variable attribute. + */ +#if __has_attribute(no_sanitize) && defined(__clang__) #define __nosanitizeaddress__attribute__((no_sanitize("address"))) #else #define __nosanitizeaddress ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r355784 - in head/sys: compat/linuxkpi/common/src dev/dpaa kern mips/nlm sys
On Mon, Dec 16, 2019 at 7:30 AM Ed Maste wrote: > > On Sun, 15 Dec 2019 at 16:27, Jeff Roberson wrote: > > > > Author: jeff > > Date: Sun Dec 15 21:26:50 2019 > > New Revision: 355784 > > URL: https://svnweb.freebsd.org/changeset/base/355784 > > > > Log: > > schedlock 4/4 > > FYI i386, arm, arm64, riscv fail to boot now, with "panic: invalid count 2" > > Boot logs: > i386: https://ci.freebsd.org/job/FreeBSD-head-i386-test/7797/console > arm: > https://ci.freebsd.org/hwlab/job/FreeBSD-device-head-beaglebone-test/1317/artifact/device_tests/beaglebone.boot.log > arm64: > https://ci.freebsd.org/hwlab/job/FreeBSD-device-head-pinea64-test/1194/artifact/device_tests/pinea64.boot.log > riscv: > https://ci.freebsd.org/hwlab/job/FreeBSD-device-head-pinea64-test/1194/artifact/device_tests/pinea64.boot.log > > arm64 is: > > panic: invalid count 2 > cpuid = 0 > time = 1 > KDB: stack backtrace: > db_trace_self() at db_trace_self_wrapper+0x28 > pc = 0x007359ec lr = 0x00106744 > sp = 0x56b063c0 fp = 0x56b065d0 > > db_trace_self_wrapper() at vpanic+0x18c > pc = 0x00106744 lr = 0x00408128 > sp = 0x56b065e0 fp = 0x56b06690 > > vpanic() at panic+0x44 > pc = 0x00408128 lr = 0x00407ed8 > sp = 0x56b066a0 fp = 0x56b06720 > > panic() at sched_switch+0x81c > pc = 0x00407ed8 lr = 0x00434264 > sp = 0x56b06730 fp = 0x56b06810 > > sched_switch() at mi_switch+0x170 > pc = 0x00434264 lr = 0x00413690 > sp = 0x56b06820 fp = 0x56b06840 > > mi_switch() at cpu_idle+0xc8 > pc = 0x00413690 lr = 0x007400a0 > sp = 0x56b06850 fp = 0x56b06860 > > cpu_idle() at sched_idletd+0x380 > pc = 0x007400a0 lr = 0x00436a90 > sp = 0x56b06870 fp = 0x56b06940 > > sched_idletd() at fork_exit+0x7c > pc = 0x00436a90 lr = 0x003c7ba4 > sp = 0x56b06950 fp = 0x56b06980 > > fork_exit() at fork_trampoline+0x10 > pc = 0x003c7ba4 lr = 0x007521ac > sp = 0x56b06990 fp = 0x > > KDB: enter: panic > [ thread pid 11 tid 13 ] > Stopped at 0 > db> It looks like amd64 vs i386, riscv, etc are using different motifs in spinlock_exit(). Perhaps we just need to rearrange them to drop the spinlock count before critical_exit(), like in amd64. Ryan ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r355747 - in head: . include lib/libc/stdlib lib/libxo
On Sat, Dec 14, 2019 at 12:28 AM Conrad Meyer wrote: > > Author: cem > Date: Sat Dec 14 08:28:10 2019 > New Revision: 355747 > URL: https://svnweb.freebsd.org/changeset/base/355747 > > Log: > Deprecate sranddev(3) API > > It serves no useful purpose and wasn't as popular as its equally meritless > cousin, srandomdev(3). > > Setting aside the problems with rand(3) in general, the problem with this > interface is that the seed isn't shared with the caller (other than by > attacking the output of the generator, which is trivial, but not a hallmark > of > pleasant API design). The (arguable) utility of rand(3) or random(3) is as > a > semi-fast simulation generator which produces consistent results from a > given > seed. These are mutually at odd. Furthermore, sometimes people got the > mistaken impression that a high quality random seed meant a weak generator > like > rand(3) or random(3) could be used for things like cryptographic key > generation. This is absolutely not so. > > The API was never part of a standard and was not widely used in tree. > Existing > in-tree uses have all been removed. > > Possible replacement in out of tree codebases: > > char buf[3]; > time_t t; > > time(t); > strftime(buf, sizeof(buf), "%S", gmtime()); > srand(atoi(buf)); > > Relnotes: yes > > Modified: > head/ObsoleteFiles.inc > head/include/stdlib.h > head/lib/libc/stdlib/Makefile.inc > head/lib/libc/stdlib/Symbol.map > head/lib/libc/stdlib/rand.3 > head/lib/libc/stdlib/rand.c > head/lib/libxo/xo_config.h > > Modified: head/ObsoleteFiles.inc > == > --- head/ObsoleteFiles.inc Sat Dec 14 05:21:56 2019(r355746) > +++ head/ObsoleteFiles.inc Sat Dec 14 08:28:10 2019(r355747) > @@ -36,6 +36,8 @@ > # xargs -n1 | sort | uniq -d; > # done > > +# 20191214: Removal of sranddev(3) > +OLD_FILES+=usr/share/man/man3/sranddev.3.gz > # 20191213: remove timeout(9) > OLD_FILES+=usr/share/man/man9/timeout.9.gz > OLD_FILES+=usr/share/man/man9/untimeout.9.gz > > Modified: head/include/stdlib.h > == > --- head/include/stdlib.h Sat Dec 14 05:21:56 2019(r355746) > +++ head/include/stdlib.h Sat Dec 14 08:28:10 2019(r355747) > @@ -309,12 +309,17 @@ intrpmatch(const char *); > voidsetprogname(const char *); > int sradixsort(const unsigned char **, int, const unsigned char *, > unsigned); > -voidsranddev(void); > voidsrandomdev(void); > long long > strtonum(const char *, long long, long long, const char **); > > /* Deprecated interfaces, to be removed. */ > +static inline void > +__attribute__((__deprecated__("sranddev to be removed in FreeBSD 13"))) > +sranddev(void) > +{ > +} > + This broke some gcc builds in ci. It looks like older versions of gcc don't like having an argument to deprecated. > __int64_t > strtoq(const char *, char **, int); > __uint64_t > > Modified: head/lib/libc/stdlib/Makefile.inc > == > --- head/lib/libc/stdlib/Makefile.inc Sat Dec 14 05:21:56 2019 > (r355746) > +++ head/lib/libc/stdlib/Makefile.inc Sat Dec 14 08:28:10 2019 > (r355747) > @@ -52,7 +52,7 @@ MLINKS+=insque.3 remque.3 > MLINKS+=lsearch.3 lfind.3 > MLINKS+=ptsname.3 grantpt.3 ptsname.3 unlockpt.3 > MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 qsort.3 qsort_r.3 > -MLINKS+=rand.3 rand_r.3 rand.3 srand.3 rand.3 sranddev.3 > +MLINKS+=rand.3 rand_r.3 rand.3 srand.3 > MLINKS+=random.3 initstate.3 random.3 setstate.3 random.3 srandom.3 \ > random.3 srandomdev.3 > MLINKS+=radixsort.3 sradixsort.3 > > Modified: head/lib/libc/stdlib/Symbol.map > == > --- head/lib/libc/stdlib/Symbol.map Sat Dec 14 05:21:56 2019 > (r355746) > +++ head/lib/libc/stdlib/Symbol.map Sat Dec 14 08:28:10 2019 > (r355747) > @@ -56,7 +56,6 @@ FBSD_1.0 { > rand_r; > rand; > srand; > - sranddev; > srandom; > srandomdev; > initstate; > > Modified: head/lib/libc/stdlib/rand.3 > == > --- head/lib/libc/stdlib/rand.3 Sat Dec 14 05:21:56 2019(r355746) > +++ head/lib/libc/stdlib/rand.3 Sat Dec 14 08:28:10 2019(r355747) > @@ -32,13 +32,12 @@ > .\" @(#)rand.3 8.1 (Berkeley) 6/4/93 > .\" $FreeBSD$ > .\" > -.Dd April 22, 2019 > +.Dd December 14, 2019 > .Dt RAND 3 > .Os > .Sh NAME > .Nm rand , > .Nm srand , > -.Nm sranddev , > .Nm rand_r > .Nd bad random number generator > .Sh LIBRARY > @@ -47,8 +46,6 @@ > .In stdlib.h > .Ft void > .Fn srand "unsigned seed" > -.Ft void > -.Fn
svn commit: r355746 - head/sys/vm
Author: rlibby Date: Sat Dec 14 05:21:56 2019 New Revision: 355746 URL: https://svnweb.freebsd.org/changeset/base/355746 Log: uma dbg: flexible size for slab debug bitset too Recently (r355315) the size of the struct uma_slab bitset field us_free became dynamic instead of conservative. Now, make the debug bitset size dynamic too. The debug bitset is INVARIANTS-only, so in fact we don't care too much about the space savings that results from this, but enabling minimally-sized slabs on INVARIANTS builds is still important in order to be able to test new slab layouts effectively. Reviewed by: jeff (previous version), markj (previous version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22759 Modified: head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Sat Dec 14 03:14:46 2019(r355745) +++ head/sys/vm/uma_core.c Sat Dec 14 05:21:56 2019(r355746) @@ -293,6 +293,8 @@ static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER static int sysctl_handle_uma_slab_efficiency(SYSCTL_HANDLER_ARGS); #ifdef INVARIANTS +static inline struct noslabbits *slab_dbg_bits(uma_slab_t slab, uma_keg_t keg); + static bool uma_dbg_kskip(uma_keg_t keg, void *mem); static bool uma_dbg_zskip(uma_zone_t zone, void *mem); static void uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *item); @@ -1204,7 +1206,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom slab->us_domain = domain; BIT_FILL(keg->uk_ipers, >us_free); #ifdef INVARIANTS - BIT_ZERO(SLAB_MAX_SETSIZE, >us_debugfree); + BIT_ZERO(keg->uk_ipers, slab_dbg_bits(slab, keg)); #endif if (keg->uk_init != NULL) { @@ -1487,6 +1489,15 @@ zero_init(void *mem, int size, int flags) return (0); } +#ifdef INVARIANTS +struct noslabbits * +slab_dbg_bits(uma_slab_t slab, uma_keg_t keg) +{ + + return ((void *)((char *)>us_free + BITSET_SIZE(keg->uk_ipers))); +} +#endif + /* * Actual size of embedded struct slab (!OFFPAGE). */ @@ -1495,7 +1506,7 @@ slab_sizeof(int nitems) { size_t s; - s = sizeof(struct uma_slab) + BITSET_SIZE(nitems); + s = sizeof(struct uma_slab) + BITSET_SIZE(nitems) * SLAB_BITSETS; return (roundup(s, UMA_ALIGN_PTR + 1)); } @@ -4541,12 +4552,10 @@ uma_dbg_alloc(uma_zone_t zone, uma_slab_t slab, void * keg = zone->uz_keg; freei = slab_item_index(slab, keg, item); - if (BIT_ISSET(SLAB_MAX_SETSIZE, freei, >us_debugfree)) + if (BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) panic("Duplicate alloc of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - BIT_SET_ATOMIC(SLAB_MAX_SETSIZE, freei, >us_debugfree); - - return; + BIT_SET_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); } /* @@ -4577,11 +4586,11 @@ uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *i panic("Unaligned free of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - if (!BIT_ISSET(SLAB_MAX_SETSIZE, freei, >us_debugfree)) + if (!BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) panic("Duplicate free of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - BIT_CLR_ATOMIC(SLAB_MAX_SETSIZE, freei, >us_debugfree); + BIT_CLR_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); } #endif /* INVARIANTS */ Modified: head/sys/vm/uma_int.h == --- head/sys/vm/uma_int.h Sat Dec 14 03:14:46 2019(r355745) +++ head/sys/vm/uma_int.h Sat Dec 14 05:21:56 2019(r355746) @@ -254,6 +254,7 @@ struct uma_keg { }; typedef struct uma_keg * uma_keg_t; +#ifdef _KERNEL /* * Free bits per-slab. */ @@ -271,17 +272,26 @@ struct uma_slab { uint16_tus_freecount; /* How many are free? */ uint8_t us_flags; /* Page flags see uma.h */ uint8_t us_domain; /* Backing NUMA domain. */ -#ifdef INVARIANTS - struct slabbits us_debugfree; /* Debug bitmask. */ -#endif - struct noslabbits us_free; /* Free bitmask. */ + struct noslabbits us_free; /* Free bitmask, flexible. */ }; +_Static_assert(sizeof(struct uma_slab) == offsetof(struct uma_slab, us_free), +"us_free field must be last"); #if MAXMEMDOM >= 255 #error "Slab domain type insufficient" #endif typedef struct uma_slab * uma_slab_t; +/* + * On INVARIANTS builds, the slab contains a second bitset of the same size, + * "dbg_bits", which is laid out immediately after us_free. + */ +#ifdef INVARIANTS +#define
svn commit: r355711 - in head: lib/libmemstat sys/vm
Author: rlibby Date: Fri Dec 13 11:21:28 2019 New Revision: 355711 URL: https://svnweb.freebsd.org/changeset/base/355711 Log: Revert r355706 & r355710 The quick fix didn't work. I'll sort it out tomorrow. Revert r355710: "libmemstat: unbreak build" Revert r355706: "uma dbg: flexible size for slab debug bitset too" Modified: head/lib/libmemstat/memstat_uma.c head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/lib/libmemstat/memstat_uma.c == --- head/lib/libmemstat/memstat_uma.c Fri Dec 13 10:34:19 2019 (r355710) +++ head/lib/libmemstat/memstat_uma.c Fri Dec 13 11:21:28 2019 (r355711) @@ -31,7 +31,6 @@ #include #include #include -#include #include #include Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Fri Dec 13 10:34:19 2019(r355710) +++ head/sys/vm/uma_core.c Fri Dec 13 11:21:28 2019(r355711) @@ -293,8 +293,6 @@ static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER static int sysctl_handle_uma_slab_efficiency(SYSCTL_HANDLER_ARGS); #ifdef INVARIANTS -static inline struct noslabbits *slab_dbg_bits(uma_slab_t slab, uma_keg_t keg); - static bool uma_dbg_kskip(uma_keg_t keg, void *mem); static bool uma_dbg_zskip(uma_zone_t zone, void *mem); static void uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *item); @@ -1206,7 +1204,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom slab->us_domain = domain; BIT_FILL(keg->uk_ipers, >us_free); #ifdef INVARIANTS - BIT_ZERO(keg->uk_ipers, slab_dbg_bits(slab, keg)); + BIT_ZERO(SLAB_MAX_SETSIZE, >us_debugfree); #endif if (keg->uk_init != NULL) { @@ -1489,15 +1487,6 @@ zero_init(void *mem, int size, int flags) return (0); } -#ifdef INVARIANTS -struct noslabbits * -slab_dbg_bits(uma_slab_t slab, uma_keg_t keg) -{ - - return ((void *)((char *)>us_free + BITSET_SIZE(keg->uk_ipers))); -} -#endif - /* * Actual size of embedded struct slab (!OFFPAGE). */ @@ -1506,7 +1495,7 @@ slab_sizeof(int nitems) { size_t s; - s = sizeof(struct uma_slab) + BITSET_SIZE(nitems) * SLAB_BITSETS; + s = sizeof(struct uma_slab) + BITSET_SIZE(nitems); return (roundup(s, UMA_ALIGN_PTR + 1)); } @@ -4552,10 +4541,12 @@ uma_dbg_alloc(uma_zone_t zone, uma_slab_t slab, void * keg = zone->uz_keg; freei = slab_item_index(slab, keg, item); - if (BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) + if (BIT_ISSET(SLAB_MAX_SETSIZE, freei, >us_debugfree)) panic("Duplicate alloc of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - BIT_SET_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); + BIT_SET_ATOMIC(SLAB_MAX_SETSIZE, freei, >us_debugfree); + + return; } /* @@ -4586,11 +4577,11 @@ uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *i panic("Unaligned free of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - if (!BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) + if (!BIT_ISSET(SLAB_MAX_SETSIZE, freei, >us_debugfree)) panic("Duplicate free of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - BIT_CLR_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); + BIT_CLR_ATOMIC(SLAB_MAX_SETSIZE, freei, >us_debugfree); } #endif /* INVARIANTS */ Modified: head/sys/vm/uma_int.h == --- head/sys/vm/uma_int.h Fri Dec 13 10:34:19 2019(r355710) +++ head/sys/vm/uma_int.h Fri Dec 13 11:21:28 2019(r355711) @@ -271,26 +271,17 @@ struct uma_slab { uint16_tus_freecount; /* How many are free? */ uint8_t us_flags; /* Page flags see uma.h */ uint8_t us_domain; /* Backing NUMA domain. */ - struct noslabbits us_free; /* Free bitmask, flexible. */ +#ifdef INVARIANTS + struct slabbits us_debugfree; /* Debug bitmask. */ +#endif + struct noslabbits us_free; /* Free bitmask. */ }; -_Static_assert(sizeof(struct uma_slab) == offsetof(struct uma_slab, us_free), -"us_free field must be last"); #if MAXMEMDOM >= 255 #error "Slab domain type insufficient" #endif typedef struct uma_slab * uma_slab_t; -/* - * On INVARIANTS builds, the slab contains a second bitset of the same size, - * "dbg_bits", which is laid out immediately after us_free. - */ -#ifdef INVARIANTS -#defineSLAB_BITSETS2 -#else -#defineSLAB_BITSETS1 -#endif - /* These three functions are for embedded (!OFFPAGE) use only. */ size_t
svn commit: r355710 - head/lib/libmemstat
Author: rlibby Date: Fri Dec 13 10:34:19 2019 New Revision: 355710 URL: https://svnweb.freebsd.org/changeset/base/355710 Log: libmemstat: unbreak build r355706 added an instance of offsetof() to the UMA private kernel header file uma_int.h. Userspace memstat_uma.c includes that header, and chokes on offsetof() because apparently the definition in sys/types.h is ifdef _KERNEL. Now, include sys/stddef.h which has an identical definition. Pointyhat to: rlibby Sponsored by: Dell EMC Isilon Modified: head/lib/libmemstat/memstat_uma.c Modified: head/lib/libmemstat/memstat_uma.c == --- head/lib/libmemstat/memstat_uma.c Fri Dec 13 09:32:16 2019 (r355709) +++ head/lib/libmemstat/memstat_uma.c Fri Dec 13 10:34:19 2019 (r355710) @@ -31,6 +31,7 @@ #include #include #include +#include #include #include ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355709 - in head: share/man/man9 sys/i386/i386 sys/kern sys/sparc64/sparc64 sys/sys sys/x86/x86
Author: rlibby Date: Fri Dec 13 09:32:16 2019 New Revision: 355709 URL: https://svnweb.freebsd.org/changeset/base/355709 Log: bitset: rename confusing macro NAND to ANDNOT s/BIT_NAND/BIT_ANDNOT/, and for CPU and DOMAINSET too. The actual implementation is "and not" (or "but not"), i.e. A but not B. Fortunately this does appear to be what all existing callers want. Don't supply a NAND (not (A and B)) operation at this time. Discussed with: jeff Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22791 Modified: head/share/man/man9/Makefile head/share/man/man9/bitset.9 head/share/man/man9/cpuset.9 head/sys/i386/i386/vm_machdep.c head/sys/kern/kern_cpuset.c head/sys/kern/kern_rmlock.c head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c head/sys/kern/subr_kdb.c head/sys/sparc64/sparc64/mp_machdep.c head/sys/sys/bitset.h head/sys/sys/cpuset.h head/sys/sys/domainset.h head/sys/x86/x86/cpu_machdep.c Modified: head/share/man/man9/Makefile == --- head/share/man/man9/MakefileFri Dec 13 09:32:09 2019 (r355708) +++ head/share/man/man9/MakefileFri Dec 13 09:32:16 2019 (r355709) @@ -607,7 +607,7 @@ MLINKS+=bitset.9 BITSET_DEFINE.9 \ bitset.9 BIT_CMP.9 \ bitset.9 BIT_OR.9 \ bitset.9 BIT_AND.9 \ - bitset.9 BIT_NAND.9 \ + bitset.9 BIT_ANDNOT.9 \ bitset.9 BIT_CLR_ATOMIC.9 \ bitset.9 BIT_SET_ATOMIC.9 \ bitset.9 BIT_SET_ATOMIC_ACQ.9 \ @@ -856,7 +856,7 @@ MLINKS+=cpuset.9 CPUSET_T_INITIALIZER.9 \ cpuset.9 CPU_CMP.9 \ cpuset.9 CPU_OR.9 \ cpuset.9 CPU_AND.9 \ - cpuset.9 CPU_NAND.9 \ + cpuset.9 CPU_ANDNOT.9 \ cpuset.9 CPU_CLR_ATOMIC.9 \ cpuset.9 CPU_SET_ATOMIC.9 \ cpuset.9 CPU_SET_ATOMIC_ACQ.9 \ Modified: head/share/man/man9/bitset.9 == --- head/share/man/man9/bitset.9Fri Dec 13 09:32:09 2019 (r355708) +++ head/share/man/man9/bitset.9Fri Dec 13 09:32:16 2019 (r355709) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 7, 2017 +.Dd December 12, 2019 .Dt BITSET 9 .Os .Sh NAME @@ -52,8 +52,8 @@ .Nm BIT_OR2 , .Nm BIT_AND , .Nm BIT_AND2 , -.Nm BIT_NAND , -.Nm BIT_NAND2 , +.Nm BIT_ANDNOT , +.Nm BIT_ANDNOT2 , .Nm BIT_XOR , .Nm BIT_XOR2 , .Nm BIT_CLR_ATOMIC , @@ -116,8 +116,8 @@ .Fa "struct STRUCTNAME *src1" .Fa "struct STRUCTNAME *src2" .Fc -.Fn BIT_NAND "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src" -.Fo BIT_NAND2 +.Fn BIT_ANDNOT "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src" +.Fo BIT_ANDNOT2 .Fa "const SETSIZE" .Fa "struct STRUCTNAME *dst" .Fa "struct STRUCTNAME *src1" @@ -412,7 +412,7 @@ equivalent of the scalar: .Fa src2 . ) .Pp The -.Fn BIT_NAND +.Fn BIT_ANDNOT macro clears bits set in .Fa src from @@ -425,7 +425,7 @@ equivalent of the scalar: .Fa ~ src . ) .Pp The -.Fn BIT_NAND2 +.Fn BIT_ANDNOT2 macro computes .Fa src1 bitwise and not Modified: head/share/man/man9/cpuset.9 == --- head/share/man/man9/cpuset.9Fri Dec 13 09:32:09 2019 (r355708) +++ head/share/man/man9/cpuset.9Fri Dec 13 09:32:16 2019 (r355709) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 29, 2016 +.Dd December 12, 2019 .Dt CPUSET 9 .Os .Sh NAME @@ -48,7 +48,7 @@ .Nm CPU_CMP , .Nm CPU_OR , .Nm CPU_AND , -.Nm CPU_NAND , +.Nm CPU_ANDNOT , .Nm CPU_CLR_ATOMIC , .Nm CPU_SET_ATOMIC , .Nm CPU_SET_ATOMIC_ACQ , @@ -88,7 +88,7 @@ .Fn CPU_CMP "cpuset_t *cpuset1" "cpuset_t *cpuset2" .Fn CPU_OR "cpuset_t *dst" "cpuset_t *src" .Fn CPU_AND "cpuset_t *dst" "cpuset_t *src" -.Fn CPU_NAND "cpuset_t *dst" "cpuset_t *src" +.Fn CPU_ANDNOT "cpuset_t *dst" "cpuset_t *src" .\" .Fn CPU_CLR_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset" .Fn CPU_SET_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset" @@ -303,7 +303,7 @@ is similar, with the same atomic semantics as .Fn CPU_OR_ATOMIC . .Pp The -.Fn CPU_NAND +.Fn CPU_ANDNOT macro removes CPUs in .Fa src from Modified: head/sys/i386/i386/vm_machdep.c == --- head/sys/i386/i386/vm_machdep.c Fri Dec 13 09:32:09 2019 (r355708) +++ head/sys/i386/i386/vm_machdep.c Fri Dec 13 09:32:16 2019 (r355709) @@ -598,7 +598,7 @@ sf_buf_shootdown(struct sf_buf *sf, int flags) if ((flags & SFB_CPUPRIVATE) == 0) { other_cpus = all_cpus; CPU_CLR(cpuid, _cpus); - CPU_NAND(_cpus, >cpumask); + CPU_ANDNOT(_cpus, >cpumask); if (!CPU_EMPTY(_cpus)) { CPU_OR(>cpumask, _cpus); smp_masked_invlpg(other_cpus,
svn commit: r355707 - head/sys/vm
Author: rlibby Date: Fri Dec 13 09:32:03 2019 New Revision: 355707 URL: https://svnweb.freebsd.org/changeset/base/355707 Log: uma: delay bucket_init() until we might actually enable buckets This helps with a bootstrapping problem in upcoming work. We don't first enable buckets until uma_startup2(), so we can delay bucket creation until then. The other two paths to bucket_enable() are both later, one in the pageout daemon (SI_SUB_KTHREAD_PAGE vs SI_SUB_VM) and one in uma_timeout() (first activated in uma_startup3()). Note that although some bucket functions are accessible before uma_startup2() (e.g. bucket_select() in zone_ctor()), none of them inspect ubz_zone. Discussed with: jeff Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22765 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Fri Dec 13 09:31:59 2019(r355706) +++ head/sys/vm/uma_core.c Fri Dec 13 09:32:03 2019(r355707) @@ -335,6 +335,8 @@ SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RWTUN static void bucket_enable(void) { + + KASSERT(booted >= BOOT_BUCKETS, ("Bucket enable before init")); bucketdisable = vm_page_count_min(); } @@ -2299,10 +2301,10 @@ zone_foreach(void (*zfunc)(uma_zone_t, void *arg), voi /* * Count how many pages do we need to bootstrap. VM supplies * its need in early zones in the argument, we add up our zones, - * which consist of: UMA Slabs, UMA Hash and 9 Bucket zones. The + * which consist of the UMA Slabs and UMA Hash zones. The * zone of zones and zone of kegs are accounted separately. */ -#defineUMA_BOOT_ZONES 11 +#defineUMA_BOOT_ZONES 2 /* Zone of zones and zone of kegs have arbitrary alignment. */ #defineUMA_BOOT_ALIGN 32 static int zsize, ksize; @@ -2417,8 +2419,6 @@ uma_startup(void *mem, int npages) sizeof(struct slabhead *) * UMA_HASH_SIZE_INIT, NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZFLAG_INTERNAL); - bucket_init(); - booted = BOOT_STRAPPED; } @@ -2439,8 +2439,9 @@ uma_startup2(void) #ifdef DIAGNOSTIC printf("Entering %s with %d boot pages left\n", __func__, boot_pages); #endif - booted = BOOT_BUCKETS; sx_init(_reclaim_lock, "umareclaim"); + bucket_init(); + booted = BOOT_BUCKETS; bucket_enable(); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355706 - head/sys/vm
Author: rlibby Date: Fri Dec 13 09:31:59 2019 New Revision: 355706 URL: https://svnweb.freebsd.org/changeset/base/355706 Log: uma dbg: flexible size for slab debug bitset too Recently (r355315) the size of the struct uma_slab bitset field us_free became dynamic instead of conservative. Now, make the debug bitset size dynamic too. The debug bitset is INVARIANTS-only, so in fact we don't care too much about the space savings that results from this, but enabling minimally-sized slabs on INVARIANTS builds is still important in order to be able to test new slab layouts effectively. Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22759 Modified: head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Fri Dec 13 09:28:44 2019(r355705) +++ head/sys/vm/uma_core.c Fri Dec 13 09:31:59 2019(r355706) @@ -292,6 +292,8 @@ static int sysctl_handle_uma_zone_frees(SYSCTL_HANDLER static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS); #ifdef INVARIANTS +static inline struct noslabbits *slab_dbg_bits(uma_slab_t slab, uma_keg_t keg); + static bool uma_dbg_kskip(uma_keg_t keg, void *mem); static bool uma_dbg_zskip(uma_zone_t zone, void *mem); static void uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *item); @@ -1201,7 +1203,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom slab->us_domain = domain; BIT_FILL(keg->uk_ipers, >us_free); #ifdef INVARIANTS - BIT_ZERO(SLAB_MAX_SETSIZE, >us_debugfree); + BIT_ZERO(keg->uk_ipers, slab_dbg_bits(slab, keg)); #endif if (keg->uk_init != NULL) { @@ -1484,6 +1486,15 @@ zero_init(void *mem, int size, int flags) return (0); } +#ifdef INVARIANTS +struct noslabbits * +slab_dbg_bits(uma_slab_t slab, uma_keg_t keg) +{ + + return ((void *)((char *)>us_free + BITSET_SIZE(keg->uk_ipers))); +} +#endif + /* * Actual size of embedded struct slab (!OFFPAGE). */ @@ -1492,7 +1503,7 @@ slab_sizeof(int nitems) { size_t s; - s = sizeof(struct uma_slab) + BITSET_SIZE(nitems); + s = sizeof(struct uma_slab) + BITSET_SIZE(nitems) * SLAB_BITSETS; return (roundup(s, UMA_ALIGN_PTR + 1)); } @@ -4514,12 +4525,10 @@ uma_dbg_alloc(uma_zone_t zone, uma_slab_t slab, void * keg = zone->uz_keg; freei = slab_item_index(slab, keg, item); - if (BIT_ISSET(SLAB_MAX_SETSIZE, freei, >us_debugfree)) + if (BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) panic("Duplicate alloc of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - BIT_SET_ATOMIC(SLAB_MAX_SETSIZE, freei, >us_debugfree); - - return; + BIT_SET_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); } /* @@ -4550,11 +4559,11 @@ uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *i panic("Unaligned free of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - if (!BIT_ISSET(SLAB_MAX_SETSIZE, freei, >us_debugfree)) + if (!BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) panic("Duplicate free of %p from zone %p(%s) slab %p(%d)\n", item, zone, zone->uz_name, slab, freei); - BIT_CLR_ATOMIC(SLAB_MAX_SETSIZE, freei, >us_debugfree); + BIT_CLR_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); } #endif /* INVARIANTS */ Modified: head/sys/vm/uma_int.h == --- head/sys/vm/uma_int.h Fri Dec 13 09:28:44 2019(r355705) +++ head/sys/vm/uma_int.h Fri Dec 13 09:31:59 2019(r355706) @@ -271,17 +271,26 @@ struct uma_slab { uint16_tus_freecount; /* How many are free? */ uint8_t us_flags; /* Page flags see uma.h */ uint8_t us_domain; /* Backing NUMA domain. */ -#ifdef INVARIANTS - struct slabbits us_debugfree; /* Debug bitmask. */ -#endif - struct noslabbits us_free; /* Free bitmask. */ + struct noslabbits us_free; /* Free bitmask, flexible. */ }; +_Static_assert(sizeof(struct uma_slab) == offsetof(struct uma_slab, us_free), +"us_free field must be last"); #if MAXMEMDOM >= 255 #error "Slab domain type insufficient" #endif typedef struct uma_slab * uma_slab_t; +/* + * On INVARIANTS builds, the slab contains a second bitset of the same size, + * "dbg_bits", which is laid out immediately after us_free. + */ +#ifdef INVARIANTS +#defineSLAB_BITSETS2 +#else +#defineSLAB_BITSETS1 +#endif + /* These three functions are for embedded (!OFFPAGE) use only. */ size_t slab_sizeof(int nitems);
svn commit: r355708 - head/sys/vm
Author: rlibby Date: Fri Dec 13 09:32:09 2019 New Revision: 355708 URL: https://svnweb.freebsd.org/changeset/base/355708 Log: uma: report slab efficiency Reviewed by: jeff Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22766 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Fri Dec 13 09:32:03 2019(r355707) +++ head/sys/vm/uma_core.c Fri Dec 13 09:32:09 2019(r355708) @@ -290,6 +290,7 @@ static int sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS); static int sysctl_handle_uma_zone_allocs(SYSCTL_HANDLER_ARGS); static int sysctl_handle_uma_zone_frees(SYSCTL_HANDLER_ARGS); static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS); +static int sysctl_handle_uma_slab_efficiency(SYSCTL_HANDLER_ARGS); #ifdef INVARIANTS static inline struct noslabbits *slab_dbg_bits(uma_slab_t slab, uma_keg_t keg); @@ -1948,6 +1949,10 @@ zone_alloc_sysctl(uma_zone_t zone, void *unused) SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "free", CTLFLAG_RD, >uk_free, 0, "items free in the slab layer"); + SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, + "efficiency", CTLFLAG_RD | CTLTYPE_INT | CTLFLAG_MPSAFE, + keg, 0, sysctl_handle_uma_slab_efficiency, "I", + "Slab utilization (100 - internal fragmentation %)"); } else SYSCTL_ADD_CONST_STRING(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "name", CTLFLAG_RD, nokeg, "Keg name"); @@ -4438,6 +4443,27 @@ sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS) sbuf_delete(); return (error); +} + +static int +sysctl_handle_uma_slab_efficiency(SYSCTL_HANDLER_ARGS) +{ + uma_keg_t keg = arg1; + int avail, effpct, total; + + total = keg->uk_ppera * PAGE_SIZE; + if ((keg->uk_flags & UMA_ZONE_OFFPAGE) != 0) + total += slab_sizeof(SLAB_MAX_SETSIZE); + /* +* We consider the client's requested size and alignment here, not the +* real size determination uk_rsize, because we also adjust the real +* size for internal implementation reasons (max bitset size). +*/ + avail = keg->uk_ipers * roundup2(keg->uk_size, keg->uk_align + 1); + if ((keg->uk_flags & UMA_ZONE_PCPU) != 0) + avail *= mp_maxid + 1; + effpct = 100 * avail / total; + return (sysctl_handle_int(oidp, , 0, req)); } #ifdef INVARIANTS ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355704 - stable/12/sys/mips/mips
Author: rlibby Date: Fri Dec 13 09:19:24 2019 New Revision: 355704 URL: https://svnweb.freebsd.org/changeset/base/355704 Log: MFC r355343: mips busdma: bzero map on alloc Modified: stable/12/sys/mips/mips/busdma_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/mips/mips/busdma_machdep.c == --- stable/12/sys/mips/mips/busdma_machdep.cFri Dec 13 08:41:37 2019 (r355703) +++ stable/12/sys/mips/mips/busdma_machdep.cFri Dec 13 09:19:24 2019 (r355704) @@ -155,8 +155,6 @@ struct bus_dmamap { bus_dma_tag_t dmat; struct memdesc mem; int flags; - void*origbuffer; - void*allocbuffer; TAILQ_ENTRY(bus_dmamap) freelist; STAILQ_ENTRY(bus_dmamap) links; bus_dmamap_callback_t *callback; @@ -204,11 +202,8 @@ dmamap_ctor(void *mem, int size, void *arg, int flags) dmat->map_count++; + bzero(map, sizeof(*map)); map->dmat = dmat; - map->flags = 0; - map->slist = NULL; - map->allocbuffer = NULL; - map->sync_count = 0; STAILQ_INIT(>bpages); return (0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355605 - head/sys/vm
Author: rlibby Date: Wed Dec 11 06:50:55 2019 New Revision: 355605 URL: https://svnweb.freebsd.org/changeset/base/355605 Log: uma: pretty print zone flags sysctl Requested by: jeff Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22748 Modified: head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Wed Dec 11 06:34:48 2019(r355604) +++ head/sys/vm/uma_core.c Wed Dec 11 06:50:55 2019(r355605) @@ -289,6 +289,7 @@ static int sysctl_vm_zone_count(SYSCTL_HANDLER_ARGS); static int sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS); static int sysctl_handle_uma_zone_allocs(SYSCTL_HANDLER_ARGS); static int sysctl_handle_uma_zone_frees(SYSCTL_HANDLER_ARGS); +static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS); #ifdef INVARIANTS static bool uma_dbg_kskip(uma_keg_t keg, void *mem); @@ -1896,8 +1897,9 @@ zone_alloc_sysctl(uma_zone_t zone, void *unused) oid = zone->uz_oid; SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "size", CTLFLAG_RD, >uz_size, 0, "Allocation size"); - SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, - "flags", CTLFLAG_RD, >uz_flags, 0, + SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, + "flags", CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE, + zone, 0, sysctl_handle_uma_zone_flags, "A", "Allocator configuration flags"); SYSCTL_ADD_U16(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "bucket_size", CTLFLAG_RD, >uz_bucket_size, 0, @@ -4406,6 +4408,24 @@ sysctl_handle_uma_zone_frees(SYSCTL_HANDLER_ARGS) cur = uma_zone_get_frees(zone); return (sysctl_handle_64(oidp, , 0, req)); +} + +static int +sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS) +{ + struct sbuf sbuf; + uma_zone_t zone = arg1; + int error; + + sbuf_new_for_sysctl(, NULL, 0, req); + if (zone->uz_flags != 0) + sbuf_printf(, "0x%b", zone->uz_flags, PRINT_UMA_ZFLAGS); + else + sbuf_printf(, "0"); + error = sbuf_finish(); + sbuf_delete(); + + return (error); } #ifdef INVARIANTS Modified: head/sys/vm/uma_int.h == --- head/sys/vm/uma_int.h Wed Dec 11 06:34:48 2019(r355604) +++ head/sys/vm/uma_int.h Wed Dec 11 06:50:55 2019(r355605) @@ -420,6 +420,32 @@ struct uma_zone { #defineUMA_ZFLAG_INHERIT \ (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY | UMA_ZFLAG_BUCKET) +#definePRINT_UMA_ZFLAGS"\20" \ +"\40CACHEONLY" \ +"\37TRASH" \ +"\36INTERNAL" \ +"\35BUCKET"\ +"\34RECLAIMING"\ +"\33CACHE" \ +"\22MINBUCKET" \ +"\21NUMA" \ +"\20PCPU" \ +"\17NODUMP"\ +"\16VTOSLAB" \ +"\15CACHESPREAD" \ +"\14MAXBUCKET" \ +"\13NOBUCKET" \ +"\12SECONDARY" \ +"\11HASH" \ +"\10VM"\ +"\7MTXCLASS" \ +"\6NOFREE" \ +"\5MALLOC" \ +"\4OFFPAGE"\ +"\3STATIC" \ +"\2ZINIT" \ +"\1PAGEABLE" + #undef UMA_ALIGN #ifdef _KERNEL ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355400 - head/sys/sys
Author: rlibby Date: Wed Dec 4 20:15:17 2019 New Revision: 355400 URL: https://svnweb.freebsd.org/changeset/base/355400 Log: bistring: avoid gcc -Wsign-compare Appease gcc after after r355377, which broke gcc builds. Reviewed by: dougm MFC with: r355377 Differential Revision:https://reviews.freebsd.org/D22682 Modified: head/sys/sys/bitstring.h Modified: head/sys/sys/bitstring.h == --- head/sys/sys/bitstring.hWed Dec 4 19:46:48 2019(r355399) +++ head/sys/sys/bitstring.hWed Dec 4 20:15:17 2019(r355400) @@ -306,7 +306,7 @@ bit_ffs_area_at(bitstr_t *_bitstr, int _start, int _nb while ((_test & (_test + 1)) != 0 && _b-- > 0) _test |= _test >> (((_size - 1) >> _b) + 1) / 2; /* Find the start of the first 0-area in _test. */ - _offset = (~_test == 0) ? _BITSTR_BITS : + _offset = (~_test == 0) ? (int)_BITSTR_BITS : ffsl(~_test) - 1; _value = (_curbitstr - _bitstr) * _BITSTR_BITS + _offset; @@ -353,7 +353,7 @@ bit_ffc_area_at(bitstr_t *_bitstr, int _start, int _nb while ((_test & (_test + 1)) != 0 && _b-- > 0) _test |= _test >> (((_size - 1) >> _b) + 1) / 2; /* Find the start of the first 0-area in _test. */ - _offset = (~_test == 0) ? _BITSTR_BITS : + _offset = (~_test == 0) ? (int)_BITSTR_BITS : ffsl(~_test) - 1; _value = (_curbitstr - _bitstr) * _BITSTR_BITS + _offset; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355396 - head/sys/kern
Author: rlibby Date: Wed Dec 4 18:21:29 2019 New Revision: 355396 URL: https://svnweb.freebsd.org/changeset/base/355396 Log: mbuf zones: take out the trash The mbuf zones were explicitly specifying the uma trash procedures on zcreate, conditionally on INVARIANTS, because that used to be necessary in order to get use-after-free checking for uma zones with non-empty constructors or destructors. After r355137 uma automatically invokes the trash constructor and destructor as long as no init and fini are specified. This now allows the mbuf zones to pass their constructors and destructors without needing to add on the uma trash procedures conditionally. Reviewed by: cem, jhb, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22583 Modified: head/sys/kern/kern_mbuf.c Modified: head/sys/kern/kern_mbuf.c == --- head/sys/kern/kern_mbuf.c Wed Dec 4 17:45:34 2019(r355395) +++ head/sys/kern/kern_mbuf.c Wed Dec 4 18:21:29 2019(r355396) @@ -322,12 +322,7 @@ mbuf_init(void *dummy) * Configure UMA zones for Mbufs, Clusters, and Packets. */ zone_mbuf = uma_zcreate(MBUF_MEM_NAME, MSIZE, - mb_ctor_mbuf, mb_dtor_mbuf, -#ifdef INVARIANTS - trash_init, trash_fini, -#else - NULL, NULL, -#endif + mb_ctor_mbuf, mb_dtor_mbuf, NULL, NULL, MSIZE - 1, UMA_ZONE_MAXBUCKET); if (nmbufs > 0) nmbufs = uma_zone_set_max(zone_mbuf, nmbufs); @@ -335,12 +330,7 @@ mbuf_init(void *dummy) uma_zone_set_maxaction(zone_mbuf, mb_reclaim); zone_clust = uma_zcreate(MBUF_CLUSTER_MEM_NAME, MCLBYTES, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); if (nmbclusters > 0) nmbclusters = uma_zone_set_max(zone_clust, nmbclusters); @@ -352,12 +342,7 @@ mbuf_init(void *dummy) /* Make jumbo frame zone too. Page size, 9k and 16k. */ zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); if (nmbjumbop > 0) nmbjumbop = uma_zone_set_max(zone_jumbop, nmbjumbop); @@ -365,12 +350,7 @@ mbuf_init(void *dummy) uma_zone_set_maxaction(zone_jumbop, mb_reclaim); zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc); if (nmbjumbo9 > 0) @@ -379,12 +359,7 @@ mbuf_init(void *dummy) uma_zone_set_maxaction(zone_jumbo9, mb_reclaim); zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc); if (nmbjumbo16 > 0) @@ -394,11 +369,7 @@ mbuf_init(void *dummy) zone_extpgs = uma_zcreate(MBUF_EXTPGS_MEM_NAME, sizeof(struct mbuf_ext_pgs), -#ifdef INVARIANTS - trash_ctor, trash_dtor, trash_init, trash_fini, -#else NULL, NULL, NULL, NULL, -#endif UMA_ALIGN_CACHE, 0); /* @@ -618,22 +589,12 @@ debugnet_mbuf_reinit(int nmbuf, int nclust, int clsize dn_clsize = clsize; dn_zone_mbuf = uma_zcache_create("debugnet_" MBUF_MEM_NAME, - MSIZE, mb_ctor_mbuf, mb_dtor_mbuf, -#ifdef INVARIANTS - trash_init, trash_fini, -#else - NULL, NULL, -#endif + MSIZE, mb_ctor_mbuf, mb_dtor_mbuf, NULL, NULL, dn_buf_import, dn_buf_release, _mbufq, UMA_ZONE_NOBUCKET); dn_zone_clust = uma_zcache_create("debugnet_" MBUF_CLUSTER_MEM_NAME, - clsize, mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + clsize, mb_ctor_clust, NULL, NULL, NULL, dn_buf_import, dn_buf_release, _clustq, UMA_ZONE_NOBUCKET); @@ -687,9 +648,6 @@ mb_ctor_mbuf(void *mem, int size, void *arg, int how) int flags; short type; -#ifdef INVARIANTS - trash_ctor(mem, size, arg, how); -#endif args = (struct mb_args *)arg; type = args->type; @@ -724,9 +682,6 @@ mb_dtor_mbuf(void *mem, int size, void *arg)
Re: svn commit: r355137 - head/sys/vm
On Tue, Dec 3, 2019 at 1:12 PM Ian Lepore wrote: > > On Tue, 2019-12-03 at 12:59 -0800, Ryan Libby wrote: > > > +* XXX UMA_ZONE_OFFPAGE. > > All over freebsd we have cryptic XXX comments that have no meaning to > anyone except whoever wrote them (and, I suspect, no meaning to those > people either after a couple months have elapsed). > > To the degree that XXX represents "possible trouble here" and/or "more > work to do here", I would argue that any placement of a new XXX > requires at least a sentence (and probably more like a paragraph) to > describe why it's there. > > -- Ian Yes, I agree it is cryptic. This specific XXX is discussed in the review and is a cookie crumb for planned future work: https://reviews.freebsd.org/D20722?id=64944#inline-140550 In this case the problem is pre-existing and the comment calls it out so that we don't miss it in a coming cleanup. I wrote the block comment directly above so that it would make sense when the correct flag check is eventually inserted. Ryan ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r355137 - head/sys/vm
On Tue, Dec 3, 2019 at 12:43 PM Gleb Smirnoff wrote: > > Ryan, > > On Wed, Nov 27, 2019 at 07:49:56PM +, Ryan Libby wrote: > R> Author: rlibby > R> Date: Wed Nov 27 19:49:55 2019 > R> New Revision: 355137 > R> URL: https://svnweb.freebsd.org/changeset/base/355137 > R> > R> Log: > R> uma: trash memory when ctor/dtor supplied too > R> > R> On INVARIANTS kernels, UMA has a use-after-free detection mechanism. > R> This mechanism previously required that all of the ctor/dtor/uminit/fini > R> arguments to uma_zcreate() be NULL in order to function. Now, it only > R> requires that uminit and fini be NULL; now, the trash ctor and dtor will > R> be called in addition to any supplied ctor or dtor. > R> > R> Also do a little refactoring for readability of the resulting logic. > R> > R> This enables use-after-free detection for more zones, and will allow for > R> simplification of some callers that worked around the previous > R> restriction (see kern_mbuf.c). > R> > R> Reviewed by: jeff, markj > R> Sponsored by: Dell EMC Isilon > R> Differential Revision: https://reviews.freebsd.org/D20722 > > If I understand the change correct, now items from UMA_ZONE_NOFREE zones > will be trashed, too. That would undermine purpose of UMA_ZONE_NOFREE. > Of course the flag is a hack, but some systems rely on it working. > > -- > Gleb Smirnoff The intent is not to change anything for NOFREE zones (i.e. still don't trash them). I didn't put all the detail in the commit log, but I did reword the block comment in uma_zcreate: > @@ -2302,14 +2307,17 @@ uma_zcreate(const char *name, size_t size, uma_ctor ct > args.fini = fini; > #ifdef INVARIANTS > /* > -* If a zone is being created with an empty constructor and > -* destructor, pass UMA constructor/destructor which checks for > -* memory use after free. > +* Inject procedures which check for memory use after free if we are > +* allowed to scramble the memory while it is not allocated. This > +* requires that: UMA is actually able to access the memory, no init > +* or fini procedures, no dependency on the initial value of the > +* memory, and no (legitimate) use of the memory after free. Note, > +* the ctor and dtor do not need to be empty. > +* > +* XXX UMA_ZONE_OFFPAGE. > */ > if ((!(flags & (UMA_ZONE_ZINIT | UMA_ZONE_NOFREE))) && > - ctor == NULL && dtor == NULL && uminit == NULL && fini == NULL) { > - args.ctor = trash_ctor; > - args.dtor = trash_dtor; > + uminit == NULL && fini == NULL) { > args.uminit = trash_init; > args.fini = trash_fini; > } Ryan ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355343 - head/sys/mips/mips
Author: rlibby Date: Tue Dec 3 17:43:52 2019 New Revision: 355343 URL: https://svnweb.freebsd.org/changeset/base/355343 Log: mips busdma: bzero map on alloc Maps from the mips busdma dmamap_zone were not completely initialized. In particular, pagesneeded and pagesreserved were not initialized. This could cause a crash. Remove some dead fields from mips struct bus_dmamap while here. Reported by: brooks Reviewed by: ian Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22638 Modified: head/sys/mips/mips/busdma_machdep.c Modified: head/sys/mips/mips/busdma_machdep.c == --- head/sys/mips/mips/busdma_machdep.c Tue Dec 3 17:06:48 2019 (r355342) +++ head/sys/mips/mips/busdma_machdep.c Tue Dec 3 17:43:52 2019 (r355343) @@ -156,8 +156,6 @@ struct bus_dmamap { bus_dma_tag_t dmat; struct memdesc mem; int flags; - void*origbuffer; - void*allocbuffer; TAILQ_ENTRY(bus_dmamap) freelist; STAILQ_ENTRY(bus_dmamap) links; bus_dmamap_callback_t *callback; @@ -205,11 +203,8 @@ dmamap_ctor(void *mem, int size, void *arg, int flags) dmat->map_count++; + bzero(map, sizeof(*map)); map->dmat = dmat; - map->flags = 0; - map->slist = NULL; - map->allocbuffer = NULL; - map->sync_count = 0; STAILQ_INIT(>bpages); return (0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355344 - head/sys/sys
Author: rlibby Date: Tue Dec 3 17:43:57 2019 New Revision: 355344 URL: https://svnweb.freebsd.org/changeset/base/355344 Log: bitset: avoid pessimized code when bitset size is not constant We have a couple optimizations for when the bitset is known to be just one word. But with dynamically sized bitsets, it was actually more work to determine the size than just to do the necessary computation. Now, only use the optimization when the size is known to be constant. Reviewed by: markj Discussed with: jeff Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22639 Modified: head/sys/sys/bitset.h Modified: head/sys/sys/bitset.h == --- head/sys/sys/bitset.h Tue Dec 3 17:43:52 2019(r355343) +++ head/sys/sys/bitset.h Tue Dec 3 17:43:57 2019(r355344) @@ -34,12 +34,19 @@ #ifndef _SYS_BITSET_H_ #define_SYS_BITSET_H_ +/* + * Whether expr is both constant and true. Result is itself constant. + * Used to enable optimizations for sets with a known small size. + */ +#define__constexpr_cond(expr) (__builtin_constant_p((expr)) && (expr)) + #define__bitset_mask(_s, n) \ - (1L << ((__bitset_words((_s)) == 1) ? \ + (1L << (__constexpr_cond(__bitset_words((_s)) == 1) ? \ (__size_t)(n) : ((n) % _BITSET_BITS))) #define__bitset_word(_s, n) \ - ((__bitset_words((_s)) == 1) ? 0 : ((n) / _BITSET_BITS)) + (__constexpr_cond(__bitset_words((_s)) == 1) ? \ +0 : ((n) / _BITSET_BITS)) #defineBIT_CLR(_s, n, p) \ ((p)->__bits[__bitset_word(_s, n)] &= ~__bitset_mask((_s), (n))) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355208 - head/sys/conf
Author: rlibby Date: Fri Nov 29 06:25:07 2019 New Revision: 355208 URL: https://svnweb.freebsd.org/changeset/base/355208 Log: kern.mk: -Wno-error=stringop-overflow for gcc due to false positives Demote gcc's Wstringop-overflow to Wno-error due to false positives. E.g. the riscv64 build with gcc 8.3.0 has been failing with this warning since r355062 [1]. A bug has been filed with gcc [2]. The warning was first introduced in gcc 7.1 [3]. Hopefully we can avoiding suppressing the warning in future gcc versions. [1] https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/16691/ [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92718 [3] https://gcc.gnu.org/wiki/WarningHistory Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22603 Modified: head/sys/conf/kern.mk Modified: head/sys/conf/kern.mk == --- head/sys/conf/kern.mk Fri Nov 29 06:25:03 2019(r355207) +++ head/sys/conf/kern.mk Fri Nov 29 06:25:07 2019(r355208) @@ -61,6 +61,9 @@ CWARNEXTRA+= -Wno-error=misleading-indentation \ -Wno-error=shift-overflow \ -Wno-error=tautological-compare .endif +.if ${COMPILER_VERSION} >= 70100 +CWARNEXTRA+= -Wno-error=stringop-overflow +.endif .if ${COMPILER_VERSION} >= 70200 CWARNEXTRA+= -Wno-error=memset-elt-size .endif ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355207 - head/sys/kern
Author: rlibby Date: Fri Nov 29 06:25:03 2019 New Revision: 355207 URL: https://svnweb.freebsd.org/changeset/base/355207 Log: ktls_session zone: don't need to specify uma trash The use of the uma trash procedures is automatic, there's no need to pass them explicitly here. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22582 Modified: head/sys/kern/uipc_ktls.c Modified: head/sys/kern/uipc_ktls.c == --- head/sys/kern/uipc_ktls.c Fri Nov 29 03:56:01 2019(r355206) +++ head/sys/kern/uipc_ktls.c Fri Nov 29 06:25:03 2019(r355207) @@ -357,11 +357,7 @@ ktls_init(void *dummy __unused) ktls_session_zone = uma_zcreate("ktls_session", sizeof(struct ktls_session), -#ifdef INVARIANTS - trash_ctor, trash_dtor, trash_init, trash_fini, -#else NULL, NULL, NULL, NULL, -#endif UMA_ALIGN_CACHE, 0); /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355166 - head/sys/vm
Author: rlibby Date: Thu Nov 28 04:15:16 2019 New Revision: 355166 URL: https://svnweb.freebsd.org/changeset/base/355166 Log: uma: move sysctl vm.uma defn out from under INVARIANTS Fix non-INVARIANTS builds after r355149. Reported by: Michael Butler Reviewed by: markj Differential Revision:https://reviews.freebsd.org/D22588 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Thu Nov 28 02:40:12 2019(r355165) +++ head/sys/vm/uma_core.c Thu Nov 28 04:15:16 2019(r355166) @@ -297,7 +297,6 @@ static bool uma_dbg_zskip(uma_zone_t zone, void *mem); static void uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *item); static void uma_dbg_alloc(uma_zone_t zone, uma_slab_t slab, void *item); -SYSCTL_NODE(_vm, OID_AUTO, uma, CTLFLAG_RW, 0, "Universal Memory Allocator"); static SYSCTL_NODE(_vm, OID_AUTO, debug, CTLFLAG_RD, 0, "Memory allocation debugging"); @@ -315,6 +314,8 @@ SYSCTL_COUNTER_U64(_vm_debug, OID_AUTO, skipped, CTLFL #endif SYSINIT(uma_startup3, SI_SUB_VM_CONF, SI_ORDER_SECOND, uma_startup3, NULL); + +SYSCTL_NODE(_vm, OID_AUTO, uma, CTLFLAG_RW, 0, "Universal Memory Allocator"); SYSCTL_PROC(_vm, OID_AUTO, zone_count, CTLFLAG_RD|CTLTYPE_INT, 0, 0, sysctl_vm_zone_count, "I", "Number of UMA zones"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355137 - head/sys/vm
Author: rlibby Date: Wed Nov 27 19:49:55 2019 New Revision: 355137 URL: https://svnweb.freebsd.org/changeset/base/355137 Log: uma: trash memory when ctor/dtor supplied too On INVARIANTS kernels, UMA has a use-after-free detection mechanism. This mechanism previously required that all of the ctor/dtor/uminit/fini arguments to uma_zcreate() be NULL in order to function. Now, it only requires that uminit and fini be NULL; now, the trash ctor and dtor will be called in addition to any supplied ctor or dtor. Also do a little refactoring for readability of the resulting logic. This enables use-after-free detection for more zones, and will allow for simplification of some callers that worked around the previous restriction (see kern_mbuf.c). Reviewed by: jeff, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20722 Modified: head/sys/vm/uma_core.c head/sys/vm/uma_int.h Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Wed Nov 27 19:34:33 2019(r355136) +++ head/sys/vm/uma_core.c Wed Nov 27 19:49:55 2019(r355137) @@ -1869,6 +1869,11 @@ zone_ctor(void *mem, int size, void *udata, int flags) for (i = 0; i < vm_ndomains; i++) TAILQ_INIT(>uz_domain[i].uzd_buckets); +#ifdef INVARIANTS + if (arg->uminit == trash_init && arg->fini == trash_fini) + zone->uz_flags |= UMA_ZFLAG_TRASH; +#endif + /* * This is a pure cache zone, no kegs. */ @@ -2302,14 +2307,17 @@ uma_zcreate(const char *name, size_t size, uma_ctor ct args.fini = fini; #ifdef INVARIANTS /* -* If a zone is being created with an empty constructor and -* destructor, pass UMA constructor/destructor which checks for -* memory use after free. +* Inject procedures which check for memory use after free if we are +* allowed to scramble the memory while it is not allocated. This +* requires that: UMA is actually able to access the memory, no init +* or fini procedures, no dependency on the initial value of the +* memory, and no (legitimate) use of the memory after free. Note, +* the ctor and dtor do not need to be empty. +* +* XXX UMA_ZONE_OFFPAGE. */ if ((!(flags & (UMA_ZONE_ZINIT | UMA_ZONE_NOFREE))) && - ctor == NULL && dtor == NULL && uminit == NULL && fini == NULL) { - args.ctor = trash_ctor; - args.dtor = trash_dtor; + uminit == NULL && fini == NULL) { args.uminit = trash_init; args.fini = trash_fini; } @@ -2462,15 +2470,14 @@ static void * item_ctor(uma_zone_t zone, void *udata, int flags, void *item) { #ifdef INVARIANTS - int skipdbg; + bool skipdbg; skipdbg = uma_dbg_zskip(zone, item); - if (zone->uz_ctor != NULL && - (!skipdbg || zone->uz_ctor != trash_ctor || - zone->uz_dtor != trash_dtor) && -#else - if (__predict_false(zone->uz_ctor != NULL) && + if (!skipdbg && (zone->uz_flags & UMA_ZFLAG_TRASH) != 0 && + zone->uz_ctor != trash_ctor) + trash_ctor(item, zone->uz_size, udata, flags); #endif + if (__predict_false(zone->uz_ctor != NULL) && zone->uz_ctor(item, zone->uz_size, udata, flags) != 0) { counter_u64_add(zone->uz_fails, 1); zone_free_item(zone, item, udata, SKIP_DTOR | SKIP_CNT); @@ -2486,6 +2493,31 @@ item_ctor(uma_zone_t zone, void *udata, int flags, voi return (item); } +static inline void +item_dtor(uma_zone_t zone, void *item, void *udata, enum zfreeskip skip) +{ +#ifdef INVARIANTS + bool skipdbg; + + skipdbg = uma_dbg_zskip(zone, item); + if (skip == SKIP_NONE && !skipdbg) { + if ((zone->uz_flags & UMA_ZONE_MALLOC) != 0) + uma_dbg_free(zone, udata, item); + else + uma_dbg_free(zone, NULL, item); + } +#endif + if (skip < SKIP_DTOR) { + if (zone->uz_dtor != NULL) + zone->uz_dtor(item, zone->uz_size, udata); +#ifdef INVARIANTS + if (!skipdbg && (zone->uz_flags & UMA_ZFLAG_TRASH) != 0 && + zone->uz_dtor != trash_dtor) + trash_dtor(item, zone->uz_size, udata); +#endif + } +} + /* See uma.h */ void * uma_zalloc_arg(uma_zone_t zone, void *udata, int flags) @@ -2523,6 +2555,7 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags if (zone->uz_ctor != NULL && zone->uz_ctor(item, zone->uz_size, udata, flags) != 0) { + counter_u64_add(zone->uz_fails, 1); zone->uz_fini(item, zone->uz_size);
svn commit: r355126 - in head/sys: kern sys
Author: rlibby Date: Wed Nov 27 01:54:39 2019 New Revision: 355126 URL: https://svnweb.freebsd.org/changeset/base/355126 Log: witness: sleepable rm locks are not sleepable in read mode There are two classes of rm lock, one "sleepable" and one not. But even a "sleepable" rm lock is only sleepable in write mode, and is non-sleepable when taken in read mode. Warn about sleepable rm locks in read mode as non-sleepable locks. Do this by defining a new lock operation flag, LOP_NOSLEEP, to indicate that a lock is non-sleepable despite what the LO_SLEEPABLE flag would indicate, and defining a new witness lock instance flag, LI_SLEEPABLE, to track the product of LO_SLEEPABLE and LOP_NOSLEEP on the lock instance. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22527 Modified: head/sys/kern/kern_rmlock.c head/sys/kern/subr_witness.c head/sys/sys/lock.h Modified: head/sys/kern/kern_rmlock.c == --- head/sys/kern/kern_rmlock.c Wed Nov 27 01:21:42 2019(r355125) +++ head/sys/kern/kern_rmlock.c Wed Nov 27 01:54:39 2019(r355126) @@ -652,8 +652,8 @@ _rm_rlock_debug(struct rmlock *rm, struct rm_priotrack KASSERT(!rm_wowned(rm), ("rm_rlock: wlock already held for %s @ %s:%d", rm->lock_object.lo_name, file, line)); - WITNESS_CHECKORDER(>lock_object, LOP_NEWORDER, file, line, - NULL); + WITNESS_CHECKORDER(>lock_object, + LOP_NEWORDER | LOP_NOSLEEP, file, line, NULL); } if (_rm_rlock(rm, tracker, trylock)) { @@ -663,7 +663,7 @@ _rm_rlock_debug(struct rmlock *rm, struct rm_priotrack else LOCK_LOG_LOCK("RMRLOCK", >lock_object, 0, 0, file, line); - WITNESS_LOCK(>lock_object, 0, file, line); + WITNESS_LOCK(>lock_object, LOP_NOSLEEP, file, line); TD_LOCKS_INC(curthread); return (1); } else if (trylock) Modified: head/sys/kern/subr_witness.c == --- head/sys/kern/subr_witness.cWed Nov 27 01:21:42 2019 (r355125) +++ head/sys/kern/subr_witness.cWed Nov 27 01:54:39 2019 (r355126) @@ -131,6 +131,7 @@ __FBSDID("$FreeBSD$"); #defineLI_RECURSEMASK 0x /* Recursion depth of lock instance. */ #defineLI_EXCLUSIVE0x0001 /* Exclusive lock instance. */ #defineLI_NORELEASE0x0002 /* Lock not allowed to be released. */ +#defineLI_SLEEPABLE0x0004 /* Lock may be held while sleeping. */ #ifndef WITNESS_COUNT #defineWITNESS_COUNT 1536 @@ -1302,7 +1303,7 @@ witness_checkorder(struct lock_object *lock, int flags * If we are locking Giant and this is a sleepable * lock, then skip it. */ - if ((lock1->li_lock->lo_flags & LO_SLEEPABLE) != 0 && + if ((lock1->li_flags & LI_SLEEPABLE) != 0 && lock == _object) continue; @@ -1311,6 +1312,7 @@ witness_checkorder(struct lock_object *lock, int flags * is Giant, then skip it. */ if ((lock->lo_flags & LO_SLEEPABLE) != 0 && + (flags & LOP_NOSLEEP) == 0 && lock1->li_lock == _object) continue; @@ -1320,15 +1322,16 @@ witness_checkorder(struct lock_object *lock, int flags * order violation to enfore a general lock order of * sleepable locks before non-sleepable locks. */ - if (((lock->lo_flags & LO_SLEEPABLE) != 0 && - (lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0)) + if ((lock->lo_flags & LO_SLEEPABLE) != 0 && + (flags & LOP_NOSLEEP) == 0 && + (lock1->li_flags & LI_SLEEPABLE) == 0) goto reversal; /* * If we are locking Giant and this is a non-sleepable * lock, then treat it as a reversal. */ - if ((lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0 && + if ((lock1->li_flags & LI_SLEEPABLE) == 0 && lock == _object) goto reversal; @@ -1378,11 +1381,12 @@ witness_checkorder(struct lock_object *lock, int flags /* * Ok, yell about it.
svn commit: r355103 - head/sys/netinet
Author: rlibby Date: Mon Nov 25 22:25:34 2019 New Revision: 355103 URL: https://svnweb.freebsd.org/changeset/base/355103 Log: in_mcast.c: need if_addr_lock around inm_release_deferred Apply a similar fix as for in6_mcast.c. Reviewed by: hselasky Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20740 Modified: head/sys/netinet/in_mcast.c Modified: head/sys/netinet/in_mcast.c == --- head/sys/netinet/in_mcast.c Mon Nov 25 22:25:10 2019(r355102) +++ head/sys/netinet/in_mcast.c Mon Nov 25 22:25:34 2019(r355103) @@ -1268,7 +1268,9 @@ in_joingroup_locked(struct ifnet *ifp, const struct in if (error) { CTR2(KTR_IGMPV3, "%s: dropping ref on %p", __func__, inm); + IF_ADDR_WLOCK(ifp); inm_release_deferred(inm); + IF_ADDR_WUNLOCK(ifp); } else { *pinm = inm; } @@ -2247,7 +2249,9 @@ out_inp_unlocked: if (is_new && imf) { if (imf->imf_inm != NULL) { IN_MULTI_LIST_LOCK(); + IF_ADDR_WLOCK(ifp); inm_release_deferred(imf->imf_inm); + IF_ADDR_WUNLOCK(ifp); IN_MULTI_LIST_UNLOCK(); } ip_mfilter_free(imf); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355102 - head/sys/netinet6
Author: rlibby Date: Mon Nov 25 22:25:10 2019 New Revision: 355102 URL: https://svnweb.freebsd.org/changeset/base/355102 Log: in6_joingroup_locked: need if_addr_lock around in6m_disconnect_locked It looks like the call that requires the lock was introduced in r337866. Reviewed by: hselasky Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20739 Modified: head/sys/netinet6/in6_mcast.c Modified: head/sys/netinet6/in6_mcast.c == --- head/sys/netinet6/in6_mcast.c Mon Nov 25 21:21:37 2019 (r355101) +++ head/sys/netinet6/in6_mcast.c Mon Nov 25 22:25:10 2019 (r355102) @@ -1267,6 +1267,7 @@ out_in6m_release: struct epoch_tracker et; CTR2(KTR_MLD, "%s: dropping ref on %p", __func__, inm); + IF_ADDR_WLOCK(ifp); NET_EPOCH_ENTER(et); CK_STAILQ_FOREACH(ifma, >if_multiaddrs, ifma_link) { if (ifma->ifma_protospec == inm) { @@ -1277,6 +1278,7 @@ out_in6m_release: in6m_disconnect_locked(, inm); in6m_rele_locked(, inm); NET_EPOCH_EXIT(et); + IF_ADDR_WUNLOCK(ifp); } else { *pinm = inm; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r355101 - head/sys/dev/cfi
On Mon, Nov 25, 2019 at 1:21 PM Ed Maste wrote: > > Author: emaste > Date: Mon Nov 25 21:21:37 2019 > New Revision: 355101 > URL: https://svnweb.freebsd.org/changeset/base/355101 > > Log: > cfi: check for inter overflow in cfi_devioctl > > Reported by:Pietro Oliva > Reviewed by: markj > MFC after:3 days > Security: Possible OOB read in root-only ioctl > Sponsored by: The FreeBSD Foundation > > Modified: > head/sys/dev/cfi/cfi_dev.c > > Modified: head/sys/dev/cfi/cfi_dev.c > == > --- head/sys/dev/cfi/cfi_dev.c Mon Nov 25 19:59:53 2019(r355100) > +++ head/sys/dev/cfi/cfi_dev.c Mon Nov 25 21:21:37 2019(r355101) > @@ -280,7 +280,8 @@ cfi_devioctl(struct cdev *dev, u_long cmd, caddr_t dat > rq = (struct cfiocqry *)data; > if (rq->offset >= sc->sc_size / sc->sc_width) > return (ESPIPE); > - if (rq->offset + rq->count > sc->sc_size / sc->sc_width) > + if (rq->offset > ULONG_MAX - rq->count || > + rq->offset + rq->count > sc->sc_size / sc->sc_width) > return (ENOSPC); > > while (!error && rq->count--) { > ___ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org" This seems to have broken the some builds. Need sys/limits.h. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r355089 - stable/12/sys/x86/include
On Mon, Nov 25, 2019 at 6:19 AM Konstantin Belousov wrote: > > Author: kib > Date: Mon Nov 25 14:18:55 2019 > New Revision: 355089 > URL: https://svnweb.freebsd.org/changeset/base/355089 > > Log: > MFC r355088: > Limit bus_dma_dmar_set_buswide() definition to kernel only. > > Modified: > stable/12/sys/x86/include/bus_dma.h > Directory Properties: > stable/12/ (props changed) > > Modified: stable/12/sys/x86/include/bus_dma.h > == > --- stable/12/sys/x86/include/bus_dma.h Mon Nov 25 14:16:41 2019 > (r355088) > +++ stable/12/sys/x86/include/bus_dma.h Mon Nov 25 14:18:55 2019 > (r355089) > @@ -179,7 +179,9 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t > return (tc->impl->map_complete(dmat, map, segs, nsegs, error)); > } > > +#ifdef _KERNEL > bool bus_dma_dmar_set_buswide(device_t dev); > +#endif > > #endif /* !_X86_BUS_DMA_H_ */ > > ___ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org" No complaint, but incidentally I think this didn't trip in current because r347836 deleted #include from camdd.c. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355084 - head/sys/vm
Author: rlibby Date: Mon Nov 25 07:38:31 2019 New Revision: 355084 URL: https://svnweb.freebsd.org/changeset/base/355084 Log: vm_object_collapse_scan_wait: drop locks before reacquiring Regression from r352174. In the vm_page_rename() failure case we forgot to unlock the vm object locks before sleeping and reacquiring them. Reviewed by: jeff Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22542 Modified: head/sys/vm/vm_object.c Modified: head/sys/vm/vm_object.c == --- head/sys/vm/vm_object.c Mon Nov 25 07:38:27 2019(r355083) +++ head/sys/vm/vm_object.c Mon Nov 25 07:38:31 2019(r355084) @@ -1496,6 +1496,8 @@ vm_object_collapse_scan_wait(vm_object_t object, vm_pa return (next); /* The page is only NULL when rename fails. */ if (p == NULL) { + VM_OBJECT_WUNLOCK(object); + VM_OBJECT_WUNLOCK(backing_object); vm_radix_wait(); } else { if (p->object == object) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355083 - head/sys/kern
Author: rlibby Date: Mon Nov 25 07:38:27 2019 New Revision: 355083 URL: https://svnweb.freebsd.org/changeset/base/355083 Log: sysctl sysctls: wire old buf before output with sysctl lock Several sysctl sysctls output to a user buffer while holding a non-sleepable lock that protects the sysctl topology. They need to wire the output buffer, or else they may try to sleep on a page fault. Reviewed by: cem, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D22528 Modified: head/sys/kern/kern_sysctl.c Modified: head/sys/kern/kern_sysctl.c == --- head/sys/kern/kern_sysctl.c Mon Nov 25 07:13:05 2019(r355082) +++ head/sys/kern/kern_sysctl.c Mon Nov 25 07:38:27 2019(r355083) @@ -1023,12 +1023,16 @@ sysctl_sysctl_name(SYSCTL_HANDLER_ARGS) { int *name = (int *) arg1; u_int namelen = arg2; - int error = 0; + int error; struct sysctl_oid *oid; struct sysctl_oid_list *lsp = __children, *lsp2; struct rm_priotracker tracker; char buf[10]; + error = sysctl_wire_old_buffer(req, 0); + if (error) + return (error); + SYSCTL_RLOCK(); while (namelen) { if (!lsp) { @@ -1265,6 +1269,10 @@ sysctl_sysctl_oidfmt(SYSCTL_HANDLER_ARGS) struct rm_priotracker tracker; int error; + error = sysctl_wire_old_buffer(req, 0); + if (error) + return (error); + SYSCTL_RLOCK(); error = sysctl_find_oid(arg1, arg2, , NULL, req); if (error) @@ -1294,6 +1302,10 @@ sysctl_sysctl_oiddescr(SYSCTL_HANDLER_ARGS) struct rm_priotracker tracker; int error; + error = sysctl_wire_old_buffer(req, 0); + if (error) + return (error); + SYSCTL_RLOCK(); error = sysctl_find_oid(arg1, arg2, , NULL, req); if (error) @@ -1318,6 +1330,10 @@ sysctl_sysctl_oidlabel(SYSCTL_HANDLER_ARGS) struct sysctl_oid *oid; struct rm_priotracker tracker; int error; + + error = sysctl_wire_old_buffer(req, 0); + if (error) + return (error); SYSCTL_RLOCK(); error = sysctl_find_oid(arg1, arg2, , NULL, req); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r349586 - head/sys/geom/eli
Author: rlibby Date: Mon Jul 1 22:06:16 2019 New Revision: 349586 URL: https://svnweb.freebsd.org/changeset/base/349586 Log: g_eli_create: only dec g_access acw if we inc'd it Reviewed by: cem, markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20743 Modified: head/sys/geom/eli/g_eli.c Modified: head/sys/geom/eli/g_eli.c == --- head/sys/geom/eli/g_eli.c Mon Jul 1 22:00:42 2019(r349585) +++ head/sys/geom/eli/g_eli.c Mon Jul 1 22:06:16 2019(r349586) @@ -827,7 +827,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp; struct g_consumer *cp; u_int i, threads; - int error; + int dcw, error; G_ELI_DEBUG(1, "Creating device %s%s.", bpp->name, G_ELI_SUFFIX); @@ -881,10 +881,8 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, * We don't open provider for writing only when user requested read-only * access. */ - if (sc->sc_flags & G_ELI_FLAG_RO) - error = g_access(cp, 1, 0, 1); - else - error = g_access(cp, 1, 1, 1); + dcw = (sc->sc_flags & G_ELI_FLAG_RO) ? 0 : 1; + error = g_access(cp, 1, dcw, 1); if (error != 0) { if (req != NULL) { gctl_error(req, "Cannot access %s (error=%d).", @@ -996,7 +994,7 @@ failed: mtx_destroy(>sc_queue_mtx); if (cp->provider != NULL) { if (cp->acr == 1) - g_access(cp, -1, -1, -1); + g_access(cp, -1, -dcw, -1); g_detach(cp); } g_destroy_consumer(cp); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r349587 - head/sys/geom/mirror
Author: rlibby Date: Mon Jul 1 22:06:36 2019 New Revision: 349587 URL: https://svnweb.freebsd.org/changeset/base/349587 Log: g_mirror_taste: avoid deadlock, always clear tasting flag If g_mirror_taste encountered an error at g_mirror_add_disk, it might try to g_mirror_destroy the device with the G_MIRROR_DEVICE_FLAG_TASTING flag still set. This would wait on a worker to complete the destruction with g_mirror_try_destroy, but that function bails out if the tasting flag is set, resulting in a deadlock. Clear the tasting flag before trying to destroy the device. Test Plan: sysctl debug.fail_point.mnowait="1%return" kyua test -k /usr/tests/sys/geom/class/mirror/Kyuafile Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20744 Modified: head/sys/geom/mirror/g_mirror.c Modified: head/sys/geom/mirror/g_mirror.c == --- head/sys/geom/mirror/g_mirror.c Mon Jul 1 22:06:16 2019 (r349586) +++ head/sys/geom/mirror/g_mirror.c Mon Jul 1 22:06:36 2019 (r349587) @@ -3291,6 +3291,7 @@ g_mirror_taste(struct g_class *mp, struct g_provider * sx_xlock(>sc_lock); sc->sc_flags |= G_MIRROR_DEVICE_FLAG_TASTING; error = g_mirror_add_disk(sc, pp, ); + sc->sc_flags &= ~G_MIRROR_DEVICE_FLAG_TASTING; if (error != 0) { G_MIRROR_DEBUG(0, "Cannot add disk %s to %s (error=%d).", pp->name, gp->name, error); @@ -3302,7 +3303,6 @@ g_mirror_taste(struct g_class *mp, struct g_provider * } gp = NULL; } - sc->sc_flags &= ~G_MIRROR_DEVICE_FLAG_TASTING; if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROY) != 0) { g_mirror_destroy(sc, G_MIRROR_DESTROY_HARD); g_topology_lock(); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r349373 - head/sys/netipsec
Author: rlibby Date: Tue Jun 25 15:43:52 2019 New Revision: 349373 URL: https://svnweb.freebsd.org/changeset/base/349373 Log: netipsec key_register: check for M_NOWAIT alloc failure Reviewed by: ae, cem Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20742 Modified: head/sys/netipsec/key.c Modified: head/sys/netipsec/key.c == --- head/sys/netipsec/key.c Tue Jun 25 14:56:13 2019(r349372) +++ head/sys/netipsec/key.c Tue Jun 25 15:43:52 2019(r349373) @@ -7164,7 +7164,7 @@ key_register(struct socket *so, struct mbuf *m, const return key_senderror(so, m, ENOBUFS); MGETHDR(n, M_NOWAIT, MT_DATA); - if (len > MHLEN) { + if (n != NULL && len > MHLEN) { if (!(MCLGET(n, M_NOWAIT))) { m_freem(n); n = NULL; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r349288 - head/sys/ddb
Author: rlibby Date: Sat Jun 22 05:35:23 2019 New Revision: 349288 URL: https://svnweb.freebsd.org/changeset/base/349288 Log: ddb show proc typo Modified: head/sys/ddb/db_ps.c Modified: head/sys/ddb/db_ps.c == --- head/sys/ddb/db_ps.cSat Jun 22 03:50:43 2019(r349287) +++ head/sys/ddb/db_ps.cSat Jun 22 05:35:23 2019(r349288) @@ -481,7 +481,7 @@ DB_SHOW_COMMAND(proc, db_show_proc) dump_args(p); db_printf("\n"); } - db_printf(" repear: %p reapsubtree: %d\n", + db_printf(" reaper: %p reapsubtree: %d\n", p->p_reaper, p->p_reapsubtree); db_printf(" sigparent: %d\n", p->p_sigparent); db_printf(" vmspace: %p\n", p->p_vmspace); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r348770 - in head: share/man/man9 sys/sys
Author: rlibby Date: Fri Jun 7 04:09:12 2019 New Revision: 348770 URL: https://svnweb.freebsd.org/changeset/base/348770 Log: Allow fail points to have separate declarations, definitions, and evals Submitted by: Matthew Bryan Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20546 Modified: head/share/man/man9/fail.9 head/sys/sys/fail.h Modified: head/share/man/man9/fail.9 == --- head/share/man/man9/fail.9 Fri Jun 7 02:36:26 2019(r348769) +++ head/share/man/man9/fail.9 Fri Jun 7 04:09:12 2019(r348770) @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2009 Isilon Inc http://www.isilon.com/ +.\" Copyright (c) 2009-2019 Dell EMC Isilon http://www.isilon.com/ .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -26,30 +26,36 @@ .\" .\" $FreeBSD$ .\" -.Dd March 15, 2016 +.Dd June 6, 2019 .Dt FAIL 9 .Os .Sh NAME +.Nm DEBUG_FP , .Nm KFAIL_POINT_CODE , .Nm KFAIL_POINT_CODE_FLAGS , .Nm KFAIL_POINT_CODE_COND , -.Nm KFAIL_POINT_RETURN , -.Nm KFAIL_POINT_RETURN_VOID , .Nm KFAIL_POINT_ERROR , +.Nm KFAIL_POINT_EVAL , +.Nm KFAIL_POINT_DECLARE , +.Nm KFAIL_POINT_DEFINE , .Nm KFAIL_POINT_GOTO , +.Nm KFAIL_POINT_RETURN , +.Nm KFAIL_POINT_RETURN_VOID , .Nm KFAIL_POINT_SLEEP_CALLBACKS , -.Nm fail_point , -.Nm DEBUG_FP +.Nm fail_point .Nd fail points .Sh SYNOPSIS .In sys/fail.h .Fn KFAIL_POINT_CODE "parent" "name" "code" .Fn KFAIL_POINT_CODE_FLAGS "parent" "name" "flags" "code" .Fn KFAIL_POINT_CODE_COND "parent" "name" "cond" "flags" "code" -.Fn KFAIL_POINT_RETURN "parent" "name" -.Fn KFAIL_POINT_RETURN_VOID "parent" "name" .Fn KFAIL_POINT_ERROR "parent" "name" "error_var" +.Fn KFAIL_POINT_EVAL "name" "code" +.Fn KFAIL_POINT_DECLARE "name" +.Fn KFAIL_POINT_DEFINE "parent" "name" "flags" .Fn KFAIL_POINT_GOTO "parent" "name" "error_var" "label" +.Fn KFAIL_POINT_RETURN "parent" "name" +.Fn KFAIL_POINT_RETURN_VOID "parent" "name" .Fn KFAIL_POINT_SLEEP_CALLBACKS "parent" "name" "pre_func" "pre_arg" "post_func" "post_arg" "code" .Sh DESCRIPTION Fail points are used to add code points where errors may be injected @@ -139,6 +145,22 @@ is the equivalent of .It Fn KFAIL_POINT_GOTO parent name error_var label is the equivalent of .Sy KFAIL_POINT_CODE(..., { error_var = RETURN_VALUE; goto label;}) +.El +.Pp +You can also introduce fail points by separating the declaration, +definition, and evaluation portions. +.Bl -inset +.It Fn KFAIL_POINT_DECLARE name +is used to declare the +.Sy fail_point +struct. +.It Fn KFAIL_POINT_DEFINE parent name flags +defines and initializes the +.Sy fail_point +and sets up its +.Xr sysctl 9 . +.It Fn KFAIL_POINT_EVAL name code +is used at the point that the fail point is executed. .El .Sh SYSCTL VARIABLES The Modified: head/sys/sys/fail.h == --- head/sys/sys/fail.h Fri Jun 7 02:36:26 2019(r348769) +++ head/sys/sys/fail.h Fri Jun 7 04:09:12 2019(r348770) @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2009 Isilon Inc http://www.isilon.com/ + * Copyright (c) 2009-2019 Dell EMC Isilon http://www.isilon.com/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -191,10 +191,12 @@ fail_point_eval(struct fail_point *fp, int *ret) __END_DECLS /* Declare a fail_point and its sysctl in a function. */ +#define KFAIL_POINT_DECLARE(name) \ +extern struct fail_point _FAIL_POINT_NAME(name) #define _FAIL_POINT_NAME(name) _fail_point_##name #define _FAIL_POINT_LOCATION() "(" __FILE__ ":" __XSTRING(__LINE__) ")" -#define _FAIL_POINT_INIT(parent, name, flags) \ - static struct fail_point _FAIL_POINT_NAME(name) = { \ +#define KFAIL_POINT_DEFINE(parent, name, flags) \ + struct fail_point _FAIL_POINT_NAME(name) = { \ .fp_name = #name, \ .fp_location = _FAIL_POINT_LOCATION(), \ .fp_ref_cnt = 0, \ @@ -213,6 +215,9 @@ __END_DECLS CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, \ &_FAIL_POINT_NAME(name), 0, \ fail_point_sysctl_status, "A", ""); + +#define _FAIL_POINT_INIT(parent, name, flags) \ + static KFAIL_POINT_DEFINE(parent, name, flags) #define _FAIL_POINT_EVAL(name, cond, code...) \ int RETURN_VALUE; \ \ @@ -222,7 +227,8 @@ __END_DECLS code; \ \ } - +#define KFAIL_POINT_EVAL(name, code...) \ + _FAIL_POINT_EVAL(name, true, code) /** * Instantiate a failpoint which returns "RETURN_VALUE" from the function ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all
svn commit: r347646 - head/sys/ddb
Author: rlibby Date: Thu May 16 05:29:54 2019 New Revision: 347646 URL: https://svnweb.freebsd.org/changeset/base/347646 Log: db show thread: avoid overflow in tick conversion The previous calculations for displaying the time since last switch easily overflowed, after less than 36 min for hz=1000. Now overflow takes 2000 times longer (as long as ticks takes to wrap). Reviewed by: cem, markj Sponsored by: Dell EMC Isilon Differential revision:https://reviews.freebsd.org/D20273 Modified: head/sys/ddb/db_ps.c Modified: head/sys/ddb/db_ps.c == --- head/sys/ddb/db_ps.cThu May 16 04:24:08 2019(r347645) +++ head/sys/ddb/db_ps.cThu May 16 05:29:54 2019(r347646) @@ -338,8 +338,8 @@ DB_SHOW_COMMAND(thread, db_show_thread) { struct thread *td; struct lock_object *lock; + u_int delta; bool comma; - int delta; /* Determine which thread to examine. */ if (have_addr) @@ -421,14 +421,14 @@ DB_SHOW_COMMAND(thread, db_show_thread) db_printf(" priority: %d\n", td->td_priority); db_printf(" container lock: %s (%p)\n", lock->lo_name, lock); if (td->td_swvoltick != 0) { - delta = (u_int)ticks - (u_int)td->td_swvoltick; - db_printf(" last voluntary switch: %d ms ago\n", - 1000 * delta / hz); + delta = ticks - td->td_swvoltick; + db_printf(" last voluntary switch: %u.%03u s ago\n", + delta / hz, (delta % hz) * 1000 / hz); } if (td->td_swinvoltick != 0) { - delta = (u_int)ticks - (u_int)td->td_swinvoltick; - db_printf(" last involuntary switch: %d ms ago\n", - 1000 * delta / hz); + delta = ticks - td->td_swinvoltick; + db_printf(" last involuntary switch: %u.%03u s ago\n", + delta / hz, (delta % hz) * 1000 / hz); } } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r347645 - head/sys/x86/iommu
Author: rlibby Date: Thu May 16 04:24:08 2019 New Revision: 347645 URL: https://svnweb.freebsd.org/changeset/base/347645 Log: iommu static analysis cleanup A static analyzer complained about a couple instances of checking a variable against NULL after already having dereferenced it. - dmar_gas_alloc_region: remove the tautological NULL checks - dmar_release_resources / dmar_fini_fault_log: don't deref unit->regs unless initialized. And while here, fix an inverted initialization check in dmar_fini_qi. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential revision:https://reviews.freebsd.org/D20263 Modified: head/sys/x86/iommu/intel_fault.c head/sys/x86/iommu/intel_gas.c head/sys/x86/iommu/intel_qi.c Modified: head/sys/x86/iommu/intel_fault.c == --- head/sys/x86/iommu/intel_fault.cThu May 16 03:30:36 2019 (r347644) +++ head/sys/x86/iommu/intel_fault.cThu May 16 04:24:08 2019 (r347645) @@ -291,12 +291,12 @@ void dmar_fini_fault_log(struct dmar_unit *unit) { + if (unit->fault_taskqueue == NULL) + return; + DMAR_LOCK(unit); dmar_disable_fault_intr(unit); DMAR_UNLOCK(unit); - - if (unit->fault_taskqueue == NULL) - return; taskqueue_drain(unit->fault_taskqueue, >fault_task); taskqueue_free(unit->fault_taskqueue); Modified: head/sys/x86/iommu/intel_gas.c == --- head/sys/x86/iommu/intel_gas.c Thu May 16 03:30:36 2019 (r347644) +++ head/sys/x86/iommu/intel_gas.c Thu May 16 04:24:08 2019 (r347645) @@ -546,7 +546,7 @@ dmar_gas_alloc_region(struct dmar_domain *domain, stru return (EBUSY); entry->start = prev->end; } - if (next != NULL && next->start < entry->end && + if (next->start < entry->end && (next->flags & DMAR_MAP_ENTRY_PLACE) == 0) { if ((next->flags & DMAR_MAP_ENTRY_RMRR) == 0) return (EBUSY); @@ -560,7 +560,7 @@ dmar_gas_alloc_region(struct dmar_domain *domain, stru dmar_gas_rb_remove(domain, prev); prev = NULL; } - if (next != NULL && next->start < entry->end) { + if (next->start < entry->end) { dmar_gas_rb_remove(domain, next); next = NULL; } Modified: head/sys/x86/iommu/intel_qi.c == --- head/sys/x86/iommu/intel_qi.c Thu May 16 03:30:36 2019 (r347644) +++ head/sys/x86/iommu/intel_qi.c Thu May 16 04:24:08 2019 (r347645) @@ -425,7 +425,7 @@ dmar_fini_qi(struct dmar_unit *unit) { struct dmar_qi_genseq gseq; - if (unit->qi_enabled) + if (!unit->qi_enabled) return; taskqueue_drain(unit->qi_taskqueue, >qi_task); taskqueue_free(unit->qi_taskqueue); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r347628 - in head/sys: amd64/amd64 i386/i386
Author: rlibby Date: Wed May 15 18:13:43 2019 New Revision: 347628 URL: https://svnweb.freebsd.org/changeset/base/347628 Log: x86: spell vpxor %zmm0 as vpxord Fix gcc/gas amd64 & i386 build after r347566. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D20264 Modified: head/sys/amd64/amd64/support.S head/sys/i386/i386/support.s Modified: head/sys/amd64/amd64/support.S == --- head/sys/amd64/amd64/support.S Wed May 15 17:58:08 2019 (r347627) +++ head/sys/amd64/amd64/support.S Wed May 15 18:13:43 2019 (r347628) @@ -1807,7 +1807,7 @@ ENTRY(mds_handler_skl_avx512) 1: movqPCPU(MDS_BUF), %rdi movqPCPU(MDS_BUF64), %rdx vmovdqa64 %zmm0, PCPU(MDS_TMP) - vpxor %zmm0, %zmm0, %zmm0 + vpxord %zmm0, %zmm0, %zmm0 lfence vorpd (%rdx), %zmm0, %zmm0 Modified: head/sys/i386/i386/support.s == --- head/sys/i386/i386/support.sWed May 15 17:58:08 2019 (r347627) +++ head/sys/i386/i386/support.sWed May 15 18:13:43 2019 (r347628) @@ -611,7 +611,7 @@ ENTRY(mds_handler_skl_avx512) 1: movlPCPU(MDS_BUF), %edi movlPCPU(MDS_BUF64), %edx vmovdqa64 %zmm0, PCPU(MDS_TMP) - vpxor %zmm0, %zmm0, %zmm0 + vpxord %zmm0, %zmm0, %zmm0 lfence vorpd (%edx), %zmm0, %zmm0 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r335094 - head/sys/ofed/drivers/infiniband/core
On Wed, Jun 13, 2018 at 4:30 PM, Matt Macy wrote: > Author: mmacy > Date: Wed Jun 13 23:30:54 2018 > New Revision: 335094 > URL: https://svnweb.freebsd.org/changeset/base/335094 > > Log: > fix OFED build after r335053 > > Modified: > head/sys/ofed/drivers/infiniband/core/ib_user_mad.c > > Modified: head/sys/ofed/drivers/infiniband/core/ib_user_mad.c > == > --- head/sys/ofed/drivers/infiniband/core/ib_user_mad.c Wed Jun 13 23:19:54 > 2018(r335093) > +++ head/sys/ofed/drivers/infiniband/core/ib_user_mad.c Wed Jun 13 23:30:54 > 2018(r335094) > @@ -130,7 +130,8 @@ struct ib_umad_packet { > > static struct class *umad_class; > > -static const dev_t base_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE); > +#define IBMKDEV(x, y) (((dev_t)(x) << 32) | (unsigned)(y)) > +static const dev_t base_dev = IBMKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE); > > static DEFINE_SPINLOCK(port_lock); > static DECLARE_BITMAP(dev_map, IB_UMAD_MAX_PORTS); > The scheme for major/minor encoding is different as of r335053. Won't that matter? In sys/ofed/drivers/infiniband/core/{ib_ucm.c,ib_uverbs_main.c} the pattern is to #define the MKDEV(). Following that would in ib_user_mad.c would also resolve this. Or makedev could be re-macroized with the new scheme. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"