Re: svn commit: r325920 - head/sys/kern

2017-11-16 Thread Cy Schubert
In message <201711170225.vah2p4jy046...@repo.freebsd.org>, Mateusz Guzik 
writes
:
> Author: mjg
> Date: Fri Nov 17 02:25:04 2017
> New Revision: 325920
> URL: https://svnweb.freebsd.org/changeset/base/325920
> 
> Log:
>   mtx: unlock before traversing threads to wake up
>   
>   This shortens the lock hold time while not affecting corretness.
>   All the woken up threads end up competing can lose the race against
>   a completely unrelated thread getting the lock anyway.
> 
> Modified:
>   head/sys/kern/kern_mutex.c
> 
> Modified: head/sys/kern/kern_mutex.c
> =
> =
> --- head/sys/kern/kern_mutex.cFri Nov 17 02:22:51 2017(r32591
> 9)
> +++ head/sys/kern/kern_mutex.cFri Nov 17 02:25:04 2017(r32592
> 0)
> @@ -629,7 +629,8 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
>  #ifdef KDTRACE_HOOKS
>   sleep_time -= lockstat_nsecs(>lock_object);
>  #endif
> - turnstile_wait(ts, mtx_owner(m), TS_EXCLUSIVE_QUEUE);
> + MPASS(owner == mtx_owner(m));

Should this be conditional when ADAPTIVE_MUTEXES is defined? Otherwise it 
fails to build.

> + turnstile_wait(ts, owner, TS_EXCLUSIVE_QUEUE);
>  #ifdef KDTRACE_HOOKS
>   sleep_time += lockstat_nsecs(>lock_object);
>   sleep_cnt++;
> @@ -1002,7 +1003,7 @@ __mtx_unlock_sleep(volatile uintptr_t *c)
>  {
>   struct mtx *m;
>   struct turnstile *ts;
> - uintptr_t tid, v;
> + uintptr_t tid;
>  
>   if (SCHEDULER_STOPPED())
>   return;
> @@ -1028,12 +1029,12 @@ __mtx_unlock_sleep(volatile uintptr_t *c)
>* can be removed from the hash list if it is empty.
>*/
>   turnstile_chain_lock(>lock_object);
> + _mtx_release_lock_quick(m);
>   ts = turnstile_lookup(>lock_object);
> + MPASS(ts != NULL);
>   if (LOCK_LOG_TEST(>lock_object, opts))
>   CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m);
> - MPASS(ts != NULL);
>   turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE);
> - _mtx_release_lock_quick(m);
>  
>   /*
>* This turnstile is now no longer associated with the mutex.  We can
> 


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


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


svn commit: r325927 - head/sys/dev/dpaa

2017-11-16 Thread Justin Hibbits
Author: jhibbits
Date: Fri Nov 17 04:29:32 2017
New Revision: 325927
URL: https://svnweb.freebsd.org/changeset/base/325927

Log:
  Add jumbo frame support to dtsec(4)
  
  MFC after:2 weeks

Modified:
  head/sys/dev/dpaa/if_dtsec.c

Modified: head/sys/dev/dpaa/if_dtsec.c
==
--- head/sys/dev/dpaa/if_dtsec.cFri Nov 17 04:10:52 2017
(r325926)
+++ head/sys/dev/dpaa/if_dtsec.cFri Nov 17 04:29:32 2017
(r325927)
@@ -67,7 +67,11 @@ __FBSDID("$FreeBSD$");
 #include "if_dtsec_im.h"
 #include "if_dtsec_rm.h"
 
+#defineDTSEC_MIN_FRAME_SIZE64
+#defineDTSEC_MAX_FRAME_SIZE9600
 
+#defineDTSEC_REG_MAXFRM0x110
+
 /**
  * @group dTSEC private defines.
  * @{
@@ -321,6 +325,22 @@ dtsec_fm_port_free_both(struct dtsec_softc *sc)
  * @{
  */
 static int
+dtsec_set_mtu(struct dtsec_softc *sc, unsigned int mtu)
+{
+
+   mtu += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ETHER_CRC_LEN;
+
+   DTSEC_LOCK_ASSERT(sc);
+
+   if (mtu >= DTSEC_MIN_FRAME_SIZE && mtu <= DTSEC_MAX_FRAME_SIZE) {
+   bus_write_4(sc->sc_mem, DTSEC_REG_MAXFRM, mtu);
+   return (mtu);
+   }
+
+   return (0);
+}
+
+static int
 dtsec_if_enable_locked(struct dtsec_softc *sc)
 {
int error;
@@ -384,6 +404,14 @@ dtsec_if_ioctl(struct ifnet *ifp, u_long command, cadd
 
/* Basic functionality to achieve media status reports */
switch (command) {
+   case SIOCSIFMTU:
+   DTSEC_LOCK(sc);
+   if (dtsec_set_mtu(sc, ifr->ifr_mtu))
+   ifp->if_mtu = ifr->ifr_mtu;
+   else
+   error = EINVAL;
+   DTSEC_UNLOCK(sc);
+   break;
case SIOCSIFFLAGS:
DTSEC_LOCK(sc);
 
@@ -678,7 +706,7 @@ dtsec_attach(device_t dev)
ifp->if_snd.ifq_drv_maxlen = TSEC_TX_NUM_DESC - 1;
IFQ_SET_READY(>if_snd);
 #endif
-   ifp->if_capabilities = 0; /* TODO: Check */
+   ifp->if_capabilities = IFCAP_JUMBO_MTU; /* TODO: HWCSUM */
ifp->if_capenable = ifp->if_capabilities;
 
/* Attach PHY(s) */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325926 - head/sys/powerpc/ofw

2017-11-16 Thread Justin Hibbits
Author: jhibbits
Date: Fri Nov 17 04:10:52 2017
New Revision: 325926
URL: https://svnweb.freebsd.org/changeset/base/325926

Log:
  Stop special casing 32-bit AIM in memory parsing
  
  There's no need to special case 32-bit AIM to short circuit processing.
  Some AIM CPUs can handle 36 bit addresses, and 64-bit CPUs can run 32-bit
  OSes, so this will allow us to expand for that in the future if we desire.

Modified:
  head/sys/powerpc/ofw/ofw_machdep.c

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==
--- head/sys/powerpc/ofw/ofw_machdep.c  Fri Nov 17 02:59:28 2017
(r325925)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Fri Nov 17 04:10:52 2017
(r325926)
@@ -184,14 +184,6 @@ parse_ofw_memory(phandle_t node, const char *prop, str
i = 0;
j = 0;
while (i < sz/sizeof(cell_t)) {
- #if !defined(__powerpc64__) && !defined(BOOKE)
-   /* On 32-bit PPC (OEA), ignore regions starting above 4 GB */
-   if (address_cells > 1 && OFmem[i] > 0) {
-   i += address_cells + size_cells;
-   continue;
-   }
- #endif
-
output[j].mr_start = OFmem[i++];
if (address_cells == 2) {
output[j].mr_start <<= 32;
@@ -204,19 +196,20 @@ parse_ofw_memory(phandle_t node, const char *prop, str
output[j].mr_size += OFmem[i++];
}
 
- #if !defined(__powerpc64__) && !defined(BOOKE)
-   /* Book-E can support 36-bit addresses. */
+   if (output[j].mr_start > BUS_SPACE_MAXADDR)
+   continue;
+
/*
-* Check for memory regions extending above 32-bit
-* memory space, and restrict them to stay there.
+* Constrain memory to that which we can access.
+* 32-bit AIM can only reference 32 bits of address currently,
+* but Book-E can access 36 bits.
 */
if (((uint64_t)output[j].mr_start +
-   (uint64_t)output[j].mr_size) >
-   BUS_SPACE_MAXADDR_32BIT) {
-   output[j].mr_size = BUS_SPACE_MAXADDR_32BIT -
-   output[j].mr_start;
+   (uint64_t)output[j].mr_size - 1) >
+   BUS_SPACE_MAXADDR) {
+   output[j].mr_size = BUS_SPACE_MAXADDR -
+   output[j].mr_start + 1;
}
- #endif
 
j++;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325925 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:59:28 2017
New Revision: 325925
URL: https://svnweb.freebsd.org/changeset/base/325925

Log:
  mtx: add missing parts of the diff in r325920
  
  Fixes build breakage.

Modified:
  head/sys/kern/kern_mutex.c

Modified: head/sys/kern/kern_mutex.c
==
--- head/sys/kern/kern_mutex.c  Fri Nov 17 02:45:38 2017(r325924)
+++ head/sys/kern/kern_mutex.c  Fri Nov 17 02:59:28 2017(r325925)
@@ -463,7 +463,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
struct turnstile *ts;
uintptr_t tid;
 #ifdef ADAPTIVE_MUTEXES
-   volatile struct thread *owner;
+   struct thread *owner;
 #endif
 #ifdef KTR
int cont_logged = 0;
@@ -1003,7 +1003,7 @@ __mtx_unlock_sleep(volatile uintptr_t *c)
 {
struct mtx *m;
struct turnstile *ts;
-   uintptr_t tid;
+   uintptr_t tid, v;
 
if (SCHEDULER_STOPPED())
return;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325924 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:45:38 2017
New Revision: 325924
URL: https://svnweb.freebsd.org/changeset/base/325924

Log:
  sched: move panic handling code out of choosethread
  
  This avoids jumps in the common case of the kernel not being panicked.

Modified:
  head/sys/kern/kern_switch.c

Modified: head/sys/kern/kern_switch.c
==
--- head/sys/kern/kern_switch.c Fri Nov 17 02:29:06 2017(r325923)
+++ head/sys/kern/kern_switch.c Fri Nov 17 02:45:38 2017(r325924)
@@ -150,24 +150,37 @@ SYSCTL_PROC(_kern_sched_stats, OID_AUTO, reset, CTLTYP
 /*
  * Select the thread that will be run next.
  */
-struct thread *
-choosethread(void)
+
+static __noinline struct thread *
+choosethread_panic(struct thread *td)
 {
-   struct thread *td;
 
-retry:
-   td = sched_choose();
-
/*
 * If we are in panic, only allow system threads,
 * plus the one we are running in, to be run.
 */
-   if (panicstr && ((td->td_proc->p_flag & P_SYSTEM) == 0 &&
+retry:
+   if (((td->td_proc->p_flag & P_SYSTEM) == 0 &&
(td->td_flags & TDF_INPANIC) == 0)) {
/* note that it is no longer on the run queue */
TD_SET_CAN_RUN(td);
+   td = sched_choose();
goto retry;
}
+
+   TD_SET_RUNNING(td);
+   return (td);
+}
+
+struct thread *
+choosethread(void)
+{
+   struct thread *td;
+
+   td = sched_choose();
+
+   if (__predict_false(panicstr != NULL))
+   return (choosethread_panic(td));
 
TD_SET_RUNNING(td);
return (td);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325923 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:29:06 2017
New Revision: 325923
URL: https://svnweb.freebsd.org/changeset/base/325923

Log:
  Check for PRS_NEW without locking the proc in sysctl_kern_proc

Modified:
  head/sys/kern/kern_proc.c

Modified: head/sys/kern/kern_proc.c
==
--- head/sys/kern/kern_proc.c   Fri Nov 17 02:27:04 2017(r325922)
+++ head/sys/kern/kern_proc.c   Fri Nov 17 02:29:06 2017(r325923)
@@ -1479,11 +1479,9 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
/*
 * Skip embryonic processes.
 */
-   PROC_LOCK(p);
-   if (p->p_state == PRS_NEW) {
-   PROC_UNLOCK(p);
+   if (p->p_state == PRS_NEW)
continue;
-   }
+   PROC_LOCK(p);
KASSERT(p->p_ucred != NULL,
("process credential is NULL for non-NEW proc"));
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325922 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:27:04 2017
New Revision: 325922
URL: https://svnweb.freebsd.org/changeset/base/325922

Log:
  sx: perform a minor cleanup of the unlock slowpath
  
  No functional changes.

Modified:
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_sx.c
==
--- head/sys/kern/kern_sx.c Fri Nov 17 02:26:15 2017(r325921)
+++ head/sys/kern/kern_sx.c Fri Nov 17 02:27:04 2017(r325922)
@@ -772,7 +772,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
 void
 _sx_xunlock_hard(struct sx *sx, uintptr_t tid, const char *file, int line)
 {
-   uintptr_t x;
+   uintptr_t x, setx;
int queue, wakeup_swapper;
 
if (SCHEDULER_STOPPED())
@@ -801,7 +801,7 @@ _sx_xunlock_hard(struct sx *sx, uintptr_t tid, const c
CTR2(KTR_LOCK, "%s: %p contested", __func__, sx);
 
sleepq_lock(>lock_object);
-   x = SX_LOCK_UNLOCKED;
+   x = SX_READ_VALUE(sx);
 
/*
 * The wake up algorithm here is quite simple and probably not
@@ -812,19 +812,21 @@ _sx_xunlock_hard(struct sx *sx, uintptr_t tid, const c
 * starvation for the threads sleeping on the exclusive queue by giving
 * them precedence and cleaning up the shared waiters bit anyway.
 */
-   if ((sx->sx_lock & SX_LOCK_SHARED_WAITERS) != 0 &&
+   setx = SX_LOCK_UNLOCKED;
+   queue = SQ_EXCLUSIVE_QUEUE;
+   if ((x & SX_LOCK_SHARED_WAITERS) != 0 &&
sleepq_sleepcnt(>lock_object, SQ_SHARED_QUEUE) != 0) {
queue = SQ_SHARED_QUEUE;
-   x |= (sx->sx_lock & SX_LOCK_EXCLUSIVE_WAITERS);
-   } else
-   queue = SQ_EXCLUSIVE_QUEUE;
+   setx |= (x & SX_LOCK_EXCLUSIVE_WAITERS);
+   }
+   atomic_store_rel_ptr(>sx_lock, setx);
 
/* Wake up all the waiters for the specific queue. */
if (LOCK_LOG_TEST(>lock_object, 0))
CTR3(KTR_LOCK, "%s: %p waking up all threads on %s queue",
__func__, sx, queue == SQ_SHARED_QUEUE ? "shared" :
"exclusive");
-   atomic_store_rel_ptr(>sx_lock, x);
+
wakeup_swapper = sleepq_broadcast(>lock_object, SLEEPQ_SX, 0,
queue);
sleepq_release(>lock_object);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325921 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:26:15 2017
New Revision: 325921
URL: https://svnweb.freebsd.org/changeset/base/325921

Log:
  rwlock: unlock before traversing threads to wake up
  
  While here perform a minor cleanup of the unlock path.

Modified:
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Fri Nov 17 02:25:04 2017(r325920)
+++ head/sys/kern/kern_rwlock.c Fri Nov 17 02:26:15 2017(r325921)
@@ -1081,7 +1081,7 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid
 {
struct rwlock *rw;
struct turnstile *ts;
-   uintptr_t v;
+   uintptr_t v, setv;
int queue;
 
if (SCHEDULER_STOPPED())
@@ -1108,8 +1108,6 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid
CTR2(KTR_LOCK, "%s: %p contested", __func__, rw);
 
turnstile_chain_lock(>lock_object);
-   ts = turnstile_lookup(>lock_object);
-   MPASS(ts != NULL);
 
/*
 * Use the same algo as sx locks for now.  Prefer waking up shared
@@ -1127,19 +1125,23 @@ __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid
 * there that could be worked around either by waking both queues
 * of waiters or doing some complicated lock handoff gymnastics.
 */
-   v = RW_UNLOCKED;
-   if (rw->rw_lock & RW_LOCK_WRITE_WAITERS) {
+   setv = RW_UNLOCKED;
+   v = RW_READ_VALUE(rw);
+   queue = TS_SHARED_QUEUE;
+   if (v & RW_LOCK_WRITE_WAITERS) {
queue = TS_EXCLUSIVE_QUEUE;
-   v |= (rw->rw_lock & RW_LOCK_READ_WAITERS);
-   } else
-   queue = TS_SHARED_QUEUE;
+   setv |= (v & RW_LOCK_READ_WAITERS);
+   }
+   atomic_store_rel_ptr(>rw_lock, setv);
 
/* Wake up all waiters for the specific queue. */
if (LOCK_LOG_TEST(>lock_object, 0))
CTR3(KTR_LOCK, "%s: %p waking up %s waiters", __func__, rw,
queue == TS_SHARED_QUEUE ? "read" : "write");
+
+   ts = turnstile_lookup(>lock_object);
+   MPASS(ts != NULL);
turnstile_broadcast(ts, queue);
-   atomic_store_rel_ptr(>rw_lock, v);
turnstile_unpend(ts, TS_EXCLUSIVE_LOCK);
turnstile_chain_unlock(>lock_object);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325920 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:25:04 2017
New Revision: 325920
URL: https://svnweb.freebsd.org/changeset/base/325920

Log:
  mtx: unlock before traversing threads to wake up
  
  This shortens the lock hold time while not affecting corretness.
  All the woken up threads end up competing can lose the race against
  a completely unrelated thread getting the lock anyway.

Modified:
  head/sys/kern/kern_mutex.c

Modified: head/sys/kern/kern_mutex.c
==
--- head/sys/kern/kern_mutex.c  Fri Nov 17 02:22:51 2017(r325919)
+++ head/sys/kern/kern_mutex.c  Fri Nov 17 02:25:04 2017(r325920)
@@ -629,7 +629,8 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
 #ifdef KDTRACE_HOOKS
sleep_time -= lockstat_nsecs(>lock_object);
 #endif
-   turnstile_wait(ts, mtx_owner(m), TS_EXCLUSIVE_QUEUE);
+   MPASS(owner == mtx_owner(m));
+   turnstile_wait(ts, owner, TS_EXCLUSIVE_QUEUE);
 #ifdef KDTRACE_HOOKS
sleep_time += lockstat_nsecs(>lock_object);
sleep_cnt++;
@@ -1002,7 +1003,7 @@ __mtx_unlock_sleep(volatile uintptr_t *c)
 {
struct mtx *m;
struct turnstile *ts;
-   uintptr_t tid, v;
+   uintptr_t tid;
 
if (SCHEDULER_STOPPED())
return;
@@ -1028,12 +1029,12 @@ __mtx_unlock_sleep(volatile uintptr_t *c)
 * can be removed from the hash list if it is empty.
 */
turnstile_chain_lock(>lock_object);
+   _mtx_release_lock_quick(m);
ts = turnstile_lookup(>lock_object);
+   MPASS(ts != NULL);
if (LOCK_LOG_TEST(>lock_object, opts))
CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m);
-   MPASS(ts != NULL);
turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE);
-   _mtx_release_lock_quick(m);
 
/*
 * This turnstile is now no longer associated with the mutex.  We can
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325919 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:22:51 2017
New Revision: 325919
URL: https://svnweb.freebsd.org/changeset/base/325919

Log:
  locks: pull up PMC_SOFT_CALLs out of slow path loops

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

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Fri Nov 17 02:21:24 2017(r325918)
+++ head/sys/kern/kern_rwlock.c Fri Nov 17 02:22:51 2017(r325919)
@@ -443,6 +443,12 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
 #endif
rw = rwlock2rw(c);
 
+#ifdef HWPMC_HOOKS
+   PMC_SOFT_CALL( , , lock, failed);
+#endif
+   lock_profile_obtain_lock_failed(>lock_object,
+   , );
+
 #ifdef LOCK_PROFILING
doing_lockprof = 1;
state = v;
@@ -460,11 +466,6 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
 #ifdef KDTRACE_HOOKS
lda.spin_cnt++;
 #endif
-#ifdef HWPMC_HOOKS
-   PMC_SOFT_CALL( , , lock, failed);
-#endif
-   lock_profile_obtain_lock_failed(>lock_object,
-   , );
 
 #ifdef ADAPTIVE_RWLOCKS
/*
@@ -890,6 +891,12 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui
CTR5(KTR_LOCK, "%s: %s contested (lock=%p) at %s:%d", __func__,
rw->lock_object.lo_name, (void *)rw->rw_lock, file, line);
 
+#ifdef HWPMC_HOOKS
+   PMC_SOFT_CALL( , , lock, failed);
+#endif
+   lock_profile_obtain_lock_failed(>lock_object,
+   , );
+
 #ifdef LOCK_PROFILING
doing_lockprof = 1;
state = v;
@@ -910,11 +917,7 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui
 #ifdef KDTRACE_HOOKS
lda.spin_cnt++;
 #endif
-#ifdef HWPMC_HOOKS
-   PMC_SOFT_CALL( , , lock, failed);
-#endif
-   lock_profile_obtain_lock_failed(>lock_object,
-   , );
+
 #ifdef ADAPTIVE_RWLOCKS
/*
 * If the lock is write locked and the owner is

Modified: head/sys/kern/kern_sx.c
==
--- head/sys/kern/kern_sx.c Fri Nov 17 02:21:24 2017(r325918)
+++ head/sys/kern/kern_sx.c Fri Nov 17 02:22:51 2017(r325919)
@@ -551,6 +551,12 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
CTR5(KTR_LOCK, "%s: %s contested (lock=%p) at %s:%d", __func__,
sx->lock_object.lo_name, (void *)sx->sx_lock, file, line);
 
+#ifdef HWPMC_HOOKS
+   PMC_SOFT_CALL( , , lock, failed);
+#endif
+   lock_profile_obtain_lock_failed(>lock_object, ,
+   );
+
 #ifdef LOCK_PROFILING
extra_work = 1;
state = x;
@@ -571,11 +577,6 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
 #ifdef KDTRACE_HOOKS
lda.spin_cnt++;
 #endif
-#ifdef HWPMC_HOOKS
-   PMC_SOFT_CALL( , , lock, failed);
-#endif
-   lock_profile_obtain_lock_failed(>lock_object, ,
-   );
 #ifdef ADAPTIVE_SX
/*
 * If the lock is write locked and the owner is
@@ -889,6 +890,12 @@ _sx_slock_hard(struct sx *sx, int opts, const char *fi
lock_delay_arg_init(, NULL);
 #endif
 
+#ifdef HWPMC_HOOKS
+   PMC_SOFT_CALL( , , lock, failed);
+#endif
+   lock_profile_obtain_lock_failed(>lock_object, ,
+   );
+
 #ifdef LOCK_PROFILING
extra_work = 1;
state = x;
@@ -910,12 +917,6 @@ _sx_slock_hard(struct sx *sx, int opts, const char *fi
 #ifdef KDTRACE_HOOKS
lda.spin_cnt++;
 #endif
-
-#ifdef HWPMC_HOOKS
-   PMC_SOFT_CALL( , , lock, failed);
-#endif
-   lock_profile_obtain_lock_failed(>lock_object, ,
-   );
 
 #ifdef ADAPTIVE_SX
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325918 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:21:24 2017
New Revision: 325918
URL: https://svnweb.freebsd.org/changeset/base/325918

Log:
  rwlock: avoid branches in the slow path if lockstat is disabled

Modified:
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Fri Nov 17 02:21:07 2017(r325917)
+++ head/sys/kern/kern_rwlock.c Fri Nov 17 02:21:24 2017(r325918)
@@ -424,11 +424,14 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
struct lock_delay_arg lda;
 #endif
 #ifdef KDTRACE_HOOKS
-   uintptr_t state;
u_int sleep_cnt = 0;
int64_t sleep_time = 0;
int64_t all_time = 0;
 #endif
+#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
+   uintptr_t state;
+   int doing_lockprof;
+#endif
 
if (SCHEDULER_STOPPED())
return;
@@ -440,12 +443,17 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
 #endif
rw = rwlock2rw(c);
 
-#ifdef KDTRACE_HOOKS
-   all_time -= lockstat_nsecs(>lock_object);
-#endif
-#ifdef KDTRACE_HOOKS
+#ifdef LOCK_PROFILING
+   doing_lockprof = 1;
state = v;
+#elif defined(KDTRACE_HOOKS)
+   doing_lockprof = lockstat_enabled;
+   if (__predict_false(doing_lockprof)) {
+   all_time -= lockstat_nsecs(>lock_object);
+   state = v;
+   }
 #endif
+
for (;;) {
if (__rw_rlock_try(rw, td, , file, line))
break;
@@ -583,6 +591,10 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
__func__, rw);
v = RW_READ_VALUE(rw);
}
+#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
+   if (__predict_true(!doing_lockprof))
+   return;
+#endif
 #ifdef KDTRACE_HOOKS
all_time += lockstat_nsecs(>lock_object);
if (sleep_time)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325917 - head/sys/kern

2017-11-16 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 17 02:21:07 2017
New Revision: 325917
URL: https://svnweb.freebsd.org/changeset/base/325917

Log:
  sx: avoid branches if in the slow path if lockstat is disabled

Modified:
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_sx.c
==
--- head/sys/kern/kern_sx.c Fri Nov 17 00:38:00 2017(r325916)
+++ head/sys/kern/kern_sx.c Fri Nov 17 02:21:07 2017(r325917)
@@ -88,8 +88,9 @@ PMC_SOFT_DECLARE( , , lock, failed);
int _giantcnt = 0;  \
WITNESS_SAVE_DECL(Giant)\
 
-#defineGIANT_SAVE() do {   
\
+#defineGIANT_SAVE(work) do {   
\
if (mtx_owned()) {\
+   work++; \
WITNESS_SAVE(_object, Giant);\
while (mtx_owned()) { \
_giantcnt++;\
@@ -513,11 +514,14 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
struct lock_delay_arg lda;
 #endif
 #ifdef KDTRACE_HOOKS
-   uintptr_t state;
u_int sleep_cnt = 0;
int64_t sleep_time = 0;
int64_t all_time = 0;
 #endif
+#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
+   uintptr_t state;
+   int extra_work;
+#endif
 
if (SCHEDULER_STOPPED())
return (0);
@@ -547,10 +551,17 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
CTR5(KTR_LOCK, "%s: %s contested (lock=%p) at %s:%d", __func__,
sx->lock_object.lo_name, (void *)sx->sx_lock, file, line);
 
-#ifdef KDTRACE_HOOKS
-   all_time -= lockstat_nsecs(>lock_object);
+#ifdef LOCK_PROFILING
+   extra_work = 1;
state = x;
+#elif defined(KDTRACE_HOOKS)
+   extra_work = lockstat_enabled;
+   if (__predict_false(extra_work)) {
+   all_time -= lockstat_nsecs(>lock_object);
+   state = x;
+   }
 #endif
+
for (;;) {
if (x == SX_LOCK_UNLOCKED) {
if (atomic_fcmpset_acq_ptr(>sx_lock, , tid))
@@ -583,7 +594,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
sched_tdname(curthread), "spinning",
"lockname:\"%s\"",
sx->lock_object.lo_name);
-   GIANT_SAVE();
+   GIANT_SAVE(extra_work);
do {
lock_delay();
x = SX_READ_VALUE(sx);
@@ -598,7 +609,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
KTR_STATE1(KTR_SCHED, "thread",
sched_tdname(curthread), "spinning",
"lockname:\"%s\"", sx->lock_object.lo_name);
-   GIANT_SAVE();
+   GIANT_SAVE(extra_work);
spintries++;
for (i = 0; i < asx_loops; i += n) {
if (LOCK_LOG_TEST(>lock_object, 0))
@@ -705,7 +716,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
 #ifdef KDTRACE_HOOKS
sleep_time -= lockstat_nsecs(>lock_object);
 #endif
-   GIANT_SAVE();
+   GIANT_SAVE(extra_work);
sleepq_add(>lock_object, NULL, sx->lock_object.lo_name,
SLEEPQ_SX | ((opts & SX_INTERRUPTIBLE) ?
SLEEPQ_INTERRUPTIBLE : 0), SQ_EXCLUSIVE_QUEUE);
@@ -729,6 +740,10 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, uintptr_t t
__func__, sx);
x = SX_READ_VALUE(sx);
}
+#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
+   if (__predict_true(!extra_work))
+   return (error);
+#endif
 #ifdef KDTRACE_HOOKS
all_time += lockstat_nsecs(>lock_object);
if (sleep_time)
@@ -856,11 +871,14 @@ _sx_slock_hard(struct sx *sx, int opts, const char *fi
struct lock_delay_arg lda;
 #endif
 #ifdef KDTRACE_HOOKS
-   uintptr_t state;
u_int sleep_cnt = 0;
int64_t sleep_time = 0;
int64_t all_time = 0;
 #endif
+#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
+   uintptr_t state;
+   int extra_work;
+#endif
 
if (SCHEDULER_STOPPED())
return (0);
@@ -870,9 +888,16 @@ _sx_slock_hard(struct sx *sx, int opts, const char *fi
 #elif defined(KDTRACE_HOOKS)
lock_delay_arg_init(, NULL);
 #endif
-#ifdef KDTRACE_HOOKS
- 

Re: svn commit: r325903 - in head: sbin/fsck_ffs sbin/newfs sys/sys

2017-11-16 Thread Warner Losh
On Nov 16, 2017 4:24 PM, "Rodney W. Grimes" 
wrote:

[ Charset UTF-8 unsupported, converting... ]
> Author: imp
> Date: Thu Nov 16 21:28:14 2017
> New Revision: 325903
> URL: https://svnweb.freebsd.org/changeset/base/325903
>
> Log:
>   Only try to enable CK_CLYGRP if we're running on kernel newer than
>   1200046, the first version that supports this feature. If we set it,
>   then use an old kernel, we'll break the 'contract' of having
>   checksummed cylinder groups this flag signifies. To avoid creating
>   something with an inconsistent state, don't turn the flag on in these
>   cases. The first full fsck with a new kernel will turn this on.

I would much rather have to force this flag on, then
my problem would for the most part just go away, I can move file
systems back and forth between kernels without any problems.

Having fsck just turn it on without even a message let alone
a way to stop it being turned on increases the pain factor.


That's a request for Kirk. I'm not changing his design for this detail. If
it helps, it is only with some options it is turned on it only does
this for non preen -p, non -y runs.

Warner


>   Spnsored by: Netflix
>   Differential Revision: https://reviews.freebsd.org/D13114
>
> Modified:
>   head/sbin/fsck_ffs/pass5.c
>   head/sbin/newfs/mkfs.c
>   head/sbin/newfs/newfs.c
>   head/sys/sys/param.h
>
> Modified: head/sbin/fsck_ffs/pass5.c
> 
==
> --- head/sbin/fsck_ffs/pass5.cThu Nov 16 19:07:19 2017
(r325902)
> +++ head/sbin/fsck_ffs/pass5.cThu Nov 16 21:28:14 2017
(r325903)
> @@ -35,6 +35,7 @@ static const char sccsid[] = "@(#)pass5.c   8.9 (Berkele
>  #include 
>  __FBSDID("$FreeBSD$");
>
> +#define  IN_RTLD /* So we pickup the P_OSREL defines
*/
>  #include 
>  #include 
>
> @@ -73,6 +74,7 @@ pass5(void)
>   newcg->cg_niblk = fs->fs_ipg;
>   if (preen == 0 && yflag == 0 && fs->fs_magic == FS_UFS2_MAGIC &&
>   fswritefd != -1 && (fs->fs_metackhash & CK_CYLGRP) == 0 &&
> + getosreldate() >= P_OSREL_CK_CLYGRP &&
>   reply("ADD CYLINDER GROUP CHECKSUM PROTECTION") != 0) {
>   fs->fs_metackhash |= CK_CYLGRP;
>   rewritecg = 1;
>
> Modified: head/sbin/newfs/mkfs.c
> 
==
> --- head/sbin/newfs/mkfs.cThu Nov 16 19:07:19 2017(r325902)
> +++ head/sbin/newfs/mkfs.cThu Nov 16 21:28:14 2017(r325903)
> @@ -44,6 +44,7 @@ static char sccsid[] = "@(#)mkfs.c  8.11 (Berkeley) 5/3
>  #include 
>  __FBSDID("$FreeBSD$");
>
> +#define  IN_RTLD /* So we pickup the P_OSREL defines
*/
>  #include 
>  #include 
>  #include 
> @@ -495,7 +496,7 @@ restart:
>   /*
>* Set flags for metadata that is being check-hashed.
>*/
> - if (Oflag > 1)
> + if (Oflag > 1 && getosreldate() >= P_OSREL_CK_CLYGRP)
>   sblock.fs_metackhash = CK_CYLGRP;
>
>   /*
>
> Modified: head/sbin/newfs/newfs.c
> 
==
> --- head/sbin/newfs/newfs.c   Thu Nov 16 19:07:19 2017(r325902)
> +++ head/sbin/newfs/newfs.c   Thu Nov 16 21:28:14 2017(r325903)
> @@ -398,10 +398,6 @@ main(int argc, char *argv[])
>   if (pp != NULL)
>   pp->p_size *= secperblk;
>   }
> - if (getosreldate() < __FreeBSD_version) {
> - warnx("%s is newer than the running kernel and may not be
compatible",
> - getprogname());
> - }
>   mkfs(pp, special);
>   ufs_disk_close();
>   if (!jflag)
>
> Modified: head/sys/sys/param.h
> 
==
> --- head/sys/sys/param.h  Thu Nov 16 19:07:19 2017(r325902)
> +++ head/sys/sys/param.h  Thu Nov 16 21:28:14 2017(r325903)
> @@ -84,6 +84,7 @@
>  #define  P_OSREL_SHUTDOWN_ENOTCONN   1100077
>  #define  P_OSREL_MAP_GUARD   1200035
>  #define  P_OSREL_WRFSBASE1200041
> +#define  P_OSREL_CK_CLYGRP   1200046
>  #define  P_OSREL_VMTOTAL64   1200054
>
>  #define  P_OSREL_MAJOR(x)((x) / 10)
>
>

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


Re: svn commit: r325903 - in head: sbin/fsck_ffs sbin/newfs sys/sys

2017-11-16 Thread Rodney W. Grimes
[ Charset UTF-8 unsupported, converting... ]
> Author: imp
> Date: Thu Nov 16 21:28:14 2017
> New Revision: 325903
> URL: https://svnweb.freebsd.org/changeset/base/325903
> 
> Log:
>   Only try to enable CK_CLYGRP if we're running on kernel newer than
>   1200046, the first version that supports this feature. If we set it,
>   then use an old kernel, we'll break the 'contract' of having
>   checksummed cylinder groups this flag signifies. To avoid creating
>   something with an inconsistent state, don't turn the flag on in these
>   cases. The first full fsck with a new kernel will turn this on.

I would much rather have to force this flag on, then
my problem would for the most part just go away, I can move file
systems back and forth between kernels without any problems.

Having fsck just turn it on without even a message let alone
a way to stop it being turned on increases the pain factor.

>   Spnsored by: Netflix
>   Differential Revision: https://reviews.freebsd.org/D13114
> 
> Modified:
>   head/sbin/fsck_ffs/pass5.c
>   head/sbin/newfs/mkfs.c
>   head/sbin/newfs/newfs.c
>   head/sys/sys/param.h
> 
> Modified: head/sbin/fsck_ffs/pass5.c
> ==
> --- head/sbin/fsck_ffs/pass5.cThu Nov 16 19:07:19 2017
> (r325902)
> +++ head/sbin/fsck_ffs/pass5.cThu Nov 16 21:28:14 2017
> (r325903)
> @@ -35,6 +35,7 @@ static const char sccsid[] = "@(#)pass5.c   8.9 (Berkele
>  #include 
>  __FBSDID("$FreeBSD$");
>  
> +#define  IN_RTLD /* So we pickup the P_OSREL defines */
>  #include 
>  #include 
>  
> @@ -73,6 +74,7 @@ pass5(void)
>   newcg->cg_niblk = fs->fs_ipg;
>   if (preen == 0 && yflag == 0 && fs->fs_magic == FS_UFS2_MAGIC &&
>   fswritefd != -1 && (fs->fs_metackhash & CK_CYLGRP) == 0 &&
> + getosreldate() >= P_OSREL_CK_CLYGRP &&
>   reply("ADD CYLINDER GROUP CHECKSUM PROTECTION") != 0) {
>   fs->fs_metackhash |= CK_CYLGRP;
>   rewritecg = 1;
> 
> Modified: head/sbin/newfs/mkfs.c
> ==
> --- head/sbin/newfs/mkfs.cThu Nov 16 19:07:19 2017(r325902)
> +++ head/sbin/newfs/mkfs.cThu Nov 16 21:28:14 2017(r325903)
> @@ -44,6 +44,7 @@ static char sccsid[] = "@(#)mkfs.c  8.11 (Berkeley) 5/3
>  #include 
>  __FBSDID("$FreeBSD$");
>  
> +#define  IN_RTLD /* So we pickup the P_OSREL defines */
>  #include 
>  #include 
>  #include 
> @@ -495,7 +496,7 @@ restart:
>   /*
>* Set flags for metadata that is being check-hashed.
>*/
> - if (Oflag > 1)
> + if (Oflag > 1 && getosreldate() >= P_OSREL_CK_CLYGRP)
>   sblock.fs_metackhash = CK_CYLGRP;
>  
>   /*
> 
> Modified: head/sbin/newfs/newfs.c
> ==
> --- head/sbin/newfs/newfs.c   Thu Nov 16 19:07:19 2017(r325902)
> +++ head/sbin/newfs/newfs.c   Thu Nov 16 21:28:14 2017(r325903)
> @@ -398,10 +398,6 @@ main(int argc, char *argv[])
>   if (pp != NULL)
>   pp->p_size *= secperblk;
>   }
> - if (getosreldate() < __FreeBSD_version) {
> - warnx("%s is newer than the running kernel and may not be 
> compatible",
> - getprogname());
> - }
>   mkfs(pp, special);
>   ufs_disk_close();
>   if (!jflag)
> 
> Modified: head/sys/sys/param.h
> ==
> --- head/sys/sys/param.h  Thu Nov 16 19:07:19 2017(r325902)
> +++ head/sys/sys/param.h  Thu Nov 16 21:28:14 2017(r325903)
> @@ -84,6 +84,7 @@
>  #define  P_OSREL_SHUTDOWN_ENOTCONN   1100077
>  #define  P_OSREL_MAP_GUARD   1200035
>  #define  P_OSREL_WRFSBASE1200041
> +#define  P_OSREL_CK_CLYGRP   1200046
>  #define  P_OSREL_VMTOTAL64   1200054
>  
>  #define  P_OSREL_MAJOR(x)((x) / 10)
> 
> 

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


svn commit: r325906 - head/usr.bin/procstat

2017-11-16 Thread Andriy Gapon
Author: avg
Date: Thu Nov 16 22:14:49 2017
New Revision: 325906
URL: https://svnweb.freebsd.org/changeset/base/325906

Log:
  procstat: fix a crash with -k -a options
  
  The traditional / legacy usage should still be supported.
  This fixes a regression in r324619 that introduced a nicer, verb based
  interface.
  
  Reviewed by:  brooks
  X-MFC with:   r324619

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

Modified: head/usr.bin/procstat/procstat.c
==
--- head/usr.bin/procstat/procstat.cThu Nov 16 21:47:41 2017
(r325905)
+++ head/usr.bin/procstat/procstat.cThu Nov 16 22:14:49 2017
(r325906)
@@ -296,7 +296,7 @@ main(int argc, char *argv[])
cmd = getcmd("tsignals");
break;
case 'k':
-   if (cmd->cmd == procstat_kstack) {
+   if (cmd != NULL && cmd->cmd == procstat_kstack) {
if ((procstat_opts & PS_OPT_VERBOSE) != 0)
usage();
procstat_opts |= PS_OPT_VERBOSE;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325903 - in head: sbin/fsck_ffs sbin/newfs sys/sys

2017-11-16 Thread Warner Losh
Author: imp
Date: Thu Nov 16 21:28:14 2017
New Revision: 325903
URL: https://svnweb.freebsd.org/changeset/base/325903

Log:
  Only try to enable CK_CLYGRP if we're running on kernel newer than
  1200046, the first version that supports this feature. If we set it,
  then use an old kernel, we'll break the 'contract' of having
  checksummed cylinder groups this flag signifies. To avoid creating
  something with an inconsistent state, don't turn the flag on in these
  cases. The first full fsck with a new kernel will turn this on.
  
  Spnsored by: Netflix
  Differential Revision: https://reviews.freebsd.org/D13114

Modified:
  head/sbin/fsck_ffs/pass5.c
  head/sbin/newfs/mkfs.c
  head/sbin/newfs/newfs.c
  head/sys/sys/param.h

Modified: head/sbin/fsck_ffs/pass5.c
==
--- head/sbin/fsck_ffs/pass5.c  Thu Nov 16 19:07:19 2017(r325902)
+++ head/sbin/fsck_ffs/pass5.c  Thu Nov 16 21:28:14 2017(r325903)
@@ -35,6 +35,7 @@ static const char sccsid[] = "@(#)pass5.c 8.9 (Berkele
 #include 
 __FBSDID("$FreeBSD$");
 
+#defineIN_RTLD /* So we pickup the P_OSREL defines */
 #include 
 #include 
 
@@ -73,6 +74,7 @@ pass5(void)
newcg->cg_niblk = fs->fs_ipg;
if (preen == 0 && yflag == 0 && fs->fs_magic == FS_UFS2_MAGIC &&
fswritefd != -1 && (fs->fs_metackhash & CK_CYLGRP) == 0 &&
+   getosreldate() >= P_OSREL_CK_CLYGRP &&
reply("ADD CYLINDER GROUP CHECKSUM PROTECTION") != 0) {
fs->fs_metackhash |= CK_CYLGRP;
rewritecg = 1;

Modified: head/sbin/newfs/mkfs.c
==
--- head/sbin/newfs/mkfs.c  Thu Nov 16 19:07:19 2017(r325902)
+++ head/sbin/newfs/mkfs.c  Thu Nov 16 21:28:14 2017(r325903)
@@ -44,6 +44,7 @@ static char sccsid[] = "@(#)mkfs.c8.11 (Berkeley) 5/3
 #include 
 __FBSDID("$FreeBSD$");
 
+#defineIN_RTLD /* So we pickup the P_OSREL defines */
 #include 
 #include 
 #include 
@@ -495,7 +496,7 @@ restart:
/*
 * Set flags for metadata that is being check-hashed.
 */
-   if (Oflag > 1)
+   if (Oflag > 1 && getosreldate() >= P_OSREL_CK_CLYGRP)
sblock.fs_metackhash = CK_CYLGRP;
 
/*

Modified: head/sbin/newfs/newfs.c
==
--- head/sbin/newfs/newfs.c Thu Nov 16 19:07:19 2017(r325902)
+++ head/sbin/newfs/newfs.c Thu Nov 16 21:28:14 2017(r325903)
@@ -398,10 +398,6 @@ main(int argc, char *argv[])
if (pp != NULL)
pp->p_size *= secperblk;
}
-   if (getosreldate() < __FreeBSD_version) {
-   warnx("%s is newer than the running kernel and may not be 
compatible",
-   getprogname());
-   }
mkfs(pp, special);
ufs_disk_close();
if (!jflag)

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hThu Nov 16 19:07:19 2017(r325902)
+++ head/sys/sys/param.hThu Nov 16 21:28:14 2017(r325903)
@@ -84,6 +84,7 @@
 #defineP_OSREL_SHUTDOWN_ENOTCONN   1100077
 #defineP_OSREL_MAP_GUARD   1200035
 #defineP_OSREL_WRFSBASE1200041
+#defineP_OSREL_CK_CLYGRP   1200046
 #defineP_OSREL_VMTOTAL64   1200054
 
 #defineP_OSREL_MAJOR(x)((x) / 10)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325901 - head/sys/net

2017-11-16 Thread Stephen Hurd
Author: shurd
Date: Thu Nov 16 18:52:58 2017
New Revision: 325901
URL: https://svnweb.freebsd.org/changeset/base/325901

Log:
  Fix default numbers of iflib queue sets
  
  The intent appears to be having one RX/TX queue set per core,
  but since scctx->isc_n[tr]xqsets is set to max before calling
  iflib_msix_init(), both end up being set to total number of cores.
  
  Use ctx->ifc_sysctl_n[rt]xqs as the selected value and
  scctx->isc_n[rt]xqsets as the max. This should result in what appears
  to be the intended behaviour
  
  Reviewed by:  sbruno
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D13096

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cThu Nov 16 18:22:03 2017(r325900)
+++ head/sys/net/iflib.cThu Nov 16 18:52:58 2017(r325901)
@@ -5312,11 +5312,11 @@ iflib_msix_init(if_ctx_t ctx)
int iflib_num_tx_queues, iflib_num_rx_queues;
int err, admincnt, bar;
 
-   iflib_num_tx_queues = scctx->isc_ntxqsets;
-   iflib_num_rx_queues = scctx->isc_nrxqsets;
+   iflib_num_tx_queues = ctx->ifc_sysctl_ntxqs;
+   iflib_num_rx_queues = ctx->ifc_sysctl_nrxqs;
 
-   device_printf(dev, "msix_init qsets capped at %d\n", 
iflib_num_tx_queues);
-   
+   device_printf(dev, "msix_init qsets capped at %d\n", 
imax(scctx->isc_ntxqsets, scctx->isc_nrxqsets));
+
bar = ctx->ifc_softc_ctx.isc_msix_bar;
admincnt = sctx->isc_admin_intrcnt;
/* Override by global tuneable */
@@ -5414,6 +5414,10 @@ iflib_msix_init(if_ctx_t ctx)
rx_queues = iflib_num_rx_queues;
else
rx_queues = queues;
+
+   if (rx_queues > scctx->isc_nrxqsets)
+   rx_queues = scctx->isc_nrxqsets;
+
/*
 * We want this to be all logical CPUs by default
 */
@@ -5421,6 +5425,9 @@ iflib_msix_init(if_ctx_t ctx)
tx_queues = iflib_num_tx_queues;
else
tx_queues = mp_ncpus;
+
+   if (tx_queues > scctx->isc_ntxqsets)
+   tx_queues = scctx->isc_ntxqsets;
 
if (ctx->ifc_sysctl_qs_eq_override == 0) {
 #ifdef INVARIANTS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325893 - in head: . etc/mtree share/man/man7 share/man/man9 targets/pseudo/hosttools targets/pseudo/userland usr.bin usr.bin/xlint

2017-11-16 Thread Rodney W. Grimes
> Author: kib
> Date: Thu Nov 16 14:37:18 2017
> New Revision: 325893
> URL: https://svnweb.freebsd.org/changeset/base/325893
> 
> Log:
>   Remove xlint(1).
>   
>   xlint is currently a fossil.  We have much more useful and alive tools
>   to do now what xlint did twenty years ago.
>   
>   I did not cleared some stuff which makes lint operational, in
>   sys/x86/include and sys/sys, but I might do it as followup.  The
>   x86/include/ucontext.h and _types.h hacks made to please lint was the
>   main reason for my initial proposal to classify xlint as obsolete and
>   to remove it.
>   
>   Also I do not intend to clear sccs ids.
>   
>   Reviewed by:bapt, brooks, emaste, jhb, pfg
>   Sponsored by:   The FreeBSD Foundation
>   Differential revision:  https://reviews.freebsd.org/D13015
> 
> Deleted:
>   head/usr.bin/xlint/
> Modified:
>   head/ObsoleteFiles.inc
>   head/etc/mtree/BSD.usr.dist
>   head/share/man/man7/hier.7
>   head/share/man/man9/style.9
>   head/targets/pseudo/hosttools/Makefile.depend.host
>   head/targets/pseudo/userland/Makefile.depend
>   head/usr.bin/Makefile

Relnotes: Y,
And deprication procedures need to be followed.


> Modified: head/ObsoleteFiles.inc
> ==
> --- head/ObsoleteFiles.incThu Nov 16 14:27:02 2017(r325892)
> +++ head/ObsoleteFiles.incThu Nov 16 14:37:18 2017(r325893)
> @@ -38,6 +38,15 @@
>  #   xargs -n1 | sort | uniq -d;
>  # done
>  
> +# 20171116: lint(1) removal
> +OLD_FILES+=usr/bin/lint
> +OLD_FILES+=usr/libexec/lint1
> +OLD_FILES+=usr/libexec/lint2
> +OLD_FILES+=usr/libdata/lint/llib-lposix.ln
> +OLD_FILES+=usr/libdata/lint/llib-lstdc.ln
> +OLD_FILES+=usr/share/man/man1/lint.1.gz
> +OLD_FILES+=usr/share/man/man7/lint.7.gz
> +OLD_DIRS+=usr/libdata/lint
>  # 20171114: Removal of all fortune datfiles other than freebsd-tips
>  OLD_FILES+=usr/share/games/fortune/fortunes
>  OLD_FILES+=usr/share/games/fortune/fortunes.dat
> 
> Modified: head/etc/mtree/BSD.usr.dist
> ==
> --- head/etc/mtree/BSD.usr.dist   Thu Nov 16 14:27:02 2017
> (r325892)
> +++ head/etc/mtree/BSD.usr.dist   Thu Nov 16 14:37:18 2017
> (r325893)
> @@ -56,8 +56,6 @@
>  ..
>  ldscripts
>  ..
> -lint
> -..
>  pkgconfig
>  ..
>  ..
> 
> Modified: head/share/man/man7/hier.7
> ==
> --- head/share/man/man7/hier.7Thu Nov 16 14:27:02 2017
> (r325892)
> +++ head/share/man/man7/hier.7Thu Nov 16 14:37:18 2017
> (r325893)
> @@ -364,10 +364,6 @@ configuration data
>  linker scripts;
>  see
>  .Xr ld 1
> -.It Pa lint/
> -various prebuilt lint libraries;
> -see
> -.Xr lint 1
>  .El
>  .Pp
>  .It Pa libexec/
> 
> Modified: head/share/man/man9/style.9
> ==
> --- head/share/man/man9/style.9   Thu Nov 16 14:27:02 2017
> (r325892)
> +++ head/share/man/man9/style.9   Thu Nov 16 14:37:18 2017
> (r325893)
> @@ -867,14 +867,11 @@ KNF
>  compliant in the repository must not diverge from compliance.
>  .Pp
>  Whenever possible, code should be run through a code checker
> -(e.g.,
> -.Xr lint 1
> -or
> +(e.g., various static analyzers or
>  .Nm cc Fl Wall )
>  and produce minimal warnings.
>  .Sh SEE ALSO
>  .Xr indent 1 ,
> -.Xr lint 1 ,
>  .Xr err 3 ,
>  .Xr warn 3 ,
>  .Xr style.Makefile 5
> 
> Modified: head/targets/pseudo/hosttools/Makefile.depend.host
> ==
> --- head/targets/pseudo/hosttools/Makefile.depend.hostThu Nov 16 
> 14:27:02 2017(r325892)
> +++ head/targets/pseudo/hosttools/Makefile.depend.hostThu Nov 16 
> 14:37:18 2017(r325893)
> @@ -15,7 +15,6 @@ DIRDEPS = \
>   usr.bin/mkcsmapper_static \
>   usr.bin/mkesdb_static \
>   usr.bin/xinstall \
> - usr.bin/xlint/xlint \
>   usr.bin/yacc \
>   usr.sbin/config \
>   usr.sbin/crunch/crunchgen \
> 
> Modified: head/targets/pseudo/userland/Makefile.depend
> ==
> --- head/targets/pseudo/userland/Makefile.depend  Thu Nov 16 14:27:02 
> 2017(r325892)
> +++ head/targets/pseudo/userland/Makefile.depend  Thu Nov 16 14:37:18 
> 2017(r325893)
> @@ -416,10 +416,6 @@ DIRDEPS+

Re: svn commit: r316980 - head/contrib/zstd/programs

2017-11-16 Thread Allan Jude
On 2017-11-16 04:04, Baptiste Daroussin wrote:
> On Wed, Nov 15, 2017 at 07:38:13PM -0800, Conrad Meyer wrote:
>> Please revert this change.
>>
>> First, it introduces the POLA-violating behavior that zstdcat deletes
>> its source files.  This is not how zcat/bzcat behaves.
> 
> This is not a POLA-violating behavior, this is a bug! that I introduced.
>>
>> Second, it introduces a needless behavioral difference between FreeBSD
>> zstd and the rest of the world's zstd.  The zstd documentation we ship
>> continues to claim that zstd preserves source files by default, yet
>> this change makes that documentation exactly backwards.  While we can
>> change FreeBSD's documentation to accommodate the change, we can't
>> change Google results.
>>
> 
> The difference has been made so that zstd follow by default the same behaviour
> has gzip/bzip2/xz so it can be a dropped in replacement.
> 
> The argument about the documentation is however a good one. Let me do first 
> some
> tests to ensure restoring the initial behaviour does not break existing usage 
> in
> base
> 
> Best regards,
> Bapt
> 

I think in this case, it is safer to surprise the user by NOT deleting a
file, than to surprise a user by DELETING a file.

If you really want to modify the behaviour (I suggest we don't, and
stick closer to upstream zstd), then you'll want to set the 'delete'
flag for the specific invocation cases inside zstdcli.c, rather than
modifying the default as was done in this commit.

I think we can deal with changing the default verbosity level.

I think if we want to compromise, we make 2 additional hard links, zzip
and zunzip that maintain the gzip like behaviour, since those will not
conflict with the documentation that exists in the rest of the world for
zstd(1)

-- 
Allan Jude



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r325860 - head/sbin/newfs

2017-11-16 Thread Warner Losh
On Wed, Nov 15, 2017 at 11:29 PM, John Baldwin  wrote:

> On Wednesday, November 15, 2017 10:17:27 PM Warner Losh wrote:
> > On Wed, Nov 15, 2017 at 6:46 PM, Ed Maste  wrote:
> >
> > > On 15 November 2017 at 19:36, Warner Losh  wrote:
> > > >
> > > > On Wed, Nov 15, 2017 at 5:05 PM, Ed Maste 
> wrote:
> > > >>
> > > >> On 15 November 2017 at 13:47, Rodney W. Grimes
> > > >>  wrote:
> > > >> >> Author: emaste
> > > >> >> Date: Wed Nov 15 18:40:40 2017
> > > >> >> New Revision: 325860
> > > >> >> URL: https://svnweb.freebsd.org/changeset/base/325860
> > > >> >>
> > > >> >> Log:
> > > >> >>   newfs: warn if newer than kernel
> > > >> >>
> > > >> >>   Creating a UFS filesystem with a newfs newer than the running
> > > kernel,
> > > >> >>   and then mounting that filesystem, can lead to interesting
> > > failures.
> > > >> >>
> > > >> >>   Add a safety belt to explicitly warn when newfs is newer than
> the
> > > >> >>   running kernel.
> > > >> >
> > > >> > You should probably make the warning if (newer || older) as
> > > >> > either is likely to have interesting side effects, as are
> > > >> > mounting ufs file systems on different versions.
> > > >>
> > > >> Why would an older newfs cause trouble? Forward compatibility
> should be
> > > >> fine
> > > >
> > > > The only scenario that 'old' would cause problems is that if you did
> a
> > > newfs
> > > > with a new binary on a new kernel, mounted the file system, wrote
> files
> > > to
> > > > it, then rebooted with an old kernel, mounted the filesystem there,
> > > writing
> > > > new files to it, and then unmounting and running with a new kernel.
> > >
> > > Right, but that's not older newfs. AFAICT there's no reason at all for
> > > a (newer || older) warning.
> >
> >
> > I concur.
> >
> > > I'm not sure that the new safety belt is reasonable. Today it's fine,
> but
> > > > over time it will start producing false-positive warnings since the
> real
> > > > issue is just before/after the cg change, not old/new in general.
> I'd be
> > > > tempted to make a check against newfs being >= 1200046 while the
> kernel
> > > is <
> > > > 1200046. There wasn't a specific bump for this change to
> sys/param.h, but
> > > > this version was bumped within a few hours of Kirk's change.
> > >
> > > Well, we don't in general support using a userland newer than the
> > > running kernel, other than on a best-effort basis to facilitate
> > > upgrades and development. This one is only a warning so I don't see
> > > much harm in leaving it in place, and it would catch any new cases of
> > > a similar nature. If such a warning was already in place we might have
> > > avoided the issue where our snapshots produced checksum mismatch
> > > messages. But I don't have a strong objection to a hardcoded version
> > > check.
> > >
> >
> > What would have fixed the snapshot isn't a warning that nobody will
> notice.
> > But rather something like the following:
>
> No, what would really fix the snapshot is using makefs or the host newfs
> instead of the target newfs during the build.  That part of the release
> process is still fundamentally broken and fixing that wouldn't require
> various
> one-off fixes for future changes that happen to introduce compatability but
> would fix the entire class of issues.
>

I agree with that. However, more than just FreeBSD's release process uses
the newly built tools to do things, so those tools shouldn't do dangerous
things when it's trivial to know not to. They are orthogonal issues, imho.
Netflix's upgrade process, for example, uses the new newfs on an old
kernel, mounts the filesystem and then splats new content into the
filesystem. The issue is larger than our somewhat imperfect (but working)
release building process.

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


svn commit: r325897 - head/tools

2017-11-16 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Nov 16 15:26:39 2017
New Revision: 325897
URL: https://svnweb.freebsd.org/changeset/base/325897

Log:
  Improve the library dependencies helper script in src/tools.
  
  Implement double pass of the relevant Makefiles. First make a list of
  library names and directories and then scan for all the dependencies.
  Spaces in directories in the source tree are not supported.
  
  This avoids using hardcoded mappings between the library name
  and the directory containing the library Makefile.
  
  Add support for scanning contrib/ofed .
  
  Bail out on any errors.
  
  Sponsored by: Mellanox Technologies
  MFC after:1 week

Modified:
  head/tools/make_libdeps.sh

Modified: head/tools/make_libdeps.sh
==
--- head/tools/make_libdeps.sh  Thu Nov 16 15:18:36 2017(r325896)
+++ head/tools/make_libdeps.sh  Thu Nov 16 15:26:39 2017(r325897)
@@ -28,9 +28,12 @@
 
 export PATH=/bin:/usr/bin
 
+set -e
+
 LC_ALL=C   # make sort deterministic
 FS=': '# internal field separator
 LIBDEPENDS=./_libdeps  # intermediate output file
+LIBDIRS=./_libdirs # intermediate output file
 USRSRC=${1:-/usr/src}  # source root
 LIBS="
lib
@@ -39,44 +42,74 @@ LIBS="
secure/lib
usr.bin/lex/lib
cddl/lib
+   contrib/ofed
 "  # where to scan for libraries
 
-# This sed(1) filter is used to convert -lfoo to path/to/libfoo.
-#
-SED_FILTER="
-sed -E
--e's; ;! ;g'
--e's;$;!;'
--e's;-lbsdxml!;lib/libexpat;g'
--e's;-lpthread!;lib/libthr;g'
--e's;-lm!;lib/msun;g'
--e's;-l(ncurses|termcap)!;lib/ncurses/ncurses;g'
--e's;-l(gcc)!;gnu/lib/lib\1;g'
--e's;-lssp_nonshared!;gnu/lib/libssp/libssp_nonshared;g'
-
-e's;-l(asn1|hdb|kdc|heimbase|heimntlm|heimsqlite|hx509|krb5|roken|wind)!;kerberos5/lib/lib\1;g'
--e's;-l(crypto|ssh|ssl)!;secure/lib/lib\1;g'
--e's;-l([^!]+)!;lib/lib\1;g'
-"
 
+# convert -lfoo to foo
+convert()
+{
+sed -e "s/\-l//g" -e "s/pthread/thr/g" -e "s/ncurses.*/ncurses/g"
+}
+
+# find library build directory given library name
+findlibdir()
+{
+   while read NAME && read DIR
+   do
+   if [ "$NAME" = "$1" ]; then
+   echo "$DIR"
+   exit
+   fi
+   done
+
+   # Should not happen
+   echo lib_not_found/lib$1
+}
+
+# find library build directories given one or more library names
+resolvelibdirs()
+{
+   while read LIBNAME
+   do
+   cat $LIBDIRS | tr ' ' '\n' | findlibdir "$LIBNAME"
+   done
+}
+
 # Generate interdependencies between libraries.
 #
 genlibdepends()
 {
(
+   # Reset file
+   echo -n > $LIBDIRS
+
+   # First pass - generate list of directories
cd ${USRSRC}
-   find -s ${LIBS} -mindepth 1 -name Makefile |
+   find -s ${LIBS} -name Makefile |
xargs grep -l 'bsd\.lib\.mk' |
while read makefile; do
libdir=$(dirname ${makefile})
+   libname=$(
+   cd ${libdir}
+   make -m ${USRSRC}/share/mk WITH_OFED=YES -V LIB
+   )
+   if [ "${libname}" ]; then
+   echo "${libname} ${libdir}" >> $LIBDIRS
+   fi
+   done
+
+   # Second pass - generate dependencies
+   find -s ${LIBS} -name Makefile |
+   xargs grep -l 'bsd\.lib\.mk' |
+   while read makefile; do
+   libdir=$(dirname ${makefile})
deps=$(
cd ${libdir}
-   make -m ${USRSRC}/share/mk -V LDADD
+   make -m ${USRSRC}/share/mk WITH_OFED=YES -V 
LDADD
)
if [ "${deps}" ]; then
-   echo ${libdir}"${FS}"$(
-   echo ${deps} |
-   eval ${SED_FILTER}
-   )
+   echo ${libdir}"${FS}"$(echo ${deps} | tr ' ' 
'\n' | convert | resolvelibdirs)
fi
done
)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325893 - in head: . etc/mtree share/man/man7 share/man/man9 targets/pseudo/hosttools targets/pseudo/userland usr.bin usr.bin/xlint

2017-11-16 Thread Konstantin Belousov
Author: kib
Date: Thu Nov 16 14:37:18 2017
New Revision: 325893
URL: https://svnweb.freebsd.org/changeset/base/325893

Log:
  Remove xlint(1).
  
  xlint is currently a fossil.  We have much more useful and alive tools
  to do now what xlint did twenty years ago.
  
  I did not cleared some stuff which makes lint operational, in
  sys/x86/include and sys/sys, but I might do it as followup.  The
  x86/include/ucontext.h and _types.h hacks made to please lint was the
  main reason for my initial proposal to classify xlint as obsolete and
  to remove it.
  
  Also I do not intend to clear sccs ids.
  
  Reviewed by:  bapt, brooks, emaste, jhb, pfg
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D13015

Deleted:
  head/usr.bin/xlint/
Modified:
  head/ObsoleteFiles.inc
  head/etc/mtree/BSD.usr.dist
  head/share/man/man7/hier.7
  head/share/man/man9/style.9
  head/targets/pseudo/hosttools/Makefile.depend.host
  head/targets/pseudo/userland/Makefile.depend
  head/usr.bin/Makefile

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Nov 16 14:27:02 2017(r325892)
+++ head/ObsoleteFiles.inc  Thu Nov 16 14:37:18 2017(r325893)
@@ -38,6 +38,15 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20171116: lint(1) removal
+OLD_FILES+=usr/bin/lint
+OLD_FILES+=usr/libexec/lint1
+OLD_FILES+=usr/libexec/lint2
+OLD_FILES+=usr/libdata/lint/llib-lposix.ln
+OLD_FILES+=usr/libdata/lint/llib-lstdc.ln
+OLD_FILES+=usr/share/man/man1/lint.1.gz
+OLD_FILES+=usr/share/man/man7/lint.7.gz
+OLD_DIRS+=usr/libdata/lint
 # 20171114: Removal of all fortune datfiles other than freebsd-tips
 OLD_FILES+=usr/share/games/fortune/fortunes
 OLD_FILES+=usr/share/games/fortune/fortunes.dat

Modified: head/etc/mtree/BSD.usr.dist
==
--- head/etc/mtree/BSD.usr.dist Thu Nov 16 14:27:02 2017(r325892)
+++ head/etc/mtree/BSD.usr.dist Thu Nov 16 14:37:18 2017(r325893)
@@ -56,8 +56,6 @@
 ..
 ldscripts
 ..
-lint
-..
 pkgconfig
 ..
 ..

Modified: head/share/man/man7/hier.7
==
--- head/share/man/man7/hier.7  Thu Nov 16 14:27:02 2017(r325892)
+++ head/share/man/man7/hier.7  Thu Nov 16 14:37:18 2017(r325893)
@@ -364,10 +364,6 @@ configuration data
 linker scripts;
 see
 .Xr ld 1
-.It Pa lint/
-various prebuilt lint libraries;
-see
-.Xr lint 1
 .El
 .Pp
 .It Pa libexec/

Modified: head/share/man/man9/style.9
==
--- head/share/man/man9/style.9 Thu Nov 16 14:27:02 2017(r325892)
+++ head/share/man/man9/style.9 Thu Nov 16 14:37:18 2017(r325893)
@@ -867,14 +867,11 @@ KNF
 compliant in the repository must not diverge from compliance.
 .Pp
 Whenever possible, code should be run through a code checker
-(e.g.,
-.Xr lint 1
-or
+(e.g., various static analyzers or
 .Nm cc Fl Wall )
 and produce minimal warnings.
 .Sh SEE ALSO
 .Xr indent 1 ,
-.Xr lint 1 ,
 .Xr err 3 ,
 .Xr warn 3 ,
 .Xr style.Makefile 5

Modified: head/targets/pseudo/hosttools/Makefile.depend.host
==
--- head/targets/pseudo/hosttools/Makefile.depend.host  Thu Nov 16 14:27:02 
2017(r325892)
+++ head/targets/pseudo/hosttools/Makefile.depend.host  Thu Nov 16 14:37:18 
2017(r325893)
@@ -15,7 +15,6 @@ DIRDEPS = \
usr.bin/mkcsmapper_static \
usr.bin/mkesdb_static \
usr.bin/xinstall \
-   usr.bin/xlint/xlint \
usr.bin/yacc \
usr.sbin/config \
usr.sbin/crunch/crunchgen \

Modified: head/targets/pseudo/userland/Makefile.depend
==
--- head/targets/pseudo/userland/Makefile.dependThu Nov 16 14:27:02 
2017(r325892)
+++ head/targets/pseudo/userland/Makefile.dependThu Nov 16 14:37:18 
2017(r325893)
@@ -416,10 +416,6 @@ DIRDEPS+= \
usr.bin/write \
usr.bin/xargs \
usr.bin/xinstall \
-   usr.bin/xlint/lint1 \
-   usr.bin/xlint/lint2 \
-   usr.bin/xlint/llib \
-   usr.bin/xlint/xlint \
usr.bin/xo \
usr.bin/xstr \
usr.bin/xz \

Modified: head/usr.bin/Makefile
==
--- head/usr.bin/Makefile   Thu Nov 16 14:27:02 2017(r325892)
+++ head/usr.bin/Makefile   Thu Nov 16 14:37:18 2017(r325893)
@@ -278,9 +278,6 @@ SUBDIR.${MK_TOOLCHAIN}+=rpcgen
 SUBDIR.${MK_TOOLCHAIN}+=   unifdef
 SUBDIR.${MK_TOOLCHAIN}+=   size
 SUBDIR.${MK_TOOLCHAIN}+=   strings
-.if ${MACHINE_ARCH} != "aarch64" # ARM64TODO xlint does not bui

svn commit: r325892 - in head/sys: conf i386/conf i386/i386 i386/include i386/pci i386/xbox isa x86/x86

2017-11-16 Thread Konstantin Belousov
Author: kib
Date: Thu Nov 16 14:27:02 2017
New Revision: 325892
URL: https://svnweb.freebsd.org/changeset/base/325892

Log:
  Remove i386 XBOX support.
  
  It is for console presented at 2001 and featuring Pentium III
  processor.  Even if any of them are still alive and run FreeBSD, we do
  not have any sign of life from their users.  While removing another
  dozens of #ifdefs from the i386 sources reduces the aversion from
  looking at the code and improves the platform vitality.
  
  Reviewed by:  cem, pfg, rink (XBOX support author)
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D13016

Deleted:
  head/sys/i386/conf/XBOX
  head/sys/i386/include/xbox.h
  head/sys/i386/xbox/
Modified:
  head/sys/conf/files.i386
  head/sys/conf/options
  head/sys/i386/conf/NOTES
  head/sys/i386/i386/machdep.c
  head/sys/i386/i386/pmap.c
  head/sys/i386/i386/vm_machdep.c
  head/sys/i386/pci/pci_cfgreg.c
  head/sys/isa/syscons_isa.c
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/conf/files.i386
==
--- head/sys/conf/files.i386Thu Nov 16 13:28:00 2017(r325891)
+++ head/sys/conf/files.i386Thu Nov 16 14:27:02 2017(r325892)
@@ -549,10 +549,6 @@ libkern/ucmpdi2.c  standard
 libkern/udivdi3.c  standard
 libkern/umoddi3.c  standard
 libkern/x86/crc32_sse42.c  standard
-i386/xbox/xbox.c   optional xbox
-i386/xbox/xboxfb.c optional xboxfb
-dev/fb/boot_font.c optional xboxfb
-i386/xbox/pic16l.s optional xbox
 #
 # x86 real mode BIOS support, required by dpms/pci/vesa
 #

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Thu Nov 16 13:28:00 2017(r325891)
+++ head/sys/conf/options   Thu Nov 16 14:27:02 2017(r325892)
@@ -892,9 +892,6 @@ HWPMC_DEBUG opt_global.h
 HWPMC_HOOKS
 HWPMC_MIPS_BACKTRACE   opt_hwpmc_hooks.h
 
-# XBOX options for FreeBSD/i386, but some files are MI
-XBOX   opt_xbox.h
-
 # Interrupt filtering
 INTR_FILTER
 

Modified: head/sys/i386/conf/NOTES
==
--- head/sys/i386/conf/NOTESThu Nov 16 13:28:00 2017(r325891)
+++ head/sys/i386/conf/NOTESThu Nov 16 14:27:02 2017(r325892)
@@ -221,23 +221,6 @@ optionsNPX_DEBUG   # enable npx debugging
 #
 optionsPERFMON
 
-#
-# XBOX causes the kernel to be bootable on the Microsoft XBox console system.
-# The resulting kernel will auto-detect whether it is being booted on a XBox,
-# so kernels compiled with this option will also work on an ordinary PC.
-# This option require I686_CPU.
-#
-# xboxfb includes support for the XBox frame buffer device. It is fully USB-
-# keyboard aware, and will only be used if an xbox is detected. This option
-# (obviously) requires XBOX support in your kernel.
-#
-# NOTE: xboxfb currently conflicts with syscons(4); if you have an XBOX and
-# include both in your kernel; you will not get any video output. Ordinary
-# PC's do not suffer from this.
-#
-optionsXBOX
-device xboxfb
-
 
 #
 # NETWORKING OPTIONS

Modified: head/sys/i386/i386/machdep.c
==
--- head/sys/i386/i386/machdep.cThu Nov 16 13:28:00 2017
(r325891)
+++ head/sys/i386/i386/machdep.cThu Nov 16 14:27:02 2017
(r325892)
@@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
 #include "opt_mp_watchdog.h"
 #include "opt_perfmon.h"
 #include "opt_platform.h"
-#include "opt_xbox.h"
 
 #include 
 #include 
@@ -148,13 +147,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
-#ifdef XBOX
-#include 
-
-int arch_i386_is_xbox = 0;
-uint32_t arch_i386_xbox_memsize = 0;
-#endif
-
 /* Sanity check for __curthread() */
 CTASSERT(offsetof(struct pcpu, pc_curthread) == 0);
 
@@ -1780,18 +1772,6 @@ getmemsize(int first)
caddr_t kmdp;
 
has_smap = 0;
-#ifdef XBOX
-   if (arch_i386_is_xbox) {
-   /*
-* We queried the memory size before, so chop off 4MB for
-* the framebuffer and inform the OS of this.
-*/
-   physmap[0] = 0;
-   physmap[1] = (arch_i386_xbox_memsize * 1024 * 1024) - 
XBOX_FB_SIZE;
-   physmap_idx = 0;
-   goto physmap_done;
-   }
-#endif
bzero(, sizeof(vmf));
bzero(physmap, sizeof(physmap));
basemem = 0;
@@ -2299,28 +2279,6 @@ init386(int first)
r_idt.rd_limit = sizeof(idt0) - 1;
r_idt.rd_base = (int) idt;
lidt(_idt);
-
-#ifdef XBOX
-   /*
-* The following code queries the PCI ID of 0:0:0. For the XBOX,
-* This should be 0x10de / 0x02a5.
-   

svn commit: r325888 - in head/sys/cam: ata scsi

2017-11-16 Thread Baptiste Daroussin
Author: bapt
Date: Thu Nov 16 10:15:17 2017
New Revision: 325888
URL: https://svnweb.freebsd.org/changeset/base/325888

Log:
  Add some 4k quirks for Samsung pm863a SSDs
  
  Submitted by: Nikita Kozlov 
  MFC after:3 days
  Sponsored by: blade
  Differential Revision:https://reviews.freebsd.org/D13093

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Thu Nov 16 07:25:12 2017(r325887)
+++ head/sys/cam/ata/ata_da.c   Thu Nov 16 10:15:17 2017(r325888)
@@ -696,6 +696,14 @@ static struct ada_quirk_entry ada_quirk_table[] =
},
{
/*
+* Same as for SAMSUNG MZ7* but enable the quirks for SSD
+* starting with MZ7* too
+*/
+   { T_DIRECT, SIP_MEDIA_FIXED, "*", "MZ7*", "*" },
+   /*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
+   },
+   {
+   /*
 * Samsung PM851 Series SSDs Dell OEM
 * device model  "SAMSUNG SSD PM851 mSATA 256GB"
 * 4k optimised, NCQ broken

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Thu Nov 16 07:25:12 2017(r325887)
+++ head/sys/cam/scsi/scsi_da.c Thu Nov 16 10:15:17 2017(r325888)
@@ -1311,6 +1311,14 @@ static struct da_quirk_entry da_quirk_table[] =
},
{
/*
+* Same as for SAMSUNG MZ7* but enable the quirks for SSD
+* starting with MZ7* too
+*/
+   { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "MZ7*", "*" },
+   /*quirks*/DA_Q_4K
+   },
+   {
+   /*
 * SuperTalent TeraDrive CT SSDs
 * 4k optimised & trim only works in 4k requests + 4k aligned
 */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325765 - head/lib/libc/string

2017-11-16 Thread Mark Millard

On 2017-Nov-15, at 11:15 PM, Bruce Evans  wrote:

> On Wed, 15 Nov 2017, Mark Millard wrote:
> 
>> Bruce Evans brde at optusnet.com.au wrote on
>> Tue Nov 14 12:41:50 UTC 2017 :
>> 
>>> . . .
> 
>> head/sys/arm/arm/support.S ( -r283366 ) has
>> 
>> 394  ENTRY(bcopy)
>> 395  /* switch the source and destination registers */
>> 396  eor r0, r1, r0
>> 397  eor r1, r0, r1
>> 398  eor r0, r1, r0
>> 399  EENTRY(memmove)
>> 400  /* Do the buffers overlap? */
>> 401  cmp r0, r1
>> 402  RETeq   /* Bail now if src/dst are the same */
>> 403  subcc   r3, r0, r1  /* if (dst > src) r3 = dst - src */
>> 404  subcs   r3, r1, r0  /* if (src > dsr) r3 = src - dst */
>> 405  cmp r3, r2  /* if (r3 < len) we have an overlap */
>> 406  bcc PIC_SYM(_C_LABEL(memcpy), PLT)
>> . . .
> 
> . . .
> 
>> head/lib/libc/arm/string/memmove.S ( -r288373 ) has:
>> 
>> 37   #ifndef _BCOPY
>> 38   /* LINTSTUB: Func: void *memmove(void *, const void *, size_t) */
>> 39   ENTRY(memmove)
>> 40   #else
>> 41   /* bcopy = memcpy/memmove with arguments reversed. */
>> 42   /* LINTSTUB: Func: void bcopy(void *, void *, size_t) */
>> 43   ENTRY(bcopy)
>> 44   /* switch the source and destination registers */
>> 45   eor r0, r1, r0
>> 46   eor r1, r0, r1
>> 47   eor r0, r1, r0
>> 48   #endif
> 
> . . .
> 
>> 49   /* Do the buffers overlap? */
>> 50   cmp r0, r1
>> 51   it  eq
>> 52   RETeq   /* Bail now if src/dst are the same */
>> 53   ite cc
>> 54   subcc   r3, r0, r1  /* if (dst > src) r3 = dst - src */
>> 55   subcs   r3, r1, r0  /* if (src > dsr) r3 = src - dst */
>> 56   cmp r3, r2  /* if (r3 < len) we have an overlap */
>> 57   bcc PIC_SYM(_C_LABEL(memcpy), PLT)
>> . . .
>> 
>> . . .
> 
> The above only shows memmove() calling bcopy(), only in the kernel.
> . . .

I was referring to the "bcc PIC_SYM(_C_LABEL(memcpy), PLT)", which
jumps to memcpy, not to bcopy. In both bcopy and memcopy there
is the conditional jump to memcpy, in both libc/arm/string/memmove.S
and sys/arm/arm/support.S .

(I claim that the selection code is wrong and should follow the
later netbsd update. Netbsd used to have code like the above
for those details. But that is not the primary point here. Also:
This note is from my memory of the issue, not a recent recheck.)

>> ...
>> Another issue is if compilers (clang, gcc) are well
>> controlled for code substitutions to preserve
>> supposed FreeBSD rules about where overlaps
>> are well defined. The library code might not be all
>> there is to it as far as behavior goes for
>> compiled C/C++ source code.
> 
> Do you mean the namespace stuff?

No, I meant what you later referred to with:

QUOTE
 Without -ffreestanding,
compilers can and do often implement memcpy inline.  Then overlapping
copies are not supported.  The BUGS section in memcpy.3 should just be
deleted.
END QUOTE

Sufficient memcpy behavior documentation for C/C++/. . .
has to consider compiler code generation as well, not
just what the library code does if called.

>> head/sys/arm64/arm64/ is similar for bcopy/memmove
>> calling memcpy (but head/lib/libc/amd64/string/ is
>> not):
> 
> It is reasonable, and possibly best, to implement the usual
> non-overlapping case by a call to memcpy() and not try hard to
> optimize the overlapping case (or jump far away to it to keep
> caches cleaner for the usual case).

arm (32-bit) has code attempting to pick when to
do a "bcc PIC_SYM(_C_LABEL(memcpy), PLT)" from
memmove and from bcopy.

>> head/sys/arm64/arm64/memmove.S ( -r307909 ) has:
>> ...
>> head/lib/libc/amd64/string/bcopy.S has:
>> ...

My switch to looking at libc/amd64/'s bcopy.S was
unintentional. I was thinking of arm64 when looking
at amd64 --even though there was a libc/aarch64/
right there to see as well.

head/contrib/cortex-strings/src/aarch64/memmove.S's
code has memmove use memcpy for backwards copies
with overlapping objects and for forward copies with
small-enough overlapping objects.

(head/contrib/cortex-strings/src/aarch64/memcpy.S
handles overlaps in small-enough objects by reading
the object in completely before writing any of it
back out. memmove depends on such details.)

The details here are different from the 32-bit arm
handling of memmove and memcpy.

===
Mark Millard
markmi at dsl-only.net

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


Re: svn commit: r316980 - head/contrib/zstd/programs

2017-11-16 Thread Baptiste Daroussin
On Wed, Nov 15, 2017 at 07:38:13PM -0800, Conrad Meyer wrote:
> Please revert this change.
> 
> First, it introduces the POLA-violating behavior that zstdcat deletes
> its source files.  This is not how zcat/bzcat behaves.

This is not a POLA-violating behavior, this is a bug! that I introduced.
> 
> Second, it introduces a needless behavioral difference between FreeBSD
> zstd and the rest of the world's zstd.  The zstd documentation we ship
> continues to claim that zstd preserves source files by default, yet
> this change makes that documentation exactly backwards.  While we can
> change FreeBSD's documentation to accommodate the change, we can't
> change Google results.
> 

The difference has been made so that zstd follow by default the same behaviour
has gzip/bzip2/xz so it can be a dropped in replacement.

The argument about the documentation is however a good one. Let me do first some
tests to ensure restoring the initial behaviour does not break existing usage in
base

Best regards,
Bapt


signature.asc
Description: PGP signature