svn commit: r275305 - head/sys/boot/i386/boot2

2014-11-30 Thread Roman Divacky
Author: rdivacky
Date: Sun Nov 30 08:43:55 2014
New Revision: 275305
URL: https://svnweb.freebsd.org/changeset/base/275305

Log:
  Unbreak the code for non-digits below '0' by casting the expression
  to unsigned int.
  
  Pointed out by: bde

Modified:
  head/sys/boot/i386/boot2/boot2.c

Modified: head/sys/boot/i386/boot2/boot2.c
==
--- head/sys/boot/i386/boot2/boot2.cSun Nov 30 08:34:46 2014
(r275304)
+++ head/sys/boot/i386/boot2/boot2.cSun Nov 30 08:43:55 2014
(r275305)
@@ -418,7 +418,7 @@ parse()
 #if SERIAL
} else if (c == 'S') {
j = 0;
-   while ((i = *arg++ - '0') <= 9)
+   while ((unsigned int)(i = *arg++ - '0') <= 9)
j = j * 10 + i;
if (j > 0 && i == -'0') {
comspeed = j;
___
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: r275312 - in head/sys: kern sys

2014-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Nov 30 11:02:07 2014
New Revision: 275312
URL: https://svnweb.freebsd.org/changeset/base/275312

Log:
  Make sballoc() and sbfree() functions. Ideally, they could be marked
  as static, but unfortunately Infiniband (ab)uses them.
  
  Sponsored by: Nginx, Inc.

Modified:
  head/sys/kern/uipc_sockbuf.c
  head/sys/sys/sockbuf.h

Modified: head/sys/kern/uipc_sockbuf.c
==
--- head/sys/kern/uipc_sockbuf.cSun Nov 30 10:55:01 2014
(r275311)
+++ head/sys/kern/uipc_sockbuf.cSun Nov 30 11:02:07 2014
(r275312)
@@ -69,6 +69,60 @@ static struct mbuf   *sbcut_internal(struc
 static voidsbflush_internal(struct sockbuf *sb);
 
 /*
+ * Adjust sockbuf state reflecting allocation of m.
+ */
+void
+sballoc(struct sockbuf *sb, struct mbuf *m)
+{
+
+   SOCKBUF_LOCK_ASSERT(sb);
+
+   sb->sb_cc += m->m_len;
+
+   if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA)
+   sb->sb_ctl += m->m_len;
+
+   sb->sb_mbcnt += MSIZE;
+   sb->sb_mcnt += 1;
+
+   if (m->m_flags & M_EXT) {
+   sb->sb_mbcnt += m->m_ext.ext_size;
+   sb->sb_ccnt += 1;
+   }
+}
+
+/*
+ * Adjust sockbuf state reflecting freeing of m.
+ */
+void
+sbfree(struct sockbuf *sb, struct mbuf *m)
+{
+
+#if 0  /* XXX: not yet: soclose() call path comes here w/o lock. */
+   SOCKBUF_LOCK_ASSERT(sb);
+#endif
+
+   sb->sb_cc -= m->m_len;
+
+   if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA)
+   sb->sb_ctl -= m->m_len;
+
+   sb->sb_mbcnt -= MSIZE;
+   sb->sb_mcnt -= 1;
+   if (m->m_flags & M_EXT) {
+   sb->sb_mbcnt -= m->m_ext.ext_size;
+   sb->sb_ccnt -= 1;
+   }
+
+   if (sb->sb_sndptr == m) {
+   sb->sb_sndptr = NULL;
+   sb->sb_sndptroff = 0;
+   }
+   if (sb->sb_sndptroff != 0)
+   sb->sb_sndptroff -= m->m_len;
+}
+
+/*
  * Socantsendmore indicates that no more data will be sent on the socket; it
  * would normally be applied to a socket when the user informs the system
  * that no more data is to be sent, by the protocol code (in case

Modified: head/sys/sys/sockbuf.h
==
--- head/sys/sys/sockbuf.h  Sun Nov 30 10:55:01 2014(r275311)
+++ head/sys/sys/sockbuf.h  Sun Nov 30 11:02:07 2014(r275312)
@@ -164,6 +164,8 @@ voidsbtoxsockbuf(struct sockbuf *sb, st
 intsbwait(struct sockbuf *sb);
 intsblock(struct sockbuf *sb, int flags);
 void   sbunlock(struct sockbuf *sb);
+void   sballoc(struct sockbuf *, struct mbuf *);
+void   sbfree(struct sockbuf *, struct mbuf *);
 
 /*
  * Return how much data is available to be taken out of socket
@@ -213,38 +215,6 @@ sbspace(struct sockbuf *sb)
return((bleft < mleft) ? bleft : mleft);
 }
 
-/* adjust counters in sb reflecting allocation of m */
-#definesballoc(sb, m) { \
-   (sb)->sb_cc += (m)->m_len; \
-   if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
-   (sb)->sb_ctl += (m)->m_len; \
-   (sb)->sb_mbcnt += MSIZE; \
-   (sb)->sb_mcnt += 1; \
-   if ((m)->m_flags & M_EXT) { \
-   (sb)->sb_mbcnt += (m)->m_ext.ext_size; \
-   (sb)->sb_ccnt += 1; \
-   } \
-}
-
-/* adjust counters in sb reflecting freeing of m */
-#definesbfree(sb, m) { \
-   (sb)->sb_cc -= (m)->m_len; \
-   if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
-   (sb)->sb_ctl -= (m)->m_len; \
-   (sb)->sb_mbcnt -= MSIZE; \
-   (sb)->sb_mcnt -= 1; \
-   if ((m)->m_flags & M_EXT) { \
-   (sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
-   (sb)->sb_ccnt -= 1; \
-   } \
-   if ((sb)->sb_sndptr == (m)) { \
-   (sb)->sb_sndptr = NULL; \
-   (sb)->sb_sndptroff = 0; \
-   } \
-   if ((sb)->sb_sndptroff != 0) \
-   (sb)->sb_sndptroff -= (m)->m_len; \
-}
-
 #define SB_EMPTY_FIXUP(sb) do {
\
if ((sb)->sb_mb == NULL) {  \
(sb)->sb_mbtail = NULL; \
___
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: r275315 - in head/sys: kern sys

2014-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Nov 30 11:22:39 2014
New Revision: 275315
URL: https://svnweb.freebsd.org/changeset/base/275315

Log:
  - Move sbcheck() declaration under SOCKBUF_DEBUG.
  - Improve SOCKBUF_DEBUG macros.
  - Improve sbcheck().
  
  Sponsored by: Netflix
  Sponsored by: Nginx, Inc.

Modified:
  head/sys/kern/uipc_sockbuf.c
  head/sys/sys/sockbuf.h

Modified: head/sys/kern/uipc_sockbuf.c
==
--- head/sys/kern/uipc_sockbuf.cSun Nov 30 11:14:49 2014
(r275314)
+++ head/sys/kern/uipc_sockbuf.cSun Nov 30 11:22:39 2014
(r275315)
@@ -607,28 +607,36 @@ sbappendstream(struct sockbuf *sb, struc
 
 #ifdef SOCKBUF_DEBUG
 void
-sbcheck(struct sockbuf *sb)
+sbcheck(struct sockbuf *sb, const char *file, int line)
 {
-   struct mbuf *m;
-   struct mbuf *n = 0;
-   u_long len = 0, mbcnt = 0;
+   struct mbuf *m, *n;
+   u_long cc, mbcnt;
 
SOCKBUF_LOCK_ASSERT(sb);
 
+   cc = mbcnt = 0;
+
for (m = sb->sb_mb; m; m = n) {
n = m->m_nextpkt;
for (; m; m = m->m_next) {
-   len += m->m_len;
+   if (m->m_len == 0) {
+   printf("sb %p empty mbuf %p\n", sb, m);
+   goto fail;
+   }
+   cc += m->m_len;
mbcnt += MSIZE;
if (m->m_flags & M_EXT) /*XXX*/ /* pretty sure this is bogus */
mbcnt += m->m_ext.ext_size;
}
}
-   if (len != sb->sb_cc || mbcnt != sb->sb_mbcnt) {
-   printf("cc %ld != %u || mbcnt %ld != %u\n", len, sb->sb_cc,
+   if (cc != sb->sb_cc || mbcnt != sb->sb_mbcnt) {
+   printf("cc %ld != %u || mbcnt %ld != %u\n", cc, sb->sb_cc,
mbcnt, sb->sb_mbcnt);
-   panic("sbcheck");
+   goto fail;
}
+   return;
+fail:
+   panic("%s from %s:%u", __func__, file, line);
 }
 #endif
 

Modified: head/sys/sys/sockbuf.h
==
--- head/sys/sys/sockbuf.h  Sun Nov 30 11:14:49 2014(r275314)
+++ head/sys/sys/sockbuf.h  Sun Nov 30 11:22:39 2014(r275315)
@@ -136,7 +136,6 @@ int sbappendcontrol_locked(struct sockbu
struct mbuf *control);
 void   sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
 void   sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0);
-void   sbcheck(struct sockbuf *sb);
 void   sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
 struct mbuf *
sbcreatecontrol(caddr_t p, int size, int type, int level);
@@ -224,13 +223,15 @@ sbspace(struct sockbuf *sb)
 
 #ifdef SOCKBUF_DEBUG
 void   sblastrecordchk(struct sockbuf *, const char *, int);
-#defineSBLASTRECORDCHK(sb) sblastrecordchk((sb), __FILE__, 
__LINE__)
-
 void   sblastmbufchk(struct sockbuf *, const char *, int);
+void   sbcheck(struct sockbuf *, const char *, int);
+#defineSBLASTRECORDCHK(sb) sblastrecordchk((sb), __FILE__, 
__LINE__)
 #defineSBLASTMBUFCHK(sb)   sblastmbufchk((sb), __FILE__, __LINE__)
+#defineSBCHECK(sb) sbcheck((sb), __FILE__, __LINE__)
 #else
-#defineSBLASTRECORDCHK(sb)  /* nothing */
-#defineSBLASTMBUFCHK(sb)/* nothing */
+#defineSBLASTRECORDCHK(sb) do {} while (0)
+#defineSBLASTMBUFCHK(sb)   do {} while (0)
+#defineSBCHECK(sb) do {} while (0)
 #endif /* SOCKBUF_DEBUG */
 
 #endif /* _KERNEL */
___
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: r275320 - head/sys/netinet

2014-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Nov 30 12:11:01 2014
New Revision: 275320
URL: https://svnweb.freebsd.org/changeset/base/275320

Log:
  Missed in r274421: use sbavail() instead of bare access to sb_cc.

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==
--- head/sys/netinet/tcp_usrreq.c   Sun Nov 30 11:59:20 2014
(r275319)
+++ head/sys/netinet/tcp_usrreq.c   Sun Nov 30 12:11:01 2014
(r275320)
@@ -925,7 +925,7 @@ tcp_usr_send(struct socket *so, int flag
tp->snd_wnd = TTCP_CLIENT_SND_WND;
tcp_mss(tp, -1);
}
-   tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
+   tp->snd_up = tp->snd_una + sbavail(&so->so_snd);
tp->t_flags |= TF_FORCEDATA;
error = tcp_output(tp);
tp->t_flags &= ~TF_FORCEDATA;
___
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: r275321 - head/sys/arm/arm

2014-11-30 Thread Andrew Turner
Author: andrew
Date: Sun Nov 30 12:20:24 2014
New Revision: 275321
URL: https://svnweb.freebsd.org/changeset/base/275321

Log:
  Remove extra labels, ENTRY_NP already provides them.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm/arm/cpufunc_asm_armv5.S
  head/sys/arm/arm/cpufunc_asm_xscale_c3.S

Modified: head/sys/arm/arm/cpufunc_asm_armv5.S
==
--- head/sys/arm/arm/cpufunc_asm_armv5.SSun Nov 30 12:11:01 2014
(r275320)
+++ head/sys/arm/arm/cpufunc_asm_armv5.SSun Nov 30 12:20:24 2014
(r275321)
@@ -194,7 +194,6 @@ ENTRY(armv5_idcache_wbinv_range)
 END(armv5_idcache_wbinv_range)
 
 ENTRY_NP(armv5_idcache_wbinv_all)
-armv5_idcache_wbinv_all:
 .Larmv5_idcache_wbinv_all:
/*
 * We assume that the code here can never be out of sync with the

Modified: head/sys/arm/arm/cpufunc_asm_xscale_c3.S
==
--- head/sys/arm/arm/cpufunc_asm_xscale_c3.SSun Nov 30 12:11:01 2014
(r275320)
+++ head/sys/arm/arm/cpufunc_asm_xscale_c3.SSun Nov 30 12:20:24 2014
(r275321)
@@ -144,7 +144,6 @@ __FBSDID("$FreeBSD$");
 
 
 ENTRY_NP(xscalec3_cache_syncI)
-xscalec3_cache_purgeID:
 EENTRY_NP(xscalec3_cache_purgeID)
mcr p15, 0, r0, c7, c5, 0   /* flush I cache (D cleaned below) */
 EENTRY_NP(xscalec3_cache_cleanID)
___
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: r275322 - head/sys/arm/arm

2014-11-30 Thread Andrew Turner
Author: andrew
Date: Sun Nov 30 12:25:04 2014
New Revision: 275322
URL: https://svnweb.freebsd.org/changeset/base/275322

Log:
  Correctly a few incorrect uses of ENTRY/EENTRY and END/EEND
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm/arm/fusu.S
  head/sys/arm/arm/support.S

Modified: head/sys/arm/arm/fusu.S
==
--- head/sys/arm/arm/fusu.S Sun Nov 30 12:20:24 2014(r275321)
+++ head/sys/arm/arm/fusu.S Sun Nov 30 12:25:04 2014(r275322)
@@ -129,7 +129,7 @@ EENTRY_NP(fuword32)
str r1, [r2, #PCB_ONFAULT]
mov r0, r3
RET
-END(fuword32)
+EEND(fuword32)
 END(fuword)
 
 /*
@@ -295,7 +295,7 @@ EENTRY_NP(suword32)
mov r0, #0x
str r0, [r2, #PCB_ONFAULT]
RET
-END(suword32)
+EEND(suword32)
 END(suword)
 
 /*

Modified: head/sys/arm/arm/support.S
==
--- head/sys/arm/arm/support.S  Sun Nov 30 12:20:24 2014(r275321)
+++ head/sys/arm/arm/support.S  Sun Nov 30 12:25:04 2014(r275322)
@@ -130,7 +130,7 @@ ENTRY(bzero)
 .Lnormal0:
mov r3, #0x00
b   do_memset
-EEND(bzero)
+END(bzero)
 /* LINTSTUB: Func: void *memset(void *, int, size_t) */
 ENTRY(memset)
and r3, r1, #0xff   /* We deal with bytes */
___
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: r275323 - head

2014-11-30 Thread Garrett Cooper
Author: ngie
Date: Sun Nov 30 12:32:16 2014
New Revision: 275323
URL: https://svnweb.freebsd.org/changeset/base/275323

Log:
  Add mergeinfo for r275302

Modified:
Directory Properties:
  head/   (props changed)
___
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: r275324 - head/etc/rc.d

2014-11-30 Thread Garrett Cooper
Author: ngie
Date: Sun Nov 30 12:34:48 2014
New Revision: 275324
URL: https://svnweb.freebsd.org/changeset/base/275324

Log:
  Remove duplicate FILESYSTEMS REQUIRE from etc/rc.d/ipmon and etc/rc.d/pflog

Modified:
  head/etc/rc.d/ipmon
  head/etc/rc.d/pflog
Directory Properties:
  head/   (props changed)
  head/etc/   (props changed)

Modified: head/etc/rc.d/ipmon
==
--- head/etc/rc.d/ipmon Sun Nov 30 12:32:16 2014(r275323)
+++ head/etc/rc.d/ipmon Sun Nov 30 12:34:48 2014(r275324)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: ipmon
-# REQUIRE: FILESYSTEMS hostname sysctl FILESYSTEMS ipfilter
+# REQUIRE: FILESYSTEMS hostname sysctl ipfilter
 # BEFORE:  SERVERS
 # KEYWORD: nojail
 

Modified: head/etc/rc.d/pflog
==
--- head/etc/rc.d/pflog Sun Nov 30 12:32:16 2014(r275323)
+++ head/etc/rc.d/pflog Sun Nov 30 12:34:48 2014(r275324)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: pflog
-# REQUIRE: FILESYSTEMS netif FILESYSTEMS
+# REQUIRE: FILESYSTEMS netif
 # KEYWORD: nojail
 
 . /etc/rc.subr
___
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: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Nov 30 12:52:33 2014
New Revision: 275326
URL: https://svnweb.freebsd.org/changeset/base/275326

Log:
  Merge from projects/sendfile:
  
  o Introduce a notion of "not ready" mbufs in socket buffers.  These
  mbufs are now being populated by some I/O in background and are
  referenced outside.  This forces following implications:
  - An mbuf which is "not ready" can't be taken out of the buffer.
  - An mbuf that is behind a "not ready" in the queue neither.
  - If sockbet buffer is flushed, then "not ready" mbufs shouln't be
freed.
  
  o In struct sockbuf the sb_cc field is split into sb_ccc and sb_acc.
The sb_ccc stands for ""claimed character count", or "committed
character count".  And the sb_acc is "available character count".
Consumers of socket buffer API shouldn't already access them directly,
but use sbused() and sbavail() respectively.
  o Not ready mbufs are marked with M_NOTREADY, and ready but blocked ones
with M_BLOCKED.
  o New field sb_fnrdy points to the first not ready mbuf, to avoid linear
search.
  o New function sbready() is provided to activate certain amount of mbufs
in a socket buffer.
  
  A special note on SCTP:
SCTP has its own sockbufs.  Unfortunately, FreeBSD stack doesn't yet
  allow protocol specific sockbufs.  Thus, SCTP does some hacks to make
  itself compatible with FreeBSD: it manages sockbufs on its own, but keeps
  sb_cc updated to inform the stack of amount of data in them.  The new
  notion of "not ready" data isn't supported by SCTP.  Instead, only a
  mechanical substitute is done: s/sb_cc/sb_ccc/.
A proper solution would be to take away struct sockbuf from struct
  socket and allow protocols to implement their own socket buffers, like
  SCTP already does.  This was discussed with rrs@.
  
  Sponsored by: Netflix
  Sponsored by: Nginx, Inc.

Modified:
  head/sys/dev/cxgbe/tom/t4_ddp.c
  head/sys/kern/uipc_debug.c
  head/sys/kern/uipc_sockbuf.c
  head/sys/kern/uipc_socket.c
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_os_bsd.h
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_pcb.h
  head/sys/netinet/sctp_structs.h
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctp_var.h
  head/sys/netinet/sctputil.c
  head/sys/netinet/sctputil.h
  head/sys/sys/sockbuf.h
  head/usr.bin/bluetooth/btsockstat/btsockstat.c
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/netgraph.c
  head/usr.bin/netstat/unix.c
  head/usr.bin/systat/netstat.c

Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
==
--- head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 12:37:20 2014
(r275325)
+++ head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 12:52:33 2014
(r275326)
@@ -971,8 +971,9 @@ handle_ddp(struct socket *so, struct uio
 */
rc = sbwait(sb);
while (toep->ddp_flags & buf_flag) {
+   /* XXXGL: shouldn't here be sbwait() call? */
sb->sb_flags |= SB_WAIT;
-   msleep(&sb->sb_cc, &sb->sb_mtx, PSOCK , "sbwait", 0);
+   msleep(&sb->sb_acc, &sb->sb_mtx, PSOCK , "sbwait", 0);
}
unwire_ddp_buffer(db);
return (rc);

Modified: head/sys/kern/uipc_debug.c
==
--- head/sys/kern/uipc_debug.c  Sun Nov 30 12:37:20 2014(r275325)
+++ head/sys/kern/uipc_debug.c  Sun Nov 30 12:52:33 2014(r275326)
@@ -401,7 +401,8 @@ db_print_sockbuf(struct sockbuf *sb, con
db_printf("sb_sndptroff: %u\n", sb->sb_sndptroff);
 
db_print_indent(indent);
-   db_printf("sb_cc: %u   ", sb->sb_cc);
+   db_printf("sb_acc: %u   ", sb->sb_acc);
+   db_printf("sb_ccc: %u   ", sb->sb_ccc);
db_printf("sb_hiwat: %u   ", sb->sb_hiwat);
db_printf("sb_mbcnt: %u   ", sb->sb_mbcnt);
db_printf("sb_mbmax: %u\n", sb->sb_mbmax);

Modified: head/sys/kern/uipc_sockbuf.c
==
--- head/sys/kern/uipc_sockbuf.cSun Nov 30 12:37:20 2014
(r275325)
+++ head/sys/kern/uipc_sockbuf.cSun Nov 30 12:52:33 2014
(r275326)
@@ -69,6 +69,43 @@ static struct mbuf   *sbcut_internal(struc
 static voidsbflush_internal(struct sockbuf *sb);
 
 /*
+ * Mark ready "count" mbufs starting with "m".
+ */
+int
+sbready(struct sockbuf *sb, struct mbuf *m, int count)
+{
+   u_int blocker;
+
+   SOCKBUF_LOCK_ASSERT(sb);
+   KASSERT(sb->sb_fnrdy != NULL, ("%s: sb %p NULL fnrdy", __func__, sb));
+
+   blocker = (sb->sb_fnrdy == m) ? M_BLOCKED : 0;
+
+   for (int i = 0; i < count; i++, m = m->m_next) {
+   KASSERT(m->m_flags & M_NOTREADY,
+   ("%s: m %p !M_NOTREADY", __func__, m));
+   m->m_flags &= ~(M_NOTREADY | blocker);
+   if (blocker)
+

svn commit: r275328 - in head/contrib/ofed/librdmacm/examples/build: cmatose mckey rping udaddy

2014-11-30 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Nov 30 13:13:46 2014
New Revision: 275328
URL: https://svnweb.freebsd.org/changeset/base/275328

Log:
  Add missing libraries when linking.
  
  MFC after:3 days
  Sponsored by: Mellanox Technologies

Modified:
  head/contrib/ofed/librdmacm/examples/build/cmatose/Makefile
  head/contrib/ofed/librdmacm/examples/build/mckey/Makefile
  head/contrib/ofed/librdmacm/examples/build/rping/Makefile
  head/contrib/ofed/librdmacm/examples/build/udaddy/Makefile

Modified: head/contrib/ofed/librdmacm/examples/build/cmatose/Makefile
==
--- head/contrib/ofed/librdmacm/examples/build/cmatose/Makefile Sun Nov 30 
13:03:46 2014(r275327)
+++ head/contrib/ofed/librdmacm/examples/build/cmatose/Makefile Sun Nov 30 
13:13:46 2014(r275328)
@@ -6,5 +6,6 @@ PROG=   cmatose
 MAN=
 SRCS=  cmatose.c
 LDADD+= -libverbs -lrdmacm -lpthread
+LDADD+= -lmlx4
 
 .include 

Modified: head/contrib/ofed/librdmacm/examples/build/mckey/Makefile
==
--- head/contrib/ofed/librdmacm/examples/build/mckey/Makefile   Sun Nov 30 
13:03:46 2014(r275327)
+++ head/contrib/ofed/librdmacm/examples/build/mckey/Makefile   Sun Nov 30 
13:13:46 2014(r275328)
@@ -6,5 +6,6 @@ PROG=   mckey
 MAN=
 SRCS=  mckey.c
 LDADD+= -libverbs -lrdmacm -lpthread
+LDADD+= -lmlx4
 
 .include 

Modified: head/contrib/ofed/librdmacm/examples/build/rping/Makefile
==
--- head/contrib/ofed/librdmacm/examples/build/rping/Makefile   Sun Nov 30 
13:03:46 2014(r275327)
+++ head/contrib/ofed/librdmacm/examples/build/rping/Makefile   Sun Nov 30 
13:13:46 2014(r275328)
@@ -6,5 +6,6 @@ PROG=   rping
 MAN=
 SRCS=  rping.c
 LDADD+= -libverbs -lrdmacm -lpthread
+LDADD+= -lmlx4
 
 .include 

Modified: head/contrib/ofed/librdmacm/examples/build/udaddy/Makefile
==
--- head/contrib/ofed/librdmacm/examples/build/udaddy/Makefile  Sun Nov 30 
13:03:46 2014(r275327)
+++ head/contrib/ofed/librdmacm/examples/build/udaddy/Makefile  Sun Nov 30 
13:13:46 2014(r275328)
@@ -6,5 +6,6 @@ PROG=   udaddy
 MAN=
 SRCS=  udaddy.c
 LDADD+= -libverbs -lrdmacm -lpthread
+LDADD+= -lmlx4
 
 .include 
___
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: r275329 - in head/sys: dev/cxgb/ulp/tom dev/cxgbe/tom kern netinet ofed/drivers/infiniband/ulp/sdp sys

2014-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Nov 30 13:24:21 2014
New Revision: 275329
URL: https://svnweb.freebsd.org/changeset/base/275329

Log:
  Merge from projects/sendfile: extend protocols API to support
  sending not ready data:
  o Add new flag to pru_send() flags - PRUS_NOTREADY.
  o Add new protocol method pru_ready().
  
  Sponsored by: Nginx, Inc.
  Sponsored by: Netflix

Modified:
  head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_ddp.c
  head/sys/kern/uipc_domain.c
  head/sys/kern/uipc_mbuf.c
  head/sys/kern/uipc_sockbuf.c
  head/sys/kern/uipc_socket.c
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_reass.c
  head/sys/netinet/tcp_usrreq.c
  head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
  head/sys/sys/mbuf.h
  head/sys/sys/protosw.h
  head/sys/sys/sockbuf.h

Modified: head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
==
--- head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Sun Nov 30 13:13:46 2014
(r275328)
+++ head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Sun Nov 30 13:24:21 2014
(r275329)
@@ -1199,7 +1199,7 @@ do_rx_data(struct sge_qset *qs, struct r
}
 
toep->tp_enqueued += m->m_pkthdr.len;
-   sbappendstream_locked(so_rcv, m);
+   sbappendstream_locked(so_rcv, m, 0);
sorwakeup_locked(so);
SOCKBUF_UNLOCK_ASSERT(so_rcv);
 

Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c  Sun Nov 30 13:13:46 2014
(r275328)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Sun Nov 30 13:24:21 2014
(r275329)
@@ -1086,7 +1086,7 @@ do_peer_close(struct sge_iq *iq, const s
 #ifdef USE_DDP_RX_FLOW_CONTROL
toep->rx_credits -= m->m_len;   /* adjust for F_RX_FC_DDP */
 #endif
-   sbappendstream_locked(sb, m);
+   sbappendstream_locked(sb, m, 0);
toep->sb_cc = sbused(sb);
}
socantrcvmore_locked(so);   /* unlocks the sockbuf */
@@ -1586,7 +1586,7 @@ do_rx_data(struct sge_iq *iq, const stru
("%s: sb %p has more data (%d) than last time (%d).",
__func__, sb, sbused(sb), toep->sb_cc));
toep->rx_credits += toep->sb_cc - sbused(sb);
-   sbappendstream_locked(sb, m);
+   sbappendstream_locked(sb, m, 0);
toep->sb_cc = sbused(sb);
sorwakeup_locked(so);
SOCKBUF_UNLOCK_ASSERT(sb);

Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
==
--- head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 13:13:46 2014
(r275328)
+++ head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 13:24:21 2014
(r275329)
@@ -231,7 +231,7 @@ insert_ddp_data(struct toepcb *toep, uin
 #ifdef USE_DDP_RX_FLOW_CONTROL
toep->rx_credits -= n;  /* adjust for F_RX_FC_DDP */
 #endif
-   sbappendstream_locked(sb, m);
+   sbappendstream_locked(sb, m, 0);
toep->sb_cc = sbused(sb);
 }
 
@@ -466,7 +466,7 @@ handle_ddp_data(struct toepcb *toep, __b
 #ifdef USE_DDP_RX_FLOW_CONTROL
toep->rx_credits -= len;/* adjust for F_RX_FC_DDP */
 #endif
-   sbappendstream_locked(sb, m);
+   sbappendstream_locked(sb, m, 0);
toep->sb_cc = sbused(sb);
 wakeup:
KASSERT(toep->ddp_flags & db_flag,

Modified: head/sys/kern/uipc_domain.c
==
--- head/sys/kern/uipc_domain.c Sun Nov 30 13:13:46 2014(r275328)
+++ head/sys/kern/uipc_domain.c Sun Nov 30 13:24:21 2014(r275329)
@@ -152,6 +152,7 @@ protosw_init(struct protosw *pr)
DEFAULT(pu->pru_sosend, sosend_generic);
DEFAULT(pu->pru_soreceive, soreceive_generic);
DEFAULT(pu->pru_sopoll, sopoll_generic);
+   DEFAULT(pu->pru_ready, pru_ready_notsupp);
 #undef DEFAULT
if (pr->pr_init)
(*pr->pr_init)();

Modified: head/sys/kern/uipc_mbuf.c
==
--- head/sys/kern/uipc_mbuf.c   Sun Nov 30 13:13:46 2014(r275328)
+++ head/sys/kern/uipc_mbuf.c   Sun Nov 30 13:24:21 2014(r275329)
@@ -388,7 +388,7 @@ mb_dupcl(struct mbuf *n, struct mbuf *m)
  * cleaned too.
  */
 void
-m_demote(struct mbuf *m0, int all)
+m_demote(struct mbuf *m0, int all, int flags)
 {
struct mbuf *m;
 
@@ -400,7 +400,7 @@ m_demote(struct mbuf *m0, int all)
m->m_flags &= ~M_PKTHDR;
bzero(&m->m_pkthdr, sizeof(struct pkthdr));
}
-   m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_NOFREE);
+   m->m_flags = m->m_flags & (M_EXT | M_RDONLY | M_NOFREE | flags);
}
 }
 
@@ -997,7 +997,7 @@ m_catpkt(struct mbuf *m, struct mbuf *n)
M_ASSERTPKTHDR(n);
 
m->m_pkthdr.len += n->m_pkthdr.len;
-   m_demote(n, 1);

svn commit: r275330 - in head/contrib/ofed: management/infiniband-diags/src usr.bin

2014-11-30 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Nov 30 13:27:58 2014
New Revision: 275330
URL: https://svnweb.freebsd.org/changeset/base/275330

Log:
  Fix building of some infiniband utilities by updating some header file
  locations and compiler include directives.
  
  MFC after:3 days
  Sponsored by: Mellanox Technologies

Modified:
  head/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c
  head/contrib/ofed/management/infiniband-diags/src/ibroute.c
  head/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c
  head/contrib/ofed/management/infiniband-diags/src/ibtracert.c
  head/contrib/ofed/management/infiniband-diags/src/saquery.c
  head/contrib/ofed/management/infiniband-diags/src/smpquery.c
  head/contrib/ofed/usr.bin/Makefile.inc

Modified: head/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c
==
--- head/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c   Sun Nov 
30 13:24:21 2014(r275329)
+++ head/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c   Sun Nov 
30 13:27:58 2014(r275330)
@@ -50,7 +50,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "ibnetdiscover.h"
 #include "grouping.h"

Modified: head/contrib/ofed/management/infiniband-diags/src/ibroute.c
==
--- head/contrib/ofed/management/infiniband-diags/src/ibroute.c Sun Nov 30 
13:24:21 2014(r275329)
+++ head/contrib/ofed/management/infiniband-diags/src/ibroute.c Sun Nov 30 
13:27:58 2014(r275330)
@@ -49,7 +49,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "ibdiag_common.h"
 

Modified: head/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c
==
--- head/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c  Sun Nov 
30 13:24:21 2014(r275329)
+++ head/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c  Sun Nov 
30 13:27:58 2014(r275330)
@@ -43,7 +43,7 @@
 #include 
 
 #include 
-#include 
+#include 
 
 #include "ibdiag_common.h"
 

Modified: head/contrib/ofed/management/infiniband-diags/src/ibtracert.c
==
--- head/contrib/ofed/management/infiniband-diags/src/ibtracert.c   Sun Nov 
30 13:24:21 2014(r275329)
+++ head/contrib/ofed/management/infiniband-diags/src/ibtracert.c   Sun Nov 
30 13:27:58 2014(r275330)
@@ -49,7 +49,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "ibdiag_common.h"
 

Modified: head/contrib/ofed/management/infiniband-diags/src/saquery.c
==
--- head/contrib/ofed/management/infiniband-diags/src/saquery.c Sun Nov 30 
13:24:21 2014(r275329)
+++ head/contrib/ofed/management/infiniband-diags/src/saquery.c Sun Nov 30 
13:27:58 2014(r275330)
@@ -50,12 +50,12 @@
 #include 
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 

Modified: head/contrib/ofed/management/infiniband-diags/src/smpquery.c
==
--- head/contrib/ofed/management/infiniband-diags/src/smpquery.cSun Nov 
30 13:24:21 2014(r275329)
+++ head/contrib/ofed/management/infiniband-diags/src/smpquery.cSun Nov 
30 13:27:58 2014(r275330)
@@ -50,7 +50,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "ibdiag_common.h"
 

Modified: head/contrib/ofed/usr.bin/Makefile.inc
==
--- head/contrib/ofed/usr.bin/Makefile.inc  Sun Nov 30 13:24:21 2014
(r275329)
+++ head/contrib/ofed/usr.bin/Makefile.inc  Sun Nov 30 13:27:58 2014
(r275330)
@@ -1,4 +1,9 @@
 DIAGPATH=  ${.CURDIR}/../../management/infiniband-diags
 BINDIR?=   /usr/bin
 CFLAGS+=   -I${.CURDIR}/../../include/infiniband
+CFLAGS+=   -I${.CURDIR}/../../include
 CFLAGS+=   -I${.CURDIR}/../../management/opensm/include/
+CFLAGS+=   -I${.CURDIR}/../../management/opensm
+CFLAGS+=   -I${.CURDIR}/../../management/libibcommon/include
+CFLAGS+=   -I${.CURDIR}/../../management/libibumad/include
+CFLAGS+=   -I${.CURDIR}/../../management/libibmad/include
___
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: r275332 - head/sys/kern

2014-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Nov 30 13:40:58 2014
New Revision: 275332
URL: https://svnweb.freebsd.org/changeset/base/275332

Log:
  Merge from projects/sendfile:
  
  Provide pru_ready for AF_LOCAL sockets.  Local sockets sendsdata directly
  to the receive buffer of the peer, thus pru_ready also works on the peer
  socket.
  
  Sponsored by: Netflix
  Sponsored by: Nginx, Inc.

Modified:
  head/sys/kern/uipc_usrreq.c

Modified: head/sys/kern/uipc_usrreq.c
==
--- head/sys/kern/uipc_usrreq.c Sun Nov 30 13:28:21 2014(r275331)
+++ head/sys/kern/uipc_usrreq.c Sun Nov 30 13:40:58 2014(r275332)
@@ -1048,6 +1048,32 @@ release:
 }
 
 static int
+uipc_ready(struct socket *so, struct mbuf *m, int count)
+{
+   struct unpcb *unp, *unp2;
+   struct socket *so2;
+   int error;
+
+   unp = sotounpcb(so);
+
+   UNP_LINK_RLOCK();
+   unp2 = unp->unp_conn;
+   UNP_PCB_LOCK(unp2);
+   so2 = unp2->unp_socket;
+
+   SOCKBUF_LOCK(&so2->so_rcv);
+   if ((error = sbready(&so2->so_rcv, m, count)) == 0)
+   sorwakeup_locked(so2);
+   else
+   SOCKBUF_UNLOCK(&so2->so_rcv);
+
+   UNP_PCB_UNLOCK(unp2);
+   UNP_LINK_RUNLOCK();
+
+   return (error);
+}
+
+static int
 uipc_sense(struct socket *so, struct stat *sb)
 {
struct unpcb *unp;
@@ -1161,6 +1187,7 @@ static struct pr_usrreqs uipc_usrreqs_st
.pru_peeraddr = uipc_peeraddr,
.pru_rcvd = uipc_rcvd,
.pru_send = uipc_send,
+   .pru_ready =uipc_ready,
.pru_sense =uipc_sense,
.pru_shutdown = uipc_shutdown,
.pru_sockaddr = uipc_sockaddr,
___
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: r275333 - head/sys/netinet

2014-11-30 Thread Gleb Smirnoff
Author: glebius
Date: Sun Nov 30 13:43:52 2014
New Revision: 275333
URL: https://svnweb.freebsd.org/changeset/base/275333

Log:
  Merge from projects/sendfile:
  
  - Provide pru_ready function for TCP.
  - Don't call tcp_output() from tcp_usr_send() if no ready data was put
into the socket buffer.
  - In case of dropped connection don't try to m_freem() not ready data.
  
  Sponsored by: Nginx, Inc.
  Sponsored by: Netflix

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==
--- head/sys/netinet/tcp_usrreq.c   Sun Nov 30 13:40:58 2014
(r275332)
+++ head/sys/netinet/tcp_usrreq.c   Sun Nov 30 13:43:52 2014
(r275333)
@@ -821,7 +821,11 @@ tcp_usr_send(struct socket *so, int flag
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
if (control)
m_freem(control);
-   if (m)
+   /*
+* In case of PRUS_NOTREADY, tcp_usr_ready() is responsible
+* for freeing memory.
+*/
+   if (m && (flags & PRUS_NOTREADY) == 0)
m_freem(m);
error = ECONNRESET;
goto out;
@@ -875,7 +879,8 @@ tcp_usr_send(struct socket *so, int flag
socantsendmore(so);
tcp_usrclosed(tp);
}
-   if (!(inp->inp_flags & INP_DROPPED)) {
+   if (!(inp->inp_flags & INP_DROPPED) &&
+   !(flags & PRUS_NOTREADY)) {
if (flags & PRUS_MORETOCOME)
tp->t_flags |= TF_MORETOCOME;
error = tcp_output(tp);
@@ -926,9 +931,11 @@ tcp_usr_send(struct socket *so, int flag
tcp_mss(tp, -1);
}
tp->snd_up = tp->snd_una + sbavail(&so->so_snd);
-   tp->t_flags |= TF_FORCEDATA;
-   error = tcp_output(tp);
-   tp->t_flags &= ~TF_FORCEDATA;
+   if (!(flags & PRUS_NOTREADY)) {
+   tp->t_flags |= TF_FORCEDATA;
+   error = tcp_output(tp);
+   tp->t_flags &= ~TF_FORCEDATA;
+   }
}
 out:
TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB :
@@ -939,6 +946,33 @@ out:
return (error);
 }
 
+static int
+tcp_usr_ready(struct socket *so, struct mbuf *m, int count)
+{
+   struct inpcb *inp;
+   struct tcpcb *tp;
+   int error;
+
+   inp = sotoinpcb(so);
+   INP_WLOCK(inp);
+   if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
+   INP_WUNLOCK(inp);
+   for (int i = 0; i < count; i++)
+   m = m_free(m);
+   return (ECONNRESET);
+   }
+   tp = intotcpcb(inp);
+
+   SOCKBUF_LOCK(&so->so_snd);
+   error = sbready(&so->so_snd, m, count);
+   SOCKBUF_UNLOCK(&so->so_snd);
+   if (error == 0)
+   error = tcp_output(tp);
+   INP_WUNLOCK(inp);
+
+   return (error);
+}
+
 /*
  * Abort the TCP.  Drop the connection abruptly.
  */
@@ -1073,6 +1107,7 @@ struct pr_usrreqs tcp_usrreqs = {
.pru_rcvd = tcp_usr_rcvd,
.pru_rcvoob =   tcp_usr_rcvoob,
.pru_send = tcp_usr_send,
+   .pru_ready =tcp_usr_ready,
.pru_shutdown = tcp_usr_shutdown,
.pru_sockaddr = in_getsockaddr,
.pru_sosetlabel =   in_pcbsosetlabel,
@@ -1095,6 +1130,7 @@ struct pr_usrreqs tcp6_usrreqs = {
.pru_rcvd = tcp_usr_rcvd,
.pru_rcvoob =   tcp_usr_rcvoob,
.pru_send = tcp_usr_send,
+   .pru_ready =tcp_usr_ready,
.pru_shutdown = tcp_usr_shutdown,
.pru_sockaddr = in6_mapped_sockaddr,
.pru_sosetlabel =   in_pcbsosetlabel,
___
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: r275335 - head/sys/dev/virtio/block

2014-11-30 Thread Bryan Venteicher
Author: bryanv
Date: Sun Nov 30 16:36:26 2014
New Revision: 275335
URL: https://svnweb.freebsd.org/changeset/base/275335

Log:
  Cleanup and performance improvement of the virtio_blk driver
  
- Add support for GEOM direct completion. Depending on the benchmark,
  this tends to give a ~30% improvement w.r.t IOPs and BW.
- Remove an invariants check in the strategy routine. This assertion
  is caught later on by an existing panic.
- Rename and resort various related functions to make more sense.
  
  MFC after:1 month

Modified:
  head/sys/dev/virtio/block/virtio_blk.c

Modified: head/sys/dev/virtio/block/virtio_blk.c
==
--- head/sys/dev/virtio/block/virtio_blk.c  Sun Nov 30 14:35:01 2014
(r275334)
+++ head/sys/dev/virtio/block/virtio_blk.c  Sun Nov 30 16:36:26 2014
(r275335)
@@ -58,7 +58,6 @@ struct vtblk_request {
struct virtio_blk_outhdr vbr_hdr;
struct bio  *vbr_bp;
uint8_t  vbr_ack;
-
TAILQ_ENTRY(vtblk_request)   vbr_link;
 };
 
@@ -132,53 +131,60 @@ static intvtblk_dump(void *, void *, vm
 static voidvtblk_strategy(struct bio *);
 
 static voidvtblk_negotiate_features(struct vtblk_softc *);
+static voidvtblk_setup_features(struct vtblk_softc *);
 static int vtblk_maximum_segments(struct vtblk_softc *,
struct virtio_blk_config *);
 static int vtblk_alloc_virtqueue(struct vtblk_softc *);
 static voidvtblk_resize_disk(struct vtblk_softc *, uint64_t);
-static voidvtblk_set_write_cache(struct vtblk_softc *, int);
-static int vtblk_write_cache_enabled(struct vtblk_softc *sc,
-   struct virtio_blk_config *);
-static int vtblk_write_cache_sysctl(SYSCTL_HANDLER_ARGS);
 static voidvtblk_alloc_disk(struct vtblk_softc *,
struct virtio_blk_config *);
 static voidvtblk_create_disk(struct vtblk_softc *);
 
-static int vtblk_quiesce(struct vtblk_softc *);
-static voidvtblk_startio(struct vtblk_softc *);
-static struct vtblk_request * vtblk_bio_request(struct vtblk_softc *);
-static int vtblk_execute_request(struct vtblk_softc *,
+static int vtblk_request_prealloc(struct vtblk_softc *);
+static voidvtblk_request_free(struct vtblk_softc *);
+static struct vtblk_request *
+   vtblk_request_dequeue(struct vtblk_softc *);
+static voidvtblk_request_enqueue(struct vtblk_softc *,
struct vtblk_request *);
+static struct vtblk_request *
+   vtblk_request_next_ready(struct vtblk_softc *);
+static voidvtblk_request_requeue_ready(struct vtblk_softc *,
+   struct vtblk_request *);
+static struct vtblk_request *
+   vtblk_request_next(struct vtblk_softc *);
+static struct vtblk_request *
+   vtblk_request_bio(struct vtblk_softc *);
+static int vtblk_request_execute(struct vtblk_softc *,
+   struct vtblk_request *);
+static int vtblk_request_error(struct vtblk_request *);
 
-static voidvtblk_vq_intr(void *);
+static voidvtblk_queue_completed(struct vtblk_softc *,
+   struct bio_queue *);
+static voidvtblk_done_completed(struct vtblk_softc *,
+   struct bio_queue *);
+static voidvtblk_drain_vq(struct vtblk_softc *, int);
+static voidvtblk_drain(struct vtblk_softc *);
 
-static voidvtblk_stop(struct vtblk_softc *);
+static voidvtblk_startio(struct vtblk_softc *);
+static voidvtblk_bio_done(struct vtblk_softc *, struct bio *, int);
 
 static voidvtblk_read_config(struct vtblk_softc *,
struct virtio_blk_config *);
-static voidvtblk_get_ident(struct vtblk_softc *);
-static voidvtblk_prepare_dump(struct vtblk_softc *);
-static int vtblk_write_dump(struct vtblk_softc *, void *, off_t, size_t);
-static int vtblk_flush_dump(struct vtblk_softc *);
+static voidvtblk_ident(struct vtblk_softc *);
 static int vtblk_poll_request(struct vtblk_softc *,
struct vtblk_request *);
+static int vtblk_quiesce(struct vtblk_softc *);
+static voidvtblk_vq_intr(void *);
+static voidvtblk_stop(struct vtblk_softc *);
 
-static voidvtblk_finish_completed(struct vtblk_softc *);
-static voidvtblk_drain_vq(struct vtblk_softc *, int);
-static voidvtblk_drain(struct vtblk_softc *);
-
-static int vtblk_alloc_requests(struct vtblk_softc *);
-static voidvtblk_free_requests(struct vtblk_softc *);
-static struct vtblk_request * vtblk_dequeue_request(struct vtblk_softc *);
-static voidvtblk_enqueue_request(struct vtblk_softc *,
-   struct vtblk_request *);
-
-static struct vtblk_request * vtblk_dequeue_ready(struct vtblk_softc *);
-static voidvtblk_enqueue_ready(struct vtblk_softc *,
-   struct vtblk_request *);
+static void  

svn commit: r275336 - head/contrib/binutils/bfd

2014-11-30 Thread Andrew Turner
Author: andrew
Date: Sun Nov 30 17:27:24 2014
New Revision: 275336
URL: https://svnweb.freebsd.org/changeset/base/275336

Log:
  Use llabs when getting the absolute value of a long long.
  
  Sponsored by: ABT Ststems Ltd

Modified:
  head/contrib/binutils/bfd/elf32-arm.c

Modified: head/contrib/binutils/bfd/elf32-arm.c
==
--- head/contrib/binutils/bfd/elf32-arm.c   Sun Nov 30 16:36:26 2014
(r275335)
+++ head/contrib/binutils/bfd/elf32-arm.c   Sun Nov 30 17:27:24 2014
(r275336)
@@ -4960,7 +4960,7 @@ elf32_arm_final_link_relocate (reloc_how
   + input_section->output_offset
   + rel->r_offset);
 
-value = abs (relocation);
+value = llabs (relocation);
 
 if (value >= 0x1000)
   return bfd_reloc_overflow;
@@ -4998,7 +4998,7 @@ elf32_arm_final_link_relocate (reloc_how
   + input_section->output_offset
   + rel->r_offset);
 
-value = abs (relocation);
+value = llabs (relocation);
 
 if (value >= 0x1000)
   return bfd_reloc_overflow;
@@ -5984,7 +5984,7 @@ elf32_arm_final_link_relocate (reloc_how
 
 /* Calculate the value of the relevant G_n, in encoded
constant-with-rotation format.  */
-g_n = calculate_group_reloc_mask (abs (signed_value), group,
+g_n = calculate_group_reloc_mask (llabs (signed_value), group,
   &residual);
 
 /* Check for overflow if required.  */
@@ -5998,7 +5998,7 @@ elf32_arm_final_link_relocate (reloc_how
 (*_bfd_error_handler)
   (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group 
relocation %s"),
   input_bfd, input_section,
-  (long) rel->r_offset, abs (signed_value), howto->name);
+  (long) rel->r_offset, llabs (signed_value), howto->name);
 return bfd_reloc_overflow;
   }
 
@@ -6077,7 +6077,7 @@ elf32_arm_final_link_relocate (reloc_how
 
 /* Calculate the value of the relevant G_{n-1} to obtain
the residual at that stage.  */
-calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
+calculate_group_reloc_mask (llabs (signed_value), group - 1, 
&residual);
 
 /* Check for overflow.  */
 if (residual >= 0x1000)
@@ -6085,7 +6085,7 @@ elf32_arm_final_link_relocate (reloc_how
 (*_bfd_error_handler)
   (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group 
relocation %s"),
   input_bfd, input_section,
-  (long) rel->r_offset, abs (signed_value), howto->name);
+  (long) rel->r_offset, llabs (signed_value), howto->name);
 return bfd_reloc_overflow;
   }
 
@@ -6160,7 +6160,7 @@ elf32_arm_final_link_relocate (reloc_how
 
 /* Calculate the value of the relevant G_{n-1} to obtain
the residual at that stage.  */
-calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
+calculate_group_reloc_mask (llabs (signed_value), group - 1, 
&residual);
 
 /* Check for overflow.  */
 if (residual >= 0x100)
@@ -6168,7 +6168,7 @@ elf32_arm_final_link_relocate (reloc_how
 (*_bfd_error_handler)
   (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group 
relocation %s"),
   input_bfd, input_section,
-  (long) rel->r_offset, abs (signed_value), howto->name);
+  (long) rel->r_offset, llabs (signed_value), howto->name);
 return bfd_reloc_overflow;
   }
 
@@ -6243,7 +6243,7 @@ elf32_arm_final_link_relocate (reloc_how
 
 /* Calculate the value of the relevant G_{n-1} to obtain
the residual at that stage.  */
-calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
+calculate_group_reloc_mask (llabs (signed_value), group - 1, 
&residual);
 
 /* Check for overflow.  (The absolute value to go in the place must be
divisible by four and, after having been divided by four, must
@@ -6253,7 +6253,7 @@ elf32_arm_final_link_relocate (reloc_how
 (*_bfd_error_handler)
   (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group 
relocation %s"),
   input_bfd, input_section,
-  (long) rel->r_offset, abs (signed_value), howto->name);
+  (long) rel->r_offset, llabs (signed_value), howto->name);
 return bfd_reloc_overflow;
   }
 
___
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: r275337 - head/contrib/gcc/config/arm

2014-11-30 Thread Andrew Turner
Author: andrew
Date: Sun Nov 30 17:29:49 2014
New Revision: 275337
URL: https://svnweb.freebsd.org/changeset/base/275337

Log:
  There is no need to use FUNC_END with aeabi_ldiv0 or aeabi_idiv0 as they
  are aliases.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/contrib/gcc/config/arm/lib1funcs.asm

Modified: head/contrib/gcc/config/arm/lib1funcs.asm
==
--- head/contrib/gcc/config/arm/lib1funcs.asm   Sun Nov 30 17:27:24 2014
(r275336)
+++ head/contrib/gcc/config/arm/lib1funcs.asm   Sun Nov 30 17:29:49 2014
(r275337)
@@ -980,8 +980,6 @@ LSYM(Lover12):
 
RET
 
-   FUNC_END aeabi_ldiv0
-   FUNC_END aeabi_idiv0
FUNC_END div0

 #endif /* L_divmodsi_tools */
___
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: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Adrian Chadd
Hi,

I really wished that these commits got individual reviews before they went in.

The whole idea of an mbuf whose data isn't quite there yet makes
debugging issues rather amusing, as now you may have VM issues to
debug at the same time as you're debugging network related stuff.

I really think this could've been done without all the back-handed VM
work. The mbufs and IO buffers both have completion function calls; it
would've been much less intrusive to do it that way.



-adrian


On 30 November 2014 at 04:52, Gleb Smirnoff  wrote:
> Author: glebius
> Date: Sun Nov 30 12:52:33 2014
> New Revision: 275326
> URL: https://svnweb.freebsd.org/changeset/base/275326
>
> Log:
>   Merge from projects/sendfile:
>
>   o Introduce a notion of "not ready" mbufs in socket buffers.  These
>   mbufs are now being populated by some I/O in background and are
>   referenced outside.  This forces following implications:
>   - An mbuf which is "not ready" can't be taken out of the buffer.
>   - An mbuf that is behind a "not ready" in the queue neither.
>   - If sockbet buffer is flushed, then "not ready" mbufs shouln't be
> freed.
>
>   o In struct sockbuf the sb_cc field is split into sb_ccc and sb_acc.
> The sb_ccc stands for ""claimed character count", or "committed
> character count".  And the sb_acc is "available character count".
> Consumers of socket buffer API shouldn't already access them directly,
> but use sbused() and sbavail() respectively.
>   o Not ready mbufs are marked with M_NOTREADY, and ready but blocked ones
> with M_BLOCKED.
>   o New field sb_fnrdy points to the first not ready mbuf, to avoid linear
> search.
>   o New function sbready() is provided to activate certain amount of mbufs
> in a socket buffer.
>
>   A special note on SCTP:
> SCTP has its own sockbufs.  Unfortunately, FreeBSD stack doesn't yet
>   allow protocol specific sockbufs.  Thus, SCTP does some hacks to make
>   itself compatible with FreeBSD: it manages sockbufs on its own, but keeps
>   sb_cc updated to inform the stack of amount of data in them.  The new
>   notion of "not ready" data isn't supported by SCTP.  Instead, only a
>   mechanical substitute is done: s/sb_cc/sb_ccc/.
> A proper solution would be to take away struct sockbuf from struct
>   socket and allow protocols to implement their own socket buffers, like
>   SCTP already does.  This was discussed with rrs@.
>
>   Sponsored by: Netflix
>   Sponsored by: Nginx, Inc.
>
> Modified:
>   head/sys/dev/cxgbe/tom/t4_ddp.c
>   head/sys/kern/uipc_debug.c
>   head/sys/kern/uipc_sockbuf.c
>   head/sys/kern/uipc_socket.c
>   head/sys/netinet/sctp_indata.c
>   head/sys/netinet/sctp_input.c
>   head/sys/netinet/sctp_os_bsd.h
>   head/sys/netinet/sctp_output.c
>   head/sys/netinet/sctp_pcb.c
>   head/sys/netinet/sctp_pcb.h
>   head/sys/netinet/sctp_structs.h
>   head/sys/netinet/sctp_usrreq.c
>   head/sys/netinet/sctp_var.h
>   head/sys/netinet/sctputil.c
>   head/sys/netinet/sctputil.h
>   head/sys/sys/sockbuf.h
>   head/usr.bin/bluetooth/btsockstat/btsockstat.c
>   head/usr.bin/netstat/inet.c
>   head/usr.bin/netstat/netgraph.c
>   head/usr.bin/netstat/unix.c
>   head/usr.bin/systat/netstat.c
>
> Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
> ==
> --- head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 12:37:20 2014
> (r275325)
> +++ head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 12:52:33 2014
> (r275326)
> @@ -971,8 +971,9 @@ handle_ddp(struct socket *so, struct uio
>  */
> rc = sbwait(sb);
> while (toep->ddp_flags & buf_flag) {
> +   /* XXXGL: shouldn't here be sbwait() call? */
> sb->sb_flags |= SB_WAIT;
> -   msleep(&sb->sb_cc, &sb->sb_mtx, PSOCK , "sbwait", 0);
> +   msleep(&sb->sb_acc, &sb->sb_mtx, PSOCK , "sbwait", 0);
> }
> unwire_ddp_buffer(db);
> return (rc);
>
> Modified: head/sys/kern/uipc_debug.c
> ==
> --- head/sys/kern/uipc_debug.c  Sun Nov 30 12:37:20 2014(r275325)
> +++ head/sys/kern/uipc_debug.c  Sun Nov 30 12:52:33 2014(r275326)
> @@ -401,7 +401,8 @@ db_print_sockbuf(struct sockbuf *sb, con
> db_printf("sb_sndptroff: %u\n", sb->sb_sndptroff);
>
> db_print_indent(indent);
> -   db_printf("sb_cc: %u   ", sb->sb_cc);
> +   db_printf("sb_acc: %u   ", sb->sb_acc);
> +   db_printf("sb_ccc: %u   ", sb->sb_ccc);
> db_printf("sb_hiwat: %u   ", sb->sb_hiwat);
> db_printf("sb_mbcnt: %u   ", sb->sb_mbcnt);
> db_printf("sb_mbmax: %u\n", sb->sb_mbmax);
>
> Modified: head/sys/kern/uipc_sockbuf.c
> ==
> --- head/sys/kern/uipc_sockbuf.cSun Nov 30 12:37:20 2014
> (r275325)
> +++ head/sys/kern/uipc_sockbuf.cSun Nov 30 1

Re: svn commit: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Alfred Perlstein
Agree, this was already discussed as quite possibly an incorrect way 
forward some months ago.


Where is the actual review for this huge change to the networking stack?

Splitting this into the mbuf layer adds a huge level of complexity where 
again, there are already completion paths in the socket layer to do 
this.  I am completely confused as to why this couldn't just be done 
with the socket callback system already in place.  Very open to being 
educated on this!


The concept of "not filled mbufs" in a socket buffer seems absolutely 
wrong at a glance, I'm sure with some better explanation this would all 
make sense, but really am still not convinced this is at all the right 
way to go on this.


Does any other OS do this for any reason?  Or is this just a short 
sighted hack for an experiment in sendfile?


I am really trying very hard to rationalize this change, so I will ask, 
is there something about keeping TCP windows open that you are hoping to 
accomplish that you can not otherwise do without sb_ccc and sb_acc?  If 
not then why is all this stuff being stuffed into mbufs as opposed to 
using callbacks?  It really seems wrong, my thoughts are "this is like 
kse for mbufs" something done with good intentions, but is complex and 
will have to be ripped out later.  Am I wrong here?


-Alfred

On 11/30/14, 9:55 AM, Adrian Chadd wrote:

Hi,

I really wished that these commits got individual reviews before they went in.

The whole idea of an mbuf whose data isn't quite there yet makes
debugging issues rather amusing, as now you may have VM issues to
debug at the same time as you're debugging network related stuff.

I really think this could've been done without all the back-handed VM
work. The mbufs and IO buffers both have completion function calls; it
would've been much less intrusive to do it that way.



-adrian


On 30 November 2014 at 04:52, Gleb Smirnoff  wrote:

Author: glebius
Date: Sun Nov 30 12:52:33 2014
New Revision: 275326
URL: https://svnweb.freebsd.org/changeset/base/275326

Log:
   Merge from projects/sendfile:

   o Introduce a notion of "not ready" mbufs in socket buffers.  These
   mbufs are now being populated by some I/O in background and are
   referenced outside.  This forces following implications:
   - An mbuf which is "not ready" can't be taken out of the buffer.
   - An mbuf that is behind a "not ready" in the queue neither.
   - If sockbet buffer is flushed, then "not ready" mbufs shouln't be
 freed.

   o In struct sockbuf the sb_cc field is split into sb_ccc and sb_acc.
 The sb_ccc stands for ""claimed character count", or "committed
 character count".  And the sb_acc is "available character count".
 Consumers of socket buffer API shouldn't already access them directly,
 but use sbused() and sbavail() respectively.
   o Not ready mbufs are marked with M_NOTREADY, and ready but blocked ones
 with M_BLOCKED.
   o New field sb_fnrdy points to the first not ready mbuf, to avoid linear
 search.
   o New function sbready() is provided to activate certain amount of mbufs
 in a socket buffer.

   A special note on SCTP:
 SCTP has its own sockbufs.  Unfortunately, FreeBSD stack doesn't yet
   allow protocol specific sockbufs.  Thus, SCTP does some hacks to make
   itself compatible with FreeBSD: it manages sockbufs on its own, but keeps
   sb_cc updated to inform the stack of amount of data in them.  The new
   notion of "not ready" data isn't supported by SCTP.  Instead, only a
   mechanical substitute is done: s/sb_cc/sb_ccc/.
 A proper solution would be to take away struct sockbuf from struct
   socket and allow protocols to implement their own socket buffers, like
   SCTP already does.  This was discussed with rrs@.

   Sponsored by: Netflix
   Sponsored by: Nginx, Inc.

Modified:
   head/sys/dev/cxgbe/tom/t4_ddp.c
   head/sys/kern/uipc_debug.c
   head/sys/kern/uipc_sockbuf.c
   head/sys/kern/uipc_socket.c
   head/sys/netinet/sctp_indata.c
   head/sys/netinet/sctp_input.c
   head/sys/netinet/sctp_os_bsd.h
   head/sys/netinet/sctp_output.c
   head/sys/netinet/sctp_pcb.c
   head/sys/netinet/sctp_pcb.h
   head/sys/netinet/sctp_structs.h
   head/sys/netinet/sctp_usrreq.c
   head/sys/netinet/sctp_var.h
   head/sys/netinet/sctputil.c
   head/sys/netinet/sctputil.h
   head/sys/sys/sockbuf.h
   head/usr.bin/bluetooth/btsockstat/btsockstat.c
   head/usr.bin/netstat/inet.c
   head/usr.bin/netstat/netgraph.c
   head/usr.bin/netstat/unix.c
   head/usr.bin/systat/netstat.c

Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
==
--- head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 12:37:20 2014
(r275325)
+++ head/sys/dev/cxgbe/tom/t4_ddp.c Sun Nov 30 12:52:33 2014
(r275326)
@@ -971,8 +971,9 @@ handle_ddp(struct socket *so, struct uio
  */
 rc = sbwait(sb);
 while (toep->ddp_flags & buf_flag) {
+   /* XXXGL: shouldn't here be sbwai

Re: svn commit: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Gleb Smirnoff
  Adrian & Alfred,

On Sun, Nov 30, 2014 at 09:55:05AM -0800, Adrian Chadd wrote:
A> I really wished that these commits got individual reviews before they went 
in.

On Sun, Nov 30, 2014 at 10:10:57AM -0800, Alfred Perlstein wrote:
A> Agree, this was already discussed as quite possibly an incorrect way 
A> forward some months ago.
A> 
A> Where is the actual review for this huge change to the networking stack?
A> 

The development was going on in the open branch, and I've been sending the
diff on the new sendfile constantly during this year. Last time I sent the
diff, the discussion very quickly moved to Lua in kernel, script(2) and
other buzz, actually ignoring my review and test request and hijacking
my thread:

https://lists.freebsd.org/pipermail/freebsd-arch/2014-September/015861.html

Yes, Alfred did ask me why can't this be accomplished with socket
upcalls, and replied I to him, but discussion ended there:

https://lists.freebsd.org/pipermail/freebsd-arch/2014-September/015858.html

Probably the script(2) topic was more appealing.

If you don't mind, I will make a separate replies on your actual
technical questions.

-- 
Totus tuus, Glebius.
___
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: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Gleb Smirnoff
  Alfred,

On Sun, Nov 30, 2014 at 10:10:57AM -0800, Alfred Perlstein wrote:
A> Splitting this into the mbuf layer adds a huge level of complexity where 
A> again, there are already completion paths in the socket layer to do 
A> this.  I am completely confused as to why this couldn't just be done 
A> with the socket callback system already in place.  Very open to being 
A> educated on this!

As said in September, I can't understand how socket buffer upcall system
can be used here. It does the opposite: wakes up something in kernel when
data arrives to socket. So I am also very open to being explained on
how can I apply it here.

A> The concept of "not filled mbufs" in a socket buffer seems absolutely 
A> wrong at a glance, I'm sure with some better explanation this would all 
A> make sense, but really am still not convinced this is at all the right 
A> way to go on this.

I'll put a longer explanation in the end of this email.

A> Does any other OS do this for any reason?  Or is this just a short 
A> sighted hack for an experiment in sendfile?

Well, we also have plans to put TLS into kernel, that would use them
as well. :) There might be more consumers.

Note, that sf_bufs were initially a "just a short sighted hack" for
sendfile(2), and now are used in several places in kernel.

A> I am really trying very hard to rationalize this change, so I will ask, 
A> is there something about keeping TCP windows open that you are hoping to 
A> accomplish that you can not otherwise do without sb_ccc and sb_acc?  If 
A> not then why is all this stuff being stuffed into mbufs as opposed to 
A> using callbacks?  It really seems wrong, my thoughts are "this is like 
A> kse for mbufs" something done with good intentions, but is complex and 
A> will have to be ripped out later.  Am I wrong here?

No, this has nothing to do with keeping TCP windows.

Here is longer explanation: the new sendfile(2) is going to be
non-blocking on disk. That means, that syscalls returns back to
application without completing I/O, immediately. Application can
do its work further. It can write(2) to the socket as well. Or run
another sendfile(2) on the same socket. Probably now you see the
problem. If the non-blocking sendfile doesn't put a placeholder
for its data into the socket buffer, then data in the socket buffer
is going to be mixed randomly.

Please note, that I don't move anything to the mbuf layer, as you
claim it. Neither mbuf.h, not kern_mbuf.c, uipc_mbuf.c are modified.
This is a new feature held internally in the socket buffer code.

Yes, the sweep of changing sb_cc to sbavail() and sbused() was
large. This is the problem of socket buffers being exposed to the
stack and stack lurking in the structure. If decades ago socket
code was developed more self-contained, then no sweep would be
needed. As I already noted in the commit message, my opinion is
that socket buffers need to be made protocol dependent and more
opaque. The SCTP code taught me that. As for TCP/UDP, right now
our socket buffer structure supports SOCK_STREAM and SOCK_DGRAM
but this is achieved through code complication, and I see no good
reason to keep it so generic. Original BSD soreceive() functions
was a hell, before it was divorced to soreceive_stream() and
soreceive_dgram(). Splitting the sockbuf to two different types
would finish that.

-- 
Totus tuus, Glebius.
___
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: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Gleb Smirnoff
  Adrian,

On Sun, Nov 30, 2014 at 09:55:05AM -0800, Adrian Chadd wrote:
A> The whole idea of an mbuf whose data isn't quite there yet makes
A> debugging issues rather amusing, as now you may have VM issues to
A> debug at the same time as you're debugging network related stuff.

I don't see how VM issues are related. The mbufs are referencing
allocated, mapped and wired pages via sf_bufs. The same way as they
did it since 1998. The only difference is that pages aren't populated
with data. No VM changes happen to the pages while the mbufs that
reference them sit in the socket buffer.

A> I really think this could've been done without all the back-handed VM
A> work. The mbufs and IO buffers both have completion function calls; it
A> would've been much less intrusive to do it that way.

If you can describe the alternative design at least in some detail,
I am listening.

-- 
Totus tuus, Glebius.
___
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: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Alfred Perlstein


On 11/30/14, 10:38 AM, Gleb Smirnoff wrote:

   Adrian & Alfred,

On Sun, Nov 30, 2014 at 09:55:05AM -0800, Adrian Chadd wrote:
A> I really wished that these commits got individual reviews before they went 
in.

On Sun, Nov 30, 2014 at 10:10:57AM -0800, Alfred Perlstein wrote:
A> Agree, this was already discussed as quite possibly an incorrect way
A> forward some months ago.
A>
A> Where is the actual review for this huge change to the networking stack?
A>

The development was going on in the open branch, and I've been sending the
diff on the new sendfile constantly during this year. Last time I sent the
diff, the discussion very quickly moved to Lua in kernel, script(2) and
other buzz, actually ignoring my review and test request and hijacking
my thread:

https://lists.freebsd.org/pipermail/freebsd-arch/2014-September/015861.html

Yes, Alfred did ask me why can't this be accomplished with socket
upcalls, and replied I to him, but discussion ended there:

https://lists.freebsd.org/pipermail/freebsd-arch/2014-September/015858.html

Probably the script(2) topic was more appealing.

If you don't mind, I will make a separate replies on your actual
technical questions.


Gleb,

Maybe I misread your reply to 
'https://lists.freebsd.org/pipermail/freebsd-arch/2014-September/015858.html' 
but my interpretation of your reply was that you would reconsider your 
approach because the suggestion to use socket callback was a valid one.


I am very open to being wrong on this issue, but with all due respect I 
don't see a good reason why not to use socket callbacks to even 
implement what you have right now.


I appreciate what seem to be kind words saying my idea is good, but it 
didn't really answer the question nor address the issue I raised.


I am currently sorting out why this approach was taken and here's what I 
have so far, this is me trying to find the best here:


1) Possible that the socket buffer accounting needs to be done to keep 
TCP window open for send?  (Could this be forced via setsockopt(2) 
option instead)?

2) Lock order issues in the socket callback.
3) There is only a single socket callback func and arg (maybe we need more?)
4) Properly asserting backpressure and actual blocking in sendfile(2) 
becomes very difficult otherwise, meaning that if you don't have the 
complexity in socketbuffer, then you need to sort of implement this 
inside a private control block AND do accounting there.
5) This is a "cool feature" and maybe other things can make use of it 
eventually?  <- hoping this is more of a good thing as opposed to 
(sorry) kse.
6) Alllows one to mix async sendfile write WITH sync write and the 
correct thing happens?  Am I right in assuming that socketbuffers can 
wind up with mbufs as such:  M_NOTREADY, M_READY, M_NOTREADY, M_READY, 
M_NOTREADY, M_READY ?  If so that is pretty interesting and useful.


Again my proposal would be to use socket callback and callback arg would 
basically be something like:


socket_sendfile_cb_arg {
  struct mbuf *head;  /* list of mbufs queued */
}

When the callback is fired just pop off the front of the queue and put 
on the socketbuffer.


This however has the following drawbacks:
1) May have trouble if anyone else is using the sbcallback as well? 
aio?  (might need to allow multiple callbacks now).
2) Can't do M_NOTREADY, M_READY, M_NOTREADY, M_READY, M_NOTREADY, 
M_READY, basically write(2) can get in front of async sendfile.


I know you have put a lot of effort into this and these are just my 
semi-random thoughts on the issue, so I apologize if I'm making you 
repeat a lot of your thinking on the issue, I would just like to 
understand a bit better why this was done and if we really need to do it.


-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"


svn commit: r275345 - head/sys/kern

2014-11-30 Thread Justin T. Gibbs
Author: gibbs
Date: Sun Nov 30 19:32:00 2014
New Revision: 275345
URL: https://svnweb.freebsd.org/changeset/base/275345

Log:
  Remove trailing whitespace.

Modified:
  head/sys/kern/subr_taskqueue.c

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Sun Nov 30 18:51:10 2014
(r275344)
+++ head/sys/kern/subr_taskqueue.c  Sun Nov 30 19:32:00 2014
(r275345)
@@ -661,11 +661,11 @@ taskqueue_thread_enqueue(void *context)
 
 TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL,
 swi_add(NULL, "task queue", taskqueue_swi_run, NULL, SWI_TQ,
-INTR_MPSAFE, &taskqueue_ih)); 
+INTR_MPSAFE, &taskqueue_ih));
 
 TASKQUEUE_DEFINE(swi_giant, taskqueue_swi_giant_enqueue, NULL,
 swi_add(NULL, "Giant taskq", taskqueue_swi_giant_run,
-NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih)); 
+NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih));
 
 TASKQUEUE_DEFINE_THREAD(thread);
 
___
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: r275346 - head/bin/sh

2014-11-30 Thread Jilles Tjoelker
Author: jilles
Date: Sun Nov 30 20:12:47 2014
New Revision: 275346
URL: https://svnweb.freebsd.org/changeset/base/275346

Log:
  sh: Remove special case for '=' in set -x; always quote it in outqstr().
  
  I plan to make set -x output always printable using $'...'; avoiding quoting
  words containing '=' is not worth the extra complexity.

Modified:
  head/bin/sh/eval.c
  head/bin/sh/output.c

Modified: head/bin/sh/eval.c
==
--- head/bin/sh/eval.c  Sun Nov 30 19:32:00 2014(r275345)
+++ head/bin/sh/eval.c  Sun Nov 30 20:12:47 2014(r275346)
@@ -774,15 +774,7 @@ xtracecommand(struct arglist *varlist, s
for (sp = arglist->list ; sp ; sp = sp->next) {
if (sep != 0)
out2c(' ');
-   /* Disambiguate command looking like assignment. */
-   if (sp == arglist->list &&
-   strchr(sp->text, '=') != NULL &&
-   strchr(sp->text, '\'') == NULL) {
-   out2c('\'');
-   out2str(sp->text);
-   out2c('\'');
-   } else
-   out2qstr(sp->text);
+   out2qstr(sp->text);
sep = ' ';
}
out2c('\n');

Modified: head/bin/sh/output.c
==
--- head/bin/sh/output.cSun Nov 30 19:32:00 2014(r275345)
+++ head/bin/sh/output.cSun Nov 30 20:12:47 2014(r275346)
@@ -122,8 +122,7 @@ outqstr(const char *p, struct output *fi
outstr("''", file);
return;
}
-   /* Caller will handle '=' if necessary */
-   if (p[strcspn(p, "|&;<>()$`\\\"' \t\n*?[~#")] == '\0' ||
+   if (p[strcspn(p, "|&;<>()$`\\\"' \t\n*?[~#=")] == '\0' ||
strcmp(p, "[") == 0) {
outstr(p, file);
return;
___
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: r275347 - head/sys/vm

2014-11-30 Thread Konstantin Belousov
Author: kib
Date: Sun Nov 30 20:20:55 2014
New Revision: 275347
URL: https://svnweb.freebsd.org/changeset/base/275347

Log:
  Provide mutual exclusion between zone allocation/destruction and
  uma_reclaim().  Reclamation code must not see half-constructed or
  destructed zones.  Do this by bracing uma_zcreate() and uma_zdestroy()
  into a shared-locked sx, and take the sx exclusively in uma_reclaim().
  
  Usually zones are not created/destroyed during the system operation,
  but tmpfs mounts do cause zone operations and exposed the bug.
  
  Another solution could be to only expose a new keg on uma_kegs list
  after the corresponding zone is fully constructed, and similar
  treatment for the destruction.  But it probably requires more risky
  code rearrangement as well.
  
  Reported and tested by:   pho
  Discussed with:   avg
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Sun Nov 30 20:12:47 2014(r275346)
+++ head/sys/vm/uma_core.c  Sun Nov 30 20:20:55 2014(r275347)
@@ -146,6 +146,8 @@ static LIST_HEAD(,uma_slab) uma_boot_pag
 /* This mutex protects the boot time pages list */
 static struct mtx_padalign uma_boot_pages_mtx;
 
+static struct sx uma_drain_lock;
+
 /* Is the VM done starting up? */
 static int booted = 0;
 #defineUMA_STARTUP 1
@@ -1876,6 +1878,7 @@ uma_startup2(void)
 {
booted = UMA_STARTUP2;
bucket_enable();
+   sx_init(&uma_drain_lock, "umadrain");
 #ifdef UMA_DEBUG
printf("UMA startup2 complete.\n");
 #endif
@@ -1930,6 +1933,8 @@ uma_zcreate(const char *name, size_t siz
 
 {
struct uma_zctor_args args;
+   uma_zone_t res;
+   bool locked;
 
/* This stuff is essential for the zone ctor */
memset(&args, 0, sizeof(args));
@@ -1943,7 +1948,16 @@ uma_zcreate(const char *name, size_t siz
args.flags = flags;
args.keg = NULL;
 
-   return (zone_alloc_item(zones, &args, M_WAITOK));
+   if (booted < UMA_STARTUP2) {
+   locked = false;
+   } else {
+   sx_slock(&uma_drain_lock);
+   locked = true;
+   }
+   res = zone_alloc_item(zones, &args, M_WAITOK);
+   if (locked)
+   sx_sunlock(&uma_drain_lock);
+   return (res);
 }
 
 /* See uma.h */
@@ -1953,6 +1967,8 @@ uma_zsecond_create(char *name, uma_ctor 
 {
struct uma_zctor_args args;
uma_keg_t keg;
+   uma_zone_t res;
+   bool locked;
 
keg = zone_first_keg(master);
memset(&args, 0, sizeof(args));
@@ -1966,8 +1982,17 @@ uma_zsecond_create(char *name, uma_ctor 
args.flags = keg->uk_flags | UMA_ZONE_SECONDARY;
args.keg = keg;
 
+   if (booted < UMA_STARTUP2) {
+   locked = false;
+   } else {
+   sx_slock(&uma_drain_lock);
+   locked = true;
+   }
/* XXX Attaches only one keg of potentially many. */
-   return (zone_alloc_item(zones, &args, M_WAITOK));
+   res = zone_alloc_item(zones, &args, M_WAITOK);
+   if (locked)
+   sx_sunlock(&uma_drain_lock);
+   return (res);
 }
 
 /* See uma.h */
@@ -2085,7 +2110,9 @@ void
 uma_zdestroy(uma_zone_t zone)
 {
 
+   sx_slock(&uma_drain_lock);
zone_free_item(zones, zone, NULL, SKIP_NONE);
+   sx_sunlock(&uma_drain_lock);
 }
 
 /* See uma.h */
@@ -3205,6 +3232,7 @@ uma_reclaim(void)
 #ifdef UMA_DEBUG
printf("UMA: vm asked us to release pages!\n");
 #endif
+   sx_xlock(&uma_drain_lock);
bucket_enable();
zone_foreach(zone_drain);
if (vm_page_count_min()) {
@@ -3219,6 +3247,7 @@ uma_reclaim(void)
zone_drain(slabzone);
zone_drain(slabrefzone);
bucket_zone_drain();
+   sx_xunlock(&uma_drain_lock);
 }
 
 /* See uma.h */
___
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: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Robert Watson


Hi Gleb:

Randall had mentioned these in-flight changes to me, and I can see how these 
might substantially reduce latency in usefully filling the TCP pipe when the 
window is opening rapidly (among other things).  As with others, I'm a bit 
cautious about further increases in asynchrony within mbufs -- but think that 
the design choice to limit asynchronous access to mbuf data, rather than 
metadata, is a sensible one.  I am especially pleased that the near-invariant 
that access to mbuf fields of mbufs owned by the socket buffer occurs only 
with the socket-buffer mutex held (note that there are one or two known nasty 
exceptions to this rule -- e.g., in MSG_PEEK that it is worth being aware of). 
I tend to agree with the view that socket upcalls are not the right mechanism 
to use here, as those both serve another function, and can run into locking 
difficulties due to their calling contexts (I am aware of some potential 
outstanding issues here for existing upcall consumers, in fact).


I do have a substantial worry about 'compatibility' -- which is to say, the 
risk of not only running into trouble with more obscure bits of the network 
stack, but also third-party extensions in local code bases that may make 
previously reasonable assumptions about mbuf behaviour.  One way to bound the 
scope of that issue is to ensure, very firmly, that these flags can never leak 
out of the socket-buffer/protocol components that explicitly support it.  I 
think I might feel more comfortable if these were globally visible mbuf flags, 
which we could assert never passed through certain types of interfaces -- 
e.g., made it to ip_output(); it might also be useful to assert that these 
flags are never set when an mbuf is freed back to the mbuf allocator.  I also 
worry that leakage of M_PROTO flags from other components could lead to quite 
hard-to-debug problems, and so it would be good to ensure that subsystems that 
will use these flags assert that they are never set as they arrive in the 
subsystem (e.g., tcp_input()).  I'm not sure how we're doing on mbuf flags, 
but we might soon find we require another field in struct mbuf for them. 
Anywhere we can use assertions to help us with this kind of problem, I think 
it's a big win.


Although these changes have clearly been refined over an extended period, and 
were developed in a Subversion project branch, I think it would have been nice 
to be able to have more "Reviewed by:" entries in the commit message.  I've 
been really happy to see a gradual change over the last few years towards a 
large percentage of network-stack commits having that tag, and think it's 
worth pursuing this pretty vigorously.  A phabricator round to networks@ (or 
whatever the recently created alias/group was) would not go amiss in the 
future.  While everyone is busy, creating an environment of mutual review 
(I'll scratch your back if you scratch mine) is very valuable -- especially 
for subsystems as subtle as the network stack.  Looking back in the e-mail 
archives, I see that you did post a phabricator link to an earlier version of 
this work in May -- I suspect more armtwisting was required, but would in 
general be worth it.  (I've been very tuned out the last few months due to 
ongoing things outside of the FreeBSD world -- but please do feel free to ping 
me if there's a critical patch like this in flight where I can at least lend a 
hand with a quick read.)


Although not an immediate issue, it may be worth looking at what happens to 
performance with these changes in the presence of lower-latency storage 
devices, such as nvme.  Where there is substantial latency due to a spinning 
disk, or even a congested SATA-attached SSD, it's easy to see how these 
changes would improve performance.  I do worry that with lower latency, you 
might see increases in lock contention -- or at least shifts, which would be 
worth understanding.  I'm not sure if your testing environment is suitable for 
that (nor, I think, the FreeBSD Project's netperf cluster -- we've just 
received our first nvme device at the Computer Laboratory for network-stack 
performance work .. and it will be interesting to see how that plays out. 
With <30us RTT on I/O, multiqueue support, etc, the dynamics are changing 
quite a lot.)  The concern would be that we might now be doing many more 
socket-buffer locking/wakeup-style events than before, and that if they are 
paced too quickly the threads will bump into each other.


FWIW, I think it would be worth pondering adding an aio_sendfile(), if only 
because it would make it easier to expose this kernel asynchrony to userspace 
concurrency frameworks like libdispatch.


Robert

On Sun, 30 Nov 2014, Gleb Smirnoff wrote:


Author: glebius
Date: Sun Nov 30 12:52:33 2014
New Revision: 275326
URL: https://svnweb.freebsd.org/changeset/base/275326

Log:
 Merge from projects/sendfile:

 o Introduce a notion of "not ready" mbufs in socket buffers.  These
 mbufs are now being popu

Re: svn commit: r275326 - in head: sys/dev/cxgbe/tom sys/kern sys/netinet sys/sys usr.bin/bluetooth/btsockstat usr.bin/netstat usr.bin/systat

2014-11-30 Thread Gleb Smirnoff
  Robert,

  thanks for longer reply!

On Sun, Nov 30, 2014 at 09:33:50PM +, Robert Watson wrote:
R> I do have a substantial worry about 'compatibility' -- which is to say, the 
R> risk of not only running into trouble with more obscure bits of the network 
R> stack, but also third-party extensions in local code bases that may make 
R> previously reasonable assumptions about mbuf behaviour.

>From viewpoint of outer code that deals with socket buffer code via APIs like
sbappendstream(), sbdrop(), etc, the change is backward compatible. We
still accept mbufs as we did before. Changes are applied only when we are
explicitly called with PRUS_NOTREADY.

Those who would suffer incompatibilities, are those who touch struct sockbuf
itself, like SCTP does. Well, this isn't a right thing to do! Of course, the
BSD stack didn't provide API for sockbufs, and our current stack doesn't
provide an excellent API. In a very perfect case struct sockbuf should be
private to uipc_sockbuf.c. We are very far from that, but we should head
into that direction.

R> One way to bound the 
R> scope of that issue is to ensure, very firmly, that these flags can never 
leak 
R> out of the socket-buffer/protocol components that explicitly support it.  I 
R> think I might feel more comfortable if these were globally visible mbuf 
flags, 
R> which we could assert never passed through certain types of interfaces -- 
R> e.g., made it to ip_output(); it might also be useful to assert that these 
R> flags are never set when an mbuf is freed back to the mbuf allocator.  I 
also 
R> worry that leakage of M_PROTO flags from other components could lead to 
quite 
R> hard-to-debug problems, and so it would be good to ensure that subsystems 
that 
R> will use these flags assert that they are never set as they arrive in the 
R> subsystem (e.g., tcp_input()).  I'm not sure how we're doing on mbuf flags, 
R> but we might soon find we require another field in struct mbuf for them. 
R> Anywhere we can use assertions to help us with this kind of problem, I think 
R> it's a big win.

Andre did a lot on asserting that M_PROTOs do not leak between protocol
boundaries and subsystems. Probably, we can add more there. I don't like
the idea of declaring these flags at global scope, although we used that
during debugging. We actually should emphasize that they are local and hide
them.

The assertions can and should use M_PROTO defines. If we use M_NOTREADY
define in assertions outside socket buffer code, that could be very misleading
once such assertion fires. A developer would seek for the bug in socket buffer
code, while a culprit could be any other code that uses M_PROTO1.

If we move M_NOTREADY out of the M_PROTO* pool of bits, then we can very
soon run out of bits.

R> Although these changes have clearly been refined over an extended period, 
and 
R> were developed in a Subversion project branch, I think it would have been 
nice 
R> to be able to have more "Reviewed by:" entries in the commit message.  I've 
R> been really happy to see a gradual change over the last few years towards a 
R> large percentage of network-stack commits having that tag, and think it's 
R> worth pursuing this pretty vigorously.  A phabricator round to networks@ (or 
R> whatever the recently created alias/group was) would not go amiss in the 
R> future.  While everyone is busy, creating an environment of mutual review 
R> (I'll scratch your back if you scratch mine) is very valuable -- especially 
R> for subsystems as subtle as the network stack.  Looking back in the e-mail 
R> archives, I see that you did post a phabricator link to an earlier version 
of 
R> this work in May -- I suspect more armtwisting was required, but would in 
R> general be worth it.  (I've been very tuned out the last few months due to 
R> ongoing things outside of the FreeBSD world -- but please do feel free to 
ping 
R> me if there's a critical patch like this in flight where I can at least lend 
a 
R> hand with a quick read.)

Yes, I'm very sorry for not forcing people enough, but please understand that
guilt is mutual there between me and potential reviewers. I didn't hide the
upcoming patch under a carpet. I posted it several times.

If you can do a post commit review, that would be much appreciated. I've split
the changes into as small self-contained chunks as possible to make that easier.

R> Although not an immediate issue, it may be worth looking at what happens to 
R> performance with these changes in the presence of lower-latency storage 
R> devices, such as nvme.  Where there is substantial latency due to a spinning 
R> disk, or even a congested SATA-attached SSD, it's easy to see how these 
R> changes would improve performance.  I do worry that with lower latency, you 
R> might see increases in lock contention -- or at least shifts, which would be 
R> worth understanding.  I'm not sure if your testing environment is suitable 
for 
R> that (nor, I think, the FreeBSD Project's netperf cluster -