svn commit: r352738 - head/contrib/ipfilter/tools
Author: cy Date: Thu Sep 26 03:09:45 2019 New Revision: 352738 URL: https://svnweb.freebsd.org/changeset/base/352738 Log: Teach the ippool parser about address families. This is a precursor to implementing IPv6 support within ippool which requires reworking radix_ipf.c. MFC after:1 month Modified: head/contrib/ipfilter/tools/ippool_y.y Modified: head/contrib/ipfilter/tools/ippool_y.y == --- head/contrib/ipfilter/tools/ippool_y.y Thu Sep 26 03:09:42 2019 (r352737) +++ head/contrib/ipfilter/tools/ippool_y.y Thu Sep 26 03:09:45 2019 (r352738) @@ -309,11 +309,27 @@ range:addrmask{ $$ = calloc(1, sizeof(*$$)); $$->ipn_info = 0; $$->ipn_addr = $1[0]; $$->ipn_mask = $1[1]; +#ifdef USE_INET6 + if (use_inet6) + $$->ipn_addr.adf_family = + AF_INET6; + else +#endif + $$->ipn_addr.adf_family = + AF_INET; } | '!' addrmask { $$ = calloc(1, sizeof(*$$)); $$->ipn_info = 1; $$->ipn_addr = $2[0]; $$->ipn_mask = $2[1]; +#ifdef USE_INET6 + if (use_inet6) + $$->ipn_addr.adf_family = + AF_INET6; + else +#endif + $$->ipn_addr.adf_family = + AF_INET; } | YY_STR{ $$ = add_poolhosts($1); free($1); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352737 - head/sys/contrib/ipfilter/netinet
Author: cy Date: Thu Sep 26 03:09:42 2019 New Revision: 352737 URL: https://svnweb.freebsd.org/changeset/base/352737 Log: ipf mistakenly regards UDP packets with a checksum of 0x as bad. Obtained from:NetBSD fil.c r1.30, NetBSD PR/54443 MFC after:3 days Modified: head/sys/contrib/ipfilter/netinet/fil.c Modified: head/sys/contrib/ipfilter/netinet/fil.c == --- head/sys/contrib/ipfilter/netinet/fil.c Thu Sep 26 02:54:45 2019 (r352736) +++ head/sys/contrib/ipfilter/netinet/fil.c Thu Sep 26 03:09:42 2019 (r352737) @@ -6730,8 +6730,11 @@ ipf_checkl4sum(fin) /*NOTREACHED*/ } - if (csump != NULL) + if (csump != NULL) { hdrsum = *csump; + if (fin->fin_p == IPPROTO_UDP && hdrsum == 0x) + hdrsum = 0x; + } if (dosum) { sum = fr_cksum(fin, fin->fin_ip, fin->fin_p, fin->fin_dp); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352736 - in head/sys/fs: nfs nfsclient
Author: rmacklem Date: Thu Sep 26 02:54:45 2019 New Revision: 352736 URL: https://svnweb.freebsd.org/changeset/base/352736 Log: Replace all mtx_assert() calls for n_mtx and ncl_iod_mutex with macros. To be consistent with replacing the mtx_lock()/mtx_unlock() calls on the NFS node mutex (n_mtx) and ncl_iod_mutex, this patch replaces all mtx_assert() calls on these mutexes with macros as well. This will simplify changing these locks to sx locks in a future commit. However, this change may be delayed indefinitely, since it appears there is a deadlock when vnode_pager_setsize() is called to shrink the size and the NFS node lock is held. There is no semantic change as a result of this commit. Suggested by: kib MFC after:1 week Modified: head/sys/fs/nfs/nfsport.h head/sys/fs/nfsclient/nfs_clnfsiod.c head/sys/fs/nfsclient/nfs_clnode.c Modified: head/sys/fs/nfs/nfsport.h == --- head/sys/fs/nfs/nfsport.h Thu Sep 26 01:54:24 2019(r352735) +++ head/sys/fs/nfs/nfsport.h Thu Sep 26 02:54:45 2019(r352736) @@ -688,10 +688,12 @@ void nfsrvd_rcv(struct socket *, void *, int); #defineNFSUNLOCKV4ROOTMUTEX() mtx_unlock(_v4root_mutex) #defineNFSLOCKNODE(n) mtx_lock(&((n)->n_mtx)) #defineNFSUNLOCKNODE(n)mtx_unlock(&((n)->n_mtx)) +#defineNFSASSERTNODE(n)mtx_assert(&((n)->n_mtx), MA_OWNED) #defineNFSLOCKMNT(m) mtx_lock(&((m)->nm_mtx)) #defineNFSUNLOCKMNT(m) mtx_unlock(&((m)->nm_mtx)) #defineNFSLOCKIOD()mtx_lock(_iod_mutex) #defineNFSUNLOCKIOD() mtx_unlock(_iod_mutex) +#defineNFSASSERTIOD() mtx_assert(_iod_mutex, MA_OWNED) #defineNFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx)) #defineNFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx)) #defineNFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx)) Modified: head/sys/fs/nfsclient/nfs_clnfsiod.c == --- head/sys/fs/nfsclient/nfs_clnfsiod.cThu Sep 26 01:54:24 2019 (r352735) +++ head/sys/fs/nfsclient/nfs_clnfsiod.cThu Sep 26 02:54:45 2019 (r352736) @@ -169,7 +169,7 @@ nfs_nfsiodnew_sync(void) { int error, i; - mtx_assert(_iod_mutex, MA_OWNED); + NFSASSERTIOD(); for (i = 0; i < ncl_iodmax; i++) { if (nfs_asyncdaemon[i] == 0) { nfs_asyncdaemon[i] = 1; @@ -206,7 +206,7 @@ void ncl_nfsiodnew(void) { - mtx_assert(_iod_mutex, MA_OWNED); + NFSASSERTIOD(); taskqueue_enqueue(taskqueue_thread, _nfsiodnew_task); } Modified: head/sys/fs/nfsclient/nfs_clnode.c == --- head/sys/fs/nfsclient/nfs_clnode.c Thu Sep 26 01:54:24 2019 (r352735) +++ head/sys/fs/nfsclient/nfs_clnode.c Thu Sep 26 02:54:45 2019 (r352736) @@ -212,7 +212,7 @@ ncl_releasesillyrename(struct vnode *vp, struct thread ASSERT_VOP_ELOCKED(vp, "releasesillyrename"); np = VTONFS(vp); - mtx_assert(>n_mtx, MA_OWNED); + NFSASSERTNODE(np); if (vp->v_type != VDIR) { sp = np->n_sillyrename; np->n_sillyrename = NULL; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352734 - head/sys/amd64/amd64
Author: cem Date: Thu Sep 26 01:51:55 2019 New Revision: 352734 URL: https://svnweb.freebsd.org/changeset/base/352734 Log: amd64 pmap: Clarify largemap bootverbose message units A PML4 covers 512 gigabytes, not gigabits. Use the typical B suffix for bytes. No functional change. Sponsored by: Dell EMC Isilon Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Thu Sep 26 01:50:26 2019(r352733) +++ head/sys/amd64/amd64/pmap.c Thu Sep 26 01:51:55 2019(r352734) @@ -1947,7 +1947,7 @@ pmap_init(void) if (lm_ents > LMEPML4I - LMSPML4I + 1) lm_ents = LMEPML4I - LMSPML4I + 1; if (bootverbose) - printf("pmap: large map %u PML4 slots (%lu Gb)\n", + printf("pmap: large map %u PML4 slots (%lu GB)\n", lm_ents, (u_long)lm_ents * (NBPML4 / 1024 / 1024 / 1024)); if (lm_ents != 0) { large_vmem = vmem_create("large", LARGEMAP_MIN_ADDRESS, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352733 - head/sys/amd64/amd64
Author: cem Date: Thu Sep 26 01:50:26 2019 New Revision: 352733 URL: https://svnweb.freebsd.org/changeset/base/352733 Log: amd64: Expose vm.pmap.large_map_pml4_entries as a sysctl node It's nice to have sysctl nodes for tunables. Sponsored by: Dell EMC Isilon Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Thu Sep 26 01:50:20 2019(r352732) +++ head/sys/amd64/amd64/pmap.c Thu Sep 26 01:50:26 2019(r352733) @@ -1965,6 +1965,11 @@ pmap_init(void) } } +SYSCTL_UINT(_vm_pmap, OID_AUTO, large_map_pml4_entries, +CTLFLAG_RDTUN | CTLFLAG_NOFETCH, _ents, 0, +"Maximum number of PML4 entries for use by large map (tunable). " +"Each entry corresponds to 512GB of address space."); + static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0, "2MB page mapping counters"); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352732 - in head/contrib/libarchive: cat cpio libarchive libarchive/test tar tar/test test_utils
Author: mm Date: Thu Sep 26 01:50:20 2019 New Revision: 352732 URL: https://svnweb.freebsd.org/changeset/base/352732 Log: MFV r352731: Sync libarchive with vendor. Relevant vendor changes: Issue #1237: Fix integer overflow in archive_read_support_filter_lz4.c PR #1249: Correct some typographical and grammatical errors. PR #1250: Minor corrections to the formatting of manual pages MFC after:1 week Modified: head/contrib/libarchive/cat/bsdcat.1 head/contrib/libarchive/cpio/bsdcpio.1 head/contrib/libarchive/libarchive/archive.h head/contrib/libarchive/libarchive/archive_entry.3 head/contrib/libarchive/libarchive/archive_entry_acl.3 head/contrib/libarchive/libarchive/archive_entry_misc.3 head/contrib/libarchive/libarchive/archive_entry_paths.3 head/contrib/libarchive/libarchive/archive_entry_perms.3 head/contrib/libarchive/libarchive/archive_entry_stat.3 head/contrib/libarchive/libarchive/archive_entry_time.3 head/contrib/libarchive/libarchive/archive_read.3 head/contrib/libarchive/libarchive/archive_read_add_passphrase.3 head/contrib/libarchive/libarchive/archive_read_data.3 head/contrib/libarchive/libarchive/archive_read_disk.3 head/contrib/libarchive/libarchive/archive_read_extract.3 head/contrib/libarchive/libarchive/archive_read_filter.3 head/contrib/libarchive/libarchive/archive_read_format.3 head/contrib/libarchive/libarchive/archive_read_free.3 head/contrib/libarchive/libarchive/archive_read_header.3 head/contrib/libarchive/libarchive/archive_read_new.3 head/contrib/libarchive/libarchive/archive_read_open.3 head/contrib/libarchive/libarchive/archive_read_set_options.3 head/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c head/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c head/contrib/libarchive/libarchive/archive_read_support_format_zip.c head/contrib/libarchive/libarchive/archive_string.c head/contrib/libarchive/libarchive/archive_util.3 head/contrib/libarchive/libarchive/archive_write.3 head/contrib/libarchive/libarchive/archive_write_blocksize.3 head/contrib/libarchive/libarchive/archive_write_data.3 head/contrib/libarchive/libarchive/archive_write_disk.3 head/contrib/libarchive/libarchive/archive_write_disk_posix.c head/contrib/libarchive/libarchive/archive_write_filter.3 head/contrib/libarchive/libarchive/archive_write_finish_entry.3 head/contrib/libarchive/libarchive/archive_write_format.3 head/contrib/libarchive/libarchive/archive_write_free.3 head/contrib/libarchive/libarchive/archive_write_header.3 head/contrib/libarchive/libarchive/archive_write_new.3 head/contrib/libarchive/libarchive/archive_write_open.3 head/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c head/contrib/libarchive/libarchive/archive_write_set_format_mtree.c head/contrib/libarchive/libarchive/archive_write_set_options.3 head/contrib/libarchive/libarchive/archive_write_set_passphrase.3 head/contrib/libarchive/libarchive/libarchive_changes.3 head/contrib/libarchive/libarchive/libarchive_internals.3 head/contrib/libarchive/libarchive/tar.5 head/contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c head/contrib/libarchive/libarchive/test/test_archive_write_set_format_filter_by_ext.c head/contrib/libarchive/libarchive/test/test_read_format_raw.c head/contrib/libarchive/libarchive/test/test_read_format_zip.c head/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c head/contrib/libarchive/libarchive/test/test_write_filter_zstd.c head/contrib/libarchive/tar/bsdtar.1 head/contrib/libarchive/tar/test/test_option_n.c head/contrib/libarchive/tar/test/test_option_xattrs.c head/contrib/libarchive/test_utils/test_main.c Directory Properties: head/contrib/libarchive/ (props changed) Modified: head/contrib/libarchive/cat/bsdcat.1 == --- head/contrib/libarchive/cat/bsdcat.1Thu Sep 26 01:42:09 2019 (r352731) +++ head/contrib/libarchive/cat/bsdcat.1Thu Sep 26 01:50:20 2019 (r352732) @@ -34,16 +34,15 @@ .Nm .Op options .Op files -.Pp .Sh DESCRIPTION .Nm expands files to standard output. .Sh OPTIONS .Nm typically takes a filename as an argument or reads standard input when used in a -pipe. In both cases decompressed data it written to standard output. +pipe. +In both cases decompressed data it written to standard output. .Sh EXAMPLES -.Pp To decompress a file: .Pp .Dl bsdcat example.txt.gz > example.txt @@ -55,8 +54,8 @@ To decompress standard input in a pipe: Both examples achieve the same results - a decompressed file by redirecting output. .Sh SEE ALSO -.Xr uncompress 1 , -.Xr zcat 1 , .Xr bzcat 1 , +.Xr uncompress 1 , .Xr xzcat 1 , -.Xr libarchive-formats 5 , +.Xr zcat 1 , +.Xr libarchive-formats 5 Modified: head/contrib/libarchive/cpio/bsdcpio.1
svn commit: r352730 - head/sys/riscv/riscv
Author: mhorne Date: Thu Sep 26 00:58:47 2019 New Revision: 352730 URL: https://svnweb.freebsd.org/changeset/base/352730 Log: Fix some broken relocation handling In a few cases, the symbol lookup is missing before attempting to perform the relocation. While the relocation types affected are currently unused, this results in an uninitialized variable warning, that is escalated to an error when building with clang. Reviewed by: markj MFC after:3 days Differential Revision:https://reviews.freebsd.org/D21773 Modified: head/sys/riscv/riscv/elf_machdep.c Modified: head/sys/riscv/riscv/elf_machdep.c == --- head/sys/riscv/riscv/elf_machdep.c Thu Sep 26 00:54:07 2019 (r352729) +++ head/sys/riscv/riscv/elf_machdep.c Thu Sep 26 00:58:47 2019 (r352730) @@ -373,6 +373,10 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; case R_RISCV_PCREL_HI20: + error = lookup(lf, symidx, 1, ); + if (error != 0) + return (-1); + val = addr - (Elf_Addr)where; insn32p = (uint32_t *)where; before32 = *insn32p; @@ -385,6 +389,10 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; case R_RISCV_PCREL_LO12_I: + error = lookup(lf, symidx, 1, ); + if (error != 0) + return (-1); + val = addr - (Elf_Addr)where; insn32p = (uint32_t *)where; before32 = *insn32p; @@ -396,6 +404,10 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; case R_RISCV_PCREL_LO12_S: + error = lookup(lf, symidx, 1, ); + if (error != 0) + return (-1); + val = addr - (Elf_Addr)where; insn32p = (uint32_t *)where; before32 = *insn32p; @@ -412,6 +424,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas if (error != 0) return (-1); + val = addr; insn32p = (uint32_t *)where; before32 = *insn32p; imm20 = calc_hi20_imm(val); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352729 - head/sys/riscv/riscv
Author: mhorne Date: Thu Sep 26 00:54:07 2019 New Revision: 352729 URL: https://svnweb.freebsd.org/changeset/base/352729 Log: Cleanup of elf_machdep.c Fix some style(9) violations. This also changes the name of the machine-dependent sysctl kern.debug_kld to debug.kld_reloc, and changes its type from int to bool. This is acceptable since we are not currently concerned with preserving the RISC-V ABI. Reviewed by: markj, kp MFC after:3 days Differential Revision:https://reviews.freebsd.org/D21772 Modified: head/sys/riscv/riscv/elf_machdep.c Modified: head/sys/riscv/riscv/elf_machdep.c == --- head/sys/riscv/riscv/elf_machdep.c Thu Sep 26 00:35:06 2019 (r352728) +++ head/sys/riscv/riscv/elf_machdep.c Thu Sep 26 00:54:07 2019 (r352729) @@ -109,13 +109,11 @@ static Elf64_Brandinfo freebsd_brand_info = { }; SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_FIRST, - (sysinit_cfunc_t) elf64_insert_brand_entry, - _brand_info); +(sysinit_cfunc_t)elf64_insert_brand_entry, _brand_info); -static int debug_kld; -SYSCTL_INT(_kern, OID_AUTO, debug_kld, - CTLFLAG_RW, _kld, 0, - "Activate debug prints in elf_reloc_internal()"); +static bool debug_kld; +SYSCTL_BOOL(_debug, OID_AUTO, kld_reloc, CTLFLAG_RW, _kld, 0, +"Activate debug prints in elf_reloc_internal()"); struct type2str_ent { int type; @@ -274,7 +272,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas uint32_t before32_1; uint32_t before32; uint64_t before64; - uint32_t* insn32p; + uint32_t *insn32p; uint32_t imm20; int error; @@ -282,15 +280,15 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case ELF_RELOC_RELA: rela = (const Elf_Rela *)data; where = (Elf_Addr *)(relocbase + rela->r_offset); - insn32p = (uint32_t*)where; + insn32p = (uint32_t *)where; addend = rela->r_addend; rtype = ELF_R_TYPE(rela->r_info); symidx = ELF_R_SYM(rela->r_info); break; default: printf("%s:%d unknown reloc type %d\n", - __FUNCTION__, __LINE__, type); - return -1; + __FUNCTION__, __LINE__, type); + return (-1); } switch (rtype) { @@ -301,43 +299,36 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_RISCV_JUMP_SLOT: error = lookup(lf, symidx, 1, ); if (error != 0) - return -1; + return (-1); val = addr; before64 = *where; if (*where != val) *where = val; - if (debug_kld) - printf("%p %c %-24s %016lx -> %016lx\n", - where, - (local? 'l': 'g'), - reloctype_to_str(rtype), - before64, *where); + printf("%p %c %-24s %016lx -> %016lx\n", where, + (local ? 'l' : 'g'), reloctype_to_str(rtype), + before64, *where); break; case R_RISCV_RELATIVE: before64 = *where; - *where = elf_relocaddr(lf, relocbase + addend); - if (debug_kld) - printf("%p %c %-24s %016lx -> %016lx\n", - where, - (local? 'l': 'g'), - reloctype_to_str(rtype), - before64, *where); + printf("%p %c %-24s %016lx -> %016lx\n", where, + (local ? 'l' : 'g'), reloctype_to_str(rtype), + before64, *where); break; case R_RISCV_JAL: error = lookup(lf, symidx, 1, ); if (error != 0) - return -1; + return (-1); val = addr - (Elf_Addr)where; - if ((val <= -(1UL << 20) || (1UL << 20) <= val)) { + if (val <= -(1UL << 20) || (1UL << 20) <= val) { printf("kldload: huge offset against R_RISCV_JAL\n"); - return -1; + return (-1); } before32 = *insn32p; @@ -345,13 +336,10 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas *insn32p = insert_imm(*insn32p, val, 10, 1, 21); *insn32p = insert_imm(*insn32p, val, 11, 11, 20); *insn32p = insert_imm(*insn32p, val, 19, 12, 12); - if (debug_kld) - printf("%p %c %-24s %08x -> %08x\n", -
svn commit: r352728 - head/sys/kern
Author: mav Date: Thu Sep 26 00:35:06 2019 New Revision: 352728 URL: https://svnweb.freebsd.org/changeset/base/352728 Log: Microoptimize sched_pickcpu() CPU affinity on SMT. Use of CPU_FFS() to implement CPUSET_FOREACH() allows to save up to ~0.5% of CPU time on 72-thread SMT system doing 80K IOPS to NVMe from one thread. MFC after:1 month Sponsored by: iXsystems, Inc. Modified: head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_ule.c == --- head/sys/kern/sched_ule.c Wed Sep 25 22:53:30 2019(r352727) +++ head/sys/kern/sched_ule.c Thu Sep 26 00:35:06 2019(r352728) @@ -643,10 +643,6 @@ struct cpu_search { #defineCPU_SEARCH_HIGHEST 0x2 #defineCPU_SEARCH_BOTH (CPU_SEARCH_LOWEST|CPU_SEARCH_HIGHEST) -#defineCPUSET_FOREACH(cpu, mask) \ - for ((cpu) = 0; (cpu) <= mp_maxid; (cpu)++) \ - if (CPU_ISSET(cpu, )) - static __always_inline int cpu_search(const struct cpu_group *cg, struct cpu_search *low, struct cpu_search *high, const int match); int __noinline cpu_search_lowest(const struct cpu_group *cg, @@ -1292,13 +1288,17 @@ sched_pickcpu(struct thread *td, int flags) tdq->tdq_lowpri >= PRI_MIN_IDLE && SCHED_AFFINITY(ts, CG_SHARE_L2)) { if (cg->cg_flags & CG_FLAG_THREAD) { - CPUSET_FOREACH(cpu, cg->cg_mask) { - if (TDQ_CPU(cpu)->tdq_lowpri < PRI_MIN_IDLE) + /* Check all SMT threads for being idle. */ + for (cpu = CPU_FFS(>cg_mask) - 1; ; cpu++) { + if (CPU_ISSET(cpu, >cg_mask) && + TDQ_CPU(cpu)->tdq_lowpri < PRI_MIN_IDLE) break; + if (cpu >= mp_maxid) { + SCHED_STAT_INC(pickcpu_idle_affinity); + return (ts->ts_cpu); + } } - } else - cpu = INT_MAX; - if (cpu > mp_maxid) { + } else { SCHED_STAT_INC(pickcpu_idle_affinity); return (ts->ts_cpu); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r352661 - head/sys/netinet/tcp_stacks
On Wed, 25 Sep 2019 at 17:13, Dimitry Andric wrote: > > > Interesting, it seems Clang doesn't even warn in the case of casting a > > uint64_t to a 32-bit pointer. Looks like there are some useful > > warnings that ought to be implemented. > > There is -Wconversion for this, or the more specific -Wshorten-64-to-32: But it's not all of -Wconversion I think we want or even 64- to 32-bit warnings, but particularly conversions between pointers and integers of different sizes. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352727 - in head: lib/libc/sys tests/sys/kern
Author: kevans Date: Wed Sep 25 22:53:30 2019 New Revision: 352727 URL: https://svnweb.freebsd.org/changeset/base/352727 Log: Add SPDX tags to recently added files Reported by: Pawel Biernacki Modified: head/lib/libc/sys/shm_open.c head/tests/sys/kern/memfd_test.c Modified: head/lib/libc/sys/shm_open.c == --- head/lib/libc/sys/shm_open.cWed Sep 25 21:23:30 2019 (r352726) +++ head/lib/libc/sys/shm_open.cWed Sep 25 22:53:30 2019 (r352727) @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2019 Kyle Evans * All rights reserved. * Modified: head/tests/sys/kern/memfd_test.c == --- head/tests/sys/kern/memfd_test.cWed Sep 25 21:23:30 2019 (r352726) +++ head/tests/sys/kern/memfd_test.cWed Sep 25 22:53:30 2019 (r352727) @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2019 Kyle Evans * All rights reserved. * ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352726 - head/usr.sbin/efibootmgr
Author: yuripv Date: Wed Sep 25 21:23:30 2019 New Revision: 352726 URL: https://svnweb.freebsd.org/changeset/base/352726 Log: efibootmgr(8): fix markup and style issues - split synopsis into separate options that can't be used together - sort options - fix (style) issues reported by mandoc lint Reviewed by: imp Differential Revision:https://reviews.freebsd.org/D21710 Modified: head/usr.sbin/efibootmgr/efibootmgr.8 Modified: head/usr.sbin/efibootmgr/efibootmgr.8 == --- head/usr.sbin/efibootmgr/efibootmgr.8 Wed Sep 25 20:46:09 2019 (r352725) +++ head/usr.sbin/efibootmgr/efibootmgr.8 Wed Sep 25 21:23:30 2019 (r352726) @@ -24,20 +24,42 @@ .\" .\" $FreeBSD$ .\" -.Dd December 28, 2018 +.Dd September 24, 2019 .Dt EFIBOOTMGR 8 .Os .Sh NAME -.Nm efibootmgr +.Nm efibootmgr .Nd manipulate the EFI Boot Manager .Sh SYNOPSIS -.Op Fl aAnNB -.Op Fl b Ar bootnum -.Op Fl t Ar timeout -.Op Fl T -.Op Fl o Ar bootorder +.Nm .Op Fl v -.Op Fl c l Ar loader [ Fl k Ar kernel ] [ Fl L Ar label ] [ Fl -dry-run ] +.Nm +.Fl a +.Fl b Ar bootnum +.Nm +.Fl A +.Fl b Ar bootnum +.Nm +.Fl B +.Fl b Ar bootnum +.Nm +.Fl c +.Fl l Ar loader +.Op Fl aD +.Op Fl b Ar bootnum +.Op Fl k Ar kernel +.Op Fl L Ar label +.Nm +.Fl n +.Fl b Ar bootnum +.Nm +.Fl N +.Nm +.Fl o Ar bootorder +.Nm +.Fl t Ar timeout +.Nm +.Fl T .Sh "DESCRIPTION" .Nm manipulates how UEFI Boot Managers boot the system. @@ -50,13 +72,13 @@ The UEFI standard defines how hosts may control what i bootstrap the system. Each method is encapsulated within a persistent UEFI variable, stored by the UEFI BIOS of the form -.Va Boot . +.Cm Boot Ns Em . These variables are numbered, describe where to load the bootstrap program from, and whether or not the method is active. The boot order of these methods is controlled by another variable -.Va BootOrder . -The currently booting method is communicated using -.Va BootCurrent . +.Cm BootOrder . +The currently booting method is communicated using +.Cm BootCurrent . A global timeout can also be set. .Pp .Nm @@ -64,91 +86,133 @@ requires that the kernel efirt module be loaded to get non-volatile variables. .Pp The following options are available: -.Bl -tag -width 28m -.It Fl c Fl -create -Create a new Boot Variable -.It Fl l -loader Ar loader -The path to and name of the loader. -.It Fl k -kernel Ar kernel -The path to and name of the kernel. +.Bl -tag -width Ds +.It Fl a -activate +Activate the given +.Ar bootnum +boot entry, or the new entry when used with +.Fl c . +.It Fl A -deactivate +Deactivate the given +.Ar bootnum +boot entry. .It Fl b -bootnum Ar bootnum -When creating or modifying an entry, use bootnum as the index. +When creating or modifying an entry, use +.Ar bootnum +as the index. When creating a new entry, fail if it already exists. -.It Fl L -label Ar label -An optional description for the entry. +.It Fl B -delete +Delete the given +.Ar bootnum +boot entry. +.It Fl c -create +Create a new +.Cm Boot +variable. .It Fl D -dry-run Process but do not change any variables. -.It Fl B -delete -Delete the given bootnum boot entry. -.It Fl a -activate -Activate the given bootnum boot entry, or the new entry when used with -c. -.It Fl A -deactivate -Deactivate the given bootnum boot entry. +.It Fl k -kernel Ar kernel +The path to and name of the kernel. +.It Fl l -loader Ar loader +The path to and name of the loader. +.It Fl L -label Ar label +An optional description for the entry. .It Fl n -bootnext -Set bootnum boot entry as the BootNext variable. -.It Fl N -delete-bootnext -Delete the BootNext optional variable. +Set +.Ar bootnum +boot entry as the +.Cm BootNext +variable. +.It Fl N -delete-bootnext +Delete the +.Cm BootNext +optional variable. .It Fl o -bootorder Ar bootorder -Set BootOrder variable to the given comma delimited set of bootnums. -The numbers are in hex to match Boot, but may omit leading zeros. +Set +.Cm BootOrder +variable to the given comma delimited set of +.Ar bootnum Ns s . +The numbers are in hex to match +.Cm Boot Ns Em , +but may omit leading zeros. .It Fl t -set-timeout Ar timeout Set the bootmenu timeout value. .It Fl T -del-timeout -Delete the BootTimeout variable. +Delete the +.Cm BootTimeout +variable. .It Fl v -verbose Display the device path of boot entries in the output. .El -.Pp .Sh Examples +To display the current +.Cm Boot +related variables in the system: .Pp -To display the current Boot related variables in the system: -.Pp .Dl efibootmgr [-v] .Pp -This will display the optional BootNext bootnum, BootCurrent, -or currently booted bootnum, followed by the optional Timeout value, any -BootOrder that may be set, followed finally by all currently defined Boot -variables, active or not. The verbose flag will augment this output with -the disk partition uuids, size/offset and device-path of the -variable. +This will
Re: svn commit: r352661 - head/sys/netinet/tcp_stacks
On 25 Sep 2019, at 15:36, Ed Maste wrote: > > On Tue, 24 Sep 2019 at 17:39, Bruce Evans wrote: >> >> On i386, these types have different sizes, so >> gcc detects the type mismatch. clang is too broken to report this type >> mismatch. > > Interesting, it seems Clang doesn't even warn in the case of casting a > uint64_t to a 32-bit pointer. Looks like there are some useful > warnings that ought to be implemented. There is -Wconversion for this, or the more specific -Wshorten-64-to-32: $ cat shorten.c int foo(long l) { return l; } $ clang -Wconversion -c shorten.c shorten.c:3:10: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] return l; ~~ ^ 1 warning generated. But for some reason this warning isn't enabled by default, even with -Wall. I guess you would get a zillion warnings on our tree, if you enabled this. :) -Dimitry signature.asc Description: Message signed with OpenPGP
svn commit: r352725 - in head/sys: dev/firewire net
Author: glebius Date: Wed Sep 25 20:46:09 2019 New Revision: 352725 URL: https://svnweb.freebsd.org/changeset/base/352725 Log: style(9): remove extraneous empty lines Modified: head/sys/dev/firewire/if_fwip.c head/sys/net/if_ethersubr.c head/sys/net/if_vlan.c Modified: head/sys/dev/firewire/if_fwip.c == --- head/sys/dev/firewire/if_fwip.c Wed Sep 25 20:01:49 2019 (r352724) +++ head/sys/dev/firewire/if_fwip.c Wed Sep 25 20:46:09 2019 (r352725) @@ -717,7 +717,6 @@ fwip_stream_input(struct fw_xferq *xferq) uint16_t src; uint32_t *p; - fwip = (struct fwip_softc *)xferq->sc; ifp = fwip->fw_softc.fwip_ifp; Modified: head/sys/net/if_ethersubr.c == --- head/sys/net/if_ethersubr.c Wed Sep 25 20:01:49 2019(r352724) +++ head/sys/net/if_ethersubr.c Wed Sep 25 20:46:09 2019(r352725) @@ -800,7 +800,6 @@ VNET_SYSUNINIT(vnet_ether_uninit, SI_SUB_PROTO_IF, SI_ static void ether_input(struct ifnet *ifp, struct mbuf *m) { - struct mbuf *mn; /* Modified: head/sys/net/if_vlan.c == --- head/sys/net/if_vlan.c Wed Sep 25 20:01:49 2019(r352724) +++ head/sys/net/if_vlan.c Wed Sep 25 20:46:09 2019(r352725) @@ -247,7 +247,6 @@ static struct sx _VLAN_SX_ID; #defineVLAN_XLOCK_ASSERT() sx_assert(&_VLAN_SX_ID, SA_XLOCKED) #defineVLAN_SXLOCK_ASSERT()sx_assert(&_VLAN_SX_ID, SA_LOCKED) - /* * We also have a per-trunk mutex that should be acquired when changing * its state. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352713 - head/sys/kern
Author: mav Date: Wed Sep 25 19:29:09 2019 New Revision: 352713 URL: https://svnweb.freebsd.org/changeset/base/352713 Log: Microoptimize sched_pickcpu() after r352658. I've noticed that I missed intr check at one more SCHED_AFFINITY(), so instead of adding one more branching I prefer to remove few. Profiler shows the function CPU time reduction from 0.24% to 0.16%. MFC after:1 month Sponsored by: iXsystems, Inc. Modified: head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_ule.c == --- head/sys/kern/sched_ule.c Wed Sep 25 19:22:03 2019(r352712) +++ head/sys/kern/sched_ule.c Wed Sep 25 19:29:09 2019(r352713) @@ -1270,20 +1270,28 @@ sched_pickcpu(struct thread *td, int flags) */ if (td->td_priority <= PRI_MAX_ITHD && THREAD_CAN_SCHED(td, self) && curthread->td_intr_nesting_level) { + tdq = TDQ_SELF(); + if (tdq->tdq_lowpri >= PRI_MIN_IDLE) { + SCHED_STAT_INC(pickcpu_idle_affinity); + return (self); + } ts->ts_cpu = self; intr = 1; - } else + cg = tdq->tdq_cg; + goto llc; + } else { intr = 0; + tdq = TDQ_CPU(ts->ts_cpu); + cg = tdq->tdq_cg; + } /* * If the thread can run on the last cpu and the affinity has not * expired and it is idle, run it there. */ - tdq = TDQ_CPU(ts->ts_cpu); - cg = tdq->tdq_cg; if (THREAD_CAN_SCHED(td, ts->ts_cpu) && tdq->tdq_lowpri >= PRI_MIN_IDLE && SCHED_AFFINITY(ts, CG_SHARE_L2)) { - if (!intr && cg->cg_flags & CG_FLAG_THREAD) { + if (cg->cg_flags & CG_FLAG_THREAD) { CPUSET_FOREACH(cpu, cg->cg_mask) { if (TDQ_CPU(cpu)->tdq_lowpri < PRI_MIN_IDLE) break; @@ -1295,6 +1303,7 @@ sched_pickcpu(struct thread *td, int flags) return (ts->ts_cpu); } } +llc: /* * Search for the last level cache CPU group in the tree. * Skip SMT, identical groups and caches with expired affinity. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352712 - in head/lib/libc: gen sys
Author: kevans Date: Wed Sep 25 19:22:03 2019 New Revision: 352712 URL: https://svnweb.freebsd.org/changeset/base/352712 Log: posix_spawn(3): handle potential signal issues with vfork Described in [1], signal handlers running in a vfork child have opportunities to corrupt the parent's state. Address this by adding a new rfork(2) flag, RFSPAWN, that has vfork(2) semantics but also resets signal handlers in the child during creation. x86 uses rfork_thread(3) instead of a direct rfork(2) because rfork with RFMEM/RFSPAWN cannot work when the return address is stored on the stack -- further information about this problem is described under RFMEM in the rfork(2) man page. Addressing this has been identified as a prerequisite to using posix_spawn in subprocess on FreeBSD [2]. [1] https://ewontfix.com/7/ [2] https://bugs.python.org/issue35823 Reviewed by: jilles, kib Differential Revision:https://reviews.freebsd.org/D19058 Modified: head/lib/libc/gen/posix_spawn.c head/lib/libc/sys/rfork.2 Modified: head/lib/libc/gen/posix_spawn.c == --- head/lib/libc/gen/posix_spawn.c Wed Sep 25 19:20:41 2019 (r352711) +++ head/lib/libc/gen/posix_spawn.c Wed Sep 25 19:22:03 2019 (r352712) @@ -194,43 +194,115 @@ process_file_actions(const posix_spawn_file_actions_t return (0); } +struct posix_spawn_args { + const char *path; + const posix_spawn_file_actions_t *fa; + const posix_spawnattr_t *sa; + char * const * argv; + char * const * envp; + int use_env_path; + int error; +}; + +#if defined(__i386__) || defined(__amd64__) +#define_RFORK_THREAD_STACK_SIZE4096 +#endif + static int +_posix_spawn_thr(void *data) +{ + struct posix_spawn_args *psa; + char * const *envp; + + psa = data; + if (psa->sa != NULL) { + psa->error = process_spawnattr(*psa->sa); + if (psa->error) + _exit(127); + } + if (psa->fa != NULL) { + psa->error = process_file_actions(*psa->fa); + if (psa->error) + _exit(127); + } + envp = psa->envp != NULL ? psa->envp : environ; + if (psa->use_env_path) + _execvpe(psa->path, psa->argv, envp); + else + _execve(psa->path, psa->argv, envp); + psa->error = errno; + + /* This is called in such a way that it must not exit. */ + _exit(127); +} + +static int do_posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa, const posix_spawnattr_t *sa, char * const argv[], char * const envp[], int use_env_path) { + struct posix_spawn_args psa; pid_t p; - volatile int error = 0; +#ifdef _RFORK_THREAD_STACK_SIZE + char *stack; - p = vfork(); - switch (p) { - case -1: - return (errno); - case 0: - if (sa != NULL) { - error = process_spawnattr(*sa); - if (error) - _exit(127); - } - if (fa != NULL) { - error = process_file_actions(*fa); - if (error) - _exit(127); - } - if (use_env_path) - _execvpe(path, argv, envp != NULL ? envp : environ); - else - _execve(path, argv, envp != NULL ? envp : environ); - error = errno; - _exit(127); - default: - if (error != 0) - _waitpid(p, NULL, WNOHANG); - else if (pid != NULL) - *pid = p; - return (error); + stack = malloc(_RFORK_THREAD_STACK_SIZE); + if (stack == NULL) + return (ENOMEM); +#endif + psa.path = path; + psa.fa = fa; + psa.sa = sa; + psa.argv = argv; + psa.envp = envp; + psa.use_env_path = use_env_path; + psa.error = 0; + + /* +* Passing RFSPAWN to rfork(2) gives us effectively a vfork that drops +* non-ignored signal handlers. We'll fall back to the slightly less +* ideal vfork(2) if we get an EINVAL from rfork -- this should only +* happen with newer libc on older kernel that doesn't accept +* RFSPAWN. +*/ +#ifdef _RFORK_THREAD_STACK_SIZE + /* +* x86 stores the return address on the stack, so rfork(2) cannot work +* as-is because the child would clobber the return address om the +* parent. Because of this, we must use rfork_thread instead while +* almost every other arch stores the return address in a register. +*/ + p = rfork_thread(RFSPAWN, stack + _RFORK_THREAD_STACK_SIZE, +
svn commit: r352711 - in head: lib/libc/sys sys/kern sys/sys
Author: kevans Date: Wed Sep 25 19:20:41 2019 New Revision: 352711 URL: https://svnweb.freebsd.org/changeset/base/352711 Log: rfork(2): add RFSPAWN flag When RFSPAWN is passed, rfork exhibits vfork(2) semantics but also resets signal handlers in the child during creation to avoid a point of corruption of parent state from the child. This flag will be used by posix_spawn(3) to handle potential signal issues. Reviewed by: jilles, kib Differential Revision:https://reviews.freebsd.org/D19058 Modified: head/lib/libc/sys/rfork.2 head/sys/kern/kern_fork.c head/sys/kern/kern_sig.c head/sys/sys/proc.h head/sys/sys/signalvar.h head/sys/sys/unistd.h Modified: head/lib/libc/sys/rfork.2 == --- head/lib/libc/sys/rfork.2 Wed Sep 25 18:50:57 2019(r352710) +++ head/lib/libc/sys/rfork.2 Wed Sep 25 19:20:41 2019(r352711) @@ -5,7 +5,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 12, 2011 +.Dd September 25, 2019 .Dt RFORK 2 .Os .Sh NAME @@ -34,7 +34,9 @@ and open files. The .Fa flags argument -is the logical OR of some subset of: +is either +.Dv RFSPAWN +or the logical OR of some subset of: .Bl -tag -width ".Dv RFLINUXTHPN" .It Dv RFPROC If set a new process is created; otherwise changes affect the @@ -103,6 +105,14 @@ This is intended to mimic certain Linux clone behaviou File descriptors in a shared file descriptor table are kept open until either they are explicitly closed or all processes sharing the table exit. +.Pp +If +.Dv RFSPAWN +is passed, +.Nm +will use +.Xr vfork 2 +semantics but reset all signal actions in the child to default. .Pp If .Dv RFPROC Modified: head/sys/kern/kern_fork.c == --- head/sys/kern/kern_fork.c Wed Sep 25 18:50:57 2019(r352710) +++ head/sys/kern/kern_fork.c Wed Sep 25 19:20:41 2019(r352711) @@ -170,10 +170,18 @@ sys_rfork(struct thread *td, struct rfork_args *uap) /* Don't allow kernel-only flags. */ if ((uap->flags & RFKERNELONLY) != 0) return (EINVAL); + /* RFSPAWN must not appear with others */ + if ((uap->flags & RFSPAWN) != 0 && uap->flags != RFSPAWN) + return (EINVAL); AUDIT_ARG_FFLAGS(uap->flags); bzero(, sizeof(fr)); - fr.fr_flags = uap->flags; + if ((uap->flags & RFSPAWN) != 0) { + fr.fr_flags = RFFDG | RFPROC | RFPPWAIT | RFMEM; + fr.fr_flags2 = FR2_DROPSIG_CAUGHT; + } else { + fr.fr_flags = uap->flags; + } fr.fr_pidp = error = fork1(td, ); if (error == 0) { @@ -471,6 +479,11 @@ do_fork(struct thread *td, struct fork_req *fr, struct } else { sigacts_copy(newsigacts, p1->p_sigacts); p2->p_sigacts = newsigacts; + if ((fr->fr_flags2 & FR2_DROPSIG_CAUGHT) != 0) { + mtx_lock(>p_sigacts->ps_mtx); + sig_drop_caught(p2); + mtx_unlock(>p_sigacts->ps_mtx); + } } if (fr->fr_flags & RFTSIGZMB) Modified: head/sys/kern/kern_sig.c == --- head/sys/kern/kern_sig.cWed Sep 25 18:50:57 2019(r352710) +++ head/sys/kern/kern_sig.cWed Sep 25 19:20:41 2019(r352711) @@ -986,12 +986,7 @@ execsigs(struct proc *p) PROC_LOCK_ASSERT(p, MA_OWNED); ps = p->p_sigacts; mtx_lock(>ps_mtx); - while (SIGNOTEMPTY(ps->ps_sigcatch)) { - sig = sig_ffs(>ps_sigcatch); - sigdflt(ps, sig); - if ((sigprop(sig) & SIGPROP_IGNORE) != 0) - sigqueue_delete_proc(p, sig); - } + sig_drop_caught(p); /* * As CloudABI processes cannot modify signal handlers, fully @@ -3856,4 +3851,21 @@ sigacts_shared(struct sigacts *ps) { return (ps->ps_refcnt > 1); +} + +void +sig_drop_caught(struct proc *p) +{ + int sig; + struct sigacts *ps; + + ps = p->p_sigacts; + PROC_LOCK_ASSERT(p, MA_OWNED); + mtx_assert(>ps_mtx, MA_OWNED); + while (SIGNOTEMPTY(ps->ps_sigcatch)) { + sig = sig_ffs(>ps_sigcatch); + sigdflt(ps, sig); + if ((sigprop(sig) & SIGPROP_IGNORE) != 0) + sigqueue_delete_proc(p, sig); + } } Modified: head/sys/sys/proc.h == --- head/sys/sys/proc.h Wed Sep 25 18:50:57 2019(r352710) +++ head/sys/sys/proc.h Wed Sep 25 19:20:41 2019(r352711) @@ -1006,6 +1006,8 @@ structfork_req { int *fr_pd_fd; int fr_pd_flags; struct filecaps *fr_pd_fcaps; + int fr_flags2; +#defineFR2_DROPSIG_CAUGHT
Re: svn commit: r351319 - in head/usr.sbin/makefs: ffs msdos
On Fri, 30 Aug 2019 at 00:29, Bruce Evans wrote: > > On Wed, 21 Aug 2019, Ed Maste wrote: > > > Author: emaste > > Date: Wed Aug 21 01:45:29 2019 > > New Revision: 351319 > > URL: https://svnweb.freebsd.org/changeset/base/351319 > > > > Log: > > makefs: use `char *` not `void *` for buf b_data, drop casts in msdos > > > > (The kernel uses caddr_t.) > > This is much better than churning the copy of the working code. My eventual goal is to converge on a shared copy of these files, generally moving to what is already done in the kernel's implementation. If there's reasonable clean up or improvements to be made in the kernel code I'm interested in doing so, but I'm not really sure what to do with the caddr_ts there yet. I see that NetBSD removed all uses of caddr_t. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352710 - head/lib/msun/src
Author: dim Date: Wed Sep 25 18:50:57 2019 New Revision: 352710 URL: https://svnweb.freebsd.org/changeset/base/352710 Log: Do not left-shift a negative number (inducing undefined behavior in C/C++) in exp(3), expf(3), expm1(3) and expm1f(3) during intermediate computations that compute the IEEE-754 bit pattern for |2**k| for integer |k|. The implementations of exp(3), expf(3), expm1(3) and expm1f(3) need to compute IEEE-754 bit patterns for 2**k in certain places. (k is an integer and 2**k is exactly representable in IEEE-754.) Currently they do things like 0x3FF0'+(k<<20), which is to say they take the bit pattern representing 1 and then add directly to the exponent field to get the desired power of two. This is fine when k is non-negative. But when k<0 (and certain classes of input trigger this), this left-shifts a negative number -- an operation with undefined behavior in C and C++. The desired semantics can be achieved by instead adding the possibly-negative k to the IEEE-754 exponent bias to get the desired exponent field, _then_ shifting that into its proper overall position. (Note that in case of s_expm1.c and s_expm1f.c, there are SET_HIGH_WORD and SET_FLOAT_WORD uses further down in each of these files that perform shift operations involving k, but by these points k's range has been restricted to 2 < k <= 56, and the shift operations under those circumstances can't do anything that would be UB.) Submitted by: Jeff Walden, https://github.com/jswalden Obtained from:https://github.com/freebsd/freebsd/pull/411 Obtained from:https://github.com/freebsd/freebsd/pull/412 MFC after:3 days Modified: head/lib/msun/src/e_exp.c head/lib/msun/src/e_expf.c head/lib/msun/src/s_expm1.c head/lib/msun/src/s_expm1f.c Modified: head/lib/msun/src/e_exp.c == --- head/lib/msun/src/e_exp.c Wed Sep 25 18:48:05 2019(r352709) +++ head/lib/msun/src/e_exp.c Wed Sep 25 18:50:57 2019(r352710) @@ -145,9 +145,9 @@ __ieee754_exp(double x) /* default IEEE double exp */ /* x is now in primary range */ t = x*x; if(k >= -1021) - INSERT_WORDS(twopk,0x3ff0+(k<<20), 0); + INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20, 0); else - INSERT_WORDS(twopk,0x3ff0+((k+1000)<<20), 0); + INSERT_WORDS(twopk,((u_int32_t)(0x3ff+(k+1000)))<<20, 0); c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5; if(k==0)return one-((x*c)/(c-2.0)-x); elsey = one-((lo-(x*c)/(2.0-c))-hi); Modified: head/lib/msun/src/e_expf.c == --- head/lib/msun/src/e_expf.c Wed Sep 25 18:48:05 2019(r352709) +++ head/lib/msun/src/e_expf.c Wed Sep 25 18:50:57 2019(r352710) @@ -83,9 +83,9 @@ __ieee754_expf(float x) /* x is now in primary range */ t = x*x; if(k >= -125) - SET_FLOAT_WORD(twopk,0x3f80+(k<<23)); + SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23); else - SET_FLOAT_WORD(twopk,0x3f80+((k+100)<<23)); + SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+(k+100)))<<23); c = x - t*(P1+t*P2); if(k==0)return one-((x*c)/(c-(float)2.0)-x); elsey = one-((lo-(x*c)/((float)2.0-c))-hi); Modified: head/lib/msun/src/s_expm1.c == --- head/lib/msun/src/s_expm1.c Wed Sep 25 18:48:05 2019(r352709) +++ head/lib/msun/src/s_expm1.c Wed Sep 25 18:50:57 2019(r352710) @@ -188,7 +188,7 @@ expm1(double x) e = hxs*((r1-t)/(6.0 - x*t)); if(k==0) return x - (x*e-hxs); /* c is 0 */ else { - INSERT_WORDS(twopk,0x3ff0+(k<<20),0); /* 2^k */ + INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20,0); /* 2^k */ e = (x*(e-c)-c); e -= hxs; if(k== -1) return 0.5*(x-e)-0.5; Modified: head/lib/msun/src/s_expm1f.c == --- head/lib/msun/src/s_expm1f.cWed Sep 25 18:48:05 2019 (r352709) +++ head/lib/msun/src/s_expm1f.cWed Sep 25 18:50:57 2019 (r352710) @@ -94,7 +94,7 @@ expm1f(float x) e = hxs*((r1-t)/((float)6.0 - x*t)); if(k==0) return x - (x*e-hxs); /* c is 0 */ else { - SET_FLOAT_WORD(twopk,0x3f80+(k<<23)); /* 2^k */ + SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23);/* 2^k */ e = (x*(e-c)-c); e -= hxs; if(k== -1) return (float)0.5*(x-e)-(float)0.5; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any
svn commit: r352709 - head/sys/compat/freebsd32
Author: kevans Date: Wed Sep 25 18:48:05 2019 New Revision: 352709 URL: https://svnweb.freebsd.org/changeset/base/352709 Log: compat/freebsd32: restore style after r352705 (no functional change) The escaped newlines haven't been necessary since r339624, but this file has not been reformatted. Restore the style. Modified: head/sys/compat/freebsd32/syscalls.master Modified: head/sys/compat/freebsd32/syscalls.master == --- head/sys/compat/freebsd32/syscalls.master Wed Sep 25 18:47:05 2019 (r352708) +++ head/sys/compat/freebsd32/syscalls.master Wed Sep 25 18:48:05 2019 (r352709) @@ -910,8 +910,8 @@ uint32_t length1, uint32_t length2); } #endif 481AUE_THR_KILL2 NOPROTO { int thr_kill2(pid_t pid, long id, int sig); } -482AUE_SHMOPEN COMPAT12|NOPROTO{ int shm_open(const char *path, - int flags, mode_t mode); } +482AUE_SHMOPEN COMPAT12|NOPROTO{ int shm_open( \ + const char *path, int flags, mode_t mode); } 483AUE_SHMUNLINK NOPROTO { int shm_unlink(const char *path); } 484AUE_NULLNOPROTO { int cpuset(cpusetid_t *setid); } #ifdef PAD64_REQUIRED ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352707 - in head/sys: conf kern net sys
Author: glebius Date: Wed Sep 25 18:26:31 2019 New Revision: 352707 URL: https://svnweb.freebsd.org/changeset/base/352707 Log: Add debugging facility EPOCH_TRACE that checks that epochs entered are properly nested and warns about recursive entrances. Unlike with locks, there is nothing fundamentally wrong with such use, the intent of tracer is to help to review complex epoch-protected code paths, and we mean the network stack here. Reviewed by: hselasky Sponsored by: Netflix Pull Request: https://reviews.freebsd.org/D21610 Modified: head/sys/conf/options head/sys/kern/kern_thread.c head/sys/kern/subr_epoch.c head/sys/kern/subr_stack.c head/sys/net/if.c head/sys/sys/epoch.h head/sys/sys/proc.h head/sys/sys/stack.h Modified: head/sys/conf/options == --- head/sys/conf/options Wed Sep 25 18:09:19 2019(r352706) +++ head/sys/conf/options Wed Sep 25 18:26:31 2019(r352707) @@ -712,6 +712,8 @@ WITNESS_SKIPSPINopt_witness.h WITNESS_COUNT opt_witness.h OPENSOLARIS_WITNESSopt_global.h +EPOCH_TRACEopt_epoch.h + # options for ACPI support ACPI_DEBUG opt_acpi.h ACPI_MAX_TASKS opt_acpi.h Modified: head/sys/kern/kern_thread.c == --- head/sys/kern/kern_thread.c Wed Sep 25 18:09:19 2019(r352706) +++ head/sys/kern/kern_thread.c Wed Sep 25 18:26:31 2019(r352707) @@ -668,6 +668,7 @@ thread_link(struct thread *td, struct proc *p) LIST_INIT(>td_contested); LIST_INIT(>td_lprof[0]); LIST_INIT(>td_lprof[1]); + SLIST_INIT(>td_epochs); sigqueue_init(>td_sigqueue, p); callout_init(>td_slpcallout, 1); TAILQ_INSERT_TAIL(>p_threads, td, td_plist); @@ -684,6 +685,8 @@ thread_unlink(struct thread *td) struct proc *p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); + MPASS(SLIST_EMPTY(>td_epochs)); + TAILQ_REMOVE(>p_threads, td, td_plist); p->p_numthreads--; /* could clear a few other things here */ Modified: head/sys/kern/subr_epoch.c == --- head/sys/kern/subr_epoch.c Wed Sep 25 18:09:19 2019(r352706) +++ head/sys/kern/subr_epoch.c Wed Sep 25 18:26:31 2019(r352707) @@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include @@ -47,6 +46,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef EPOCH_TRACE +#include +#include +#include +#endif #include #include #include @@ -80,6 +84,7 @@ struct epoch { struct sx e_drain_sx; struct mtx e_drain_mtx; volatile int e_drain_count; + const char *e_name; }; /* arbitrary --- needs benchmarking */ @@ -134,6 +139,103 @@ __read_mostly epoch_t global_epoch_preempt; static void epoch_call_task(void *context __unused); static uma_zone_t pcpu_zone_record; +#ifdef EPOCH_TRACE +struct stackentry { + RB_ENTRY(stackentry) se_node; + struct stack se_stack; +}; + +static int +stackentry_compare(struct stackentry *a, struct stackentry *b) +{ + + if (a->se_stack.depth > b->se_stack.depth) + return (1); + if (a->se_stack.depth < b->se_stack.depth) + return (-1); + for (int i = 0; i < a->se_stack.depth; i++) { + if (a->se_stack.pcs[i] > b->se_stack.pcs[i]) + return (1); + if (a->se_stack.pcs[i] < b->se_stack.pcs[i]) + return (-1); + } + + return (0); +} + +RB_HEAD(stacktree, stackentry) epoch_stacks = RB_INITIALIZER(_stacks); +RB_GENERATE_STATIC(stacktree, stackentry, se_node, stackentry_compare); + +static struct mtx epoch_stacks_lock; +MTX_SYSINIT(epochstacks, _stacks_lock, "epoch_stacks", MTX_DEF); + +static void epoch_trace_report(const char *fmt, ...) __printflike(1, 2); +static inline void +epoch_trace_report(const char *fmt, ...) +{ + va_list ap; + struct stackentry se, *new; + + stack_zero(_stack); /* XXX: is it really needed? */ + stack_save(_stack); + + /* Tree is never reduced - go lockless. */ + if (RB_FIND(stacktree, _stacks, ) != NULL) + return; + + new = malloc(sizeof(*new), M_STACK, M_NOWAIT); + if (new != NULL) { + bcopy(_stack, >se_stack, sizeof(struct stack)); + + mtx_lock(_stacks_lock); + new = RB_INSERT(stacktree, _stacks, new); + mtx_unlock(_stacks_lock); + if (new != NULL) + free(new, M_STACK); + } + + va_start(ap, fmt); + (void)vprintf(fmt, ap); + va_end(ap); + stack_print_ddb(_stack); +} + +static inline void +epoch_trace_enter(struct thread *td, epoch_t epoch, epoch_tracker_t et, +
svn commit: r352706 - in head: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys usr.bin/kdump
Author: kevans Date: Wed Sep 25 18:09:19 2019 New Revision: 352706 URL: https://svnweb.freebsd.org/changeset/base/352706 Log: sysent: regenerate after r352705 This also implements it, fixes kdump, and removes no longer needed bits from lib/libc/sys/shm_open.c for the interim. Modified: head/lib/libc/sys/shm_open.c head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/freebsd32/freebsd32_systrace_args.c head/sys/kern/init_sysent.c head/sys/kern/syscalls.c head/sys/kern/systrace_args.c head/sys/kern/uipc_shm.c head/sys/sys/syscall.h head/sys/sys/syscall.mk head/sys/sys/sysproto.h head/usr.bin/kdump/kdump.c Modified: head/lib/libc/sys/shm_open.c == --- head/lib/libc/sys/shm_open.cWed Sep 25 18:06:48 2019 (r352705) +++ head/lib/libc/sys/shm_open.cWed Sep 25 18:09:19 2019 (r352706) @@ -46,10 +46,6 @@ __FBSDID("$FreeBSD$"); __weak_reference(shm_open, _shm_open); __weak_reference(shm_open, __sys_shm_open); -#ifndef SYS_freebsd12_shm_open -#defineSYS_freebsd12_shm_open SYS_shm_open -#endif - #defineSHM_OPEN2_OSREL 1300048 #defineMEMFD_NAME_PREFIX "memfd:" Modified: head/sys/compat/freebsd32/freebsd32_syscall.h == --- head/sys/compat/freebsd32/freebsd32_syscall.h Wed Sep 25 18:06:48 2019(r352705) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Wed Sep 25 18:09:19 2019(r352706) @@ -404,7 +404,7 @@ #defineFREEBSD32_SYS_freebsd32_truncate479 #defineFREEBSD32_SYS_freebsd32_ftruncate 480 #defineFREEBSD32_SYS_thr_kill2 481 -#defineFREEBSD32_SYS_shm_open 482 +#defineFREEBSD32_SYS_freebsd12_shm_open482 #defineFREEBSD32_SYS_shm_unlink483 #defineFREEBSD32_SYS_cpuset484 #defineFREEBSD32_SYS_freebsd32_cpuset_setid485 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c == --- head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Sep 25 18:06:48 2019(r352705) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Sep 25 18:09:19 2019(r352706) @@ -500,7 +500,7 @@ const char *freebsd32_syscallnames[] = { "freebsd32_ftruncate", /* 480 = freebsd32_ftruncate */ #endif "thr_kill2",/* 481 = thr_kill2 */ - "shm_open", /* 482 = shm_open */ + "compat12.shm_open",/* 482 = freebsd12 shm_open */ "shm_unlink", /* 483 = shm_unlink */ "cpuset", /* 484 = cpuset */ #ifdef PAD64_REQUIRED Modified: head/sys/compat/freebsd32/freebsd32_sysent.c == --- head/sys/compat/freebsd32/freebsd32_sysent.cWed Sep 25 18:06:48 2019(r352705) +++ head/sys/compat/freebsd32/freebsd32_sysent.cWed Sep 25 18:09:19 2019(r352706) @@ -51,6 +51,12 @@ #define compat11(n, name) 0, (sy_call_t *)nosys #endif +#ifdef COMPAT_FREEBSD12 +#define compat12(n, name) n, (sy_call_t *)__CONCAT(freebsd12_,name) +#else +#define compat12(n, name) 0, (sy_call_t *)nosys +#endif + /* The casts are bogus but will do for now. */ struct sysent freebsd32_sysent[] = { #if !defined(PAD64_REQUIRED) && !defined(__amd64__) @@ -547,7 +553,7 @@ struct sysent freebsd32_sysent[] = { { AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */ #endif { AS(thr_kill2_args), (sy_call_t *)sys_thr_kill2, AUE_THR_KILL2, NULL, 0, 0, 0, SY_THR_STATIC },/* 481 = thr_kill2 */ - { AS(shm_open_args), (sy_call_t *)sys_shm_open, AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 482 = shm_open */ + { compat12(AS(freebsd12_shm_open_args),shm_open), AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 482 = freebsd12 shm_open */ { AS(shm_unlink_args), (sy_call_t *)sys_shm_unlink, AUE_SHMUNLINK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 483 = shm_unlink */ { AS(cpuset_args), (sy_call_t *)sys_cpuset, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 484 = cpuset */ #ifdef PAD64_REQUIRED Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c == --- head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Sep 25 18:06:48 2019(r352705) +++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Sep 25 18:09:19 2019(r352706) @@ -2491,15 +2491,6 @@ systrace_args(int sysnum,
svn commit: r352705 - in head/sys: compat/freebsd32 kern
Author: kevans Date: Wed Sep 25 18:06:48 2019 New Revision: 352705 URL: https://svnweb.freebsd.org/changeset/base/352705 Log: Mark shm_open(2) as COMPAT12, succeeded by shm_open2 Implementation and regenerated files will follow. Modified: head/sys/compat/freebsd32/syscalls.master head/sys/kern/syscalls.master Modified: head/sys/compat/freebsd32/syscalls.master == --- head/sys/compat/freebsd32/syscalls.master Wed Sep 25 18:04:09 2019 (r352704) +++ head/sys/compat/freebsd32/syscalls.master Wed Sep 25 18:06:48 2019 (r352705) @@ -910,8 +910,8 @@ uint32_t length1, uint32_t length2); } #endif 481AUE_THR_KILL2 NOPROTO { int thr_kill2(pid_t pid, long id, int sig); } -482AUE_SHMOPEN NOPROTO { int shm_open(const char *path, int flags, \ - mode_t mode); } +482AUE_SHMOPEN COMPAT12|NOPROTO{ int shm_open(const char *path, + int flags, mode_t mode); } 483AUE_SHMUNLINK NOPROTO { int shm_unlink(const char *path); } 484AUE_NULLNOPROTO { int cpuset(cpusetid_t *setid); } #ifdef PAD64_REQUIRED Modified: head/sys/kern/syscalls.master == --- head/sys/kern/syscalls.master Wed Sep 25 18:04:09 2019 (r352704) +++ head/sys/kern/syscalls.master Wed Sep 25 18:06:48 2019 (r352705) @@ -2579,7 +2579,7 @@ int sig ); } -482AUE_SHMOPEN STD { +482AUE_SHMOPEN COMPAT12 { int shm_open( _In_z_ const char *path, int flags, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352704 - head
Author: kevans Date: Wed Sep 25 18:04:09 2019 New Revision: 352704 URL: https://svnweb.freebsd.org/changeset/base/352704 Log: Adjust Makefile.inc1 syscall sub commit Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 == --- head/Makefile.inc1 Wed Sep 25 18:03:18 2019(r352703) +++ head/Makefile.inc1 Wed Sep 25 18:04:09 2019(r352704) @@ -947,7 +947,7 @@ _cleanobj_fast_depend_hack: .PHONY # Syscall stubs rewritten in C and obsolete MD assembly implementations # Date SVN Rev Syscalls # 20180604 r334626 brk sbrk -# 20190916 r35 shm_open +# 20190916 r352703 shm_open .for f in brk sbrk shm_open @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \ egrep -qw '${f}\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352703 - in head: . lib/libc/include lib/libc/sys sys/sys tests/sys/kern
Author: kevans Date: Wed Sep 25 18:03:18 2019 New Revision: 352703 URL: https://svnweb.freebsd.org/changeset/base/352703 Log: Add linux-compatible memfd_create memfd_create is effectively a SHM_ANON shm_open(2) mapping with optional CLOEXEC and file sealing support. This is used by some mesa parts, some linux libs, and qemu can also take advantage of it and uses the sealing to prevent resizing the region. This reimplements shm_open in terms of shm_open2(2) at the same time. shm_open(2) will be moved to COMPAT12 shortly. Reviewed by: markj, kib Differential Revision:https://reviews.freebsd.org/D21393 Added: head/lib/libc/sys/shm_open.c (contents, props changed) head/tests/sys/kern/memfd_test.c (contents, props changed) Modified: head/Makefile.inc1 head/lib/libc/include/libc_private.h head/lib/libc/sys/Makefile.inc head/lib/libc/sys/Symbol.map head/lib/libc/sys/shm_open.2 head/sys/sys/mman.h head/tests/sys/kern/Makefile Modified: head/Makefile.inc1 == --- head/Makefile.inc1 Wed Sep 25 18:03:15 2019(r352702) +++ head/Makefile.inc1 Wed Sep 25 18:03:18 2019(r352703) @@ -947,7 +947,8 @@ _cleanobj_fast_depend_hack: .PHONY # Syscall stubs rewritten in C and obsolete MD assembly implementations # Date SVN Rev Syscalls # 20180604 r334626 brk sbrk -.for f in brk sbrk +# 20190916 r35 shm_open +.for f in brk sbrk shm_open @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \ egrep -qw '${f}\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \ echo "Removing stale dependencies for ${f} syscall wrappers"; \ Modified: head/lib/libc/include/libc_private.h == --- head/lib/libc/include/libc_private.hWed Sep 25 18:03:15 2019 (r352702) +++ head/lib/libc/include/libc_private.hWed Sep 25 18:03:18 2019 (r352703) @@ -391,6 +391,7 @@ __pid_t __sys_wait6(enum idtype, __id_t, int *, int, struct __wrusage *, struct __siginfo *); __ssize_t __sys_write(int, const void *, __size_t); __ssize_t __sys_writev(int, const struct iovec *, int); +int__sys_shm_open2(const char *, int, __mode_t, int, const char *); int__libc_sigaction(int, const struct sigaction *, struct sigaction *) __hidden; Modified: head/lib/libc/sys/Makefile.inc == --- head/lib/libc/sys/Makefile.inc Wed Sep 25 18:03:15 2019 (r352702) +++ head/lib/libc/sys/Makefile.inc Wed Sep 25 18:03:18 2019 (r352703) @@ -46,6 +46,7 @@ PSEUDO+= _getdirentries.o SRCS+= brk.c SRCS+= pipe.c +SRCS+= shm_open.c SRCS+= vadvise.c SRCS+= compat-stub.c @@ -475,7 +476,8 @@ MLINKS+=setuid.2 setegid.2 \ setuid.2 seteuid.2 \ setuid.2 setgid.2 MLINKS+=shmat.2 shmdt.2 -MLINKS+=shm_open.2 shm_unlink.2 +MLINKS+=shm_open.2 memfd_create.3 \ + shm_open.2 shm_unlink.2 MLINKS+=sigwaitinfo.2 sigtimedwait.2 MLINKS+=stat.2 fstat.2 \ stat.2 fstatat.2 \ Modified: head/lib/libc/sys/Symbol.map == --- head/lib/libc/sys/Symbol.mapWed Sep 25 18:03:15 2019 (r352702) +++ head/lib/libc/sys/Symbol.mapWed Sep 25 18:03:18 2019 (r352703) @@ -409,6 +409,7 @@ FBSD_1.6 { fhreadlink; getfhat; funlinkat; + memfd_create; }; FBSDprivate_1.0 { Modified: head/lib/libc/sys/shm_open.2 == --- head/lib/libc/sys/shm_open.2Wed Sep 25 18:03:15 2019 (r352702) +++ head/lib/libc/sys/shm_open.2Wed Sep 25 18:03:18 2019 (r352703) @@ -28,11 +28,11 @@ .\" .\" $FreeBSD$ .\" -.Dd January 20, 2017 +.Dd September 24, 2019 .Dt SHM_OPEN 2 .Os .Sh NAME -.Nm shm_open , shm_unlink +.Nm memfd_create , shm_open , shm_unlink .Nd "shared memory object operations" .Sh LIBRARY .Lb libc @@ -41,6 +41,8 @@ .In sys/mman.h .In fcntl.h .Ft int +.Fn memfd_create "const char *name" "unsigned int flags" +.Ft int .Fn shm_open "const char *path" "int flags" "mode_t mode" .Ft int .Fn shm_unlink "const char *path" @@ -139,14 +141,64 @@ The .Fn shm_unlink system call removes a shared memory object named .Fa path . +.Pp +The +.Fn memfd_create +function creates an anonymous shared memory object, identical to that created +by +.Fn shm_open +when +.Dv SHM_ANON +is specified. +Newly created objects start off with a size of zero. +The size of the new object must be adjusted via +.Xr ftruncate 2 . +.Pp +The +.Fa name +argument must not be +.Dv NULL , +but it may be an empty string. +The length of the +.Fa name +argument may not exceed +.Dv NAME_MAX +minus six characters for the
svn commit: r352702 - head/tools/debugscripts
Author: glebius Date: Wed Sep 25 18:03:15 2019 New Revision: 352702 URL: https://svnweb.freebsd.org/changeset/base/352702 Log: Enhance the 'ps' command so that it prints a line per proc and a line per thread, so that instead of repeating the same info for all threads in proc, it would print thread specific info. Also includes thread number that would match 'info threads' info and can be used as argument for thread swithcing with 'thread' command. Modified: head/tools/debugscripts/gdbinit.kernel Modified: head/tools/debugscripts/gdbinit.kernel == --- head/tools/debugscripts/gdbinit.kernel Wed Sep 25 17:59:58 2019 (r352701) +++ head/tools/debugscripts/gdbinit.kernel Wed Sep 25 18:03:15 2019 (r352702) @@ -199,28 +199,29 @@ define ps set $nproc = nprocs set $aproc = allproc.lh_first set $proc = allproc.lh_first -printf " pidproc uid ppid pgrp flag stat comm wchan\n" +set $tid = 1 +printf "pid/ID ppid/tid uid pgrp flag st comm/name proc/thread\n" while (--$nproc >= 0) set $pptr = $proc.p_pptr if ($pptr == 0) set $pptr = $proc end if ($proc.p_state) +printf " %5d %6d %4d %5d %8x %2d %-10s %p\n", \ + $proc.p_pid, $pptr->p_pid, \ + $proc.p_ucred->cr_ruid, \ + $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_state, \ + &$proc.p_comm[0], $aproc set $thread = $proc->p_threads.tqh_first while ($thread) -printf "%5d %08x %4d %5d %5d %06x %d %-10s ", \ - $proc.p_pid, $aproc, \ - $proc.p_ucred->cr_ruid, $pptr->p_pid, \ - $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_state, \ - &$proc.p_comm[0] -if ($thread.td_wchan) -if ($thread.td_wmesg) -printf "%s ", $thread.td_wmesg -end -printf "%x", $thread.td_wchan +printf "(%5d) %6d%-10s %p", \ + $tid, $thread->td_tid, $thread->td_name, $thread +if ($thread.td_wmesg) +printf " %s", $thread.td_wmesg end -printf "\n" +printf "\n" set $thread = $thread->td_plist.tqe_next +set $tid = $tid + 1 end end set $aproc = $proc.p_list.le_next ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352701 - in head/sys: compat/freebsd32 kern sys
Author: kevans Date: Wed Sep 25 17:59:58 2019 New Revision: 352701 URL: https://svnweb.freebsd.org/changeset/base/352701 Log: sysent: regenerate after r352700 Modified: head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/freebsd32/freebsd32_systrace_args.c head/sys/kern/init_sysent.c head/sys/kern/syscalls.c head/sys/kern/systrace_args.c head/sys/sys/syscall.h head/sys/sys/syscall.mk head/sys/sys/sysproto.h Modified: head/sys/compat/freebsd32/freebsd32_syscall.h == --- head/sys/compat/freebsd32/freebsd32_syscall.h Wed Sep 25 17:59:15 2019(r352700) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Wed Sep 25 17:59:58 2019(r352701) @@ -497,4 +497,5 @@ #defineFREEBSD32_SYS_funlinkat 568 #defineFREEBSD32_SYS_copy_file_range 569 #defineFREEBSD32_SYS_freebsd32___sysctlbyname 570 -#defineFREEBSD32_SYS_MAXSYSCALL571 +#defineFREEBSD32_SYS_shm_open2 571 +#defineFREEBSD32_SYS_MAXSYSCALL572 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c == --- head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Sep 25 17:59:15 2019(r352700) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Sep 25 17:59:58 2019(r352701) @@ -607,4 +607,5 @@ const char *freebsd32_syscallnames[] = { "funlinkat",/* 568 = funlinkat */ "copy_file_range", /* 569 = copy_file_range */ "freebsd32___sysctlbyname", /* 570 = freebsd32___sysctlbyname */ + "shm_open2",/* 571 = shm_open2 */ }; Modified: head/sys/compat/freebsd32/freebsd32_sysent.c == --- head/sys/compat/freebsd32/freebsd32_sysent.cWed Sep 25 17:59:15 2019(r352700) +++ head/sys/compat/freebsd32/freebsd32_sysent.cWed Sep 25 17:59:58 2019(r352701) @@ -654,4 +654,5 @@ struct sysent freebsd32_sysent[] = { { AS(funlinkat_args), (sy_call_t *)sys_funlinkat, AUE_UNLINKAT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },/* 568 = funlinkat */ { AS(copy_file_range_args), (sy_call_t *)sys_copy_file_range, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },/* 569 = copy_file_range */ { AS(freebsd32___sysctlbyname_args), (sy_call_t *)freebsd32___sysctlbyname, AUE_SYSCTL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },/* 570 = freebsd32___sysctlbyname */ + { AS(shm_open2_args), (sy_call_t *)sys_shm_open2, AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 571 = shm_open2 */ }; Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c == --- head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Sep 25 17:59:15 2019(r352700) +++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Sep 25 17:59:58 2019(r352701) @@ -3344,6 +3344,17 @@ systrace_args(int sysnum, void *params, uint64_t *uarg *n_args = 6; break; } + /* shm_open2 */ + case 571: { + struct shm_open2_args *p = params; + uarg[0] = (intptr_t) p->path; /* const char * */ + iarg[1] = p->flags; /* int */ + iarg[2] = p->mode; /* mode_t */ + iarg[3] = p->shmflags; /* int */ + uarg[4] = (intptr_t) p->name; /* const char * */ + *n_args = 5; + break; + } default: *n_args = 0; break; @@ -9008,6 +9019,28 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; }; break; + /* shm_open2 */ + case 571: + switch(ndx) { + case 0: + p = "userland const char *"; + break; + case 1: + p = "int"; + break; + case 2: + p = "mode_t"; + break; + case 3: + p = "int"; + break; + case 4: + p = "userland const char *"; + break; + default: + break; + }; + break; default: break; }; @@ -10889,6 +10922,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* freebsd32___sysctlbyname */ case 570: + if (ndx == 0 || ndx == 1) + p = "int"; +
svn commit: r352700 - in head/sys: compat/freebsd32 kern sys
Author: kevans Date: Wed Sep 25 17:59:15 2019 New Revision: 352700 URL: https://svnweb.freebsd.org/changeset/base/352700 Log: Add a shm_open2 syscall to support upcoming memfd_create shm_open2 allows a little more flexibility than the original shm_open. shm_open2 doesn't enforce CLOEXEC on its callers, and it has a separate shmflag argument that can be expanded later. Currently the only shmflag is to allow file sealing on the returned fd. shm_open and memfd_create will both be implemented in libc to use this new syscall. __FreeBSD_version is bumped to indicate the presence. Reviewed by: kib, markj Differential Revision:https://reviews.freebsd.org/D21393 Modified: head/sys/compat/freebsd32/syscalls.master head/sys/kern/capabilities.conf head/sys/kern/syscalls.master head/sys/kern/uipc_shm.c head/sys/sys/mman.h head/sys/sys/param.h head/sys/sys/syscallsubr.h Modified: head/sys/compat/freebsd32/syscalls.master == --- head/sys/compat/freebsd32/syscalls.master Wed Sep 25 17:52:59 2019 (r352699) +++ head/sys/compat/freebsd32/syscalls.master Wed Sep 25 17:59:15 2019 (r352700) @@ -1154,5 +1154,8 @@ 570AUE_SYSCTL STD { int freebsd32___sysctlbyname(const char *name, \ size_t namelen, void *old, uint32_t *oldlenp, \ void *new, size_t newlen); } +571AUE_SHMOPEN NOPROTO { int shm_open2( \ + const char *path, int flags, mode_t mode, \ + int shmflags, const char *name); } ; vim: syntax=off Modified: head/sys/kern/capabilities.conf == --- head/sys/kern/capabilities.conf Wed Sep 25 17:52:59 2019 (r352699) +++ head/sys/kern/capabilities.conf Wed Sep 25 17:59:15 2019 (r352700) @@ -655,6 +655,7 @@ setuid ## shm_open(2) is scoped so as to allow only access to new anonymous objects. ## shm_open +shm_open2 ## ## Allow I/O-related file descriptors, subject to capability rights. Modified: head/sys/kern/syscalls.master == --- head/sys/kern/syscalls.master Wed Sep 25 17:52:59 2019 (r352699) +++ head/sys/kern/syscalls.master Wed Sep 25 17:59:15 2019 (r352700) @@ -3195,6 +3195,15 @@ _In_reads_bytes_opt_(newlen) void *new, size_t newlen); } +571AUE_SHMOPEN STD { + int shm_open2( + _In_z_ const char *path, + int flags, + mode_t mode, + int shmflags, + _In_z_ const char *name + ); + } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master Modified: head/sys/kern/uipc_shm.c == --- head/sys/kern/uipc_shm.cWed Sep 25 17:52:59 2019(r352699) +++ head/sys/kern/uipc_shm.cWed Sep 25 17:59:15 2019(r352700) @@ -1316,3 +1316,36 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, posix_shm_list, CTLFLAG_RD | CTLFLAG_MPSAFE | CTLTYPE_OPAQUE, NULL, 0, sysctl_posix_shm_list, "", "POSIX SHM list"); + +int +kern_shm_open2(struct thread *td, const char *path, int flags, mode_t mode, +int shmflags, const char *name __unused) +{ + int initial_seals; + + if ((shmflags & ~SHM_ALLOW_SEALING) != 0) + return (EINVAL); + + initial_seals = F_SEAL_SEAL; + if ((shmflags & SHM_ALLOW_SEALING) != 0) + initial_seals &= ~F_SEAL_SEAL; + return (kern_shm_open(td, path, flags, 0, NULL, initial_seals)); +} + +/* + * This version of the shm_open() interface leaves CLOEXEC behavior up to the + * caller, and libc will enforce it for the traditional shm_open() call. This + * allows other consumers, like memfd_create(), to opt-in for CLOEXEC. This + * interface also includes a 'name' argument that is currently unused, but could + * potentially be exported later via some interface for debugging purposes. + * From the kernel's perspective, it is optional. Individual consumers like + * memfd_create() may require it in order to be compatible with other systems + * implementing the same function. + */ +int +sys_shm_open2(struct thread *td, struct shm_open2_args *uap) +{ + + return (kern_shm_open2(td, uap->path, uap->flags, uap->mode, + uap->shmflags, uap->name)); +} Modified: head/sys/sys/mman.h == --- head/sys/sys/mman.h Wed Sep 25 17:52:59 2019(r352699) +++ head/sys/sys/mman.h Wed Sep 25 17:59:15 2019(r352700) @@ -176,6 +176,12 @@ * Anonymous
svn commit: r352699 - head/share/mk
Author: dim Date: Wed Sep 25 17:52:59 2019 New Revision: 352699 URL: https://svnweb.freebsd.org/changeset/base/352699 Log: In suite.test.mk, test if ${DESTDIR} exists before attempting to run chflags -R on it, otherwise the command will error out. (Note that adding -f to the chflags invocation does not help, unlike with rm.) MFC after:3 days Modified: head/share/mk/suite.test.mk Modified: head/share/mk/suite.test.mk == --- head/share/mk/suite.test.mk Wed Sep 25 17:35:34 2019(r352698) +++ head/share/mk/suite.test.mk Wed Sep 25 17:52:59 2019(r352699) @@ -120,7 +120,7 @@ beforecheck: # etc. aftercheck: @cd ${.CURDIR} && ${MAKE} clean - @chflags -R 0 "${DESTDIR}" + @test ! -e ${DESTDIR} || chflags -R 0 "${DESTDIR}" @rm -Rf "${DESTDIR}" .endif ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352698 - head
Author: dim Date: Wed Sep 25 17:35:34 2019 New Revision: 352698 URL: https://svnweb.freebsd.org/changeset/base/352698 Log: In r340411, libufs.so's major number was bumped to 7, but an entry in ObsoleteFiles.inc was not added. Retroactively fix that. Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc == --- head/ObsoleteFiles.inc Wed Sep 25 17:35:03 2019(r352697) +++ head/ObsoleteFiles.inc Wed Sep 25 17:35:34 2019(r352698) @@ -668,6 +668,9 @@ OLD_DIRS+=usr/lib/clang/6.0.1/lib OLD_DIRS+=usr/lib/clang/6.0.1 # 20181116: Rename test file. OLD_FILES+=usr/tests/sys/netinet/reuseport_lb +# 20181113: libufs version bumped to 7. +OLD_LIBS+=lib/libufs.so.6 +OLD_LIBS+=usr/lib32/libufs.so.6 # 20181112: Cleanup old libcap_dns. OLD_LIBS+=lib/casper/libcap_dns.so.1 OLD_LIBS+=usr/lib32/libcap_dns.so.1 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352697 - in head/sys: compat/cloudabi kern sys
Author: kevans Date: Wed Sep 25 17:35:03 2019 New Revision: 352697 URL: https://svnweb.freebsd.org/changeset/base/352697 Log: [2/3] Add an initial seal argument to kern_shm_open() Now that flags may be set on posixshm, add an argument to kern_shm_open() for the initial seals. To maintain past behavior where callers of shm_open(2) are guaranteed to not have any seals applied to the fd they're given, apply F_SEAL_SEAL for existing callers of kern_shm_open. A special flag could be opened later for shm_open(2) to indicate that sealing should be allowed. We currently restrict initial seals to F_SEAL_SEAL. We cannot error out if F_SEAL_SEAL is re-applied, as this would easily break shm_open() twice to a shmfd that already existed. A note's been added about the assumptions we've made here as a hint towards anyone wanting to allow other seals to be applied at creation. Reviewed by: kib, markj Differential Revision:https://reviews.freebsd.org/D21392 Modified: head/sys/compat/cloudabi/cloudabi_fd.c head/sys/kern/uipc_shm.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/cloudabi/cloudabi_fd.c == --- head/sys/compat/cloudabi/cloudabi_fd.c Wed Sep 25 17:33:12 2019 (r352696) +++ head/sys/compat/cloudabi/cloudabi_fd.c Wed Sep 25 17:35:03 2019 (r352697) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -95,7 +96,7 @@ cloudabi_sys_fd_create1(struct thread *td, cap_rights_init(_rights, CAP_FSTAT, CAP_FTRUNCATE, CAP_MMAP_RWX); return (kern_shm_open(td, SHM_ANON, O_RDWR | O_CLOEXEC, 0, - )); + , F_SEAL_SEAL)); default: return (EINVAL); } Modified: head/sys/kern/uipc_shm.c == --- head/sys/kern/uipc_shm.cWed Sep 25 17:33:12 2019(r352696) +++ head/sys/kern/uipc_shm.cWed Sep 25 17:35:03 2019(r352697) @@ -701,13 +701,14 @@ shm_remove(char *path, Fnv32_t fnv, struct ucred *ucre int kern_shm_open(struct thread *td, const char *userpath, int flags, mode_t mode, -struct filecaps *fcaps) +struct filecaps *fcaps, int initial_seals) { struct filedesc *fdp; struct shmfd *shmfd; struct file *fp; char *path; const char *pr_path; + void *rl_cookie; size_t pr_pathlen; Fnv32_t fnv; mode_t cmode; @@ -730,6 +731,17 @@ kern_shm_open(struct thread *td, const char *userpath, if ((flags & ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC)) != 0) return (EINVAL); + /* +* Currently only F_SEAL_SEAL may be set when creating or opening shmfd. +* If the decision is made later to allow additional seals, care must be +* taken below to ensure that the seals are properly set if the shmfd +* already existed -- this currently assumes that only F_SEAL_SEAL can +* be set and doesn't take further precautions to ensure the validity of +* the seals being added with respect to current mappings. +*/ + if ((initial_seals & ~F_SEAL_SEAL) != 0) + return (EINVAL); + fdp = td->td_proc->p_fd; cmode = (mode & ~fdp->fd_cmask) & ACCESSPERMS; @@ -753,6 +765,7 @@ kern_shm_open(struct thread *td, const char *userpath, return (EINVAL); } shmfd = shm_alloc(td->td_ucred, cmode); + shmfd->shm_seals = initial_seals; } else { path = malloc(MAXPATHLEN, M_SHMFD, M_WAITOK); pr_path = td->td_ucred->cr_prison->pr_path; @@ -789,6 +802,7 @@ kern_shm_open(struct thread *td, const char *userpath, if (error == 0) { #endif shmfd = shm_alloc(td->td_ucred, cmode); + shmfd->shm_seals = initial_seals; shm_insert(path, fnv, shmfd); #ifdef MAC } @@ -798,12 +812,39 @@ kern_shm_open(struct thread *td, const char *userpath, error = ENOENT; } } else { + rl_cookie = rangelock_wlock(>shm_rl, 0, OFF_MAX, + >shm_mtx); + /* +* kern_shm_open() likely shouldn't ever error out on +* trying to set a seal that already exists, unlike +* F_ADD_SEALS. This would break terribly as +* shm_open(2) actually sets F_SEAL_SEAL to maintain +* historical behavior where the underlying file could +* not be
svn commit: r352696 - head/lib/libc/sys
Author: kevans Date: Wed Sep 25 17:33:12 2019 New Revision: 352696 URL: https://svnweb.freebsd.org/changeset/base/352696 Log: Update fcntl(2) after r352695 Modified: head/lib/libc/sys/fcntl.2 Modified: head/lib/libc/sys/fcntl.2 == --- head/lib/libc/sys/fcntl.2 Wed Sep 25 17:32:43 2019(r352695) +++ head/lib/libc/sys/fcntl.2 Wed Sep 25 17:33:12 2019(r352696) @@ -28,7 +28,7 @@ .\" @(#)fcntl.28.2 (Berkeley) 1/12/94 .\" $FreeBSD$ .\" -.Dd Nov 15, 2018 +.Dd September 4, 2019 .Dt FCNTL 2 .Os .Sh NAME @@ -180,6 +180,11 @@ is non-zero. A zero value in .Fa arg turns off read ahead. +.It Dv F_ADD_SEALS +Add seals to the file as described below, if the underlying filesystem supports +seals. +.It Dv F_GET_SEALS +Get seals associated with the file, if the underlying filesystem supports seals. .El .Pp The flags for the @@ -217,6 +222,37 @@ when I/O is possible, e.g., upon availability of data to be read. .El .Pp +The seals that may be applied with +.Dv F_ADD_SEALS +are as follows: +.Bl -tag -width F_SEAL_SHRINK +.It Dv F_SEAL_SEAL +Prevent any further seals from being applied to the file. +.It Dv F_SEAL_SHRINK +Prevent the file from being shrunk with +.Xr ftruncate 2 . +.It Dv F_SEAL_GROW +Prevent the file from being enlarged with +.Xr ftruncate 2 . +.It Dv F_SEAL_WRITE +Prevent any further +.Xr write 2 +calls to the file. +Any writes in progress will finish before +.Fn fcntl +returns. +If any writeable mappings exist, F_ADD_SEALS will fail and return +.Dv EBUSY . +.El +.Pp +Seals are on a per-inode basis and require support by the underlying filesystem. +If the underlying filesystem does not support seals, +.Dv F_ADD_SEALS +and +.Dv F_GET_SEALS +will fail and return +.Dv EINVAL . +.Pp Several commands are available for doing advisory file locking; they all operate on the following structure: .Bd -literal @@ -528,6 +564,14 @@ is an exclusive lock and .Fa fd is not a valid file descriptor open for writing. +.It Bq Er EBUSY +The argument +.Fa cmd +is +.Dv F_ADD_SEALS , +attempting to set +.Dv F_SEAL_WRITE , +and writeable mappings of the file exist. .It Bq Er EDEADLK The argument .Fa cmd @@ -565,6 +609,14 @@ points is not valid. .Pp The argument .Fa cmd +is +.Dv F_ADD_SEALS +or +.Dv F_GET_SEALS , +and the underlying filesystem does not support sealing. +.Pp +The argument +.Fa cmd is invalid. .It Bq Er EMFILE The argument @@ -624,6 +676,15 @@ is and the process ID or process group given as an argument is in a different session than the caller. +.Pp +The +.Fa cmd +argument +is +.Dv F_ADD_SEALS +and the +.Dv F_SEAL_SEAL +seal has already been set. .It Bq Er ESRCH The .Fa cmd ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352695 - in head/sys: kern sys
Author: kevans Date: Wed Sep 25 17:32:43 2019 New Revision: 352695 URL: https://svnweb.freebsd.org/changeset/base/352695 Log: [1/3] Add mostly Linux-compatible file sealing support File sealing applies protections against certain actions (currently: write, growth, shrink) at the inode level. New fileops are added to accommodate seals - EINVAL is returned by fcntl(2) if they are not implemented. Reviewed by: markj, kib Differential Revision:https://reviews.freebsd.org/D21391 Modified: head/sys/kern/kern_descrip.c head/sys/kern/uipc_shm.c head/sys/sys/fcntl.h head/sys/sys/file.h head/sys/sys/mman.h Modified: head/sys/kern/kern_descrip.c == --- head/sys/kern/kern_descrip.cWed Sep 25 17:30:28 2019 (r352694) +++ head/sys/kern/kern_descrip.cWed Sep 25 17:32:43 2019 (r352695) @@ -489,7 +489,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ struct filedescent *fde; struct proc *p; struct vnode *vp; - int error, flg, tmp; + int error, flg, seals, tmp; uint64_t bsize; off_t foffset; @@ -753,6 +753,25 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_ vp = fp->f_vnode; error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_GETLK, flp, F_POSIX); + fdrop(fp, td); + break; + + case F_ADD_SEALS: + error = fget_unlocked(fdp, fd, _no_rights, , NULL); + if (error != 0) + break; + error = fo_add_seals(fp, arg); + fdrop(fp, td); + break; + + case F_GET_SEALS: + error = fget_unlocked(fdp, fd, _no_rights, , NULL); + if (error != 0) + break; + if (fo_get_seals(fp, ) == 0) + td->td_retval[0] = seals; + else + error = EINVAL; fdrop(fp, td); break; Modified: head/sys/kern/uipc_shm.c == --- head/sys/kern/uipc_shm.cWed Sep 25 17:30:28 2019(r352694) +++ head/sys/kern/uipc_shm.cWed Sep 25 17:32:43 2019(r352695) @@ -119,6 +119,8 @@ static void shm_init(void *arg); static voidshm_insert(char *path, Fnv32_t fnv, struct shmfd *shmfd); static struct shmfd *shm_lookup(char *path, Fnv32_t fnv); static int shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred); +static int shm_dotruncate_locked(struct shmfd *shmfd, off_t length, +void *rl_cookie); static fo_rdwr_t shm_read; static fo_rdwr_t shm_write; @@ -131,6 +133,8 @@ static fo_chown_t shm_chown; static fo_seek_t shm_seek; static fo_fill_kinfo_t shm_fill_kinfo; static fo_mmap_t shm_mmap; +static fo_get_seals_t shm_get_seals; +static fo_add_seals_t shm_add_seals; /* File descriptor operations. */ struct fileops shm_ops = { @@ -148,6 +152,8 @@ struct fileops shm_ops = { .fo_seek = shm_seek, .fo_fill_kinfo = shm_fill_kinfo, .fo_mmap = shm_mmap, + .fo_get_seals = shm_get_seals, + .fo_add_seals = shm_add_seals, .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE }; @@ -316,8 +322,10 @@ shm_write(struct file *fp, struct uio *uio, struct ucr rl_cookie = rangelock_wlock(>shm_rl, uio->uio_offset, uio->uio_offset + uio->uio_resid, >shm_mtx); } - - error = uiomove_object(shmfd->shm_object, shmfd->shm_size, uio); + if ((shmfd->shm_seals & F_SEAL_WRITE) != 0) + error = EPERM; + else + error = uiomove_object(shmfd->shm_object, shmfd->shm_size, uio); rangelock_unlock(>shm_rl, rl_cookie, >shm_mtx); foffset_unlock_uio(fp, uio, flags); return (error); @@ -412,8 +420,8 @@ shm_close(struct file *fp, struct thread *td) return (0); } -int -shm_dotruncate(struct shmfd *shmfd, off_t length) +static int +shm_dotruncate_locked(struct shmfd *shmfd, off_t length, void *rl_cookie) { vm_object_t object; vm_page_t m; @@ -423,23 +431,23 @@ shm_dotruncate(struct shmfd *shmfd, off_t length) KASSERT(length >= 0, ("shm_dotruncate: length < 0")); object = shmfd->shm_object; - VM_OBJECT_WLOCK(object); - if (length == shmfd->shm_size) { - VM_OBJECT_WUNLOCK(object); + VM_OBJECT_ASSERT_WLOCKED(object); + rangelock_cookie_assert(rl_cookie, RA_WLOCKED); + if (length == shmfd->shm_size) return (0); - } nobjsize = OFF_TO_IDX(length + PAGE_MASK); /* Are we shrinking? If so, trim the end. */ if (length < shmfd->shm_size) { + if ((shmfd->shm_seals & F_SEAL_SHRINK) != 0) + return (EPERM); + /*
svn commit: r352694 - in head/sys: amd64/linux amd64/linux32 arm64/linux compat/freebsd32 i386/linux sys
Author: kevans Date: Wed Sep 25 17:30:28 2019 New Revision: 352694 URL: https://svnweb.freebsd.org/changeset/base/352694 Log: sysent: regenerate after r352693 Modified: head/sys/amd64/linux/linux_proto.h head/sys/amd64/linux32/linux32_proto.h head/sys/arm64/linux/linux_proto.h head/sys/compat/freebsd32/freebsd32_proto.h head/sys/i386/linux/linux_proto.h head/sys/sys/sysproto.h Modified: head/sys/amd64/linux/linux_proto.h == --- head/sys/amd64/linux/linux_proto.h Wed Sep 25 17:29:45 2019 (r352693) +++ head/sys/amd64/linux/linux_proto.h Wed Sep 25 17:30:28 2019 (r352694) @@ -1556,6 +1556,13 @@ int linux_io_uring_register(struct thread *, struct li #endif /* COMPAT_FREEBSD11 */ + +#ifdef COMPAT_FREEBSD12 + +#definenosys linux_nosys + +#endif /* COMPAT_FREEBSD12 */ + #defineLINUX_SYS_AUE_linux_openAUE_OPEN_RWTC #defineLINUX_SYS_AUE_linux_newstat AUE_STAT #defineLINUX_SYS_AUE_linux_newfstatAUE_FSTAT Modified: head/sys/amd64/linux32/linux32_proto.h == --- head/sys/amd64/linux32/linux32_proto.h Wed Sep 25 17:29:45 2019 (r352693) +++ head/sys/amd64/linux32/linux32_proto.h Wed Sep 25 17:30:28 2019 (r352694) @@ -1896,6 +1896,13 @@ int linux_io_uring_register(struct thread *, struct li #endif /* COMPAT_FREEBSD11 */ + +#ifdef COMPAT_FREEBSD12 + +#definenosys linux_nosys + +#endif /* COMPAT_FREEBSD12 */ + #defineLINUX32_SYS_AUE_linux_exit AUE_EXIT #defineLINUX32_SYS_AUE_linux_fork AUE_FORK #defineLINUX32_SYS_AUE_linux_open AUE_OPEN_RWTC Modified: head/sys/arm64/linux/linux_proto.h == --- head/sys/arm64/linux/linux_proto.h Wed Sep 25 17:29:45 2019 (r352693) +++ head/sys/arm64/linux/linux_proto.h Wed Sep 25 17:30:28 2019 (r352694) @@ -1320,6 +1320,13 @@ int linux_pkey_free(struct thread *, struct linux_pkey #endif /* COMPAT_FREEBSD11 */ + +#ifdef COMPAT_FREEBSD12 + +#definenosys linux_nosys + +#endif /* COMPAT_FREEBSD12 */ + #defineLINUX_SYS_AUE_linux_setxattrAUE_NULL #defineLINUX_SYS_AUE_linux_lsetxattr AUE_NULL #defineLINUX_SYS_AUE_linux_fsetxattr AUE_NULL Modified: head/sys/compat/freebsd32/freebsd32_proto.h == --- head/sys/compat/freebsd32/freebsd32_proto.h Wed Sep 25 17:29:45 2019 (r352693) +++ head/sys/compat/freebsd32/freebsd32_proto.h Wed Sep 25 17:30:28 2019 (r352694) @@ -1266,6 +1266,30 @@ int freebsd11_freebsd32_fstatat(struct thread *, struc #endif /* COMPAT_FREEBSD11 */ + +#ifdef COMPAT_FREEBSD12 + +#if !defined(PAD64_REQUIRED) && !defined(__amd64__) +#define PAD64_REQUIRED +#endif +#ifdef PAD64_REQUIRED +#else +#endif +#ifdef PAD64_REQUIRED +#else +#endif +#ifdef PAD64_REQUIRED +#else +#endif +#ifdef PAD64_REQUIRED +#else +#endif +#ifdef PAD64_REQUIRED +#else +#endif + +#endif /* COMPAT_FREEBSD12 */ + #defineFREEBSD32_SYS_AUE_freebsd32_wait4 AUE_WAIT4 #defineFREEBSD32_SYS_AUE_freebsd4_freebsd32_getfsstat AUE_GETFSSTAT #defineFREEBSD32_SYS_AUE_ofreebsd32_lseek AUE_LSEEK Modified: head/sys/i386/linux/linux_proto.h == --- head/sys/i386/linux/linux_proto.h Wed Sep 25 17:29:45 2019 (r352693) +++ head/sys/i386/linux/linux_proto.h Wed Sep 25 17:30:28 2019 (r352694) @@ -1916,6 +1916,13 @@ int linux_io_uring_register(struct thread *, struct li #endif /* COMPAT_FREEBSD11 */ + +#ifdef COMPAT_FREEBSD12 + +#definenosys linux_nosys + +#endif /* COMPAT_FREEBSD12 */ + #defineLINUX_SYS_AUE_linux_exitAUE_EXIT #defineLINUX_SYS_AUE_linux_forkAUE_FORK #defineLINUX_SYS_AUE_linux_openAUE_OPEN_RWTC Modified: head/sys/sys/sysproto.h == --- head/sys/sys/sysproto.h Wed Sep 25 17:29:45 2019(r352693) +++ head/sys/sys/sysproto.h Wed Sep 25 17:30:28 2019(r352694) @@ -2643,6 +2643,12 @@ int freebsd11_mknodat(struct thread *, struct freebsd1 #endif /* COMPAT_FREEBSD11 */ + +#ifdef COMPAT_FREEBSD12 + + +#endif /* COMPAT_FREEBSD12 */ + #defineSYS_AUE_syscall AUE_NULL #defineSYS_AUE_exitAUE_EXIT #defineSYS_AUE_forkAUE_FORK ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352693 - in head/sys: compat/freebsd32 kern
Author: kevans Date: Wed Sep 25 17:29:45 2019 New Revision: 352693 URL: https://svnweb.freebsd.org/changeset/base/352693 Log: Add COMPAT12 support to makesyscalls.sh Reviewed by: kib, imp, brooks (all without syscalls.master edits) Differential Revision:https://reviews.freebsd.org/D21366 Modified: head/sys/compat/freebsd32/syscalls.master head/sys/kern/makesyscalls.sh head/sys/kern/syscalls.master Modified: head/sys/compat/freebsd32/syscalls.master == --- head/sys/compat/freebsd32/syscalls.master Wed Sep 25 17:16:21 2019 (r352692) +++ head/sys/compat/freebsd32/syscalls.master Wed Sep 25 17:29:45 2019 (r352693) @@ -13,7 +13,7 @@ ; case where the event exists, but we don't want auditing, the ; event should be #defined to AUE_NULL in audit_kevents.h. ; typeone of STD, OBSOL, UNIMPL, COMPAT, COMPAT4, COMPAT6, -; COMPAT7, COMPAT11, NODEF, NOARGS, NOPROTO, NOSTD +; COMPAT7, COMPAT11, COMPAT12, NODEF, NOARGS, NOPROTO, NOSTD ; The COMPAT* options may be combined with one or more NO* ; options separated by '|' with no spaces (e.g. COMPAT|NOARGS) ; namepseudo-prototype of syscall routine @@ -31,6 +31,7 @@ ; COMPAT7 included on COMPAT_FREEBSD7 #ifdef (FreeBSD 7 compat) ; COMPAT10 included on COMPAT_FREEBSD10 #ifdef (FreeBSD 10 compat) ; COMPAT11 included on COMPAT_FREEBSD11 #ifdef (FreeBSD 11 compat) +; COMPAT12 included on COMPAT_FREEBSD12 #ifdef (FreeBSD 12 compat) ; OBSOL obsolete, not included in system, only specifies name ; UNIMPL not implemented, placeholder only ; NOSTD implemented but as a lkm that can be statically Modified: head/sys/kern/makesyscalls.sh == --- head/sys/kern/makesyscalls.sh Wed Sep 25 17:16:21 2019 (r352692) +++ head/sys/kern/makesyscalls.sh Wed Sep 25 17:29:45 2019 (r352693) @@ -11,6 +11,7 @@ compat6=COMPAT_FREEBSD6 compat7=COMPAT_FREEBSD7 compat10=COMPAT_FREEBSD10 compat11=COMPAT_FREEBSD11 +compat12=COMPAT_FREEBSD12 # output files: sysnames="syscalls.c" @@ -39,6 +40,8 @@ syscompat10="sysent.compat10.$$" syscompat10dcl="sysent.compat10dcl.$$" syscompat11="sysent.compat11.$$" syscompat11dcl="sysent.compat11dcl.$$" +syscompat12="sysent.compat12.$$" +syscompat12dcl="sysent.compat12dcl.$$" sysent="sysent.switch.$$" sysinc="sysinc.switch.$$" sysarg="sysarg.switch.$$" @@ -47,9 +50,9 @@ systracetmp="systrace.$$" systraceret="systraceret.$$" capabilities_conf="capabilities.conf" -trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0 +trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $syscompat12 $syscompat12dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0 -touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret +touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $syscompat12 $syscompat12dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret case $# in 0) echo "usage: $0 input-file " 1>&2 @@ -118,6 +121,8 @@ sed -e ' syscompat10dcl = \"$syscompat10dcl\" syscompat11 = \"$syscompat11\" syscompat11dcl = \"$syscompat11dcl\" + syscompat12 = \"$syscompat12\" + syscompat12dcl = \"$syscompat12dcl\" sysent = \"$sysent\" syssw = \"$syssw\" sysinc = \"$sysinc\" @@ -134,6 +139,7 @@ sed -e ' compat7 = \"$compat7\" compat10 = \"$compat10\" compat11 = \"$compat11\" + compat12 = \"$compat12\" syscallprefix = \"$syscallprefix\" switchname = \"$switchname\" namesname = \"$namesname\" @@ -188,6 +194,7 @@ sed -e ' printf "\n#ifdef %s\n\n", compat7 > syscompat7 printf "\n#ifdef %s\n\n", compat10 > syscompat10 printf "\n#ifdef %s\n\n", compat11 > syscompat11 + printf "\n#ifdef %s\n\n", compat12 > syscompat12 printf "/*\n * System call names.\n *\n" > sysnames printf " * DO NOT EDIT-- this file is
svn commit: r352691 - in head: contrib/netbsd-tests/usr.bin/grep usr.bin/grep
Author: kevans Date: Wed Sep 25 17:14:43 2019 New Revision: 352691 URL: https://svnweb.freebsd.org/changeset/base/352691 Log: bsdgrep(1): various fixes of empty pattern/exit code/-c behavior When an empty pattern is encountered in the pattern list, I had previously broken bsdgrep to count that as a "match all" and ignore any other patterns in the list. This commit rectifies that mistake, among others: - The -v flag semantics were not quite right; lines matched should have been counted differently based on whether the -v flag was set or not. procline now definitively returns whether it's matched or not, and interpreting that result has been kicked up a level. - Empty patterns with the -x flag was broken similarly to empty patterns with the -w flag. The former is a whole-line match and should be more strict, only matching blank lines. No -x and no -w will will match the empty string at the beginning of each line. - The exit code with -L was broken, w.r.t. modern grep. Modern grap will exit(0) if any file that didn't match was output, so our interpretation was simply backwards. The new interpretation makes sense to me. Tests updated and added to try and catch some of this. This misbehavior was found by autoconf while fixing ports found in PR 229925 expecting either a more sane or a more GNU-like sed. MFC after:1 week Modified: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh head/usr.bin/grep/grep.c head/usr.bin/grep/util.c Modified: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh == --- head/contrib/netbsd-tests/usr.bin/grep/t_grep.shWed Sep 25 17:08:35 2019(r352690) +++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.shWed Sep 25 17:14:43 2019(r352691) @@ -413,6 +413,60 @@ wflag_emptypat_body() atf_check -o file:test4 grep -w -e "" test4 } +atf_test_case xflag_emptypat +xflag_emptypat_body() +{ + printf "" > test1 + printf "\n" > test2 + printf "qaz" > test3 + printf " qaz\n" > test4 + + # -x is whole-line, more strict than -w. + atf_check -s exit:1 -o empty grep -x -e "" test1 + + atf_check -o file:test2 grep -x -e "" test2 + + atf_check -s exit:1 -o empty grep -x -e "" test3 + + atf_check -s exit:1 -o empty grep -x -e "" test4 + + total=$(wc -l /COPYRIGHT | sed 's/[^0-9]//g') + + # Simple checks that grep -x with an empty pattern isn't matching every + # line. The exact counts aren't important, as long as they don't + # match the total line count and as long as they don't match each other. + atf_check -o save:xpositive.count grep -Fxc '' /COPYRIGHT + atf_check -o save:xnegative.count grep -Fvxc '' /COPYRIGHT + + atf_check -o not-inline:"${total}" cat xpositive.count + atf_check -o not-inline:"${total}" cat xnegative.count + + atf_check -o not-file:xnegative.count cat xpositive.count +} + +atf_test_case xflag_emptypat_plus +xflag_emptypat_plus_body() +{ + printf "foo\n\nbar\n\nbaz\n" > target + printf "foo\n \nbar\n \nbaz\n" > target_spacelines + printf "foo\nbar\nbaz\n" > matches + printf " \n \n" > spacelines + + printf "foo\n\nbar\n\nbaz\n" > patlist1 + printf "foo\n\nba\n\nbaz\n" > patlist2 + + sed -e '/bar/d' target > matches_not2 + + # Normal handling first + atf_check -o file:target grep -Fxf patlist1 target + atf_check -o file:matches grep -Fxf patlist1 target_spacelines + atf_check -o file:matches_not2 grep -Fxf patlist2 target + + # -v handling + atf_check -s exit:1 -o empty grep -Fvxf patlist1 target + atf_check -o file:spacelines grep -Fxvf patlist1 target_spacelines +} + atf_test_case excessive_matches excessive_matches_head() { @@ -551,6 +605,12 @@ grep_nomatch_flags_head() grep_nomatch_flags_body() { + grep_type + + if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "this test does not pass with GNU grep in base" + fi + printf "A\nB\nC\n" > test1 atf_check -o inline:"1\n" grep -c -C 1 -e "B" test1 @@ -563,7 +623,7 @@ grep_nomatch_flags_body() atf_check -o inline:"test1\n" grep -l -A 1 -e "B" test1 atf_check -o inline:"test1\n" grep -l -C 1 -e "B" test1 - atf_check -s exit:1 -o inline:"test1\n" grep -L -e "D" test1 + atf_check -o inline:"test1\n" grep -L -e "D" test1 atf_check -o empty grep -q -e "B" test1 atf_check -o empty grep -q -B 1 -e "B" test1 @@ -777,6 +837,8 @@ atf_init_test_cases() atf_add_test_case egrep_empty_invalid atf_add_test_case zerolen atf_add_test_case wflag_emptypat + atf_add_test_case xflag_emptypat + atf_add_test_case xflag_emptypat_plus atf_add_test_case excessive_matches atf_add_test_case wv_combo_break
svn commit: r352690 - head/sys/vm
Author: markj Date: Wed Sep 25 17:08:35 2019 New Revision: 352690 URL: https://svnweb.freebsd.org/changeset/base/352690 Log: Add some counters for per-VM page events. For now, just count batched page queue state operations. vm.stats.page.queue_ops counts the number of batch entries that successfully completed, while queue_nops counts entries that had no effect, which occurs when the queue operation had been completed before the batch entry was processed. Reviewed by: alc, kib MFC after:1 week Sponsored by: Intel, Netflix Differential Revision:https://reviews.freebsd.org/D21782 Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c == --- head/sys/vm/vm_page.c Wed Sep 25 16:49:22 2019(r352689) +++ head/sys/vm/vm_page.c Wed Sep 25 17:08:35 2019(r352690) @@ -73,11 +73,12 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include #include #include +#include #include #include #include @@ -130,6 +131,28 @@ static int vm_min_waiters; static int vm_severe_waiters; static int vm_pageproc_waiters; +static SYSCTL_NODE(_vm_stats, OID_AUTO, page, CTLFLAG_RD, 0, +"VM page statistics"); + +static counter_u64_t queue_ops = EARLY_COUNTER; +SYSCTL_COUNTER_U64(_vm_stats_page, OID_AUTO, queue_ops, +CTLFLAG_RD, _ops, +"Number of batched queue operations"); + +static counter_u64_t queue_nops = EARLY_COUNTER; +SYSCTL_COUNTER_U64(_vm_stats_page, OID_AUTO, queue_nops, +CTLFLAG_RD, _nops, +"Number of batched queue operations with no effects"); + +static void +counter_startup(void) +{ + + queue_ops = counter_u64_alloc(M_WAITOK); + queue_nops = counter_u64_alloc(M_WAITOK); +} +SYSINIT(page_counters, SI_SUB_CPU, SI_ORDER_ANY, counter_startup, NULL); + /* * bogus page -- for I/O to/from partially complete buffers, * or for paging into sparsely invalid regions. @@ -3117,6 +3140,7 @@ vm_pqbatch_process_page(struct vm_pagequeue *pq, vm_pa if (__predict_true((qflags & PGA_ENQUEUED) != 0)) vm_pagequeue_remove(pq, m); vm_page_dequeue_complete(m); + counter_u64_add(queue_ops, 1); } else if ((qflags & (PGA_REQUEUE | PGA_REQUEUE_HEAD)) != 0) { if ((qflags & PGA_ENQUEUED) != 0) TAILQ_REMOVE(>pq_pl, m, plinks.q); @@ -3141,6 +3165,9 @@ vm_pqbatch_process_page(struct vm_pagequeue *pq, vm_pa vm_page_aflag_clear(m, qflags & (PGA_REQUEUE | PGA_REQUEUE_HEAD)); + counter_u64_add(queue_ops, 1); + } else { + counter_u64_add(queue_nops, 1); } } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352689 - head/lib/libc/i386/string
Author: emaste Date: Wed Sep 25 16:49:22 2019 New Revision: 352689 URL: https://svnweb.freebsd.org/changeset/base/352689 Log: remove obsolete i386 MD memchr implementation bde reports (in a reply to r351700 commit mail): This uses scasb, which was last optimal on the 8086, or perhaps the original i386. On freefall, it is several times slower than the naive translation of the naive C code. Reported by: bde Reviewed by: kib, markj Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D21785 Deleted: head/lib/libc/i386/string/memchr.S Modified: head/lib/libc/i386/string/Makefile.inc Modified: head/lib/libc/i386/string/Makefile.inc == --- head/lib/libc/i386/string/Makefile.inc Wed Sep 25 16:11:35 2019 (r352688) +++ head/lib/libc/i386/string/Makefile.inc Wed Sep 25 16:49:22 2019 (r352689) @@ -5,7 +5,6 @@ MDSRCS+= \ bcopy.S \ bzero.S \ ffs.S \ - memchr.S \ memcmp.S \ memcpy.S \ memmove.S \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r351700 - head/lib/libc/string
On Wed, 25 Sep 2019 at 11:46, Bruce Evans wrote: > > On Wed, 25 Sep 2019, Ed Maste wrote: > > > On Fri, 20 Sep 2019 at 08:14, Bruce Evans wrote: > >> > >> Optimizing this function [memchr] is especially unimportant, > > > > Why? > > Because it is almost never used, and most of its uses are unimportant. > > It is used a whole 26 times in all of /usr/src/*bin: Sure, but libc exists for the benefit of more than just the FreeBSD base system. Open source software and proprietary products built on FreeBSD make use of memchr and other string routines and have performance concerns. > But how do you know that long strings are most common? For short strings, > it is better to have low overhead. Indeed, there is a trade-off. Some ad-hoc testing confirms the original implementation is faster for byte strings of less than 8 bytes (as one would expect), and showed it slower above that. > LONG_BIT is another bad way of encoding the word size. On arches with > correctly sized longs, long is twice as wide as either a machine register > or the maximum memory access width. So it is usually twice the word size > if correct. One can argue that all of our 64-bit archs have incorrectly sized longs then, but I don't find that useful. The compilers and machines FreeBSD runs on have 64-bit longs on 64-bit processors. > register_t is closer to being correct. That makes sense, although not currently used for that purpose anywhere in libc (or other libs) that I can see. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352688 - in head/sys: amd64/amd64 arm/arm arm64/arm64 dev/agp i386/i386 mips/mips powerpc/booke riscv/riscv vm x86/iommu
Author: markj Date: Wed Sep 25 16:11:35 2019 New Revision: 352688 URL: https://svnweb.freebsd.org/changeset/base/352688 Log: Complete the removal of the "wire_count" field from struct vm_page. Convert all remaining references to that field to "ref_count" and update comments accordingly. No functional change intended. Reviewed by: alc, kib Sponsored by: Intel, Netflix Differential Revision:https://reviews.freebsd.org/D21768 Modified: head/sys/amd64/amd64/efirt_machdep.c head/sys/amd64/amd64/pmap.c head/sys/arm/arm/pmap-v6.c head/sys/arm64/arm64/efirt_machdep.c head/sys/arm64/arm64/pmap.c head/sys/dev/agp/agp_i810.c head/sys/i386/i386/pmap.c head/sys/mips/mips/pmap.c head/sys/powerpc/booke/pmap.c head/sys/riscv/riscv/pmap.c head/sys/vm/vm_page.h head/sys/x86/iommu/intel_idpgtbl.c Modified: head/sys/amd64/amd64/efirt_machdep.c == --- head/sys/amd64/amd64/efirt_machdep.cWed Sep 25 15:51:07 2019 (r352687) +++ head/sys/amd64/amd64/efirt_machdep.cWed Sep 25 16:11:35 2019 (r352688) @@ -74,7 +74,7 @@ efi_destroy_1t1_map(void) if (obj_1t1_pt != NULL) { VM_OBJECT_RLOCK(obj_1t1_pt); TAILQ_FOREACH(m, _1t1_pt->memq, listq) - m->wire_count = VPRC_OBJREF; + m->ref_count = VPRC_OBJREF; vm_wire_sub(obj_1t1_pt->resident_page_count); VM_OBJECT_RUNLOCK(obj_1t1_pt); vm_object_deallocate(obj_1t1_pt); Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Wed Sep 25 15:51:07 2019(r352687) +++ head/sys/amd64/amd64/pmap.c Wed Sep 25 16:11:35 2019(r352688) @@ -1856,7 +1856,7 @@ pmap_init(void) ("pmap_init: page table page is out of range")); mpte->pindex = pmap_pde_pindex(KERNBASE) + i; mpte->phys_addr = KPTphys + (i << PAGE_SHIFT); - mpte->wire_count = 1; + mpte->ref_count = 1; /* * Collect the page table pages that were replaced by a 2MB @@ -3285,8 +3285,8 @@ pmap_remove_pt_page(pmap_t pmap, vm_offset_t va) } /* - * Decrements a page table page's wire count, which is used to record the - * number of valid page table entries within the page. If the wire count + * Decrements a page table page's reference count, which is used to record the + * number of valid page table entries within the page. If the reference count * drops to zero, then the page table page is unmapped. Returns TRUE if the * page table page was unmapped and FALSE otherwise. */ @@ -3294,8 +3294,8 @@ static inline boolean_t pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) { - --m->wire_count; - if (m->wire_count == 0) { + --m->ref_count; + if (m->ref_count == 0) { _pmap_unwire_ptp(pmap, va, m, free); return (TRUE); } else @@ -3355,7 +3355,7 @@ _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_ /* * After removing a page table entry, this routine is used to - * conditionally free the page, and manage the hold/wire counts. + * conditionally free the page, and manage the reference count. */ static int pmap_unuse_pt(pmap_t pmap, vm_offset_t va, pd_entry_t ptepde, @@ -3615,7 +3615,7 @@ _pmap_allocpte(pmap_t pmap, vm_pindex_t ptepindex, str } else { /* Add reference to pdp page */ pdppg = PHYS_TO_VM_PAGE(*pml4 & PG_FRAME); - pdppg->wire_count++; + pdppg->ref_count++; } pdp = (pdp_entry_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME); @@ -3660,7 +3660,7 @@ _pmap_allocpte(pmap_t pmap, vm_pindex_t ptepindex, str } else { /* Add reference to the pd page */ pdpg = PHYS_TO_VM_PAGE(*pdp & PG_FRAME); - pdpg->wire_count++; + pdpg->ref_count++; } } pd = (pd_entry_t *)PHYS_TO_DMAP(*pdp & PG_FRAME); @@ -3689,7 +3689,7 @@ retry: if (pdpe != NULL && (*pdpe & PG_V) != 0) { /* Add a reference to the pd page. */ pdpg = PHYS_TO_VM_PAGE(*pdpe & PG_FRAME); - pdpg->wire_count++; + pdpg->ref_count++; } else { /* Allocate a pd page. */ ptepindex = pmap_pde_pindex(va); @@ -3740,7 +3740,7 @@ retry: */ if (pd != NULL && (*pd & PG_V) != 0) { m = PHYS_TO_VM_PAGE(*pd & PG_FRAME); - m->wire_count++; + m->ref_count++; } else { /* * Here
Re: svn commit: r351700 - head/lib/libc/string
On Wed, 25 Sep 2019, Ed Maste wrote: On Fri, 20 Sep 2019 at 08:14, Bruce Evans wrote: Optimizing this function [memchr] is especially unimportant, Why? Because it is almost never used, and most of its uses are unimportant. It is used a whole 26 times in all of /usr/src/*bin: - sh/exec.c: 1 especially^N unimportant use after execve() fails - dmesg/dmesg.c: 2 uses; speed unimportant in utilitities like dmesg that parse small data - sort/sort.c: 2 uses for reading lines; speed possibly important - sed/process.c: 2 uses in options parsing; speed unimportant - grep/file.c: 3 uses for reading lines; speed possibly important, but if you want speed in utility that parses large data then you should use a special lexer and not general functions even to find newlines - gcore/elfcore.c: 1 use; speed unimportant - diff/diffreg.c: 1 use for detecting binaries; speed probably unimportant - mkimg/mkimg.c: 2 uses for writes; speed unimportant since i/o-bound - truss/syscalls.c:1 use; speed unimportant - indent/pr_comment.c: 1 use; speed unimportant - ppp/*.c: 4 uses; speed unimportant - timed/readmsg.c: 1 use; speed unimportant - inetd/inetd.c: 1 use; speed unimportant - jail/config.c: 1 use; speed unimportant - daemon/daemon.c: 1 use; speed unimportant - bhyve/gdb.c: 2 uses; speed unimportant Really, we should provide optimized assembly implementations of string functions deemed important, but it will take time for that to happen on all architectures. Really, we should provide optimized (usually non-assembly) implementations of no more than copying memory, and not deem any other string function as important (since none are). Even optimizing copying memory gives speed improvements of less than 1% in most programs. Assembly implementations are usually pessimal, and become more so with time. E.g., if you write memcpy() as something like *dst++ = *src++, then if the size is known at compile time, then clang will optimize to use AVXn in some cases. Handling the same number of cases in assembly is impractical. My experiments to optimize copying memory only handle about 30 cases, but I only tried to optimized for large copies and stopped adding cases 15 years ago when it became clear that too many cases would be needed. clang knows that it doesn't understand memory, so it doesn't do optimizations like this if the size is not known at compile time. It calls the library, which in FreeBSD doesn't even know that it doesn't understand memory. and this version has mounds of style bugs. Yes, I've wondered about applying style(9) to the handful of imported string routines. In general we don't really expect ongoing updates, so it's probably no concern from a maintenance perspective. - do { - if (*p++ == (unsigned char)c) - return ((void *)(p - 1)); - } while (--n != 0); Old KNF code. In the !__GNUC__ #else clause , this is replaced by equivalent code with a style that is very far from KNF. Functionally equivalent, although I compared the compiled output of both cases and what's currently there is somewhat smaller. Note that it's not an #else case, the equivalent loop is used in both cases - handling the non-word-size residue in the __GNUC__ case. +void *memchr(const void *src, int c, size_t n) +{ + const unsigned char *s = src; + c = (unsigned char)c; +#ifdef __GNUC__ + for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--); + if (n && *s != c) { + typedef size_t __attribute__((__may_alias__)) word; This seems to have no dependencies on __GNUC__ except the use of anti-aliasing, Yes, that is the reason. I checked that this optimization actually works. For long strings, it is almost sizeof(size_t) times faster, by accessing memory with a size sizeof(size_t). size_t is a not very good way of hard-coding the word size. Indeed - I wouldn't have imported this change if I didn't observe a reasonable benefit when trying it out. As for word size it could be replaced using LONG_BIT I suppose (as strspn.c, strlen.c), if it's getting reworked anyway. But how do you know that long strings are most common? For short strings, it is better to have low overhead. LONG_BIT is another bad way of encoding the word size. On arches with correctly sized longs, long is twice as wide as either a machine register or the maximum memory access width. So it is usually twice the word size if correct. register_t is closer to being correct. Related silly optimizations: - i386 has memchr() in asm. This uses scasb, which was last optimal on the 8088, or perhaps the original i386. On freefall, it is several times slower than the naive translation of the naive C code. I posted a review
Re: svn commit: r351700 - head/lib/libc/string
On Wed, 25 Sep 2019 at 10:11, Ed Maste wrote: > > Functionally equivalent, although I compared the compiled output of > both cases and what's currently there is somewhat smaller. Note that > it's not an #else case, the equivalent loop is used in both cases - > handling the non-word-size residue in the __GNUC__ case. Ah, actually I think I'm mistaken here - what's in the tree does indeed compile to a slightly smaller object, but just due to arbitrary nop alignment. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r351659 - in head: contrib/libc++/include contrib/netbsd-tests/lib/libc/ssp gnu/lib/libssp include lib/libc/stdio
On Fri, 13 Sep 2019 at 08:00, Bruce Evans wrote: > > C11 removed gets(), but POSIX.1-2017 (Issue 7) still has it (marked as > obsolescent). Thus this change breaks support for all versions of POSIX. Yes, and intentionally so. If there is a compelling reason to restore it I'll add the #ifdef-ery to make it available only in pre-C11. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r351700 - head/lib/libc/string
On Fri, 20 Sep 2019 at 08:14, Bruce Evans wrote: > > Optimizing this function [memchr] is especially unimportant, Why? Really, we should provide optimized assembly implementations of string functions deemed important, but it will take time for that to happen on all architectures. > and this version has mounds of style bugs. Yes, I've wondered about applying style(9) to the handful of imported string routines. In general we don't really expect ongoing updates, so it's probably no concern from a maintenance perspective. > > - do { > > - if (*p++ == (unsigned char)c) > > - return ((void *)(p - 1)); > > - } while (--n != 0); > > Old KNF code. In the !__GNUC__ #else clause , this is replaced by > equivalent code with a style that is very far from KNF. Functionally equivalent, although I compared the compiled output of both cases and what's currently there is somewhat smaller. Note that it's not an #else case, the equivalent loop is used in both cases - handling the non-word-size residue in the __GNUC__ case. > > +void *memchr(const void *src, int c, size_t n) > > +{ > > + const unsigned char *s = src; > > + c = (unsigned char)c; > > +#ifdef __GNUC__ > > + for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--); > > + if (n && *s != c) { > > + typedef size_t __attribute__((__may_alias__)) word; > > This seems to have no dependencies on __GNUC__ except the use of > anti-aliasing, Yes, that is the reason. > I checked that this optimization actually works. For long strings, it is > almost sizeof(size_t) times faster, by accessing memory with a size > sizeof(size_t). size_t is a not very good way of hard-coding the word size. Indeed - I wouldn't have imported this change if I didn't observe a reasonable benefit when trying it out. As for word size it could be replaced using LONG_BIT I suppose (as strspn.c, strlen.c), if it's getting reworked anyway. > Related silly optimizations: > - i386 has memchr() in asm. This uses scasb, which was last optimal on the >8088, or perhaps the original i386. On freefall, it is several times > slower >than the naive translation of the naive C code. I posted a review (https://reviews.freebsd.org/D21785) to remove the scasb implementation. I haven't investigated wmemchr. > - i386 pessimizes several old string functions using scasb. The only other one I see is in strcat.S, which should probably be retired as well. Are there others? > - i386 also does dubious alignment optimizations I don't think there's much value in putting a lot of time into i386, but am happy to address straightforward issues (such as removing pessimal MD implementations). I haven't looked at these alignment optimizations. > - amd64 pessimizes strcpy() by implementing it as a C wrapper for stpcpy(). >The wrapper code is MI, but is only used for amd64. And it appears the MD one is selected by Makefile .PATH ordering, which seems fragile. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352684 - head/sys/x86/x86
Author: kib Date: Wed Sep 25 13:36:56 2019 New Revision: 352684 URL: https://svnweb.freebsd.org/changeset/base/352684 Log: x86: Fall back to leaf 0x16 if TSC frequency is obtained by CPUID and leaf 0x15 is not functional. This should improve automatic TSC frequency determination on Skylake/Kabylake/... families, where 0x15 exists but does not provide all necessary information. SDM contains relatively strong wording against such uses of 0x16, but Intel does not give us any other way to obtain the frequency. Linux did the same in the commit 604dc9170f2435d27da5039a3efd757dceadc684. Based on submission by: Neel Chauhan PR: 240475 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after:1 week Differential revision:https://reviews.freebsd.org/D21777 Modified: head/sys/x86/x86/tsc.c Modified: head/sys/x86/x86/tsc.c == --- head/sys/x86/x86/tsc.c Wed Sep 25 13:29:56 2019(r352683) +++ head/sys/x86/x86/tsc.c Wed Sep 25 13:36:56 2019(r352684) @@ -134,7 +134,11 @@ tsc_freq_vmware(void) /* * Calculate TSC frequency using information from the CPUID leaf 0x15 - * 'Time Stamp Counter and Nominal Core Crystal Clock'. It should be + * 'Time Stamp Counter and Nominal Core Crystal Clock'. If leaf 0x15 + * is not functional, as it is on Skylake/Kabylake, try 0x16 'Processor + * Frequency Information'. Leaf 0x16 is described in the SDM as + * informational only, but if 0x15 did not work, and TSC calibration + * is disabled, it is the best we can get at all. It should still be * an improvement over the parsing of the CPU model name in * tsc_freq_intel(), when available. */ @@ -146,10 +150,20 @@ tsc_freq_cpuid(void) if (cpu_high < 0x15) return (false); do_cpuid(0x15, regs); - if (regs[0] == 0 || regs[1] == 0 || regs[2] == 0) + if (regs[0] != 0 && regs[1] != 0 && regs[2] != 0) { + tsc_freq = (uint64_t)regs[2] * regs[1] / regs[0]; + return (true); + } + + if (cpu_high < 0x16) return (false); - tsc_freq = (uint64_t)regs[2] * regs[1] / regs[0]; - return (true); + do_cpuid(0x16, regs); + if (regs[0] != 0) { + tsc_freq = (uint64_t)regs[0] * 100; + return (true); + } + + return (false); } static void ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r352661 - head/sys/netinet/tcp_stacks
On Tue, 24 Sep 2019 at 17:39, Bruce Evans wrote: > > On i386, these types have different sizes, so > gcc detects the type mismatch. clang is too broken to report this type > mismatch. Interesting, it seems Clang doesn't even warn in the case of casting a uint64_t to a 32-bit pointer. Looks like there are some useful warnings that ought to be implemented. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352681 - in head/sys/dev/vt: . hw/fb
Author: tsoome Date: Wed Sep 25 13:24:31 2019 New Revision: 352681 URL: https://svnweb.freebsd.org/changeset/base/352681 Log: vt: use colors from terminal emulator Instead of hardcoded colors, use terminal state. This also means, we need to record the pointer to terminal state with vtbuf. Modified: head/sys/dev/vt/hw/fb/vt_fb.c head/sys/dev/vt/vt.h head/sys/dev/vt/vt_buf.c head/sys/dev/vt/vt_core.c head/sys/dev/vt/vt_cpulogos.c Modified: head/sys/dev/vt/hw/fb/vt_fb.c == --- head/sys/dev/vt/hw/fb/vt_fb.c Wed Sep 25 13:21:07 2019 (r352680) +++ head/sys/dev/vt/hw/fb/vt_fb.c Wed Sep 25 13:24:31 2019 (r352681) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -453,7 +454,8 @@ vt_fb_init(struct vt_device *vd) { struct fb_info *info; u_int margin; - int err; + int bg, err; + term_color_t c; info = vd->vd_softc; vd->vd_height = MIN(VT_FB_MAX_HEIGHT, info->fb_height); @@ -477,8 +479,15 @@ vt_fb_init(struct vt_device *vd) info->fb_cmsize = 16; } + c = TC_BLACK; + TUNABLE_INT_FETCH("teken.bg_color", ); + if (bg != -1) { + if (bg == TC_WHITE) + bg |= TC_LIGHT; + c = bg; + } /* Clear the screen. */ - vd->vd_driver->vd_blank(vd, TC_BLACK); + vd->vd_driver->vd_blank(vd, c); /* Wakeup screen. KMS need this. */ vt_fb_postswitch(vd); Modified: head/sys/dev/vt/vt.h == --- head/sys/dev/vt/vt.hWed Sep 25 13:21:07 2019(r352680) +++ head/sys/dev/vt/vt.hWed Sep 25 13:24:31 2019(r352681) @@ -192,6 +192,7 @@ void vt_suspend(struct vt_device *vd); struct vt_buf { struct mtx vb_lock; /* Buffer lock. */ + struct terminal *vb_terminal; term_pos_t vb_scr_size; /* (b) Screen dimensions. */ int vb_flags; /* (b) Flags. */ #defineVBF_CURSOR 0x1 /* Cursor visible. */ Modified: head/sys/dev/vt/vt_buf.c == --- head/sys/dev/vt/vt_buf.cWed Sep 25 13:21:07 2019(r352680) +++ head/sys/dev/vt/vt_buf.cWed Sep 25 13:24:31 2019(r352681) @@ -420,6 +420,8 @@ void vtbuf_init_early(struct vt_buf *vb) { term_rect_t rect; + const teken_attr_t *a; + term_char_t c; vb->vb_flags |= VBF_CURSOR; vb->vb_roffset = 0; @@ -433,7 +435,11 @@ vtbuf_init_early(struct vt_buf *vb) rect.tr_begin.tp_row = rect.tr_begin.tp_col = 0; rect.tr_end.tp_col = vb->vb_scr_size.tp_col; rect.tr_end.tp_row = vb->vb_history_size; - vtbuf_do_fill(vb, , VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR)); + + a = teken_get_curattr(>vb_terminal->tm_emulator); + c = TCOLOR_FG((term_char_t)a->ta_fgcolor) | + TCOLOR_BG((term_char_t)a->ta_bgcolor); + vtbuf_do_fill(vb, , VTBUF_SPACE_CHAR(c)); vtbuf_make_undirty(vb); if ((vb->vb_flags & VBF_MTX_INIT) == 0) { mtx_init(>vb_lock, "vtbuf", NULL, MTX_SPIN); @@ -478,7 +484,12 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns unsigned int w, h, c, r, old_history_size; size_t bufsize, rowssize; int history_full; + const teken_attr_t *a; + term_char_t ch; + a = teken_get_curattr(>vb_terminal->tm_emulator); + ch = TCOLOR_FG(a->ta_fgcolor) | TCOLOR_BG(a->ta_bgcolor); + history_size = MAX(history_size, p->tp_row); /* Allocate new buffer. */ @@ -544,7 +555,7 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns * background color. */ for (c = MIN(p->tp_col, w); c < p->tp_col; c++) { - row[c] = VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR); + row[c] = VTBUF_SPACE_CHAR(ch); } } @@ -552,7 +563,7 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns for (r = old_history_size; r < history_size; r++) { row = rows[r]; for (c = MIN(p->tp_col, w); c < p->tp_col; c++) { - row[c] = VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR); + row[c] = VTBUF_SPACE_CHAR(ch); } } @@ -601,7 +612,7 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, uns * background color. */ for (c = MIN(p->tp_col, w); c < p->tp_col; c++) { - row[c] =
svn commit: r352680 - head/sys/kern
Author: tsoome Date: Wed Sep 25 13:21:07 2019 New Revision: 352680 URL: https://svnweb.freebsd.org/changeset/base/352680 Log: kernel: terminal_init() should check for teken colors from kenv Check for teken.fg_color and teken.bg_color and prepare the color attributes accordingly. When white background is used, make it light to improve visibility. When black background is used, make kernel messages light. Modified: head/sys/kern/subr_terminal.c Modified: head/sys/kern/subr_terminal.c == --- head/sys/kern/subr_terminal.c Wed Sep 25 13:04:34 2019 (r352679) +++ head/sys/kern/subr_terminal.c Wed Sep 25 13:21:07 2019 (r352680) @@ -124,13 +124,13 @@ static teken_funcs_t terminal_drawmethods = { }; /* Kernel message formatting. */ -static const teken_attr_t kernel_message = { +static teken_attr_t kernel_message = { .ta_fgcolor = TCHAR_FGCOLOR(TERMINAL_KERN_ATTR), .ta_bgcolor = TCHAR_BGCOLOR(TERMINAL_KERN_ATTR), .ta_format = TCHAR_FORMAT(TERMINAL_KERN_ATTR) }; -static const teken_attr_t default_message = { +static teken_attr_t default_message = { .ta_fgcolor = TCHAR_FGCOLOR(TERMINAL_NORM_ATTR), .ta_bgcolor = TCHAR_BGCOLOR(TERMINAL_NORM_ATTR), .ta_format = TCHAR_FORMAT(TERMINAL_NORM_ATTR) @@ -168,10 +168,33 @@ static const teken_attr_t default_message = { static void terminal_init(struct terminal *tm) { + int fg, bg; if (tm->tm_flags & TF_CONS) mtx_init(>tm_mtx, "trmlck", NULL, MTX_SPIN); + teken_init(>tm_emulator, _drawmethods, tm); + + TUNABLE_INT_FETCH("teken.fg_color", ); + TUNABLE_INT_FETCH("teken.bg_color", ); + + if (fg != -1) { + default_message.ta_fgcolor = fg; + kernel_message.ta_fgcolor = fg; + } + if (bg != -1) { + default_message.ta_bgcolor = bg; + kernel_message.ta_bgcolor = bg; + } + + if (default_message.ta_bgcolor == TC_WHITE) { + default_message.ta_bgcolor |= TC_LIGHT; + kernel_message.ta_bgcolor |= TC_LIGHT; + } + + if (default_message.ta_bgcolor == TC_BLACK && + default_message.ta_fgcolor < TC_NCOLORS) + kernel_message.ta_fgcolor |= TC_LIGHT; teken_set_defattr(>tm_emulator, _message); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352679 - head
Author: kevans Date: Wed Sep 25 13:04:34 2019 New Revision: 352679 URL: https://svnweb.freebsd.org/changeset/base/352679 Log: RELNOTES: Document r352668 (crontab -n and -q options) Suggested by: bapt Modified: head/RELNOTES Modified: head/RELNOTES == --- head/RELNOTES Wed Sep 25 12:58:49 2019(r352678) +++ head/RELNOTES Wed Sep 25 13:04:34 2019(r352679) @@ -10,6 +10,11 @@ newline. Entries should be separated by a newline. Changes to this file should not be MFCed. +r352668: + cron(8) now supports the -n (suppress mail on succesful run) and -q + (suppress logging of command execution) options in the crontab format. + See the crontab(5) manpage for details. + r352304: ntpd is no longer by default locked in memory. rlimit memlock 32 or rlimit memlock 0 can be used to restore this behaviour. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r352668 - in head/usr.sbin/cron: cron crontab lib
On Wed, Sep 25, 2019 at 1:58 AM Baptiste Daroussin wrote: > > On Wed, Sep 25, 2019 at 02:37:41AM +, Kyle Evans wrote: > > Author: kevans > > Date: Wed Sep 25 02:37:40 2019 > > New Revision: 352668 > > URL: https://svnweb.freebsd.org/changeset/base/352668 > > > > Log: > > cron: add log suppression and mail suppression for successful runs > > > > This commit adds two new extensions to crontab, ported from OpenBSD: > > - -n: suppress mail on succesful run > > - -q: suppress logging of command execution > > > > The -q option appears decades old, but -n is relatively new. The > > original proposal by Job Snijder can be found here [1], and gives very > > convincing reasons for inclusion in base. > > > > This patch is a nearly identical port of OpenBSD cron for -q and -n > > features. It is written to follow existing conventions and style of the > > existing codebase. > > > > Example usage: > > > > # should only send email, but won't show up in log > > * * * * * -q date > > > > # should not send email > > * * * * * -n date > > > > # should not send email or log > > * * * * * -n -q date > > > > # should send email because of ping failure > > * * * * * -n -q ping -c 1 5.5.5.5 > > > > [1]: https://marc.info/?l=openbsd-tech=152874866117948=2 > > > > PR: 237538 > > Submitted by: Naveen Nathan > > Reviewed by:bcr (manpages) > > MFC after: 1 week > > Differential Revision: https://reviews.freebsd.org/D20046 > > > I do think this deserves an entry in the release notes > Ahh, I'm inclined to agree. I'll write up a RELNOTES entry here shortly. Thanks, Kyle Evans ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r352658 - head/sys/kern
On 25.09.2019 01:13, Peter Holm wrote: > On Tue, Sep 24, 2019 at 08:01:20PM +, Alexander Motin wrote: >> Author: mav >> Date: Tue Sep 24 20:01:20 2019 >> New Revision: 352658 >> URL: https://svnweb.freebsd.org/changeset/base/352658 >> >> Log: >> Fix/improve interrupt threads scheduling. >> >> Doing some tests with very high interrupt rates I've noticed that one of >> conditions I added in r232207 to make interrupt threads in most cases >> run on local CPU never worked as expected (worked only if previous time >> it was executed on some other CPU, that is quite opposite). It caused >> additional CPU usage to run full CPU search and could schedule interrupt >> threads to some other CPU. >> >> This patch removes that code and instead reuses existing non-interrupt >> code path with some tweaks for interrupt case: >>- On SMT systems, if current thread is idle, don't look on other threads. >> Even if they are busy, it may take more time to do fill search and bounce >> the interrupt thread to other core then execute it locally, even sharing >> CPU resources. It is other threads should migrate, not bound interrupts. >>- Try hard to keep interrupt threads within LLC of their original CPU. >> This improves scheduling cost and supposedly cache and memory locality. >> >> On a test system with 72 threads doing 2.2M IOPS to NVMe this saves few >> percents of CPU time while adding few percents to IOPS. >> >> MFC after: 1 month >> Sponsored by: iXsystems, Inc. >> >> Modified: >> head/sys/kern/sched_ule.c >> >> Modified: head/sys/kern/sched_ule.c >> == >> --- head/sys/kern/sched_ule.cTue Sep 24 18:18:11 2019 >> (r352657) >> +++ head/sys/kern/sched_ule.cTue Sep 24 20:01:20 2019 >> (r352658) >> @@ -1251,7 +1251,7 @@ sched_pickcpu(struct thread *td, int flags) > > Could this be yours? > > FreeBSD/SMP: Multiprocessor System Detected: 24 CPUs > FreeBSD/SMP: 2 package(s) x 6 core(s) x 2 hardware threads > random: unblocking device. > Firmware Warning (ACPI): Invalid length for FADT/Pm1aControlBlock: 32, using > default 16 (20190703/tbfadt-850) > ioapic0 irqs 0-23 > ioapic1 irqs 24-47 > ioapic2 irqs 48-71 > Launching APs: 13 6 18 17 5 9 8 19 7 10 1 11 2 12 14 15 20 4 21 16 22 3 23 > panic: sched_pickcpu: Failed to find a cpu. > cpuid = 0 > time = 1 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0x8254a830 > vpanic() at vpanic+0x19d/frame 0x8254a880 > panic() at panic+0x43/frame 0x8254a8e0 > sched_pickcpu() at sched_pickcpu+0x4c1/frame 0x8254a990 > sched_add() at sched_add+0x6e/frame 0x8254a9d0 > gtaskqueue_start_threads() at gtaskqueue_start_threads+0x124/frame > 0x8254aa70 > taskqgroup_cpu_create() at taskqgroup_cpu_create+0x135/frame > 0x8254aab0 > taskqgroup_adjust() at taskqgroup_adjust+0x1ad/frame 0x8254ab20 > mi_startup() at mi_startup+0x210/frame 0x8254ab70 > btext() at btext+0x2c > KDB: enter: panic > [ thread pid 0 tid 10 ] > Stopped at kdb_enter+0x3b: movq$0,kdb_why > db> Should be fixed by r352677. Sorry. -- Alexander Motin ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352677 - head/sys/kern
Author: mav Date: Wed Sep 25 11:58:54 2019 New Revision: 352677 URL: https://svnweb.freebsd.org/changeset/base/352677 Log: Fix wrong assertion in r352658. MFC after:1 month Modified: head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_ule.c == --- head/sys/kern/sched_ule.c Wed Sep 25 10:46:05 2019(r352676) +++ head/sys/kern/sched_ule.c Wed Sep 25 11:58:54 2019(r352677) @@ -1345,7 +1345,7 @@ sched_pickcpu(struct thread *td, int flags) if (cpu >= 0) SCHED_STAT_INC(pickcpu_lowest); } - KASSERT(cpu < 0, ("sched_pickcpu: Failed to find a cpu.")); + KASSERT(cpu >= 0, ("sched_pickcpu: Failed to find a cpu.")); KASSERT(!CPU_ABSENT(cpu), ("sched_pickcpu: Picked absent CPU %d.", cpu)); /* * Compare the lowest loaded cpu to current cpu. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352671 - head/sbin/nvmecontrol
Author: imp Date: Wed Sep 25 07:51:30 2019 New Revision: 352671 URL: https://svnweb.freebsd.org/changeset/base/352671 Log: Size is unsigned, so remove the test entirely. The kernel won't crash if you have a bad value and I'd rather not have nvmecontrol know the internal details about how the nvme driver limits the transfer size. Modified: head/sbin/nvmecontrol/perftest.c Modified: head/sbin/nvmecontrol/perftest.c == --- head/sbin/nvmecontrol/perftest.cWed Sep 25 07:36:35 2019 (r352670) +++ head/sbin/nvmecontrol/perftest.cWed Sep 25 07:51:30 2019 (r352671) @@ -177,10 +177,6 @@ perftest(const struct cmd *f, int argc, char *argv[]) arg_help(argc, argv, f); } io_test.time = opt.time; - if (opt.size < 0) { - fprintf(stderr, "Invalid size.\n"); - arg_help(argc, argv, f); - } io_test.size = opt.size; open_dev(opt.dev, , 1, 1); if (ioctl(fd, ioctl_cmd, _test) < 0) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352670 - in head/stand: efi/libefi i386/libi386
Author: tsoome Date: Wed Sep 25 07:36:35 2019 New Revision: 352670 URL: https://svnweb.freebsd.org/changeset/base/352670 Log: loader: fix indentation in efi_console and vidconsole Remove extra tab. Reported by: yuripv Modified: head/stand/efi/libefi/efi_console.c head/stand/i386/libi386/vidconsole.c Modified: head/stand/efi/libefi/efi_console.c == --- head/stand/efi/libefi/efi_console.c Wed Sep 25 07:09:25 2019 (r352669) +++ head/stand/efi/libefi/efi_console.c Wed Sep 25 07:36:35 2019 (r352670) @@ -374,7 +374,7 @@ color_name_to_teken(const char *name, int *val) *val = TC_CYAN; return (true); } - if (strcasecmp(name, "white") == 0) { + if (strcasecmp(name, "white") == 0) { *val = TC_WHITE; return (true); } Modified: head/stand/i386/libi386/vidconsole.c == --- head/stand/i386/libi386/vidconsole.cWed Sep 25 07:09:25 2019 (r352669) +++ head/stand/i386/libi386/vidconsole.cWed Sep 25 07:36:35 2019 (r352670) @@ -600,7 +600,7 @@ color_name_to_teken(const char *name, int *val) *val = TC_CYAN; return (true); } - if (strcasecmp(name, "white") == 0) { + if (strcasecmp(name, "white") == 0) { *val = TC_WHITE; return (true); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r352658 - head/sys/kern
> On 25. Sep 2019, at 07:13, Peter Holm wrote: > > On Tue, Sep 24, 2019 at 08:01:20PM +, Alexander Motin wrote: >> Author: mav >> Date: Tue Sep 24 20:01:20 2019 >> New Revision: 352658 >> URL: https://svnweb.freebsd.org/changeset/base/352658 >> >> Log: >> Fix/improve interrupt threads scheduling. >> >> Doing some tests with very high interrupt rates I've noticed that one of >> conditions I added in r232207 to make interrupt threads in most cases >> run on local CPU never worked as expected (worked only if previous time >> it was executed on some other CPU, that is quite opposite). It caused >> additional CPU usage to run full CPU search and could schedule interrupt >> threads to some other CPU. >> >> This patch removes that code and instead reuses existing non-interrupt >> code path with some tweaks for interrupt case: >> - On SMT systems, if current thread is idle, don't look on other threads. >> Even if they are busy, it may take more time to do fill search and bounce >> the interrupt thread to other core then execute it locally, even sharing >> CPU resources. It is other threads should migrate, not bound interrupts. >> - Try hard to keep interrupt threads within LLC of their original CPU. >> This improves scheduling cost and supposedly cache and memory locality. >> >> On a test system with 72 threads doing 2.2M IOPS to NVMe this saves few >> percents of CPU time while adding few percents to IOPS. >> >> MFC after: 1 month >> Sponsored by: iXsystems, Inc. >> >> Modified: >> head/sys/kern/sched_ule.c >> >> Modified: head/sys/kern/sched_ule.c >> == >> --- head/sys/kern/sched_ule.cTue Sep 24 18:18:11 2019 >> (r352657) >> +++ head/sys/kern/sched_ule.cTue Sep 24 20:01:20 2019 >> (r352658) >> @@ -1251,7 +1251,7 @@ sched_pickcpu(struct thread *td, int flags) > > Could this be yours? > > FreeBSD/SMP: Multiprocessor System Detected: 24 CPUs > FreeBSD/SMP: 2 package(s) x 6 core(s) x 2 hardware threads > random: unblocking device. > Firmware Warning (ACPI): Invalid length for FADT/Pm1aControlBlock: 32, using > default 16 (20190703/tbfadt-850) > ioapic0 irqs 0-23 > ioapic1 irqs 24-47 > ioapic2 irqs 48-71 > Launching APs: 13 6 18 17 5 9 8 19 7 10 1 11 2 12 14 15 20 4 21 16 22 3 23 > panic: sched_pickcpu: Failed to find a cpu. > cpuid = 0 > time = 1 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0x8254a830 > vpanic() at vpanic+0x19d/frame 0x8254a880 > panic() at panic+0x43/frame 0x8254a8e0 > sched_pickcpu() at sched_pickcpu+0x4c1/frame 0x8254a990 > sched_add() at sched_add+0x6e/frame 0x8254a9d0 > gtaskqueue_start_threads() at gtaskqueue_start_threads+0x124/frame > 0x8254aa70 > taskqgroup_cpu_create() at taskqgroup_cpu_create+0x135/frame > 0x8254aab0 > taskqgroup_adjust() at taskqgroup_adjust+0x1ad/frame 0x8254ab20 > mi_startup() at mi_startup+0x210/frame 0x8254ab70 > btext() at btext+0x2c > KDB: enter: panic > [ thread pid 0 tid 10 ] > Stopped at kdb_enter+0x3b: movq$0,kdb_why > db> Also triggered by syzkaller: https://syzkaller.appspot.com/bug?id=27e65a528a1431f0aeea7b7814e685bddf769747 Best regards Michael > > - Peter smime.p7s Description: S/MIME cryptographic signature
svn commit: r352669 - in head/stand: efi/libefi i386/libi386
Author: tsoome Date: Wed Sep 25 07:09:25 2019 New Revision: 352669 URL: https://svnweb.freebsd.org/changeset/base/352669 Log: loader: add teken.fg_color and teken.bg_color variables Add settable variables to control teken default color attributes. The supported colors are 0-7 or basic color names: black, red, green, brown, blue, magenta, cyan, white. The current implementation does add some duplication which will be addressed later. Modified: head/stand/efi/libefi/efi_console.c head/stand/i386/libi386/vidconsole.c Modified: head/stand/efi/libefi/efi_console.c == --- head/stand/efi/libefi/efi_console.c Wed Sep 25 02:37:40 2019 (r352668) +++ head/stand/efi/libefi/efi_console.c Wed Sep 25 07:09:25 2019 (r352669) @@ -343,6 +343,91 @@ efi_cons_probe(struct console *cp) cp->c_flags |= C_PRESENTIN | C_PRESENTOUT; } +static bool +color_name_to_teken(const char *name, int *val) +{ + if (strcasecmp(name, "black") == 0) { + *val = TC_BLACK; + return (true); + } + if (strcasecmp(name, "red") == 0) { + *val = TC_RED; + return (true); + } + if (strcasecmp(name, "green") == 0) { + *val = TC_GREEN; + return (true); + } + if (strcasecmp(name, "brown") == 0) { + *val = TC_BROWN; + return (true); + } + if (strcasecmp(name, "blue") == 0) { + *val = TC_BLUE; + return (true); + } + if (strcasecmp(name, "magenta") == 0) { + *val = TC_MAGENTA; + return (true); + } + if (strcasecmp(name, "cyan") == 0) { + *val = TC_CYAN; + return (true); + } + if (strcasecmp(name, "white") == 0) { + *val = TC_WHITE; + return (true); + } + return (false); +} + +static int +efi_set_colors(struct env_var *ev, int flags, const void *value) +{ + int val = 0; + char buf[2]; + const void *evalue; + const teken_attr_t *ap; + teken_attr_t a; + + if (value == NULL) + return (CMD_OK); + + if (color_name_to_teken(value, )) { + snprintf(buf, sizeof (buf), "%d", val); + evalue = buf; + } else { + char *end; + + errno = 0; + val = (int)strtol(value, , 0); + if (errno != 0 || *end != '\0') { + printf("Allowed values are either ansi color name or " + "number from range [0-7].\n"); + return (CMD_OK); + } + evalue = value; + } + + ap = teken_get_defattr(); + a = *ap; + if (strcmp(ev->ev_name, "teken.fg_color") == 0) { + /* is it already set? */ + if (ap->ta_fgcolor == val) + return (CMD_OK); + a.ta_fgcolor = val; + } + if (strcmp(ev->ev_name, "teken.bg_color") == 0) { + /* is it already set? */ + if (ap->ta_bgcolor == val) + return (CMD_OK); + a.ta_bgcolor = val; + } + env_setenv(ev->ev_name, flags | EV_NOHOOK, evalue, NULL, NULL); + teken_set_defattr(, ); + return (CMD_OK); +} + bool efi_cons_update_mode(void) { @@ -373,6 +458,13 @@ efi_cons_update_mode(void) teken_set_winsize(, ); a = teken_get_defattr(); + + snprintf(env, sizeof(env), "%d", a->ta_fgcolor); + env_setenv("teken.fg_color", EV_VOLATILE, env, efi_set_colors, + env_nounset); + snprintf(env, sizeof(env), "%d", a->ta_bgcolor); + env_setenv("teken.bg_color", EV_VOLATILE, env, efi_set_colors, + env_nounset); for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++) { Modified: head/stand/i386/libi386/vidconsole.c == --- head/stand/i386/libi386/vidconsole.cWed Sep 25 02:37:40 2019 (r352668) +++ head/stand/i386/libi386/vidconsole.cWed Sep 25 07:09:25 2019 (r352669) @@ -569,7 +569,97 @@ vidc_probe(struct console *cp) cp->c_flags |= C_PRESENTOUT; } +static bool +color_name_to_teken(const char *name, int *val) +{ + if (strcasecmp(name, "black") == 0) { + *val = TC_BLACK; + return (true); + } + if (strcasecmp(name, "red") == 0) { + *val = TC_RED; + return (true); + } + if (strcasecmp(name, "green") == 0) { + *val = TC_GREEN; + return (true); + } + if (strcasecmp(name, "brown") == 0) { + *val = TC_BROWN; + return (true); + } + if (strcasecmp(name,
Re: svn commit: r352668 - in head/usr.sbin/cron: cron crontab lib
On Wed, Sep 25, 2019 at 02:37:41AM +, Kyle Evans wrote: > Author: kevans > Date: Wed Sep 25 02:37:40 2019 > New Revision: 352668 > URL: https://svnweb.freebsd.org/changeset/base/352668 > > Log: > cron: add log suppression and mail suppression for successful runs > > This commit adds two new extensions to crontab, ported from OpenBSD: > - -n: suppress mail on succesful run > - -q: suppress logging of command execution > > The -q option appears decades old, but -n is relatively new. The > original proposal by Job Snijder can be found here [1], and gives very > convincing reasons for inclusion in base. > > This patch is a nearly identical port of OpenBSD cron for -q and -n > features. It is written to follow existing conventions and style of the > existing codebase. > > Example usage: > > # should only send email, but won't show up in log > * * * * * -q date > > # should not send email > * * * * * -n date > > # should not send email or log > * * * * * -n -q date > > # should send email because of ping failure > * * * * * -n -q ping -c 1 5.5.5.5 > > [1]: https://marc.info/?l=openbsd-tech=152874866117948=2 > > PR: 237538 > Submitted by: Naveen Nathan > Reviewed by:bcr (manpages) > MFC after: 1 week > Differential Revision: https://reviews.freebsd.org/D20046 > I do think this deserves an entry in the release notes Best regards, Bapt signature.asc Description: PGP signature