svn commit: r340393 - head/sys/powerpc/conf

2018-11-13 Thread Kevin Bowling
Author: kbowling (ports committer)
Date: Tue Nov 13 09:19:07 2018
New Revision: 340393
URL: https://svnweb.freebsd.org/changeset/base/340393

Log:
  powerpc64: reduce GENERIC64 diff versus amd64 GENERIC
  
  Reviewed by:  jhibbits
  Approved by:  timur (mentor)
  Differential Revision:https://reviews.freebsd.org/D17515

Modified:
  head/sys/powerpc/conf/GENERIC64

Modified: head/sys/powerpc/conf/GENERIC64
==
--- head/sys/powerpc/conf/GENERIC64 Tue Nov 13 04:34:30 2018
(r340392)
+++ head/sys/powerpc/conf/GENERIC64 Tue Nov 13 09:19:07 2018
(r340393)
@@ -39,6 +39,10 @@ options  PREEMPTION  #Enable kernel thread 
preemption
 optionsVIMAGE  # Subsystem virtualization, e.g. VNET
 optionsINET#InterNETworking
 optionsINET6   #IPv6 communications protocols
+optionsIPSEC   # IP (v4/v6) security
+optionsIPSEC_SUPPORT   # Allow kldload of ipsec and tcpmd5
+optionsTCP_OFFLOAD # TCP offload
+optionsTCP_BLACKBOX# Enhanced TCP event logging
 optionsTCP_HHOOK   # hhook(9) framework for TCP
 optionsTCP_RFC7413 # TCP Fast Open
 optionsSCTP#Stream Control Transmission Protocol
@@ -83,6 +87,9 @@ options   MAC # TrustedBSD MAC 
Framework
 optionsKDTRACE_HOOKS   # Kernel DTrace hooks
 optionsDDB_CTF # Kernel ELF linker loads CTF data
 optionsINCLUDE_CONFIG_FILE # Include this file in kernel
+optionsRACCT   # Resource accounting framework
+optionsRACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
+optionsRCTL# Resource limits
 
 # Debugging support.  Always need this:
 optionsKDB # Enable kernel debugger support.
@@ -136,10 +143,12 @@ devicesym # NCR/Symbios/LSI Logic 
53C8XX/53C1010/53
 
 # ATA/SCSI peripherals
 device scbus   # SCSI bus (required for ATA/SCSI)
+device ch  # SCSI media changers
 device da  # Direct Access (disks)
 device sa  # Sequential Access (tape etc)
 device cd  # CD
 device pass# Passthrough device (direct ATA/SCSI access)
+device ses # Enclosure Service (SES and SAF-TE)
 
 # vt is the default console driver, resembling an SCO console
 device vt  # Core console driver
@@ -168,6 +177,7 @@ device  re  # RealTek 
8139C+/8169/8169S/8110S
 device rl  # RealTek 8129/8139
 
 # Pseudo devices.
+device crypto  # core crypto support
 device loop# Network loopback
 device random  # Entropy device
 device ether   # Ethernet support
@@ -193,10 +203,8 @@ device usb # USB Bus (required)
 device uhid# "Human Interface Devices"
 device ukbd# Keyboard
 optionsKBD_INSTALL_CDEV # install a CDEV entry in /dev
-device ulpt# Printer
 device umass   # Disks/Mass storage - Requires scbus and da0
 device ums # Mouse
-device urio# Diamond Rio 500 MP3 player
 # USB Ethernet
 device aue # ADMtek USB Ethernet
 device axe # ASIX Electronics USB Ethernet
@@ -236,3 +244,5 @@ device  sound   # Generic sound driver 
(required)
 device snd_ai2s# Apple I2S audio
 device snd_uaudio  # USB Audio
 
+# Netmap provides direct access to TX/RX rings on supported NICs
+device netmap  # netmap(4) support
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340394 - head/sbin/ipfw

2018-11-13 Thread Eugene Grosbein
Author: eugen
Date: Tue Nov 13 13:57:15 2018
New Revision: 340394
URL: https://svnweb.freebsd.org/changeset/base/340394

Log:
  Fix part of the SYNOPSIS documenting LIST OF RULES AND PREPROCESSING
  that is still referred as last section of the SYNOPSIS later
  but was erroneously situated in the section IN-KERNEL NAT.
  
  MFC after:1 month

Modified:
  head/sbin/ipfw/ipfw.8

Modified: head/sbin/ipfw/ipfw.8
==
--- head/sbin/ipfw/ipfw.8   Tue Nov 13 09:19:07 2018(r340393)
+++ head/sbin/ipfw/ipfw.8   Tue Nov 13 13:57:15 2018(r340394)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 12, 2018
+.Dd November 13, 2018
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -105,16 +105,6 @@ in-kernel NAT.
 .Ar number
 .Cm config
 .Ar config-options
-.Pp
-.Nm
-.Op Fl cfnNqS
-.Oo
-.Fl p Ar preproc
-.Oo
-.Ar preproc-flags
-.Oc
-.Oc
-.Ar pathname
 .Ss STATEFUL IPv6/IPv4 NETWORK ADDRESS AND PROTOCOL TRANSLATION
 .Nm
 .Oo Cm set Ar N Oc Cm nat64lsn Ar name Cm create Ar create-options
@@ -166,6 +156,16 @@ in-kernel NAT.
 .Cm internal talist
 .Nm
 .Cm internal vlist
+.Ss LIST OF RULES AND PREPROCESSING
+.Nm
+.Op Fl cfnNqS
+.Oo
+.Fl p Ar preproc
+.Oo
+.Ar preproc-flags
+.Oc
+.Oc
+.Ar pathname
 .Sh DESCRIPTION
 The
 .Nm
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340395 - head/lib/csu/common

2018-11-13 Thread Andrew Turner
Author: andrew
Date: Tue Nov 13 15:28:27 2018
New Revision: 340395
URL: https://svnweb.freebsd.org/changeset/base/340395

Log:
  Run __cxa_finalize in shared objects in the destructor path.
  
  When we have .dtors call them before .dtor handling, otherwise call from
  a destructor.
  
  PR:   233056
  MFC with: r339738
  Sponsored by: DARPA, AFRL

Modified:
  head/lib/csu/common/crtbegin.c

Modified: head/lib/csu/common/crtbegin.c
==
--- head/lib/csu/common/crtbegin.c  Tue Nov 13 13:57:15 2018
(r340394)
+++ head/lib/csu/common/crtbegin.c  Tue Nov 13 15:28:27 2018
(r340395)
@@ -32,12 +32,29 @@ typedef void (*crt_func)(void);
 
 extern void *__dso_handle __hidden;
 
-#ifdef SHARED
-void *__dso_handle = &__dso_handle;
-#else
+#ifndef SHARED
 void *__dso_handle = 0;
+#else
+void *__dso_handle = &__dso_handle;
+void __cxa_finalize(void *) __weak_symbol;
+
+/*
+ * Call __cxa_finalize with the dso handle in shared objects.
+ * When we have ctors/dtors call from the dtor handler before calling
+ * any dtors, otherwise use a destructor.
+ */
+#ifndef HAVE_CTORS
+__attribute__((destructor))
 #endif
+static void
+run_cxa_finalize(void)
+{
 
+   if (__cxa_finalize != NULL)
+   __cxa_finalize(__dso_handle);
+}
+#endif
+
 /*
  * On some architectures and toolchains we may need to call the .dtors.
  * These are called in the order they are in the ELF file.
@@ -57,6 +74,10 @@ __do_global_dtors_aux(void)
 {
crt_func fn;
int n;
+
+#ifdef SHARED
+   run_cxa_finalize();
+#endif
 
for (n = 1;; n++) {
fn = __DTOR_LIST__[n];
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r339358 - head/sys/net

2018-11-13 Thread Oleg Bulyzhin


btw, this breaks kernel build with VLAN_ARRAY option defined.

-- 
Oleg.


=== Oleg Bulyzhin -- OBUL-RIPN -- OBUL-RIPE -- o...@rinet.ru ===


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340396 - in stable/12/sys: kern vm

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 16:51:30 2018
New Revision: 340396
URL: https://svnweb.freebsd.org/changeset/base/340396

Log:
  MFC r339925:
  Fix some problems that manifest when NUMA domain 0 is empty.
  
  Approved by:  re (gjb)

Modified:
  stable/12/sys/kern/kern_cpuset.c
  stable/12/sys/vm/uma_core.c
  stable/12/sys/vm/vm_init.c
  stable/12/sys/vm/vm_kern.c
  stable/12/sys/vm/vm_page.c
  stable/12/sys/vm/vm_pageout.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_cpuset.c
==
--- stable/12/sys/kern/kern_cpuset.cTue Nov 13 15:28:27 2018
(r340395)
+++ stable/12/sys/kern/kern_cpuset.cTue Nov 13 16:51:30 2018
(r340396)
@@ -492,20 +492,29 @@ _domainset_create(struct domainset *domain, struct dom
 }
 
 /*
- * Are any of the domains in the mask empty? If so, silently
- * remove them.  If only empty domains are present, we must
- * return failure.
+ * Are any of the domains in the mask empty?  If so, silently
+ * remove them and update the domainset accordingly.  If only empty
+ * domains are present, we must return failure.
  */
 static bool
 domainset_empty_vm(struct domainset *domain)
 {
-   int i, max;
+   int i, j, max;
 
max = DOMAINSET_FLS(&domain->ds_mask) + 1;
-   for (i = 0; i < max; i++) {
-   if (DOMAINSET_ISSET(i, &domain->ds_mask) &&
-   VM_DOMAIN_EMPTY(i))
+   for (i = 0; i < max; i++)
+   if (DOMAINSET_ISSET(i, &domain->ds_mask) && VM_DOMAIN_EMPTY(i))
DOMAINSET_CLR(i, &domain->ds_mask);
+   domain->ds_cnt = DOMAINSET_COUNT(&domain->ds_mask);
+   max = DOMAINSET_FLS(&domain->ds_mask) + 1;
+   for (i = j = 0; i < max; i++) {
+   if (DOMAINSET_ISSET(i, &domain->ds_mask))
+   domain->ds_order[j++] = i;
+   else if (domain->ds_policy == DOMAINSET_POLICY_PREFER &&
+   domain->ds_prefer == i && domain->ds_cnt > 1) {
+   domain->ds_policy = DOMAINSET_POLICY_ROUNDROBIN;
+   domain->ds_prefer = -1;
+   }
}
 
return (DOMAINSET_EMPTY(&domain->ds_mask));
@@ -1378,7 +1387,7 @@ cpuset_setithread(lwpid_t id, int cpu)
 
 /*
  * Initialize static domainsets after NUMA information is available.  This is
- * called very early during boot.
+ * called before memory allocators are initialized.
  */
 void
 domainset_init(void)
@@ -1407,7 +1416,7 @@ domainset_init(void)
 void
 domainset_zero(void)
 {
-   struct domainset *dset;
+   struct domainset *dset, *tmp;
 
mtx_init(&cpuset_lock, "cpuset", NULL, MTX_SPIN | MTX_RECURSE);
 
@@ -1422,8 +1431,9 @@ domainset_zero(void)
kernel_object->domain.dr_policy = _domainset_create(&domainset2, NULL);
 
/* Remove empty domains from the global policies. */
-   LIST_FOREACH(dset, &cpuset_domains, ds_link)
-   (void)domainset_empty_vm(dset);
+   LIST_FOREACH_SAFE(dset, &cpuset_domains, ds_link, tmp)
+   if (domainset_empty_vm(dset))
+   LIST_REMOVE(dset, ds_link);
 }
 
 /*

Modified: stable/12/sys/vm/uma_core.c
==
--- stable/12/sys/vm/uma_core.c Tue Nov 13 15:28:27 2018(r340395)
+++ stable/12/sys/vm/uma_core.c Tue Nov 13 16:51:30 2018(r340396)
@@ -3608,29 +3608,30 @@ uma_zone_reserve_kva(uma_zone_t zone, int count)
 void
 uma_prealloc(uma_zone_t zone, int items)
 {
+   struct vm_domainset_iter di;
uma_domain_t dom;
uma_slab_t slab;
uma_keg_t keg;
-   int domain, slabs;
+   int domain, flags, slabs;
 
keg = zone_first_keg(zone);
if (keg == NULL)
return;
KEG_LOCK(keg);
slabs = items / keg->uk_ipers;
-   domain = 0;
if (slabs * keg->uk_ipers < items)
slabs++;
+   flags = M_WAITOK;
+   vm_domainset_iter_policy_ref_init(&di, &keg->uk_dr, &domain, &flags);
while (slabs-- > 0) {
-   slab = keg_alloc_slab(keg, zone, domain, M_WAITOK);
+   slab = keg_alloc_slab(keg, zone, domain, flags);
if (slab == NULL)
return;
MPASS(slab->us_keg == keg);
dom = &keg->uk_domain[slab->us_domain];
LIST_INSERT_HEAD(&dom->ud_free_slab, slab, us_link);
-   do {
-   domain = (domain + 1) % vm_ndomains;
-   } while (VM_DOMAIN_EMPTY(domain));
+   if (vm_domainset_iter_policy(&di, &domain) != 0)
+   break;
}
KEG_UNLOCK(keg);
 }

Modified: stable/12/sys/vm/vm_init.c
==
--- stable/12/sys/vm/vm_init.c  Tue Nov 13 15:28:27 2018(r340395)
+++ stable/12/sys/vm/vm_init.c  Tue Nov 

svn commit: r340397 - stable/12/sys/netinet

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 17:25:34 2018
New Revision: 340397
URL: https://svnweb.freebsd.org/changeset/base/340397

Log:
  MFC r340313:
  Ensure that IP fragments do not extend beyond IP_MAXPACKET.
  
  Approved by:  re (gjb)

Modified:
  stable/12/sys/netinet/ip_reass.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/ip_reass.c
==
--- stable/12/sys/netinet/ip_reass.cTue Nov 13 16:51:30 2018
(r340396)
+++ stable/12/sys/netinet/ip_reass.cTue Nov 13 17:25:34 2018
(r340397)
@@ -228,6 +228,16 @@ ip_reass(struct mbuf *m)
ip->ip_off = htons(ntohs(ip->ip_off) << 3);
 
/*
+* Make sure the fragment lies within a packet of valid size.
+*/
+   if (ntohs(ip->ip_len) + ntohs(ip->ip_off) > IP_MAXPACKET) {
+   IPSTAT_INC(ips_toolong);
+   IPSTAT_INC(ips_fragdropped);
+   m_freem(m);
+   return (NULL);
+   }
+
+   /*
 * Attempt reassembly; if it succeeds, proceed.
 * ip_reass() will return a different mbuf.
 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340398 - stable/12/sys/vm

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 17:43:16 2018
New Revision: 340398
URL: https://svnweb.freebsd.org/changeset/base/340398

Log:
  MFC r340331:
  Re-apply r336984, reverting r339934.
  
  Approved by:  re (gjb)

Modified:
  stable/12/sys/vm/vm_object.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/vm/vm_object.c
==
--- stable/12/sys/vm/vm_object.cTue Nov 13 17:25:34 2018
(r340397)
+++ stable/12/sys/vm/vm_object.cTue Nov 13 17:43:16 2018
(r340398)
@@ -2143,8 +2143,9 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset
next_size >>= PAGE_SHIFT;
next_pindex = OFF_TO_IDX(prev_offset) + prev_size;
 
-   if ((prev_object->ref_count > 1) &&
-   (prev_object->size != next_pindex)) {
+   if (prev_object->ref_count > 1 &&
+   prev_object->size != next_pindex &&
+   (prev_object->flags & OBJ_ONEMAPPING) == 0) {
VM_OBJECT_WUNLOCK(prev_object);
return (FALSE);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r340326 - head

2018-11-13 Thread Ian Lepore
On Mon, 2018-11-12 at 06:00 -0800, Rodney W. Grimes wrote:
> > 
> > I absolutely approve of Ben's excellent addition to UPDATING, a
> > text document.
> At no point did I raise ANY objectection to the content
> of his change, stop trying to make that the issue.
> 
> > 
> > Your demands for additional scrutiny and time-wasting around code
> > review are ridiculous and disproportionate, and certainly a poor
> > reward for Ben's straightforward and unimpeachable effort to
> > improve
> > our UPDATING documentation.
> My demands are reasonable, as I stated them, your ignoring them
> and casting focus on my non dmeands however is pointless.
> 
> > 
> > 
> > Ben, thank you for submitting and committing the UPDATING change
> > and
> > please try to ignore Rod's hyper-criticism.
> What you are totally ignoring is that Ben infact TAGGED me into
> the review process, causing me to process yet another email only
> to go look at the review to find it had been closed by a commit
> in < 4 hours total elapsed time.
> 
> That is BULLSHIT and I am calling it BULLSHIT.  And though Ben
> is the poor victom of example here, he is not the only guilty
> party, and though this is a trivial change, it is not the change
> that I am ranting about, but the fact that the process is
> broken.
> 
> IF YOUR GOING TO TAG SOMEONE INTO A REVIEW YOU MUST GIVE THEM
> TIME TO RESPOND BEFORE YOU COMMIT, otherwise your just wasting
> there time.  
> 
> Do NOT tag me into a review if your going to commit it before
> I can possibly be expected to respond.  I well rant on anyone
> who does that.
> 
> CLEAR NOW?
> 

You seem to be very confused about phabricator and the review process.
Being added to the list of reviewers in no way implies that your
signoff is REQUIRED before a commit can occur. If you don't have time
to jump on a review immediately, but some other committer does, then
that's good enough, the process is working to perfection.

-- Ian


> > 
> > Conrad
> > 
> > 
> > On Sat, Nov 10, 2018 at 5:07 PM Rodney W. Grimes
> >  wrote:
> > > 
> > > 
> > > [ Charset UTF-8 unsupported, converting... ]
> > > > 
> > > > On Sun, 11 Nov 2018 at 2:43 am, Rodney W. Grimes <
> > > > free...@pdx.rh.cn85.dnsmgr.net> wrote:
> > > > 
> > > > > 
> > > > > If your going to bother with a differential, and invite
> > > > > people to
> > > > > it you should give them at least 24 hours, and preferably 72
> > > > > hours
> > > > > to respond to the new review.  Reviews that last < 4 hours
> > > > > are not
> > > > > code reviews.
> > > > > 
> > > > > --
> > > > > Rod Grimes
> > > > > rgri...@freebsd.org
> > > > > 
> > > > Hi Rod,
> > > > 
> > > > Sorry. The main reason I submitted the code review is because I
> > > > do not have
> > > > my src commit bit, so needed to seek approval to commit.
> > > All the more reason for it to wait until the people you *invited*
> > > to
> > > the review to have a chance to respond.
> > > 
> > > I do not believe an "accept" in a review is an "approve to commit
> > > beyond your normal scope".
> > > 
> > > Was cem aware that he was "approving a non src committer to
> > > commit
> > > this change to the src tree" as your review has no mention that
> > > you
> > > are seeking src bit approval to commit there.
> > > 
> > > > 
> > > > 
> > > > I felt the need to commit the UPDATING entry was time
> > > > sensitive, given the
> > > > change it was notifying users of had already been committed.
> > > > 
> > > > Regards,
> > > > Ben
> > > > --
> > > --
> > > Rod Grimes rgrime
> > > s...@freebsd.org
> > > 
> > 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340399 - head/sys/riscv/include

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 18:12:06 2018
New Revision: 340399
URL: https://svnweb.freebsd.org/changeset/base/340399

Log:
  RISC-V: Add macros for reading performance counter CSRs.
  
  The RISC-V spec defines several performance counter CSRs such as: cycle,
  time, instret, hpmcounter(3...31).  They are defined to be 64-bits wide
  on all RISC-V architectures.  On RV64 and RV128 they can be read from a
  single CSR.  On RV32, additional CSRs (given the suffix "h") are present
  which contain the upper 32 bits of these counters, and must be read as
  well.  (See section 2.8 in the User ISA Spec for full details.)
  
  This change adds macros for reading these values safely on any RISC-V
  ISA length.  Obviously we aren't supporting anything other than RV64
  at the moment, but this ensures we won't need to change how we read
  these values if we ever do.
  
  Submitted by: Mitchell Horne 
  Reviewed by:  jhb
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D17952

Modified:
  head/sys/riscv/include/cpufunc.h
  head/sys/riscv/include/riscvreg.h

Modified: head/sys/riscv/include/cpufunc.h
==
--- head/sys/riscv/include/cpufunc.hTue Nov 13 17:43:16 2018
(r340398)
+++ head/sys/riscv/include/cpufunc.hTue Nov 13 18:12:06 2018
(r340399)
@@ -104,6 +104,11 @@ sfence_vma_page(uintptr_t addr)
__asm __volatile("sfence.vma %0" :: "r" (addr) : "memory");
 }
 
+#definerdcycle()   csr_read64(cycle)
+#definerdtime()csr_read64(time)
+#definerdinstret() csr_read64(instret)
+#definerdhpmcounter(n) csr_read64(hpmcounter##n)
+
 #definecpufunc_nullop()riscv_nullop()
 
 void riscv_nullop(void);

Modified: head/sys/riscv/include/riscvreg.h
==
--- head/sys/riscv/include/riscvreg.h   Tue Nov 13 17:43:16 2018
(r340398)
+++ head/sys/riscv/include/riscvreg.h   Tue Nov 13 18:12:06 2018
(r340399)
@@ -223,4 +223,23 @@
val;\
 })
 
+#if __riscv_xlen == 32
+#definecsr_read64(csr) 
\
+({ uint64_t val;   \
+   uint32_t high, low; \
+   __asm __volatile("1: "  \
+"csrr t0, " #csr "h\n" \
+"csrr %0, " #csr "\n"  \
+"csrr %1, " #csr "h\n" \
+"bne t0, %1, 1b"   \
+: "=r" (low), "=r" (high)  \
+:  \
+: "t0");   \
+   val = (low | ((uint64_t)high << 32));   \
+   val;\
+})
+#else
+#definecsr_read64(csr) ((uint64_t)csr_read(csr))
+#endif
+
 #endif /* !_MACHINE_RISCVREG_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340400 - head/sys/riscv/include

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 18:20:27 2018
New Revision: 340400
URL: https://svnweb.freebsd.org/changeset/base/340400

Log:
  RISC-V: Implement get_cyclecount(9).
  
  Add the missing implementation for get_cyclecount(9) on RISC-V by
  reading the cycle CSR.
  
  Submitted by: Mitchell Horne 
  Reviewed by:  jhb
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D17953

Modified:
  head/sys/riscv/include/cpu.h

Modified: head/sys/riscv/include/cpu.h
==
--- head/sys/riscv/include/cpu.hTue Nov 13 18:12:06 2018
(r340399)
+++ head/sys/riscv/include/cpu.hTue Nov 13 18:20:27 2018
(r340400)
@@ -38,6 +38,7 @@
 #define_MACHINE_CPU_H_
 
 #include 
+#include 
 #include 
 
 #defineTRAPF_PC(tfp)   ((tfp)->tf_ra)
@@ -86,8 +87,7 @@ static __inline uint64_t
 get_cyclecount(void)
 {
 
-   /* TODO: This is bogus */
-   return (1);
+   return (rdcycle());
 }
 
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340401 - in stable/12: . share/man/man9 sys/dev/hwpmc sys/i386/i386 sys/kern sys/sys sys/vm sys/x86/iommu sys/x86/x86

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 18:21:47 2018
New Revision: 340401
URL: https://svnweb.freebsd.org/changeset/base/340401

Log:
  MFC r339927:
  Add malloc_domainset(9) and _domainset variants to other allocator KPIs.
  
  Approved by:  re (gjb)

Modified:
  stable/12/ObsoleteFiles.inc
  stable/12/share/man/man9/Makefile
  stable/12/share/man/man9/contigmalloc.9
  stable/12/share/man/man9/domainset.9
  stable/12/share/man/man9/malloc.9
  stable/12/sys/dev/hwpmc/hwpmc_logging.c
  stable/12/sys/dev/hwpmc/hwpmc_mod.c
  stable/12/sys/i386/i386/pmap.c
  stable/12/sys/kern/kern_cpuset.c
  stable/12/sys/kern/kern_malloc.c
  stable/12/sys/kern/kern_mbuf.c
  stable/12/sys/kern/kern_pmc.c
  stable/12/sys/kern/subr_busdma_bufalloc.c
  stable/12/sys/sys/domainset.h
  stable/12/sys/sys/malloc.h
  stable/12/sys/vm/uma_core.c
  stable/12/sys/vm/vm_extern.h
  stable/12/sys/vm/vm_kern.c
  stable/12/sys/x86/iommu/busdma_dmar.c
  stable/12/sys/x86/x86/busdma_bounce.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/ObsoleteFiles.inc
==
--- stable/12/ObsoleteFiles.inc Tue Nov 13 18:20:27 2018(r340400)
+++ stable/12/ObsoleteFiles.inc Tue Nov 13 18:21:47 2018(r340401)
@@ -38,6 +38,8 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20181030: malloc_domain(9) KPI change
+OLD_FILES+=share/man/man9/malloc_domain.9.gz
 # 20181025: OpenSSL libraries version bump to avoid conflict with ports
 OLD_LIBS+=lib/libcrypto.so.9
 OLD_LIBS+=usr/lib/libssl.so.9

Modified: stable/12/share/man/man9/Makefile
==
--- stable/12/share/man/man9/Makefile   Tue Nov 13 18:20:27 2018
(r340400)
+++ stable/12/share/man/man9/Makefile   Tue Nov 13 18:21:47 2018
(r340401)
@@ -811,7 +811,8 @@ MLINKS+=condvar.9 cv_broadcast.9 \
 MLINKS+=config_intrhook.9 config_intrhook_disestablish.9 \
config_intrhook.9 config_intrhook_establish.9 \
config_intrhook.9 config_intrhook_oneshot.9
-MLINKS+=contigmalloc.9 contigfree.9
+MLINKS+=contigmalloc.9 contigmalloc_domainset.9 \
+   contigmalloc.9 contigfree.9
 MLINKS+=casuword.9 casueword.9 \
casuword.9 casueword32.9 \
casuword.9 casuword32.9
@@ -1286,7 +1287,7 @@ MLINKS+=make_dev.9 destroy_dev.9 \
make_dev.9 make_dev_p.9 \
make_dev.9 make_dev_s.9
 MLINKS+=malloc.9 free.9 \
-   malloc.9 malloc_domain.9 \
+   malloc.9 malloc_domainset.9 \
malloc.9 free_domain.9 \
malloc.9 mallocarray.9 \
malloc.9 MALLOC_DECLARE.9 \

Modified: stable/12/share/man/man9/contigmalloc.9
==
--- stable/12/share/man/man9/contigmalloc.9 Tue Nov 13 18:20:27 2018
(r340400)
+++ stable/12/share/man/man9/contigmalloc.9 Tue Nov 13 18:21:47 2018
(r340401)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 29, 2015
+.Dd October 30, 2018
 .Dt CONTIGMALLOC 9
 .Os
 .Sh NAME
@@ -50,6 +50,19 @@
 .Fa "unsigned long size"
 .Fa "struct malloc_type *type"
 .Fc
+.In sys/param.h
+.In sys/domainset.h
+.Ft "void *"
+.Fo contigmalloc_domainset
+.Fa "unsigned long size"
+.Fa "struct malloc_type *type"
+.Fa "struct domainset *ds"
+.Fa "int flags"
+.Fa "vm_paddr_t low"
+.Fa "vm_paddr_t high"
+.Fa "unsigned long alignment"
+.Fa "vm_paddr_t boundary"
+.Fc
 .Sh DESCRIPTION
 The
 .Fn contigmalloc
@@ -70,6 +83,15 @@ address range of
 bytes allocated from the kernel virtual address (KVA) map.
 .Pp
 The
+.Fn contigmalloc_domainset
+variant allows the caller to additionally specify a
+.Xr numa 4
+domain selection policy.
+See
+.Xr domainset 9
+for some example policies.
+.Pp
+The
 .Fa flags
 parameter modifies
 .Fn contigmalloc Ns 's
@@ -90,7 +112,9 @@ Other flags (if present) are ignored.
 The
 .Fn contigfree
 function deallocates memory allocated by a previous call to
-.Fn contigmalloc .
+.Fn contigmalloc
+or
+.Fn contigmalloc_domainset .
 .Sh IMPLEMENTATION NOTES
 The
 .Fn contigmalloc

Modified: stable/12/share/man/man9/domainset.9
==
--- stable/12/share/man/man9/domainset.9Tue Nov 13 18:20:27 2018
(r340400)
+++ stable/12/share/man/man9/domainset.9Tue Nov 13 18:21:47 2018
(r340401)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 20, 2018
+.Dd October 30, 2018
 .Dt DOMAINSET 9
 .Os
 .Sh NAME
@@ -43,7 +43,11 @@ struct domainset {
 };
 .Ed
 .Pp
+.Ft struct domainset *
+.Fn DOMAINSET_FIXED domain
+.Ft struct domainset *
 .Fn DOMAINSET_RR
+.Ft struct domainset *
 .Fn DOMAINSET_PREF domain
 .Ft struct domainset *
 .Fn domainset_create "const struct domainset *key"
@@ -98,11 +102,26 @@ efficiency higher and is preferential to round-robin f
 .El
 .Pp
 The
+.Fn DOMAINSET_FIXED ,
 .Fn DOMAINSET_RR
 and
 .Fn DOMAINSET_PREF
-provide pointers to global pre-defined policies for use when the
+ma

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

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 18:40:01 2018
New Revision: 340402
URL: https://svnweb.freebsd.org/changeset/base/340402

Log:
  Allow allocations across meta boundaries.
  
  Remove restrictions that prevent allocation requests to cross the
  boundary between two meta nodes.
  
  Replace the bmu_avail field in meta nodes with a bitmap that identifies
  which subtrees have some free memory, and iterate over the nonempty
  subtrees only in blst_meta_alloc.  If free memory is scarce, this should
  make searching for it faster.
  
  Put the code for handling the next-leaf allocation in a separate
  function.  When taking blocks from the next leaf empties the leaf, be
  sure to clear the appropriate bit in its parent, and so on, up to the
  least-common ancestor of this leaf and the next.
  
  Eliminate special terminator nodes, and rely instead on the fact that
  there is a 0-bit at the end of the bitmask at the root of the tree that
  will stop a meta_alloc search, or a next-leaf search, before the search
  falls off the end of the tree. Make sure that the tree is big enough to
  have space for that 0-bit.
  
  Eliminate special all-free indicators.  Lazy initialization of subtrees
  stands in the way of having an allocation span a meta-node boundary, so
  a subtree of all free blocks is not treated specially.  Subtrees of
  all-allocated blocks are still recognized by looking at the bitmask at
  the root and finding 0.
  
  Don't print all-allocated subtrees.  Do print the bitmasks for meta
  nodes, when tree-printing.
  
  Submitted by: Doug Moore 
  Reviewed by:  alc
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D12635

Modified:
  head/sys/kern/subr_blist.c
  head/sys/sys/blist.h

Modified: head/sys/kern/subr_blist.c
==
--- head/sys/kern/subr_blist.c  Tue Nov 13 18:21:47 2018(r340401)
+++ head/sys/kern/subr_blist.c  Tue Nov 13 18:40:01 2018(r340402)
@@ -46,11 +46,11 @@
  * upper bound on a potential allocation, but not necessarily a tight upper
  * bound.
  *
- * The radix tree also implements two collapsed states for meta nodes:
- * the ALL-ALLOCATED state and the ALL-FREE state.  If a meta node is
- * in either of these two states, all information contained underneath
- * the node is considered stale.  These states are used to optimize
- * allocation and freeing operations.
+ * The bitmap field in each node directs the search for available blocks.
+ * For a leaf node, a bit is set if the corresponding block is free.  For a
+ * meta node, a bit is set if the corresponding subtree contains a free
+ * block somewhere within it.  The search at a meta node considers only
+ * children of that node that represent a range that includes a free block.
  *
  * The hinting greatly increases code efficiency for allocations while
  * the general radix structure optimizes both allocations and frees.  The
@@ -59,19 +59,19 @@
  *
  * The blist code wires all necessary memory at creation time.  Neither
  * allocations nor frees require interaction with the memory subsystem.
- * The non-blocking features of the blist code are used in the swap code
- * (vm/swap_pager.c).
+ * The non-blocking nature of allocations and frees is required by swap
+ * code (vm/swap_pager.c).
  *
- * LAYOUT: The radix tree is laid out recursively using a
- * linear array.  Each meta node is immediately followed (laid out
- * sequentially in memory) by BLIST_META_RADIX lower level nodes.  This
- * is a recursive structure but one that can be easily scanned through
- * a very simple 'skip' calculation.  In order to support large radixes,
- * portions of the tree may reside outside our memory allocation.  We
- * handle this with an early-termination optimization (when bighint is
- * set to -1) on the scan.  The memory allocation is only large enough
- * to cover the number of blocks requested at creation time even if it
- * must be encompassed in larger root-node radix.
+ * LAYOUT: The radix tree is laid out recursively using a linear array.
+ * Each meta node is immediately followed (laid out sequentially in
+ * memory) by BLIST_META_RADIX lower level nodes.  This is a recursive
+ * structure but one that can be easily scanned through a very simple
+ * 'skip' calculation.  The memory allocation is only large enough to
+ * cover the number of blocks requested at creation time.  Nodes that
+ * represent blocks beyond that limit, nodes that would never be read
+ * or written, are not allocated, so that the last of the
+ * BLIST_META_RADIX lower level nodes of a some nodes may not be
+ * allocated.
  *
  * NOTE: the allocator cannot currently allocate more than
  * BLIST_BMAP_RADIX blocks per call.  It will panic with 'allocation too
@@ -105,6 +105,7 @@ __FBS

svn commit: r340403 - in stable/11/sys/dev: mpr mps

2018-11-13 Thread Scott Long
Author: scottl
Date: Tue Nov 13 18:49:43 2018
New Revision: 340403
URL: https://svnweb.freebsd.org/changeset/base/340403

Log:
  Fix a regression from prior to 11.2 that caused MSI (not MSI-X) interrupt
  allocation to fail.  While here, refactor the code so that it's more clear
  and less likely to break in the future.  This is not an MFC due to the code
  in 12/head being very different, but it follows the latter's structure
  more closely than before.
  
  Reported by:  Harry Schmalzbauer

Modified:
  stable/11/sys/dev/mpr/mpr_pci.c
  stable/11/sys/dev/mps/mps_pci.c

Modified: stable/11/sys/dev/mpr/mpr_pci.c
==
--- stable/11/sys/dev/mpr/mpr_pci.c Tue Nov 13 18:40:01 2018
(r340402)
+++ stable/11/sys/dev/mpr/mpr_pci.c Tue Nov 13 18:49:43 2018
(r340403)
@@ -262,12 +262,16 @@ mpr_pci_alloc_interrupts(struct mpr_softc *sc)
error = 0;
msgs = 0;
 
-   if ((sc->disable_msix == 0) &&
-   ((msgs = pci_msix_count(dev)) >= MPR_MSI_COUNT))
-   error = mpr_alloc_msix(sc, MPR_MSI_COUNT);
-   if ((error != 0) && (sc->disable_msi == 0) &&
-   ((msgs = pci_msi_count(dev)) >= MPR_MSI_COUNT))
-   error = mpr_alloc_msi(sc, MPR_MSI_COUNT);
+   if (sc->disable_msix == 0) {
+   msgs = pci_msix_count(dev);
+   if (msgs >= MPR_MSI_COUNT)
+   error = mpr_alloc_msix(sc, MPR_MSI_COUNT);
+   }
+   if (((error != 0) || (msgs == 0)) && (sc->disable_msi == 0)) {
+   msgs = pci_msi_count(dev);
+   if (msgs >= MPR_MSI_COUNT)
+   error = mpr_alloc_msi(sc, MPR_MSI_COUNT);
+   }
if (error != 0)
msgs = 0;
 

Modified: stable/11/sys/dev/mps/mps_pci.c
==
--- stable/11/sys/dev/mps/mps_pci.c Tue Nov 13 18:40:01 2018
(r340402)
+++ stable/11/sys/dev/mps/mps_pci.c Tue Nov 13 18:49:43 2018
(r340403)
@@ -247,12 +247,16 @@ mps_pci_alloc_interrupts(struct mps_softc *sc)
error = 0;
msgs = 0;
 
-   if ((sc->disable_msix == 0) &&
-   ((msgs = pci_msix_count(dev)) >= MPS_MSI_COUNT))
-   error = mps_alloc_msix(sc, MPS_MSI_COUNT);
-   if ((error != 0) && (sc->disable_msi == 0) &&
-   ((msgs = pci_msi_count(dev)) >= MPS_MSI_COUNT))
-   error = mps_alloc_msi(sc, MPS_MSI_COUNT);
+   if (sc->disable_msix == 0) {
+   msgs = pci_msix_count(dev);
+   if (msgs >= MPS_MSI_COUNT)
+   error = mps_alloc_msix(sc, MPS_MSI_COUNT);
+   }
+   if (((error != 0) || (msgs == 0)) && (sc->disable_msi == 0)) {
+   msgs = pci_msi_count(dev);
+   if (msgs >= MPS_MSI_COUNT)
+   error = mps_alloc_msi(sc, MPS_MSI_COUNT);
+   }
if (error != 0)
msgs = 0;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-11-13 Thread Gleb Smirnoff
Author: glebius
Date: Tue Nov 13 19:02:11 2018
New Revision: 340404
URL: https://svnweb.freebsd.org/changeset/base/340404

Log:
  Uninline epoch(9) entrance and exit. There is no proof that modern
  processors would benefit from avoiding a function call, but bloating
  code. In fact, clang created an uninlined real function for many
  object files in the network stack.
  
  - Move epoch_private.h into subr_epoch.c. Code copied exactly, avoiding
any changes, including style(9).
  - Remove private copies of critical_enter/exit.
  
  Reviewed by:  kib, jtl
  Differential Revision:https://reviews.freebsd.org/D17879

Deleted:
  head/sys/sys/epoch_private.h
Modified:
  head/sys/kern/subr_epoch.c
  head/sys/sys/epoch.h

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Tue Nov 13 18:49:43 2018(r340403)
+++ head/sys/kern/subr_epoch.c  Tue Nov 13 19:02:11 2018(r340404)
@@ -55,6 +55,40 @@ __FBSDID("$FreeBSD$");
 
 static MALLOC_DEFINE(M_EPOCH, "epoch", "epoch based reclamation");
 
+typedef struct epoch_thread {
+#ifdef EPOCH_TRACKER_DEBUG
+   uint64_t et_magic_pre;
+#endif
+   TAILQ_ENTRY(epoch_thread) et_link;  /* Epoch queue. */
+   struct thread *et_td;   /* pointer to thread in section */
+   ck_epoch_section_t et_section; /* epoch section object */
+#ifdef EPOCH_TRACKER_DEBUG
+   uint64_t et_magic_post;
+#endif
+} *epoch_thread_t;
+TAILQ_HEAD (epoch_tdlist, epoch_thread);
+
+#ifdef __amd64__
+#define EPOCH_ALIGN CACHE_LINE_SIZE*2
+#else
+#define EPOCH_ALIGN CACHE_LINE_SIZE
+#endif
+
+typedef struct epoch_record {
+   ck_epoch_record_t er_read_record;
+   ck_epoch_record_t er_write_record;
+   volatile struct epoch_tdlist er_tdlist;
+   volatile uint32_t er_gen;
+   uint32_t er_cpuid;
+} __aligned(EPOCH_ALIGN) *epoch_record_t;
+
+struct epoch {
+   struct ck_epoch e_epoch __aligned(EPOCH_ALIGN);
+   epoch_record_t e_pcpu_record;
+   int e_idx;
+   int e_flags;
+};
+
 /* arbitrary --- needs benchmarking */
 #define MAX_ADAPTIVE_SPIN 100
 #define MAX_EPOCHS 64
@@ -157,6 +191,15 @@ epoch_ctor(epoch_t epoch)
}
 }
 
+static void
+epoch_adjust_prio(struct thread *td, u_char prio)
+{
+
+   thread_lock(td);
+   sched_prio(td, prio);
+   thread_unlock(td);
+}
+
 epoch_t
 epoch_alloc(int flags)
 {
@@ -192,32 +235,110 @@ epoch_free(epoch_t epoch)
free(epoch, M_EPOCH);
 }
 
+static epoch_record_t
+epoch_currecord(epoch_t epoch)
+{
+
+   return (zpcpu_get_cpu(epoch->e_pcpu_record, curcpu));
+}
+
+#define INIT_CHECK(epoch)  \
+   do {\
+   if (__predict_false((epoch) == NULL))   \
+   return; \
+   } while (0)
+
 void
-epoch_enter_preempt_KBI(epoch_t epoch, epoch_tracker_t et)
+epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
 {
+   struct epoch_record *er;
+   struct epoch_thread *etd;
+   struct thread_lite *td;
 
-   epoch_enter_preempt(epoch, et);
+   MPASS(cold || epoch != NULL);
+   INIT_CHECK(epoch);
+   etd = (void *)et;
+   MPASS(epoch->e_flags & EPOCH_PREEMPT);
+#ifdef EPOCH_TRACKER_DEBUG
+   etd->et_magic_pre = EPOCH_MAGIC0;
+   etd->et_magic_post = EPOCH_MAGIC1;
+#endif
+   td = (struct thread_lite *)curthread;
+   etd->et_td = (void*)td;
+   td->td_epochnest++;
+   critical_enter();
+   sched_pin_lite(td);
+
+   td->td_pre_epoch_prio = td->td_priority;
+   er = epoch_currecord(epoch);
+   TAILQ_INSERT_TAIL(&er->er_tdlist, etd, et_link);
+   ck_epoch_begin(&er->er_read_record, (ck_epoch_section_t 
*)&etd->et_section);
+   critical_exit();
 }
 
 void
-epoch_exit_preempt_KBI(epoch_t epoch, epoch_tracker_t et)
+epoch_enter(epoch_t epoch)
 {
+   struct thread_lite *td;
+   epoch_record_t er;
 
-   epoch_exit_preempt(epoch, et);
+   MPASS(cold || epoch != NULL);
+   INIT_CHECK(epoch);
+   td = (struct thread_lite *)curthread;
+
+   td->td_epochnest++;
+   critical_enter();
+   er = epoch_currecord(epoch);
+   ck_epoch_begin(&er->er_read_record, NULL);
 }
 
 void
-epoch_enter_KBI(epoch_t epoch)
+epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
 {
+   struct epoch_record *er;
+   struct epoch_thread *etd;
+   struct thread_lite *td;
 
-   epoch_enter(epoch);
+   INIT_CHECK(epoch);
+   td = (struct thread_lite *)curthread;
+   critical_enter();
+   sched_unpin_lite(td);
+   MPASS(td->td_epochnest);
+   td->td_epochnest--;
+   er = epoch_currecord(epoch);
+   MPASS(epoch->e_flags & EPOCH_PREEMPT);
+   etd = (void *)et;
+   MPASS(etd != NULL);
+   MPASS(etd->et_td == (struct thread *)td);
+#ifdef EPOCH_TRACKER_DEBUG
+   MPASS(etd->et

svn commit: r340405 - head/sys/vm

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 19:44:40 2018
New Revision: 340405
URL: https://svnweb.freebsd.org/changeset/base/340405

Log:
  Add accounting to per-domain UMA full bucket caches.
  
  In particular, track the current size of the cache and maintain an
  estimate of its working set size.  This will be used to decide how
  much to shrink various caches when the kernel attempts to reclaim
  pages.  As a secondary effect, it makes statistics aggregation (done
  by, e.g., vmstat -z) cheaper since sysctl_vm_zone_stats() no longer
  needs to iterate over lists of cached buckets.
  
  Discussed with:   alc, glebius, jeff
  Tested by:pho (previous version)
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D1

Modified:
  head/sys/vm/uma_core.c
  head/sys/vm/uma_int.h

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Tue Nov 13 19:02:11 2018(r340404)
+++ head/sys/vm/uma_core.c  Tue Nov 13 19:44:40 2018(r340405)
@@ -459,7 +459,37 @@ bucket_zone_drain(void)
zone_drain(ubz->ubz_zone);
 }
 
+static uma_bucket_t
+zone_try_fetch_bucket(uma_zone_t zone, uma_zone_domain_t zdom, const bool ws)
+{
+   uma_bucket_t bucket;
+
+   ZONE_LOCK_ASSERT(zone);
+
+   if ((bucket = LIST_FIRST(&zdom->uzd_buckets)) != NULL) {
+   MPASS(zdom->uzd_nitems >= bucket->ub_cnt);
+   LIST_REMOVE(bucket, ub_link);
+   zdom->uzd_nitems -= bucket->ub_cnt;
+   if (ws && zdom->uzd_imin > zdom->uzd_nitems)
+   zdom->uzd_imin = zdom->uzd_nitems;
+   }
+   return (bucket);
+}
+
 static void
+zone_put_bucket(uma_zone_t zone, uma_zone_domain_t zdom, uma_bucket_t bucket,
+const bool ws)
+{
+
+   ZONE_LOCK_ASSERT(zone);
+
+   LIST_INSERT_HEAD(&zdom->uzd_buckets, bucket, ub_link);
+   zdom->uzd_nitems += bucket->ub_cnt;
+   if (ws && zdom->uzd_imax < zdom->uzd_nitems)
+   zdom->uzd_imax = zdom->uzd_nitems;
+}
+
+static void
 zone_log_warning(uma_zone_t zone)
 {
static const struct timeval warninterval = { 300, 0 };
@@ -509,6 +539,23 @@ uma_timeout(void *unused)
 }
 
 /*
+ * Update the working set size estimate for the zone's bucket cache.
+ * The constants chosen here are somewhat arbitrary.  With an update period of
+ * 20s (UMA_TIMEOUT), this estimate is dominated by zone activity over the
+ * last 100s.
+ */
+static void
+zone_domain_update_wss(uma_zone_domain_t zdom)
+{
+   long wss;
+
+   MPASS(zdom->uzd_imax >= zdom->uzd_imin);
+   wss = zdom->uzd_imax - zdom->uzd_imin;
+   zdom->uzd_imax = zdom->uzd_imin = zdom->uzd_nitems;
+   zdom->uzd_wss = (3 * wss + 2 * zdom->uzd_wss) / 5;
+}
+
+/*
  * Routine to perform timeout driven calculations.  This expands the
  * hashes and does per cpu statistics aggregation.
  *
@@ -560,8 +607,14 @@ keg_timeout(uma_keg_t keg)
 static void
 zone_timeout(uma_zone_t zone)
 {
+   int i;
 
zone_foreach_keg(zone, &keg_timeout);
+
+   ZONE_LOCK(zone);
+   for (i = 0; i < vm_ndomains; i++)
+   zone_domain_update_wss(&zone->uz_domain[i]);
+   ZONE_UNLOCK(zone);
 }
 
 /*
@@ -772,16 +825,16 @@ cache_drain_safe_cpu(uma_zone_t zone)
cache = &zone->uz_cpu[curcpu];
if (cache->uc_allocbucket) {
if (cache->uc_allocbucket->ub_cnt != 0)
-   LIST_INSERT_HEAD(&zone->uz_domain[domain].uzd_buckets,
-   cache->uc_allocbucket, ub_link);
+   zone_put_bucket(zone, &zone->uz_domain[domain],
+   cache->uc_allocbucket, false);
else
b1 = cache->uc_allocbucket;
cache->uc_allocbucket = NULL;
}
if (cache->uc_freebucket) {
if (cache->uc_freebucket->ub_cnt != 0)
-   LIST_INSERT_HEAD(&zone->uz_domain[domain].uzd_buckets,
-   cache->uc_freebucket, ub_link);
+   zone_put_bucket(zone, &zone->uz_domain[domain],
+   cache->uc_freebucket, false);
else
b2 = cache->uc_freebucket;
cache->uc_freebucket = NULL;
@@ -844,8 +897,8 @@ bucket_cache_drain(uma_zone_t zone)
 */
for (i = 0; i < vm_ndomains; i++) {
zdom = &zone->uz_domain[i];
-   while ((bucket = LIST_FIRST(&zdom->uzd_buckets)) != NULL) {
-   LIST_REMOVE(bucket, ub_link);
+   while ((bucket = zone_try_fetch_bucket(zone, zdom, false)) !=
+   NULL) {
ZONE_UNLOCK(zone);
bucket_drain(zone, bucket);
bucket_free(zone, bucket, NULL);
@@ -2523,11 +2576,9 @@ zalloc_start:
zdom = &zone->uz_domain[0];
else
zdom = &zone->u

svn commit: r340406 - head/release/scripts

2018-11-13 Thread Glen Barber
Author: gjb
Date: Tue Nov 13 19:51:22 2018
New Revision: 340406
URL: https://svnweb.freebsd.org/changeset/base/340406

Log:
  The roff ascii.gz documentation installed to /usr/share/doc
  was removed in r318881 when roff was removed from the base
  system.
  
  This results in the doc.txz distribution set containing a
  single directory (./) which is empty.
  
  Remove the "Additional documentation" option from the menu
  selection of bsdinstall(8), as the plain-text documentation
  installed in /usr/share/doc is installed as part of the
  packageworld target.
  
  The doc entry has not been removed from EXTRA_DISTRIBUTIONS
  in Makefile.inc1, in case its removal triggers an issue with
  freebsd-update(8), which is currently aware of the world/doc
  component, so the empty doc.txz continues to be created as
  a precaution.
  
  Noticed by:   rgrimes
  MFC after:2 days
  MFC before:   12.0-RC1
  Sponsored by: The FreeBSD Foundation

Modified:
  head/release/scripts/make-manifest.sh

Modified: head/release/scripts/make-manifest.sh
==
--- head/release/scripts/make-manifest.sh   Tue Nov 13 19:44:40 2018
(r340405)
+++ head/release/scripts/make-manifest.sh   Tue Nov 13 19:51:22 2018
(r340406)
@@ -51,6 +51,9 @@ for i in ${*}; do
desc="$(eval echo \"\${desc_${distname}}\")"
 
case ${i} in
+   doc.txz)
+   continue
+   ;;
kernel-dbg.txz)
desc="${desc_kernel_dbg}"
;;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340407 - in head: . release/scripts

2018-11-13 Thread Glen Barber
Author: gjb
Date: Tue Nov 13 19:53:02 2018
New Revision: 340407
URL: https://svnweb.freebsd.org/changeset/base/340407

Log:
  In followup to r340406, remove doc from the EXTRA_DISTRIBUTIONS
  list and remaining references from the script used to create the
  MANIFEST file used by bsdinstall(8).
  
  No MFC is planned at this time.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/Makefile.inc1
  head/release/scripts/make-manifest.sh

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Tue Nov 13 19:51:22 2018(r340406)
+++ head/Makefile.inc1  Tue Nov 13 19:53:02 2018(r340407)
@@ -1287,7 +1287,7 @@ ITOOLS+=makewhatis
 #
 
 # Non-base distributions produced by the base system
-EXTRA_DISTRIBUTIONS=   doc
+EXTRA_DISTRIBUTIONS=
 .if defined(LIBCOMPAT)
 EXTRA_DISTRIBUTIONS+=  lib${libcompat}
 .endif
@@ -1297,7 +1297,7 @@ EXTRA_DISTRIBUTIONS+= tests
 
 DEBUG_DISTRIBUTIONS=
 .if ${MK_DEBUG_FILES} != "no"
-DEBUG_DISTRIBUTIONS+=  base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
+DEBUG_DISTRIBUTIONS+=  base ${EXTRA_DISTRIBUTIONS:S,tests,,}
 .endif
 
 MTREE_MAGIC?=  mtree 2.0

Modified: head/release/scripts/make-manifest.sh
==
--- head/release/scripts/make-manifest.sh   Tue Nov 13 19:51:22 2018
(r340406)
+++ head/release/scripts/make-manifest.sh   Tue Nov 13 19:53:02 2018
(r340407)
@@ -10,7 +10,6 @@
 # $FreeBSD$
 
 base="Base system"
-doc="Additional Documentation"
 kernel="Kernel"
 ports="Ports tree"
 src="System source tree"
@@ -19,7 +18,6 @@ tests="Test suite"
 
 desc_base="${base} (MANDATORY)"
 desc_base_dbg="${base} (Debugging)"
-desc_doc="${doc}"
 desc_kernel="${kernel} (MANDATORY)"
 desc_kernel_dbg="${kernel} (Debugging)"
 desc_kernel_alt="Alternate ${kernel}"
@@ -30,7 +28,6 @@ desc_ports="${ports}"
 desc_src="${src}"
 desc_tests="${tests}"
 
-default_doc=off
 default_src=off
 default_ports=off
 default_tests=off
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340408 - in head: lib/libnv lib/libnv/tests sys/contrib/libnv

2018-11-13 Thread Mark Johnston
Author: markj
Date: Tue Nov 13 20:07:55 2018
New Revision: 340408
URL: https://svnweb.freebsd.org/changeset/base/340408

Log:
  Ensure that libnv can be used when kern.trap_enotcap=1.
  
  libnv used fcntl(fd, F_GETFL) to test whether fd is a valid file
  descriptor.  Aside from being racy, this check requires CAP_FCNTL
  rights on fd.  Instead, use fcntl(fd, F_GETFD), which does not require
  any capability rights.
  
  Also remove some redundant fd_is_valid() checks to avoid extra system
  calls; in many cases we were performing this check immediately before
  dup()ing the descriptor.
  
  Reviewed by:  cem, oshogbo (previous version)
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D17963

Modified:
  head/lib/libnv/common_impl.h
  head/lib/libnv/msgio.c
  head/lib/libnv/tests/nvlist_send_recv_test.c
  head/sys/contrib/libnv/nvpair.c

Modified: head/lib/libnv/common_impl.h
==
--- head/lib/libnv/common_impl.hTue Nov 13 19:53:02 2018
(r340407)
+++ head/lib/libnv/common_impl.hTue Nov 13 20:07:55 2018
(r340408)
@@ -34,6 +34,15 @@
 #ifndef_COMMON_IMPL_H_
 #define_COMMON_IMPL_H_
 
-#definefd_is_valid(fd) (fcntl((fd), F_GETFL) != -1 || errno != EBADF)
+#include 
+#include 
+#include 
+
+static inline bool
+fd_is_valid(int fd)
+{
+
+   return (fcntl(fd, F_GETFD) != -1 || errno != EBADF);
+}
 
 #endif /* !_COMMON_IMPL_H_ */

Modified: head/lib/libnv/msgio.c
==
--- head/lib/libnv/msgio.c  Tue Nov 13 19:53:02 2018(r340407)
+++ head/lib/libnv/msgio.c  Tue Nov 13 20:07:55 2018(r340408)
@@ -66,11 +66,6 @@ msghdr_add_fd(struct cmsghdr *cmsg, int fd)
 
PJDLOG_ASSERT(fd >= 0);
 
-   if (!fd_is_valid(fd)) {
-   errno = EBADF;
-   return (-1);
-   }
-
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));

Modified: head/lib/libnv/tests/nvlist_send_recv_test.c
==
--- head/lib/libnv/tests/nvlist_send_recv_test.cTue Nov 13 19:53:02 
2018(r340407)
+++ head/lib/libnv/tests/nvlist_send_recv_test.cTue Nov 13 20:07:55 
2018(r340408)
@@ -306,15 +306,12 @@ parent(int sock)
CHECK(name == NULL);
 }
 
-int
-main(void)
+static void
+send_nvlist(void)
 {
int status, socks[2];
pid_t pid;
 
-   printf("1..134\n");
-   fflush(stdout);
-
if (socketpair(PF_UNIX, SOCK_STREAM, 0, socks) < 0)
err(1, "socketpair() failed");
pid = fork();
@@ -326,7 +323,7 @@ main(void)
/* Child. */
close(socks[0]);
child(socks[1]);
-   return (0);
+   _exit(0);
default:
/* Parent. */
close(socks[1]);
@@ -336,6 +333,35 @@ main(void)
 
if (waitpid(pid, &status, 0) < 0)
err(1, "waitpid() failed");
+}
+
+static void
+send_closed_fd(void)
+{
+   nvlist_t *nvl;
+   int error, socks[2];
+
+   if (socketpair(PF_UNIX, SOCK_STREAM, 0, socks) < 0)
+   err(1, "socketpair() failed");
+
+   nvl = nvlist_create(0);
+   nvlist_add_descriptor(nvl, "fd", 12345);
+   error = nvlist_error(nvl);
+   CHECK(error == EBADF);
+
+   error = nvlist_send(socks[1], nvl);
+   CHECK(error != 0 && errno == EBADF);
+}
+
+int
+main(void)
+{
+
+   printf("1..136\n");
+   fflush(stdout);
+
+   send_nvlist();
+   send_closed_fd();
 
return (0);
 }

Modified: head/sys/contrib/libnv/nvpair.c
==
--- head/sys/contrib/libnv/nvpair.c Tue Nov 13 19:53:02 2018
(r340407)
+++ head/sys/contrib/libnv/nvpair.c Tue Nov 13 20:07:55 2018
(r340408)
@@ -1276,11 +1276,6 @@ nvpair_create_descriptor(const char *name, int value)
 {
nvpair_t *nvp;
 
-   if (value < 0 || !fd_is_valid(value)) {
-   ERRNO_SET(EBADF);
-   return (NULL);
-   }
-
value = fcntl(value, F_DUPFD_CLOEXEC, 0);
if (value < 0)
return (NULL);
@@ -1517,11 +1512,6 @@ nvpair_create_descriptor_array(const char *name, const
if (value[ii] == -1) {
fds[ii] = -1;
} else {
-   if (!fd_is_valid(value[ii])) {
-   ERRNO_SET(EBADF);
-   goto fail;
-   }
-
fds[ii] = fcntl(value[ii], F_DUPFD_CLOEXEC, 0);
if (fds[ii] == -1)
goto fail;
@@ -2035,10 +2025,6 @@ nvpair_append_descriptor_array(

AN INVESTMENT OFFER.

2018-11-13 Thread Charles Mayiga
Greetings,

We are international project financiers and we specialize in both start up 
projects and existing businesses needing funding or Loan for expansion. We are 
committed to helping businesses develop and succeed.

We will like to partner with you/your company should you be interested or may 
require funding for the expansion of your business. We will be glad to 
receiving your terms and condition before proceeding further.

We are currently seeking means of expanding and relocating our business 
interest and we are open for discussion to any lucrative investments you can 
recommend to us which will be implemented under a blind trust investment 
venture.

Looking forward to hear from you.

Sincere regards,


Charles Mayiga.

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340409 - head/sys/kern

2018-11-13 Thread Eric van Gyzen
Author: vangyzen
Date: Tue Nov 13 20:48:05 2018
New Revision: 340409
URL: https://svnweb.freebsd.org/changeset/base/340409

Log:
  Make no assertions about lock state when the scheduler is stopped.
  
  Change the assert paths in rm, rw, and sx locks to match the lock
  and unlock paths.  I did this for mutexes in r306346.
  
  Reported by:  Travis Lane 
  MFC after:2 weeks
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/kern/kern_rmlock.c
  head/sys/kern/kern_rwlock.c
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_rmlock.c
==
--- head/sys/kern/kern_rmlock.c Tue Nov 13 20:07:55 2018(r340408)
+++ head/sys/kern/kern_rmlock.c Tue Nov 13 20:48:05 2018(r340409)
@@ -742,7 +742,7 @@ _rm_assert(const struct rmlock *rm, int what, const ch
 {
int count;
 
-   if (panicstr != NULL)
+   if (SCHEDULER_STOPPED())
return;
switch (what) {
case RA_LOCKED:

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Tue Nov 13 20:07:55 2018(r340408)
+++ head/sys/kern/kern_rwlock.c Tue Nov 13 20:48:05 2018(r340409)
@@ -1439,7 +1439,7 @@ __rw_assert(const volatile uintptr_t *c, int what, con
 {
const struct rwlock *rw;
 
-   if (panicstr != NULL)
+   if (SCHEDULER_STOPPED())
return;
 
rw = rwlock2rw(c);

Modified: head/sys/kern/kern_sx.c
==
--- head/sys/kern/kern_sx.c Tue Nov 13 20:07:55 2018(r340408)
+++ head/sys/kern/kern_sx.c Tue Nov 13 20:48:05 2018(r340409)
@@ -1416,7 +1416,7 @@ _sx_assert(const struct sx *sx, int what, const char *
int slocked = 0;
 #endif
 
-   if (panicstr != NULL)
+   if (SCHEDULER_STOPPED())
return;
switch (what) {
case SA_SLOCKED:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340410 - head/sys/kern

2018-11-13 Thread Mateusz Guzik
Author: mjg
Date: Tue Nov 13 21:29:56 2018
New Revision: 340410
URL: https://svnweb.freebsd.org/changeset/base/340410

Log:
  locks: plug warnings about unitialized variables
  
  They only showed up after I redefined LOCKSTAT_ENABLED to 0.
  
  doing_lockprof in mutex.c is a real (but harmless) bug. Should the
  value be non-zero it will do checks for lock profiling which would
  otherwise be skipped.
  
  state in rwlock.c is a wart from the compiler, the value can't be
  used if lock profiling is not enabled.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/kern_mutex.c
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_mutex.c
==
--- head/sys/kern/kern_mutex.c  Tue Nov 13 20:48:05 2018(r340409)
+++ head/sys/kern/kern_mutex.c  Tue Nov 13 21:29:56 2018(r340410)
@@ -486,7 +486,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
int64_t all_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-   int doing_lockprof;
+   int doing_lockprof = 0;
 #endif
 
td = curthread;
@@ -690,7 +690,7 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t
int64_t spin_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-   int doing_lockprof;
+   int doing_lockprof = 0;
 #endif
 
tid = (uintptr_t)curthread;

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Tue Nov 13 20:48:05 2018(r340409)
+++ head/sys/kern/kern_rwlock.c Tue Nov 13 21:29:56 2018(r340410)
@@ -445,7 +445,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, 
int64_t all_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-   uintptr_t state;
+   uintptr_t state = 0;
int doing_lockprof = 0;
 #endif
 
@@ -913,7 +913,7 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOC
int64_t all_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-   uintptr_t state;
+   uintptr_t state = 0;
int doing_lockprof = 0;
 #endif
int extra_work = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340411 - in head: lib/libufs sbin/clri sbin/ffsinfo sbin/fsck_ffs sbin/fsirand sbin/growfs sbin/newfs sbin/tunefs sys/ufs/ffs tools/diag/prtblknos

2018-11-13 Thread Kirk McKusick
Author: mckusick
Date: Tue Nov 13 21:40:56 2018
New Revision: 340411
URL: https://svnweb.freebsd.org/changeset/base/340411

Log:
  In preparation for adding inode check-hashes, clean up and
  document the libufs interface for fetching and storing inodes.
  The undocumented getino / putino interface has been replaced
  with a new getinode / putinode interface.
  
  Convert the utilities that had been using the undocumented
  interface to use the new documented interface.
  
  No functional change (as for now the libufs library does not
  do inode check-hashes).
  
  Reviewed by:  kib
  Tested by:Peter Holm
  Sponsored by: Netflix

Added:
  head/lib/libufs/getinode.3   (contents, props changed)
Modified:
  head/lib/libufs/Makefile
  head/lib/libufs/inode.c
  head/lib/libufs/libufs.h
  head/sbin/clri/clri.c
  head/sbin/ffsinfo/ffsinfo.c
  head/sbin/fsck_ffs/dir.c
  head/sbin/fsck_ffs/fsck.h
  head/sbin/fsck_ffs/gjournal.c
  head/sbin/fsck_ffs/inode.c
  head/sbin/fsck_ffs/main.c
  head/sbin/fsck_ffs/pass5.c
  head/sbin/fsirand/fsirand.c
  head/sbin/growfs/growfs.c
  head/sbin/newfs/mkfs.c
  head/sbin/tunefs/tunefs.c
  head/sys/ufs/ffs/ffs_extern.h
  head/sys/ufs/ffs/ffs_inode.c
  head/sys/ufs/ffs/ffs_snapshot.c
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ffs/ffs_subr.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/tools/diag/prtblknos/main.c

Modified: head/lib/libufs/Makefile
==
--- head/lib/libufs/MakefileTue Nov 13 21:29:56 2018(r340410)
+++ head/lib/libufs/MakefileTue Nov 13 21:40:56 2018(r340411)
@@ -3,12 +3,12 @@
 PACKAGE=lib${LIB}
 LIB=   ufs
 SHLIBDIR?= /lib
-SHLIB_MAJOR=   6
+SHLIB_MAJOR=   7
 
 SRCS=  block.c cgroup.c crc32.c inode.c sblock.c type.c ffs_subr.c ffs_tables.c
 INCS=  libufs.h
 
-MAN=   bread.3 cgread.3 libufs.3 sbread.3 ufs_disk_close.3
+MAN=   bread.3 cgread.3 getinode.3 libufs.3 sbread.3 ufs_disk_close.3
 MLINKS+= bread.3 bwrite.3
 MLINKS+= bread.3 berase.3
 MLINKS+= cgread.3 cgread1.3
@@ -16,6 +16,7 @@ MLINKS+= cgread.3 cgget.3
 MLINKS+= cgread.3 cgwrite.3
 MLINKS+= cgread.3 cgwrite1.3
 MLINKS+= cgread.3 cgput.3
+MLINKS+= getinode.3 putinode.3
 MLINKS+= sbread.3 sbwrite.3
 MLINKS+= sbread.3 sbget.3
 MLINKS+= sbread.3 sbput.3

Added: head/lib/libufs/getinode.3
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libufs/getinode.3  Tue Nov 13 21:40:56 2018(r340411)
@@ -0,0 +1,131 @@
+.\" Author:Marshall Kirk McKusick 
+.\" Date:  January 19, 2018
+.\" Description:
+.\"Manual page for libufs functions:
+.\"getinode(3)
+.\"putinode(3)
+.\"
+.\" This file is in the public domain.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd November 10, 2018
+.Dt GETINODE 3
+.Os
+.Sh NAME
+.Nm getinode , putinode
+.Nd fetch and store inodes on a UFS file system
+.Sh LIBRARY
+.Lb libufs
+.Sh SYNOPSIS
+.In ufs/ufs/dinode.h
+.In ufs/ffs/fs.h
+.In libufs.h
+.Ft int
+.Fn getinode "struct uufsd *disk" "union dinodep *dp" "ino_t inumber"
+.Ft int
+.Fn putinode "struct uufsd *disk"
+.Sh DESCRIPTION
+The
+.Fn getinode
+and
+.Fn putinode
+functions provide an inode fetch and store API for
+.Xr libufs 3
+consumers.
+They operate on a userland UFS disk structure.
+The
+.Fn getinode
+function fetches the specified inode from the filesystem.
+The
+.Fn putinode
+function stores the most recently fetched inode to the filesystem.
+.Pp
+The
+.Va dinodep
+union is defined as:
+.Bd -literal -offset indent
+union dinodep {
+   struct ufs1_dinode *dp1;
+   struct ufs2_dinode *dp2;
+};
+.Ed
+.Pp
+Sample code to clear write permissions for inode number
+.Fa inumber
+stored on the filesystem described by
+.Fa diskp .
+.Bd -literal -offset indent
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+void
+clearwrite(struct uufsd *diskp, ino_t inumber)
+{
+   union dinodep dp;
+
+   if (getinode(diskp, &dp, inumber) == -1)
+   err(1, "getinode: %s", diskp->d_error);
+   switch (diskp->d_ufs) {
+   case 1: /* UFS 1 filesystem */
+   dp.dp1->di_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
+   break;
+   case 2: /* UFS 2 filesystem */
+   dp.dp2->di_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
+   break;
+   default:
+   errx(1, "unknown filesystem type");
+   }
+   if (putinode(diskp) == -1)
+   err(1, "putinode: %s", diskp->d_error);
+}
+.Ed
+.Sh RETURN VALUES
+The
+.Fn getinode
+and
+.Fn putinode
+functions return 0 on success, or \-1 in case of any error.
+A string describing the error is stored in
+.Fa diskp->d_error .
+The global
+.Fa errno
+often provides additional information.
+.Sh ERRORS
+The function
+.Fn getinode
+may fail and set
+.Va errno
+for any of the errors specified for the library function
+.Xr pread 2 .
+It can also fail if the inode number is out of the range o

svn commit: r340412 - head/sys/dev/nvme

2018-11-13 Thread Warner Losh
Author: imp
Date: Tue Nov 13 22:41:20 2018
New Revision: 340412
URL: https://svnweb.freebsd.org/changeset/base/340412

Log:
  Use atomic_load_acq_int() here too to poll done, ala r328521

Modified:
  head/sys/dev/nvme/nvme_ns.c

Modified: head/sys/dev/nvme/nvme_ns.c
==
--- head/sys/dev/nvme/nvme_ns.c Tue Nov 13 21:40:56 2018(r340411)
+++ head/sys/dev/nvme/nvme_ns.c Tue Nov 13 22:41:20 2018(r340412)
@@ -535,11 +535,11 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t 
if (!mtx_initialized(&ns->lock))
mtx_init(&ns->lock, "nvme ns lock", NULL, MTX_DEF);
 
-   status.done = FALSE;
+   status.done = 0;
nvme_ctrlr_cmd_identify_namespace(ctrlr, id, &ns->data,
nvme_completion_poll_cb, &status);
-   while (status.done == FALSE)
-   DELAY(5);
+   while (!atomic_load_acq_int(&status.done))
+   pause("nvme", 1);
if (nvme_completion_is_error(&status.cpl)) {
nvme_printf(ctrlr, "nvme_identify_namespace failed\n");
return (ENXIO);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340413 - in head/sys: kern net sys

2018-11-13 Thread Gleb Smirnoff
Author: glebius
Date: Tue Nov 13 22:58:38 2018
New Revision: 340413
URL: https://svnweb.freebsd.org/changeset/base/340413

Log:
  For compatibility KPI functions like if_addr_rlock() that used to have
  mutexes but now are converted to epoch(9) use thread-private epoch_tracker.
  Embedding tracker into ifnet(9) or ifnet derived structures creates a non
  reentrable function, that will fail miserably if called simultaneously from
  two different contexts.
  A thread private tracker will provide a single tracker that would allow to
  call these functions safely. It doesn't allow nested call, but this is not
  expected from compatibility KPIs.
  
  Reviewed by:  markj

Modified:
  head/sys/kern/kern_thread.c
  head/sys/kern/subr_epoch.c
  head/sys/net/if.c
  head/sys/net/if_var.h
  head/sys/sys/epoch.h
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_thread.c
==
--- head/sys/kern/kern_thread.c Tue Nov 13 22:41:20 2018(r340412)
+++ head/sys/kern/kern_thread.c Tue Nov 13 22:58:38 2018(r340413)
@@ -272,6 +272,7 @@ thread_init(void *mem, int size, int flags)
td->td_rlqe = NULL;
EVENTHANDLER_DIRECT_INVOKE(thread_init, td);
umtx_thread_init(td);
+   epoch_thread_init(td);
td->td_kstack = 0;
td->td_sel = NULL;
return (0);
@@ -291,6 +292,7 @@ thread_fini(void *mem, int size)
turnstile_free(td->td_turnstile);
sleepq_free(td->td_sleepqueue);
umtx_thread_fini(td);
+   epoch_thread_fini(td);
seltdfini(td);
 }
 

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Tue Nov 13 22:41:20 2018(r340412)
+++ head/sys/kern/subr_epoch.c  Tue Nov 13 22:58:38 2018(r340413)
@@ -667,3 +667,17 @@ in_epoch(epoch_t epoch)
 {
return (in_epoch_verbose(epoch, 0));
 }
+
+void
+epoch_thread_init(struct thread *td)
+{
+
+   td->td_et = malloc(sizeof(struct epoch_tracker), M_EPOCH, M_WAITOK);
+}
+
+void
+epoch_thread_fini(struct thread *td)
+{
+
+   free(td->td_et, M_EPOCH);
+}

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Tue Nov 13 22:41:20 2018(r340412)
+++ head/sys/net/if.c   Tue Nov 13 22:58:38 2018(r340413)
@@ -1767,35 +1767,29 @@ if_data_copy(struct ifnet *ifp, struct if_data *ifd)
 void
 if_addr_rlock(struct ifnet *ifp)
 {
-   MPASS(*(uint64_t *)&ifp->if_addr_et == 0);
-   epoch_enter_preempt(net_epoch_preempt, &ifp->if_addr_et);
+
+   epoch_enter_preempt(net_epoch_preempt, curthread->td_et);
 }
 
 void
 if_addr_runlock(struct ifnet *ifp)
 {
-   epoch_exit_preempt(net_epoch_preempt, &ifp->if_addr_et);
-#ifdef INVARIANTS
-   bzero(&ifp->if_addr_et, sizeof(struct epoch_tracker));
-#endif
+
+   epoch_exit_preempt(net_epoch_preempt, curthread->td_et);
 }
 
 void
 if_maddr_rlock(if_t ifp)
 {
 
-   MPASS(*(uint64_t *)&ifp->if_maddr_et == 0);
-   epoch_enter_preempt(net_epoch_preempt, &ifp->if_maddr_et);
+   epoch_enter_preempt(net_epoch_preempt, curthread->td_et);
 }
 
 void
 if_maddr_runlock(if_t ifp)
 {
 
-   epoch_exit_preempt(net_epoch_preempt, &ifp->if_maddr_et);
-#ifdef INVARIANTS
-   bzero(&ifp->if_maddr_et, sizeof(struct epoch_tracker));
-#endif
+   epoch_exit_preempt(net_epoch_preempt, curthread->td_et);
 }
 
 /*

Modified: head/sys/net/if_var.h
==
--- head/sys/net/if_var.h   Tue Nov 13 22:41:20 2018(r340412)
+++ head/sys/net/if_var.h   Tue Nov 13 22:58:38 2018(r340413)
@@ -381,8 +381,6 @@ struct ifnet {
 */
struct netdump_methods *if_netdump_methods;
struct epoch_contextif_epoch_ctx;
-   struct epoch_trackerif_addr_et;
-   struct epoch_trackerif_maddr_et;
 
/*
 * Spare fields to be added before branching a stable branch, so

Modified: head/sys/sys/epoch.h
==
--- head/sys/sys/epoch.hTue Nov 13 22:41:20 2018(r340412)
+++ head/sys/sys/epoch.hTue Nov 13 22:58:38 2018(r340413)
@@ -82,5 +82,8 @@ void epoch_exit_preempt(epoch_t epoch, epoch_tracker_t
 void epoch_enter(epoch_t epoch);
 void epoch_exit(epoch_t epoch);
 
+void epoch_thread_init(struct thread *);
+void epoch_thread_fini(struct thread *);
+
 #endif /* _KERNEL */
 #endif /* _SYS_EPOCH_H_ */

Modified: head/sys/sys/proc.h
==
--- head/sys/sys/proc.h Tue Nov 13 22:41:20 2018(r340412)
+++ head/sys/sys/proc.h Tue Nov 13 22:58:38 2018(r340413)
@@ -193,6 +193,7 @@ struct trapframe;
 struct turnstile;
 struct vm_map;
 struct vm_map_entry;
+struct epoch_tracker;
 
 /*
  * XXX: Does 

svn commit: r340414 - head/sys/amd64/conf

2018-11-13 Thread Matt Macy
Author: mmacy
Date: Tue Nov 13 23:08:46 2018
New Revision: 340414
URL: https://svnweb.freebsd.org/changeset/base/340414

Log:
  Add ZFS to amd64 NOTES to catch future breakage of static linking

Modified:
  head/sys/amd64/conf/NOTES

Modified: head/sys/amd64/conf/NOTES
==
--- head/sys/amd64/conf/NOTES   Tue Nov 13 22:58:38 2018(r340413)
+++ head/sys/amd64/conf/NOTES   Tue Nov 13 23:08:46 2018(r340414)
@@ -642,6 +642,11 @@ optionsLINPROCFS
 optionsLINSYSFS
 
 #
+# ZFS support
+
+optionsZFS
+
+#
 # VM OPTIONS
 
 # KSTACK_PAGES is the number of memory pages to assign to the kernel
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-11-13 Thread Gleb Smirnoff
Author: glebius
Date: Tue Nov 13 23:20:55 2018
New Revision: 340415
URL: https://svnweb.freebsd.org/changeset/base/340415

Log:
  The dualism between epoch_tracker and epoch_thread is fragile and
  unnecessary. So, expose CK types to kernel and use a single normal
  structure for epoch_tracker.
  
  Reviewed by:  jtl, gallatin

Modified:
  head/sys/kern/subr_epoch.c
  head/sys/sys/epoch.h

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Tue Nov 13 23:08:46 2018(r340414)
+++ head/sys/kern/subr_epoch.c  Tue Nov 13 23:20:55 2018(r340415)
@@ -55,25 +55,13 @@ __FBSDID("$FreeBSD$");
 
 static MALLOC_DEFINE(M_EPOCH, "epoch", "epoch based reclamation");
 
-typedef struct epoch_thread {
-#ifdef EPOCH_TRACKER_DEBUG
-   uint64_t et_magic_pre;
-#endif
-   TAILQ_ENTRY(epoch_thread) et_link;  /* Epoch queue. */
-   struct thread *et_td;   /* pointer to thread in section */
-   ck_epoch_section_t et_section; /* epoch section object */
-#ifdef EPOCH_TRACKER_DEBUG
-   uint64_t et_magic_post;
-#endif
-} *epoch_thread_t;
-TAILQ_HEAD (epoch_tdlist, epoch_thread);
-
 #ifdef __amd64__
 #define EPOCH_ALIGN CACHE_LINE_SIZE*2
 #else
 #define EPOCH_ALIGN CACHE_LINE_SIZE
 #endif
 
+TAILQ_HEAD (epoch_tdlist, epoch_tracker);
 typedef struct epoch_record {
ck_epoch_record_t er_read_record;
ck_epoch_record_t er_write_record;
@@ -252,27 +240,25 @@ void
 epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
 {
struct epoch_record *er;
-   struct epoch_thread *etd;
struct thread_lite *td;
 
MPASS(cold || epoch != NULL);
INIT_CHECK(epoch);
-   etd = (void *)et;
MPASS(epoch->e_flags & EPOCH_PREEMPT);
 #ifdef EPOCH_TRACKER_DEBUG
-   etd->et_magic_pre = EPOCH_MAGIC0;
-   etd->et_magic_post = EPOCH_MAGIC1;
+   et->et_magic_pre = EPOCH_MAGIC0;
+   et->et_magic_post = EPOCH_MAGIC1;
 #endif
td = (struct thread_lite *)curthread;
-   etd->et_td = (void*)td;
+   et->et_td = (void*)td;
td->td_epochnest++;
critical_enter();
sched_pin_lite(td);
 
td->td_pre_epoch_prio = td->td_priority;
er = epoch_currecord(epoch);
-   TAILQ_INSERT_TAIL(&er->er_tdlist, etd, et_link);
-   ck_epoch_begin(&er->er_read_record, (ck_epoch_section_t 
*)&etd->et_section);
+   TAILQ_INSERT_TAIL(&er->er_tdlist, et, et_link);
+   ck_epoch_begin(&er->er_read_record, &et->et_section);
critical_exit();
 }
 
@@ -296,7 +282,6 @@ void
 epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
 {
struct epoch_record *er;
-   struct epoch_thread *etd;
struct thread_lite *td;
 
INIT_CHECK(epoch);
@@ -307,19 +292,19 @@ epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
td->td_epochnest--;
er = epoch_currecord(epoch);
MPASS(epoch->e_flags & EPOCH_PREEMPT);
-   etd = (void *)et;
-   MPASS(etd != NULL);
-   MPASS(etd->et_td == (struct thread *)td);
+   MPASS(et != NULL);
+   MPASS(et->et_td == (struct thread *)td);
 #ifdef EPOCH_TRACKER_DEBUG
-   MPASS(etd->et_magic_pre == EPOCH_MAGIC0);
-   MPASS(etd->et_magic_post == EPOCH_MAGIC1);
-   etd->et_magic_pre = 0;
-   etd->et_magic_post = 0;
+   MPASS(et->et_magic_pre == EPOCH_MAGIC0);
+   MPASS(et->et_magic_post == EPOCH_MAGIC1);
+   et->et_magic_pre = 0;
+   et->et_magic_post = 0;
 #endif
-   etd->et_td = (void*)0xDEADBEEF;
-   ck_epoch_end(&er->er_read_record,
-   (ck_epoch_section_t *)&etd->et_section);
-   TAILQ_REMOVE(&er->er_tdlist, etd, et_link);
+#ifdef INVARIANTS
+   et->et_td = (void*)0xDEADBEEF;
+#endif
+   ck_epoch_end(&er->er_read_record, &et->et_section);
+   TAILQ_REMOVE(&er->er_tdlist, et, et_link);
er->er_gen++;
if (__predict_false(td->td_pre_epoch_prio != td->td_priority))
epoch_adjust_prio((struct thread *)td, td->td_pre_epoch_prio);
@@ -351,7 +336,7 @@ epoch_block_handler_preempt(struct ck_epoch *global __
 {
epoch_record_t record;
struct thread *td, *owner, *curwaittd;
-   struct epoch_thread *tdwait;
+   struct epoch_tracker *tdwait;
struct turnstile *ts;
struct lock_object *lock;
int spincount, gen;
@@ -633,7 +618,7 @@ epoch_call_task(void *arg __unused)
 int
 in_epoch_verbose(epoch_t epoch, int dump_onfail)
 {
-   struct epoch_thread *tdwait;
+   struct epoch_tracker *tdwait;
struct thread *td;
epoch_record_t er;
 

Modified: head/sys/sys/epoch.h
==
--- head/sys/sys/epoch.hTue Nov 13 23:08:46 2018(r340414)
+++ head/sys/sys/epoch.hTue Nov 13 23:20:55 2018(r340415)
@@ -30,31 +30,16 @@
 #ifndef _SYS_EPOCH_H_
 #define _SYS_EPOCH_H_
 
-/*
- * XXXGL: temporarily keep epoch_tracker 

svn commit: r340416 - head/sbin/dump

2018-11-13 Thread Gleb Smirnoff
Author: glebius
Date: Tue Nov 13 23:44:27 2018
New Revision: 340416
URL: https://svnweb.freebsd.org/changeset/base/340416

Log:
  Plug build break after r340411.

Modified:
  head/sbin/dump/dump.h
  head/sbin/dump/main.c
  head/sbin/dump/traverse.c

Modified: head/sbin/dump/dump.h
==
--- head/sbin/dump/dump.h   Tue Nov 13 23:20:55 2018(r340415)
+++ head/sbin/dump/dump.h   Tue Nov 13 23:44:27 2018(r340416)
@@ -126,7 +126,7 @@ voiddumpabort(int signo) __dead2;
 void   dump_getfstab(void);
 
 char   *rawname(char *cp);
-union  dinode *getinode(ino_t inum, int *mode);
+union  dinode *getinode0(ino_t inum, int *mode);
 
 /* rdump routines */
 #ifdef RDUMP

Modified: head/sbin/dump/main.c
==
--- head/sbin/dump/main.c   Tue Nov 13 23:20:55 2018(r340415)
+++ head/sbin/dump/main.c   Tue Nov 13 23:44:27 2018(r340416)
@@ -549,7 +549,7 @@ main(int argc, char *argv[])
/*
 * Skip directory inodes deleted and maybe reallocated
 */
-   dp = getinode(ino, &mode);
+   dp = getinode0(ino, &mode);
if (mode != IFDIR)
continue;
(void)dumpino(dp, ino);
@@ -568,7 +568,7 @@ main(int argc, char *argv[])
/*
 * Skip inodes deleted and reallocated as directories.
 */
-   dp = getinode(ino, &mode);
+   dp = getinode0(ino, &mode);
if (mode == IFDIR)
continue;
(void)dumpino(dp, ino);

Modified: head/sbin/dump/traverse.c
==
--- head/sbin/dump/traverse.c   Tue Nov 13 23:20:55 2018(r340415)
+++ head/sbin/dump/traverse.c   Tue Nov 13 23:44:27 2018(r340416)
@@ -195,7 +195,7 @@ mapfiles(ino_t maxino, long *tapesize)
}
for (i = 0; i < inosused; i++, ino++) {
if (ino < UFS_ROOTINO ||
-   (dp = getinode(ino, &mode)) == NULL ||
+   (dp = getinode0(ino, &mode)) == NULL ||
(mode & IFMT) == 0)
continue;
if (ino >= maxino) {
@@ -277,7 +277,7 @@ mapdirs(ino_t maxino, long *tapesize)
nodump = !nonodump && (TSTINO(ino, usedinomap) == 0);
if ((isdir & 1) == 0 || (TSTINO(ino, dumpinomap) && !nodump))
continue;
-   dp = getinode(ino, &i);
+   dp = getinode0(ino, &i);
/*
 * inode buf may change in searchdir().
 */
@@ -421,7 +421,7 @@ searchdir(
continue;
}
if (nodump) {
-   ip = getinode(dp->d_ino, &mode);
+   ip = getinode0(dp->d_ino, &mode);
if (TSTINO(dp->d_ino, dumpinomap)) {
CLRINO(dp->d_ino, dumpinomap);
*tapesize -= blockest(ip);
@@ -875,7 +875,7 @@ writeheader(ino_t ino)
 }
 
 union dinode *
-getinode(ino_t inum, int *modep)
+getinode0(ino_t inum, int *modep)
 {
static ino_t minino, maxino;
static caddr_t inoblock;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340417 - head/sys/kern

2018-11-13 Thread Gleb Smirnoff
Author: glebius
Date: Tue Nov 13 23:45:38 2018
New Revision: 340417
URL: https://svnweb.freebsd.org/changeset/base/340417

Log:
  With epoch not inlined, there is no point in using _lite KPI. While here,
  remove some unnecessary casts.

Modified:
  head/sys/kern/genoffset.c
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/genoffset.c
==
--- head/sys/kern/genoffset.c   Tue Nov 13 23:44:27 2018(r340416)
+++ head/sys/kern/genoffset.c   Tue Nov 13 23:45:38 2018(r340417)
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-OFFSYM(td_pre_epoch_prio, thread, u_char);
 OFFSYM(td_priority, thread, u_char);
 OFFSYM(td_epochnest, thread, u_char);
 OFFSYM(td_critnest, thread, u_int);

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Tue Nov 13 23:44:27 2018(r340416)
+++ head/sys/kern/subr_epoch.c  Tue Nov 13 23:45:38 2018(r340417)
@@ -240,7 +240,7 @@ void
 epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
 {
struct epoch_record *er;
-   struct thread_lite *td;
+   struct thread *td;
 
MPASS(cold || epoch != NULL);
INIT_CHECK(epoch);
@@ -249,11 +249,11 @@ epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
et->et_magic_pre = EPOCH_MAGIC0;
et->et_magic_post = EPOCH_MAGIC1;
 #endif
-   td = (struct thread_lite *)curthread;
-   et->et_td = (void*)td;
+   td = curthread;
+   et->et_td = td;
td->td_epochnest++;
critical_enter();
-   sched_pin_lite(td);
+   sched_pin();
 
td->td_pre_epoch_prio = td->td_priority;
er = epoch_currecord(epoch);
@@ -265,12 +265,12 @@ epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
 void
 epoch_enter(epoch_t epoch)
 {
-   struct thread_lite *td;
+   struct thread *td;
epoch_record_t er;
 
MPASS(cold || epoch != NULL);
INIT_CHECK(epoch);
-   td = (struct thread_lite *)curthread;
+   td = curthread;
 
td->td_epochnest++;
critical_enter();
@@ -282,18 +282,18 @@ void
 epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
 {
struct epoch_record *er;
-   struct thread_lite *td;
+   struct thread *td;
 
INIT_CHECK(epoch);
-   td = (struct thread_lite *)curthread;
+   td = curthread;
critical_enter();
-   sched_unpin_lite(td);
+   sched_unpin();
MPASS(td->td_epochnest);
td->td_epochnest--;
er = epoch_currecord(epoch);
MPASS(epoch->e_flags & EPOCH_PREEMPT);
MPASS(et != NULL);
-   MPASS(et->et_td == (struct thread *)td);
+   MPASS(et->et_td == td);
 #ifdef EPOCH_TRACKER_DEBUG
MPASS(et->et_magic_pre == EPOCH_MAGIC0);
MPASS(et->et_magic_post == EPOCH_MAGIC1);
@@ -307,18 +307,18 @@ epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
TAILQ_REMOVE(&er->er_tdlist, et, et_link);
er->er_gen++;
if (__predict_false(td->td_pre_epoch_prio != td->td_priority))
-   epoch_adjust_prio((struct thread *)td, td->td_pre_epoch_prio);
+   epoch_adjust_prio(td, td->td_pre_epoch_prio);
critical_exit();
 }
 
 void
 epoch_exit(epoch_t epoch)
 {
-   struct thread_lite *td;
+   struct thread *td;
epoch_record_t er;
 
INIT_CHECK(epoch);
-   td = (struct thread_lite *)curthread;
+   td = curthread;
MPASS(td->td_epochnest);
td->td_epochnest--;
er = epoch_currecord(epoch);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340418 - head/sys/dev/tws

2018-11-13 Thread Warner Losh
Author: imp
Date: Tue Nov 13 23:53:24 2018
New Revision: 340418
URL: https://svnweb.freebsd.org/changeset/base/340418

Log:
  Remove support for versions prior to FreeBSD 7.0 from twa(4)
  
  This was for pre-7.0 CAM support. Neither the CAM nor the busdma
  changes over the years have not been ifdef'd. The code cannot build
  on 6.x anymore. Support for 6.4 ended in 2010, so remove them.

Modified:
  head/sys/dev/tws/tws.c
  head/sys/dev/tws/tws_cam.c
  head/sys/dev/tws/tws_services.h

Modified: head/sys/dev/tws/tws.c
==
--- head/sys/dev/tws/tws.c  Tue Nov 13 23:45:38 2018(r340417)
+++ head/sys/dev/tws/tws.c  Tue Nov 13 23:53:24 2018(r340418)
@@ -445,9 +445,7 @@ tws_setup_intr(struct tws_softc *sc, int irqs)
 if (!(sc->intr_handle[i])) {
 if ((error = bus_setup_intr(sc->tws_dev, sc->irq_res[i],
 INTR_TYPE_CAM | INTR_MPSAFE,
-#if (__FreeBSD_version >= 70)
 NULL, 
-#endif
 tws_intr, sc, &sc->intr_handle[i]))) {
 tws_log(sc, SETUP_INTR_RES);
 return(FAILURE);

Modified: head/sys/dev/tws/tws_cam.c
==
--- head/sys/dev/tws/tws_cam.c  Tue Nov 13 23:45:38 2018(r340417)
+++ head/sys/dev/tws/tws_cam.c  Tue Nov 13 23:53:24 2018(r340418)
@@ -160,9 +160,7 @@ tws_cam_attach(struct tws_softc *sc)
 */
 sc->sim = cam_sim_alloc(tws_action, tws_poll, "tws", sc,
   device_get_unit(sc->tws_dev), 
-#if (__FreeBSD_version >= 70)
   &sc->sim_lock,
-#endif
   tws_cam_depth, 1, devq);
   /* 1, 1, devq); */
 if (sc->sim == NULL) {
@@ -172,9 +170,7 @@ tws_cam_attach(struct tws_softc *sc)
 /* Register the bus. */
 mtx_lock(&sc->sim_lock);
 if (xpt_bus_register(sc->sim, 
-#if (__FreeBSD_version >= 70)
  sc->tws_dev, 
-#endif
  0) != CAM_SUCCESS) {
 cam_sim_free(sc->sim, TRUE); /* passing true will free the devq */
 sc->sim = NULL; /* so cam_detach will not try to free it */
@@ -269,7 +265,6 @@ tws_action(struct cam_sim *sim, union ccb *ccb)
 {
 TWS_TRACE_DEBUG(sc, "get tran settings", sim, ccb);
 
-#if (__FreeBSD_version >= 70 )
 ccb->cts.protocol = PROTO_SCSI;
 ccb->cts.protocol_version = SCSI_REV_2;
 ccb->cts.transport = XPORT_SPI;
@@ -279,10 +274,6 @@ tws_action(struct cam_sim *sim, union ccb *ccb)
 ccb->cts.xport_specific.spi.flags = CTS_SPI_FLAGS_DISC_ENB;
 ccb->cts.proto_specific.scsi.valid = CTS_SCSI_VALID_TQ;
 ccb->cts.proto_specific.scsi.flags = CTS_SCSI_FLAGS_TAG_ENB;
-#else
-ccb->cts.valid = (CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID);
-ccb->cts.flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB);
-#endif
 ccb->ccb_h.status = CAM_REQ_CMP;
 xpt_done(ccb);
 
@@ -314,13 +305,11 @@ tws_action(struct cam_sim *sim, union ccb *ccb)
 strlcpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN);
 strlcpy(ccb->cpi.hba_vid, "3ware", HBA_IDLEN);
 strlcpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN);
-#if (__FreeBSD_version >= 70 )
 ccb->cpi.transport = XPORT_SPI;
 ccb->cpi.transport_version = 2;
 ccb->cpi.protocol = PROTO_SCSI;
 ccb->cpi.protocol_version = SCSI_REV_2;
 ccb->cpi.maxio = TWS_MAX_IO_SIZE;
-#endif
 ccb->ccb_h.status = CAM_REQ_CMP;
 xpt_done(ccb);
 

Modified: head/sys/dev/tws/tws_services.h
==
--- head/sys/dev/tws/tws_services.h Tue Nov 13 23:45:38 2018
(r340417)
+++ head/sys/dev/tws/tws_services.h Tue Nov 13 23:53:24 2018
(r340418)
@@ -131,12 +131,5 @@ struct error_desc {
 
 
 /*  */
-#if (__FreeBSD_version >= 70)
 #include 
 #define TWS_LOCAL_TIME (time_second - utc_offset())
-#else
-#include 
-#define TWS_LOCAL_TIME (time_second - (tz_minuteswest * 60) -   \
-  (wall_cmos_clock ? adjkerntz : 0))
-#endif
-
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340419 - head/sys/kern

2018-11-13 Thread Gleb Smirnoff
Author: glebius
Date: Tue Nov 13 23:57:34 2018
New Revision: 340419
URL: https://svnweb.freebsd.org/changeset/base/340419

Log:
  style(9), mostly adjusting overly long lines.

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Tue Nov 13 23:53:24 2018(r340418)
+++ head/sys/kern/subr_epoch.c  Tue Nov 13 23:57:34 2018(r340419)
@@ -141,11 +141,15 @@ epoch_init(void *arg __unused)
epoch_call_count = counter_u64_alloc(M_WAITOK);
epoch_call_task_count = counter_u64_alloc(M_WAITOK);
 
-   pcpu_zone_record = uma_zcreate("epoch_record pcpu", sizeof(struct 
epoch_record),
-   NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
+   pcpu_zone_record = uma_zcreate("epoch_record pcpu",
+   sizeof(struct epoch_record), NULL, NULL, NULL, NULL,
+   UMA_ALIGN_PTR, UMA_ZONE_PCPU);
CPU_FOREACH(cpu) {
-   GROUPTASK_INIT(DPCPU_ID_PTR(cpu, epoch_cb_task), 0, 
epoch_call_task, NULL);
-   taskqgroup_attach_cpu(qgroup_softirq, DPCPU_ID_PTR(cpu, 
epoch_cb_task), NULL, cpu, -1, "epoch call task");
+   GROUPTASK_INIT(DPCPU_ID_PTR(cpu, epoch_cb_task), 0,
+   epoch_call_task, NULL);
+   taskqgroup_attach_cpu(qgroup_softirq,
+   DPCPU_ID_PTR(cpu, epoch_cb_task), NULL, cpu, -1,
+   "epoch call task");
}
inited = 1;
global_epoch = epoch_alloc(0);
@@ -327,12 +331,12 @@ epoch_exit(epoch_t epoch)
 }
 
 /*
- * epoch_block_handler_preempt is a callback from the ck code when another 
thread is
- * currently in an epoch section.
+ * epoch_block_handler_preempt() is a callback from the CK code when another
+ * thread is currently in an epoch section.
  */
 static void
-epoch_block_handler_preempt(struct ck_epoch *global __unused, 
ck_epoch_record_t *cr,
-void *arg __unused)
+epoch_block_handler_preempt(struct ck_epoch *global __unused,
+ck_epoch_record_t *cr, void *arg __unused)
 {
epoch_record_t record;
struct thread *td, *owner, *curwaittd;
@@ -424,25 +428,27 @@ epoch_block_handler_preempt(struct ck_epoch *global __
if (TD_IS_INHIBITED(curwaittd) && TD_ON_LOCK(curwaittd) &&
((ts = curwaittd->td_blocked) != NULL)) {
/*
-* We unlock td to allow turnstile_wait to reacquire the
-* the thread lock. Before unlocking it we enter a 
critical
-* section to prevent preemption after we reenable 
interrupts
-* by dropping the thread lock in order to prevent 
curwaittd
-* from getting to run.
+* We unlock td to allow turnstile_wait to reacquire
+* the thread lock. Before unlocking it we enter a
+* critical section to prevent preemption after we
+* reenable interrupts by dropping the thread lock in
+* order to prevent curwaittd from getting to run.
 */
critical_enter();
thread_unlock(td);
owner = turnstile_lock(ts, &lock);
/*
-* The owner pointer indicates that the lock succeeded. 
Only
-* in case we hold the lock and the turnstile we locked 
is still
-* the one that curwaittd is blocked on can we 
continue. Otherwise
-* The turnstile pointer has been changed out from 
underneath
-* us, as in the case where the lock holder has 
signalled curwaittd,
+* The owner pointer indicates that the lock succeeded.
+* Only in case we hold the lock and the turnstile we
+* locked is still the one that curwaittd is blocked on
+* can we continue. Otherwise the turnstile pointer has
+* been changed out from underneath us, as in the case
+* where the lock holder has signalled curwaittd,
 * and we need to continue.
 */
if (owner != NULL && ts == curwaittd->td_blocked) {
-   MPASS(TD_IS_INHIBITED(curwaittd) && 
TD_ON_LOCK(curwaittd));
+   MPASS(TD_IS_INHIBITED(curwaittd) &&
+   TD_ON_LOCK(curwaittd));
critical_exit();
turnstile_wait(ts, owner, 
curwaittd->td_tsqueue);
counter_u64_add(turnstile_count, 1);
@@ -492,9 +498,8 @@ epoch_wait_preempt(epoch_t epoch)
if ((epoch->e_flags & EPOCH_LOCKED) == 0)

svn commit: r340420 - head/sys/kern

2018-11-13 Thread Matt Macy
Author: mmacy
Date: Wed Nov 14 00:12:04 2018
New Revision: 340420
URL: https://svnweb.freebsd.org/changeset/base/340420

Log:
  epoch(9) revert r340097 - no longer a need for multiple sections per cpu
  
  I spoke with Samy Bahra and recent changes to CK to make ck_epoch_call and
  ck_epoch_poll not modify the record have eliminated the need for this.

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Tue Nov 13 23:57:34 2018(r340419)
+++ head/sys/kern/subr_epoch.c  Wed Nov 14 00:12:04 2018(r340420)
@@ -63,8 +63,7 @@ static MALLOC_DEFINE(M_EPOCH, "epoch", "epoch based re
 
 TAILQ_HEAD (epoch_tdlist, epoch_tracker);
 typedef struct epoch_record {
-   ck_epoch_record_t er_read_record;
-   ck_epoch_record_t er_write_record;
+   ck_epoch_record_t er_record;
volatile struct epoch_tdlist er_tdlist;
volatile uint32_t er_gen;
uint32_t er_cpuid;
@@ -176,8 +175,7 @@ epoch_ctor(epoch_t epoch)
CPU_FOREACH(cpu) {
er = zpcpu_get_cpu(epoch->e_pcpu_record, cpu);
bzero(er, sizeof(*er));
-   ck_epoch_register(&epoch->e_epoch, &er->er_read_record, NULL);
-   ck_epoch_register(&epoch->e_epoch, &er->er_write_record, NULL);
+   ck_epoch_register(&epoch->e_epoch, &er->er_record, NULL);
TAILQ_INIT((struct threadlist *)(uintptr_t)&er->er_tdlist);
er->er_cpuid = cpu;
}
@@ -262,7 +260,7 @@ epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
td->td_pre_epoch_prio = td->td_priority;
er = epoch_currecord(epoch);
TAILQ_INSERT_TAIL(&er->er_tdlist, et, et_link);
-   ck_epoch_begin(&er->er_read_record, &et->et_section);
+   ck_epoch_begin(&er->er_record, &et->et_section);
critical_exit();
 }
 
@@ -279,7 +277,7 @@ epoch_enter(epoch_t epoch)
td->td_epochnest++;
critical_enter();
er = epoch_currecord(epoch);
-   ck_epoch_begin(&er->er_read_record, NULL);
+   ck_epoch_begin(&er->er_record, NULL);
 }
 
 void
@@ -307,7 +305,7 @@ epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
 #ifdef INVARIANTS
et->et_td = (void*)0xDEADBEEF;
 #endif
-   ck_epoch_end(&er->er_read_record, &et->et_section);
+   ck_epoch_end(&er->er_record, &et->et_section);
TAILQ_REMOVE(&er->er_tdlist, et, et_link);
er->er_gen++;
if (__predict_false(td->td_pre_epoch_prio != td->td_priority))
@@ -326,7 +324,7 @@ epoch_exit(epoch_t epoch)
MPASS(td->td_epochnest);
td->td_epochnest--;
er = epoch_currecord(epoch);
-   ck_epoch_end(&er->er_read_record, NULL);
+   ck_epoch_end(&er->er_record, NULL);
critical_exit();
 }
 
@@ -346,7 +344,7 @@ epoch_block_handler_preempt(struct ck_epoch *global __
int spincount, gen;
int locksheld __unused;
 
-   record = __containerof(cr, struct epoch_record, er_read_record);
+   record = __containerof(cr, struct epoch_record, er_record);
td = curthread;
locksheld = td->td_locks;
spincount = 0;
@@ -574,7 +572,7 @@ epoch_call(epoch_t epoch, epoch_context_t ctx, void (*
critical_enter();
*DPCPU_PTR(epoch_cb_count) += 1;
er = epoch_currecord(epoch);
-   ck_epoch_call(&er->er_write_record, cb, (ck_epoch_cb_t *)callback);
+   ck_epoch_call(&er->er_record, cb, (ck_epoch_cb_t *)callback);
critical_exit();
return;
 boottime:
@@ -598,7 +596,7 @@ epoch_call_task(void *arg __unused)
if (__predict_false((epoch = allepochs[i]) == NULL))
continue;
er = epoch_currecord(epoch);
-   record = &er->er_write_record;
+   record = &er->er_record;
if ((npending = record->n_pending) == 0)
continue;
ck_epoch_poll_deferred(record, &cb_stack);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340421 - head/usr.sbin/cpucontrol

2018-11-13 Thread Conrad Meyer
Author: cem
Date: Wed Nov 14 00:21:49 2018
New Revision: 340421
URL: https://svnweb.freebsd.org/changeset/base/340421

Log:
  cpucontrol(8): De-duplicate common update logic
  
  Every µcode-updater must open the cpucontrol devfs node RDWR, open a
  firmware file, validate the FW file has a positive length, mmap it, etc.
  De-duplicate that identical logic between every individual platform.
  
  Also, constify references to the readonly-mapped firmware files while here.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/usr.sbin/cpucontrol/amd.c
  head/usr.sbin/cpucontrol/amd10h.c
  head/usr.sbin/cpucontrol/cpucontrol.c
  head/usr.sbin/cpucontrol/cpucontrol.h
  head/usr.sbin/cpucontrol/intel.c
  head/usr.sbin/cpucontrol/via.c

Modified: head/usr.sbin/cpucontrol/amd.c
==
--- head/usr.sbin/cpucontrol/amd.c  Wed Nov 14 00:12:04 2018
(r340420)
+++ head/usr.sbin/cpucontrol/amd.c  Wed Nov 14 00:21:49 2018
(r340421)
@@ -73,16 +73,16 @@ amd_probe(int fd)
 }
 
 void
-amd_update(const char *dev, const char *path)
+amd_update(const struct ucode_update_params *params)
 {
-   int fd, devfd;
+   int devfd;
unsigned int i;
-   struct stat st;
-   uint32_t *fw_image;
-   amd_fw_header_t *fw_header;
+   const char *dev, *path;
+   const uint32_t *fw_image;
+   const amd_fw_header_t *fw_header;
uint32_t sum;
uint32_t signature;
-   uint32_t *fw_data;
+   const uint32_t *fw_data;
size_t fw_size;
cpuctl_cpuid_args_t idargs = {
.level  = 1,/* Request signature. */
@@ -90,16 +90,14 @@ amd_update(const char *dev, const char *path)
cpuctl_update_args_t args;
int error;
 
+   dev = params->dev_path;
+   path = params->fw_path;
+   devfd = params->devfd;
+   fw_image = params->fwimage;
+
assert(path);
assert(dev);
 
-   fd  = -1;
-   fw_image = MAP_FAILED;
-   devfd = open(dev, O_RDWR);
-   if (devfd < 0) {
-   WARN(0, "could not open %s for writing", dev);
-   return;
-   }
error = ioctl(devfd, CPUCTL_CPUID, &idargs);
if (error < 0) {
WARN(0, "ioctl()");
@@ -115,37 +113,18 @@ amd_update(const char *dev, const char *path)
/*
 * Open the firmware file.
 */
-   fd = open(path, O_RDONLY, 0);
-   if (fd < 0) {
-   WARN(0, "open(%s)", path);
-   goto fail;
-   }
-   error = fstat(fd, &st);
-   if (error != 0) {
-   WARN(0, "fstat(%s)", path);
-   goto fail;
-   }
-   if (st.st_size < 0 || (unsigned)st.st_size < sizeof(*fw_header)) {
+   if (params->fwsize < sizeof(*fw_header)) {
WARNX(2, "file too short: %s", path);
goto fail;
}
-   /*
-* mmap the whole image.
-*/
-   fw_image = (uint32_t *)mmap(NULL, st.st_size, PROT_READ,
-   MAP_PRIVATE, fd, 0);
-   if  (fw_image == MAP_FAILED) {
-   WARN(0, "mmap(%s)", path);
-   goto fail;
-   }
-   fw_header = (amd_fw_header_t *)fw_image;
+   fw_header = (const amd_fw_header_t *)fw_image;
if ((fw_header->magic >> 8) != AMD_MAGIC) {
WARNX(2, "%s is not a valid amd firmware: version mismatch",
path);
goto fail;
}
-   fw_data = (uint32_t *)(fw_header + 1);
-   fw_size = (st.st_size - sizeof(*fw_header)) / sizeof(uint32_t);
+   fw_data = (const uint32_t *)(fw_header + 1);
+   fw_size = (params->fwsize - sizeof(*fw_header)) / sizeof(uint32_t);
 
/*
 * Check the primary checksum.
@@ -160,8 +139,8 @@ amd_update(const char *dev, const char *path)
if (signature == fw_header->signature) {
fprintf(stderr, "%s: updating cpu %s... ", path, dev);
 
-   args.data = fw_image;
-   args.size = st.st_size;
+   args.data = __DECONST(void *, fw_image);
+   args.size = params->fwsize;
error = ioctl(devfd, CPUCTL_UPDATE, &args);
if (error < 0) {
fprintf(stderr, "failed.\n");
@@ -172,12 +151,5 @@ amd_update(const char *dev, const char *path)
}
 
 fail:
-   if (fd >= 0)
-   close(fd);
-   if (devfd >= 0)
-   close(devfd);
-   if (fw_image != MAP_FAILED)
-   if(munmap(fw_image, st.st_size) != 0)
-   warn("munmap(%s)", path);
return;
 }

Modified: head/usr.sbin/cpucontrol/amd10h.c
==
--- head/usr.sbin/cpucontrol/amd10h.c   Wed Nov 14 00:12:04 2018
(r340420)
+++ head/usr.sbin/cpucontrol/amd10h.c   Wed Nov 14 00:21:49 2018
(r340421)
@@ -88,9 +88,8 @@ amd10h_probe(int fd)
  * source code.
  */
 void

svn commit: r340422 - head/sbin/dump

2018-11-13 Thread Kirk McKusick
Author: mckusick
Date: Wed Nov 14 00:21:52 2018
New Revision: 340422
URL: https://svnweb.freebsd.org/changeset/base/340422

Log:
  Fix build break from dump incompatibility I introduced in -r340411
  
  Pointy-hat to: mckusick

Modified:
  head/sbin/dump/dump.h
  head/sbin/dump/main.c
  head/sbin/dump/traverse.c

Modified: head/sbin/dump/dump.h
==
--- head/sbin/dump/dump.h   Wed Nov 14 00:21:49 2018(r340421)
+++ head/sbin/dump/dump.h   Wed Nov 14 00:21:52 2018(r340422)
@@ -126,7 +126,7 @@ voiddumpabort(int signo) __dead2;
 void   dump_getfstab(void);
 
 char   *rawname(char *cp);
-union  dinode *getinode0(ino_t inum, int *mode);
+union  dinode *getino(ino_t inum, int *mode);
 
 /* rdump routines */
 #ifdef RDUMP

Modified: head/sbin/dump/main.c
==
--- head/sbin/dump/main.c   Wed Nov 14 00:21:49 2018(r340421)
+++ head/sbin/dump/main.c   Wed Nov 14 00:21:52 2018(r340422)
@@ -549,7 +549,7 @@ main(int argc, char *argv[])
/*
 * Skip directory inodes deleted and maybe reallocated
 */
-   dp = getinode0(ino, &mode);
+   dp = getino(ino, &mode);
if (mode != IFDIR)
continue;
(void)dumpino(dp, ino);
@@ -568,7 +568,7 @@ main(int argc, char *argv[])
/*
 * Skip inodes deleted and reallocated as directories.
 */
-   dp = getinode0(ino, &mode);
+   dp = getino(ino, &mode);
if (mode == IFDIR)
continue;
(void)dumpino(dp, ino);

Modified: head/sbin/dump/traverse.c
==
--- head/sbin/dump/traverse.c   Wed Nov 14 00:21:49 2018(r340421)
+++ head/sbin/dump/traverse.c   Wed Nov 14 00:21:52 2018(r340422)
@@ -195,7 +195,7 @@ mapfiles(ino_t maxino, long *tapesize)
}
for (i = 0; i < inosused; i++, ino++) {
if (ino < UFS_ROOTINO ||
-   (dp = getinode0(ino, &mode)) == NULL ||
+   (dp = getino(ino, &mode)) == NULL ||
(mode & IFMT) == 0)
continue;
if (ino >= maxino) {
@@ -277,7 +277,7 @@ mapdirs(ino_t maxino, long *tapesize)
nodump = !nonodump && (TSTINO(ino, usedinomap) == 0);
if ((isdir & 1) == 0 || (TSTINO(ino, dumpinomap) && !nodump))
continue;
-   dp = getinode0(ino, &i);
+   dp = getino(ino, &i);
/*
 * inode buf may change in searchdir().
 */
@@ -421,7 +421,7 @@ searchdir(
continue;
}
if (nodump) {
-   ip = getinode0(dp->d_ino, &mode);
+   ip = getino(dp->d_ino, &mode);
if (TSTINO(dp->d_ino, dumpinomap)) {
CLRINO(dp->d_ino, dumpinomap);
*tapesize -= blockest(ip);
@@ -875,7 +875,7 @@ writeheader(ino_t ino)
 }
 
 union dinode *
-getinode0(ino_t inum, int *modep)
+getino(ino_t inum, int *modep)
 {
static ino_t minino, maxino;
static caddr_t inoblock;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340423 - head/sys/kern

2018-11-13 Thread Gleb Smirnoff
Author: glebius
Date: Wed Nov 14 00:33:03 2018
New Revision: 340423
URL: https://svnweb.freebsd.org/changeset/base/340423

Log:
  Fix build on some architectures after r340413. On amd64 epoch.h
  appeared to be included implicitly.

Modified:
  head/sys/kern/kern_thread.c

Modified: head/sys/kern/kern_thread.c
==
--- head/sys/kern/kern_thread.c Wed Nov 14 00:21:52 2018(r340422)
+++ head/sys/kern/kern_thread.c Wed Nov 14 00:33:03 2018(r340423)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340424 - in head/sys: compat/freebsd32 kern

2018-11-13 Thread Brooks Davis
Author: brooks
Date: Wed Nov 14 00:46:02 2018
New Revision: 340424
URL: https://svnweb.freebsd.org/changeset/base/340424

Log:
  Use the main capabilities.conf for freebsd32.
  
  Allow the location of capabilities.conf to be configured.
  
  Also allow a per-abi syscall prefix to be configured with the
  abi_func_prefix syscalls.conf variable and check syscalls against
  entries in capabilities.conf with and without the prefix amended.
  
  Take advantage of these two features to allow use shared capabilities.conf
  between the default syscall vector and the freebsd32 compatability
  layer.  We've been inconsistent about keeping the two in sync as
  evidenced by the bugs fixed in r340294.  This eliminates that problem
  going forward.
  
  Reviewed by:  kib
  Obtained from:CheriBSD
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D17932

Deleted:
  head/sys/compat/freebsd32/capabilities.conf
Modified:
  head/sys/compat/freebsd32/Makefile
  head/sys/compat/freebsd32/syscalls.conf
  head/sys/kern/makesyscalls.sh

Modified: head/sys/compat/freebsd32/Makefile
==
--- head/sys/compat/freebsd32/Makefile  Wed Nov 14 00:33:03 2018
(r340423)
+++ head/sys/compat/freebsd32/Makefile  Wed Nov 14 00:46:02 2018
(r340424)
@@ -11,7 +11,7 @@ all:
 sysent:  freebsd32_sysent.c freebsd32_syscall.h freebsd32_proto.h 
freebsd32_systrace_args.c
 
 freebsd32_sysent.c freebsd32_syscalls.c freebsd32_syscall.h freebsd32_proto.h 
freebsd32_systrace_args.c : \
-   ../../kern/makesyscalls.sh syscalls.master syscalls.conf 
capabilities.conf
+   ../../kern/makesyscalls.sh syscalls.master syscalls.conf 
../../kern/capabilities.conf
sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf
 
 clean:

Modified: head/sys/compat/freebsd32/syscalls.conf
==
--- head/sys/compat/freebsd32/syscalls.conf Wed Nov 14 00:33:03 2018
(r340423)
+++ head/sys/compat/freebsd32/syscalls.conf Wed Nov 14 00:46:02 2018
(r340424)
@@ -9,3 +9,5 @@ syscallprefix="FREEBSD32_SYS_"
 switchname="freebsd32_sysent"
 namesname="freebsd32_syscallnames"
 systrace="freebsd32_systrace_args.c"
+abi_func_prefix="freebsd32_"
+capabilities_conf="../../kern/capabilities.conf"

Modified: head/sys/kern/makesyscalls.sh
==
--- head/sys/kern/makesyscalls.sh   Wed Nov 14 00:33:03 2018
(r340423)
+++ head/sys/kern/makesyscalls.sh   Wed Nov 14 00:46:02 2018
(r340424)
@@ -45,14 +45,8 @@ sysarg="sysarg.switch.$$"
 sysprotoend="sysprotoend.$$"
 systracetmp="systrace.$$"
 systraceret="systraceret.$$"
+capabilities_conf="capabilities.conf"
 
-if [ -r capabilities.conf ]; then
-   capenabled=`egrep -v '^#|^$' capabilities.conf`
-   capenabled=`echo $capenabled | sed 's/ /,/g'`
-else
-   capenabled=""
-fi
-
 trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl 
$syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 
$syscompat10dcl $syscompat11 $syscompat11dcl $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
@@ -67,6 +61,13 @@ if [ -n "$2" ]; then
. $2
 fi
 
+if [ -r $capabilities_conf ]; then
+   capenabled=`egrep -v '^#|^$' $capabilities_conf`
+   capenabled=`echo $capenabled | sed 's/ /,/g'`
+else
+   capenabled=""
+fi
+
 sed -e '
# FreeBSD ID, includes, comments, and blank lines
/.*\$FreeBSD/b done_joining
@@ -137,6 +138,7 @@ sed -e '
switchname = \"$switchname\"
namesname = \"$namesname\"
infile = \"$1\"
+   abi_func_prefix = \"$abi_func_prefix\"
capenabled_string = \"$capenabled\"
"'
 
@@ -381,7 +383,8 @@ sed -e '
# from it.
#
for (cap in capenabled) {
-   if (funcname == capenabled[cap]) {
+   if (funcname == capenabled[cap] ||
+   funcname == abi_func_prefix capenabled[cap]) {
flags = "SYF_CAPENABLED";
break;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r337334 - head/lib/libc/sys

2018-11-13 Thread Warner Losh
On Sun, Aug 5, 2018 at 6:46 PM Bruce Evans  wrote:

> On Mon, 6 Aug 2018, Bruce Evans wrote:
>
> > ...
> > I forgot about FAT times, and only remembered that utc_offset() was used
> > for RTC drivers.  I thought that utc_offset() is 0 unless something sets
> > the timezone to nonzero or the RTC is on local time (wall_cmos_clock
> case).
> > However, since the kernel needs the timezone for FAT times, it must be
> > known even if the RTC is on UTC time.  Now I don't see how FAT times can
> > even work unless the wall_cmos_clock.  They are just the UTC minus
> > utc_offset(), where utc_offset() is
> >
> >   (tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0))
> >
> > Here wall_cmos_clock is only for managing the RTC offset.  It must be 0
> > unless the RTC is on local time.  But then either FAT times or RTC times
> > must be broken except in the Greenwich meridian.  Otherwise,
> tz_minuteswest
> > must be nonzero to ajust FAT times right, but this makes utc_offset()
> > unusable for the RTC offset.
>
> I verified the brokenness:
> - adjkerntz() normally leaves tz_minuteswest as 0.  I verified that it does
>this when there is a nonzero dst adjustment.  dst adjustments are folded
>into machdep.adjkerntz.
>

Right. adjkerntz() was supposed to completely replace tz_minuteswest.


> - when wall_cmos_clock == 0, adjkerntz(8) does little or nothing, so all
>adjustments are 0, so utc_offset() is 0, so FAT times are broken except
>in the Greenwich meridian.
>
> The broken FAT times are not completely obvious, since getting and setting
> them use the same wrong offset of 0, so the times appear to be correct when
> displayed on FreeBSD.  The are only obviously wrong when displayed on
> another
> system with non-broken FAT times, perhaps by rebooting to the other system
> or by moving removable media to such a system.
>
> FAT times are used by other file systems.  I checked this in FreeBSD-9
> so as to find axed file systems.  The were used by smbfs, nwfs and msdosfs.
> Now they are only used by msdosfs.  I never liked de-deduplicating their
> implementation into an over-engineered version with especially excessive
> handling for leap years.  Leap year handling is unimportant compared with
> offset handling.
>

And tz_minuteswest won't fix this, except on a single user system. And it
is duplicative of adjkerntz.


> tz_minuteswest is used by compatibility code.  It cannot usefully be
> removed from the native version, since non-native syscalls use it and
> non-native applications might use it.  Of course, it must have a correct
> value to work in compatibility.  Its normal value of 0 breaks compatibility
> code much like the bugs in utc_offset() breaks FAT time.  It is used in the
> following compatibility code:
> - amd64 linux32 linux_gettimeofday().  Like native gettimeofday().  It also
>reconstructs the dstflag part of the timezone struct.  If linux drops
> this,
>then strict compatiility requires the support to depend on the linux
> version.
> - amd64 linux32 linux_settimeofday().  Like native settimeofday().  Has
>invisible reference to tz_minuteswest hidden in assignment of timezones.
>I only grepped for tz_minuteswest and only checked this indirect
> reference.
> - freebsd32 freebsd32_gettimeofday().  Similarly, except we control it, so
>can avoid needing version checks by not dropping support.
> - dev/tws/tws_services.h.  This uses utc_offset() for FreeBSD-7 and later,
>and its reference to tz_minuteswest is only explicit for older versions
>where it open-codes utc_offset() with bug for bug compatibility except
> for
>adding style bugs.
> - smbfs.  This uses FAT times, and in nearby code it uses tzoff for the
> offset
>and has commented-out code with an open-coded fully-buggy utc_offset().
> - ibcs2 xenix_ftime().  This is similar to gettimeofday().
>

All of these are somewhat irrelevant. If anybody really cares about these
cases, they can fix them to use the adjkerntz() facility (or in the case of
tws, just remove the bogus code).

The question is, does anybody use this feature? It's been obsolete for 2
decades and we should just remove it.

Warner
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340425 - in head/sys/dev: amdsmn amdtemp

2018-11-13 Thread Conrad Meyer
Author: cem
Date: Wed Nov 14 03:42:39 2018
New Revision: 340425
URL: https://svnweb.freebsd.org/changeset/base/340425

Log:
  amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges
  
  As reported, tested, and patch supplied by Johannes.
  
  There may be future work to do to support multiple sensors, but for now, any
  sensor at all is a strict improvement for Ryzen 2 systems.
  
  PR:   228480
  Submitted by: Johannes Lundberg  (earlier version)
  Reported by:  deischen@, Johannes, and numerous others
  MFC after:3.72 days

Modified:
  head/sys/dev/amdsmn/amdsmn.c
  head/sys/dev/amdtemp/amdtemp.c

Modified: head/sys/dev/amdsmn/amdsmn.c
==
--- head/sys/dev/amdsmn/amdsmn.cWed Nov 14 00:46:02 2018
(r340424)
+++ head/sys/dev/amdsmn/amdsmn.cWed Nov 14 03:42:39 2018
(r340425)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -53,14 +54,21 @@ __FBSDID("$FreeBSD$");
 #defineSMN_ADDR_REG0x60
 #defineSMN_DATA_REG0x64
 
+#definePCI_DEVICE_ID_AMD_17H_ROOT  0x1450
+#definePCI_DEVICE_ID_AMD_17H_ROOT_DF_F30x1463
+#definePCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0
+#definePCI_DEVICE_ID_AMD_17H_M10H_ROOT_DF_F3   0x15eb
+
 struct amdsmn_softc {
struct mtx smn_lock;
 };
 
 static struct pciid {
-   uint32_tdevice_id;
+   uint16_tamdsmn_vendorid;
+   uint16_tamdsmn_deviceid;
 } amdsmn_ids[] = {
-   { 0x14501022 },
+   { CPU_VENDOR_AMD, PCI_DEVICE_ID_AMD_17H_ROOT },
+   { CPU_VENDOR_AMD, PCI_DEVICE_ID_AMD_17H_M10H_ROOT },
 };
 
 /*
@@ -89,18 +97,21 @@ static driver_t amdsmn_driver = {
 static devclass_t amdsmn_devclass;
 DRIVER_MODULE(amdsmn, hostb, amdsmn_driver, amdsmn_devclass, NULL, NULL);
 MODULE_VERSION(amdsmn, 1);
-MODULE_PNP_INFO("W32:vendor/device", pci, amdsmn, amdsmn_ids,
+MODULE_PNP_INFO("U16:vendor;U16:device", pci, amdsmn, amdsmn_ids,
 nitems(amdsmn_ids));
 
 static bool
 amdsmn_match(device_t parent)
 {
-   uint32_t devid;
+   uint16_t vendor, device;
size_t i;
 
-   devid = pci_get_devid(parent);
+   vendor = pci_get_vendor(parent);
+   device = pci_get_device(parent);
+
for (i = 0; i < nitems(amdsmn_ids); i++)
-   if (amdsmn_ids[i].device_id == devid)
+   if (vendor == amdsmn_ids[i].amdsmn_vendorid &&
+   device == amdsmn_ids[i].amdsmn_deviceid)
return (true);
return (false);
 }

Modified: head/sys/dev/amdtemp/amdtemp.c
==
--- head/sys/dev/amdtemp/amdtemp.c  Wed Nov 14 00:46:02 2018
(r340424)
+++ head/sys/dev/amdtemp/amdtemp.c  Wed Nov 14 03:42:39 2018
(r340425)
@@ -86,7 +86,10 @@ struct amdtemp_softc {
 #defineDEVICEID_AMD_MISC16 0x1533
 #defineDEVICEID_AMD_MISC16_M30H0x1583
 #defineDEVICEID_AMD_MISC17 0x141d
-#defineDEVICEID_AMD_HOSTB17H   0x1450
+#defineDEVICEID_AMD_HOSTB17H_ROOT  0x1450
+#defineDEVICEID_AMD_HOSTB17H_DF_F3 0x1463
+#defineDEVICEID_AMD_HOSTB17H_M10H_ROOT 0x15d0
+#defineDEVICEID_AMD_HOSTB17H_M10H_DF_F3 0x15eb
 
 static struct amdtemp_product {
uint16_tamdtemp_vendorid;
@@ -101,7 +104,8 @@ static struct amdtemp_product {
{ VENDORID_AMD, DEVICEID_AMD_MISC16 },
{ VENDORID_AMD, DEVICEID_AMD_MISC16_M30H },
{ VENDORID_AMD, DEVICEID_AMD_MISC17 },
-   { VENDORID_AMD, DEVICEID_AMD_HOSTB17H },
+   { VENDORID_AMD, DEVICEID_AMD_HOSTB17H_ROOT },
+   { VENDORID_AMD, DEVICEID_AMD_HOSTB17H_M10H_ROOT },
 };
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340426 - head/sys/dev/amdtemp

2018-11-13 Thread Conrad Meyer
Author: cem
Date: Wed Nov 14 04:50:29 2018
New Revision: 340426
URL: https://svnweb.freebsd.org/changeset/base/340426

Log:
  amdtemp(4): Fix temperature reporting on AMD 2990WX
  
  Update the AMD family 17h temperature reporting based on AMD Tech Doc 56255
  OSRR, section 4.2.1.
  
  For CPUS w/CUR_TEMP_RANGE_SEL set, scale the reported temperature into the
  range -49..206; i.e., subtract 49°C.
  
  Submitted by: gallatin@
  Reported by:  bcran@
  Reviewed by:  me (long ago)
  MFC after:22.57 seconds
  Relnotes: yea
  Differential Revision:https://reviews.freebsd.org/D16855

Modified:
  head/sys/dev/amdtemp/amdtemp.c

Modified: head/sys/dev/amdtemp/amdtemp.c
==
--- head/sys/dev/amdtemp/amdtemp.c  Wed Nov 14 03:42:39 2018
(r340425)
+++ head/sys/dev/amdtemp/amdtemp.c  Wed Nov 14 04:50:29 2018
(r340426)
@@ -115,8 +115,15 @@ static struct amdtemp_product {
 
 /*
  * Reported Temperature, Family 17h
+ *
+ * According to AMD OSRR for 17H, section 4.2.1, bits 31-21 of this register
+ * provide the current temp.  bit 19, when clear, means the temp is reported in
+ * a range 0.."225C" (probable typo for 255C), and when set changes the range
+ * to -49..206C.
  */
-#defineAMDTEMP_17H_CUR_TMP 0x59800
+#defineAMDTEMP_17H_CUR_TMP 0x59800
+#defineAMDTEMP_17H_CUR_TMP_RANGE_SEL   (1 << 19)
+#defineAMDTEMP_17H_CUR_TMP_RANGE_OFF   490
 
 /*
  * Thermaltrip Status Register (Family 0Fh only)
@@ -595,13 +602,15 @@ static int32_t
 amdtemp_gettemp17h(device_t dev, amdsensor_t sensor)
 {
struct amdtemp_softc *sc = device_get_softc(dev);
-   uint32_t temp;
+   uint32_t temp, val;
int error;
 
-   error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &temp);
+   error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &val);
KASSERT(error == 0, ("amdsmn_read"));
 
-   temp = ((temp >> 21) & 0x7ff) * 5 / 4;
+   temp = ((val >> 21) & 0x7ff) * 5 / 4;
+   if ((val & AMDTEMP_17H_CUR_TMP_RANGE_SEL) != 0)
+   temp -= AMDTEMP_17H_CUR_TMP_RANGE_OFF;
temp += AMDTEMP_ZERO_C_TO_K + sc->sc_offset * 10;
 
return (temp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"