vr(4) TX interrupt reduction

2013-01-14 Thread Darren Tucker
Hi all.

This patch below reduces the number of interrupts on the transmit side
of vr(4).  Currently we set the TX competion interrupt bit on each
outbound packet.  This patch changes it to only set the interrupt bit on
the last packet enqueued.  (One thing of note is that the interrupt bit
is set on the first of potentially several TX descriptors for a packet
whereas currently it's the last.  I'm not sure if this matters, but if
it does I can change it).

On my ALIX, it increase the IP routing throughput from 80Mbit/s to
85Mbit/s while reducing the interrupt CPU usage from 99% to 80%.

Testing on any VIA Rhine chips would be appreciated (especially ones
that are not 6105M like my ALIX).

(Help/suggestions from jsing@ chris@ mikeb@ dlg@...)

Thanks.

Index: dev/pci/if_vr.c
===
RCS file: /cvs/src/sys/dev/pci/if_vr.c,v
retrieving revision 1.121
diff -u -p -r1.121 if_vr.c
--- dev/pci/if_vr.c 1 Dec 2012 09:55:03 -   1.121
+++ dev/pci/if_vr.c 14 Jan 2013 10:50:58 -
@@ -1254,8 +1254,8 @@ vr_encap(struct vr_softc *sc, struct vr_
sc-vr_cdata.vr_tx_cnt++;
}
 
-   /* Set EOP on the last desciptor */
-   f-vr_ctl |= htole32(VR_TXCTL_LASTFRAG | VR_TXCTL_FINT);
+   /* Set EOP on the last descriptor */
+   f-vr_ctl |= htole32(VR_TXCTL_LASTFRAG);
 
return (0);
 }
@@ -1265,6 +1265,13 @@ vr_encap(struct vr_softc *sc, struct vr_
  * to the mbuf data regions directly in the transmit lists. We also save a
  * copy of the pointers since the transmit list fragment pointers are
  * physical addresses.
+ *
+ * Notes:
+ * We only set ownership bit on first descriptor for a each packet.
+ * We'll only want an interrupt for a given packet if either vr_encap fails
+ * (ie the descriptor ring is full) or if the interface input queue is
+ * empty, and we need to set the interrupt bit before setting the owner bit
+ * to turn it over to the hardware.
  */
 
 void
@@ -1272,7 +1279,7 @@ vr_start(struct ifnet *ifp)
 {
struct vr_softc *sc;
struct mbuf *m_head;
-   struct vr_chain *cur_tx, *head_tx;
+   struct vr_chain *cur_tx, *head_tx, *prev_tx = NULL;
 
sc = ifp-if_softc;
 
@@ -1298,9 +1305,9 @@ vr_start(struct ifnet *ifp)
IF_PREPEND(ifp-if_snd, m_head);
break;
}
-
-   /* Only set ownership bit on first descriptor */
-   head_tx-vr_ptr-vr_status |= htole32(VR_TXSTAT_OWN);
+   /* successfully enqueued new packet, we're done with previous */
+   if (prev_tx != NULL)
+   prev_tx-vr_ptr-vr_status |= htole32(VR_TXSTAT_OWN);
 
 #if NBPFILTER  0
/*
@@ -1312,7 +1319,13 @@ vr_start(struct ifnet *ifp)
BPF_DIRECTION_OUT);
 #endif
cur_tx = cur_tx-vr_nextdesc;
+   prev_tx = head_tx;
+   }
+   if (prev_tx != NULL) {
+   prev_tx-vr_ptr-vr_ctl |= htole32(VR_TXCTL_FINT);
+   prev_tx-vr_ptr-vr_status |= htole32(VR_TXSTAT_OWN);
}
+
if (sc-vr_cdata.vr_tx_cnt != 0) {
sc-vr_cdata.vr_tx_prod = cur_tx;
 
-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.



PATCH: Make top(1) switches the real switches

2013-01-14 Thread Vadim Zhukov
As it's already known, top(1) receive options from three places:
  * from TOP enviornment variable;
  * from command line;
  * from user input (in interactive mode).

Some options are actually simple switches, namely -1CHISu. But handling
of those switches when specified in TOP or on the command line differs:
some of them make corresponding options always on, and some switch the
values back and forth. This patch makes all such options real switches.
I.e., if you have TOP=-H -1 -s 2 and want to acquire non-threaded output,
you don't have to use monsters such as ``TOP=-1 -s 2 top''.

Any opinions/okays?


Index: top.c
===
RCS file: /cvs/src/usr.bin/top/top.c,v
retrieving revision 1.79
diff -u -p -r1.79 top.c
--- top.c   8 Jun 2012 13:41:16 -   1.79
+++ top.c   14 Jan 2013 11:38:44 -
@@ -139,10 +139,10 @@ parseargs(int ac, char **av)
while ((i = getopt(ac, av, 1SHICbinqus:d:p:U:o:g:)) != -1) {
switch (i) {
case '1':
-   combine_cpus = 1;
+   combine_cpus = !combine_cpus;
break;
case 'C':
-   show_args = Yes;
+   show_args = !show_args;
break;
case 'u':   /* toggle uid/username display */
do_unames = !do_unames;
@@ -182,8 +182,8 @@ parseargs(int ac, char **av)
break;
 
case 'H':   /* show threads */
-   ps.threads = Yes;
-   old_threads = Yes;
+   ps.threads = !ps.threads;
+   old_threads = ps.threads;
break;
 
case 'I':   /* show idle processes */



Soekris net6501 GPIO LED support

2013-01-14 Thread Matt Dainty
Attached is a patch that adds soekris(4) which provides access to the
GPIO and LEDs as implemented by the onboard Xilinx FPGA on the Soekris
net6501. The driver provides two GPIO buses; one for the 16 real GPIO
pins exposed on the board, and another which has the LEDs coerced into
the GPIO framework as output-only pins.

I kept them separate to prevent confusion and make the code slightly
simpler, if it's preferred to have just one GPIO bus let me know.

It's enabled in the kernel config with:

soekris0 at isa? port 0x680
gpio*at soekris?

The driver cannot be enabled by default as there's no reliable way to
detect the hardware, it's just a handful of I/O ports at a known
address, (GPIO isn't enabled by default in GENERIC so a kernel compile
is required regardless).

This is what is shown at boot:

soekris0 at isa0 port 0x680/32
gpio0 at soekris0: 16 pins
gpio1 at soekris0: 2 pins

I then have the following in /etc/rc.securelevel:

gpioctl -q gpio1 0 set out error_led
gpioctl -q gpio1 1 set out ready_led

If this driver is acceptable I can send a further patch with man pages.
Tested on a Soekris net6501 running amd64, LEDs work and I've put
simple LED and pushbutton circuits on the GPIO pins.

Comments?

Matt

--- /dev/null   Tue Jan  8 21:22:57 2013
+++ sys/dev/isa/soekris.c   Tue Jan  8 21:17:02 2013
@@ -0,0 +1,235 @@
+/* $OpenBSD$ */
+
+/*
+ * Copyright (c) 2013 Matt Dainty m...@bodgit-n-scarper.com
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Soekris net6501 GPIO and LEDs as implemented by the onboard Xilinx FPGA 
+ */
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/device.h
+#include sys/gpio.h
+
+#include machine/bus.h
+#include machine/intr.h
+
+#include dev/isa/isavar.h
+
+#include dev/gpio/gpiovar.h
+
+#defineSOEKRIS_BASE0x680   /* Base address of FPGA I/O */
+#defineSOEKRIS_IOSIZE  32  /* I/O region size */
+
+#defineSOEKRIS_NPINS   16  /* Number of Pins */
+#defineSOEKRIS_GPIO_INPUT  0x000   /* Current state of pins */
+#defineSOEKRIS_GPIO_OUTPUT 0x004   /* Set state of output pins */
+#defineSOEKRIS_GPIO_RESET  0x008   /* Reset output pins */
+#defineSOEKRIS_GPIO_SET0x00c   /* Set output pins */
+#defineSOEKRIS_GPIO_DIR0x010   /* Direction, set for output */
+
+#defineSOEKRIS_NLEDS   2   /* Number of LEDs */
+#defineSOEKRIS_LED_ERROR   0x01c   /* Offset to error LED */
+#defineSOEKRIS_LED_READY   0x01d   /* Offset to ready LED */
+
+const u_int soekris_led_offset[SOEKRIS_NLEDS] = {
+   SOEKRIS_LED_ERROR, SOEKRIS_LED_READY
+};
+
+struct soekris_softc {
+   struct devicesc_dev;
+
+   bus_space_tag_t  sc_iot;
+   bus_space_handle_t   sc_ioh;
+
+   struct gpio_chipset_tag  sc_gpio_gc;
+   gpio_pin_t   sc_gpio_pins[SOEKRIS_NPINS];
+
+   /* Fake GPIO device for the LEDs */
+   struct gpio_chipset_tag  sc_led_gc;
+   gpio_pin_t   sc_led_pins[SOEKRIS_NLEDS];
+};
+
+int soekris_match(struct device *, void *, void *);
+voidsoekris_attach(struct device *, struct device *, void *);
+int soekris_gpio_read(void *, int);
+voidsoekris_gpio_write(void *, int, int);
+voidsoekris_gpio_ctl(void *, int, int);
+int soekris_led_read(void *, int);
+voidsoekris_led_write(void *, int, int);
+voidsoekris_led_ctl(void *, int, int);
+
+struct cfattach soekris_ca = {
+   sizeof(struct soekris_softc), soekris_match, soekris_attach
+};
+
+struct cfdriver soekris_cd = {
+   NULL, soekris, DV_DULL
+};
+
+int
+soekris_match(struct device *parent, void *match, void *aux)
+{
+   struct isa_attach_args *ia = aux;
+   bus_space_handle_t ioh;
+
+   /* Need some sort of heuristic to match the Soekris net6501 */
+
+   if (ia-ia_iobase != SOEKRIS_BASE || bus_space_map(ia-ia_iot,
+   ia-ia_iobase, SOEKRIS_IOSIZE, 0, ioh) != 0)
+   return (0);
+
+   bus_space_unmap(ia-ia_iot, ioh, SOEKRIS_IOSIZE);
+   ia-ia_iosize = SOEKRIS_IOSIZE;
+   ia-ipa_nio = 1;
+   ia-ipa_nmem = 0;
+   ia-ipa_nirq = 0;
+   ia-ipa_ndrq = 0;
+
+   return (1);
+}
+
+void

Re: vr(4) TX interrupt reduction

2013-01-14 Thread Michał Markowski
2013/1/14 Darren Tucker dtuc...@zip.com.au:
 Testing on any VIA Rhine chips would be appreciated (especially ones
 that are not 6105M like my ALIX).

Hi, nothing conclusive on VIA VT6107 (dmesg: vr0 at pci0 dev 10
function 0 VIA RhineII-2 rev 0x8d: irq 15, address
00:16:35:06:af:eb).

current kernel: 9835.56 int/s, 84.0 Mbps (100 s avg)
with your patch: 9857.85 int/s, 84.0 Mbps

No problems observed, though.

-- 
Michał Markowski



Re: [miniroot/install.sub] skip x* sets if do not expect to run X.

2013-01-14 Thread Chris Cappuccio
Devin Ceartas [de...@nacredata.com] wrote:
 There are cases where you want to compile some port not directly related to X 
 but the dependency is missing if you didn't load the X sets. I don't remember 
 the particular, but I know this has happened to me. 
 

Several ports depend on libraries that are only included with xbase, like 
freetype. The decision to work this way was made long ago for simplicity.



mg: don't spin when stdin is lost

2013-01-14 Thread Florian Obser
this can be tested like this:
EDITOR=mg cvs commit
kill cvs
- mg spins with 100% cpu in ttgetc

While there prevent an unterminated recursion in panic (via ttclose).
I'm not particularly happy with the errorhandling in ttgetc, but this
is the least intrusive change.

comments, oks?

diff --git ttyio.c ttyio.c
index 228a370..5b9021f 100644
--- ttyio.c
+++ ttyio.c
@@ -173,7 +173,9 @@ ttgetc(void)
redraw(0, 0);
winch_flag = 0;
}
-   } else if (ret == 1)
+   } else if (ret == -1  errno == EIO)
+   panic(lost stdin);
+   else if (ret == 1)
break;
} while (1);
return ((int) c)  0xFF;
@@ -196,6 +198,12 @@ charswaiting(void)
 void
 panic(char *s)
 {
+   static int panicking = 0;
+
+   if (panicking)
+   return;
+   else
+   panicking = 1;
ttclose();
(void) fputs(panic: , stderr);
(void) fputs(s, stderr);

-- 
I'm not entirely sure you are real.



Re: Soekris net6501 GPIO LED support

2013-01-14 Thread Janne Johansson
2013/1/14 Matt Dainty m...@bodgit-n-scarper.com:
 Attached is a patch that adds soekris(4) which provides access to the
 GPIO and LEDs as implemented by the onboard Xilinx FPGA on the Soekris

Dunno if I am out of my league here, but:

 +void
 +soekris_gpio_write(void *arg, int pin, int value)
 +{
 +   struct soekris_softc *sc = arg;
 +   u_int16_t data;
 +
 +   data = bus_space_read_2(sc-sc_iot, sc-sc_ioh, SOEKRIS_GPIO_INPUT);
 +
 +   if (value == GPIO_PIN_LOW)
 +   data = ~(1  pin);
 +   else if (value == GPIO_PIN_HIGH)
 +   data |= (1  pin);
 +
 +   bus_space_write_2(sc-sc_iot, sc-sc_ioh, SOEKRIS_GPIO_OUTPUT, data);
 +}


 +void
 +soekris_led_write(void *arg, int pin, int value)
 +{
 +   struct soekris_softc *sc = arg;
 +
 +   bus_space_write_1(sc-sc_iot, sc-sc_ioh, soekris_led_offset[pin],
 +   value);

These two (and the read function) don't really seem to prevent me from
writing or reading pin/led 23498324 and have it wander far off into
memory. Then again, that protection may be at the ioctl level, making
my whole comment moot, but at least bus_space_write_N() doesn't check
it afterwards.

-- 
May the most significant bit of your life be positive.



Re: vr(4) TX interrupt reduction

2013-01-14 Thread Chris Cappuccio
Micha?? Markowski [markows...@gmail.com] wrote:
 2013/1/14 Darren Tucker dtuc...@zip.com.au:
  Testing on any VIA Rhine chips would be appreciated (especially ones
  that are not 6105M like my ALIX).
 
 Hi, nothing conclusive on VIA VT6107 (dmesg: vr0 at pci0 dev 10
 function 0 VIA RhineII-2 rev 0x8d: irq 15, address
 00:16:35:06:af:eb).
 
 current kernel: 9835.56 int/s, 84.0 Mbps (100 s avg)
 with your patch: 9857.85 int/s, 84.0 Mbps
 
 No problems observed, though.
 

This will only affect TX direction interrupts. Can you try and generate a stream
of UDP traffic at full rate with a program like iperf to test just TX?



socket splicing maximum signaling

2013-01-14 Thread Alexander Bluhm
Hi,

Some years ago reyk@ mentioned that the current socket splicing
semantics is suboptimal.  When used with persistent http connections,
the kernel does not inform user land when the maximum splicing
lenght has been reached.  The file descriptor does not get active
when the last byte within the limit has been spliced, but only after
additional data has arrived.

When mikeb@ implemented idle timeouts, he had the idea to pass an
ETIMEDOUT error to user land.  This creates an event on the socket
that can be checked with select(2).  Similary this diff passes an
EFBIG error when the maximum splicing length is reached.  So the
kernel passes control to user land immediately.  This can be used
to log the end of an http request.

reyk@, mikeb@: What do you think about this idea?

bluhm

diff --git a/kern/uipc_socket.c b/kern/uipc_socket.c
index bc4f3d1..20f79f2 100644
--- a/kern/uipc_socket.c
+++ b/kern/uipc_socket.c
@@ -1173,7 +1173,8 @@ somove(struct socket *so, int wait)
error = EPIPE;
goto release;
}
-   if (sosp-so_error  sosp-so_error != ETIMEDOUT) {
+   if (sosp-so_error  sosp-so_error != ETIMEDOUT 
+   sosp-so_error != EFBIG) {
error = sosp-so_error;
goto release;
}
@@ -1388,6 +1389,8 @@ somove(struct socket *so, int wait)
 
  release:
sosp-so_state = ~SS_ISSENDING;
+   if (!error  maxreached  so-so_splicemax == so-so_splicelen)
+   error = EFBIG;
if (error)
so-so_error = error;
if (((so-so_state  SS_CANTRCVMORE)  so-so_rcv.sb_cc == 0) ||



Detect on-die temp sensor for Atom E6xx on amd64

2013-01-14 Thread Matt Dainty
The following patch fixes the the detection of the on-die temp sensor
for Atom E6xx CPUs (and possibly other Atom CPUs). The code was only
matching processors where the model began with Intel but this Atom
CPU model begins with Genuine Intel so I've updated the logic to
match.

Now I get:

# sysctl hw
hw.machine=amd64
hw.model=Genuine Intel(R) CPU @ 1.60GHz
hw.ncpu=2
hw.byteorder=1234
hw.pagesize=4096
hw.disknames=sd0:937db626fa67a9f0
hw.diskcount=1
hw.sensors.cpu0.temp0=66.00 degC
hw.sensors.cpu1.temp0=66.00 degC
hw.cpuspeed=600
hw.setperf=0
hw.physmem=2146304000
hw.usermem=2146287616
hw.ncpufound=2
hw.allowpowerdown=1

This only seems to affect the amd64 port, I can't find similar logic in
the i386 port.

Matt

--- sys/arch/amd64/amd64/identcpu.c.orig2013-01-14 22:23:43.0 
+
+++ sys/arch/amd64/amd64/identcpu.c 2013-01-14 22:33:21.0 +
@@ -506,7 +506,8 @@
if (ci-ci_feature_sefflags  SEFF0EBX_SMAP)
replacesmap();
}
-   if (!strncmp(mycpu_model, Intel, 5)) {
+   if (!strncmp(mycpu_model, Intel, 5) ||
+   !strncmp(mycpu_model, Genuine Intel, 13)) {
u_int32_t cflushsz;
 
CPUID(0x01, dummy, cflushsz, dummy, dummy);



Re: vr(4) TX interrupt reduction

2013-01-14 Thread Stuart Henderson
On 2013/01/14 14:03, Chris Cappuccio wrote:
 Micha?? Markowski [markows...@gmail.com] wrote:
  2013/1/14 Darren Tucker dtuc...@zip.com.au:
   Testing on any VIA Rhine chips would be appreciated (especially ones
   that are not 6105M like my ALIX).
  
  Hi, nothing conclusive on VIA VT6107 (dmesg: vr0 at pci0 dev 10
  function 0 VIA RhineII-2 rev 0x8d: irq 15, address
  00:16:35:06:af:eb).
  
  current kernel: 9835.56 int/s, 84.0 Mbps (100 s avg)
  with your patch: 9857.85 int/s, 84.0 Mbps
  
  No problems observed, though.
  
 
 This will only affect TX direction interrupts. Can you try and generate a 
 stream
 of UDP traffic at full rate with a program like iperf to test just TX?
 

source: tcpbench -u -B packetsize somehost
sink: tcpbench -s -u



Re: relayd uses more socket splicing

2013-01-14 Thread Alexander Bluhm
Hi,

Here is an updated relayd socket splicing diff that uses the new
EFBIG feature of maximum splicing lenght.  This way relayctl show
sessions displays an updated idle counter immediately after the
whole http content has been transferred.

bluhm

Index: usr.sbin/relayd/relay.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/relayd/relay.c,v
retrieving revision 1.160
diff -u -p -r1.160 relay.c
--- usr.sbin/relayd/relay.c 18 Dec 2012 15:58:25 -  1.160
+++ usr.sbin/relayd/relay.c 14 Jan 2013 21:36:44 -
@@ -70,9 +70,6 @@ void   relay_input(struct rsession *);
 
 u_int32_t   relay_hash_addr(struct sockaddr_storage *, u_int32_t);
 
-int relay_splice(struct ctl_relay_event *);
-int relay_splicelen(struct ctl_relay_event *);
-
 SSL_CTX*relay_ssl_ctx_create(struct relay *);
 voidrelay_ssl_transaction(struct rsession *,
struct ctl_relay_event *);
@@ -643,6 +640,7 @@ relay_connected(int fd, short sig, void 
case RELAY_PROTO_HTTP:
/* Check the servers's HTTP response */
if (!RB_EMPTY(rlay-rl_proto-response_tree)) {
+   con-se_out.toread = TOREAD_HTTP_HEADER;
outrd = relay_read_http;
if ((con-se_out.nodes = calloc(proto-response_nodes,
sizeof(u_int8_t))) == NULL) {
@@ -699,6 +697,7 @@ relay_input(struct rsession *con)
/* Check the client's HTTP request */
if (!RB_EMPTY(rlay-rl_proto-request_tree) ||
proto-lateconnect) {
+   con-se_in.toread = TOREAD_HTTP_HEADER;
inrd = relay_read_http;
if ((con-se_in.nodes = calloc(proto-request_nodes,
sizeof(u_int8_t))) == NULL) {
@@ -741,10 +740,19 @@ relay_write(struct bufferevent *bev, voi
 {
struct ctl_relay_event  *cre = (struct ctl_relay_event *)arg;
struct rsession *con = cre-con;
+
if (gettimeofday(con-se_tv_last, NULL) == -1)
-   con-se_done = 1;
+   goto fail;
if (con-se_done)
-   relay_close(con, last write (done));
+   goto done;
+   if (relay_splice(cre-dst) == -1)
+   goto fail;
+   return;
+ done:
+   relay_close(con, last write (done));
+   return;
+ fail:
+   relay_close(con, strerror(errno));
 }
 
 void
@@ -822,11 +830,31 @@ relay_splice(struct ctl_relay_event *cre
(proto-tcpflags  TCPFLAG_NSPLICE))
return (0);
 
-   if (cre-bev-readcb != relay_read)
+   if (cre-splicelen = 0)
return (0);
 
+   /* still not connected */
+   if (cre-bev == NULL || cre-dst-bev == NULL)
+   return (0);
+
+   if (! (cre-toread == TOREAD_UNLIMITED || cre-toread  0)) {
+   DPRINTF(%s: session %d: splice dir %d, nothing to read %lld,
+   __func__, con-se_id, cre-dir, cre-toread);
+   return (0);
+   }
+
+   /* do not splice before buffers have not been completely fushed */
+   if (EVBUFFER_LENGTH(cre-bev-input) ||
+   EVBUFFER_LENGTH(cre-dst-bev-output)) {
+   DPRINTF(%s: session %d: splice dir %d, dirty buffer,
+   __func__, con-se_id, cre-dir);
+   bufferevent_disable(cre-bev, EV_READ);
+   return (2);
+   }
+
bzero(sp, sizeof(sp));
sp.sp_fd = cre-dst-s;
+   sp.sp_max = cre-toread  0 ? cre-toread : 0;
sp.sp_idle = rlay-rl_conf.timeout;
if (setsockopt(cre-s, SOL_SOCKET, SO_SPLICE, sp, sizeof(sp)) == -1) {
log_debug(%s: session %d: splice dir %d failed: %s,
@@ -834,8 +862,11 @@ relay_splice(struct ctl_relay_event *cre
return (-1);
}
cre-splicelen = 0;
-   DPRINTF(%s: session %d: splice dir %d successful,
-   __func__, con-se_id, cre-dir);
+   bufferevent_enable(cre-bev, EV_READ);
+
+   DPRINTF(%s: session %d: splice dir %d, maximum %lld, successful,
+   __func__, con-se_id, cre-dir, cre-toread);
+
return (1);
 }
 
@@ -846,19 +877,42 @@ relay_splicelen(struct ctl_relay_event *
off_tlen;
socklen_toptlen;
 
+   if (cre-splicelen  0)
+   return (0);
+
optlen = sizeof(len);
if (getsockopt(cre-s, SOL_SOCKET, SO_SPLICE, len, optlen) == -1) {
log_debug(%s: session %d: splice dir %d get length failed: %s,
__func__, con-se_id, cre-dir, strerror(errno));
return (-1);
}
+
+   DPRINTF(%s: session %d: splice dir %d, length %lld,
+   __func__, con-se_id, cre-dir, len);
+
if (len  cre-splicelen) {
+   if (gettimeofday(con-se_tv_last, NULL) == -1)
+ 

Re: vr(4) TX interrupt reduction

2013-01-14 Thread Michał Markowski
2013/1/14 Chris Cappuccio ch...@nmedia.net:
 This will only affect TX direction interrupts. Can you try and generate a 
 stream
 of UDP traffic at full rate with a program like iperf to test just TX?

Those numbers are from `iperf -c a -t 100 -i 10` on vr machine.
Iperf man page says: user must establish both a server (to discard
traffic) and a client (to generate traffic) so yes, it's TX.

When I try UDP test with -b higher than 87m:

$ iperf -c a -u -b 100m -t 100 -i 10

Client connecting to a, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 9.00 KByte (default)

[  3] local 192.168.1.192 port 25889 connected with 192.168.1.50 port 5001
zsh: segmentation fault (core dumped)  iperf -c a -u -b 100m -t 100 -i 10
$ gdb /usr/local/bin/iperf iperf.core
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type show copying to see the conditions.
There is absolutely no warranty for GDB.  Type show warranty for details.
This GDB was configured as i386-unknown-openbsd5.2...(no debugging
symbols found)

Core was generated by `iperf'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libpthread.so.17.0...done.
Loaded symbols for /usr/lib/libpthread.so.17.0
Reading symbols from /usr/lib/libstdc++.so.55.0...done.
Loaded symbols for /usr/lib/libstdc++.so.55.0
Reading symbols from /usr/lib/libm.so.7.1...done.
Loaded symbols for /usr/lib/libm.so.7.1
Symbols already loaded for /usr/lib/libpthread.so.17.0
Reading symbols from /usr/lib/libc.so.66.1...done.
Loaded symbols for /usr/lib/libc.so.66.1
Reading symbols from /usr/libexec/ld.so...done.
Loaded symbols for /usr/libexec/ld.so
#0  strlen (str=0x2 Address 0x2 out of bounds) at
/usr/src/lib/libc/string/strlen.c:43
43  for (s = str; *s; ++s)
(gdb)


-- 
Michał Markowski



Re: vr(4) TX interrupt reduction

2013-01-14 Thread Chris Cappuccio
Micha?? Markowski [markows...@gmail.com] wrote:
 2013/1/14 Chris Cappuccio ch...@nmedia.net:
  This will only affect TX direction interrupts. Can you try and generate a 
  stream
  of UDP traffic at full rate with a program like iperf to test just TX?
 
 Those numbers are from `iperf -c a -t 100 -i 10` on vr machine.
 Iperf man page says: user must establish both a server (to discard
 traffic) and a client (to generate traffic) so yes, it's TX.
 

Well your numbers clearly show almost no difference. But TCP might not
be the best way to test due to the regular ack reply.

 When I try UDP test with -b higher than 87m:
 

Clearly, the current ports iperf is buggy. Stuart has the ticket on
tcpbench, in, uhh, udpbench mode.



Re: vr(4) TX interrupt reduction

2013-01-14 Thread Darren Tucker
On Mon, Jan 14, 2013 at 10:10:55PM +1100, Darren Tucker wrote:
 This patch below reduces the number of interrupts on the transmit side
 of vr(4).  Currently we set the TX competion interrupt bit on each
 outbound packet.  This patch changes it to only set the interrupt bit on
 the last packet enqueued.  (One thing of note is that the interrupt bit
 is set on the first of potentially several TX descriptors for a packet
 whereas currently it's the last.  I'm not sure if this matters, but if
 it does I can change it).

Here's an updated diff where, when a single packet spans multiple TX
descriptors, it'll only sent the interrupt request bit on the final
discriptor (which matches the current behaviour for that case).

Index: dev/pci/if_vr.c
===
RCS file: /cvs/src/sys/dev/pci/if_vr.c,v
retrieving revision 1.121
diff -u -p -r1.121 if_vr.c
--- dev/pci/if_vr.c 1 Dec 2012 09:55:03 -   1.121
+++ dev/pci/if_vr.c 14 Jan 2013 23:23:57 -
@@ -1254,8 +1254,8 @@ vr_encap(struct vr_softc *sc, struct vr_
sc-vr_cdata.vr_tx_cnt++;
}
 
-   /* Set EOP on the last desciptor */
-   f-vr_ctl |= htole32(VR_TXCTL_LASTFRAG | VR_TXCTL_FINT);
+   /* Set EOP on the last descriptor */
+   f-vr_ctl |= htole32(VR_TXCTL_LASTFRAG);
 
return (0);
 }
@@ -1265,6 +1265,13 @@ vr_encap(struct vr_softc *sc, struct vr_
  * to the mbuf data regions directly in the transmit lists. We also save a
  * copy of the pointers since the transmit list fragment pointers are
  * physical addresses.
+ *
+ * Notes:
+ * We only set ownership bit on first descriptor for a each packet.
+ * We'll only want an interrupt for a given packet if either vr_encap fails
+ * (ie the descriptor ring is full) or if the interface input queue is
+ * empty, and we need to set the interrupt bit before setting the owner bit
+ * to turn it over to the hardware.
  */
 
 void
@@ -1273,6 +1280,7 @@ vr_start(struct ifnet *ifp)
struct vr_softc *sc;
struct mbuf *m_head;
struct vr_chain *cur_tx, *head_tx;
+   struct vr_chain *prev_head_tx = NULL, *prev_tail_tx = NULL;
 
sc = ifp-if_softc;
 
@@ -1298,9 +1306,10 @@ vr_start(struct ifnet *ifp)
IF_PREPEND(ifp-if_snd, m_head);
break;
}
-
-   /* Only set ownership bit on first descriptor */
-   head_tx-vr_ptr-vr_status |= htole32(VR_TXSTAT_OWN);
+   /* successfully enqueued new packet, we're done with previous */
+   if (prev_head_tx != NULL)
+   prev_head_tx-vr_ptr-vr_status |=
+   htole32(VR_TXSTAT_OWN);
 
 #if NBPFILTER  0
/*
@@ -1311,9 +1320,22 @@ vr_start(struct ifnet *ifp)
bpf_mtap_ether(ifp-if_bpf, head_tx-vr_mbuf,
BPF_DIRECTION_OUT);
 #endif
+   prev_head_tx = head_tx;
+   prev_tail_tx = cur_tx;
cur_tx = cur_tx-vr_nextdesc;
}
if (sc-vr_cdata.vr_tx_cnt != 0) {
+   /*
+* If we enqueued any packets, we want to set FINT on the last
+* descriptor for the last packet, but set TXOWN on the first
+* descriptor of the last packet.
+*/
+   if (prev_tail_tx != NULL)
+   prev_tail_tx-vr_ptr-vr_ctl |= htole32(VR_TXCTL_FINT);
+   if (prev_head_tx != NULL)
+   prev_head_tx-vr_ptr-vr_status |=
+   htole32(VR_TXSTAT_OWN);
+
sc-vr_cdata.vr_tx_prod = cur_tx;
 
bus_dmamap_sync(sc-sc_dmat, sc-sc_listmap.vrm_map, 0,

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.



Re: vr(4) TX interrupt reduction

2013-01-14 Thread Michał Markowski
2013/1/15 Chris Cappuccio ch...@nmedia.net:
 Well your numbers clearly show almost no difference. But TCP might not
 be the best way to test due to the regular ack reply.

Ok, -current kernel:

$ int1=`vmstat -i | awk '$1 ~ /vr0/ {print $2}'`; tcpbench -u -t 100
-r 1 r; int2=`vmstat -i | awk '$1 ~ /vr0/ {print $2}'`; let intps
= (int2 - int1) / 100; echo int/s: $intps
Elapsed:   1 Mbps:  87.668 Peak Mbps:  87.668 Tx PPS:7444
Elapsed:   2 Mbps:  87.217 Peak Mbps:  87.668 Tx PPS:7406
Elapsed:   3 Mbps:  87.210 Peak Mbps:  87.668 Tx PPS:7405
Elapsed:   4 Mbps:  87.212 Peak Mbps:  87.668 Tx PPS:7405
Elapsed:   5 Mbps:  87.210 Peak Mbps:  87.668 Tx PPS:7405
Elapsed:   6 Mbps:  87.210 Peak Mbps:  87.668 Tx PPS:7405
Elapsed:   7 Mbps:  87.215 Peak Mbps:  87.668 Tx PPS:7406
Elapsed:   8 Mbps:  87.208 Peak Mbps:  87.668 Tx PPS:7405
Elapsed:   89995 Mbps:  87.207 Peak Mbps:  87.668 Tx PPS:7405
Elapsed:  15 Mbps:  87.212 Peak Mbps:  87.668 Tx PPS:7405
int/s: 7472

Patched (http://marc.info/?l=openbsd-techm=135820613320957q=raw) kernel:

$ int1=`vmstat -i | awk '$1 ~ /vr0/ {print $2}'`; tcpbench -u -t 100
-r 1 r; int2=`vmstat -i | awk '$1 ~ /vr0/ {print $2}'`; let intps
= (int2 - int1) / 100; echo int/s: $intps
Elapsed:   1 Mbps:  87.638 Peak Mbps:  87.638 Tx PPS:7442
Elapsed:   2 Mbps:  87.198 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:   3 Mbps:  87.193 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:   4 Mbps:  87.192 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:   5 Mbps:  87.192 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:   6 Mbps:  87.199 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:   7 Mbps:  87.194 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:   8 Mbps:  87.193 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:   9 Mbps:  87.198 Peak Mbps:  87.638 Tx PPS:7404
Elapsed:  10 Mbps:  87.190 Peak Mbps:  87.638 Tx PPS:7404
int/s: 7471

-- 
Michał Markowski



Re: terminfo entries for rxvt-unicode

2013-01-14 Thread Nicholas Marriott
Hi

Weren't we going to install it in /usr/local/share/terminfo?



On Thu, Jan 03, 2013 at 05:50:13AM -0700, David Coppa wrote:
 
 Hi.
 
 Had this in my src tree for a long time...
 
 Is it worth considering for general consumption?
 
 Ciao,
 David
 
 Index: share/termtypes/termtypes.master
 ===
 RCS file: /cvs/src/share/termtypes/termtypes.master,v
 retrieving revision 1.47
 diff -u -p -r1.47 termtypes.master
 --- share/termtypes/termtypes.master  1 Apr 2012 11:24:46 -   1.47
 +++ share/termtypes/termtypes.master  7 Dec 2012 15:18:32 -
 @@ -4420,6 +4420,176 @@ rxvt-cygwin-native|rxvt terminal emulato
  rxvt-16color|xterm with 16 colors like aixterm,
   ncv#32, use=ibm+16color, use=rxvt,
  
 +# From: Thomas Dickey dic...@clark.net 04 Oct 1997
 +# Updated: Oezguer Kesim ke...@math.fu-berlin.de 02 Nov 1997
 +# Updated: Marc Lehmann schm...@schmorp.de, 17 Feb 2005
 +# Updated: Marc Lehmann schm...@schmorp.de, 04 Nov 2008: change init/reset 
 sequences
 +rxvt-unicode|rxvt-unicode terminal (X Window System),
 + am,
 + bce,
 + eo,
 + km,
 + msgr,
 + xenl,
 + hs,
 + cols#80,
 + it#8,
 + lines#24,
 + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~-A.B+C\,D0EhFiG,
 + bel=^G,
 + blink=\E[5m,
 + bold=\E[1m,
 + civis=\E[?25l,
 + clear=\E[H\E[2J,
 + cnorm=\E[?25h,
 + cr=^M,
 + csr=\E[%i%p1%d;%p2%dr,
 + cub=\E[%p1%dD,
 + cub1=^H,
 + cud=\E[%p1%dB,
 + cud1=^J,
 + cuf=\E[%p1%dC,
 + cuf1=\E[C,
 + cup=\E[%i%p1%d;%p2%dH,
 + cuu=\E[%p1%dA,
 + cuu1=\E[A,
 + cvvis=\E[?25h,
 + dch=\E[%p1%dP,
 + dch1=\E[P,
 + dl=\E[%p1%dM,
 + dl1=\E[M,
 + ed=\E[J,
 + el=\E[K,
 + el1=\E[1K,
 + flash=\E[?5h$20/\E[?5l,
 + home=\E[H,
 + hpa=\E[%i%p1%dG,
 + ht=^I,
 + hts=\EH,
 + ich=\E[%p1%d@,
 + ich1=\E[@,
 + il=\E[%p1%dL,
 + il1=\E[L,
 + ind=^J,
 + is1=\E[\041p,
 + is2=\E[r\E[m\E[2J\E[?7;25h\E[?1;3;4;5;6;9;66;1000;1001;1049l\E[4l,
 + kDC=\E[3$,
 + kIC=\E[2$,
 + kEND=\E[8$,
 + kHOM=\E[7$,
 + kLFT=\E[d,
 + kNXT=\E[6$,
 + kPRV=\E[5$,
 + kRIT=\E[c,
 + kbs=\177,
 + ka1=\EOw,
 + ka3=\EOy,
 + kb2=\EOu,
 + kc1=\EOq,
 + kc3=\EOs,
 + kcbt=\E[Z,
 + kcub1=\E[D,
 + kcud1=\E[B,
 + kcuf1=\E[C,
 + kcuu1=\E[A,
 + kdch1=\E[3~,
 + kel=\E[8\^,
 + kend=\E[8~,
 + kent=\EOM,
 + kf1=\E[11~,
 + kf10=\E[21~,
 + kf11=\E[23~,
 + kf12=\E[24~,
 + kf13=\E[25~,
 + kf14=\E[26~,
 + kf15=\E[28~,
 + kf16=\E[29~,
 + kf17=\E[31~,
 + kf18=\E[32~,
 + kf19=\E[33~,
 + kf2=\E[12~,
 + kf20=\E[34~,
 + kf3=\E[13~,
 + kf4=\E[14~,
 + kf5=\E[15~,
 + kf6=\E[17~,
 + kf7=\E[18~,
 + kf8=\E[19~,
 + kf9=\E[20~,
 + kfnd=\E[1~,
 + khome=\E[7~,
 + kich1=\E[2~,
 + kmous=\E[M,
 + knp=\E[6~,
 + kpp=\E[5~,
 + kslt=\E[4~,
 + rc=\E8,
 + rev=\E[7m,
 + ri=\EM,
 + rmso=\E[27m,
 + rmul=\E[24m,
 + rs1=\Ec,
 + rs2=\E[r\E[m\E[?7;25h\E[?1;3;4;5;6;9;66;1000;1001;1049l\E[4l,
 + sgr0=\E[m\E(B,
 + enacs=,
 + smacs=\E(0,
 + rmacs=\E(B,
 + smso=\E[7m,
 + smul=\E[4m,
 + tbc=\E[3g,
 + vpa=\E[%i%p1%dd,
 + colors#88,
 + pairs#7744,
 + btns#5,
 + lm#0,
 + ccc,
 + npc,
 + mc5i,
 + ncv#0,
 + mir,
 + xon,
 + bw,
 + ech=\E[%p1%dX,
 + mc0=\E[i,
 + mc4=\E[4i,
 + mc5=\E[5i,
 + sitm=\E[3m,
 + ritm=\E[23m,
 + smam=\E[?7h,
 + rmam=\E[?7l,
 + smir=\E[4h,
 + rmir=\E[4l,
 + smcup=\E[?1049h,
 + rmcup=\E[r\E[?1049l,
 + smkx=\E=,
 + rmkx=\E,
 + indn=\E[%p1%dS,
 + rin=\E[%p1%dT,
 + 
 sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
 + op=\E[39;49m,
 + setaf=\E[38;5;%p1%dm,
 + setab=\E[48;5;%p1%dm,
 + 
 setf=%?%p1%{7}%%t\E[38;5;%p1%dm%e\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
 + 
 setb=%?%p1%{7}%%t\E[48;5;%p1%dm%e\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
 + 
 initc=\E]4;%p1%d;rgb\:%p2%{65535}%*%{1000}%/%4.4X/%p3%{65535}%*%{1000}%/%4.4X/%p4%{65535}%*%{1000}%/%4.4X\E\\,
 + sc=\E7,
 + s0ds=\E(B,
 + s1ds=\E(0,
 + s2ds=\E*B,
 + s3ds=\E+B,
 + u6=\E[%i%d;%dR,
 + u7=\E[6n,
 + u8=\E[?1;2c,
 + u9=\E[c,
 + tsl=\E]2;,
 + fsl=\007,
 + dsl=\E]2;\007,
 +
 +rxvt-unicode-256color|rxvt-unicode terminal with 256 colors (X Window 
 System),
 + colors#256,
 + pairs#32767,
 + use=rxvt-unicode,
 +
   MRXVT
  # mrxvt 0.5.4
  #