svn commit: r267220 - head/sys/netinet6

2014-06-08 Thread Andrey V. Elsukov
Author: ae
Date: Sun Jun  8 09:08:51 2014
New Revision: 267220
URL: http://svnweb.freebsd.org/changeset/base/267220

Log:
  Remove unused variable.
  
  Sponsored by: Yandex LLC

Modified:
  head/sys/netinet6/ip6_forward.c

Modified: head/sys/netinet6/ip6_forward.c
==
--- head/sys/netinet6/ip6_forward.c Sun Jun  8 06:35:08 2014
(r267219)
+++ head/sys/netinet6/ip6_forward.c Sun Jun  8 09:08:51 2014
(r267220)
@@ -104,7 +104,6 @@ ip6_forward(struct mbuf *m, int srcrt)
struct in6_addr src_in6, dst_in6, odst;
 #ifdef IPSEC
struct secpolicy *sp = NULL;
-   int ipsecrt = 0;
 #endif
 #ifdef SCTP
int sw_csum;
@@ -383,11 +382,7 @@ again2:
IP6STAT_INC(ip6s_badscope);
goto bad;
}
-   if (inzone != outzone
-#ifdef IPSEC
-   && !ipsecrt
-#endif
-   ) {
+   if (inzone != outzone) {
IP6STAT_INC(ip6s_cantforward);
IP6STAT_INC(ip6s_badscope);
in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard);
@@ -477,9 +472,6 @@ again2:
 * modified by a redirect.
 */
if (V_ip6_sendredirects && rt->rt_ifp == m->m_pkthdr.rcvif && !srcrt &&
-#ifdef IPSEC
-   !ipsecrt &&
-#endif /* IPSEC */
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0) {
if ((rt->rt_ifp->if_flags & IFF_POINTOPOINT) != 0) {
/*
@@ -656,10 +648,6 @@ pass:
 bad:
m_freem(m);
 out:
-   if (rt != NULL
-#ifdef IPSEC
-   && !ipsecrt
-#endif
-   )
+   if (rt != NULL)
RTFREE(rt);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267221 - in head/sys: nfs rpc

2014-06-08 Thread Alexander Motin
Author: mav
Date: Sun Jun  8 09:40:26 2014
New Revision: 267221
URL: http://svnweb.freebsd.org/changeset/base/267221

Log:
  Introduce new per-thread lock to protect the list of requests.
  
  This allows to slightly simplify svc_run_internal() code: if we processed
  all the requests in a queue, then we know that new one will not appear.
  
  MFC after:2 weeks

Modified:
  head/sys/nfs/nfs_fha.c
  head/sys/rpc/svc.c
  head/sys/rpc/svc.h

Modified: head/sys/nfs/nfs_fha.c
==
--- head/sys/nfs/nfs_fha.c  Sun Jun  8 09:08:51 2014(r267220)
+++ head/sys/nfs/nfs_fha.c  Sun Jun  8 09:40:26 2014(r267221)
@@ -288,11 +288,7 @@ fha_hash_entry_add_op(struct fha_hash_en
  * Get the service thread currently associated with the fhe that is
  * appropriate to handle this operation.
  */
-SVCTHREAD *
-fha_hash_entry_choose_thread(struct fha_params *softc,
-struct fha_hash_entry *fhe, struct fha_info *i, SVCTHREAD *this_thread);
-
-SVCTHREAD *
+static SVCTHREAD *
 fha_hash_entry_choose_thread(struct fha_params *softc,
 struct fha_hash_entry *fhe, struct fha_info *i, SVCTHREAD *this_thread)
 {
@@ -428,13 +424,13 @@ fha_assign(SVCTHREAD *this_thread, struc
 * Grab the pool lock here to not let chosen thread go away before
 * the new request inserted to its queue while we drop fhe lock.
 */
-   mtx_lock(&(*softc->pool)->sp_lock);
+   mtx_lock(&thread->st_lock);
mtx_unlock(fhe->mtx);
 
return (thread);
 thist:
req->rq_p1 = NULL;
-   mtx_lock(&(*softc->pool)->sp_lock);
+   mtx_lock(&this_thread->st_lock);
return (this_thread);
 }
 

Modified: head/sys/rpc/svc.c
==
--- head/sys/rpc/svc.c  Sun Jun  8 09:08:51 2014(r267220)
+++ head/sys/rpc/svc.c  Sun Jun  8 09:40:26 2014(r267221)
@@ -1070,7 +1070,6 @@ svc_request_space_available(SVCPOOL *poo
 static void
 svc_run_internal(SVCPOOL *pool, bool_t ismaster)
 {
-   struct svc_reqlist reqs;
SVCTHREAD *st, *stpref;
SVCXPRT *xprt;
enum xprt_stat stat;
@@ -1079,11 +1078,11 @@ svc_run_internal(SVCPOOL *pool, bool_t i
int error;
 
st = mem_alloc(sizeof(*st));
+   mtx_init(&st->st_lock, "st_lock", NULL, MTX_DEF);
st->st_pool = pool;
st->st_xprt = NULL;
STAILQ_INIT(&st->st_reqs);
cv_init(&st->st_cond, "rpcsvc");
-   STAILQ_INIT(&reqs);
 
mtx_lock(&pool->sp_lock);
LIST_INSERT_HEAD(&pool->sp_threads, st, st_link);
@@ -1117,7 +1116,7 @@ svc_run_internal(SVCPOOL *pool, bool_t i
}
 
xprt = st->st_xprt;
-   if (!xprt && STAILQ_EMPTY(&st->st_reqs)) {
+   if (!xprt) {
/*
 * Enforce maxthreads count.
 */
@@ -1159,8 +1158,7 @@ svc_run_internal(SVCPOOL *pool, bool_t i
if (!ismaster
&& (pool->sp_threadcount
> pool->sp_minthreads)
-   && !st->st_xprt
-   && STAILQ_EMPTY(&st->st_reqs))
+   && !st->st_xprt)
break;
} else if (error) {
mtx_unlock(&pool->sp_lock);
@@ -1170,93 +1168,69 @@ svc_run_internal(SVCPOOL *pool, bool_t i
}
continue;
}
+   mtx_unlock(&pool->sp_lock);
 
-   if (xprt) {
-   /*
-* Drain the transport socket and queue up any
-* RPCs.
-*/
-   xprt->xp_lastactive = time_uptime;
-   do {
-   if (!svc_request_space_available(pool))
-   break;
-   mtx_unlock(&pool->sp_lock);
-   rqstp = NULL;
-   stat = svc_getreq(xprt, &rqstp);
-   if (rqstp) {
-   svc_change_space_used(pool, 
rqstp->rq_size);
-   /*
-* See if the application has
-* a preference for some other
-* thread.
-*/
-   stpref = st;
-   if (pool->sp_assign)
-   stpref = pool->sp_assign(st,
-   rqstp);
-   else
-   

svn commit: r267223 - head/sys/rpc

2014-06-08 Thread Alexander Motin
Author: mav
Date: Sun Jun  8 10:18:22 2014
New Revision: 267223
URL: http://svnweb.freebsd.org/changeset/base/267223

Log:
  Remove st_idle variable, duplicating st_xprt.
  
  MFC after:2 weeks

Modified:
  head/sys/rpc/svc.c
  head/sys/rpc/svc.h

Modified: head/sys/rpc/svc.c
==
--- head/sys/rpc/svc.c  Sun Jun  8 09:49:42 2014(r267222)
+++ head/sys/rpc/svc.c  Sun Jun  8 10:18:22 2014(r267223)
@@ -340,7 +340,6 @@ xprt_assignthread(SVCXPRT *xprt)
st = LIST_FIRST(&pool->sp_idlethreads);
if (st) {
LIST_REMOVE(st, st_ilink);
-   st->st_idle = FALSE;
SVC_ACQUIRE(xprt);
xprt->xp_thread = st;
st->st_xprt = xprt;
@@ -1138,7 +1137,6 @@ svc_run_internal(SVCPOOL *pool, bool_t i
}
 
LIST_INSERT_HEAD(&pool->sp_idlethreads, st, st_ilink);
-   st->st_idle = TRUE;
if (ismaster || (!ismaster &&
pool->sp_threadcount > pool->sp_minthreads))
error = cv_timedwait_sig(&st->st_cond,
@@ -1146,10 +1144,8 @@ svc_run_internal(SVCPOOL *pool, bool_t i
else
error = cv_wait_sig(&st->st_cond,
&pool->sp_lock);
-   if (st->st_idle) {
+   if (st->st_xprt == NULL)
LIST_REMOVE(st, st_ilink);
-   st->st_idle = FALSE;
-   }
 
/*
 * Reduce worker thread count when idle.

Modified: head/sys/rpc/svc.h
==
--- head/sys/rpc/svc.h  Sun Jun  8 09:49:42 2014(r267222)
+++ head/sys/rpc/svc.h  Sun Jun  8 10:18:22 2014(r267223)
@@ -295,7 +295,6 @@ typedef struct __rpc_svcthread {
struct __rpc_svcpool*st_pool;
SVCXPRT *st_xprt; /* transport we are processing */
struct svc_reqlist  st_reqs;  /* RPC requests to execute */
-   int st_idle; /* thread is on idle list */
struct cv   st_cond; /* sleeping for work */
LIST_ENTRY(__rpc_svcthread) st_link; /* all threads list */
LIST_ENTRY(__rpc_svcthread) st_ilink; /* idle threads list */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267226 - in head/sys: conf kern modules/ufs ufs/ffs

2014-06-08 Thread Konstantin Belousov
Author: kib
Date: Sun Jun  8 10:55:06 2014
New Revision: 267226
URL: http://svnweb.freebsd.org/changeset/base/267226

Log:
  Initialize the pbuf counter for directio using SYSINIT, instead of
  using a direct hook called from kern_vfs_bio_buffer_alloc().
  Mark ffs_rawread.c as requiring both ffs and directio options to be
  compiled into the kernel.  Add ffs_rawread.c to the list of ufs.ko
  module' sources.
  
  In addition to stopping breaking the layering violation, it also
  allows to link kernel when FFS is configured as module and DIRECTIO is
  enabled.
  
  One consequence of the change is that ffs_rawread.o is always linked
  into the module regardless of the DIRECTIO option.  This is similar to
  the option QUOTA and ufs_quota.c.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/conf/files
  head/sys/kern/vfs_bio.c
  head/sys/modules/ufs/Makefile
  head/sys/ufs/ffs/ffs_rawread.c

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sun Jun  8 10:22:03 2014(r267225)
+++ head/sys/conf/files Sun Jun  8 10:55:06 2014(r267226)
@@ -3883,7 +3883,7 @@ ufs/ffs/ffs_subr.coptional ffs
 ufs/ffs/ffs_tables.c   optional ffs
 ufs/ffs/ffs_vfsops.c   optional ffs
 ufs/ffs/ffs_vnops.coptional ffs
-ufs/ffs/ffs_rawread.c  optional directio
+ufs/ffs/ffs_rawread.c  optional ffs directio
 ufs/ffs/ffs_suspend.c  optional ffs
 ufs/ufs/ufs_acl.c  optional ffs
 ufs/ufs/ufs_bmap.c optional ffs

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Sun Jun  8 10:22:03 2014(r267225)
+++ head/sys/kern/vfs_bio.c Sun Jun  8 10:55:06 2014(r267226)
@@ -77,7 +77,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include "opt_compat.h"
-#include "opt_directio.h"
 #include "opt_swap.h"
 
 static MALLOC_DEFINE(M_BIOBUF, "biobuf", "BIO buffer");
@@ -382,10 +381,6 @@ sysctl_bufspace(SYSCTL_HANDLER_ARGS)
 }
 #endif
 
-#ifdef DIRECTIO
-extern void ffs_rawread_setup(void);
-#endif /* DIRECTIO */
-
 /*
  * bqlock:
  *
@@ -770,9 +765,6 @@ kern_vfs_bio_buffer_alloc(caddr_t v, lon
if (nswbuf < NSWBUF_MIN)
nswbuf = NSWBUF_MIN;
 #endif
-#ifdef DIRECTIO
-   ffs_rawread_setup();
-#endif
 
/*
 * Reserve space for the buffer cache buffers

Modified: head/sys/modules/ufs/Makefile
==
--- head/sys/modules/ufs/Makefile   Sun Jun  8 10:22:03 2014
(r267225)
+++ head/sys/modules/ufs/Makefile   Sun Jun  8 10:55:06 2014
(r267226)
@@ -6,9 +6,9 @@ KMOD=   ufs
 SRCS=  opt_ddb.h opt_directio.h opt_ffs.h opt_quota.h opt_suiddir.h opt_ufs.h \
vnode_if.h ufs_acl.c ufs_bmap.c ufs_dirhash.c ufs_extattr.c \
ufs_gjournal.c ufs_inode.c ufs_lookup.c ufs_quota.c ufs_vfsops.c \
-   ufs_vnops.c ffs_alloc.c ffs_balloc.c ffs_inode.c ffs_snapshot.c \
-   ffs_softdep.c ffs_subr.c ffs_suspend.c ffs_tables.c ffs_vfsops.c \
-   ffs_vnops.c
+   ufs_vnops.c ffs_alloc.c ffs_balloc.c ffs_inode.c ffs_rawread.c \
+   ffs_snapshot.c ffs_softdep.c ffs_subr.c ffs_suspend.c ffs_tables.c \
+   ffs_vfsops.c ffs_vnops.c
 
 .if !defined(KERNBUILDDIR)
 CFLAGS+= -DSOFTUPDATES -DUFS_DIRHASH

Modified: head/sys/ufs/ffs/ffs_rawread.c
==
--- head/sys/ufs/ffs/ffs_rawread.c  Sun Jun  8 10:22:03 2014
(r267225)
+++ head/sys/ufs/ffs/ffs_rawread.c  Sun Jun  8 10:55:06 2014
(r267226)
@@ -71,8 +71,6 @@ static int ffs_rawread_sync(struct vnode
 
 int ffs_rawread(struct vnode *vp, struct uio *uio, int *workdone);
 
-void ffs_rawread_setup(void);
-
 SYSCTL_DECL(_vfs_ffs);
 
 static int ffsrawbufcnt = 4;
@@ -87,13 +85,13 @@ static int rawreadahead = 1;
 SYSCTL_INT(_vfs_ffs, OID_AUTO, rawreadahead, CTLFLAG_RW, &rawreadahead, 0,
   "Flag to enable readahead for long raw reads");
 
-
-void
-ffs_rawread_setup(void)
+static void
+ffs_rawread_setup(void *arg __unused)
 {
+
ffsrawbufcnt = (nswbuf > 100 ) ? (nswbuf - (nswbuf >> 4)) : nswbuf - 8;
 }
-
+SYSINIT(ffs_raw, SI_SUB_VM_CONF, SI_ORDER_ANY, ffs_rawread_setup, NULL);
 
 static int
 ffs_rawread_sync(struct vnode *vp)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267227 - head/sys/kern

2014-06-08 Thread Konstantin Belousov
Author: kib
Date: Sun Jun  8 10:56:25 2014
New Revision: 267227
URL: http://svnweb.freebsd.org/changeset/base/267227

Log:
  Remove write-only local variable.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Sun Jun  8 10:55:06 2014(r267226)
+++ head/sys/kern/sched_ule.c   Sun Jun  8 10:56:25 2014(r267227)
@@ -2686,7 +2686,6 @@ sched_throw(struct thread *td)
 void
 sched_fork_exit(struct thread *td)
 {
-   struct td_sched *ts;
struct tdq *tdq;
int cpuid;
 
@@ -2696,7 +2695,6 @@ sched_fork_exit(struct thread *td)
 */
cpuid = PCPU_GET(cpuid);
tdq = TDQ_CPU(cpuid);
-   ts = td->td_sched;
if (TD_IS_IDLETHREAD(td))
td->td_lock = TDQ_LOCKPTR(tdq);
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267228 - head/sys/rpc

2014-06-08 Thread Alexander Motin
Author: mav
Date: Sun Jun  8 11:19:32 2014
New Revision: 267228
URL: http://svnweb.freebsd.org/changeset/base/267228

Log:
  Split RPC pool threads into number of smaller semi-isolated groups.
  
  Old design with unified thread pool was good from the point of thread
  utilization.  But single pool-wide mutex became huge congestion point
  for systems with many CPUs.  To reduce the congestion create several
  thread groups within a pool (one group for every 6 CPUs and 12 threads),
  each group with own mutex.  Each connection during its registration is
  assigned to one of the groups in round-robin fashion.  File affinify
  code may still move requests between the groups, but otherwise groups
  are self-contained.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/rpc/svc.c
  head/sys/rpc/svc.h
  head/sys/rpc/svc_generic.c

Modified: head/sys/rpc/svc.c
==
--- head/sys/rpc/svc.c  Sun Jun  8 10:56:25 2014(r267227)
+++ head/sys/rpc/svc.c  Sun Jun  8 11:19:32 2014(r267228)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -70,7 +71,7 @@ __FBSDID("$FreeBSD$");
 
 static struct svc_callout *svc_find(SVCPOOL *pool, rpcprog_t, rpcvers_t,
 char *);
-static void svc_new_thread(SVCPOOL *pool);
+static void svc_new_thread(SVCGROUP *grp);
 static void xprt_unregister_locked(SVCXPRT *xprt);
 static void svc_change_space_used(SVCPOOL *pool, int delta);
 static bool_t svc_request_space_available(SVCPOOL *pool);
@@ -79,11 +80,14 @@ static bool_t svc_request_space_availabl
 
 static int svcpool_minthread_sysctl(SYSCTL_HANDLER_ARGS);
 static int svcpool_maxthread_sysctl(SYSCTL_HANDLER_ARGS);
+static int svcpool_threads_sysctl(SYSCTL_HANDLER_ARGS);
 
 SVCPOOL*
 svcpool_create(const char *name, struct sysctl_oid_list *sysctl_base)
 {
SVCPOOL *pool;
+   SVCGROUP *grp;
+   int g;
 
pool = malloc(sizeof(SVCPOOL), M_RPC, M_WAITOK|M_ZERO);

@@ -91,15 +95,22 @@ svcpool_create(const char *name, struct 
pool->sp_name = name;
pool->sp_state = SVCPOOL_INIT;
pool->sp_proc = NULL;
-   TAILQ_INIT(&pool->sp_xlist);
-   TAILQ_INIT(&pool->sp_active);
TAILQ_INIT(&pool->sp_callouts);
TAILQ_INIT(&pool->sp_lcallouts);
-   LIST_INIT(&pool->sp_threads);
-   LIST_INIT(&pool->sp_idlethreads);
pool->sp_minthreads = 1;
pool->sp_maxthreads = 1;
-   pool->sp_threadcount = 0;
+   pool->sp_groupcount = 1;
+   for (g = 0; g < SVC_MAXGROUPS; g++) {
+   grp = &pool->sp_groups[g];
+   mtx_init(&grp->sg_lock, "sg_lock", NULL, MTX_DEF);
+   grp->sg_pool = pool;
+   grp->sg_state = SVCPOOL_ACTIVE;
+   TAILQ_INIT(&grp->sg_xlist);
+   TAILQ_INIT(&grp->sg_active);
+   LIST_INIT(&grp->sg_idlethreads);
+   grp->sg_minthreads = 1;
+   grp->sg_maxthreads = 1;
+   }
 
/*
 * Don't use more than a quarter of mbuf clusters or more than
@@ -114,12 +125,19 @@ svcpool_create(const char *name, struct 
if (sysctl_base) {
SYSCTL_ADD_PROC(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"minthreads", CTLTYPE_INT | CTLFLAG_RW,
-   pool, 0, svcpool_minthread_sysctl, "I", "");
+   pool, 0, svcpool_minthread_sysctl, "I",
+   "Minimal number of threads");
SYSCTL_ADD_PROC(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"maxthreads", CTLTYPE_INT | CTLFLAG_RW,
-   pool, 0, svcpool_maxthread_sysctl, "I", "");
+   pool, 0, svcpool_maxthread_sysctl, "I",
+   "Maximal number of threads");
+   SYSCTL_ADD_PROC(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+   "threads", CTLTYPE_INT | CTLFLAG_RD,
+   pool, 0, svcpool_threads_sysctl, "I",
+   "Current number of threads");
SYSCTL_ADD_INT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
-   "threads", CTLFLAG_RD, &pool->sp_threadcount, 0, "");
+   "groups", CTLFLAG_RD, &pool->sp_groupcount, 0,
+   "Number of thread groups");
 
SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_used", CTLFLAG_RD,
@@ -158,20 +176,29 @@ svcpool_create(const char *name, struct 
 void
 svcpool_destroy(SVCPOOL *pool)
 {
+   SVCGROUP *grp;
SVCXPRT *xprt, *nxprt;
struct svc_callout *s;
struct svc_loss_callout *sl;
struct svcxprt_list cleanup;
+   int g;
 
TAILQ_INIT(&cleanup);
-   mtx_lock(&pool->sp_lock);
 
-   while (TAILQ_FIRST(&pool->sp_xlist)) {
-   xprt = TAILQ_FIRST(&pool->sp_xlist);
-   xprt_unregister_locked(xprt);
-   TAILQ_IN

svn commit: r267232 - head/sys/kern

2014-06-08 Thread Alexander Motin
Author: mav
Date: Sun Jun  8 15:38:40 2014
New Revision: 267232
URL: http://svnweb.freebsd.org/changeset/base/267232

Log:
  Use atomics to modify numvnodes variable.
  
  This allows to mostly avoid lock usage in getnewvnode_[drop_]reserve(),
  that reduces number of global vnode_free_list_mtx mutex acquisitions
  from 4 to 2 per NFS request on ZFS, improving SMP scalability.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSun Jun  8 14:02:25 2014(r267231)
+++ head/sys/kern/vfs_subr.cSun Jun  8 15:38:40 2014(r267232)
@@ -995,14 +995,25 @@ void
 getnewvnode_reserve(u_int count)
 {
struct thread *td;
+   long num;
 
td = curthread;
+   /* First try to be quick and racy. */
+   if (numvnodes + count <= desiredvnodes) {
+   num = atomic_fetchadd_long(&numvnodes, count);
+   if (num + count <= desiredvnodes) {
+   td->td_vp_reserv += count;
+   return;
+   } else
+   atomic_subtract_long(&numvnodes, count);
+   }
+
mtx_lock(&vnode_free_list_mtx);
while (count > 0) {
if (getnewvnode_wait(0) == 0) {
count--;
td->td_vp_reserv++;
-   numvnodes++;
+   atomic_add_long(&numvnodes, 1);
}
}
mtx_unlock(&vnode_free_list_mtx);
@@ -1014,10 +1025,7 @@ getnewvnode_drop_reserve(void)
struct thread *td;
 
td = curthread;
-   mtx_lock(&vnode_free_list_mtx);
-   KASSERT(numvnodes >= td->td_vp_reserv, ("reserve too large"));
-   numvnodes -= td->td_vp_reserv;
-   mtx_unlock(&vnode_free_list_mtx);
+   atomic_subtract_long(&numvnodes, td->td_vp_reserv);
td->td_vp_reserv = 0;
 }
 
@@ -1054,7 +1062,7 @@ getnewvnode(const char *tag, struct moun
return (error);
}
 #endif
-   numvnodes++;
+   atomic_add_long(&numvnodes, 1);
mtx_unlock(&vnode_free_list_mtx);
 alloc:
vp = (struct vnode *) uma_zalloc(vnode_zone, M_WAITOK|M_ZERO);
@@ -2385,9 +2393,7 @@ vdropl(struct vnode *vp)
 * The vnode has been marked for destruction, so free it.
 */
CTR2(KTR_VFS, "%s: destroying the vnode %p", __func__, vp);
-   mtx_lock(&vnode_free_list_mtx);
-   numvnodes--;
-   mtx_unlock(&vnode_free_list_mtx);
+   atomic_subtract_long(&numvnodes, 1);
bo = &vp->v_bufobj;
VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
("cleaned vnode still on the free list."));
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin/...

2014-06-08 Thread Bryan Drewery
Author: bdrewery
Date: Sun Jun  8 17:29:31 2014
New Revision: 267233
URL: http://svnweb.freebsd.org/changeset/base/267233

Log:
  In preparation for ASLR [1] support add WITH_PIE to support building with 
-fPIE.
  
  This is currently an opt-in build flag. Once ASLR support is ready and stable
  it should changed to opt-out and be enabled by default along with ASLR.
  
  Each application Makefile uses opt-out to ensure that ASLR will be enabled by
  default in new directories when the system is compiled with PIE/ASLR. [2]
  
  Mark known build failures as NO_PIE for now.
  
  The only known runtime failure was rtld.
  
  [1] http://www.bsdcan.org/2014/schedule/events/452.en.html
  Submitted by: Shawn Webb 
  Discussed between:des@ and Shawn Webb [2]

Added:
  head/tools/build/options/WITH_PIE   (contents, props changed)
Modified:
  head/Makefile.inc1
  head/bin/rmail/Makefile
  head/gnu/usr.bin/binutils/addr2line/Makefile
  head/gnu/usr.bin/binutils/nm/Makefile
  head/gnu/usr.bin/binutils/objcopy/Makefile
  head/gnu/usr.bin/binutils/objdump/Makefile
  head/gnu/usr.bin/binutils/readelf/Makefile
  head/gnu/usr.bin/binutils/size/Makefile
  head/gnu/usr.bin/binutils/strings/Makefile
  head/gnu/usr.bin/binutils/strip/Makefile
  head/gnu/usr.bin/gdb/gdb/Makefile
  head/gnu/usr.bin/gdb/gdbtui/Makefile
  head/gnu/usr.bin/gdb/kgdb/Makefile
  head/gnu/usr.bin/groff/src/devices/grodvi/Makefile
  head/gnu/usr.bin/groff/src/devices/grohtml/Makefile
  head/gnu/usr.bin/groff/src/devices/grolbp/Makefile
  head/gnu/usr.bin/groff/src/devices/grolj4/Makefile
  head/gnu/usr.bin/groff/src/devices/grops/Makefile
  head/gnu/usr.bin/groff/src/devices/grotty/Makefile
  head/gnu/usr.bin/groff/src/preproc/eqn/Makefile
  head/gnu/usr.bin/groff/src/preproc/grn/Makefile
  head/gnu/usr.bin/groff/src/preproc/html/Makefile
  head/gnu/usr.bin/groff/src/preproc/pic/Makefile
  head/gnu/usr.bin/groff/src/preproc/refer/Makefile
  head/gnu/usr.bin/groff/src/preproc/soelim/Makefile
  head/gnu/usr.bin/groff/src/preproc/tbl/Makefile
  head/gnu/usr.bin/groff/src/roff/groff/Makefile
  head/gnu/usr.bin/groff/src/roff/troff/Makefile
  head/gnu/usr.bin/groff/src/utils/addftinfo/Makefile
  head/gnu/usr.bin/groff/src/utils/hpftodit/Makefile
  head/gnu/usr.bin/groff/src/utils/indxbib/Makefile
  head/gnu/usr.bin/groff/src/utils/lkbib/Makefile
  head/gnu/usr.bin/groff/src/utils/lookbib/Makefile
  head/gnu/usr.bin/groff/src/utils/tfmtodit/Makefile
  head/gnu/usr.bin/rcs/Makefile.inc
  head/gnu/usr.bin/texinfo/info/Makefile
  head/gnu/usr.bin/texinfo/infokey/Makefile
  head/gnu/usr.bin/texinfo/install-info/Makefile
  head/gnu/usr.bin/texinfo/makeinfo/Makefile
  head/gnu/usr.bin/texinfo/texindex/Makefile
  head/kerberos5/libexec/digest-service/Makefile
  head/kerberos5/libexec/hprop/Makefile
  head/kerberos5/libexec/hpropd/Makefile
  head/kerberos5/libexec/ipropd-master/Makefile
  head/kerberos5/libexec/ipropd-slave/Makefile
  head/kerberos5/libexec/kadmind/Makefile
  head/kerberos5/libexec/kcm/Makefile
  head/kerberos5/libexec/kdc/Makefile
  head/kerberos5/libexec/kdigest/Makefile
  head/kerberos5/libexec/kfd/Makefile
  head/kerberos5/libexec/kimpersonate/Makefile
  head/kerberos5/libexec/kpasswdd/Makefile
  head/kerberos5/tools/asn1_compile/Makefile
  head/kerberos5/tools/slc/Makefile
  head/kerberos5/usr.bin/hxtool/Makefile
  head/kerberos5/usr.bin/kadmin/Makefile
  head/kerberos5/usr.bin/kcc/Makefile
  head/kerberos5/usr.bin/kdestroy/Makefile
  head/kerberos5/usr.bin/kf/Makefile
  head/kerberos5/usr.bin/kgetcred/Makefile
  head/kerberos5/usr.bin/kinit/Makefile
  head/kerberos5/usr.bin/kpasswd/Makefile
  head/kerberos5/usr.bin/ksu/Makefile
  head/kerberos5/usr.bin/string2key/Makefile
  head/kerberos5/usr.bin/verify_krb5_conf/Makefile
  head/kerberos5/usr.sbin/iprop-log/Makefile
  head/kerberos5/usr.sbin/kstash/Makefile
  head/kerberos5/usr.sbin/ktutil/Makefile
  head/lib/csu/amd64/Makefile
  head/lib/csu/i386-elf/Makefile
  head/libexec/mail.local/Makefile
  head/libexec/rtld-elf/Makefile
  head/libexec/smrsh/Makefile
  head/libexec/telnetd/Makefile
  head/sbin/fsck/Makefile
  head/sbin/ipf/ipf/Makefile
  head/sbin/ipf/ipfstat/Makefile
  head/sbin/ipf/ipftest/Makefile
  head/sbin/ipf/ipmon/Makefile
  head/sbin/ipf/ipnat/Makefile
  head/sbin/ipf/ippool/Makefile
  head/sbin/ipf/ipresend/Makefile
  head/sbin/rcorder/Makefile
  head/share/mk/bsd.opts.mk
  head/share/mk/bsd.prog.mk
  head/sys/boot/i386/boot2/Makefile
  head/sys/boot/i386/btx/btx/Makefile
  head/sys/boot/i386/btx/btxldr/Makefile
  head/sys/boot/i386/btx/lib/Makefile
  head/sys/boot/i386/loader/Makefile
  head/sys/boot/mips/beri/boot2/Makefile
  head/sys/boot/mips/beri/loader/Makefile
  head/sys/boot/pc98/boot2/Makefile
  head/sys/boot/pc98/btx/lib/Makefile
  head/sys/boot/pc98/loader/Makefile
  head/sys/boot/sparc64/boot1/Makefile
  head/sys/boot/sparc64/loader/Makefile
  head/usr.bin/clang/clang-tblgen/Makefile
  head/usr.bin/clang/clang.prog.mk
  head/usr.bin/clang/tblgen/Makefile
 

svn commit: r267234 - head/share/man/man5

2014-06-08 Thread Bryan Drewery
Author: bdrewery
Date: Sun Jun  8 17:33:37 2014
New Revision: 267234
URL: http://svnweb.freebsd.org/changeset/base/267234

Log:
  Regen after r267233

Modified:
  head/share/man/man5/src.conf.5

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Sun Jun  8 17:29:31 2014
(r267233)
+++ head/share/man/man5/src.conf.5  Sun Jun  8 17:33:37 2014
(r267234)
@@ -1,7 +1,7 @@
 .\" DO NOT EDIT-- this file is automatically generated.
 .\" from FreeBSD: head/tools/build/options/makeman 255964 2013-10-01 07:22:04Z 
des
 .\" $FreeBSD$
-.Dd June 3, 2014
+.Dd June 8, 2014
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -883,6 +883,9 @@ When set, it also enforces the following
 .It
 .Va WITHOUT_AUTHPF
 .El
+.It Va WITH_PIE
+.\" from FreeBSD: head/tools/build/options/WITH_PIE 267233 2014-06-08 
17:29:31Z bdrewery
+Enable building of Position-Independent Executables (PIEs).
 .It Va WITHOUT_PKGBOOTSTRAP
 .\" from FreeBSD: head/tools/build/options/WITHOUT_PKGBOOTSTRAP 258924 
2013-12-04 15:58:42Z bdrewery
 Set to not build
@@ -1019,7 +1022,7 @@ Set to not build
 .Xr telnet 8
 and related programs.
 .It Va WITH_TESTS
-.\" from FreeBSD: head/tools/build/options/WITH_TESTS 264408 2014-04-13 
11:29:52Z jmmv
+.\" from FreeBSD: head/tools/build/options/WITH_TESTS 267033 2014-06-03 
22:34:27Z jmmv
 Set to install the
 .Fx
 Test Suite in
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Bjoern A. Zeeb

On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:

> Author: bdrewery
> Date: Sun Jun  8 17:29:31 2014
> New Revision: 267233
> URL: http://svnweb.freebsd.org/changeset/base/267233
> 
> Log:
>  In preparation for ASLR [1] support add WITH_PIE to support building with 
> -fPIE.
> 
>  This is currently an opt-in build flag. Once ASLR support is ready and stable
>  it should changed to opt-out and be enabled by default along with ASLR.
> 
>  Each application Makefile uses opt-out to ensure that ASLR will be enabled by
>  default in new directories when the system is compiled with PIE/ASLR. [2]
> 
>  Mark known build failures as NO_PIE for now.

No, no, no, no more NOs!

I’ll leave it to others who understand the current build system in days when 
it’s not broken to fix this entire splattering across all these Makefiles;  we 
really need a better way for this.

— 
Bjoern A. Zeeb "Come on. Learn, goddamn it.", WarGames, 1983

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


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Konstantin Belousov
On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:
> 
> On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:
> 
> > Author: bdrewery
> > Date: Sun Jun  8 17:29:31 2014
> > New Revision: 267233
> > URL: http://svnweb.freebsd.org/changeset/base/267233
> > 
> > Log:
> >  In preparation for ASLR [1] support add WITH_PIE to support building with 
> > -fPIE.
> > 
> >  This is currently an opt-in build flag. Once ASLR support is ready and 
> > stable
> >  it should changed to opt-out and be enabled by default along with ASLR.
> > 
> >  Each application Makefile uses opt-out to ensure that ASLR will be enabled 
> > by
> >  default in new directories when the system is compiled with PIE/ASLR. [2]
> > 
> >  Mark known build failures as NO_PIE for now.
> 
> No, no, no, no more NOs!
> 
> I?ll leave it to others who understand the current build system in days when 
> it?s not broken to fix this entire splattering across all these Makefiles;  
> we really need a better way for this.

I have no words to express my dissatisfaction with this commit.
If change to the build of _some_ usermode binaries require patching
of loader', csu and rtld Makefiles, obviously it is done wrong.

Why almost half of the binaries require opt-out ?  

PLEASE REVERT THIS.


pgpUzSs1tV9SP.pgp
Description: PGP signature


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Alfred Perlstein

On 6/8/14 11:27 AM, Konstantin Belousov wrote:

On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:

On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:


Author: bdrewery
Date: Sun Jun  8 17:29:31 2014
New Revision: 267233
URL: http://svnweb.freebsd.org/changeset/base/267233

Log:
  In preparation for ASLR [1] support add WITH_PIE to support building with 
-fPIE.

  This is currently an opt-in build flag. Once ASLR support is ready and stable
  it should changed to opt-out and be enabled by default along with ASLR.

  Each application Makefile uses opt-out to ensure that ASLR will be enabled by
  default in new directories when the system is compiled with PIE/ASLR. [2]

  Mark known build failures as NO_PIE for now.

No, no, no, no more NOs!

I?ll leave it to others who understand the current build system in days when 
it?s not broken to fix this entire splattering across all these Makefiles;  we 
really need a better way for this.

I have no words to express my dissatisfaction with this commit.
If change to the build of _some_ usermode binaries require patching
of loader', csu and rtld Makefiles, obviously it is done wrong.

Why almost half of the binaries require opt-out ?

PLEASE REVERT THIS.
Wait.  Does this not serve as a useful stake in the ground for people to 
come in and update things?  Instead of asking to back out, shouldn't we 
be doing an announcement "ok folks, it's now time to fix this!" and move 
forward?  Otherwise we may never get any pie.


-Alfred





--
Alfred Perlstein

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


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Konstantin Belousov
On Sun, Jun 08, 2014 at 11:30:42AM -0700, Alfred Perlstein wrote:
> On 6/8/14 11:27 AM, Konstantin Belousov wrote:
> > On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:
> >> On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:
> >>
> >>> Author: bdrewery
> >>> Date: Sun Jun  8 17:29:31 2014
> >>> New Revision: 267233
> >>> URL: http://svnweb.freebsd.org/changeset/base/267233
> >>>
> >>> Log:
> >>>   In preparation for ASLR [1] support add WITH_PIE to support building 
> >>> with -fPIE.
> >>>
> >>>   This is currently an opt-in build flag. Once ASLR support is ready and 
> >>> stable
> >>>   it should changed to opt-out and be enabled by default along with ASLR.
> >>>
> >>>   Each application Makefile uses opt-out to ensure that ASLR will be 
> >>> enabled by
> >>>   default in new directories when the system is compiled with PIE/ASLR. 
> >>> [2]
> >>>
> >>>   Mark known build failures as NO_PIE for now.
> >> No, no, no, no more NOs!
> >>
> >> I?ll leave it to others who understand the current build system in days 
> >> when it?s not broken to fix this entire splattering across all these 
> >> Makefiles;  we really need a better way for this.
> > I have no words to express my dissatisfaction with this commit.
> > If change to the build of _some_ usermode binaries require patching
> > of loader', csu and rtld Makefiles, obviously it is done wrong.
> >
> > Why almost half of the binaries require opt-out ?
> >
> > PLEASE REVERT THIS.
> Wait.  Does this not serve as a useful stake in the ground for people to 
> come in and update things?  Instead of asking to back out, shouldn't we 
> be doing an announcement "ok folks, it's now time to fix this!" and move 
> forward?  Otherwise we may never get any pie.

Let me reformulate.

Somebody commits broken change, despite it was pointed out by many
before the commit. From the changes it is obvious that people which
proposed it do not understand what they hack on. And then, somebody else
must run and 'fix' previously non-broken code.

Sure, you get the pie.


pgpC0hYaQKAjg.pgp
Description: PGP signature


svn commit: r267239 - head/sys/kern

2014-06-08 Thread Alexander Motin
Author: mav
Date: Sun Jun  8 19:01:37 2014
New Revision: 267239
URL: http://svnweb.freebsd.org/changeset/base/267239

Log:
  Remove extra branching from r267232.
  
  MFC after:2 weeks

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSun Jun  8 18:11:53 2014(r267238)
+++ head/sys/kern/vfs_subr.cSun Jun  8 19:01:37 2014(r267239)
@@ -995,18 +995,14 @@ void
 getnewvnode_reserve(u_int count)
 {
struct thread *td;
-   long num;
 
td = curthread;
/* First try to be quick and racy. */
-   if (numvnodes + count <= desiredvnodes) {
-   num = atomic_fetchadd_long(&numvnodes, count);
-   if (num + count <= desiredvnodes) {
-   td->td_vp_reserv += count;
-   return;
-   } else
-   atomic_subtract_long(&numvnodes, count);
-   }
+   if (atomic_fetchadd_long(&numvnodes, count) + count <= desiredvnodes) {
+   td->td_vp_reserv += count;
+   return;
+   } else
+   atomic_subtract_long(&numvnodes, count);
 
mtx_lock(&vnode_free_list_mtx);
while (count > 0) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Alfred Perlstein

On 6/8/14 11:44 AM, Konstantin Belousov wrote:

On Sun, Jun 08, 2014 at 11:30:42AM -0700, Alfred Perlstein wrote:

On 6/8/14 11:27 AM, Konstantin Belousov wrote:

On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:

On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:


Author: bdrewery
Date: Sun Jun  8 17:29:31 2014
New Revision: 267233
URL: http://svnweb.freebsd.org/changeset/base/267233

Log:
   In preparation for ASLR [1] support add WITH_PIE to support building with 
-fPIE.

   This is currently an opt-in build flag. Once ASLR support is ready and stable
   it should changed to opt-out and be enabled by default along with ASLR.

   Each application Makefile uses opt-out to ensure that ASLR will be enabled by
   default in new directories when the system is compiled with PIE/ASLR. [2]

   Mark known build failures as NO_PIE for now.

No, no, no, no more NOs!

I?ll leave it to others who understand the current build system in days when 
it?s not broken to fix this entire splattering across all these Makefiles;  we 
really need a better way for this.

I have no words to express my dissatisfaction with this commit.
If change to the build of _some_ usermode binaries require patching
of loader', csu and rtld Makefiles, obviously it is done wrong.

Why almost half of the binaries require opt-out ?

PLEASE REVERT THIS.

Wait.  Does this not serve as a useful stake in the ground for people to
come in and update things?  Instead of asking to back out, shouldn't we
be doing an announcement "ok folks, it's now time to fix this!" and move
forward?  Otherwise we may never get any pie.

Let me reformulate.

Somebody commits broken change, despite it was pointed out by many
before the commit. From the changes it is obvious that people which
proposed it do not understand what they hack on. And then, somebody else
must run and 'fix' previously non-broken code.

Sure, you get the pie.

Sure, but hasn't the default stayed unchanged?

It seems like you have to enable ASLR first before you see all the 
breakage.  Right now it seems like goal was to document what even 
compiles versus doesn't compile with ASLR.  Afaik there is not setting 
of ASLR on by default.


There has to be a way to call out what works and what doesn't work and 
form a transition from a world with no ASLR to one with some ASLR and 
eventually one with almost entirely ASLR coverage.  I'm not sure it can 
be done in one fell swoop.  Hooks like this in -current allow for this 
to be done as a group effort.


It would be very unlikely that we retain the semantics all the way until 
a -stable release.


-Alfred

--
Alfred Perlstein

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


svn commit: r267240 - in head/sys/dev/usb: . controller

2014-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Jun  8 20:10:29 2014
New Revision: 267240
URL: http://svnweb.freebsd.org/changeset/base/267240

Log:
  Resolve a deadlock setting the USB configuration index from userspace
  on USB HUBs by moving the code into the USB explore threads. The
  deadlock happens because child devices of the USB HUB don't have the
  expected reference count when called from outside the explore
  thread. Only the HUB device itself, which the IOCTL interface locks,
  gets the correct reference count.
  
  MFC after:3 days

Modified:
  head/sys/dev/usb/controller/usb_controller.c
  head/sys/dev/usb/usb_dev.c
  head/sys/dev/usb/usb_device.h
  head/sys/dev/usb/usb_generic.c
  head/sys/dev/usb/usb_hub.c
  head/sys/dev/usb/usb_hub.h
  head/sys/dev/usb/usbdi.h

Modified: head/sys/dev/usb/controller/usb_controller.c
==
--- head/sys/dev/usb/controller/usb_controller.cSun Jun  8 19:01:37 
2014(r267239)
+++ head/sys/dev/usb/controller/usb_controller.cSun Jun  8 20:10:29 
2014(r267240)
@@ -367,7 +367,13 @@ usb_bus_explore(struct usb_proc_msg *pm)
if (bus->no_explore != 0)
return;
 
-   if (udev && udev->hub) {
+   if (udev != NULL) {
+   USB_BUS_UNLOCK(bus);
+   uhub_explore_handle_re_enumerate(udev);
+   USB_BUS_LOCK(bus);
+   }
+
+   if (udev != NULL && udev->hub != NULL) {
 
if (bus->do_probe) {
bus->do_probe = 0;

Modified: head/sys/dev/usb/usb_dev.c
==
--- head/sys/dev/usb/usb_dev.c  Sun Jun  8 19:01:37 2014(r267239)
+++ head/sys/dev/usb/usb_dev.c  Sun Jun  8 20:10:29 2014(r267240)
@@ -1116,9 +1116,14 @@ usb_ioctl(struct cdev *dev, u_long cmd, 
 
usb_pause_mtx(NULL, hz / 128);
 
-   if (usb_ref_device(cpd, &refs, 1 /* need uref */)) {
-   err = ENXIO;
-   goto done;
+   while (usb_ref_device(cpd, &refs, 1 /* need uref */)) {
+   if (usb_ref_device(cpd, &refs, 0)) {
+   /* device no longer exits */
+   err = ENXIO;
+   goto done;
+   }
+   usb_unref_device(cpd, &refs);
+   usb_pause_mtx(NULL, hz / 128);
}
}
 

Modified: head/sys/dev/usb/usb_device.h
==
--- head/sys/dev/usb/usb_device.h   Sun Jun  8 19:01:37 2014
(r267239)
+++ head/sys/dev/usb/usb_device.h   Sun Jun  8 20:10:29 2014
(r267240)
@@ -228,6 +228,7 @@ struct usb_device {
uint8_t address;/* device addess */
uint8_t device_index;   /* device index in "bus->devices" */
uint8_t controller_slot_id; /* controller specific value */
+   uint8_t next_config_index;  /* used by USB_RE_ENUM_SET_CONFIG */
uint8_t curr_config_index;  /* current configuration index */
uint8_t curr_config_no; /* current configuration number */
uint8_t depth;  /* distance from root HUB */
@@ -241,6 +242,7 @@ struct usb_device {
 #defineUSB_RE_ENUM_DONE0
 #defineUSB_RE_ENUM_START   1
 #defineUSB_RE_ENUM_PWR_OFF 2
+#defineUSB_RE_ENUM_SET_CONFIG  3
uint8_t ifaces_max; /* number of interfaces present */
uint8_t endpoints_max;  /* number of endpoints present */
 

Modified: head/sys/dev/usb/usb_generic.c
==
--- head/sys/dev/usb/usb_generic.c  Sun Jun  8 19:01:37 2014
(r267239)
+++ head/sys/dev/usb/usb_generic.c  Sun Jun  8 20:10:29 2014
(r267240)
@@ -616,24 +616,17 @@ ugen_set_config(struct usb_fifo *f, uint
/* not possible in device side mode */
return (ENOTTY);
}
-   if (f->udev->curr_config_index == index) {
-   /* no change needed */
-   return (0);
-   }
+
/* make sure all FIFO's are gone */
/* else there can be a deadlock */
if (ugen_fs_uninit(f)) {
/* ignore any errors */
DPRINTFN(6, "no FIFOs\n");
}
-   /* change setting - will free generic FIFOs, if any */
-   if (usbd_set_config_index(f->udev, index)) {
-   return (EIO);
-   }
-   /* probe and attach */
-   if (usb_probe_and_attach(f->udev, USB_IFACE_INDEX_ANY)) {
+
+   if (usbd_start_set_config(f->udev, index) != 0)
return (EIO);
-   }
+
return (0);
 }
 
@@ -970,11 +963,6 @@ ugen_re_enumerate(struct usb_fifo *f)
DPRINTFN(6, "device mode\n");
 

Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Pedro Giffuni

Hello;

El 6/8/2014 2:14 PM, Alfred Perlstein escribió:

On 6/8/14 11:44 AM, Konstantin Belousov wrote:

On Sun, Jun 08, 2014 at 11:30:42AM -0700, Alfred Perlstein wrote:

On 6/8/14 11:27 AM, Konstantin Belousov wrote:

On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:

On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:


Author: bdrewery
Date: Sun Jun  8 17:29:31 2014
New Revision: 267233
URL: http://svnweb.freebsd.org/changeset/base/267233

Log:
   In preparation for ASLR [1] support add WITH_PIE to support
building with -fPIE.

   This is currently an opt-in build flag. Once ASLR support is
ready and stable
   it should changed to opt-out and be enabled by default along
with ASLR.

   Each application Makefile uses opt-out to ensure that ASLR will
be enabled by
   default in new directories when the system is compiled with
PIE/ASLR. [2]

   Mark known build failures as NO_PIE for now.

No, no, no, no more NOs!

I?ll leave it to others who understand the current build system in
days when it?s not broken to fix this entire splattering across all
these Makefiles;  we really need a better way for this.

I have no words to express my dissatisfaction with this commit.
If change to the build of _some_ usermode binaries require patching
of loader', csu and rtld Makefiles, obviously it is done wrong.

Why almost half of the binaries require opt-out ?

PLEASE REVERT THIS.

Wait.  Does this not serve as a useful stake in the ground for people to
come in and update things?  Instead of asking to back out, shouldn't we
be doing an announcement "ok folks, it's now time to fix this!" and move
forward?  Otherwise we may never get any pie.

Let me reformulate.

Somebody commits broken change, despite it was pointed out by many
before the commit. From the changes it is obvious that people which
proposed it do not understand what they hack on. And then, somebody else
must run and 'fix' previously non-broken code.

Sure, you get the pie.

Sure, but hasn't the default stayed unchanged?

It seems like you have to enable ASLR first before you see all the
breakage.  Right now it seems like goal was to document what even
compiles versus doesn't compile with ASLR.  Afaik there is not setting
of ASLR on by default.



FWIW, and with huge respect to the people working on it, I have come to 
the conclusion that ASLR is useless. The fact that MS and Apple enable 
it now by default is not really a point in favor of the technology as 
the workarounds became popular and finer randomization won't help[1].


I am also worried about the performance: Redhat created PIE but 
backpedaled when they noticed the performance impact and AFAICT only use 
PIE in a restricted set of binaries.


I would like to see these as an option but I don't think it should ever 
be made the default. Yes, I am aware these patches don't turn anything 
by default but I (and probably others) am suspecting such a switch may 
be thrown upon us without much discussion.




There has to be a way to call out what works and what doesn't work and
form a transition from a world with no ASLR to one with some ASLR and
eventually one with almost entirely ASLR coverage.  I'm not sure it can
be done in one fell swoop.  Hooks like this in -current allow for this
to be done as a group effort.

It would be very unlikely that we retain the semantics all the way until
a -stable release.



I am not (yet) criticizing the patches to the build system as I want to 
preserve my innocence ;) ... but perhaps if the semantics are not 
finalized this should be done in a branch. It is my opinion that in 
general we are not using SVN branches as much as we should.


Pedro.

For reference:

[1] http://youtu.be/dkZ9zdSRQYM
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Alfred Perlstein

On 6/8/14 1:13 PM, Pedro Giffuni wrote:

Hello;

El 6/8/2014 2:14 PM, Alfred Perlstein escribió:


There has to be a way to call out what works and what doesn't work and
form a transition from a world with no ASLR to one with some ASLR and
eventually one with almost entirely ASLR coverage.  I'm not sure it can
be done in one fell swoop.  Hooks like this in -current allow for this
to be done as a group effort.

It would be very unlikely that we retain the semantics all the way until
a -stable release.



I am not (yet) criticizing the patches to the build system as I want 
to preserve my innocence ;) ... but perhaps if the semantics are not 
finalized this should be done in a branch. It is my opinion that in 
general we are not using SVN branches as much as we should.


IMO branching is great for something that causes instability, known 
performance issues or won't build.  This is not the same as "changes 
build system".


Putting things like this on branches is likely a good way to imo kill 
discussion.


Right now we have discussion, it's rather healthy.  Let's take a while 
to think about this before saying this all should be done in a branch.


-Alfred

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


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Konstantin Belousov
On Sun, Jun 08, 2014 at 12:14:15PM -0700, Alfred Perlstein wrote:
> On 6/8/14 11:44 AM, Konstantin Belousov wrote:
> > On Sun, Jun 08, 2014 at 11:30:42AM -0700, Alfred Perlstein wrote:
> >> On 6/8/14 11:27 AM, Konstantin Belousov wrote:
> >>> On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:
>  On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:
> 
> > Author: bdrewery
> > Date: Sun Jun  8 17:29:31 2014
> > New Revision: 267233
> > URL: http://svnweb.freebsd.org/changeset/base/267233
> >
> > Log:
> >In preparation for ASLR [1] support add WITH_PIE to support building 
> > with -fPIE.
> >
> >This is currently an opt-in build flag. Once ASLR support is ready 
> > and stable
> >it should changed to opt-out and be enabled by default along with 
> > ASLR.
> >
> >Each application Makefile uses opt-out to ensure that ASLR will be 
> > enabled by
> >default in new directories when the system is compiled with 
> > PIE/ASLR. [2]
> >
> >Mark known build failures as NO_PIE for now.
>  No, no, no, no more NOs!
> 
>  I?ll leave it to others who understand the current build system in days 
>  when it?s not broken to fix this entire splattering across all these 
>  Makefiles;  we really need a better way for this.
> >>> I have no words to express my dissatisfaction with this commit.
> >>> If change to the build of _some_ usermode binaries require patching
> >>> of loader', csu and rtld Makefiles, obviously it is done wrong.
> >>>
> >>> Why almost half of the binaries require opt-out ?
> >>>
> >>> PLEASE REVERT THIS.
> >> Wait.  Does this not serve as a useful stake in the ground for people to
> >> come in and update things?  Instead of asking to back out, shouldn't we
> >> be doing an announcement "ok folks, it's now time to fix this!" and move
> >> forward?  Otherwise we may never get any pie.
> > Let me reformulate.
> >
> > Somebody commits broken change, despite it was pointed out by many
> > before the commit. From the changes it is obvious that people which
> > proposed it do not understand what they hack on. And then, somebody else
> > must run and 'fix' previously non-broken code.
> >
> > Sure, you get the pie.
> Sure, but hasn't the default stayed unchanged?
No, they were changed, in very buggy and unuseful way, which is indicated
by the need to modify the Makefiles for the completely unrelated things
which I listed before.

The change modified the VA layout of all affected binaries, and also
added overhead of relocation to the previously fixed-mapped binaries.
> 
> It seems like you have to enable ASLR first before you see all the 
> breakage.  Right now it seems like goal was to document what even 
> compiles versus doesn't compile with ASLR.  Afaik there is not setting 
> of ASLR on by default.
The change of binaries to the shared objects, which was done by the
discussing commit, is not about ASLR.  It is required to get that
snake oil to function, but by itself it is not ASLR.

And no, it is not about what works/does not work with ASLR. Seemingly,
it is about what the authors were able to mangle, or not able. E.g.,
FreeBSD cannot execute static 'binaries' compiled with PIE, since our
csu does not perform relocations. So whatever is changed by a knob to
become static (WITHOUT_SHARED_ROOT or how is it called now) is plain
broken after the commit, if the knob is tweaked. Similarly, if something
becomes shared-linked by knob (WITHOUT_STATIC_TOOLCHAIN ?) the NO_PIE is
not needed.

That said, the change is wrong on its principle.

> 
> There has to be a way to call out what works and what doesn't work and 
> form a transition from a world with no ASLR to one with some ASLR and 
> eventually one with almost entirely ASLR coverage.  I'm not sure it can 
> be done in one fell swoop.  Hooks like this in -current allow for this 
> to be done as a group effort.
> 
> It would be very unlikely that we retain the semantics all the way until 
> a -stable release.

I do not understand this two paragraphs at all.



pgpglYQs9wfJw.pgp
Description: PGP signature


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Bryan Drewery
On 6/8/2014 1:44 PM, Konstantin Belousov wrote:
> On Sun, Jun 08, 2014 at 11:30:42AM -0700, Alfred Perlstein wrote:
>> On 6/8/14 11:27 AM, Konstantin Belousov wrote:
>>> On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:
 On 08 Jun 2014, at 17:29 , Bryan Drewery  wrote:

> Author: bdrewery
> Date: Sun Jun  8 17:29:31 2014
> New Revision: 267233
> URL: http://svnweb.freebsd.org/changeset/base/267233
>
> Log:
>   In preparation for ASLR [1] support add WITH_PIE to support building 
> with -fPIE.
>
>   This is currently an opt-in build flag. Once ASLR support is ready and 
> stable
>   it should changed to opt-out and be enabled by default along with ASLR.
>
>   Each application Makefile uses opt-out to ensure that ASLR will be 
> enabled by
>   default in new directories when the system is compiled with PIE/ASLR. 
> [2]
>
>   Mark known build failures as NO_PIE for now.
 No, no, no, no more NOs!

 I?ll leave it to others who understand the current build system in days 
 when it?s not broken to fix this entire splattering across all these 
 Makefiles;  we really need a better way for this.
>>> I have no words to express my dissatisfaction with this commit.
>>> If change to the build of _some_ usermode binaries require patching
>>> of loader', csu and rtld Makefiles, obviously it is done wrong.
>>>
>>> Why almost half of the binaries require opt-out ?
>>>
>>> PLEASE REVERT THIS.
>> Wait.  Does this not serve as a useful stake in the ground for people to 
>> come in and update things?  Instead of asking to back out, shouldn't we 
>> be doing an announcement "ok folks, it's now time to fix this!" and move 
>> forward?  Otherwise we may never get any pie.
> 
> Let me reformulate.
> 
> Somebody commits broken change, despite it was pointed out by many
> before the commit. From the changes it is obvious that people which
> proposed it do not understand what they hack on. And then, somebody else
> must run and 'fix' previously non-broken code.
> 
> Sure, you get the pie.
> 

Nothing here is broken by default. Nothing is broken with WITH_PIE
enabled either.

I will not revert this. It lays groundwork for ASLR support. No one has
identified anything actually wrong with this commit.

so@ made the call on making this OPT-OUT per Makefile. Not me or Shawn.

The ASLR patches have been in public for review for 6 months or more
now. You've all had opportunities to weigh in on them. I encourage more
review on the ASLR patches themselves as well.

The presentation at BSDCan was 100% positive by my account. Whether you
think ASLR, or the implementation, is good or not doesn't matter much if
you don't participate. We are the last OS to not have it and it does
have benefits.


-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Bryan Drewery
On 6/8/2014 12:29 PM, Bryan Drewery wrote:
> Author: bdrewery
> Date: Sun Jun  8 17:29:31 2014
> New Revision: 267233
> URL: http://svnweb.freebsd.org/changeset/base/267233
> 
> Log:
>   In preparation for ASLR [1] support add WITH_PIE to support building with 
> -fPIE.
>   
>   This is currently an opt-in build flag. Once ASLR support is ready and 
> stable
>   it should changed to opt-out and be enabled by default along with ASLR.
>   
>   Each application Makefile uses opt-out to ensure that ASLR will be enabled 
> by
>   default in new directories when the system is compiled with PIE/ASLR. [2]
>   
>   Mark known build failures as NO_PIE for now.
>   
>   The only known runtime failure was rtld.
>   
>   [1] http://www.bsdcan.org/2014/schedule/events/452.en.html
>   Submitted by:   Shawn Webb 
>   Discussed between:  des@ and Shawn Webb [2]
> 
...
> 
> Modified: head/share/mk/bsd.opts.mk
> ==
> --- head/share/mk/bsd.opts.mk Sun Jun  8 15:38:40 2014(r267232)
> +++ head/share/mk/bsd.opts.mk Sun Jun  8 17:29:31 2014(r267233)
> @@ -68,7 +68,8 @@ __DEFAULT_YES_OPTIONS = \
>  __DEFAULT_NO_OPTIONS = \
>  CTF \
>  DEBUG_FILES \
> -INSTALL_AS_USER
> +INSTALL_AS_USER \
> +PIE
>  
>  .include 
>  

In case you missed it. This commit is a NOP. By default PIE is not used.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Bryan Drewery
On 6/8/2014 3:34 PM, Alfred Perlstein wrote:
> On 6/8/14 1:13 PM, Pedro Giffuni wrote:
>> Hello;
>>
>> El 6/8/2014 2:14 PM, Alfred Perlstein escribió:
>>>
>>> There has to be a way to call out what works and what doesn't work and
>>> form a transition from a world with no ASLR to one with some ASLR and
>>> eventually one with almost entirely ASLR coverage.  I'm not sure it can
>>> be done in one fell swoop.  Hooks like this in -current allow for this
>>> to be done as a group effort.
>>>
>>> It would be very unlikely that we retain the semantics all the way until
>>> a -stable release.
>>>
>>
>> I am not (yet) criticizing the patches to the build system as I want
>> to preserve my innocence ;) ... but perhaps if the semantics are not
>> finalized this should be done in a branch. It is my opinion that in
>> general we are not using SVN branches as much as we should.
>>
> IMO branching is great for something that causes instability, known
> performance issues or won't build.  This is not the same as "changes
> build system".
> 
> Putting things like this on branches is likely a good way to imo kill
> discussion.
> 
> Right now we have discussion, it's rather healthy.  Let's take a while
> to think about this before saying this all should be done in a branch.
> 
> -Alfred

Yes doing this in a branch would be great if the 2 contributors doing
all the work had bits, and if other people critical of their work would
be willing to help as well. Alas we don't give bits in these cases so
we're stuck with me proxying and them getting little feedback except the
big demotivating message from this commit.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Bryan Drewery
On 6/8/2014 3:13 PM, Pedro Giffuni wrote:
> Hello;
> 
> El 6/8/2014 2:14 PM, Alfred Perlstein escribió:
>> On 6/8/14 11:44 AM, Konstantin Belousov wrote:
>>> On Sun, Jun 08, 2014 at 11:30:42AM -0700, Alfred Perlstein wrote:
 On 6/8/14 11:27 AM, Konstantin Belousov wrote:
> On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:
>> On 08 Jun 2014, at 17:29 , Bryan Drewery 
>> wrote:
>>
>>> Author: bdrewery
>>> Date: Sun Jun  8 17:29:31 2014
>>> New Revision: 267233
>>> URL: http://svnweb.freebsd.org/changeset/base/267233
>>>
>>> Log:
>>>In preparation for ASLR [1] support add WITH_PIE to support
>>> building with -fPIE.
>>>
>>>This is currently an opt-in build flag. Once ASLR support is
>>> ready and stable
>>>it should changed to opt-out and be enabled by default along
>>> with ASLR.
>>>
>>>Each application Makefile uses opt-out to ensure that ASLR will
>>> be enabled by
>>>default in new directories when the system is compiled with
>>> PIE/ASLR. [2]
>>>
>>>Mark known build failures as NO_PIE for now.
>> No, no, no, no more NOs!
>>
>> I?ll leave it to others who understand the current build system in
>> days when it?s not broken to fix this entire splattering across all
>> these Makefiles;  we really need a better way for this.
> I have no words to express my dissatisfaction with this commit.
> If change to the build of _some_ usermode binaries require patching
> of loader', csu and rtld Makefiles, obviously it is done wrong.
>
> Why almost half of the binaries require opt-out ?
>
> PLEASE REVERT THIS.
 Wait.  Does this not serve as a useful stake in the ground for
 people to
 come in and update things?  Instead of asking to back out, shouldn't we
 be doing an announcement "ok folks, it's now time to fix this!" and
 move
 forward?  Otherwise we may never get any pie.
>>> Let me reformulate.
>>>
>>> Somebody commits broken change, despite it was pointed out by many
>>> before the commit. From the changes it is obvious that people which
>>> proposed it do not understand what they hack on. And then, somebody else
>>> must run and 'fix' previously non-broken code.
>>>
>>> Sure, you get the pie.
>> Sure, but hasn't the default stayed unchanged?
>>
>> It seems like you have to enable ASLR first before you see all the
>> breakage.  Right now it seems like goal was to document what even
>> compiles versus doesn't compile with ASLR.  Afaik there is not setting
>> of ASLR on by default.
>>
> 
> FWIW, and with huge respect to the people working on it, I have come to
> the conclusion that ASLR is useless. The fact that MS and Apple enable
> it now by default is not really a point in favor of the technology as
> the workarounds became popular and finer randomization won't help[1].
> 
> I am also worried about the performance: Redhat created PIE but
> backpedaled when they noticed the performance impact and AFAICT only use
> PIE in a restricted set of binaries.
> 
> I would like to see these as an option but I don't think it should ever
> be made the default. Yes, I am aware these patches don't turn anything
> by default but I (and probably others) am suspecting such a switch may
> be thrown upon us without much discussion.
> 
> 
>> There has to be a way to call out what works and what doesn't work and
>> form a transition from a world with no ASLR to one with some ASLR and
>> eventually one with almost entirely ASLR coverage.  I'm not sure it can
>> be done in one fell swoop.  Hooks like this in -current allow for this
>> to be done as a group effort.
>>
>> It would be very unlikely that we retain the semantics all the way until
>> a -stable release.
>>
> 
> I am not (yet) criticizing the patches to the build system as I want to
> preserve my innocence ;) ... but perhaps if the semantics are not
> finalized this should be done in a branch. It is my opinion that in
> general we are not using SVN branches as much as we should.
> 
> Pedro.
> 
> For reference:
> 
> [1] http://youtu.be/dkZ9zdSRQYM

Yes there are performance implications. No, the default of PIE and ASLR
won't be done without discussion.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r267245 - head/sys/kern

2014-06-08 Thread Alan Cox
Author: alc
Date: Mon Jun  9 00:15:16 2014
New Revision: 267245
URL: http://svnweb.freebsd.org/changeset/base/267245

Log:
  Refresh a comment.  The VM_STACK option was eliminated in r43209.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/kern/kern_exec.c

Modified: head/sys/kern/kern_exec.c
==
--- head/sys/kern/kern_exec.c   Sun Jun  8 23:22:25 2014(r267244)
+++ head/sys/kern/kern_exec.c   Mon Jun  9 00:15:16 2014(r267245)
@@ -1101,9 +1101,9 @@ exec_new_vmspace(imgp, sv)
return (error);
 #endif
 
-   /* vm_ssize and vm_maxsaddr are somewhat antiquated concepts in the
-* VM_STACK case, but they are still used to monitor the size of the
-* process stack so we can check the stack rlimit.
+   /*
+* vm_ssize and vm_maxsaddr are somewhat antiquated concepts, but they
+* are still used to enforce the stack rlimit on the process stack.
 */
vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT;
vmspace->vm_maxsaddr = (char *)sv->sv_usrstack - ssiz;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267248 - head/usr.sbin/acpi/acpiconf

2014-06-08 Thread Eitan Adler
Author: eadler
Date: Mon Jun  9 01:54:00 2014
New Revision: 267248
URL: http://svnweb.freebsd.org/changeset/base/267248

Log:
  acpiconf(8): document 'k' option
  
Add missing documentation for the 'k' option based on reading the source
code.

Modified:
  head/usr.sbin/acpi/acpiconf/acpiconf.8

Modified: head/usr.sbin/acpi/acpiconf/acpiconf.8
==
--- head/usr.sbin/acpi/acpiconf/acpiconf.8  Mon Jun  9 01:39:47 2014
(r267247)
+++ head/usr.sbin/acpi/acpiconf/acpiconf.8  Mon Jun  9 01:54:00 2014
(r267248)
@@ -37,6 +37,7 @@
 .Nm
 .Op Fl h
 .Op Fl i Ar batt
+.Op Fl k Ar ack
 .Op Fl s Ar type
 .Sh DESCRIPTION
 The
@@ -49,6 +50,8 @@ The following command-line options are r
 Displays a summary of available options.
 .It Fl i Ar batt
 Get design information about the specified battery.
+.It Fl k Ar ack
+Ack or abort a pending suspend request using the argument provided.
 .It Fl s Ar type
 Enters the specified sleep mode.
 Recognized types are
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r267248 - head/usr.sbin/acpi/acpiconf

2014-06-08 Thread Glen Barber
On Mon, Jun 09, 2014 at 01:54:01AM +, Eitan Adler wrote:
> Author: eadler
> Date: Mon Jun  9 01:54:00 2014
> New Revision: 267248
> URL: http://svnweb.freebsd.org/changeset/base/267248
> 
> Log:
>   acpiconf(8): document 'k' option
>   
>   Add missing documentation for the 'k' option based on reading the source
>   code.
> 
> Modified:
>   head/usr.sbin/acpi/acpiconf/acpiconf.8
> 
> Modified: head/usr.sbin/acpi/acpiconf/acpiconf.8
> ==
> --- head/usr.sbin/acpi/acpiconf/acpiconf.8Mon Jun  9 01:39:47 2014
> (r267247)
> +++ head/usr.sbin/acpi/acpiconf/acpiconf.8Mon Jun  9 01:54:00 2014
> (r267248)
> @@ -37,6 +37,7 @@
>  .Nm
>  .Op Fl h
>  .Op Fl i Ar batt
> +.Op Fl k Ar ack
>  .Op Fl s Ar type
>  .Sh DESCRIPTION
>  The
> @@ -49,6 +50,8 @@ The following command-line options are r
>  Displays a summary of available options.
>  .It Fl i Ar batt
>  Get design information about the specified battery.
> +.It Fl k Ar ack
> +Ack or abort a pending suspend request using the argument provided.
>  .It Fl s Ar type
>  Enters the specified sleep mode.
>  Recognized types are

.Dd missed.

Glen



pgpWOtg3ZX0iM.pgp
Description: PGP signature


Re: svn commit: r267233 - in head: . bin/rmail gnu/usr.bin/binutils/addr2line gnu/usr.bin/binutils/nm gnu/usr.bin/binutils/objcopy gnu/usr.bin/binutils/objdump gnu/usr.bin/binutils/readelf gnu/usr.bin

2014-06-08 Thread Pedro Giffuni

El 6/8/2014 4:39 PM, Bryan Drewery escribió:

On 6/8/2014 3:13 PM, Pedro Giffuni wrote:

Hello;

El 6/8/2014 2:14 PM, Alfred Perlstein escribió:

On 6/8/14 11:44 AM, Konstantin Belousov wrote:

On Sun, Jun 08, 2014 at 11:30:42AM -0700, Alfred Perlstein wrote:

On 6/8/14 11:27 AM, Konstantin Belousov wrote:

On Sun, Jun 08, 2014 at 05:38:49PM +, Bjoern A. Zeeb wrote:

On 08 Jun 2014, at 17:29 , Bryan Drewery 
wrote:


Author: bdrewery
Date: Sun Jun  8 17:29:31 2014
New Revision: 267233
URL: http://svnweb.freebsd.org/changeset/base/267233

Log:
In preparation for ASLR [1] support add WITH_PIE to support
building with -fPIE.

This is currently an opt-in build flag. Once ASLR support is
ready and stable
it should changed to opt-out and be enabled by default along
with ASLR.

Each application Makefile uses opt-out to ensure that ASLR will
be enabled by
default in new directories when the system is compiled with
PIE/ASLR. [2]

Mark known build failures as NO_PIE for now.

No, no, no, no more NOs!

I?ll leave it to others who understand the current build system in
days when it?s not broken to fix this entire splattering across all
these Makefiles;  we really need a better way for this.

I have no words to express my dissatisfaction with this commit.
If change to the build of _some_ usermode binaries require patching
of loader', csu and rtld Makefiles, obviously it is done wrong.

Why almost half of the binaries require opt-out ?

PLEASE REVERT THIS.

Wait.  Does this not serve as a useful stake in the ground for
people to
come in and update things?  Instead of asking to back out, shouldn't we
be doing an announcement "ok folks, it's now time to fix this!" and
move
forward?  Otherwise we may never get any pie.

Let me reformulate.

Somebody commits broken change, despite it was pointed out by many
before the commit. From the changes it is obvious that people which
proposed it do not understand what they hack on. And then, somebody else
must run and 'fix' previously non-broken code.

Sure, you get the pie.

Sure, but hasn't the default stayed unchanged?

It seems like you have to enable ASLR first before you see all the
breakage.  Right now it seems like goal was to document what even
compiles versus doesn't compile with ASLR.  Afaik there is not setting
of ASLR on by default.



FWIW, and with huge respect to the people working on it, I have come to
the conclusion that ASLR is useless. The fact that MS and Apple enable
it now by default is not really a point in favor of the technology as
the workarounds became popular and finer randomization won't help[1].

I am also worried about the performance: Redhat created PIE but
backpedaled when they noticed the performance impact and AFAICT only use
PIE in a restricted set of binaries.

I would like to see these as an option but I don't think it should ever
be made the default. Yes, I am aware these patches don't turn anything
by default but I (and probably others) am suspecting such a switch may
be thrown upon us without much discussion.



There has to be a way to call out what works and what doesn't work and
form a transition from a world with no ASLR to one with some ASLR and
eventually one with almost entirely ASLR coverage.  I'm not sure it can
be done in one fell swoop.  Hooks like this in -current allow for this
to be done as a group effort.

It would be very unlikely that we retain the semantics all the way until
a -stable release.



I am not (yet) criticizing the patches to the build system as I want to
preserve my innocence ;) ... but perhaps if the semantics are not
finalized this should be done in a branch. It is my opinion that in
general we are not using SVN branches as much as we should.

Pedro.

For reference:

[1] http://youtu.be/dkZ9zdSRQYM


Yes there are performance implications. No, the default of PIE and ASLR
won't be done without discussion.



Sounds fair enough for me, thanks!

For the record, despite my general disagreement around making it 
default, I do appreciate the enthusiasm with which Shawn and Oliver are 
taking these security enhancement projects and Bryan's willingness to 
wear the asbestos pants here.


Pedro.

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


svn commit: r267252 - head/sys/dev/vmware/vmxnet3

2014-06-08 Thread Bryan Venteicher
Author: bryanv
Date: Mon Jun  9 02:39:05 2014
New Revision: 267252
URL: http://svnweb.freebsd.org/changeset/base/267252

Log:
  Remove an unnecessary variable reassignment
  
  And it would be bad if 'm' was different from '*m0' at this
  point, since we've already populated the SG list.
  
  MFC after:3 days

Modified:
  head/sys/dev/vmware/vmxnet3/if_vmx.c

Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c
==
--- head/sys/dev/vmware/vmxnet3/if_vmx.cMon Jun  9 02:33:39 2014
(r267251)
+++ head/sys/dev/vmware/vmxnet3/if_vmx.cMon Jun  9 02:39:05 2014
(r267252)
@@ -2757,7 +2757,7 @@ vmxnet3_txq_encap(struct vmxnet3_txqueue
}
}
 
-   txr->vxtxr_txbuf[txr->vxtxr_head].vtxb_m = m = *m0;
+   txr->vxtxr_txbuf[txr->vxtxr_head].vtxb_m = m;
sop = &txr->vxtxr_txd[txr->vxtxr_head];
gen = txr->vxtxr_gen ^ 1;   /* Owned by cpu (yet) */
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267253 - head/sys/dev/vmware/vmxnet3

2014-06-08 Thread Bryan Venteicher
Author: bryanv
Date: Mon Jun  9 02:45:53 2014
New Revision: 267253
URL: http://svnweb.freebsd.org/changeset/base/267253

Log:
  Fix TSO support on VMware Fusion
  
  Apparently for VMware Fusion (and presumably VMware Workstation/Player
  since the PR states TSO is broken there too, but I cannot test), the
  TCP header pseudo checksum calculated should only include the protocol
  (IPPROTO_TCP) value, not also the lengths as the stack does instead.
  
  VMware ESXi seems to ignore whatever value is in the TCP header checksum,
  and it is a bit surprising there is a different behavior between the
  VMware products. And it is unfortunate that on ESXi we are forced to do
  this extra bit of work.
  
  PR:   kern/185849
  MFC after:3 days

Modified:
  head/sys/dev/vmware/vmxnet3/if_vmx.c

Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c
==
--- head/sys/dev/vmware/vmxnet3/if_vmx.cMon Jun  9 02:39:05 2014
(r267252)
+++ head/sys/dev/vmware/vmxnet3/if_vmx.cMon Jun  9 02:45:53 2014
(r267253)
@@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -2604,6 +2606,12 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 {
struct ether_vlan_header *evh;
int offset;
+#if defined(INET)
+   struct ip *ip, iphdr;
+#endif
+#if defined(INET6)
+   struct ip6_hdr *ip6, ip6hdr;
+#endif
 
evh = mtod(m, struct ether_vlan_header *);
if (evh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
@@ -2617,8 +2625,7 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 
switch (*etype) {
 #if defined(INET)
-   case ETHERTYPE_IP: {
-   struct ip *ip, iphdr;
+   case ETHERTYPE_IP:
if (__predict_false(m->m_len < offset + sizeof(struct ip))) {
m_copydata(m, offset, sizeof(struct ip),
(caddr_t) &iphdr);
@@ -2628,10 +2635,16 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
*proto = ip->ip_p;
*start = offset + (ip->ip_hl << 2);
break;
-   }
 #endif
 #if defined(INET6)
case ETHERTYPE_IPV6:
+   if (__predict_false(m->m_len <
+   offset + sizeof(struct ip6_hdr))) {
+   m_copydata(m, offset, sizeof(struct ip6_hdr),
+   (caddr_t) &ip6hdr);
+   ip6 = &ip6hdr;
+   } else
+   ip6 = mtodo(m, offset);
*proto = -1;
*start = ip6_lasthdr(m, offset, IPPROTO_IPV6, proto);
/* Assert the network stack sent us a valid packet. */
@@ -2646,6 +2659,7 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 
if (m->m_pkthdr.csum_flags & CSUM_TSO) {
struct tcphdr *tcp, tcphdr;
+   uint16_t sum;
 
if (__predict_false(*proto != IPPROTO_TCP)) {
/* Likely failed to correctly parse the mbuf. */
@@ -2654,16 +2668,38 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 
txq->vxtxq_stats.vmtxs_tso++;
 
-   /*
-* For TSO, the size of the protocol header is also
-* included in the descriptor header size.
-*/
+   switch (*etype) {
+#if defined(INET)
+   case ETHERTYPE_IP:
+   sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
+   htons(IPPROTO_TCP));
+   break;
+#endif
+#if defined(INET6)
+   case ETHERTYPE_IPV6:
+   sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0);
+   break;
+#endif
+   default:
+   sum = 0;
+   break;
+   }
+
if (m->m_len < *start + sizeof(struct tcphdr)) {
-   m_copydata(m, offset, sizeof(struct tcphdr),
+   m_copyback(m, *start + offsetof(struct tcphdr, th_sum),
+   sizeof(uint16_t), (caddr_t) &sum);
+   m_copydata(m, *start, sizeof(struct tcphdr),
(caddr_t) &tcphdr);
tcp = &tcphdr;
-   } else
+   } else {
tcp = mtodo(m, *start);
+   tcp->th_sum = sum;
+   }
+
+   /*
+* For TSO, the size of the protocol header is also
+* included in the descriptor header size.
+*/
*start += (tcp->th_off << 2);
} else
txq->vxtxq_stats.vmtxs_csum++;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267254 - head/sys/vm

2014-06-08 Thread Konstantin Belousov
Author: kib
Date: Mon Jun  9 03:37:41 2014
New Revision: 267254
URL: http://svnweb.freebsd.org/changeset/base/267254

Log:
  Make mmap(MAP_STACK) search for the available address space, similar
  to !MAP_STACK mapping requests.  For MAP_STACK | MAP_FIXED, clear any
  mappings which could previously exist in the used range.
  
  For this, teach vm_map_find() and vm_map_fixed() to handle
  MAP_STACK_GROWS_DOWN or _UP cow flags, by calling a new
  vm_map_stack_locked() helper, which is factored out from
  vm_map_stack().
  
  The side effect of the change is that MAP_STACK started obeying
  MAP_ALIGNMENT and MAP_32BIT flags.
  
  Reported by:  rwatson
  Reviewed by:  alc
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/vm/vm_map.c
  head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cMon Jun  9 02:45:53 2014(r267253)
+++ head/sys/vm/vm_map.cMon Jun  9 03:37:41 2014(r267254)
@@ -136,6 +136,9 @@ static void vm_map_entry_dispose(vm_map_
 static void vm_map_zdtor(void *mem, int size, void *arg);
 static void vmspace_zdtor(void *mem, int size, void *arg);
 #endif
+static int vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos,
+vm_size_t max_ssize, vm_size_t growsize, vm_prot_t prot, vm_prot_t max,
+int cow);
 
 #defineENTRY_CHARGED(e) ((e)->cred != NULL || \
 ((e)->object.vm_object != NULL && (e)->object.vm_object->cred != NULL && \
@@ -1399,11 +1402,19 @@ vm_map_fixed(vm_map_t map, vm_object_t o
int result;
 
end = start + length;
+   KASSERT((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) == 0 ||
+   object == NULL,
+   ("vm_map_fixed: non-NULL backing object for stack"));
vm_map_lock(map);
VM_MAP_RANGE_CHECK(map, start, end);
(void) vm_map_delete(map, start, end);
-   result = vm_map_insert(map, object, offset, start, end, prot,
-   max, cow);
+   if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) {
+   result = vm_map_stack_locked(map, start, length, sgrowsiz,
+   prot, max, cow);
+   } else {
+   result = vm_map_insert(map, object, offset, start, end,
+   prot, max, cow);
+   }
vm_map_unlock(map);
return (result);
 }
@@ -1426,6 +1437,9 @@ vm_map_find(vm_map_t map, vm_object_t ob
vm_offset_t alignment, initial_addr, start;
int result;
 
+   KASSERT((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) == 0 ||
+   object == NULL,
+   ("vm_map_find: non-NULL backing object for stack"));
if (find_space == VMFS_OPTIMAL_SPACE && (object == NULL ||
(object->flags & OBJ_COLORED) == 0))
find_space = VMFS_ANY_SPACE;
@@ -1467,8 +1481,13 @@ again:
 
start = *addr;
}
-   result = vm_map_insert(map, object, offset, start, start +
-   length, prot, max, cow);
+   if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) {
+   result = vm_map_stack_locked(map, start, length,
+   sgrowsiz, prot, max, cow);
+   } else {
+   result = vm_map_insert(map, object, offset, start,
+   start + length, prot, max, cow);
+   }
} while (result == KERN_NO_SPACE && find_space != VMFS_NO_SPACE &&
find_space != VMFS_ANY_SPACE);
vm_map_unlock(map);
@@ -3347,11 +3366,43 @@ int
 vm_map_stack(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize,
 vm_prot_t prot, vm_prot_t max, int cow)
 {
+   vm_size_t growsize, init_ssize;
+   rlim_t lmemlim, vmemlim;
+   int rv;
+
+   growsize = sgrowsiz;
+   init_ssize = (max_ssize < growsize) ? max_ssize : growsize;
+   vm_map_lock(map);
+   PROC_LOCK(curproc);
+   lmemlim = lim_cur(curproc, RLIMIT_MEMLOCK);
+   vmemlim = lim_cur(curproc, RLIMIT_VMEM);
+   PROC_UNLOCK(curproc);
+   if (!old_mlock && map->flags & MAP_WIREFUTURE) {
+   if (ptoa(pmap_wired_count(map->pmap)) + init_ssize > lmemlim) {
+   rv = KERN_NO_SPACE;
+   goto out;
+   }
+   }
+   /* If we would blow our VMEM resource limit, no go */
+   if (map->size + init_ssize > vmemlim) {
+   rv = KERN_NO_SPACE;
+   goto out;
+   }
+   rv = vm_map_stack_locked(map, addrbos, max_ssize, sgrowsiz, prot,
+   max, cow);
+out:
+   vm_map_unlock(map);
+   return (rv);
+}
+
+static int
+vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize,
+vm_size_t growsize, vm_prot_t prot, vm_prot_t max, int cow)
+{
vm_map_entry_t new_entry, prev_entry;
vm_offset_t bot, top;
-   vm_size_t growsize, init_ssize;

svn commit: r267255 - head/sys/kern

2014-06-08 Thread Konstantin Belousov
Author: kib
Date: Mon Jun  9 03:38:03 2014
New Revision: 267255
URL: http://svnweb.freebsd.org/changeset/base/267255

Log:
  Change the nblock mutex, protecting the needsbuffer buffer deficit
  flags, to rwlock.  Lock it in read mode when used from subroutines
  called from buffer release code paths.
  
  The needsbuffer is now updated using atomics, while read lock of
  nblock prevents loosing the wakeups from bufspacewakeup() and
  bufcountadd() in getnewbuf_bufd_help().
  
  In several interesting loads, needsbuffer flags are never set, while
  buffers are reused quickly.  This causes brelse() and bqrelse() from
  different threads to content on the nblock.  Now they take nblock in
  read mode, together with needsbuffer not needing an update, allowing
  higher parallelism.
  
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Mon Jun  9 03:37:41 2014(r267254)
+++ head/sys/kern/vfs_bio.c Mon Jun  9 03:38:03 2014(r267255)
@@ -254,7 +254,7 @@ static struct mtx_padalign rbreqlock;
 /*
  * Lock that protects needsbuffer and the sleeps/wakeups surrounding it.
  */
-static struct mtx_padalign nblock;
+static struct rwlock_padalign nblock;
 
 /*
  * Lock that protects bdirtywait.
@@ -299,7 +299,7 @@ static int runningbufreq;
  * Used in numdirtywakeup(), bufspacewakeup(), bufcountadd(), bwillwrite(),
  * getnewbuf(), and getblk().
  */
-static int needsbuffer;
+static volatile int needsbuffer;
 
 /*
  * Synchronization for bwillwrite() waiters.
@@ -457,18 +457,27 @@ bdirtyadd(void)
 static __inline void
 bufspacewakeup(void)
 {
+   int need_wakeup, on;
 
/*
 * If someone is waiting for BUF space, wake them up.  Even
 * though we haven't freed the kva space yet, the waiting
 * process will be able to now.
 */
-   mtx_lock(&nblock);
-   if (needsbuffer & VFS_BIO_NEED_BUFSPACE) {
-   needsbuffer &= ~VFS_BIO_NEED_BUFSPACE;
-   wakeup(&needsbuffer);
+   rw_rlock(&nblock);
+   for (;;) {
+   need_wakeup = 0;
+   on = needsbuffer;
+   if ((on & VFS_BIO_NEED_BUFSPACE) == 0)
+   break;
+   need_wakeup = 1;
+   if (atomic_cmpset_rel_int(&needsbuffer, on,
+   on & ~VFS_BIO_NEED_BUFSPACE))
+   break;
}
-   mtx_unlock(&nblock);
+   if (need_wakeup)
+   wakeup((void *)&needsbuffer);
+   rw_runlock(&nblock);
 }
 
 /*
@@ -528,7 +537,7 @@ runningbufwakeup(struct buf *bp)
 static __inline void
 bufcountadd(struct buf *bp)
 {
-   int old;
+   int mask, need_wakeup, old, on;
 
KASSERT((bp->b_flags & B_INFREECNT) == 0,
("buf %p already counted as free", bp));
@@ -536,14 +545,22 @@ bufcountadd(struct buf *bp)
old = atomic_fetchadd_int(&numfreebuffers, 1);
KASSERT(old >= 0 && old < nbuf,
("numfreebuffers climbed to %d", old + 1));
-   mtx_lock(&nblock);
-   if (needsbuffer) {
-   needsbuffer &= ~VFS_BIO_NEED_ANY;
-   if (numfreebuffers >= hifreebuffers)
-   needsbuffer &= ~VFS_BIO_NEED_FREE;
-   wakeup(&needsbuffer);
+   mask = VFS_BIO_NEED_ANY;
+   if (numfreebuffers >= hifreebuffers)
+   mask |= VFS_BIO_NEED_FREE;
+   rw_rlock(&nblock);
+   for (;;) {
+   need_wakeup = 0;
+   on = needsbuffer;
+   if (on == 0)
+   break;
+   need_wakeup = 1;
+   if (atomic_cmpset_rel_int(&needsbuffer, on, on & ~mask))
+   break;
}
-   mtx_unlock(&nblock);
+   if (need_wakeup)
+   wakeup((void *)&needsbuffer);
+   rw_runlock(&nblock);
 }
 
 /*
@@ -787,7 +804,7 @@ bufinit(void)
mtx_init(&bqclean, "bufq clean lock", NULL, MTX_DEF);
mtx_init(&bqdirty, "bufq dirty lock", NULL, MTX_DEF);
mtx_init(&rbreqlock, "runningbufspace lock", NULL, MTX_DEF);
-   mtx_init(&nblock, "needsbuffer lock", NULL, MTX_DEF);
+   rw_init(&nblock, "needsbuffer lock");
mtx_init(&bdlock, "buffer daemon lock", NULL, MTX_DEF);
mtx_init(&bdirtylock, "dirty buf lock", NULL, MTX_DEF);
 
@@ -2085,9 +2102,7 @@ getnewbuf_bufd_help(struct vnode *vp, in
waitmsg = "newbuf";
flags = VFS_BIO_NEED_ANY;
}
-   mtx_lock(&nblock);
-   needsbuffer |= flags;
-   mtx_unlock(&nblock);
+   atomic_set_int(&needsbuffer, flags);
mtx_unlock(&bqclean);
 
bd_speedup();   /* hlp */
@@ -2097,12 +2112,11 @@ getnewbuf_bufd_help(struct vnode *vp, in
td = curthread;
cnt = 0;
wait = MNT_NOWAIT;
-   mtx_lock(&nblock);
-   while (

svn commit: r267260 - head/usr.sbin/acpi/acpiconf

2014-06-08 Thread Eitan Adler
Author: eadler
Date: Mon Jun  9 06:16:12 2014
New Revision: 267260
URL: http://svnweb.freebsd.org/changeset/base/267260

Log:
  acpiconf(8): bump .Dd
  
  Reported by:  gjb

Modified:
  head/usr.sbin/acpi/acpiconf/acpiconf.8

Modified: head/usr.sbin/acpi/acpiconf/acpiconf.8
==
--- head/usr.sbin/acpi/acpiconf/acpiconf.8  Mon Jun  9 06:03:38 2014
(r267259)
+++ head/usr.sbin/acpi/acpiconf/acpiconf.8  Mon Jun  9 06:16:12 2014
(r267260)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 16, 2004
+.Dd June 6, 2014
 .Dt ACPICONF 8
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r267261 - head/usr.sbin/acpi/acpiconf

2014-06-08 Thread Eitan Adler
Author: eadler
Date: Mon Jun  9 06:17:02 2014
New Revision: 267261
URL: http://svnweb.freebsd.org/changeset/base/267261

Log:
  acpiconf(8): check the calendar

Modified:
  head/usr.sbin/acpi/acpiconf/acpiconf.8

Modified: head/usr.sbin/acpi/acpiconf/acpiconf.8
==
--- head/usr.sbin/acpi/acpiconf/acpiconf.8  Mon Jun  9 06:16:12 2014
(r267260)
+++ head/usr.sbin/acpi/acpiconf/acpiconf.8  Mon Jun  9 06:17:02 2014
(r267261)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 6, 2014
+.Dd June 8, 2014
 .Dt ACPICONF 8
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"