svn commit: r351452 - in head/sys: dts/arm/overlays modules/dtb/allwinner

2019-08-24 Thread Ganbold Tsagaankhuu
Author: ganbold
Date: Sat Aug 24 13:26:34 2019
New Revision: 351452
URL: https://svnweb.freebsd.org/changeset/base/351452

Log:
  dtso: allwinner: Add an overlay for H3 thermal node
  
  Reviewed by:  manu

Added:
  head/sys/dts/arm/overlays/sun8i-h3-ths.dtso   (contents, props changed)
Modified:
  head/sys/dts/arm/overlays/sun8i-h3-sid.dtso
  head/sys/modules/dtb/allwinner/Makefile

Modified: head/sys/dts/arm/overlays/sun8i-h3-sid.dtso
==
--- head/sys/dts/arm/overlays/sun8i-h3-sid.dtso Sat Aug 24 12:51:46 2019
(r351451)
+++ head/sys/dts/arm/overlays/sun8i-h3-sid.dtso Sat Aug 24 13:26:34 2019
(r351452)
@@ -10,5 +10,10 @@
compatible = "allwinner,sun8i-h3-sid";
reg = <0x1c14000 0x400>;
status = "okay";
+
+   /* Data cells */
+   ths_calib: calib@234 {
+   reg = <0x234 0x2>;
+   };
};
 };

Added: head/sys/dts/arm/overlays/sun8i-h3-ths.dtso
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dts/arm/overlays/sun8i-h3-ths.dtso Sat Aug 24 13:26:34 2019
(r351452)
@@ -0,0 +1,27 @@
+/dts-v1/;
+/plugin/;
+
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "allwinner,sun8i-h3";
+};
+
+&{/soc} {
+   ths: thermal_sensor@1c25000 {
+compatible = "allwinner,sun8i-h3-ths";
+reg = <0x01c25000 0x100>;
+interrupts = ;
+clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_THS>;
+clock-names = "apb", "ths";
+resets = <&ccu RST_BUS_THS>;
+reset-names = "apb";
+#thermal-sensor-cells = <0>;
+status = "okay";
+
+nvmem-cells = <&ths_calib>;
+nvmem-cell-names = "ths-calib";
+};
+};

Modified: head/sys/modules/dtb/allwinner/Makefile
==
--- head/sys/modules/dtb/allwinner/Makefile Sat Aug 24 12:51:46 2019
(r351451)
+++ head/sys/modules/dtb/allwinner/Makefile Sat Aug 24 13:26:34 2019
(r351452)
@@ -25,7 +25,8 @@ DTS=  \
 
 DTSO=  sun8i-a83t-sid.dtso \
sun8i-h3-i2c0.dtso \
-   sun8i-h3-sid.dtso
+   sun8i-h3-sid.dtso \
+   sun8i-h3-ths.dtso
 
 LINKS= \
${DTBDIR}/sun4i-a10-cubieboard.dtb ${DTBDIR}/cubieboard.dtb \
___
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: r351453 - head/sys/vm

2019-08-24 Thread Konstantin Belousov
Author: kib
Date: Sat Aug 24 14:29:13 2019
New Revision: 351453
URL: https://svnweb.freebsd.org/changeset/base/351453

Log:
  Make stack grow use the same gap as stack create.
  
  Store stack_guard_page * PAGE_SIZE into the gap->next_read field at
  the time of the stack creation.  This makes the used guard size
  consistent between stack creation and stack grow time.
  
  Suggested by: alc
  Reviewed by:  alc, markj
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D21384

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cSat Aug 24 13:26:34 2019(r351452)
+++ head/sys/vm/vm_map.cSat Aug 24 14:29:13 2019(r351453)
@@ -4189,8 +4189,20 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos,
rv = vm_map_insert(map, NULL, 0, gap_bot, gap_top, VM_PROT_NONE,
VM_PROT_NONE, MAP_CREATE_GUARD | (orient == MAP_STACK_GROWS_DOWN ?
MAP_CREATE_STACK_GAP_DN : MAP_CREATE_STACK_GAP_UP));
-   if (rv != KERN_SUCCESS)
+   if (rv == KERN_SUCCESS) {
+   /*
+* Gap can never successfully handle a fault, so
+* read-ahead logic is never used for it.  Re-use
+* next_read of the gap entry to store
+* stack_guard_page for vm_map_growstack().
+*/
+   if (orient == MAP_STACK_GROWS_DOWN)
+   new_entry->prev->next_read = sgp;
+   else
+   new_entry->next->next_read = sgp;
+   } else {
(void)vm_map_delete(map, bot, top);
+   }
return (rv);
 }
 
@@ -4231,7 +4243,6 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_ma
 
MPASS(!map->system_map);
 
-   guard = stack_guard_page * PAGE_SIZE;
lmemlim = lim_cur(curthread, RLIMIT_MEMLOCK);
stacklim = lim_cur(curthread, RLIMIT_STACK);
vmemlim = lim_cur(curthread, RLIMIT_VMEM);
@@ -4258,6 +4269,7 @@ retry:
} else {
return (KERN_FAILURE);
}
+   guard = gap_entry->next_read;
max_grow = gap_entry->end - gap_entry->start;
if (guard > max_grow)
return (KERN_NO_SPACE);
___
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: r351454 - head/sys/amd64/amd64

2019-08-24 Thread Konstantin Belousov
Author: kib
Date: Sat Aug 24 15:22:18 2019
New Revision: 351454
URL: https://svnweb.freebsd.org/changeset/base/351454

Log:
  Remove unecessary VM_ALLOC_ZERO from allocation of the domain-local
  page for pcpu.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D21320

Modified:
  head/sys/amd64/amd64/mp_machdep.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 14:29:13 2019
(r351453)
+++ head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:22:18 2019
(r351454)
@@ -401,7 +401,7 @@ mp_realloc_pcpu(int cpuid, int domain)
if (_vm_phys_domain(pmap_kextract(oa)) == domain)
return;
m = vm_page_alloc_domain(NULL, 0, domain,
-   VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_ZERO);
+   VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ);
na = PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m));
pagecopy((void *)oa, (void *)na);
pmap_enter(kernel_pmap, oa, m, VM_PROT_READ | VM_PROT_WRITE, 0, 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: r351455 - head/sys/amd64/amd64

2019-08-24 Thread Konstantin Belousov
Author: kib
Date: Sat Aug 24 15:25:53 2019
New Revision: 351455
URL: https://svnweb.freebsd.org/changeset/base/351455

Log:
  Style.

Modified:
  head/sys/amd64/amd64/mp_machdep.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:22:18 2019
(r351454)
+++ head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:25:53 2019
(r351455)
@@ -510,7 +510,7 @@ native_start_all_aps(void)
outb(CMOS_DATA, mpbiosreason);
 
/* number of APs actually started */
-   return mp_naps;
+   return (mp_naps);
 }
 
 
___
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: r351456 - head/sys/amd64/amd64

2019-08-24 Thread Konstantin Belousov
Author: kib
Date: Sat Aug 24 15:28:40 2019
New Revision: 351456
URL: https://svnweb.freebsd.org/changeset/base/351456

Log:
  Do not constrain allocations for doublefault, boot, and mce stacks.
  
  All these stacks are used only once (doublefault, boot) or very rare
  (mce).
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D21320

Modified:
  head/sys/amd64/amd64/mp_machdep.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:25:53 2019
(r351455)
+++ head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:28:40 2019
(r351456)
@@ -475,13 +475,11 @@ native_start_all_aps(void)
domain = acpi_pxm_get_cpu_locality(apic_id);
 #endif
/* allocate and set up an idle stack data page */
-   bootstacks[cpu] = (void *)kmem_malloc_domainset(
-   DOMAINSET_FIXED(domain), kstack_pages * PAGE_SIZE,
+   bootstacks[cpu] = (void *)kmem_malloc(kstack_pages * PAGE_SIZE,
M_WAITOK | M_ZERO);
-   doublefault_stack = (char *)kmem_malloc_domainset(
-   DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
-   mce_stack = (char *)kmem_malloc_domainset(
-   DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
+   doublefault_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK |
+   M_ZERO);
+   mce_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO);
nmi_stack = (char *)kmem_malloc_domainset(
DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
dbg_stack = (char *)kmem_malloc_domainset(
___
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: r351457 - in head/sys/amd64: amd64 include

2019-08-24 Thread Konstantin Belousov
Author: kib
Date: Sat Aug 24 15:31:31 2019
New Revision: 351457
URL: https://svnweb.freebsd.org/changeset/base/351457

Log:
  amd64: rework PCPU allocation
  
  Move pcpu KVA out of .bss into dynamically allocated VA at
  pmap_bootstrap().  This avoids demoting superpage mapping .data/.bss.
  Also it makes possible to use pmap_qenter() for installation of
  domain-local pcpu page on NUMA configs.
  
  Refactor pcpu and IST initialization by moving it to helper functions.
  
  Reviewed by:  markj
  Tested by:pho
  Discussed with:   jeff
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D21320

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/include/counter.h
  head/sys/amd64/include/md_var.h

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Sat Aug 24 15:28:40 2019
(r351456)
+++ head/sys/amd64/amd64/machdep.c  Sat Aug 24 15:31:31 2019
(r351457)
@@ -215,7 +215,8 @@ struct kva_md_info kmi;
 static struct trapframe proc0_tf;
 struct region_descriptor r_gdt, r_idt;
 
-struct pcpu __pcpu[MAXCPU];
+struct pcpu *__pcpu;
+struct pcpu temp_bsp_pcpu;
 
 struct mtx icu_lock;
 
@@ -1543,13 +1544,68 @@ amd64_conf_fast_syscall(void)
wrmsr(MSR_SF_MASK, PSL_NT | PSL_T | PSL_I | PSL_C | PSL_D | PSL_AC);
 }
 
+void
+amd64_bsp_pcpu_init1(struct pcpu *pc)
+{
+
+   PCPU_SET(prvspace, pc);
+   PCPU_SET(curthread, &thread0);
+   PCPU_SET(tssp, &common_tss[0]);
+   PCPU_SET(commontssp, &common_tss[0]);
+   PCPU_SET(tss, (struct system_segment_descriptor *)&gdt[GPROC0_SEL]);
+   PCPU_SET(ldt, (struct system_segment_descriptor *)&gdt[GUSERLDT_SEL]);
+   PCPU_SET(fs32p, &gdt[GUFS32_SEL]);
+   PCPU_SET(gs32p, &gdt[GUGS32_SEL]);
+}
+
+void
+amd64_bsp_pcpu_init2(uint64_t rsp0)
+{
+
+   PCPU_SET(rsp0, rsp0);
+   PCPU_SET(pti_rsp0, ((vm_offset_t)PCPU_PTR(pti_stack) +
+   PC_PTI_STACK_SZ * sizeof(uint64_t)) & ~0xful);
+   PCPU_SET(curpcb, thread0.td_pcb);
+}
+
+void
+amd64_bsp_ist_init(struct pcpu *pc)
+{
+   struct nmi_pcpu *np;
+
+   /* doublefault stack space, runs on ist1 */
+   common_tss[0].tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)];
+
+   /*
+* NMI stack, runs on ist2.  The pcpu pointer is stored just
+* above the start of the ist2 stack.
+*/
+   np = ((struct nmi_pcpu *)&nmi0_stack[sizeof(nmi0_stack)]) - 1;
+   np->np_pcpu = (register_t)pc;
+   common_tss[0].tss_ist2 = (long)np;
+
+   /*
+* MC# stack, runs on ist3.  The pcpu pointer is stored just
+* above the start of the ist3 stack.
+*/
+   np = ((struct nmi_pcpu *)&mce0_stack[sizeof(mce0_stack)]) - 1;
+   np->np_pcpu = (register_t)pc;
+   common_tss[0].tss_ist3 = (long)np;
+
+   /*
+* DB# stack, runs on ist4.
+*/
+   np = ((struct nmi_pcpu *)&dbg0_stack[sizeof(dbg0_stack)]) - 1;
+   np->np_pcpu = (register_t)pc;
+   common_tss[0].tss_ist4 = (long)np;
+}
+
 u_int64_t
 hammer_time(u_int64_t modulep, u_int64_t physfree)
 {
caddr_t kmdp;
int gsel_tss, x;
struct pcpu *pc;
-   struct nmi_pcpu *np;
struct xstate_hdr *xhdr;
u_int64_t rsp0;
char *env;
@@ -1623,7 +1679,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
r_gdt.rd_base =  (long) gdt;
lgdt(&r_gdt);
-   pc = &__pcpu[0];
+   pc = &temp_bsp_pcpu;
 
wrmsr(MSR_FSBASE, 0);   /* User value */
wrmsr(MSR_GSBASE, (u_int64_t)pc);
@@ -1632,15 +1688,8 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
pcpu_init(pc, 0, sizeof(struct pcpu));
dpcpu_init((void *)(physfree + KERNBASE), 0);
physfree += DPCPU_SIZE;
-   PCPU_SET(prvspace, pc);
-   PCPU_SET(curthread, &thread0);
+   amd64_bsp_pcpu_init1(pc);
/* Non-late cninit() and printf() can be moved up to here. */
-   PCPU_SET(tssp, &common_tss[0]);
-   PCPU_SET(commontssp, &common_tss[0]);
-   PCPU_SET(tss, (struct system_segment_descriptor *)&gdt[GPROC0_SEL]);
-   PCPU_SET(ldt, (struct system_segment_descriptor *)&gdt[GUSERLDT_SEL]);
-   PCPU_SET(fs32p, &gdt[GUFS32_SEL]);
-   PCPU_SET(gs32p, &gdt[GUGS32_SEL]);
 
/*
 * Initialize mutexes.
@@ -1729,31 +1778,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
finishidentcpu();   /* Final stage of CPU initialization */
initializecpu();/* Initialize CPU registers */
 
-   /* doublefault stack space, runs on ist1 */
-   common_tss[0].tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)];
-
-   /*
-* NMI stack, runs on ist2.  The pcpu pointer is stored just
-* above the start of the ist2 sta

svn commit: r351458 - head/share/man/man4

2019-08-24 Thread Konstantin Belousov
Author: kib
Date: Sat Aug 24 15:38:07 2019
New Revision: 351458
URL: https://svnweb.freebsd.org/changeset/base/351458

Log:
  Add nvdimm(4) man page.
  
  Reviewed by:  emaste
  Discussed with:   scottl, scottph
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days
  Differential revision:https://reviews.freebsd.org/D21386

Added:
  head/share/man/man4/nvdimm.4   (contents, props changed)
Modified:
  head/share/man/man4/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileSat Aug 24 15:31:31 2019
(r351457)
+++ head/share/man/man4/MakefileSat Aug 24 15:38:07 2019
(r351458)
@@ -379,6 +379,7 @@ MAN=aac.4 \
null.4 \
numa.4 \
${_nvd.4} \
+   ${_nvdimm.4} \
${_nvme.4} \
${_nvram.4} \
${_nvram2env.4} \
@@ -825,6 +826,7 @@ _xnb.4= xnb.4
 
 .if ${MACHINE_CPUARCH} == "amd64"
 _ioat.4=   ioat.4
+_nvdimm.4= nvdimm.4
 _qlxge.4=  qlxge.4
 _qlxgb.4=  qlxgb.4
 _qlxgbe.4= qlxgbe.4

Added: head/share/man/man4/nvdimm.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/nvdimm.4Sat Aug 24 15:38:07 2019
(r351458)
@@ -0,0 +1,122 @@
+.\" Copyright (c) 2019 The FreeBSD Foundation, Inc.
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov  under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd August 23, 2019
+.Dt NVDIMM 4
+.Os
+.Sh NAME
+.Nm nvdimm
+.Nd ACPI NVDIMM driver
+.Sh SYNOPSIS
+To load the driver as a module at boot, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+nvdimm_load="YES"
+.Ed
+.Sh DESCRIPTION
+.Bf -symbolic
+Note:
+The
+.Nm
+driver is under development and has some important limitations
+described below.
+.Ef
+.Pp
+The
+.Nm
+driver provides access to Non-Volatile DIMM (NVDIMM) persistent memory
+devices, which are ACPI-enumerated under the root NVDIMM device
+with a
+.Va _HID
+of
+.Dv ACPI0012
+and in the
+.Dv NFIT
+table.
+.Pp
+For each System Physical Address (SPA) Range described by NFIT, a
+device node
+.Pa /dev/nvdimm_spaNNN
+is created, where
+.Dv NNN
+is the SPA position in the table.
+The node can be used to
+.Xr read 2 ,
+.Xr write 2 ,
+or
+.Xr mmap 2
+the device.
+.Pp
+Also, for each SPA, the geom provider
+.Pa spaNNN
+is created, which can be used to create a conventional filesystem (e.g.
+by
+.Xr newfs 8 )
+and
+.Xr mount 8
+it as any storage volume.
+Content accessible by
+.Pa /dev/nvdimm_spaNNN
+and
+.Pa /dev/spaNNN
+is coherent.
+.Sh SEE ALSO
+.Xr ACPI 4 ,
+.Xr GEOM 4 ,
+.Xr geom 8 ,
+.Xr mount 8 ,
+.Xr newfs 8 ,
+.Xr disk 9
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Fx 12.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was originally written by
+.An Konstantin Belousov Aq Mt k...@freebsd.org ,
+and then updated by
+.An D. Scott Phillips Aq Mt scot...@freebsd.org .
+.Sh BUGS
+The
+.Nm
+driver does not utilize the Block Window interface, so if the write to
+NVDIMM was interrupted due to a system crash or power outage,
+the corresponding page might be left in partially updated state.
+.Pp
+There is no support for Device-Specific Methods (DSM), used to report and
+control the device health and wearing.
+.Pp
+The driver depends on the
+.Xr pmap_largemap 9
+pmap interface, which is currently only implemented on amd64.
+The interface can be only reasonable implemented on 64bit architectures.
___

Re: svn commit: r351456 - head/sys/amd64/amd64

2019-08-24 Thread Conrad Meyer
Hi Konstantin,

What is the motivation for this change?  The commit message doesn't
really describe why it was done.

Thanks,
Conrad

On Sat, Aug 24, 2019 at 8:28 AM Konstantin Belousov  wrote:
>
> Author: kib
> Date: Sat Aug 24 15:28:40 2019
> New Revision: 351456
> URL: https://svnweb.freebsd.org/changeset/base/351456
>
> Log:
>   Do not constrain allocations for doublefault, boot, and mce stacks.
>
>   All these stacks are used only once (doublefault, boot) or very rare
>   (mce).
>
>   Reviewed by:  markj
>   Tested by:pho
>   Sponsored by: The FreeBSD Foundation
>   Differential revision:https://reviews.freebsd.org/D21320
>
> Modified:
>   head/sys/amd64/amd64/mp_machdep.c
>
> Modified: head/sys/amd64/amd64/mp_machdep.c
> ==
> --- head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:25:53 2019
> (r351455)
> +++ head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:28:40 2019
> (r351456)
> @@ -475,13 +475,11 @@ native_start_all_aps(void)
> domain = acpi_pxm_get_cpu_locality(apic_id);
>  #endif
> /* allocate and set up an idle stack data page */
> -   bootstacks[cpu] = (void *)kmem_malloc_domainset(
> -   DOMAINSET_FIXED(domain), kstack_pages * PAGE_SIZE,
> +   bootstacks[cpu] = (void *)kmem_malloc(kstack_pages * 
> PAGE_SIZE,
> M_WAITOK | M_ZERO);
> -   doublefault_stack = (char *)kmem_malloc_domainset(
> -   DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
> -   mce_stack = (char *)kmem_malloc_domainset(
> -   DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
> +   doublefault_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK |
> +   M_ZERO);
> +   mce_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO);
> nmi_stack = (char *)kmem_malloc_domainset(
> DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
> dbg_stack = (char *)kmem_malloc_domainset(
>
___
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: r351459 - head/usr.bin/last

2019-08-24 Thread Eugene Grosbein
Author: eugen
Date: Sat Aug 24 15:50:13 2019
New Revision: 351459
URL: https://svnweb.freebsd.org/changeset/base/351459

Log:
  last(1): correction after r351413
  
  Make that change no-op for C/POSIX locale just like for UTF-8
  that it superset of US-ASCII.
  
  MFC after:2 weeks
  X-MFC-With:   r351413

Modified:
  head/usr.bin/last/last.c

Modified: head/usr.bin/last/last.c
==
--- head/usr.bin/last/last.cSat Aug 24 15:38:07 2019(r351458)
+++ head/usr.bin/last/last.cSat Aug 24 15:50:13 2019(r351459)
@@ -92,8 +92,8 @@ static const  char *crmsg;/* cause of 
last reboot */
 static time_t  currentout; /* current logout value */
 static longmaxrec; /* records to display */
 static const   char *file = NULL;  /* utx.log file */
+static int noctfix = 0;/* locale is C or UTF-8 */
 static int sflag = 0;  /* show delta in seconds */
-static int utf8flag;   /* current locale is UTF-8 */
 static int width = 5;  /* show seconds in delta */
 static int yflag;  /* show year */
 static int  d_first;
@@ -120,7 +120,7 @@ ctf(const char *fmt) {
const char  *src, *end;
char*dst;
 
-   if (utf8flag)
+   if (noctfix)
return (fmt);
 
end = buf + sizeof(buf);
@@ -158,7 +158,9 @@ main(int argc, char *argv[])
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
 
(void) setlocale(LC_CTYPE, "");
-   utf8flag = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0);
+   p = nl_langinfo(CODESET);
+   if (strcmp (p, "UTF-8") == 0 || strcmp (p, "US-ASCII") == 0)
+   noctfix = 1;
 
argc = xo_parse_args(argc, argv);
if (argc < 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"


Re: svn commit: r351456 - head/sys/amd64/amd64

2019-08-24 Thread Konstantin Belousov
On Sat, Aug 24, 2019 at 08:49:42AM -0700, Conrad Meyer wrote:
> Hi Konstantin,
> 
> What is the motivation for this change?  The commit message doesn't
> really describe why it was done.
Really it does. There is no point to request allocations for e.g.
doublefault stack to be at the local domain, because this stack is only
used once.  Doublefault is definitely a machine halt situation, it does
not matter if it generates inter-socket traffic to handle.

Same for boot stacks, and for mce.

The change avoids unnecessary constraints.

> 
> Thanks,
> Conrad
> 
> On Sat, Aug 24, 2019 at 8:28 AM Konstantin Belousov  wrote:
> >
> > Author: kib
> > Date: Sat Aug 24 15:28:40 2019
> > New Revision: 351456
> > URL: https://svnweb.freebsd.org/changeset/base/351456
> >
> > Log:
> >   Do not constrain allocations for doublefault, boot, and mce stacks.
> >
> >   All these stacks are used only once (doublefault, boot) or very rare
> >   (mce).
> >
> >   Reviewed by:  markj
> >   Tested by:pho
> >   Sponsored by: The FreeBSD Foundation
> >   Differential revision:https://reviews.freebsd.org/D21320
> >
> > Modified:
> >   head/sys/amd64/amd64/mp_machdep.c
> >
> > Modified: head/sys/amd64/amd64/mp_machdep.c
> > ==
> > --- head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:25:53 2019
> > (r351455)
> > +++ head/sys/amd64/amd64/mp_machdep.c   Sat Aug 24 15:28:40 2019
> > (r351456)
> > @@ -475,13 +475,11 @@ native_start_all_aps(void)
> > domain = acpi_pxm_get_cpu_locality(apic_id);
> >  #endif
> > /* allocate and set up an idle stack data page */
> > -   bootstacks[cpu] = (void *)kmem_malloc_domainset(
> > -   DOMAINSET_FIXED(domain), kstack_pages * PAGE_SIZE,
> > +   bootstacks[cpu] = (void *)kmem_malloc(kstack_pages * 
> > PAGE_SIZE,
> > M_WAITOK | M_ZERO);
> > -   doublefault_stack = (char *)kmem_malloc_domainset(
> > -   DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
> > -   mce_stack = (char *)kmem_malloc_domainset(
> > -   DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
> > +   doublefault_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK 
> > |
> > +   M_ZERO);
> > +   mce_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | 
> > M_ZERO);
> > nmi_stack = (char *)kmem_malloc_domainset(
> > DOMAINSET_FIXED(domain), PAGE_SIZE, M_WAITOK | M_ZERO);
> > dbg_stack = (char *)kmem_malloc_domainset(
> >
___
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: r351461 - head/sbin/ping

2019-08-24 Thread Alan Somers
Author: asomers
Date: Sat Aug 24 18:00:18 2019
New Revision: 351461
URL: https://svnweb.freebsd.org/changeset/base/351461

Log:
  ping: fix unaligned access to ancillary data
  
  Use CMSG_FIRSTHDR rather than assume that an array is correctly aligned.
  Fixes warnings on sparc64 and powerpcspe.
  
  Submitted by: Ján Sučan 
  MFH:  2 weeks
  Sponsored by: Google LLC (Google Summer of Code 2019)
  Differential Revision:https://reviews.freebsd.org/D21406

Modified:
  head/sbin/ping/ping.c

Modified: head/sbin/ping/ping.c
==
--- head/sbin/ping/ping.c   Sat Aug 24 16:44:47 2019(r351460)
+++ head/sbin/ping/ping.c   Sat Aug 24 18:00:18 2019(r351461)
@@ -875,6 +875,7 @@ main(int argc, char *const *argv)
msg.msg_iovlen = 1;
 #ifdef SO_TIMESTAMP
msg.msg_control = (caddr_t)ctrl;
+   msg.msg_controllen = sizeof(ctrl);
 #endif
iov.iov_base = packet;
iov.iov_len = IP_MAXPACKET;
@@ -920,9 +921,7 @@ main(int argc, char *const *argv)
if (n == 1) {
struct timespec *tv = NULL;
 #ifdef SO_TIMESTAMP
-   struct cmsghdr *cmsg = (struct cmsghdr *)&ctrl;
-
-   msg.msg_controllen = sizeof(ctrl);
+   struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
 #endif
msg.msg_namelen = sizeof(from);
if ((cc = recvmsg(srecv, &msg, 0)) < 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"


Re: svn commit: r351456 - head/sys/amd64/amd64

2019-08-24 Thread Conrad Meyer
On Sat, Aug 24, 2019 at 9:15 AM Konstantin Belousov  wrote:
>
> On Sat, Aug 24, 2019 at 08:49:42AM -0700, Conrad Meyer wrote:
> > Hi Konstantin,
> >
> > What is the motivation for this change?  The commit message doesn't
> > really describe why it was done.
>
> Really it does. There is no point to request allocations for e.g.
> doublefault stack to be at the local domain, because this stack is only
> used once.  Doublefault is definitely a machine halt situation, it does
> not matter if it generates inter-socket traffic to handle.
>
> Same for boot stacks, and for mce.
>
> The change avoids unnecessary constraints.

Sure, but what is the harm of the unnecessary constraints?  Does this
change fix an actual bug, or is it just a stylistic preference to
avoid domain-specific allocations for infrequently used objects?

Thanks,
Conrad
___
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: r351459 - head/usr.bin/last

2019-08-24 Thread Conrad Meyer
Hi Eugene,

This change introduced some style(9) violations.

On Sat, Aug 24, 2019 at 8:50 AM Eugene Grosbein  wrote:
>
> Author: eugen
> Date: Sat Aug 24 15:50:13 2019
> New Revision: 351459
> URL: https://svnweb.freebsd.org/changeset/base/351459
> ...
> --- head/usr.bin/last/last.cSat Aug 24 15:38:07 2019(r351458)
> +++ head/usr.bin/last/last.cSat Aug 24 15:50:13 2019(r351459)
> ...
> @@ -158,7 +158,9 @@ main(int argc, char *argv[])
> d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
>
> (void) setlocale(LC_CTYPE, "");
> -   utf8flag = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0);
> +   p = nl_langinfo(CODESET);
> +   if (strcmp (p, "UTF-8") == 0 || strcmp (p, "US-ASCII") == 0)
> +   noctfix = 1;

There are extraneous spaces between strcmp and '('.

Best,
Conrad
___
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: r351364 - in head/sys: crypto/blowfish crypto/chacha20 crypto/des opencrypto

2019-08-24 Thread Mark Millard via svn-src-head
Warner Losh imp at bsdimp.com wrote on
Fri Aug 23 22:05:39 UTC 2019 :

> On Fri, Aug 23, 2019 at 12:26 PM Conrad Meyer  wrote:
> 
> > At expected peril of wading into a thread >4 emails deep,
> >
> > @Warner, modern GCC reports a similar warning; it just doesn't become
> > an error (at least in CI?).  I'm not sure of the mechanism.  Maybe
> > CI-specific?  Old GCC didn't have a -Wno-error for -Wcast-qual, so
> > -Wcast-qual + -Werror there produced an error; that's why
> > $NO_WCAST_QUAL in conf/kern.mk is defined to -Wno-cast-qual for old
> > GCC but -Wno-error=cast-qual for newer compilers.  That said, this
> > file does not appear to be compiled with ${NO_WCAST_QUAL} either way.
> >
> 
> Yea. I'm unsure. It's an odd warning, and an odd way to get around it. In
> general, nobody cares about gcc 4.2.1, so pinning implementing that belief
> to this specific bug may have been unwise. I just assumed newer versions
> wouldn't warn on this, but I saw on IRC that the types are stupidly
> different...
. . .

While I know how to build for powerpc64 ( using WITHOUT_LIB32= )
without using gcc4.2.1 or the matching binutils, 32-bit powerpc
is not so clear for how to target without gcc 4.2.1, at least
based on what I'm familiar with. (I normally work with materials
from the official FreeBSD svn, not other development material
sources.)

(Locally reverting the secure-plt change would help for
amd64->powerpc cross builds based on system-clang and
devel/powerpc64-binutils or base/binutils . Even lld from
devel/llvm90 is not ready for 32-bit powerpc as yet, from what
I've seen, so llvm90 is not yet a self-contained solution.)

May be someone else does know a good way to build FreeBSD for
tracking head for targeting 32-bit powerpc as things are now?
May I the only one not knowing how to build for this target
as things are?

I'd been trying to avoid disabling the secure-plt change
that causes gnu's modern ld's to revert to bss-plt and return
an error code that stops the build when system-clang or
llvm90 is used. (The old FreeBSD ld does not return the error
code but does report reverting to bss-plt. But it fails for
buildkernel via a separate issue when system-clang is used.)

As stands I'm not aware of how to target 32-bit power pc
from some more modern gcc/binutils combination.

As stands it looks like reverting secure-plt's use is the
direction I'd have to go to avoid gcc 4.2.1 .

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

___
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: r351458 - head/share/man/man4

2019-08-24 Thread Scott Long
Thank you!

Scott

> On Aug 24, 2019, at 9:38 AM, Konstantin Belousov  wrote:
> 
> Author: kib
> Date: Sat Aug 24 15:38:07 2019
> New Revision: 351458
> URL: https://svnweb.freebsd.org/changeset/base/351458
> 
> Log:
>  Add nvdimm(4) man page.
> 
>  Reviewed by: emaste
>  Discussed with:  scottl, scottph
>  Sponsored by:The FreeBSD Foundation
>  MFC after:   3 days
>  Differential revision:   https://reviews.freebsd.org/D21386
> 
> Added:
>  head/share/man/man4/nvdimm.4   (contents, props changed)
> Modified:
>  head/share/man/man4/Makefile
> 
> Modified: head/share/man/man4/Makefile
> ==
> --- head/share/man/man4/Makefile  Sat Aug 24 15:31:31 2019
> (r351457)
> +++ head/share/man/man4/Makefile  Sat Aug 24 15:38:07 2019
> (r351458)
> @@ -379,6 +379,7 @@ MAN=  aac.4 \
>   null.4 \
>   numa.4 \
>   ${_nvd.4} \
> + ${_nvdimm.4} \
>   ${_nvme.4} \
>   ${_nvram.4} \
>   ${_nvram2env.4} \
> @@ -825,6 +826,7 @@ _xnb.4=   xnb.4
> 
> .if ${MACHINE_CPUARCH} == "amd64"
> _ioat.4=  ioat.4
> +_nvdimm.4=   nvdimm.4
> _qlxge.4= qlxge.4
> _qlxgb.4= qlxgb.4
> _qlxgbe.4=qlxgbe.4
> 
> Added: head/share/man/man4/nvdimm.4
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ head/share/man/man4/nvdimm.4  Sat Aug 24 15:38:07 2019
> (r351458)
> @@ -0,0 +1,122 @@
> +.\" Copyright (c) 2019 The FreeBSD Foundation, Inc.
> +.\"
> +.\" This documentation was written by
> +.\" Konstantin Belousov  under sponsorship
> +.\" from the FreeBSD Foundation.
> +.\"
> +.\" Redistribution and use in source and binary forms, with or without
> +.\" modification, are permitted provided that the following conditions
> +.\" are met:
> +.\" 1. Redistributions of source code must retain the above copyright
> +.\"notice, this list of conditions and the following disclaimer.
> +.\" 2. Redistributions in binary form must reproduce the above copyright
> +.\"notice, this list of conditions and the following disclaimer in the
> +.\"documentation and/or other materials provided with the distribution.
> +.\"
> +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
> +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> +.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
> +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> CONSEQUENTIAL
> +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
> STRICT
> +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> +.\" SUCH DAMAGE.
> +.\"
> +.\" $FreeBSD$
> +.\"
> +.Dd August 23, 2019
> +.Dt NVDIMM 4
> +.Os
> +.Sh NAME
> +.Nm nvdimm
> +.Nd ACPI NVDIMM driver
> +.Sh SYNOPSIS
> +To load the driver as a module at boot, place the following line in
> +.Xr loader.conf 5 :
> +.Bd -literal -offset indent
> +nvdimm_load="YES"
> +.Ed
> +.Sh DESCRIPTION
> +.Bf -symbolic
> +Note:
> +The
> +.Nm
> +driver is under development and has some important limitations
> +described below.
> +.Ef
> +.Pp
> +The
> +.Nm
> +driver provides access to Non-Volatile DIMM (NVDIMM) persistent memory
> +devices, which are ACPI-enumerated under the root NVDIMM device
> +with a
> +.Va _HID
> +of
> +.Dv ACPI0012
> +and in the
> +.Dv NFIT
> +table.
> +.Pp
> +For each System Physical Address (SPA) Range described by NFIT, a
> +device node
> +.Pa /dev/nvdimm_spaNNN
> +is created, where
> +.Dv NNN
> +is the SPA position in the table.
> +The node can be used to
> +.Xr read 2 ,
> +.Xr write 2 ,
> +or
> +.Xr mmap 2
> +the device.
> +.Pp
> +Also, for each SPA, the geom provider
> +.Pa spaNNN
> +is created, which can be used to create a conventional filesystem (e.g.
> +by
> +.Xr newfs 8 )
> +and
> +.Xr mount 8
> +it as any storage volume.
> +Content accessible by
> +.Pa /dev/nvdimm_spaNNN
> +and
> +.Pa /dev/spaNNN
> +is coherent.
> +.Sh SEE ALSO
> +.Xr ACPI 4 ,
> +.Xr GEOM 4 ,
> +.Xr geom 8 ,
> +.Xr mount 8 ,
> +.Xr newfs 8 ,
> +.Xr disk 9
> +.Sh HISTORY
> +The
> +.Nm
> +driver first appeared in
> +.Fx 12.0 .
> +.Sh AUTHORS
> +.An -nosplit
> +The
> +.Nm
> +driver was originally written by
> +.An Konstantin Belousov Aq Mt k...@freebsd.org ,
> +and then updated by
> +.An D. Scott Phillips Aq Mt scot...@freebsd.org .
> +.Sh BUGS
> +The
> +.Nm
> +driver does not utilize the Block Window interface, so if the write to
> +NVDIMM was interrupted due to a system crash or power outage,
> +the corresponding page might be left in partially

Re: svn commit: r351456 - head/sys/amd64/amd64

2019-08-24 Thread Konstantin Belousov
On Sat, Aug 24, 2019 at 11:47:52AM -0700, Conrad Meyer wrote:
> On Sat, Aug 24, 2019 at 9:15 AM Konstantin Belousov  
> wrote:
> >
> > On Sat, Aug 24, 2019 at 08:49:42AM -0700, Conrad Meyer wrote:
> > > Hi Konstantin,
> > >
> > > What is the motivation for this change?  The commit message doesn't
> > > really describe why it was done.
> >
> > Really it does. There is no point to request allocations for e.g.
> > doublefault stack to be at the local domain, because this stack is only
> > used once.  Doublefault is definitely a machine halt situation, it does
> > not matter if it generates inter-socket traffic to handle.
> >
> > Same for boot stacks, and for mce.
> >
> > The change avoids unnecessary constraints.
> 
> Sure, but what is the harm of the unnecessary constraints?  Does this
> change fix an actual bug, or is it just a stylistic preference to
> avoid domain-specific allocations for infrequently used objects?
I am not sure about this being a stylistic preference.  We usually
write code to express the required actions.  I removed constraints
which did not added anything neither to code correctness nor to the
performance.
___
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: r351467 - head/usr.bin/last

2019-08-24 Thread Eugene Grosbein
Author: eugen
Date: Sun Aug 25 01:05:01 2019
New Revision: 351467
URL: https://svnweb.freebsd.org/changeset/base/351467

Log:
  last(1): fix style after r351459
  
  Reported by:  cem
  MFC after:2 weeks
  X-MFC-With:   351459

Modified:
  head/usr.bin/last/last.c

Modified: head/usr.bin/last/last.c
==
--- head/usr.bin/last/last.cSun Aug 25 00:57:51 2019(r351466)
+++ head/usr.bin/last/last.cSun Aug 25 01:05:01 2019(r351467)
@@ -159,7 +159,7 @@ main(int argc, char *argv[])
 
(void) setlocale(LC_CTYPE, "");
p = nl_langinfo(CODESET);
-   if (strcmp (p, "UTF-8") == 0 || strcmp (p, "US-ASCII") == 0)
+   if (strcmp(p, "UTF-8") == 0 || strcmp(p, "US-ASCII") == 0)
noctfix = 1;
 
argc = xo_parse_args(argc, argv);
___
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: r351469 - head/tests/sys/posixshm

2019-08-24 Thread Kyle Evans
Author: kevans
Date: Sun Aug 25 02:38:45 2019
New Revision: 351469
URL: https://svnweb.freebsd.org/changeset/base/351469

Log:
  tests: shm_open(2): Verify FD_CLOEXEC
  
  Motivated by the fact that I'm messing around near the implementation and
  wanting to ensure this doesn't get messed up in the process.
  
  MFC after:1 week

Modified:
  head/tests/sys/posixshm/posixshm_test.c

Modified: head/tests/sys/posixshm/posixshm_test.c
==
--- head/tests/sys/posixshm/posixshm_test.c Sun Aug 25 01:09:31 2019
(r351468)
+++ head/tests/sys/posixshm/posixshm_test.c Sun Aug 25 02:38:45 2019
(r351469)
@@ -609,6 +609,27 @@ ATF_TC_BODY(shm_functionality_across_fork, tc)
shm_unlink(test_path);
 }
 
+ATF_TC_WITHOUT_HEAD(cloexec);
+ATF_TC_BODY(cloexec, tc)
+{
+   int fd;
+
+   gen_test_path();
+
+   /* shm_open(2) is required to set FD_CLOEXEC */
+   fd = shm_open(SHM_ANON, O_RDWR, 0777);
+   ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno);
+   ATF_REQUIRE((fcntl(fd, F_GETFD) & FD_CLOEXEC) != 0);
+   close(fd);
+
+   /* Also make sure that named shm is correct */
+   fd = shm_open(test_path, O_CREAT | O_RDWR, 0600);
+   ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno);
+   ATF_REQUIRE((fcntl(fd, F_GETFD) & FD_CLOEXEC) != 0);
+   close(fd);
+}
+
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -630,6 +651,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, unlink_bad_path_pointer);
ATF_TP_ADD_TC(tp, unlink_path_too_long);
ATF_TP_ADD_TC(tp, object_resize);
+   ATF_TP_ADD_TC(tp, cloexec);
 
return (atf_no_error());
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r351471 - in head/sys: kern sys

2019-08-24 Thread Mateusz Guzik
Author: mjg
Date: Sun Aug 25 05:11:43 2019
New Revision: 351471
URL: https://svnweb.freebsd.org/changeset/base/351471

Log:
  vfs: add vholdnz (for already held vnodes)
  
  Reviewed by:  kib (previous version)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21358

Modified:
  head/sys/kern/vfs_subr.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSun Aug 25 04:56:33 2019(r351470)
+++ head/sys/kern/vfs_subr.cSun Aug 25 05:11:43 2019(r351471)
@@ -3018,6 +3018,19 @@ _vhold(struct vnode *vp, bool locked)
VI_UNLOCK(vp);
 }
 
+void
+vholdnz(struct vnode *vp)
+{
+
+   CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
+#ifdef INVARIANTS
+   int old = atomic_fetchadd_int(&vp->v_holdcnt, 1);
+   VNASSERT(old > 0, vp, ("%s: wrong hold count", __func__));
+#else
+   atomic_add_int(&vp->v_holdcnt, 1);
+#endif
+}
+
 /*
  * Drop the hold count of the vnode.  If this is the last reference to
  * the vnode we place it on the free list unless it has been vgone'd

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hSun Aug 25 04:56:33 2019(r351470)
+++ head/sys/sys/vnode.hSun Aug 25 05:11:43 2019(r351471)
@@ -657,6 +657,7 @@ voidvgone(struct vnode *vp);
 #definevhold(vp)   _vhold((vp), 0)
 #definevholdl(vp)  _vhold((vp), 1)
 void   _vhold(struct vnode *, bool);
+void   vholdnz(struct vnode *);
 void   vinactive(struct vnode *, struct thread *);
 intvinvalbuf(struct vnode *vp, int save, int slpflag, int slptimeo);
 intvtruncbuf(struct vnode *vp, off_t length, int blksize);
___
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: r351472 - head/sys/fs/nullfs

2019-08-24 Thread Mateusz Guzik
Author: mjg
Date: Sun Aug 25 05:13:15 2019
New Revision: 351472
URL: https://svnweb.freebsd.org/changeset/base/351472

Log:
  nullfs: reduce areas protected by vnode interlock
  
  Some places only take the interlock to hold the vnode, which was a requiremnt
  before they started being manipulated with atomics. Use the newly introduced
  vholdnz to bump the count.
  
  Reviewed by:  kib
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21358

Modified:
  head/sys/fs/nullfs/null_vnops.c

Modified: head/sys/fs/nullfs/null_vnops.c
==
--- head/sys/fs/nullfs/null_vnops.c Sun Aug 25 05:11:43 2019
(r351471)
+++ head/sys/fs/nullfs/null_vnops.c Sun Aug 25 05:13:15 2019
(r351472)
@@ -668,7 +668,7 @@ null_lock(struct vop_lock1_args *ap)
 * We prevent it from being recycled by holding the vnode
 * here.
 */
-   vholdl(lvp);
+   vholdnz(lvp);
error = VOP_LOCK(lvp, flags);
 
/*
@@ -710,31 +710,16 @@ static int
 null_unlock(struct vop_unlock_args *ap)
 {
struct vnode *vp = ap->a_vp;
-   int flags = ap->a_flags;
-   int mtxlkflag = 0;
struct null_node *nn;
struct vnode *lvp;
int error;
 
-   if ((flags & LK_INTERLOCK) != 0)
-   mtxlkflag = 1;
-   else if (mtx_owned(VI_MTX(vp)) == 0) {
-   VI_LOCK(vp);
-   mtxlkflag = 2;
-   }
nn = VTONULL(vp);
if (nn != NULL && (lvp = NULLVPTOLOWERVP(vp)) != NULL) {
-   VI_LOCK_FLAGS(lvp, MTX_DUPOK);
-   flags |= LK_INTERLOCK;
-   vholdl(lvp);
-   VI_UNLOCK(vp);
-   error = VOP_UNLOCK(lvp, flags);
+   vholdnz(lvp);
+   error = VOP_UNLOCK(lvp, 0);
vdrop(lvp);
-   if (mtxlkflag == 0)
-   VI_LOCK(vp);
} else {
-   if (mtxlkflag == 2)
-   VI_UNLOCK(vp);
error = vop_stdunlock(ap);
}
 
@@ -845,10 +830,8 @@ null_getwritemount(struct vop_getwritemount_args *ap)
VI_LOCK(vp);
xp = VTONULL(vp);
if (xp && (lowervp = xp->null_lowervp)) {
-   VI_LOCK_FLAGS(lowervp, MTX_DUPOK);
+   vholdnz(lowervp);
VI_UNLOCK(vp);
-   vholdl(lowervp);
-   VI_UNLOCK(lowervp);
VOP_GETWRITEMOUNT(lowervp, ap->a_mpp);
vdrop(lowervp);
} else {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"