svn commit: r196487 - head/sys/dev/sound/usb

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 04:57:48 2009
New Revision: 196487
URL: http://svn.freebsd.org/changeset/base/196487

Log:
  Remove redundant Giant reference. Giant will be dropped
  automatically when the mutex argument is NULL.
  
  Reported by: Various people
  Submitted by: hps

Modified:
  head/sys/dev/sound/usb/uaudio.c

Modified: head/sys/dev/sound/usb/uaudio.c
==
--- head/sys/dev/sound/usb/uaudio.c Mon Aug 24 03:49:37 2009
(r196486)
+++ head/sys/dev/sound/usb/uaudio.c Mon Aug 24 04:57:48 2009
(r196487)
@@ -2958,7 +2958,7 @@ uaudio_mixer_get(struct usb_device *udev
USETW(req.wIndex, mc->wIndex);
USETW(req.wLength, len);
 
-   err = usbd_do_request(udev, &Giant, &req, data);
+   err = usbd_do_request(udev, NULL, &req, data);
if (err) {
DPRINTF("err=%s\n", usbd_errstr(err));
return (0);
@@ -3081,7 +3081,7 @@ uaudio_set_speed(struct usb_device *udev
data[1] = speed >> 8;
data[2] = speed >> 16;
 
-   return (usbd_do_request(udev, &Giant, &req, data));
+   return (usbd_do_request(udev, NULL, &req, data));
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196488 - head/sys/dev/usb/controller

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 04:58:11 2009
New Revision: 196488
URL: http://svn.freebsd.org/changeset/base/196488

Log:
  - allow disabling "root_mount_hold()" by
  setting a sysctl/tunable at boot
  - remove some redundant initial explore code
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/controller/usb_controller.c

Modified: head/sys/dev/usb/controller/usb_controller.c
==
--- head/sys/dev/usb/controller/usb_controller.cMon Aug 24 04:57:48 
2009(r196487)
+++ head/sys/dev/usb/controller/usb_controller.cMon Aug 24 04:58:11 
2009(r196488)
@@ -67,7 +67,6 @@ static device_attach_t usb_attach;
 static device_detach_t usb_detach;
 
 static voidusb_attach_sub(device_t, struct usb_bus *);
-static voidusb_post_init(void *);
 
 /* static variables */
 
@@ -84,8 +83,6 @@ TUNABLE_INT("hw.usb.no_boot_wait", &usb_
 SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 
0,
 "No device enumerate waiting at boot.");
 
-static uint8_t usb_post_init_called = 0;
-
 static devclass_t usb_devclass;
 
 static device_method_t usb_methods[] = {
@@ -142,12 +139,8 @@ usb_attach(device_t dev)
bus->bus_roothold = root_mount_hold(device_get_nameunit(dev));
}
 
-   if (usb_post_init_called) {
-   mtx_lock(&Giant);
-   usb_attach_sub(dev, bus);
-   mtx_unlock(&Giant);
-   usb_needs_explore(bus, 1);
-   }
+   usb_attach_sub(dev, bus);
+
return (0); /* return success */
 }
 
@@ -226,22 +219,24 @@ usb_bus_explore(struct usb_proc_msg *pm)
/* avoid zero, hence that is memory default */
bus->driver_added_refcount = 1;
}
-   USB_BUS_UNLOCK(bus);
 
-   mtx_lock(&Giant);
+   /*
+* The following three lines of code are only here to
+* recover from DDB:
+*/
+   usb_proc_rewakeup(&bus->control_xfer_proc);
+   usb_proc_rewakeup(&bus->giant_callback_proc);
+   usb_proc_rewakeup(&bus->non_giant_callback_proc);
+
+   USB_BUS_UNLOCK(bus);
 
/*
 * First update the USB power state!
 */
usb_bus_powerd(bus);
-   /*
-* Explore the Root USB HUB. This call can sleep,
-* exiting Giant, which is actually Giant.
-*/
-   (udev->hub->explore) (udev);
-
-   mtx_unlock(&Giant);
 
+/* Explore the Root USB HUB. */
+   (udev->hub->explore) (udev);
USB_BUS_LOCK(bus);
}
if (bus->bus_roothold != NULL) {
@@ -269,10 +264,10 @@ usb_bus_detach(struct usb_proc_msg *pm)
device_set_softc(dev, NULL);
USB_BUS_UNLOCK(bus);
 
-   mtx_lock(&Giant);
-
/* detach children first */
+   mtx_lock(&Giant);
bus_generic_detach(dev);
+   mtx_unlock(&Giant);
 
/*
 * Free USB Root device, but not any sub-devices, hence they
@@ -281,7 +276,6 @@ usb_bus_detach(struct usb_proc_msg *pm)
usb_free_device(udev,
USB_UNCFG_FLAG_FREE_EP0);
 
-   mtx_unlock(&Giant);
USB_BUS_LOCK(bus);
/* clear bdev variable last */
bus->bdev = NULL;
@@ -297,6 +291,12 @@ usb_power_wdog(void *arg)
usb_callout_reset(&bus->power_wdog,
4 * hz, usb_power_wdog, arg);
 
+   /*
+* The following line of code is only here to recover from
+* DDB:
+*/
+   usb_proc_rewakeup(&bus->explore_proc);  /* recover from DDB */
+
USB_BUS_UNLOCK(bus);
 
usb_bus_power_update(bus);
@@ -350,7 +350,6 @@ usb_bus_attach(struct usb_proc_msg *pm)
}
 
USB_BUS_UNLOCK(bus);
-   mtx_lock(&Giant);   /* XXX not required by USB */
 
/* default power_mask value */
bus->hw_power_state =
@@ -383,7 +382,6 @@ usb_bus_attach(struct usb_proc_msg *pm)
err = USB_ERR_NOMEM;
}
 
-   mtx_unlock(&Giant);
USB_BUS_LOCK(bus);
 
if (err) {
@@ -401,17 +399,18 @@ usb_bus_attach(struct usb_proc_msg *pm)
 /**
  * usb_attach_sub
  *
- * This function creates a thread which runs the USB attach code. It
- * is factored out, hence it can be called at two different places in
- * time. During bootup this function is called from
- * "usb_post_init". During hot-plug it is called directly from the
- * "usb_attach()" method.
+ * This function creates a thread which runs the USB attach code.
  **/
 static void
 usb_attach_sub(device_t dev, struct usb_bus *bus)
 {
const char *pname = device_get_name

svn commit: r196489 - head/sys/dev/usb/input

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 04:58:42 2009
New Revision: 196489
URL: http://svn.freebsd.org/changeset/base/196489

Log:
  - patch for cordump slowdown. Avoid using DELAY(1000) when no
  keys are pressed.
  - Reported by: Various people
  
  - add sysctl to disable keyboard led control request
  - Reported by: Yoshihiro Ota
  
  - Save system CPU usage: Patch to stop keyboard timer when no
  keys are pressed.
  
  Submitted by: hps
  MFC after:3 days

Modified:
  head/sys/dev/usb/input/ukbd.c

Modified: head/sys/dev/usb/input/ukbd.c
==
--- head/sys/dev/usb/input/ukbd.c   Mon Aug 24 04:58:11 2009
(r196488)
+++ head/sys/dev/usb/input/ukbd.c   Mon Aug 24 04:58:42 2009
(r196489)
@@ -96,10 +96,14 @@ __FBSDID("$FreeBSD$");
 
 #if USB_DEBUG
 static int ukbd_debug = 0;
+static int ukbd_no_leds = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB ukbd");
 SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RW,
 &ukbd_debug, 0, "Debug level");
+SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RW,
+&ukbd_no_leds, 0, "Disables setting of keyboard leds");
+
 #endif
 
 #defineUPROTO_BOOT_KEYBOARD 1
@@ -165,6 +169,7 @@ struct ukbd_softc {
 #defineUKBD_FLAG_APPLE_EJECT   0x0040
 #defineUKBD_FLAG_APPLE_FN  0x0080
 #defineUKBD_FLAG_APPLE_SWAP0x0100
+#defineUKBD_FLAG_TIMER_RUNNING 0x0200
 
int32_t sc_mode;/* input mode (K_XLATE,K_RAW,K_CODE) */
int32_t sc_state;   /* shift/lock key state */
@@ -279,6 +284,25 @@ static device_attach_t ukbd_attach;
 static device_detach_t ukbd_detach;
 static device_resume_t ukbd_resume;
 
+static uint8_t
+ukbd_any_key_pressed(struct ukbd_softc *sc)
+{
+   uint8_t i;
+   uint8_t j;
+
+   for (j = i = 0; i < UKBD_NKEYCODE; i++)
+   j |= sc->sc_odata.keycode[i];
+
+   return (j ? 1 : 0);
+}
+
+static void
+ukbd_start_timer(struct ukbd_softc *sc)
+{
+   sc->sc_flags |= UKBD_FLAG_TIMER_RUNNING;
+   usb_callout_reset(&sc->sc_callout, hz / 40, &ukbd_timeout, sc);
+}
+
 static void
 ukbd_put_key(struct ukbd_softc *sc, uint32_t key)
 {
@@ -308,11 +332,15 @@ ukbd_do_poll(struct ukbd_softc *sc, uint
 
usbd_transfer_poll(sc->sc_xfer, UKBD_N_TRANSFER);
 
-   DELAY(1000);/* delay 1 ms */
+   /* Delay-optimised support for repetition of keys */
 
-   sc->sc_time_ms++;
+   if (ukbd_any_key_pressed(sc)) {
+   /* a key is pressed - need timekeeping */
+   DELAY(1000);
 
-   /* support repetition of keys: */
+   /* 1 millisecond has passed */
+   sc->sc_time_ms += 1;
+   }
 
ukbd_interrupt(sc);
 
@@ -470,7 +498,11 @@ ukbd_timeout(void *arg)
}
ukbd_interrupt(sc);
 
-   usb_callout_reset(&sc->sc_callout, hz / 40, &ukbd_timeout, sc);
+   if (ukbd_any_key_pressed(sc)) {
+   ukbd_start_timer(sc);
+   } else {
+   sc->sc_flags &= ~UKBD_FLAG_TIMER_RUNNING;
+   }
 }
 
 static uint8_t
@@ -582,6 +614,12 @@ ukbd_intr_callback(struct usb_xfer *xfer
}
 
ukbd_interrupt(sc);
+
+   if (!(sc->sc_flags & UKBD_FLAG_TIMER_RUNNING)) {
+   if (ukbd_any_key_pressed(sc)) {
+   ukbd_start_timer(sc);
+   }
+   }
}
case USB_ST_SETUP:
 tr_setup:
@@ -613,6 +651,11 @@ ukbd_set_leds_callback(struct usb_xfer *
uint8_t buf[2];
struct ukbd_softc *sc = usbd_xfer_softc(xfer);
 
+#if USB_DEBUG
+   if (ukbd_no_leds)
+   return;
+#endif
+
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
@@ -647,11 +690,11 @@ ukbd_set_leds_callback(struct usb_xfer *
usbd_xfer_set_frames(xfer, 2);
usbd_transfer_submit(xfer);
}
-   return;
+   break;
 
default:/* Error */
DPRINTFN(0, "error=%s\n", usbd_errstr(error));
-   return;
+   break;
}
 }
 
@@ -745,8 +788,6 @@ ukbd_attach(device_t dev)
uint16_t n;
uint16_t hid_len;
 
-   mtx_assert(&Giant, MA_OWNED);
-
kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0);
 
kbd->kb_data = (void *)sc;
@@ -831,7 +872,7 @@ ukbd_attach(device_t dev)
}
 
/* ignore if SETIDLE fails, hence it is not crucial */
-   err = usbd_req_set_idle(sc->sc_udev, &Giant, sc->sc_iface_index, 0, 0);
+   err = usbd_req_set_idle(sc->sc_udev, NULL, sc->sc_iface_index, 0, 0);
 
ukbd_ioct

svn commit: r196490 - in head/sys/dev/usb: misc storage

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 04:59:09 2009
New Revision: 196490
URL: http://svn.freebsd.org/changeset/base/196490

Log:
  - FIFO's are always opened separately in read and write
  direction even if the actual device is opened for read and
  write. Fix fflags check so that the UFM and URIO drivers work.
  Reported by: Krassimir Slavchev
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/misc/ufm.c
  head/sys/dev/usb/storage/urio.c

Modified: head/sys/dev/usb/misc/ufm.c
==
--- head/sys/dev/usb/misc/ufm.c Mon Aug 24 04:58:42 2009(r196489)
+++ head/sys/dev/usb/misc/ufm.c Mon Aug 24 04:59:09 2009(r196490)
@@ -86,11 +86,9 @@ static device_attach_t ufm_attach;
 static device_detach_t ufm_detach;
 
 static usb_fifo_ioctl_t ufm_ioctl;
-static usb_fifo_open_t ufm_open;
 
 static struct usb_fifo_methods ufm_fifo_methods = {
.f_ioctl = &ufm_ioctl,
-   .f_open = &ufm_open,
.basename[0] = "ufm",
 };
 
@@ -179,15 +177,6 @@ ufm_detach(device_t dev)
 }
 
 static int
-ufm_open(struct usb_fifo *dev, int fflags)
-{
-   if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
-   return (EACCES);
-   }
-   return (0);
-}
-
-static int
 ufm_do_req(struct ufm_softc *sc, uint8_t request,
 uint16_t value, uint16_t index, uint8_t *retbuf)
 {
@@ -315,6 +304,10 @@ ufm_ioctl(struct usb_fifo *fifo, u_long 
struct ufm_softc *sc = usb_fifo_softc(fifo);
int error = 0;
 
+   if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
+   return (EACCES);
+   }
+
switch (cmd) {
case FM_SET_FREQ:
error = ufm_set_freq(sc, addr);

Modified: head/sys/dev/usb/storage/urio.c
==
--- head/sys/dev/usb/storage/urio.c Mon Aug 24 04:58:42 2009
(r196489)
+++ head/sys/dev/usb/storage/urio.c Mon Aug 24 04:59:09 2009
(r196490)
@@ -390,9 +390,6 @@ urio_open(struct usb_fifo *fifo, int ffl
 {
struct urio_softc *sc = usb_fifo_softc(fifo);
 
-   if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
-   return (EACCES);
-   }
if (fflags & FREAD) {
/* clear stall first */
mtx_lock(&sc->sc_mtx);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196491 - head/sys/dev/usb/net

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:00:07 2009
New Revision: 196491
URL: http://svn.freebsd.org/changeset/base/196491

Log:
  We used force all of the GPIO pins low first and then
  enable the ones we want. This has been changed to better
  match the ADMtek's reference design to avoid setting the
  power-down configuration line of the PHY at the same time
  it is reset.
  
  Submitted by: John Hood via hps

Modified:
  head/sys/dev/usb/net/if_aue.c

Modified: head/sys/dev/usb/net/if_aue.c
==
--- head/sys/dev/usb/net/if_aue.c   Mon Aug 24 04:59:09 2009
(r196490)
+++ head/sys/dev/usb/net/if_aue.c   Mon Aug 24 05:00:07 2009
(r196491)
@@ -484,7 +484,7 @@ aue_miibus_writereg(device_t dev, int ph
}
 
if (i == AUE_TIMEOUT)
-   device_printf(sc->sc_ue.ue_dev, "MII read timed out\n");
+   device_printf(sc->sc_ue.ue_dev, "MII write timed out\n");
 
if (!locked)
AUE_UNLOCK(sc);
@@ -603,11 +603,14 @@ aue_reset(struct aue_softc *sc)
 * to set the GPIO pins high so that the PHY(s) will
 * be enabled.
 *
-* Note: We force all of the GPIO pins low first, *then*
-* enable the ones we want.
+* NOTE: We used to force all of the GPIO pins low first and then
+* enable the ones we want. This has been changed to better
+* match the ADMtek's reference design to avoid setting the
+* power-down configuration line of the PHY at the same time
+* it is reset.
 */
-   aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0);
-   aue_csr_write_1(sc, AUE_GPIO0, 
AUE_GPIO_OUT0|AUE_GPIO_SEL0|AUE_GPIO_SEL1);
+   aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_SEL0|AUE_GPIO_SEL1);
+   aue_csr_write_1(sc, AUE_GPIO0, 
AUE_GPIO_SEL0|AUE_GPIO_SEL1|AUE_GPIO_OUT0);
 
if (sc->sc_flags & AUE_FLAG_LSYS) {
/* Grrr. LinkSys has to be different from everyone else. */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196492 - head/sys/dev/usb/net

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:00:33 2009
New Revision: 196492
URL: http://svn.freebsd.org/changeset/base/196492

Log:
   - fix CDC ethernet matching order so that the match flags get 
correct.
  
  Reported by: Juergen Lock
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/net/if_cdce.c

Modified: head/sys/dev/usb/net/if_cdce.c
==
--- head/sys/dev/usb/net/if_cdce.c  Mon Aug 24 05:00:07 2009
(r196491)
+++ head/sys/dev/usb/net/if_cdce.c  Mon Aug 24 05:00:33 2009
(r196492)
@@ -197,9 +197,6 @@ static const struct usb_ether_methods cd
 };
 
 static const struct usb_device_id cdce_devs[] = {
-   {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 
0)},
-   {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)},
-
{USB_VPI(USB_VENDOR_ACERLABS, USB_PRODUCT_ACERLABS_M5632, 
CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250, 
CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQLINUX, 
CDCE_FLAG_NO_UNION)},
@@ -213,6 +210,9 @@ static const struct usb_device_id cdce_d
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLA300, CDCE_FLAG_ZAURUS | 
CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC700, CDCE_FLAG_ZAURUS | 
CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC750, CDCE_FLAG_ZAURUS | 
CDCE_FLAG_NO_UNION)},
+
+   {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 
0)},
+   {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)},
 };
 
 static int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196493 - in head/sys/dev/usb: . serial

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:01:06 2009
New Revision: 196493
URL: http://svn.freebsd.org/changeset/base/196493

Log:
   - Fix false positive uipaq probe
  
  Reported by: Alexander Motin 
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/serial/uipaq.c
  head/sys/dev/usb/usb.h

Modified: head/sys/dev/usb/serial/uipaq.c
==
--- head/sys/dev/usb/serial/uipaq.c Mon Aug 24 05:00:33 2009
(r196492)
+++ head/sys/dev/usb/serial/uipaq.c Mon Aug 24 05:01:06 2009
(r196493)
@@ -1103,6 +1103,10 @@ uipaq_probe(device_t dev)
if (uaa->info.bIfaceIndex != UIPAQ_IFACE_INDEX) {
return (ENXIO);
}
+   if (uaa->info.bInterfaceClass == UICLASS_IAD) {
+   DPRINTF("IAD detected - not UIPAQ serial device\n");
+   return (ENXIO);
+   }
return (usbd_lookup_id_by_uaa(uipaq_devs, sizeof(uipaq_devs), uaa));
 }
 

Modified: head/sys/dev/usb/usb.h
==
--- head/sys/dev/usb/usb.h  Mon Aug 24 05:00:33 2009(r196492)
+++ head/sys/dev/usb/usb.h  Mon Aug 24 05:01:06 2009(r196493)
@@ -484,6 +484,8 @@ typedef struct usb_interface_assoc_descr
 #defineUISUBCLASS_RF   0x01
 #defineUIPROTO_BLUETOOTH   0x01
 
+#defineUICLASS_IAD 0xEF/* Interface Association 
Descriptor */
+
 #defineUICLASS_APPL_SPEC   0xfe
 #defineUISUBCLASS_FIRMWARE_DOWNLOAD1
 #defineUISUBCLASS_IRDA 2
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196494 - head/sys/dev/usb/serial

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:01:40 2009
New Revision: 196494
URL: http://svn.freebsd.org/changeset/base/196494

Log:
   - fix uvisor support, mostly correct buffer sizes used.
   - correct device info flag for SONY Cli NR70V
  
  Reported by: Marc Fonvieille
  Submitted by: hps

Modified:
  head/sys/dev/usb/serial/uvisor.c

Modified: head/sys/dev/usb/serial/uvisor.c
==
--- head/sys/dev/usb/serial/uvisor.cMon Aug 24 05:01:06 2009
(r196493)
+++ head/sys/dev/usb/serial/uvisor.cMon Aug 24 05:01:40 2009
(r196494)
@@ -95,7 +95,15 @@ SYSCTL_INT(_hw_usb_uvisor, OID_AUTO, deb
 
 #defineUVISOR_CONFIG_INDEX 0
 #defineUVISOR_IFACE_INDEX  0
-#defineUVISOR_BUFSIZE   1024   /* bytes */
+
+/*
+ * The following buffer sizes are hardcoded due to the way the Palm
+ * firmware works. It looks like the device is not short terminating
+ * the data transferred.
+ */
+#defineUVISORIBUFSIZE 0/* Use wMaxPacketSize */
+#defineUVISOROBUFSIZE 32   /* bytes */
+#defineUVISOROFRAMES  32   /* units */
 
 /* From the Linux driver */
 /*
@@ -208,7 +216,8 @@ static const struct usb_config uvisor_co
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
-   .bufsize = UVISOR_BUFSIZE,  /* bytes */
+   .bufsize = UVISOROBUFSIZE * UVISOROFRAMES,
+   .frames = UVISOROFRAMES,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.callback = &uvisor_write_callback,
},
@@ -217,7 +226,7 @@ static const struct usb_config uvisor_co
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
-   .bufsize = UVISOR_BUFSIZE,  /* bytes */
+   .bufsize = UVISORIBUFSIZE,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.callback = &uvisor_read_callback,
},
@@ -270,7 +279,7 @@ static const struct usb_device_id uvisor
{USB_VPI(USB_VENDOR_PALM, USB_PRODUCT_PALM_ZIRE31, UVISOR_FLAG_PALM4)},
{USB_VPI(USB_VENDOR_SAMSUNG, USB_PRODUCT_SAMSUNG_I500, 
UVISOR_FLAG_PALM4)},
{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_40, 0)},
-   {USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_41, UVISOR_FLAG_PALM4)},
+   {USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_41, 0)},
{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_S360, 
UVISOR_FLAG_PALM4)},
{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_NX60, 
UVISOR_FLAG_PALM4)},
{USB_VPI(USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_35, 
UVISOR_FLAG_PALM35)},
@@ -375,7 +384,6 @@ uvisor_init(struct uvisor_softc *sc, str
struct uvisor_connection_info coninfo;
struct uvisor_palm_connection_info pconinfo;
uint16_t actlen;
-   uWord wAvail;
uint8_t buffer[256];
 
if (sc->sc_flag & UVISOR_FLAG_VISOR) {
@@ -496,6 +504,9 @@ uvisor_init(struct uvisor_softc *sc, str
goto done;
}
}
+#if 0
+   uWord wAvail;
+
DPRINTF("getting available bytes\n");
req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
req.bRequest = UVISOR_REQUEST_BYTES_AVAILABLE;
@@ -507,6 +518,7 @@ uvisor_init(struct uvisor_softc *sc, str
goto done;
}
DPRINTF("avail=%d\n", UGETW(wAvail));
+#endif
 
DPRINTF("done\n");
 done:
@@ -579,19 +591,31 @@ uvisor_write_callback(struct usb_xfer *x
struct uvisor_softc *sc = usbd_xfer_softc(xfer);
struct usb_page_cache *pc;
uint32_t actlen;
+   uint8_t x;
 
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
case USB_ST_TRANSFERRED:
 tr_setup:
-   pc = usbd_xfer_get_frame(xfer, 0);
-   if (ucom_get_data(&sc->sc_ucom, pc, 0,
-   UVISOR_BUFSIZE, &actlen)) {
+   for (x = 0; x != UVISOROFRAMES; x++) {
+
+   usbd_xfer_set_frame_offset(xfer, 
+   x * UVISOROBUFSIZE, x);
 
-   usbd_xfer_set_frame_len(xfer, 0, actlen);
+   pc = usbd_xfer_get_frame(xfer, x);
+   if (ucom_get_data(&sc->sc_ucom, pc, 0,
+   UVISOROBUFSIZE, &actlen)) {
+   usbd_xfer_set_frame_len(xfer, x, actlen);
+   } else {
+   break;
+   }
+   }
+   /* check for data */
+   if (x != 0) {
+   usbd_xfer_set_frames(xfer, x);
usbd_transfer_submit(xfer);
}
-   return;
+   break;
 
default:/* Error */
if (error != USB_ERR_CANCELLED) {
@@ -5

svn commit: r196495 - in head/sys/dev/usb: . storage

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:02:36 2009
New Revision: 196495
URL: http://svn.freebsd.org/changeset/base/196495

Log:
  Add mass storage quirks.
  
  PR: usb/137138,usb/137226,usb/137789,usb/135372
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/storage/umass.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/storage/umass.c
==
--- head/sys/dev/usb/storage/umass.cMon Aug 24 05:01:40 2009
(r196494)
+++ head/sys/dev/usb/storage/umass.cMon Aug 24 05:02:36 2009
(r196495)
@@ -412,6 +412,10 @@ static const struct umass_devdescr umass
UMASS_PROTO_DEFAULT,
NO_SYNCHRONIZE_CACHE
},
+   {USB_VENDOR_ALCOR, USB_PRODUCT_ALCOR_SDCR_6335, RID_WILDCARD,
+   UMASS_PROTO_DEFAULT,
+   NO_TEST_UNIT_READY | NO_SYNCHRONIZE_CACHE
+   },
{USB_VENDOR_ALCOR, USB_PRODUCT_ALCOR_AU6390, RID_WILDCARD,
UMASS_PROTO_DEFAULT,
NO_SYNCHRONIZE_CACHE
@@ -733,6 +737,10 @@ static const struct umass_devdescr umass
UMASS_PROTO_UFI,
NO_QUIRKS
},
+   { USB_VENDOR_PHILIPS, USB_PRODUCT_PHILIPS_SPE3030CC, RID_WILDCARD,
+   UMASS_PROTO_DEFAULT,
+   NO_SYNCHRONIZE_CACHE
+   },
{USB_VENDOR_PLEXTOR, USB_PRODUCT_PLEXTOR_40_12_40U, RID_WILDCARD,
UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
NO_TEST_UNIT_READY
@@ -893,6 +901,10 @@ static const struct umass_devdescr umass
UMASS_PROTO_UFI | UMASS_PROTO_CBI,
NO_QUIRKS
},
+   {USB_VENDOR_TECLAST, USB_PRODUCT_TECLAST_TLC300, RID_WILDCARD,
+   UMASS_PROTO_DEFAULT,
+   NO_TEST_UNIT_READY | NO_SYNCHRONIZE_CACHE
+   },
{USB_VENDOR_TREK, USB_PRODUCT_TREK_MEMKEY, RID_WILDCARD,
UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
NO_INQUIRY
@@ -965,6 +977,10 @@ static const struct umass_devdescr umass
UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
NO_SYNCHRONIZE_CACHE
},
+   {USB_VENDOR_ASUS, USB_PRODUCT_ASUS_GMSC, RID_WILDCARD,
+   UMASS_PROTO_DEFAULT,
+   NO_SYNCHRONIZE_CACHE
+   },
{VID_EOT, PID_EOT, RID_EOT, 0, 0}
 };
 

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsMon Aug 24 05:01:40 2009(r196494)
+++ head/sys/dev/usb/usbdevsMon Aug 24 05:02:36 2009(r196495)
@@ -360,6 +360,7 @@ vendor SMC  0x0707  Standard Microsystems
 vendor PUTERCOM0x0708  Putercom
 vendor MCT 0x0711  MCT
 vendor IMATION 0x0718  Imation
+vendor TECLAST 0x071b  Teclast
 vendor SONYERICSSON0x0731  Sony Ericsson
 vendor EICON   0x0734  Eicon Networks
 vendor SYNTECH 0x0745  Syntech Information
@@ -585,6 +586,7 @@ vendor NETGEAR3 0x1385  Netgear
 vendor BALTECH 0x13ad  Baltech
 vendor CISCOLINKSYS0x13b1  Cisco-Linksys
 vendor SHARK   0x13d2  Shark
+vendor EMTEC   0x13fe  Emtec
 vendor NOVATEL 0x1410  Novatel Wireless
 vendor MERLIN  0x1416  Merlin
 vendor WISTRONNEWEB0x1435  Wistron NeWeb
@@ -820,6 +822,7 @@ product AKS USBHASP 0x0001  USB-HASP 0.0
 /* Alcor Micro, Inc. products */
 product ALCOR2 KBD_HUB 0x2802  Kbd Hub
 
+product ALCOR SDCR_63350x6335  SD/MMC Card Reader
 product ALCOR TRANSCEND0x6387  Transcend JetFlash Drive
 product ALCOR MA_KBD_HUB   0x9213  MacAlly Kbd Hub
 product ALCOR AU9814   0x9215  AU9814 Hub
@@ -861,6 +864,12 @@ product APC UPS0x0002  Uninterruptible
 
 /* Apple Computer products */
 product APPLE EXT_KBD  0x020c  Apple Extended USB Keyboard
+product APPLE KBD_TP_ANSI  0x0223  Apple Internal Keyboard/Trackpad 
(Wellspring/ANSI)
+product APPLE KBD_TP_ISO   0x0224  Apple Internal Keyboard/Trackpad 
(Wellspring/ISO)
+product APPLE KBD_TP_JIS   0x0225  Apple Internal Keyboard/Trackpad 
(Wellspring/JIS)
+product APPLE KBD_TP_ANSI2 0x0230  Apple Internal Keyboard/Trackpad 
(Wellspring2/ANSI)
+product APPLE KBD_TP_ISO2  0x0231  Apple Internal Keyboard/Trackpad 
(Wellspring2/ISO)
+product APPLE KBD_TP_JIS2  0x0232  Apple Internal Keyboard/Trackpad 
(Wellspring2/JIS)
 product APPLE OPTMOUSE 0x0302  Optical mouse
 product APPLE MIGHTYMOUSE  0x0304  Mighty Mouse
 product APPLE EXT_KBD_HUB  0x1003  Hub in Apple Extended USB Keyboard
@@ -902,6 +911,7 @@ product ASUS RT2573_1   0x1723  RT2573
 product ASUS RT2573_2  0x1724  RT2573
 product ASUS LCM   0x1726  LCM display
 product ASUS P535  0x420f  ASUS P535 PDA
+productASUS GMSC   0x422f  ASUS Generic Mass Storage
 
 /* ATen products */
 product ATEN U

svn commit: r196496 - head/sys/dev/usb

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:03:30 2009
New Revision: 196496
URL: http://svn.freebsd.org/changeset/base/196496

Log:
  Add a reminder comment to optimize bus_dmamap_sync calls.
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/usb_busdma.c

Modified: head/sys/dev/usb/usb_busdma.c
==
--- head/sys/dev/usb/usb_busdma.c   Mon Aug 24 05:02:36 2009
(r196495)
+++ head/sys/dev/usb/usb_busdma.c   Mon Aug 24 05:03:30 2009
(r196496)
@@ -679,6 +679,12 @@ usb_pc_cpu_invalidate(struct usb_page_ca
/* nothing has been loaded into this page cache! */
return;
}
+
+   /*
+* TODO: We currently do XXX_POSTREAD and XXX_PREREAD at the
+* same time, but in the future we should try to isolate the
+* different cases to optimise the code. --HPS
+*/
bus_dmamap_sync(pc->tag, pc->map, BUS_DMASYNC_POSTREAD);
bus_dmamap_sync(pc->tag, pc->map, BUS_DMASYNC_PREREAD);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196497 - head/sys/dev/usb/wlan

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:03:59 2009
New Revision: 196497
URL: http://svn.freebsd.org/changeset/base/196497

Log:
  Remove redundant locking.
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/wlan/if_upgt.c

Modified: head/sys/dev/usb/wlan/if_upgt.c
==
--- head/sys/dev/usb/wlan/if_upgt.c Mon Aug 24 05:03:30 2009
(r196496)
+++ head/sys/dev/usb/wlan/if_upgt.c Mon Aug 24 05:03:59 2009
(r196497)
@@ -465,7 +465,6 @@ upgt_ioctl(struct ifnet *ifp, u_long cmd
 
switch (cmd) {
case SIOCSIFFLAGS:
-   mtx_lock(&Giant);
if (ifp->if_flags & IFF_UP) {
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
if ((ifp->if_flags ^ sc->sc_if_flags) &
@@ -482,7 +481,6 @@ upgt_ioctl(struct ifnet *ifp, u_long cmd
sc->sc_if_flags = ifp->if_flags;
if (startall)
ieee80211_start_all(ic);
-   mtx_unlock(&Giant);
break;
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196498 - head/sys/dev/usb

2009-08-23 Thread Alfred Perlstein
Author: alfred
Date: Mon Aug 24 05:05:38 2009
New Revision: 196498
URL: http://svn.freebsd.org/changeset/base/196498

Log:
   - Patch to allow USB controller to resume operation after
   being polled.
  
   - Remove the need for Giant from the USB HUB driver.
  
   - Leave device unconfigured instead of disabling the USB port
 when Huawei Autoinstall disk detection triggers. This should
 fix problems that the Huawei device is not detected after
 Autoinstall eject is issued.
   - Reported by: Nikolay Antsiferov
  
   - Fix memory use after free race for USB character devices.
   - Reported by: Lucius Windschuh
  
   - Factor out the enumeration lock into three functions to make the
   coming newbus lock conversion more easy.
- usbd_enum_lock
- usbd_enum_unlock
- usbd_enum_is_locked
  
  Submitted by: hps

Modified:
  head/sys/dev/usb/usb_dev.c
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_device.h
  head/sys/dev/usb/usb_handle_request.c
  head/sys/dev/usb/usb_hub.c
  head/sys/dev/usb/usb_process.c
  head/sys/dev/usb/usb_process.h
  head/sys/dev/usb/usb_transfer.c

Modified: head/sys/dev/usb/usb_dev.c
==
--- head/sys/dev/usb/usb_dev.c  Mon Aug 24 05:03:59 2009(r196497)
+++ head/sys/dev/usb/usb_dev.c  Mon Aug 24 05:05:38 2009(r196498)
@@ -217,7 +217,7 @@ usb_ref_device(struct usb_cdev_privdata 
 * We need to grab the sx-lock before grabbing the
 * FIFO refs to avoid deadlock at detach!
 */
-   sx_xlock(cpd->udev->default_sx + 1);
+   usbd_enum_lock(cpd->udev);
 
mtx_lock(&usb_ref_lock);
 
@@ -275,14 +275,12 @@ usb_ref_device(struct usb_cdev_privdata 
}
mtx_unlock(&usb_ref_lock);
 
-   if (crd->is_uref) {
-   mtx_lock(&Giant);   /* XXX */
-   }
return (0);
 
 error:
if (crd->is_uref) {
-   sx_unlock(cpd->udev->default_sx + 1);
+   usbd_enum_unlock(cpd->udev);
+
if (--(cpd->udev->refcount) == 0) {
cv_signal(cpd->udev->default_cv + 1);
}
@@ -334,10 +332,9 @@ usb_unref_device(struct usb_cdev_privdat
 
DPRINTFN(2, "cpd=%p is_uref=%d\n", cpd, crd->is_uref);
 
-   if (crd->is_uref) {
-   mtx_unlock(&Giant); /* XXX */
-   sx_unlock(cpd->udev->default_sx + 1);
-   }
+   if (crd->is_uref)
+   usbd_enum_unlock(cpd->udev);
+
mtx_lock(&usb_ref_lock);
if (crd->is_read) {
if (--(crd->rxfifo->refcount) == 0) {
@@ -1042,9 +1039,9 @@ usb_ioctl(struct cdev *dev, u_long cmd, 
 * reference if we need it!
 */
err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
-   if (err) {
+   if (err)
return (ENXIO);
-   }
+
fflags = cpd->fflags;
 
f = NULL;   /* set default value */

Modified: head/sys/dev/usb/usb_device.c
==
--- head/sys/dev/usb/usb_device.c   Mon Aug 24 05:03:59 2009
(r196497)
+++ head/sys/dev/usb/usb_device.c   Mon Aug 24 05:05:38 2009
(r196498)
@@ -402,11 +402,11 @@ usb_unconfigure(struct usb_device *udev,
uint8_t do_unlock;
 
/* automatic locking */
-   if (sx_xlocked(udev->default_sx + 1)) {
+   if (usbd_enum_is_locked(udev)) {
do_unlock = 0;
} else {
do_unlock = 1;
-   sx_xlock(udev->default_sx + 1);
+   usbd_enum_lock(udev);
}
 
/* detach all interface drivers */
@@ -442,9 +442,8 @@ usb_unconfigure(struct usb_device *udev,
udev->curr_config_no = USB_UNCONFIG_NO;
udev->curr_config_index = USB_UNCONFIG_INDEX;
 
-   if (do_unlock) {
-   sx_unlock(udev->default_sx + 1);
-   }
+   if (do_unlock)
+   usbd_enum_unlock(udev);
 }
 
 /**
@@ -472,11 +471,11 @@ usbd_set_config_index(struct usb_device 
DPRINTFN(6, "udev=%p index=%d\n", udev, index);
 
/* automatic locking */
-   if (sx_xlocked(udev->default_sx + 1)) {
+   if (usbd_enum_is_locked(udev)) {
do_unlock = 0;
} else {
do_unlock = 1;
-   sx_xlock(udev->default_sx + 1);
+   usbd_enum_lock(udev);
}
 
usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV);
@@ -585,9 +584,8 @@ done:
if (err) {
usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV);
}
-   if (do_unlock) {
-   sx_unlock(udev->default_sx + 1);
-   }
+   if (do_unlock)
+   usbd_enum_unlock(udev);

svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci

2009-09-01 Thread Alfred Perlstein
Author: alfred
Date: Wed Sep  2 02:12:07 2009
New Revision: 196746
URL: http://svn.freebsd.org/changeset/base/196746

Log:
  MFC: r196489,196498
  Critical USB bugfixes for 8.0
  
  Approved by:re

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/usb/input/ukbd.c
  stable/8/sys/dev/usb/usb_dev.c
  stable/8/sys/dev/usb/usb_device.c
  stable/8/sys/dev/usb/usb_device.h
  stable/8/sys/dev/usb/usb_handle_request.c
  stable/8/sys/dev/usb/usb_hub.c
  stable/8/sys/dev/usb/usb_process.c
  stable/8/sys/dev/usb/usb_process.h
  stable/8/sys/dev/usb/usb_transfer.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/usb/input/ukbd.c
==
--- stable/8/sys/dev/usb/input/ukbd.c   Wed Sep  2 00:39:59 2009
(r196745)
+++ stable/8/sys/dev/usb/input/ukbd.c   Wed Sep  2 02:12:07 2009
(r196746)
@@ -96,10 +96,14 @@ __FBSDID("$FreeBSD$");
 
 #if USB_DEBUG
 static int ukbd_debug = 0;
+static int ukbd_no_leds = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB ukbd");
 SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RW,
 &ukbd_debug, 0, "Debug level");
+SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RW,
+&ukbd_no_leds, 0, "Disables setting of keyboard leds");
+
 #endif
 
 #defineUPROTO_BOOT_KEYBOARD 1
@@ -165,6 +169,7 @@ struct ukbd_softc {
 #defineUKBD_FLAG_APPLE_EJECT   0x0040
 #defineUKBD_FLAG_APPLE_FN  0x0080
 #defineUKBD_FLAG_APPLE_SWAP0x0100
+#defineUKBD_FLAG_TIMER_RUNNING 0x0200
 
int32_t sc_mode;/* input mode (K_XLATE,K_RAW,K_CODE) */
int32_t sc_state;   /* shift/lock key state */
@@ -279,6 +284,25 @@ static device_attach_t ukbd_attach;
 static device_detach_t ukbd_detach;
 static device_resume_t ukbd_resume;
 
+static uint8_t
+ukbd_any_key_pressed(struct ukbd_softc *sc)
+{
+   uint8_t i;
+   uint8_t j;
+
+   for (j = i = 0; i < UKBD_NKEYCODE; i++)
+   j |= sc->sc_odata.keycode[i];
+
+   return (j ? 1 : 0);
+}
+
+static void
+ukbd_start_timer(struct ukbd_softc *sc)
+{
+   sc->sc_flags |= UKBD_FLAG_TIMER_RUNNING;
+   usb_callout_reset(&sc->sc_callout, hz / 40, &ukbd_timeout, sc);
+}
+
 static void
 ukbd_put_key(struct ukbd_softc *sc, uint32_t key)
 {
@@ -308,11 +332,15 @@ ukbd_do_poll(struct ukbd_softc *sc, uint
 
usbd_transfer_poll(sc->sc_xfer, UKBD_N_TRANSFER);
 
-   DELAY(1000);/* delay 1 ms */
+   /* Delay-optimised support for repetition of keys */
 
-   sc->sc_time_ms++;
+   if (ukbd_any_key_pressed(sc)) {
+   /* a key is pressed - need timekeeping */
+   DELAY(1000);
 
-   /* support repetition of keys: */
+   /* 1 millisecond has passed */
+   sc->sc_time_ms += 1;
+   }
 
ukbd_interrupt(sc);
 
@@ -470,7 +498,11 @@ ukbd_timeout(void *arg)
}
ukbd_interrupt(sc);
 
-   usb_callout_reset(&sc->sc_callout, hz / 40, &ukbd_timeout, sc);
+   if (ukbd_any_key_pressed(sc)) {
+   ukbd_start_timer(sc);
+   } else {
+   sc->sc_flags &= ~UKBD_FLAG_TIMER_RUNNING;
+   }
 }
 
 static uint8_t
@@ -582,6 +614,12 @@ ukbd_intr_callback(struct usb_xfer *xfer
}
 
ukbd_interrupt(sc);
+
+   if (!(sc->sc_flags & UKBD_FLAG_TIMER_RUNNING)) {
+   if (ukbd_any_key_pressed(sc)) {
+   ukbd_start_timer(sc);
+   }
+   }
}
case USB_ST_SETUP:
 tr_setup:
@@ -613,6 +651,11 @@ ukbd_set_leds_callback(struct usb_xfer *
uint8_t buf[2];
struct ukbd_softc *sc = usbd_xfer_softc(xfer);
 
+#if USB_DEBUG
+   if (ukbd_no_leds)
+   return;
+#endif
+
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
@@ -647,11 +690,11 @@ ukbd_set_leds_callback(struct usb_xfer *
usbd_xfer_set_frames(xfer, 2);
usbd_transfer_submit(xfer);
}
-   return;
+   break;
 
default:/* Error */
DPRINTFN(0, "error=%s\n", usbd_errstr(error));
-   return;
+   break;
}
 }
 
@@ -745,8 +788,6 @@ ukbd_attach(device_t dev)
uint16_t n;
uint16_t hid_len;
 
-   mtx_assert(&Giant, MA_OWNED);
-
kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0);
 
kbd->kb_data = (void *)sc;
@@ -831,7 +872,7 @@ 

Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci

2009-09-03 Thread Alfred Perlstein
* Mark Linimon  [090902 03:05] wrote:
> On Wed, Sep 02, 2009 at 02:12:07AM +0000, Alfred Perlstein wrote:
> >   MFC: r196489,196498
> >   Critical USB bugfixes for 8.0
> 
> Will this change anything for ports?

Don't think so, it's kernel fixes for crashdumps and memory handling.

-- 
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci

2009-09-03 Thread Alfred Perlstein
Since this information is available via "svn log -g"
maybe we can fix the commit email script to include that
infomation instead?

-Alfred


* Remko Lodder  [090901 23:13] wrote:
> On Wed, September 2, 2009 4:12 am, Alfred Perlstein wrote:
> > Author: alfred
> > Date: Wed Sep  2 02:12:07 2009
> > New Revision: 196746
> > URL: http://svn.freebsd.org/changeset/base/196746
> >
> > Log:
> >   MFC: r196489,196498
> >   Critical USB bugfixes for 8.0
> >
> 
> Dear Alfred (and hps!),
> 
> It would be awesome to see something more about this in the commit log. I
> needed to look up the specific revisions to see what changed. I always
> learned from Warner and people, that including the original commit
> message(s) saves a lot of time and makes it clear about what is being
> merged.
> 
> Can you help and include a bit more information next time please?
> 
> Thanks alot!
> 
> -- 
> /"\   Best regards,  | re...@freebsd.org
> \ /   Remko Lodder   | re...@efnet
>  Xhttp://www.evilcoder.org/  |
> / \   ASCII Ribbon Campaign  | Against HTML Mail and News
> 

-- 
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r227483 - head/usr.sbin/portsnap/portsnap

2011-11-12 Thread Alfred Perlstein
Author: alfred
Date: Sun Nov 13 03:18:57 2011
New Revision: 227483
URL: http://svn.freebsd.org/changeset/base/227483

Log:
  Utilize shell's IFS instead of forking ~6 processes to
  handle splitting input files on a '|'.  This greatly
  reduces the time taken to process several databases
  during the update process.
  
  Additionally add some more debug logging.

Modified:
  head/usr.sbin/portsnap/portsnap/portsnap.sh

Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh
==
--- head/usr.sbin/portsnap/portsnap/portsnap.sh Sun Nov 13 03:01:58 2011
(r227482)
+++ head/usr.sbin/portsnap/portsnap/portsnap.sh Sun Nov 13 03:18:57 2011
(r227483)
@@ -570,14 +570,16 @@ fetch_metadata_sanity() {
 
 # Take a list of ${oldhash}|${newhash} and output a list of needed patches
 fetch_make_patchlist() {
-   grep -vE "^([0-9a-f]{64})\|\1$" | 
-   while read LINE; do
-   X=`echo ${LINE} | cut -f 1 -d '|'`
-   Y=`echo ${LINE} | cut -f 2 -d '|'`
-   if [ -f "files/${Y}.gz" ]; then continue; fi
-   if [ ! -f "files/${X}.gz" ]; then continue; fi
-   echo "${LINE}"
+   IFS='|'
+   echo "" 1>${QUIETREDIR}
+   grep -vE "^([0-9a-f]{64})\|\1$" |
+   while read X Y; do
+   printf "Processing: $X $Y ...\r" 1>${QUIETREDIR}
+   if [ -f "files/${Y}.gz" -o ! -f "files/${X}.gz" ]; then 
continue; fi
+   echo "${X}|${Y}"
done
+   echo "" 1>${QUIETREDIR}
+   IFS=
 }
 
 # Print user-friendly progress statistics
@@ -692,9 +694,8 @@ fetch_update() {
 
 # Attempt to apply metadata patches
echo -n "Applying metadata patches... "
-   while read LINE; do
-   X=`echo ${LINE} | cut -f 1 -d '|'`
-   Y=`echo ${LINE} | cut -f 2 -d '|'`
+   IFS='|'
+   while read X Y; do
if [ ! -f "${X}-${Y}.gz" ]; then continue; fi
gunzip -c < ${X}-${Y}.gz > diff
gunzip -c < files/${X}.gz > OLD
@@ -707,6 +708,7 @@ fetch_update() {
fi
rm -f diff OLD NEW ${X}-${Y}.gz ptmp
done < patchlist 2>${QUIETREDIR}
+   IFS=
echo "done."
 
 # Update metadata without patches
@@ -724,16 +726,19 @@ fetch_update() {
2>${QUIETREDIR}
 
while read Y; do
+   echo -n "Verifying ${Y}... " 1>${QUIETREDIR}
if [ `gunzip -c < ${Y}.gz | ${SHA256} -q` = ${Y} ]; then
mv ${Y}.gz files/${Y}.gz
else
echo "metadata is corrupt."
return 1
fi
+   echo "ok." 1>${QUIETREDIR}
done < filelist
echo "done."
 
 # Extract the index
+   echo -n "Extracting index... " 1>${QUIETREDIR}
gunzip -c files/`look INDEX tINDEX.new |
cut -f 2 -d '|'`.gz > INDEX.new
fetch_index_sanity || return 1
@@ -754,8 +759,10 @@ fetch_update() {
fi
 
 # Generate a list of wanted ports patches
+   echo -n "Generating list of wanted patches..." 1>${QUIETREDIR}
join -t '|' -o 1.2,2.2 INDEX INDEX.new |
fetch_make_patchlist > patchlist
+   echo " done." 1>${QUIETREDIR}
 
 # Attempt to fetch ports patches
echo -n "Fetching `wc -l < patchlist | tr -d ' '` "
@@ -766,11 +773,18 @@ fetch_update() {
echo "done."
 
 # Attempt to apply ports patches
-   echo -n "Applying patches... "
-   while read LINE; do
-   X=`echo ${LINE} | cut -f 1 -d '|'`
-   Y=`echo ${LINE} | cut -f 2 -d '|'`
-   if [ ! -f "${X}-${Y}" ]; then continue; fi
+   PATCHCNT=`wc -l patchlist`
+   echo "Applying patches... "
+   IFS='|'
+   I=0
+   while read X Y; do
+   I=$(($I + 1))
+   F="${X}-${Y}"
+   if [ ! -f "${F}" ]; then
+   printf "  Skipping ${F} (${I} of ${PATCHCNT}).\r"
+   continue;
+   fi
+   echo "  Processing ${F}..." 1>${QUIETREDIR}
gunzip -c < files/${X}.gz > OLD
${BSPATCH} OLD NEW ${X}-${Y}
if [ `${SHA256} -q NEW` = ${Y} ]; then
@@ -779,6 +793,7 @@ fetch_update() {
fi
rm -f diff OLD NEW ${X}-${Y}
done < patchlist 2>${QUIETREDIR}
+   IFS=
echo "done."
 
 # Update ports without patches
@@ -795,7 +810,10 @@ fetch_update() {
xargs ${XARGST} ${PHTTPGET} ${SERVERNAME}   \
2>${QUIETREDIR}
 
+   I=0
while read Y; do
+   I=$(($I + 1))
+   printf "   Processing ${Y} (${I} of ${PATCHCNT}).\r" 
1>${QUIETREDIR}
if [ `gunzip -c < ${Y}.gz | ${SHA256} -q` = ${Y} ]; then
mv ${Y}.gz files/${Y}.gz
else

Re: svn commit: r227483 - head/usr.sbin/portsnap/portsnap

2011-11-12 Thread Alfred Perlstein
* Garrett Cooper  [12 19:25] wrote:
> On Nov 12, 2011, at 7:18 PM, Alfred Perlstein wrote:
> 
> > Author: alfred
> > Date: Sun Nov 13 03:18:57 2011
> > New Revision: 227483
> > URL: http://svn.freebsd.org/changeset/base/227483
> > 
> > Log:
> >  Utilize shell's IFS instead of forking ~6 processes to
> >  handle splitting input files on a '|'.  This greatly
> >  reduces the time taken to process several databases
> >  during the update process.
> > 
> >  Additionally add some more debug logging.
> > 
> > Modified:
> >  head/usr.sbin/portsnap/portsnap/portsnap.sh
> > 
> 
>   Wouldn't
> 
> oldIFS=$IFS
> # Blah blah
> IFS=$oldIFS
> 
>   be better?

Meh, it's hard to do it in some of the code because of the
'return' in the middle of the logic and in the other places
I didn't really care that much.

That said, I'll happily take a patch to clean it up some.

Just watch the logic, it's hairy in the places I used
'local'.

-- 
- Alfred Perlstein
.- VMOA #5191, 03 vmax, 92 gs500, 85 ch250, 07 zx10
.- FreeBSD committer
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r227484 - head/usr.sbin/portsnap/portsnap

2011-11-12 Thread Alfred Perlstein
Author: alfred
Date: Sun Nov 13 06:39:49 2011
New Revision: 227484
URL: http://svn.freebsd.org/changeset/base/227484

Log:
  Fix spelling of extract.
  
  Pointed out by: gcooper

Modified:
  head/usr.sbin/portsnap/portsnap/portsnap.sh

Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh
==
--- head/usr.sbin/portsnap/portsnap/portsnap.sh Sun Nov 13 03:18:57 2011
(r227483)
+++ head/usr.sbin/portsnap/portsnap/portsnap.sh Sun Nov 13 06:39:49 2011
(r227484)
@@ -935,7 +935,7 @@ extract_run() {
extract_indices
 }
 
-update_run_exract() {
+update_run_extract() {
local IFS='|'
 
 # Install new files
@@ -999,7 +999,7 @@ update_run() {
fi
echo "done."
 
-   update_run_exract || return 1
+   update_run_extract || return 1
extract_metadata
extract_indices
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2011-11-13 Thread Alfred Perlstein
Author: alfred
Date: Mon Nov 14 07:12:10 2011
New Revision: 227496
URL: http://svn.freebsd.org/changeset/base/227496

Log:
  Constify args to copyiniov and copyinuio.

Modified:
  head/sys/kern/subr_uio.c
  head/sys/sys/uio.h

Modified: head/sys/kern/subr_uio.c
==
--- head/sys/kern/subr_uio.cMon Nov 14 00:45:25 2011(r227495)
+++ head/sys/kern/subr_uio.cMon Nov 14 07:12:10 2011(r227496)
@@ -437,7 +437,7 @@ copyinstrfrom(const void * __restrict sr
 }
 
 int
-copyiniov(struct iovec *iovp, u_int iovcnt, struct iovec **iov, int error)
+copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, int 
error)
 {
u_int iovlen;
 
@@ -455,7 +455,7 @@ copyiniov(struct iovec *iovp, u_int iovc
 }
 
 int
-copyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop)
+copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop)
 {
struct iovec *iov;
struct uio *uio;

Modified: head/sys/sys/uio.h
==
--- head/sys/sys/uio.h  Mon Nov 14 00:45:25 2011(r227495)
+++ head/sys/sys/uio.h  Mon Nov 14 07:12:10 2011(r227496)
@@ -89,11 +89,11 @@ struct vm_page;
 struct uio *cloneuio(struct uio *uiop);
 intcopyinfrom(const void * __restrict src, void * __restrict dst,
size_t len, int seg);
-intcopyiniov(struct iovec *iovp, u_int iovcnt, struct iovec **iov,
+intcopyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov,
int error);
 intcopyinstrfrom(const void * __restrict src, void * __restrict dst,
size_t len, size_t * __restrict copied, int seg);
-intcopyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop);
+intcopyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop);
 intcopyout_map(struct thread *td, vm_offset_t *addr, size_t sz);
 intcopyout_unmap(struct thread *td, vm_offset_t addr, size_t sz);
 intuiomove(void *cp, int n, struct uio *uio);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r227483 - head/usr.sbin/portsnap/portsnap

2011-11-14 Thread Alfred Perlstein
* Doug Barton  [13 13:26] wrote:
> On 11/13/2011 04:21, Jilles Tjoelker wrote:
> > Given that you are already using 'local', why not use it everywhere? You
> > may need to split up some functions to do this.
> 
> You might want to look more deeply at the portsnap code before you
> recommend that Alfred take responsibility for roto-tilling it. :)  I
> looked at it, and ran away screaming. The fact that Alfred is willing to
> take on the task of making some incremental improvements is a feature.

http://memegenerator.net/cache/instances/400x/10/11149/11417307.jpg

-- 
- Alfred Perlstein
.- VMOA #5191, 03 vmax, 92 gs500, 85 ch250, 07 zx10
.- FreeBSD committer
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r227549 - stable/7/sys/nfsclient

2011-11-16 Thread Alfred Perlstein
Rick, I have a question, what will happen if the nfs_freesillyrename()
call happens when the mount is down?  Will it block the taskqueue_thread?

If so, it might make more sense to make a taskqueue per mount point.

If not, excuse me. :-)

-Alfred

* Rick Macklem  [15 21:05] wrote:
> Author: rmacklem
> Date: Wed Nov 16 05:05:13 2011
> New Revision: 227549
> URL: http://svn.freebsd.org/changeset/base/227549
> 
> Log:
>   MFC: r224604
>   Fix a LOR in the NFS client which could cause a deadlock.
>   This was reported to the mailing list freebsd-...@freebsd.org
>   on July 21, 2011 under the subject "LOR with nfsclient sillyrename".
>   The LOR occurred when nfs_inactive() called vrele(sp->s_dvp)
>   while holding the vnode lock on the file in s_dvp. This patch
>   modifies the client so that it performs the vrele(sp->s_dvp)
>   as a separate task to avoid the LOR. This fix was discussed
>   with jhb@ and kib@, who both proposed variations of it.
> 
> Modified:
>   stable/7/sys/nfsclient/nfs_node.c
>   stable/7/sys/nfsclient/nfsnode.h
> Directory Properties:
>   stable/7/sys/   (props changed)
>   stable/7/sys/cddl/contrib/opensolaris/   (props changed)
>   stable/7/sys/contrib/dev/acpica/   (props changed)
>   stable/7/sys/contrib/pf/   (props changed)
> 
> Modified: stable/7/sys/nfsclient/nfs_node.c
> ==
> --- stable/7/sys/nfsclient/nfs_node.c Wed Nov 16 02:52:24 2011
> (r227548)
> +++ stable/7/sys/nfsclient/nfs_node.c Wed Nov 16 05:05:13 2011
> (r227549)
> @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -59,6 +60,8 @@ __FBSDID("$FreeBSD$");
>  
>  static uma_zone_t nfsnode_zone;
>  
> +static void  nfs_freesillyrename(void *arg, __unused int pending);
> +
>  #define TRUE 1
>  #define  FALSE   0
>  
> @@ -191,6 +194,20 @@ nfs_nget(struct mount *mntp, nfsfh_t *fh
>   return (0);
>  }
>  
> +/*
> + * Do the vrele(sp->s_dvp) as a separate task in order to avoid a
> + * deadlock because of a LOR when vrele() locks the directory vnode.
> + */
> +static void
> +nfs_freesillyrename(void *arg, __unused int pending)
> +{
> + struct sillyrename *sp;
> +
> + sp = arg;
> + vrele(sp->s_dvp);
> + free(sp, M_NFSREQ);
> +}
> +
>  int
>  nfs_inactive(struct vop_inactive_args *ap)
>  {
> @@ -213,8 +230,8 @@ nfs_inactive(struct vop_inactive_args *a
>*/
>   (sp->s_removeit)(sp);
>   crfree(sp->s_cred);
> - vrele(sp->s_dvp);
> - FREE((caddr_t)sp, M_NFSREQ);
> + TASK_INIT(&sp->s_task, 0, nfs_freesillyrename, sp);
> + taskqueue_enqueue(taskqueue_thread, &sp->s_task);
>   }
>   np->n_flag &= NMODIFIED;
>   return (0);
> 
> Modified: stable/7/sys/nfsclient/nfsnode.h
> ==
> --- stable/7/sys/nfsclient/nfsnode.h  Wed Nov 16 02:52:24 2011
> (r227548)
> +++ stable/7/sys/nfsclient/nfsnode.h  Wed Nov 16 05:05:13 2011
> (r227549)
> @@ -36,6 +36,7 @@
>  #ifndef _NFSCLIENT_NFSNODE_H_
>  #define _NFSCLIENT_NFSNODE_H_
>  
> +#include 
>  #if !defined(_NFSCLIENT_NFS_H_) && !defined(_KERNEL)
>  #include 
>  #endif
> @@ -45,6 +46,7 @@
>   * can be removed by nfs_inactive()
>   */
>  struct sillyrename {
> + struct  task s_task;
>   struct  ucred *s_cred;
>   struct  vnode *s_dvp;
>   int (*s_removeit)(struct sillyrename *sp);

-- 
- Alfred Perlstein
.- VMOA #5191, 03 vmax, 92 gs500, 85 ch250, 07 zx10
.- FreeBSD committer
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r227549 - stable/7/sys/nfsclient

2011-11-17 Thread Alfred Perlstein
* Rick Macklem  [16 21:16] wrote:
> Alfred Perlstein wrote:
> > Rick, I have a question, what will happen if the nfs_freesillyrename()
> > call happens when the mount is down? Will it block the
> > taskqueue_thread?
> > 
> > If so, it might make more sense to make a taskqueue per mount point.
> > 
> > If not, excuse me. :-)
> > 
> Well, all nfs_freesillyrename() does is a vrele() on the parent
> directory when the file node's use count has gone to 0.
> I can't think why that would do any RPC, so I don't see a problem?
> If you do see a problem with vrele() on the directory, please let me
> know.
> 
> The problem this fixes is a LOR that would occur when the vrele() on
> the directory was done by the thread doing VOP_INACTIVE(), since it
> already has the file vnode lock and the vrele() was locking the parent
> directory. This could cause a fairly rare deadlock.

Yes, I understand the VFS deadlock.

I see, I didn't realize the call was against the directory,
thank you for explaining.

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


svn commit: r218060 - stable/8/usr.sbin/portsnap/portsnap

2011-01-29 Thread Alfred Perlstein
Author: alfred
Date: Sat Jan 29 08:14:47 2011
New Revision: 218060
URL: http://svn.freebsd.org/changeset/base/218060

Log:
  MFC: 'alfred' command.

Modified:
  stable/8/usr.sbin/portsnap/portsnap/portsnap.sh

Modified: stable/8/usr.sbin/portsnap/portsnap/portsnap.sh
==
--- stable/8/usr.sbin/portsnap/portsnap/portsnap.sh Sat Jan 29 07:22:33 
2011(r218059)
+++ stable/8/usr.sbin/portsnap/portsnap/portsnap.sh Sat Jan 29 08:14:47 
2011(r218060)
@@ -140,7 +140,7 @@ parse_cmdline() {
if [ ! -z "${SERVERNAME}" ]; then usage; fi
shift; SERVERNAME="$1"
;;
-   cron | extract | fetch | update)
+   cron | extract | fetch | update | alfred)
COMMANDS="${COMMANDS} $1"
;;
*)
@@ -1040,6 +1040,22 @@ cmd_update() {
update_run || exit 1
 }
 
+# Alfred command.  Run 'fetch' or 'cron' depending on
+# whether stdin is a terminal; then run 'update' or
+# 'extract' depending on whether ${PORTSDIR} exists.
+cmd_alfred() {
+if [ -t 0 ]; then
+   cmd_fetch
+else
+   cmd_cron
+fi
+if [ -d ${PORTSDIR} ]; then
+   cmd_update
+else
+   cmd_extract
+fi
+}
+
  Entry point
 
 # Make sure we find utilities from the base system
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r218060 - stable/8/usr.sbin/portsnap/portsnap

2011-01-31 Thread Alfred Perlstein
> On Sat, 2011-01-29 at 08:14 +0000, Alfred Perlstein wrote:
> > Author: alfred
> > Date: Sat Jan 29 08:14:47 2011
> > New Revision: 218060
> > URL: http://svn.freebsd.org/changeset/base/218060
> > 
> > Log:
> >   MFC: 'alfred' command.
> > 
> > Modified:
> >   stable/8/usr.sbin/portsnap/portsnap/portsnap.sh
> 
> Hi,
> 
> Firstly, thanks for merging this, although it would be great if it could
> be given a better name.   Possibly the command should be called "auto".
> 
> This merge also appears to be missing the related mergeinfo.
> 
> You should be able to fix this with:
> cd stable/8/usr.sbin/portsnap
> svn merge --record-only -c 201251 $FBSD/usr.sbin/portsnap .
> 
> Then verify it looks correct with an "svn diff" before committing.

I'm fine with 'auto'.

Anyone object?

Also will do the mergehistory fixup.  Thank you for the quick howto.

-- 
- Alfred Perlstein
.- VMOA #5191, 03 vmax, 92 gs500, 85 ch250, 07 zx10
.- FreeBSD committer
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r251507 - head/usr.sbin/portsnap/portsnap

2013-06-17 Thread Alfred Perlstein

On 6/17/13 11:59 AM, Dmitry Morozovsky wrote:

On Sun, 16 Jun 2013, Gavin Atkinson wrote:


   Make 'portsnap alfred' overwrite ports tree if it's not created by a
   portsnap.

FWIW, the 'alfred' command is poorly named and is used by other
projects (ISTR portshaker uses it).  It should also be documented.

I would love to see this renamed - unfortunately the most obvious name for
it "update" is already taken.  I wonder if it should be named "auto"?

Hmm, 'forceupdate' maybe, in brief mimic to /etc/rc.d/* ?



I've already told MANY people that it's easy to use when they just run 
"portsnap alfred".


I think we need to leave it as this point.  An alias is fine.

--
Alfred Perlstein
VP Software Engineering, iXsystems

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


Re: svn commit: r251894 - in head: lib/libmemstat sys/vm

2013-06-18 Thread Alfred Perlstein

On 6/18/13 4:37 AM, Gleb Smirnoff wrote:

On Tue, Jun 18, 2013 at 10:25:08AM +0200, Andre Oppermann wrote:
A> There used to be a problem with per CPU caches accumulating large amounts
A> of items without freeing back to the global (or socket) pool.
A>
A> Do these updates to UMA change this situation and/or do you have further
A> improvements coming up?

This is especially a problem with ZFS, which utilizes UMA extensively.

IMHO, we need a flag for uma_zcreate() that would disable per CPU caches, so
that certain zones (ZFS at least) would have them off.

It might be a good idea to force this flag on every zone that has allocation >=
then the page size.

What about people running with 256GB+ ram?  Do they also want the per 
cpu caches off?


--
Alfred Perlstein
VP Software Engineering, iXsystems

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


Re: svn commit: r251894 - in head: lib/libmemstat sys/vm

2013-06-18 Thread Alfred Perlstein

On 6/18/13 5:21 PM, Jeff Roberson wrote:

On Tue, 18 Jun 2013, Alfred Perlstein wrote:


On 6/18/13 4:37 AM, Gleb Smirnoff wrote:

On Tue, Jun 18, 2013 at 10:25:08AM +0200, Andre Oppermann wrote:
A> There used to be a problem with per CPU caches accumulating large 
amounts

A> of items without freeing back to the global (or socket) pool.
A>
A> Do these updates to UMA change this situation and/or do you have 
further

A> improvements coming up?

This is especially a problem with ZFS, which utilizes UMA extensively.

IMHO, we need a flag for uma_zcreate() that would disable per CPU 
caches, so

that certain zones (ZFS at least) would have them off.

It might be a good idea to force this flag on every zone that has 
allocation >=

then the page size.

What about people running with 256GB+ ram?  Do they also want the per 
cpu caches off?


If you look at the new system there is a static threshold for the 
initial item size required for different sized per-cpu buckets. What 
might make sense is to tune this size based on available memory.  For 
what it's worth I looked at solaris settings and they cache roughly 4x 
as much on a per-cpu basis.


The new system should tend to cache less of large and infrequent 
allocations vs the old system.  I can't say yet whether it is still a 
problem.


I have an implementation of vmem to replace using vm_maps for 
kmem_map, buffer_map, etc. which may resolve the zfs allocation 
problems.  I hope to get this in over the next few weeks.




That looks really exciting Jeff.  Thank you.

I'm hoping we can give back some testing numbers when it goes in.

-Alfred

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


svn commit: r252683 - head/sys/kern

2013-07-03 Thread Alfred Perlstein
Author: alfred
Date: Thu Jul  4 05:53:05 2013
New Revision: 252683
URL: http://svnweb.freebsd.org/changeset/base/252683

Log:
  The change in r236456 (atomic_store_rel not locked) exposed a bug
  in the ithread code where we could lose ithread interrupts if
  intr_event_schedule_thread() is called while the ithread is already
  running.  Effectively memory writes could be ordered incorrectly
  such that the unatomic write of 0 to ithd->it_need (in ithread_loop)
  could be delayed until after it was set to be triggered again by
  intr_event_schedule_thread().
  
  This was particularly a big problem for CAM because CAM optimizes
  scheduling of ithreads such that it only signals camisr() when it
  queues to an empty queue.  This means that additional completion
  events would not unstick CAM and quickly lead to a complete lockup
  of the CAM stack.
  
  To fix this use atomics in all places where ithd->it_need is accessed.
  
  Submitted by: delphij, mav
  Obtained from: TrueOS, iXsystems
  MFC After: 1 week

Modified:
  head/sys/kern/kern_intr.c

Modified: head/sys/kern/kern_intr.c
==
--- head/sys/kern/kern_intr.c   Thu Jul  4 05:35:56 2013(r252682)
+++ head/sys/kern/kern_intr.c   Thu Jul  4 05:53:05 2013(r252683)
@@ -841,7 +841,7 @@ ok:
 * again and remove this handler if it has already passed
 * it on the list.
 */
-   ie->ie_thread->it_need = 1;
+   atomic_store_rel_int(&ie->ie_thread->it_need, 1);
} else
TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
thread_unlock(ie->ie_thread->it_thread);
@@ -912,7 +912,7 @@ intr_event_schedule_thread(struct intr_e
 * running.  Then, lock the thread and see if we actually need to
 * put it on the runqueue.
 */
-   it->it_need = 1;
+   atomic_store_rel_int(&it->it_need, 1);
thread_lock(td);
if (TD_AWAITING_INTR(td)) {
CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
@@ -990,7 +990,7 @@ ok:
 * again and remove this handler if it has already passed
 * it on the list.
 */
-   it->it_need = 1;
+   atomic_store_rel_int(&it->it_need, 1);
} else
TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
thread_unlock(it->it_thread);
@@ -1066,7 +1066,7 @@ intr_event_schedule_thread(struct intr_e
 * running.  Then, lock the thread and see if we actually need to
 * put it on the runqueue.
 */
-   it->it_need = 1;
+   atomic_store_rel_int(&it->it_need, 1);
thread_lock(td);
if (TD_AWAITING_INTR(td)) {
CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
@@ -1247,7 +1247,7 @@ intr_event_execute_handlers(struct proc 
 * interrupt threads always invoke all of their handlers.
 */
if (ie->ie_flags & IE_SOFT) {
-   if (!ih->ih_need)
+   if (atomic_load_acq_int(&ih->ih_need) == 0)
continue;
else
atomic_store_rel_int(&ih->ih_need, 0);
@@ -1349,7 +1349,7 @@ ithread_loop(void *arg)
 * we are running, it will set it_need to note that we
 * should make another pass.
 */
-   while (ithd->it_need) {
+   while (atomic_load_acq_int(&ithd->it_need) != 0) {
/*
 * This might need a full read and write barrier
 * to make sure that this write posts before any
@@ -1368,7 +1368,8 @@ ithread_loop(void *arg)
 * set again, so we have to check it again.
 */
thread_lock(td);
-   if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
+   if ((atomic_load_acq_int(&ithd->it_need) == 0) &&
+   !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
TD_SET_IWAIT(td);
ie->ie_count = 0;
mi_switch(SW_VOL | SWT_IWAIT, NULL);
@@ -1529,7 +1530,7 @@ ithread_loop(void *arg)
 * we are running, it will set it_need to note that we
 * should make another pass.
 */
-   while (ithd->it_need) {
+   while (atomic_load_acq_int(&ithd->it_need) != 0) {
/*
 * This might need a full read and write barrier
 * to make sure that this write posts before any
@@ -1551,7 +1552,8 @@ ithread_loop(void *arg)
 * set again, so we have to check it again.
 */
thread_lock(td);
-   if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT)))

svn commit: r253002 - head

2013-07-07 Thread Alfred Perlstein
Author: alfred
Date: Sun Jul  7 20:39:11 2013
New Revision: 253002
URL: http://svnweb.freebsd.org/changeset/base/253002

Log:
  Document tip on how to build all kernels quickly.

Modified:
  head/Makefile

Modified: head/Makefile
==
--- head/Makefile   Sun Jul  7 19:58:14 2013(r253001)
+++ head/Makefile   Sun Jul  7 20:39:11 2013(r253002)
@@ -32,6 +32,12 @@
 # targets - Print a list of supported TARGET/TARGET_ARCH pairs
 #   for world and kernel targets.
 # toolchains  - Build a toolchain for all world and kernel targets.
+# 
+# "quick" way to test all kernel builds:
+#  _jflag=`sysctl -n hw.ncpu`
+#  _jflag=$(($_jflag * 2))
+#  [ $_jflag -gt 12 ] && _jflag=12
+#  make universe -DMAKE_JUST_KERNELS JFLAG=${jflag}
 #
 # This makefile is simple by design. The FreeBSD make automatically reads
 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r253003 - head

2013-07-07 Thread Alfred Perlstein
Author: alfred
Date: Sun Jul  7 20:44:04 2013
New Revision: 253003
URL: http://svnweb.freebsd.org/changeset/base/253003

Log:
  Correct typo specifying jflags.

Modified:
  head/Makefile

Modified: head/Makefile
==
--- head/Makefile   Sun Jul  7 20:39:11 2013(r253002)
+++ head/Makefile   Sun Jul  7 20:44:04 2013(r253003)
@@ -37,7 +37,7 @@
 #  _jflag=`sysctl -n hw.ncpu`
 #  _jflag=$(($_jflag * 2))
 #  [ $_jflag -gt 12 ] && _jflag=12
-#  make universe -DMAKE_JUST_KERNELS JFLAG=${jflag}
+#  make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
 #
 # This makefile is simple by design. The FreeBSD make automatically reads
 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253002 - head

2013-07-07 Thread Alfred Perlstein

On 7/7/13 2:01 PM, Garrett Cooper wrote:

Why the magic number 12?


Numbers higher seem to result in worse performance as reported by some 
members of my team.


-Alfred



Sent from my iPhone

On Jul 7, 2013, at 1:39 PM, Alfred Perlstein  wrote:


Author: alfred
Date: Sun Jul  7 20:39:11 2013
New Revision: 253002
URL: http://svnweb.freebsd.org/changeset/base/253002

Log:
  Document tip on how to build all kernels quickly.

Modified:
  head/Makefile

Modified: head/Makefile
==
--- head/MakefileSun Jul  7 19:58:14 2013(r253001)
+++ head/MakefileSun Jul  7 20:39:11 2013(r253002)
@@ -32,6 +32,12 @@
# targets - Print a list of supported TARGET/TARGET_ARCH pairs
#   for world and kernel targets.
# toolchains  - Build a toolchain for all world and kernel targets.
+#
+# "quick" way to test all kernel builds:
+#_jflag=`sysctl -n hw.ncpu`
+#_jflag=$(($_jflag * 2))
+#[ $_jflag -gt 12 ] && _jflag=12
+#make universe -DMAKE_JUST_KERNELS JFLAG=${jflag}
#
# This makefile is simple by design. The FreeBSD make automatically reads
# the /usr/share/mk/sys.mk unless the -m argument is specified on the
___
svn-src-h...@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-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r253007 - in head/sys: kern net80211 sys

2013-07-07 Thread Alfred Perlstein
Author: alfred
Date: Sun Jul  7 21:39:37 2013
New Revision: 253007
URL: http://svnweb.freebsd.org/changeset/base/253007

Log:
  Make kassert_printf use __printflike.
  
  Fix associated errors/warnings while I'm here.
  
  Requested by: avg

Modified:
  head/sys/kern/subr_witness.c
  head/sys/kern/vfs_bio.c
  head/sys/net80211/ieee80211_output.c
  head/sys/sys/systm.h

Modified: head/sys/kern/subr_witness.c
==
--- head/sys/kern/subr_witness.cSun Jul  7 21:23:58 2013
(r253006)
+++ head/sys/kern/subr_witness.cSun Jul  7 21:39:37 2013
(r253007)
@@ -1138,12 +1138,16 @@ witness_checkorder(struct lock_object *l
iclass = LOCK_CLASS(interlock);
lock1 = find_instance(lock_list, interlock);
if (lock1 == NULL)
-   kassert_panic("interlock (%s) %s not locked @ %s:%d",
+   kassert_panic(
+   "interlock (%s) %s not locked while locking"
+   " %s @ %s:%d",
iclass->lc_name, interlock->lo_name,
flags & LOP_EXCLUSIVE ? "exclusive" : "shared",
fixup_filename(file), line);
else if ((lock1->li_flags & LI_RECURSEMASK) != 0)
-   kassert_panic("interlock (%s) %s recursed @ %s:%d",
+   kassert_panic(
+   "interlock (%s) %s recursed while locking %s"
+   " @ %s:%d",
iclass->lc_name, interlock->lo_name,
flags & LOP_EXCLUSIVE ? "exclusive" : "shared",
fixup_filename(file), line);

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Sun Jul  7 21:23:58 2013(r253006)
+++ head/sys/kern/vfs_bio.c Sun Jul  7 21:39:37 2013(r253007)
@@ -4485,8 +4485,8 @@ bdata2bio(struct buf *bp, struct bio *bi
bip->bio_flags |= BIO_UNMAPPED;
KASSERT(round_page(bip->bio_ma_offset + bip->bio_length) /
PAGE_SIZE == bp->b_npages,
-   ("Buffer %p too short: %d %d %d", bp, bip->bio_ma_offset,
-   bip->bio_length, bip->bio_ma_n));
+   ("Buffer %p too short: %d %lld %d", bp, bip->bio_ma_offset,
+   (long long)bip->bio_length, bip->bio_ma_n));
} else {
bip->bio_data = bp->b_data;
bip->bio_ma = NULL;

Modified: head/sys/net80211/ieee80211_output.c
==
--- head/sys/net80211/ieee80211_output.cSun Jul  7 21:23:58 2013
(r253006)
+++ head/sys/net80211/ieee80211_output.cSun Jul  7 21:39:37 2013
(r253007)
@@ -1022,7 +1022,7 @@ ieee80211_mbuf_adjust(struct ieee80211va
return NULL;
}
KASSERT(needed_space <= MHLEN,
-   ("not enough room, need %u got %zu\n", needed_space, 
MHLEN));
+   ("not enough room, need %u got %d\n", needed_space, MHLEN));
/*
 * Setup new mbuf to have leading space to prepend the
 * 802.11 header and any crypto header bits that are

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hSun Jul  7 21:23:58 2013(r253006)
+++ head/sys/sys/systm.hSun Jul  7 21:39:37 2013(r253007)
@@ -74,7 +74,7 @@ extern int vm_guest;  /* Running as virt
 enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN };
 
 #if defined(WITNESS) || defined(INVARIANTS)
-void   kassert_panic(const char *fmt, ...);
+void   kassert_panic(const char *fmt, ...)  __printflike(1, 2);
 #endif
 
 #ifdef INVARIANTS  /* The option is always available */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253002 - head

2013-07-07 Thread Alfred Perlstein

On 7/7/13 2:40 PM, Andriy Gapon wrote:

on 08/07/2013 00:15 Alfred Perlstein said the following:

On 7/7/13 2:01 PM, Garrett Cooper wrote:

Why the magic number 12?

Numbers higher seem to result in worse performance as reported by some members
of my team.

Should we really commit all "notes to self" or "my team's knowledge base" to
FreeBSD source code like this?


I would hope so!  At least in comments, that way we can all help each other.

Otherwise each time another person comes along they are subject to 
having to discover the same things that I did.


What is the point of listing 10+ make targets if someone coming in 
doesn't know which ones to run and how to run them optimally in order to 
ensure a safe build?  Do you not agree that more of this sort of 
documentation should be in the code instead of having to ask on IRC?


For the record I checked multiple pages in developer primer and scoured 
makefiles for a while before giving up and asking on IRC.  I figured it 
would be helpful for the next clueless goon that came in and tried to 
make things better if I recorded my experience to guide them.


I hold no strong feelings towards the comments, other than they should 
be preserved in some form, or maybe even turned into a workable target 
for people that don't want or can not hold all that context in their brains.


-Alfred





On Jul 7, 2013, at 1:39 PM, Alfred Perlstein  wrote:


Author: alfred
Date: Sun Jul  7 20:39:11 2013
New Revision: 253002
URL: http://svnweb.freebsd.org/changeset/base/253002

Log:
   Document tip on how to build all kernels quickly.

Modified:
   head/Makefile

Modified: head/Makefile
==
--- head/MakefileSun Jul  7 19:58:14 2013(r253001)
+++ head/MakefileSun Jul  7 20:39:11 2013(r253002)
@@ -32,6 +32,12 @@
# targets - Print a list of supported TARGET/TARGET_ARCH pairs
#   for world and kernel targets.
# toolchains  - Build a toolchain for all world and kernel targets.
+#
+# "quick" way to test all kernel builds:
+#_jflag=`sysctl -n hw.ncpu`
+#_jflag=$(($_jflag * 2))
+#[ $_jflag -gt 12 ] && _jflag=12
+#make universe -DMAKE_JUST_KERNELS JFLAG=${jflag}
#
# This makefile is simple by design. The FreeBSD make automatically reads
# the /usr/share/mk/sys.mk unless the -m argument is specified on the
___
svn-src-h...@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-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253002 - head

2013-07-08 Thread Alfred Perlstein

On 7/8/13 4:24 PM, Garrett Cooper wrote:

On Mon, Jul 8, 2013 at 2:13 PM, John Baldwin  wrote:

On Monday, July 08, 2013 2:23:31 am Garrett Cooper wrote:

On Sun, Jul 7, 2013 at 7:25 PM, Garrett Cooper 

wrote:

On Jul 7, 2013, at 2:15 PM, Alfred Perlstein  wrote:


On 7/7/13 2:01 PM, Garrett Cooper wrote:

Why the magic number 12?

Numbers higher seem to result in worse performance as reported by some

members of my team.

The suggestion is good in spirit, but this doesn't justify the reasoning

for this recommendation for all cases.

Please revert this change and add a doc page or notes to the dev handbook

discussing what the empirical process and results were for determining this
value so people can come up with their own values that work best with their
hardware and software config. This recommendation is prone to bitrot like some
of the recommendations in tuning(7).

Misinformation is sometimes more harmful than no information.

I spoke with Alfred over the phone and did some more careful thought
about this and I'm rescinding this request.

Alfred did a good job at documenting how JFLAG works (it was
previously undocumented). My concern over -j12 was performance
related, and after giving things more careful thought it actually
makes sense why -j12 was chosen because Westmere and newer processors
have issues with NUMA and cache locality between multiple processor
packages as we've seen non-empirically and empirically at Isilon with
FreeBSD 7 and 10 (it's a known issue that jeffr@ and jhb@ are aware
of).

I'll come up with a concise patch that does what Alfred was trying to
achieve and have Alfred review it.

Thanks (and thank you Alfred for the contribution!!!)!

Westmere is fine, it's post-Westmere that is more troublesome.

Even the 6-core Westmeres (I'm being completely dumb here as you and
Jeff know a lot more about the NUMA issue than I do as I just caught
the tail end of the conversation at BSDCan)? I'm asking because they
(iX) are using build.ix as the primary build machine and it has 2
Westmere dies with (IIRC -- please correct me if I'm wrong
Alfred/Xin/etc) 6 cores each and are SMT enabled. It also has a
boatload of RAM and disks hooked up to an mfi(4) controller (which
could be a contributing factor in the performance degradation issue).


I think the comment is not super useful, but don't object enough to want
it to be removed.  I always use 'make tinderbox' instead of
'make universe' though as I want build failures to be obvious.  For the
described use case of "checking if kernels build", 'tinderbox' certainly
seems to be the more appropriate target.

Changing it from universe to tinderbox seems like a better idea --
I'll put a short note in my proposed patch for that.

Thanks!
-Garrett

Just to clarify, the passing of jflag in the comments was there because 
it seems like most of the targets default to "-j1" which out of the box 
is somewhat ludicrous these days.  It was only a guide such that someone 
who knows what "-j" does would be like "oh that's absurd, I know a 
better value" rather than just being oblivious to it (like me) or 
stupidly assume that some level of auto-tuning was done (also like me) 
and wind up wondering why "make universe" is taking as long as an actual 
real live universe to build.


;)

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


svn commit: r253184 - stable/9/sys/kern

2013-07-10 Thread Alfred Perlstein
Author: alfred
Date: Thu Jul 11 04:57:08 2013
New Revision: 253184
URL: http://svnweb.freebsd.org/changeset/base/253184

Log:
  Fix for lost software interrupts/cam lockup.
  
  MFC: 252683

Modified:
  stable/9/sys/kern/kern_intr.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_intr.c
==
--- stable/9/sys/kern/kern_intr.c   Thu Jul 11 04:47:44 2013
(r253183)
+++ stable/9/sys/kern/kern_intr.c   Thu Jul 11 04:57:08 2013
(r253184)
@@ -841,7 +841,7 @@ ok:
 * again and remove this handler if it has already passed
 * it on the list.
 */
-   ie->ie_thread->it_need = 1;
+   atomic_store_rel_int(&ie->ie_thread->it_need, 1);
} else
TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
thread_unlock(ie->ie_thread->it_thread);
@@ -912,7 +912,7 @@ intr_event_schedule_thread(struct intr_e
 * running.  Then, lock the thread and see if we actually need to
 * put it on the runqueue.
 */
-   it->it_need = 1;
+   atomic_store_rel_int(&it->it_need, 1);
thread_lock(td);
if (TD_AWAITING_INTR(td)) {
CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
@@ -990,7 +990,7 @@ ok:
 * again and remove this handler if it has already passed
 * it on the list.
 */
-   it->it_need = 1;
+   atomic_store_rel_int(&it->it_need, 1);
} else
TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
thread_unlock(it->it_thread);
@@ -1066,7 +1066,7 @@ intr_event_schedule_thread(struct intr_e
 * running.  Then, lock the thread and see if we actually need to
 * put it on the runqueue.
 */
-   it->it_need = 1;
+   atomic_store_rel_int(&it->it_need, 1);
thread_lock(td);
if (TD_AWAITING_INTR(td)) {
CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
@@ -1256,7 +1256,7 @@ intr_event_execute_handlers(struct proc 
 * interrupt threads always invoke all of their handlers.
 */
if (ie->ie_flags & IE_SOFT) {
-   if (!ih->ih_need)
+   if (atomic_load_acq_int(&ih->ih_need) == 0)
continue;
else
atomic_store_rel_int(&ih->ih_need, 0);
@@ -1358,7 +1358,7 @@ ithread_loop(void *arg)
 * we are running, it will set it_need to note that we
 * should make another pass.
 */
-   while (ithd->it_need) {
+   while (atomic_load_acq_int(&ithd->it_need) != 0) {
/*
 * This might need a full read and write barrier
 * to make sure that this write posts before any
@@ -1377,7 +1377,8 @@ ithread_loop(void *arg)
 * set again, so we have to check it again.
 */
thread_lock(td);
-   if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
+   if ((atomic_load_acq_int(&ithd->it_need) == 0) &&
+   !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
TD_SET_IWAIT(td);
ie->ie_count = 0;
mi_switch(SW_VOL | SWT_IWAIT, NULL);
@@ -1538,7 +1539,7 @@ ithread_loop(void *arg)
 * we are running, it will set it_need to note that we
 * should make another pass.
 */
-   while (ithd->it_need) {
+   while (atomic_load_acq_int(&ithd->it_need) != 0) {
/*
 * This might need a full read and write barrier
 * to make sure that this write posts before any
@@ -1560,7 +1561,8 @@ ithread_loop(void *arg)
 * set again, so we have to check it again.
 */
thread_lock(td);
-   if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
+   if ((atomic_load_acq_int(&ithd->it_need) == 0) &&
+   !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
TD_SET_IWAIT(td);
ie->ie_count = 0;
mi_switch(SW_VOL | SWT_IWAIT, NULL);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r248031 - in head/sys: kern sys

2013-03-08 Thread Alfred Perlstein

Agreed,

Andre, please stop removing my comments.

-Alfred

On 3/8/13 10:17 AM, Alan Cox wrote:

On 03/08/2013 04:14, Andre Oppermann wrote:

Author: andre
Date: Fri Mar  8 10:14:58 2013
New Revision: 248031
URL: http://svnweb.freebsd.org/changeset/base/248031

Log:
   Move the auto-sizing of the callout array from init_param2() to
   kern_timeout_callwheel_alloc() where it is actually used.
   
   This is a mechanical move and no tuning parameters are changed.
   
   The pre-allocated callout array is only used for legacy timeout(9)

   calls and is only allocated and active on cpu0.  Eventually all
   remaining users of timeout(9) should switch to the callout_* API.
   

In the meantime, until all legacy timeout(9) users are updated, I think
that it would be wise to retain the comment that describes where the
magic number 18508 comes from.

Regards,
Alan


   Reviewed by: davide

Modified:
   head/sys/kern/kern_timeout.c
   head/sys/kern/subr_param.c
   head/sys/sys/callout.h

Modified: head/sys/kern/kern_timeout.c
==
--- head/sys/kern/kern_timeout.cFri Mar  8 08:19:50 2013
(r248030)
+++ head/sys/kern/kern_timeout.cFri Mar  8 10:14:58 2013
(r248031)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -101,6 +102,11 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpca
  0, "Average number of MP direct callouts made per callout_process call. "
  "Units = 1/1000");
  #endif
+
+static int ncallout;
+SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0,
+"Number of entries in callwheel and size of timeout() preallocation");
+
  /*
   * TODO:
   *allocate more timeout table slots when table overflows.
@@ -252,6 +258,14 @@ kern_timeout_callwheel_alloc(caddr_t v)
  
  	timeout_cpu = PCPU_GET(cpuid);

cc = CC_CPU(timeout_cpu);
+
+   /*
+* Calculate the size of the callout wheel and the preallocated
+* timeout() structures.
+*/
+   ncallout = imin(16 + maxproc + maxfiles, 18508);
+   TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
+
/*
 * Calculate callout wheel size, should be next power of two higher
 * than 'ncallout'.

Modified: head/sys/kern/subr_param.c
==
--- head/sys/kern/subr_param.c  Fri Mar  8 08:19:50 2013(r248030)
+++ head/sys/kern/subr_param.c  Fri Mar  8 10:14:58 2013(r248031)
@@ -91,7 +91,6 @@ int   maxprocperuid;  /* max # of procs p
  int   maxfiles;   /* sys. wide open files limit */
  int   maxfilesperproc;/* per-proc open files limit */
  int   msgbufsize; /* size of kernel message buffer */
-intncallout;   /* maximum # of timer events */
  int   nbuf;
  int   ngroups_max;/* max # groups per process */
  int   nswbuf;
@@ -109,8 +108,6 @@ u_long  sgrowsiz;   /* amount to 
grow sta
  
  SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0,

  "Number of clock ticks per second");
-SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0,
-"Number of pre-allocated timer events");
  SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN, &nbuf, 0,
  "Number of buffers in the buffer cache");
  SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0,
@@ -327,15 +324,6 @@ init_param2(long physpages)
TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
  
  	/*

-* XXX: Does the callout wheel have to be so big?
-*
-* Clip callout to result of previous function of maxusers maximum
-* 384.  This is still huge, but acceptable.
-*/
-   ncallout = imin(16 + maxproc + maxfiles, 18508);
-   TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
-
-   /*
 * The default for maxpipekva is min(1/64 of the kernel address space,
 * max(1/64 of main memory, 512KB)).  See sys_pipe.c for more details.
 */

Modified: head/sys/sys/callout.h
==
--- head/sys/sys/callout.h  Fri Mar  8 08:19:50 2013(r248030)
+++ head/sys/sys/callout.h  Fri Mar  8 10:14:58 2013(r248031)
@@ -63,8 +63,6 @@ struct callout_handle {
  };
  
  #ifdef _KERNEL

-extern int ncallout;
-
  #define   callout_active(c)   ((c)->c_flags & CALLOUT_ACTIVE)
  #define   callout_deactivate(c)   ((c)->c_flags &= ~CALLOUT_ACTIVE)
  #define   callout_drain(c)_callout_stop_safe(c, 1)



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


svn commit: r248356 - stable/9/usr.bin/netstat

2013-03-15 Thread Alfred Perlstein
Author: alfred
Date: Fri Mar 15 22:24:34 2013
New Revision: 248356
URL: http://svnweb.freebsd.org/changeset/base/248356

Log:
  MFC: 242030
  
  Show how many times we are blocked waiting for mbufs.

Modified:
  stable/9/usr.bin/netstat/mbuf.c
Directory Properties:
  stable/9/usr.bin/netstat/   (props changed)

Modified: stable/9/usr.bin/netstat/mbuf.c
==
--- stable/9/usr.bin/netstat/mbuf.c Fri Mar 15 22:20:45 2013
(r248355)
+++ stable/9/usr.bin/netstat/mbuf.c Fri Mar 15 22:24:34 2013
(r248356)
@@ -67,16 +67,18 @@ mbpr(void *kvmd, u_long mbaddr)
struct memory_type_list *mtlp;
struct memory_type *mtp;
uintmax_t mbuf_count, mbuf_bytes, mbuf_free, mbuf_failures, mbuf_size;
+   uintmax_t mbuf_sleeps;
uintmax_t cluster_count, cluster_bytes, cluster_limit, cluster_free;
-   uintmax_t cluster_failures, cluster_size;
+   uintmax_t cluster_failures, cluster_size, cluster_sleeps;
uintmax_t packet_count, packet_bytes, packet_free, packet_failures;
+   uintmax_t packet_sleeps;
uintmax_t tag_count, tag_bytes;
uintmax_t jumbop_count, jumbop_bytes, jumbop_limit, jumbop_free;
-   uintmax_t jumbop_failures, jumbop_size;
+   uintmax_t jumbop_failures, jumbop_sleeps, jumbop_size;
uintmax_t jumbo9_count, jumbo9_bytes, jumbo9_limit, jumbo9_free;
-   uintmax_t jumbo9_failures, jumbo9_size;
+   uintmax_t jumbo9_failures, jumbo9_sleeps, jumbo9_size;
uintmax_t jumbo16_count, jumbo16_bytes, jumbo16_limit, jumbo16_free;
-   uintmax_t jumbo16_failures, jumbo16_size;
+   uintmax_t jumbo16_failures, jumbo16_sleeps, jumbo16_size;
uintmax_t bytes_inuse, bytes_incache, bytes_total;
int nsfbufs, nsfbufspeak, nsfbufsused;
struct mbstat mbstat;
@@ -121,6 +123,7 @@ mbpr(void *kvmd, u_long mbaddr)
mbuf_bytes = memstat_get_bytes(mtp);
mbuf_free = memstat_get_free(mtp);
mbuf_failures = memstat_get_failures(mtp);
+   mbuf_sleeps = memstat_get_sleeps(mtp);
mbuf_size = memstat_get_size(mtp);
 
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_PACKET_MEM_NAME);
@@ -132,6 +135,7 @@ mbpr(void *kvmd, u_long mbaddr)
packet_count = memstat_get_count(mtp);
packet_bytes = memstat_get_bytes(mtp);
packet_free = memstat_get_free(mtp);
+   packet_sleeps = memstat_get_sleeps(mtp);
packet_failures = memstat_get_failures(mtp);
 
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_CLUSTER_MEM_NAME);
@@ -145,6 +149,7 @@ mbpr(void *kvmd, u_long mbaddr)
cluster_limit = memstat_get_countlimit(mtp);
cluster_free = memstat_get_free(mtp);
cluster_failures = memstat_get_failures(mtp);
+   cluster_sleeps = memstat_get_sleeps(mtp);
cluster_size = memstat_get_size(mtp);
 
mtp = memstat_mtl_find(mtlp, ALLOCATOR_MALLOC, MBUF_TAG_MEM_NAME);
@@ -167,6 +172,7 @@ mbpr(void *kvmd, u_long mbaddr)
jumbop_limit = memstat_get_countlimit(mtp);
jumbop_free = memstat_get_free(mtp);
jumbop_failures = memstat_get_failures(mtp);
+   jumbop_sleeps = memstat_get_sleeps(mtp);
jumbop_size = memstat_get_size(mtp);
 
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO9_MEM_NAME);
@@ -180,6 +186,7 @@ mbpr(void *kvmd, u_long mbaddr)
jumbo9_limit = memstat_get_countlimit(mtp);
jumbo9_free = memstat_get_free(mtp);
jumbo9_failures = memstat_get_failures(mtp);
+   jumbo9_sleeps = memstat_get_sleeps(mtp);
jumbo9_size = memstat_get_size(mtp);
 
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO16_MEM_NAME);
@@ -193,6 +200,7 @@ mbpr(void *kvmd, u_long mbaddr)
jumbo16_limit = memstat_get_countlimit(mtp);
jumbo16_free = memstat_get_free(mtp);
jumbo16_failures = memstat_get_failures(mtp);
+   jumbo16_sleeps = memstat_get_sleeps(mtp);
jumbo16_size = memstat_get_size(mtp);
 
printf("%ju/%ju/%ju mbufs in use (current/cache/total)\n",
@@ -279,7 +287,13 @@ mbpr(void *kvmd, u_long mbaddr)
printf("%ju/%ju/%ju requests for mbufs denied (mbufs/clusters/"
"mbuf+clusters)\n", mbuf_failures, cluster_failures,
packet_failures);
-
+   printf("%ju/%ju/%ju requests for mbufs delayed (mbufs/clusters/"
+   "mbuf+clusters)\n", mbuf_sleeps, cluster_sleeps,
+   packet_sleeps);
+
+   printf("%ju/%ju/%ju requests for jumbo clusters delayed "
+   "(%juk/9k/16k)\n", jumbop_sleeps, jumbo9_sleeps,
+   jumbo16_sleeps, jumbop_size / 1024);
printf("%ju/%ju/%ju requests for jumbo clusters denied "
"(%juk/9k/16k)\n", jumbop_failures, jumbo9_failures,
jumbo16_failures, jumbop_size / 1024);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send

Re: svn commit: r249352 - head/sys/cam/scsi

2013-04-11 Thread Alfred Perlstein

woohoo!

-Alfred

On 4/10/13 11:34 PM, Alexander Motin wrote:

Author: mav
Date: Thu Apr 11 06:34:41 2013
New Revision: 249352
URL: http://svnweb.freebsd.org/changeset/base/249352

Log:
   Do not sent 120 TEST UNIT READY requests on generic NOT READY statuses.
   
   Some failing disks tend to return vendor-specific ASC/ASCQ codes with

   NOT READY sense key.  It caused extremely long recovery attempts, repeating
   these 120 TURs (it takes at least 1 minute) for every I/O request.
   Instead of that use default error handling, doing just few retries.
   
   Reviewed by:	ken, gibbs

   MFC after:   1 month

Modified:
   head/sys/cam/scsi/scsi_all.c

Modified: head/sys/cam/scsi/scsi_all.c
==
--- head/sys/cam/scsi/scsi_all.cThu Apr 11 04:29:45 2013
(r249351)
+++ head/sys/cam/scsi/scsi_all.cThu Apr 11 06:34:41 2013
(r249352)
@@ -699,10 +699,7 @@ const struct sense_key_table_entry sense
  {
{ SSD_KEY_NO_SENSE, SS_NOP, "NO SENSE" },
{ SSD_KEY_RECOVERED_ERROR, SS_NOP|SSQ_PRINT_SENSE, "RECOVERED ERROR" },
-   {
- SSD_KEY_NOT_READY, SS_TUR|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY,
- "NOT READY"
-   },
+   { SSD_KEY_NOT_READY, SS_RDEF, "NOT READY" },
{ SSD_KEY_MEDIUM_ERROR, SS_RDEF, "MEDIUM ERROR" },
{ SSD_KEY_HARDWARE_ERROR, SS_RDEF, "HARDWARE FAILURE" },
{ SSD_KEY_ILLEGAL_REQUEST, SS_FATAL|EINVAL, "ILLEGAL REQUEST" },
@@ -877,7 +874,7 @@ static struct asc_table_entry asc_table[
{ SST(0x03, 0x02, SS_RDEF,
"Excessive write errors") },
/* DTLPWROMAEBKVF */
-   { SST(0x04, 0x00, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EIO,
+   { SST(0x04, 0x00, SS_RDEF,
"Logical unit not ready, cause not reportable") },
/* DTLPWROMAEBKVF */
{ SST(0x04, 0x01, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EBUSY,



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


Re: svn commit: r249921 - in head: . sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2013-04-26 Thread Alfred Perlstein


This can not be MFC'd, it breaks API.

Using a sysctl proc (or analogous method) to preserve the old sysctl mib 
would suffice.


-Alfred

On 4/26/13 4:24 AM, Steven Hartland wrote:

Author: smh
Date: Fri Apr 26 11:24:20 2013
New Revision: 249921
URL: http://svnweb.freebsd.org/changeset/base/249921

Log:
   Changed ZFS TRIM sysctl from vfs.zfs.trim_disable -> vfs.zfs.trim.enabled
   Enabled ZFS TRIM by default
   
   Reviewed by:	pjd (mentor)

   Approved by: pjd (mentor)
   MFC after:   2 weeks

Modified:
   head/UPDATING
   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c

Modified: head/UPDATING
==
--- head/UPDATING   Fri Apr 26 07:00:49 2013(r249920)
+++ head/UPDATING   Fri Apr 26 11:24:20 2013(r249921)
@@ -31,6 +31,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
  
+20130426:

+   The sysctl which controls TRIM support under ZFS has been renamed
+   from vfs.zfs.trim_disable -> vfs.zfs.trim.enabled and has been
+   enabled by default.
+
  20130425:
The mergemaster command now uses the default MAKEOBJDIRPREFIX
rather than creating it's own in the temporary directory in

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h  Fri Apr 
26 07:00:49 2013(r249920)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h  Fri Apr 
26 11:24:20 2013(r249921)
@@ -46,7 +46,7 @@ typedef enum vdev_dtl_type {
  } vdev_dtl_type_t;
  
  extern boolean_t zfs_nocacheflush;

-extern boolean_t zfs_notrim;
+extern boolean_t zfs_trim_enabled;
  
  extern int vdev_open(vdev_t *);

  extern void vdev_open_children(vdev_t *);

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c  Fri Apr 
26 07:00:49 2013(r249920)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c  Fri Apr 
26 11:24:20 2013(r249921)
@@ -72,7 +72,7 @@ typedef struct trim_seg {
hrtime_tts_time;/* Segment creation time. */
  } trim_seg_t;
  
-extern boolean_t zfs_notrim;

+extern boolean_t zfs_trim_enabled;
  
  static u_int trim_txg_delay = 32;

  static u_int trim_timeout = 30;
@@ -157,7 +157,7 @@ trim_map_create(vdev_t *vd)
  
  	ASSERT(vd->vdev_ops->vdev_op_leaf);
  
-	if (zfs_notrim)

+   if (!zfs_trim_enabled)
return;
  
  	tm = kmem_zalloc(sizeof (*tm), KM_SLEEP);

@@ -183,7 +183,7 @@ trim_map_destroy(vdev_t *vd)
  
  	ASSERT(vd->vdev_ops->vdev_op_leaf);
  
-	if (zfs_notrim)

+   if (!zfs_trim_enabled)
return;
  
  	tm = vd->vdev_trimmap;

@@ -340,7 +340,7 @@ trim_map_free(vdev_t *vd, uint64_t offse
  {
trim_map_t *tm = vd->vdev_trimmap;
  
-	if (zfs_notrim || vd->vdev_notrim || tm == NULL)

+   if (!zfs_trim_enabled || vd->vdev_notrim || tm == NULL)
return;
  
  	mutex_enter(&tm->tm_lock);

@@ -357,7 +357,7 @@ trim_map_write_start(zio_t *zio)
boolean_t left_over, right_over;
uint64_t start, end;
  
-	if (zfs_notrim || vd->vdev_notrim || tm == NULL)

+   if (!zfs_trim_enabled || vd->vdev_notrim || tm == NULL)
return (B_TRUE);
  
  	start = zio->io_offset;

@@ -404,7 +404,7 @@ trim_map_write_done(zio_t *zio)
 * Don't check for vdev_notrim, since the write could have
 * started before vdev_notrim was set.
 */
-   if (zfs_notrim || tm == NULL)
+   if (!zfs_trim_enabled || tm == NULL)
return;
  
  	mutex_enter(&tm->tm_lock);

@@ -589,7 +589,7 @@ void
  trim_thread_create(spa_t *spa)
  {
  
-	if (zfs_notrim)

+   if (!zfs_trim_enabled)
return;
  
  	mutex_init(&spa->spa_trim_lock, NULL, MUTEX_DEFAULT, NULL);

@@ -604,7 +604,7 @@ void
  trim_thread_destroy(spa_t *spa)
  {
  
-	if (zfs_notrim)

+   if (!zfs_trim_enabled)
return;
if (spa->spa_trim_thread == NULL)
return;
@@ -627,7 +627,7 @@ void
  trim_thread_wakeup(spa_t *spa)
  {
  
-	if (zfs_notrim)

+   if (!zfs_trim_enabled)
return;
if (spa->spa_trim_thread == NULL)
return;

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/

Re: svn commit: r249921 - in head: . sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2013-04-26 Thread Alfred Perlstein

On 4/26/13 2:48 PM, Steven Hartland wrote:
The entire ZFS TRIM work is only is on in current ATM so I assume this 
wont actually be an issue?


Yes, that makes sense.  I misunderstood that the change was a rename 
that was going to make it into -stable.


thanks,
-Alfred



   Regards
   Steve
- Original Message - From: "Alfred Perlstein" 
To: "Steven Hartland" 
Cc: ; ; 


Sent: Friday, April 26, 2013 8:54 PM
Subject: Re: svn commit: r249921 - in head: . 
sys/cddl/contrib/opensolaris/uts/common/fs/zfs 
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys





This can not be MFC'd, it breaks API.

Using a sysctl proc (or analogous method) to preserve the old sysctl 
mib would suffice.


-Alfred

On 4/26/13 4:24 AM, Steven Hartland wrote:

Author: smh
Date: Fri Apr 26 11:24:20 2013
New Revision: 249921
URL: http://svnweb.freebsd.org/changeset/base/249921

Log:
   Changed ZFS TRIM sysctl from vfs.zfs.trim_disable -> 
vfs.zfs.trim.enabled

   Enabled ZFS TRIM by default
   Reviewed by: pjd (mentor)
   Approved by: pjd (mentor)
   MFC after: 2 weeks

Modified:
   head/UPDATING
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c

Modified: head/UPDATING
== 


--- head/UPDATING Fri Apr 26 07:00:49 2013 (r249920)
+++ head/UPDATING Fri Apr 26 11:24:20 2013 (r249921)
@@ -31,6 +31,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10
  disable the most expensive debugging functionality run
  "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
  +20130426:
+ The sysctl which controls TRIM support under ZFS has been renamed
+ from vfs.zfs.trim_disable -> vfs.zfs.trim.enabled and has been
+ enabled by default.
+
  20130425:
  The mergemaster command now uses the default MAKEOBJDIRPREFIX
  rather than creating it's own in the temporary directory in

Modified: 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
== 

--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h 
Fri Apr 26 07:00:49 2013 (r249920)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h 
Fri Apr 26 11:24:20 2013 (r249921)

@@ -46,7 +46,7 @@ typedef enum vdev_dtl_type {
  } vdev_dtl_type_t;
  extern boolean_t zfs_nocacheflush;
-extern boolean_t zfs_notrim;
+extern boolean_t zfs_trim_enabled;
  extern int vdev_open(vdev_t *);
  extern void vdev_open_children(vdev_t *);

Modified: 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
== 

--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c 
Fri Apr 26 07:00:49 2013 (r249920)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c 
Fri Apr 26 11:24:20 2013 (r249921)

@@ -72,7 +72,7 @@ typedef struct trim_seg {
  hrtime_t ts_time; /* Segment creation time. */
  } trim_seg_t;
  -extern boolean_t zfs_notrim;
+extern boolean_t zfs_trim_enabled;
  static u_int trim_txg_delay = 32;
  static u_int trim_timeout = 30;
@@ -157,7 +157,7 @@ trim_map_create(vdev_t *vd)
  ASSERT(vd->vdev_ops->vdev_op_leaf);
  - if (zfs_notrim)
+ if (!zfs_trim_enabled)
  return;
  tm = kmem_zalloc(sizeof (*tm), KM_SLEEP);
@@ -183,7 +183,7 @@ trim_map_destroy(vdev_t *vd)
  ASSERT(vd->vdev_ops->vdev_op_leaf);
  - if (zfs_notrim)
+ if (!zfs_trim_enabled)
  return;
  tm = vd->vdev_trimmap;
@@ -340,7 +340,7 @@ trim_map_free(vdev_t *vd, uint64_t offse
  {
  trim_map_t *tm = vd->vdev_trimmap;
  - if (zfs_notrim || vd->vdev_notrim || tm == NULL)
+ if (!zfs_trim_enabled || vd->vdev_notrim || tm == NULL)
  return;
  mutex_enter(&tm->tm_lock);
@@ -357,7 +357,7 @@ trim_map_write_start(zio_t *zio)
  boolean_t left_over, right_over;
  uint64_t start, end;
  - if (zfs_notrim || vd->vdev_notrim || tm == NULL)
+ if (!zfs_trim_enabled || vd->vdev_notrim || tm == NULL)
  return (B_TRUE);
  start = zio->io_offset;
@@ -404,7 +404,7 @@ trim_map_write_done(zio_t *zio)
  * Don't check for vdev_notrim, since the write could have
  * started before vdev_notrim was set.
  */
- if (zfs_notrim || tm == NULL)
+ if (!zfs_trim_enabled || tm == NULL)
  return;
  mutex_enter(&tm->tm_lock);
@@ -589,7 +589,7 @@ void
  trim_thread_create(spa_t *spa)
  {
  - if (zfs_notrim)
+ if (!zfs_trim_enabled)
  return;
  mutex_init(&spa->spa_trim_lock, NULL, MUTEX_DEFAULT, NULL);
@@ -604,7 +604,7 @@ void
  trim_thread_destroy(spa_t *spa)
  {
  - if (zfs_notrim)
+ if (!zfs_trim_enabled)
  return;
  if (spa->spa_trim_thread == NULL)
  return;
@@ -627,7 +627,7 @@ void
  trim_thread_wakeup(spa_t *spa)
  {
  - if (zfs_notrim)
+ if (!zfs_trim_enabled)
  return;
  if

svn commit: r253719 - in head: sys/conf sys/dev/watchdog sys/libkern sys/sys usr.sbin/watchdogd

2013-07-27 Thread Alfred Perlstein
Author: alfred
Date: Sat Jul 27 20:47:01 2013
New Revision: 253719
URL: http://svnweb.freebsd.org/changeset/base/253719

Log:
  Fix watchdog pretimeout.
  
  The original API calls for pow2ns, however the new APIs from
  Linux call for seconds.
  
  We need to be able to convert to/from 2^Nns to seconds in both
  userland and kernel to fix this and properly compare units.

Added:
  head/sys/libkern/flsll.c   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/watchdog/watchdog.c
  head/sys/sys/libkern.h
  head/usr.sbin/watchdogd/watchdogd.c

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sat Jul 27 20:15:18 2013(r253718)
+++ head/sys/conf/files Sat Jul 27 20:47:01 2013(r253719)
@@ -2976,6 +2976,7 @@ libkern/arc4random.c  standard
 libkern/bcd.c  standard
 libkern/bsearch.c  standard
 libkern/crc32.cstandard
+libkern/flsll.c standard
 libkern/fnmatch.c  standard
 libkern/iconv.coptional libiconv
 libkern/iconv_converter_if.m   optional libiconv

Modified: head/sys/dev/watchdog/watchdog.c
==
--- head/sys/dev/watchdog/watchdog.cSat Jul 27 20:15:18 2013
(r253718)
+++ head/sys/dev/watchdog/watchdog.cSat Jul 27 20:47:01 2013
(r253719)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -60,10 +61,56 @@ static int wd_softtimeout_act = WD_SOFT_
 
 static struct cdev *wd_dev;
 static volatile u_int wd_last_u;/* last timeout value set by kern_do_pat */
+static u_int wd_last_u_sysctl;/* last timeout value set by kern_do_pat */
+static u_int wd_last_u_sysctl_secs;/* wd_last_u in seconds */
+
+SYSCTL_NODE(_hw, OID_AUTO, watchdog, CTLFLAG_RD, 0, "Main watchdog device");
+SYSCTL_UINT(_hw_watchdog, OID_AUTO, wd_last_u, CTLFLAG_RD,
+&wd_last_u_sysctl, 0, "Watchdog last update time");
+SYSCTL_UINT(_hw_watchdog, OID_AUTO, wd_last_u_secs, CTLFLAG_RD,
+&wd_last_u_sysctl_secs, 0, "Watchdog last update time");
 
 static int wd_lastpat_valid = 0;
 static time_t wd_lastpat = 0;  /* when the watchdog was last patted */
 
+static void
+pow2ns_to_ts(int pow2ns, struct timespec *ts)
+{
+   uint64_t ns;
+
+   ns = 1ULL << pow2ns;
+   ts->tv_sec = ns / 10ULL;
+   ts->tv_nsec = ns % 10ULL;
+}
+
+static int
+pow2ns_to_ticks(int pow2ns)
+{
+   struct timeval tv;
+   struct timespec ts;
+
+   pow2ns_to_ts(pow2ns, &ts);
+   TIMESPEC_TO_TIMEVAL(&tv, &ts);
+   return (tvtohz(&tv));
+}
+
+static int
+seconds_to_pow2ns(int seconds)
+{
+   uint64_t power;
+   uint64_t ns;
+   uint64_t shifted;
+
+   ns = ((uint64_t)seconds) * 10ULL;
+   power = flsll(ns);
+   shifted = 1ULL << power;
+   if (shifted <= ns) {
+   power++;
+   }
+   return (power);
+}
+
+
 int
 wdog_kern_pat(u_int utim)
 {
@@ -86,6 +133,8 @@ wdog_kern_pat(u_int utim)
 * This can be zero (to disable the watchdog)
 */
wd_last_u = (utim & WD_INTERVAL);
+   wd_last_u_sysctl = wd_last_u;
+   wd_last_u_sysctl_secs = pow2ns_to_ticks(wd_last_u) / hz;
}
if ((utim & WD_INTERVAL) == WD_TO_NEVER) {
utim = 0;
@@ -101,7 +150,7 @@ wdog_kern_pat(u_int utim)
callout_stop(&wd_softtimeo_handle);
} else {
(void) callout_reset(&wd_softtimeo_handle,
-   hz*utim, wd_timeout_cb, "soft");
+   pow2ns_to_ticks(utim), wd_timeout_cb, "soft");
}
error = 0;
} else {
@@ -201,10 +250,13 @@ static int
 wd_set_pretimeout(int newtimeout, int disableiftoolong)
 {
u_int utime;
+   struct timespec utime_ts;
+   int timeout_ticks;
 
utime = wdog_kern_last_timeout();
+   pow2ns_to_ts(utime, &utime_ts);
/* do not permit a pre-timeout >= than the timeout. */
-   if (newtimeout >= utime) {
+   if (newtimeout >= utime_ts.tv_sec) {
/*
 * If 'disableiftoolong' then just fall through
 * so as to disable the pre-watchdog
@@ -222,8 +274,22 @@ wd_set_pretimeout(int newtimeout, int di
return 0;
}
 
+   timeout_ticks = pow2ns_to_ticks(utime) - (hz*newtimeout);
+#if 0
+   printf("wd_set_pretimeout: "
+   "newtimeout: %d, "
+   "utime: %d -> utime_ticks: %d, "
+   "hz*newtimeout: %d, "
+   "timeout_ticks: %d -> sec: %d\n",
+   newtimeout,
+   utime, pow2ns_to_ticks(utime),
+   hz*newtimeout,
+   timeout_ticks, timeout_ticks / hz);
+#endif
+
/* We determined the value

svn commit: r253723 - head/usr.sbin/watchdogd

2013-07-27 Thread Alfred Perlstein
Author: alfred
Date: Sat Jul 27 22:23:32 2013
New Revision: 253723
URL: http://svnweb.freebsd.org/changeset/base/253723

Log:
  Provide some examples for watchdogd usage.

Modified:
  head/usr.sbin/watchdogd/watchdogd.8

Modified: head/usr.sbin/watchdogd/watchdogd.8
==
--- head/usr.sbin/watchdogd/watchdogd.8 Sat Jul 27 22:21:10 2013
(r253722)
+++ head/usr.sbin/watchdogd/watchdogd.8 Sat Jul 27 22:23:32 2013
(r253723)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 5, 2013
+.Dd July 27, 2013
 .Dt WATCHDOGD 8
 .Os
 .Sh NAME
@@ -204,6 +204,81 @@ and the kernel
 .Xr log 4
 device for
 .Xr syslog 8 .
+.Sh EXAMPLES
+.Ss Debugging watchdogd and/or your watchdog script.
+.Pp
+This is a useful recipe for debugging watchdogd and your watchdog
+script.
+.Pp
+(Note that ^C works oddly because watchdogd calls system(3) so the
+first ^C will terminate the "sleep" command.)
+.Pp
+.Pp
+Explanation of options used:
+.Bl -enum -offset indent -compact
+.It
+Set Debug on (--debug)
+.It
+Set the watchdog to trip at 30 seconds. (-t 30)
+.It
+Use of a softtimeout:
+.Bl -enum -offset indent -compact -nested
+.It
+Use a softtimeout (don't arm the hardware watchdog) (--softtimeout)
+.It
+Set the softtimeout action to do both kernel printf(9) and log(9) when it 
trips. (--softtimeout-action log,printf)
+.El
+.It
+Use of a pre-timeout:
+.Bl -enum -offset indent -compact -nested
+.It
+Set a pre-timeout of 15 seconds (this will later trigger a panic/dump) 
(--pretimeout 15)
+.It
+Set the action to also kernel printf(9) and log(9) when it trips. 
(--pretimeout-action log,printf)
+.El
+.It
+Use of a script:
+.Bl -enum -offset indent -compact -nested
+.It
+Run "sleep 60" as a shell command that acts as the watchdog (-e 'sleep 60')
+.It
+Warn us when the script takes longer than 1 second to run (-w)
+.El
+.El
+.Bd -literal
+watchdogd --debug -t 30 \\
+  --softtimeout --softtimeout-action log,printf \\
+  --pretimeout 15 --pretimeout-action log,printf \\
+  -e 'sleep 60' -w
+.Ed
+.Ss Production use of example
+.Bl -enum -offset indent -compact
+.It
+Set hard timeout to 120 seconds (-t 120)
+.It
+Set a panic to happen at 60 seconds (to trigger a
+.Xr crash 8
+for dump analysis):
+.Bl -enum -offset indent -compact -nested
+.It
+Use of pre-timeout (--pretimeout 60)
+.It
+Specify pre-timeout action (--pretimeout-action log,printf,panic )
+.El
+.It
+Use of a script:
+.Bl -enum -offset indent -compact -nested
+.It
+Run your script (-e '/path/to/your/script 60')
+.It
+Log if your script takes a longer than 15 seconds to run time. (-w -T 15)
+.El
+.El
+.Bd -literal
+watchdogd  -t 120 \\
+  --pretimeout 60 --pretimeout-action log,printf,panic \\
+  -e '/path/to/your/script 60' -w -T 15
+.Ed
 .Sh FILES
 .Bl -tag -width ".Pa /var/run/watchdogd.pid" -compact
 .It Pa /var/run/watchdogd.pid
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253719 - in head: sys/conf sys/dev/watchdog sys/libkern sys/sys usr.sbin/watchdogd

2013-07-30 Thread Alfred Perlstein

On 7/30/13 4:24 AM, Ulrich Spörlein wrote:

On Sat, 2013-07-27 at 20:47:02 +, Alfred Perlstein wrote:

Author: alfred
Date: Sat Jul 27 20:47:01 2013
New Revision: 253719
URL: http://svnweb.freebsd.org/changeset/base/253719

Log:
   Fix watchdog pretimeout.

Alfred,

this broken the build and hasn't been fixed for almost three days now.
What's up with that? How was this change tested before commit?

===> usr.sbin/watchdogd (all)
cc  -O2 -pipe  -std=gnu99 -Qunused-arguments -fstack-protector -Wsystem-headers 
-Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes 
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings 
-Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline 
-Wnested-externs -Wredundant-decls -Wold-style-definition 
-Wmissing-variable-declarations -Wno-pointer-sign -Wno-empty-body 
-Wno-string-plus-int -c /data/src/freebsd-head/usr.sbin/watchdogd/watchdogd.c
/data/src/freebsd-head/usr.sbin/watchdogd/watchdogd.c:777:18: error: comparison 
of integers of different signs: 'u_int' (aka 'unsigned int') and 'time_t' (aka 
'int') [-Werror,-Wsign-compare]
 if (pretimeout >= ts.tv_sec) {
 ~~ ^  ~
1 error generated.
*** Error code 1


Yikes!  What?

I did test this a ton of times.  My apologies to all.

Let me see what I can do.

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


Re: svn commit: r253719 - in head: sys/conf sys/dev/watchdog sys/libkern sys/sys usr.sbin/watchdogd

2013-07-30 Thread Alfred Perlstein

On 7/30/13 4:22 AM, Glen Barber wrote:

On Sat, Jul 27, 2013 at 08:47:02PM +, Alfred Perlstein wrote:

Author: alfred
Date: Sat Jul 27 20:47:01 2013
New Revision: 253719
URL: http://svnweb.freebsd.org/changeset/base/253719

Log:
   Fix watchdog pretimeout.
   
   The original API calls for pow2ns, however the new APIs from

   Linux call for seconds.
   
   We need to be able to convert to/from 2^Nns to seconds in both

   userland and kernel to fix this and properly compare units.

Added:
   head/sys/libkern/flsll.c   (contents, props changed)
Modified:
   head/sys/conf/files
   head/sys/dev/watchdog/watchdog.c
   head/sys/sys/libkern.h
   head/usr.sbin/watchdogd/watchdogd.c

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sat Jul 27 20:15:18 2013(r253718)
+++ head/sys/conf/files Sat Jul 27 20:47:01 2013(r253719)
@@ -2976,6 +2976,7 @@ libkern/arc4random.c  standard
  libkern/bcd.c standard
  libkern/bsearch.c standard
  libkern/crc32.c   standard
+libkern/flsll.c standard
  libkern/fnmatch.c standard
  libkern/iconv.c   optional libiconv
  libkern/iconv_converter_if.m  optional libiconv

Modified: head/sys/dev/watchdog/watchdog.c
==
--- head/sys/dev/watchdog/watchdog.cSat Jul 27 20:15:18 2013
(r253718)
+++ head/sys/dev/watchdog/watchdog.cSat Jul 27 20:47:01 2013
(r253719)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -60,10 +61,56 @@ static int wd_softtimeout_act = WD_SOFT_
  
  static struct cdev *wd_dev;

  static volatile u_int wd_last_u;/* last timeout value set by kern_do_pat 
*/
+static u_int wd_last_u_sysctl;/* last timeout value set by kern_do_pat */
+static u_int wd_last_u_sysctl_secs;/* wd_last_u in seconds */
+
+SYSCTL_NODE(_hw, OID_AUTO, watchdog, CTLFLAG_RD, 0, "Main watchdog device");
+SYSCTL_UINT(_hw_watchdog, OID_AUTO, wd_last_u, CTLFLAG_RD,
+&wd_last_u_sysctl, 0, "Watchdog last update time");
+SYSCTL_UINT(_hw_watchdog, OID_AUTO, wd_last_u_secs, CTLFLAG_RD,
+&wd_last_u_sysctl_secs, 0, "Watchdog last update time");
  
  static int wd_lastpat_valid = 0;

  static time_t wd_lastpat = 0; /* when the watchdog was last patted */
  
+static void

+pow2ns_to_ts(int pow2ns, struct timespec *ts)
+{
+   uint64_t ns;
+
+   ns = 1ULL << pow2ns;
+   ts->tv_sec = ns / 10ULL;
+   ts->tv_nsec = ns % 10ULL;
+}
+
+static int
+pow2ns_to_ticks(int pow2ns)
+{
+   struct timeval tv;
+   struct timespec ts;
+
+   pow2ns_to_ts(pow2ns, &ts);
+   TIMESPEC_TO_TIMEVAL(&tv, &ts);
+   return (tvtohz(&tv));
+}
+
+static int
+seconds_to_pow2ns(int seconds)
+{
+   uint64_t power;
+   uint64_t ns;
+   uint64_t shifted;
+
+   ns = ((uint64_t)seconds) * 10ULL;
+   power = flsll(ns);
+   shifted = 1ULL << power;
+   if (shifted <= ns) {
+   power++;
+   }
+   return (power);
+}
+
+
  int
  wdog_kern_pat(u_int utim)
  {
@@ -86,6 +133,8 @@ wdog_kern_pat(u_int utim)
 * This can be zero (to disable the watchdog)
 */
wd_last_u = (utim & WD_INTERVAL);
+   wd_last_u_sysctl = wd_last_u;
+   wd_last_u_sysctl_secs = pow2ns_to_ticks(wd_last_u) / hz;
}
if ((utim & WD_INTERVAL) == WD_TO_NEVER) {
utim = 0;
@@ -101,7 +150,7 @@ wdog_kern_pat(u_int utim)
callout_stop(&wd_softtimeo_handle);
} else {
(void) callout_reset(&wd_softtimeo_handle,
-   hz*utim, wd_timeout_cb, "soft");
+   pow2ns_to_ticks(utim), wd_timeout_cb, "soft");
}
error = 0;
} else {
@@ -201,10 +250,13 @@ static int
  wd_set_pretimeout(int newtimeout, int disableiftoolong)
  {
u_int utime;
+   struct timespec utime_ts;
+   int timeout_ticks;
  
  	utime = wdog_kern_last_timeout();

+   pow2ns_to_ts(utime, &utime_ts);
/* do not permit a pre-timeout >= than the timeout. */
-   if (newtimeout >= utime) {
+   if (newtimeout >= utime_ts.tv_sec) {
/*
 * If 'disableiftoolong' then just fall through
 * so as to disable the pre-watchdog
@@ -222,8 +274,22 @@ wd_set_pretimeout(int newtimeout, int di
return 0;
}
  
+	timeout_ticks = pow2ns_to_ticks(utime) - (hz*newtimeout);

+#if 0
+   printf("wd_set_pretimeout: "
+   "newtimeout: %d, "
+ 

svn commit: r254173 - head/usr.sbin/watchdogd

2013-08-09 Thread Alfred Perlstein
Author: alfred
Date: Sat Aug 10 01:48:15 2013
New Revision: 254173
URL: http://svnweb.freebsd.org/changeset/base/254173

Log:
  Fix bug in r253719: fix command line watchdog disable.
  
  r253719 disallowed watchdog(8) from disabling the watchdog
  by breaking the ability to pass 0 as a timeout arg.  Fix this.

Modified:
  head/usr.sbin/watchdogd/watchdogd.c

Modified: head/usr.sbin/watchdogd/watchdogd.c
==
--- head/usr.sbin/watchdogd/watchdogd.c Sat Aug 10 00:53:22 2013
(r254172)
+++ head/usr.sbin/watchdogd/watchdogd.c Sat Aug 10 01:48:15 2013
(r254173)
@@ -60,7 +60,8 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-static longfetchtimeout(int opt, const char *longopt, const char 
*myoptarg);
+static longfetchtimeout(int opt,
+const char *longopt, const char *myoptarg, int zero_ok);
 static voidparseargs(int, char *[]);
 static int seconds_to_pow2ns(int);
 static voidsighandler(int);
@@ -219,7 +220,7 @@ parse_timeout_to_pow2ns(char opt, const 
if (!longopt)
shortopt[1] = opt;
 
-   a = fetchtimeout(opt, longopt, myoptarg);
+   a = fetchtimeout(opt, longopt, myoptarg, 1);
 
if (a == 0)
rv = WD_TO_NEVER;
@@ -487,7 +488,7 @@ usage(void)
 }
 
 static long
-fetchtimeout(int opt, const char *longopt, const char *myoptarg)
+fetchtimeout(int opt, const char *longopt, const char *myoptarg, int zero_ok)
 {
const char *errstr;
char *p;
@@ -499,7 +500,7 @@ fetchtimeout(int opt, const char *longop
rv = strtol(myoptarg, &p, 0);
if ((p != NULL && *p != '\0') || errno != 0)
errstr = "is not a number";
-   if (rv <= 0)
+   if (rv < 0 || (!zero_ok && rv == 0))
errstr = "must be greater than zero";
if (errstr) {
if (longopt) 
@@ -721,7 +722,7 @@ parseargs(int argc, char *argv[])
break;
 #endif
case 's':
-   nap = fetchtimeout(c, NULL, optarg);
+   nap = fetchtimeout(c, NULL, optarg, 0);
break;
case 'S':
do_syslog = 0;
@@ -734,7 +735,8 @@ parseargs(int argc, char *argv[])
timeout);
break;
case 'T':
-   carp_thresh_seconds = fetchtimeout(c, "NULL", optarg);
+   carp_thresh_seconds =
+   fetchtimeout(c, "NULL", optarg, 0);
break;
case 'w':
do_timedog = 1;
@@ -742,7 +744,7 @@ parseargs(int argc, char *argv[])
case 0:
lopt = longopts[longindex].name;
if (!strcmp(lopt, "pretimeout")) {
-   pretimeout = fetchtimeout(0, lopt, optarg);
+   pretimeout = fetchtimeout(0, lopt, optarg, 0);
} else if (!strcmp(lopt, "pretimeout-action")) {
pretimeout_act = timeout_act_str2int(lopt,
optarg);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r254756 - head/sys/sys

2013-08-23 Thread Alfred Perlstein
Author: alfred
Date: Sat Aug 24 00:30:32 2013
New Revision: 254756
URL: http://svnweb.freebsd.org/changeset/base/254756

Log:
  Grow some spares in struct vfsops.
  
  This should hopefully prevent ABI breakage
  on adding new vfsops in 10.x.

Modified:
  head/sys/sys/mount.h

Modified: head/sys/sys/mount.h
==
--- head/sys/sys/mount.hSat Aug 24 00:29:34 2013(r254755)
+++ head/sys/sys/mount.hSat Aug 24 00:30:32 2013(r254756)
@@ -628,6 +628,7 @@ struct vfsops {
vfs_susp_clean_t*vfs_susp_clean;
vfs_notify_lowervp_t*vfs_reclaim_lowervp;
vfs_notify_lowervp_t*vfs_unlink_lowervp;
+   vfs_mount_t *vfs_spare[6];  /* spares for ABI compat */
 };
 
 vfs_statfs_t   __vfs_statfs;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r254823 - head/sys/net

2013-08-24 Thread Alfred Perlstein
Author: alfred
Date: Sun Aug 25 01:55:14 2013
New Revision: 254823
URL: http://svnweb.freebsd.org/changeset/base/254823

Log:
  Remove the #ifdef OFED from the 20 byte mac in struct llentry.
  
  With this change it is now possible to build the entire infiniband
  stack as modules and load it dynamically including IP over IB.

Modified:
  head/sys/net/if_llatbl.h

Modified: head/sys/net/if_llatbl.h
==
--- head/sys/net/if_llatbl.hSun Aug 25 00:34:44 2013(r254822)
+++ head/sys/net/if_llatbl.hSun Aug 25 01:55:14 2013(r254823)
@@ -75,9 +75,7 @@ struct llentry {
union {
uint64_tmac_aligned;
uint16_tmac16[3];
-#ifdef OFED
uint8_t mac8[20];   /* IB needs 20 bytes. */
-#endif
} ll_addr;
 
/* XXX af-private? */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2013-08-26 Thread Alfred Perlstein

Thanks Gleb.  Will do.

-Alfred

On 8/26/13 4:52 AM, Gleb Smirnoff wrote:

On Sun, Aug 25, 2013 at 01:55:15AM +, Alfred Perlstein wrote:
A> Author: alfred
A> Date: Sun Aug 25 01:55:14 2013
A> New Revision: 254823
A> URL: http://svnweb.freebsd.org/changeset/base/254823
A>
A> Log:
A>   Remove the #ifdef OFED from the 20 byte mac in struct llentry.
A>
A>   With this change it is now possible to build the entire infiniband
A>   stack as modules and load it dynamically including IP over IB.
A>
A> Modified:
A>   head/sys/net/if_llatbl.h
A>
A> Modified: head/sys/net/if_llatbl.h
A> 
==
A> --- head/sys/net/if_llatbl.h  Sun Aug 25 00:34:44 2013(r254822)
A> +++ head/sys/net/if_llatbl.h  Sun Aug 25 01:55:14 2013(r254823)
A> @@ -75,9 +75,7 @@ struct llentry {
A>   union {
A>   uint64_tmac_aligned;
A>   uint16_tmac16[3];
A> -#ifdef OFED
A>   uint8_t mac8[20];   /* IB needs 20 bytes. */
A> -#endif
A>   } ll_addr;
A>
A>   /* XXX af-private? */

#include "opt_ofed.h" should be removed from the file as well.



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


svn commit: r254963 - head/sys/net

2013-08-27 Thread Alfred Perlstein
Author: alfred
Date: Tue Aug 27 16:45:00 2013
New Revision: 254963
URL: http://svnweb.freebsd.org/changeset/base/254963

Log:
  Remove include opt_ofed.h since OFED is unifdef'd.
  
  Pointed out by: glebius

Modified:
  head/sys/net/if_llatbl.h

Modified: head/sys/net/if_llatbl.h
==
--- head/sys/net/if_llatbl.hTue Aug 27 16:30:50 2013(r254962)
+++ head/sys/net/if_llatbl.hTue Aug 27 16:45:00 2013(r254963)
@@ -30,8 +30,6 @@ __FBSDID("$FreeBSD$");
 #ifndef_NET_IF_LLATBL_H_
 #define_NET_IF_LLATBL_H_
 
-#include "opt_ofed.h"
-
 #include 
 #include 
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r255219 - in head: contrib/tcpdump lib/libc lib/libc/capability lib/libc/include lib/libc/sys lib/libprocstat sbin/dhclient sbin/hastd sys/amd64/linux32 sys/bsm sys/cddl/compat/opensol

2014-01-02 Thread Alfred Perlstein

On 1/2/14 1:33 AM, Pawel Jakub Dawidek wrote:

On Wed, Jan 01, 2014 at 11:16:22PM -0800, Stanislav Sedov wrote:

On Sep 4, 2013, at 5:09 PM, Pawel Jakub Dawidek  wrote:


  This commit also breaks compatibility with some existing Capsicum system 
calls,
  but I see no other way to do that. This should be fine as Capsicum is still
  experimental and this change is not going to 9.x.

Hi!

This change also increases the size of kinfo_file structure, which won’t allow
programs not compiled against HEAD and working with kern.info.filedesc sysctl
to run properly on HEAD (e.g. 8.x, 9.x and 10.x jails won’t run properly on 
HEAD,
and it also broke valgrind).  Is there absolutely no way to avoid extending the 
size
of this struct?

Well, I made this change to have space for future cap_rights_t
expension. I did that change for a major branch, so we don't have to do
it in the middle of 10.x or to not block the work until 11.0.

Note that the structure changed size not only because of _kf_cap_spare[3]
field, but also because cap_rights_t is not uint64_t anymore, it is now
struct that contains two uint64_t (1424 - 1392 = 4 * 8).

I'm afraid it is too late to change it for 10.0 at this point anyway.
Not sure if you are aware this was merged to 10, because you write about
10.x jails not working properly on HEAD. 10.x jails will work properly
on HEAD.

BTW. I'd love if we stop using such structures for a running kernel.
We should really move to using libnv to export data like that.


Aren't there enough bits in int _kf_ispare[4];  /* Space 
for more stuff. */
to make this work for the time being until you can provide an alternate 
way to fetch the cap stuff from the kernel.


Afaik you could just remove the "spare" and steal 2 or 4 entries from 
_kf_ispare until it is sorted.


Can you please make use of that and discuss merge to 10 with re@?

It really sounds like breaking top/etc under jails is something that 
should and can be avoided.


Thank you,
-Alfred




  #if defined(__amd64__) || defined(__i386__)
-#defineKINFO_FILE_SIZE 1392
+#defineKINFO_FILE_SIZE 1424
  #endif
  
  struct kinfo_file {

@@ -389,6 +390,7 @@
 uint16_tkf_pad1;/* Round to 32 bit alignment. 
*/
 int _kf_ispare0;/* Space for more stuff. */
 cap_rights_tkf_cap_rights;  /* Capability rights. */
+   uint64_t_kf_cap_spare[3];   /* Space for future 
cap_rights_t. */
 int _kf_ispare[4];  /* Space for more stuff. */
 /* Truncated before copyout in sysctl */
 charkf_path[PATH_MAX];  /* Path to file, if any. */



--
Alfred Perlstein

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

Re: svn commit: r255219 - in head: contrib/tcpdump lib/libc lib/libc/capability lib/libc/include lib/libc/sys lib/libprocstat sbin/dhclient sbin/hastd sys/amd64/linux32 sys/bsm sys/cddl/compat/opensol

2014-01-02 Thread Alfred Perlstein

On 1/2/14 2:49 AM, Pawel Jakub Dawidek wrote:

On Thu, Jan 02, 2014 at 02:28:57AM -0800, Alfred Perlstein wrote:

On 1/2/14 1:33 AM, Pawel Jakub Dawidek wrote:

On Wed, Jan 01, 2014 at 11:16:22PM -0800, Stanislav Sedov wrote:

On Sep 4, 2013, at 5:09 PM, Pawel Jakub Dawidek  wrote:


   This commit also breaks compatibility with some existing Capsicum system 
calls,
   but I see no other way to do that. This should be fine as Capsicum is still
   experimental and this change is not going to 9.x.

Hi!

This change also increases the size of kinfo_file structure, which won’t allow
programs not compiled against HEAD and working with kern.info.filedesc sysctl
to run properly on HEAD (e.g. 8.x, 9.x and 10.x jails won’t run properly on 
HEAD,
and it also broke valgrind).  Is there absolutely no way to avoid extending the 
size
of this struct?

Well, I made this change to have space for future cap_rights_t
expension. I did that change for a major branch, so we don't have to do
it in the middle of 10.x or to not block the work until 11.0.

Note that the structure changed size not only because of _kf_cap_spare[3]
field, but also because cap_rights_t is not uint64_t anymore, it is now
struct that contains two uint64_t (1424 - 1392 = 4 * 8).

I'm afraid it is too late to change it for 10.0 at this point anyway.
Not sure if you are aware this was merged to 10, because you write about
10.x jails not working properly on HEAD. 10.x jails will work properly
on HEAD.

BTW. I'd love if we stop using such structures for a running kernel.
We should really move to using libnv to export data like that.

Aren't there enough bits in int _kf_ispare[4];  /* Space
for more stuff. */
to make this work for the time being until you can provide an alternate
way to fetch the cap stuff from the kernel.

I don't plan to provide alternative way to fetch the cap stuff. Well, I
implemented libnv, which can be used to reimplement how we fetch all
data like kinfo_file in a ABI friendly way, but I don't plan to modify
this specific code myself.


Afaik you could just remove the "spare" and steal 2 or 4 entries from
_kf_ispare until it is sorted.

Yes, this would work for current cap_rights_t structure, at least for
i386 and amd64, but would only allow to expand the structure by one
uint64_t in the future (which might or might not be enough). The
cap_rights_t structure is designed to be expanded to 5 uint64_ts without
breaking ABI. I don't want to stuck with current cap_rights_t that is
designed to expand, but cannot be, because kinfo_file wasn't modified at
the start of a major branch.


Can you please make use of that and discuss merge to 10 with re@?

I'm Bccing re@, but I'm pretty sure it is too late for such a change,
especially that it breaks ABI with all 10-RCs. I'm also not changing my
mind. I'd like to structure to stay as-is.


It really sounds like breaking top/etc under jails is something that
should and can be avoided.

I agree. Maybe it should be done every 10 major releases (I'm still fine
with that rule), but we cannot just stuck with it forever.

My suggestions would be:
1. Move to libnv.
2. Detect that the given binary was compiled against some older version
of this structure and copy old structure to userland. Not sure if we
can do that now or not, but I'd expect we can detect that.


Well I agree strongly with what you are doing except the part where 9.x 
jails and earlier are broken because of this change.


It seems like there is a way out and you agree.  Perhaps since the cap 
fits in the spare area we can make do for the time being?


The way to do a major re-org of the kinfo_file/proc/whatever is to 
either use libnv as you suggest, check the binary version (as you 
suggest) or to make an entirely new one and make the old one 
kinfo_file_old and make a new way to fetch the new data as we did with 
the various syscalls ostatfs, ostat, etc.


It still seems like we have a way out that would even give capabilities 
another "version" (there are enough cells in _kf_ispare for the next 
version of the capabilities code.


-Alfred








   #if defined(__amd64__) || defined(__i386__)
-#defineKINFO_FILE_SIZE 1392
+#defineKINFO_FILE_SIZE 1424
   #endif
   
   struct kinfo_file {

@@ -389,6 +390,7 @@
  uint16_tkf_pad1;/* Round to 32 bit alignment. 
*/
  int _kf_ispare0;/* Space for more stuff. */
  cap_rights_tkf_cap_rights;  /* Capability rights. */
+   uint64_t_kf_cap_spare[3];   /* Space for future 
cap_rights_t. */
  int _kf_ispare[4];  /* Space for more stuff. */
  /* Truncated before copyout in sysctl */
  charkf_path[PATH_MAX];  /* Path to file, if any. */



--
Alfred Perlstein

___
svn

Re: svn commit: r255219 - in head: contrib/tcpdump lib/libc lib/libc/capability lib/libc/include lib/libc/sys lib/libprocstat sbin/dhclient sbin/hastd sys/amd64/linux32 sys/bsm sys/cddl/compat/opensol

2014-01-02 Thread Alfred Perlstein


On 1/2/14, 11:14 AM, John-Mark Gurney wrote:

Konstantin Belousov wrote this message on Thu, Jan 02, 2014 at 15:13 +0200:

Afaik you could just remove the "spare" and steal 2 or 4 entries from
_kf_ispare until it is sorted.

Yes, this would work for current cap_rights_t structure, at least for
i386 and amd64, but would only allow to expand the structure by one
uint64_t in the future (which might or might not be enough). The
cap_rights_t structure is designed to be expanded to 5 uint64_ts without
breaking ABI. I don't want to stuck with current cap_rights_t that is
designed to expand, but cannot be, because kinfo_file wasn't modified at
the start of a major branch.

The ABI stability is not limited to the single branch.  It must be
preserved across whole project lifetime.

Umm. when did this policy change happen?  I thought ABI compatibility
was limited to major releases of FreeBSD?  How are you suppose to do
any work if you can't break ABI ever?

I did a quick search for "freebsd policy abi breakage" and found some
mailing list posts about this, but no authoritative statement...

Of course the problem is that when we move to
(ASN.1/libnv/ctf/YAML/JSON/XML/etc) we will break ABI compatibility too,
or introduce tons of compatibility code that will rot...

I agree, however there is a very easy way to fix it for the time being.  
Let's not be binary about it "well it's going to have to break, so let's 
break it!" when such an easy way to not break it exists.  It should be 
"let's see if there's a non-intrusive way of not breaking it" and the 
answer to that seems to be "yes".


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


Re: svn commit: r255219 - in head: contrib/tcpdump lib/libc lib/libc/capability lib/libc/include lib/libc/sys lib/libprocstat sbin/dhclient sbin/hastd sys/amd64/linux32 sys/bsm sys/cddl/compat/opensol

2014-01-02 Thread Alfred Perlstein


On 1/2/14, 11:34 AM, Konstantin Belousov wrote:

On Thu, Jan 02, 2014 at 11:23:55AM -0800, Alfred Perlstein wrote:

On 1/2/14, 11:14 AM, John-Mark Gurney wrote:

Konstantin Belousov wrote this message on Thu, Jan 02, 2014 at 15:13 +0200:

Afaik you could just remove the "spare" and steal 2 or 4 entries from
_kf_ispare until it is sorted.

Yes, this would work for current cap_rights_t structure, at least for
i386 and amd64, but would only allow to expand the structure by one
uint64_t in the future (which might or might not be enough). The
cap_rights_t structure is designed to be expanded to 5 uint64_ts without
breaking ABI. I don't want to stuck with current cap_rights_t that is
designed to expand, but cannot be, because kinfo_file wasn't modified at
the start of a major branch.

The ABI stability is not limited to the single branch.  It must be
preserved across whole project lifetime.

Umm. when did this policy change happen?  I thought ABI compatibility
was limited to major releases of FreeBSD?  How are you suppose to do
any work if you can't break ABI ever?

I did a quick search for "freebsd policy abi breakage" and found some
mailing list posts about this, but no authoritative statement...

Of course the problem is that when we move to
(ASN.1/libnv/ctf/YAML/JSON/XML/etc) we will break ABI compatibility too,
or introduce tons of compatibility code that will rot...


I agree, however there is a very easy way to fix it for the time being.
Let's not be binary about it "well it's going to have to break, so let's
break it!" when such an easy way to not break it exists.  It should be
"let's see if there's a non-intrusive way of not breaking it" and the
answer to that seems to be "yes".

If parts of ABI is broken, then why spend efforts trying to keep other
parts stable ?  You already have random set of binaries broken, sometimes
in subtle way.  Then, making other interfaces stable is just a waste.

ABI stability is a yes/no proposition, you cannot have it partly done.
Personally, I do not want to spend a time on hobbyist system.

BTW, to point out obvious thing, Linux has almost perfect ABI stability
and forward compatibility.  It is pity to see that our people do not
understand the importance and benefits of it.

I agree strongly.

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


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

2014-01-22 Thread Alfred Perlstein


On 1/22/14, 10:14 AM, John-Mark Gurney wrote:

Scott Long wrote this message on Tue, Jan 21, 2014 at 15:12 -0700:

On Jan 21, 2014, at 9:26 AM, John Baldwin  wrote:


On Monday, January 20, 2014 5:18:44 pm Alexander Kabaev wrote:

On Mon, 20 Jan 2014 11:32:29 -0500
John Baldwin  wrote:


On Sunday 19 January 2014 18:18:03 Rui Paulo wrote:

On 19 Jan 2014, at 17:59, Neel Natu  wrote:

Author: neel
Date: Mon Jan 20 01:59:35 2014
New Revision: 260898
URL: http://svnweb.freebsd.org/changeset/base/260898

Log:
Bump up WITNESS_COUNT from 1024 to 1536 so there are sufficient
entries for
WITNESS to actually work.

This value should be automatically tuned...

How do you propose to do so?  This is the count of locks initialized
before witness' own SYSINIT is executed and the array it sizes is
allocated statically at compile time.  This used to not be a static
array, but an intrusive list embedded in locks themselves, but we
decided to shave a pointer off of each lock that was only used for
that and to use a statically sized table instead.

--
John Baldwin

As  +  * MAXCPU, as evidently most recent
overflows reported were caused by jacking MAXCPU up from its default
value?

If raising MAXCPU changes the number of unique lock names used, then the
locks are named incorrectly.  We don't use the 'pid' in the name for
PROC_LOCK precisely so that WITNESS will treat them all the same so
that if if it learns a lock order for pid 37 it enforces the same lock
order for pid 38.  Device locks should follow a similar rule.  They
should generally not include the device name (and in some cases they
really shouldn't even have the driver name).

Why shouldn?t they have a driver and device name?  Wouldn?t it help identify
possible deadlocks from driver instances calling into each other?

Locks have a name and a type.  The type is used for witness, but if it
is NULL, the name is used.  So you could if you wanted, create a common
type, and then put driver/device name in name, but the passed in strings
to both name and type have to be stable storage (only the pointer is
stored), so you can't use a stack variable to construct it.

Hmm, what if locks had a pointer to a 2 element char * array, the first 
being the name, the second the type.  That would keep the size of the 
lock down and most locks could share a common tuple of name/type in each 
subsystem.  This would allow us to get rid of the pending static list.


effectively:
struct lock_object {
char *lo_name;  /* Individual lock name. */
u_int   lo_flags;
u_int   lo_data;/* General class specific data. */
struct  witness *lo_witness;/* Data for witness. */
};

would change to:
struct lock_object {
char **lo_name_type;  /* Individual lock 
name[0]/type[1]. */

u_int   lo_flags;
u_int   lo_data;/* General class specific data. */
struct  witness *lo_witness;/* Data for witness. */
};

This may be somewhat disruptive, I haven't played with how it would 
actually change driver/etc/code.


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


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

2014-01-22 Thread Alfred Perlstein


On 1/22/14, 12:27 PM, John Baldwin wrote:

On Wednesday, January 22, 2014 2:06:39 pm Alfred Perlstein wrote:

Hmm, what if locks had a pointer to a 2 element char * array, the first
being the name, the second the type.  That would keep the size of the
lock down and most locks could share a common tuple of name/type in each
subsystem.  This would allow us to get rid of the pending static list.

effectively:
struct lock_object {
  char *lo_name;  /* Individual lock name. */
  u_int   lo_flags;
  u_int   lo_data;/* General class specific data. */
  struct  witness *lo_witness;/* Data for witness. */
};

would change to:
struct lock_object {
  char **lo_name_type;  /* Individual lock
name[0]/type[1]. */
  u_int   lo_flags;
  u_int   lo_data;/* General class specific data. */
  struct  witness *lo_witness;/* Data for witness. */
};

This may be somewhat disruptive, I haven't played with how it would
actually change driver/etc/code.

Where would the memory for the char* array come from?

That is a good question.  I suspect it would be up to the subsystem to 
allocate it.


Wouldn't it be trivial for *most* of the subsystems to simply have this 
either as a static global or static function variable:


static char *mutex_typename = { "kqueue", "foo" };

Under kern I see this:
grep mtx_init * | grep -v NULL
...
kern_rmlock.c:mtx_init(&rm->rm_lock_mtx, name, "rmlock_mtx", 
MTX_NOWITNESS);

subr_bus.c:mtx_init(&devsoftc.mtx, "dev mtx", "devd", MTX_DEF);

Those are solved with statics.

Another example:

sys/dev/ae/if_ae.c
mtx_init(&sc->mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 
MTX_DEF);


I think the array could be in the softc here? sc->mutex_name_type[0] = 
device_get_nameunit(dev); sc->mutex_name_type[1] = MTX_NETWORK_LOCK;


Do we want to do that?  It moves "wasting space" to another variable.

I'm not sure where there isn't the possibility of using either static 
(for a global mutex) or space inside the equiv of the softc (or proc or 
whatever) for this?


I'm not sure this is a good idea, just an idea.  Are there places where 
it's not as simple as doing this?


-Alfred

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


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

2014-01-22 Thread Alfred Perlstein


On 1/22/14, 1:22 PM, John Baldwin wrote:

On Wednesday, January 22, 2014 3:59:37 pm Alfred Perlstein wrote:

On 1/22/14, 12:27 PM, John Baldwin wrote:

On Wednesday, January 22, 2014 2:06:39 pm Alfred Perlstein wrote:

Hmm, what if locks had a pointer to a 2 element char * array, the first
being the name, the second the type.  That would keep the size of the
lock down and most locks could share a common tuple of name/type in each
subsystem.  This would allow us to get rid of the pending static list.

effectively:
struct lock_object {
   char *lo_name;  /* Individual lock name. */
   u_int   lo_flags;
   u_int   lo_data;/* General class specific data.

*/

   struct  witness *lo_witness;/* Data for witness. */
};

would change to:
struct lock_object {
   char **lo_name_type;  /* Individual lock
name[0]/type[1]. */
   u_int   lo_flags;
   u_int   lo_data;/* General class specific data.

*/

   struct  witness *lo_witness;/* Data for witness. */
};

This may be somewhat disruptive, I haven't played with how it would
actually change driver/etc/code.

Where would the memory for the char* array come from?


That is a good question.  I suspect it would be up to the subsystem to
allocate it.

Wouldn't it be trivial for *most* of the subsystems to simply have this
either as a static global or static function variable:

static char *mutex_typename = { "kqueue", "foo" };

Under kern I see this:
grep mtx_init * | grep -v NULL
...
kern_rmlock.c:mtx_init(&rm->rm_lock_mtx, name, "rmlock_mtx",
MTX_NOWITNESS);
subr_bus.c:mtx_init(&devsoftc.mtx, "dev mtx", "devd", MTX_DEF);

Those are solved with statics.

Another example:

sys/dev/ae/if_ae.c
  mtx_init(&sc->mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);

I think the array could be in the softc here? sc->mutex_name_type[0] =
device_get_nameunit(dev); sc->mutex_name_type[1] = MTX_NETWORK_LOCK;

Do we want to do that?  It moves "wasting space" to another variable.

I'm not sure where there isn't the possibility of using either static
(for a global mutex) or space inside the equiv of the softc (or proc or
whatever) for this?

I'm not sure this is a good idea, just an idea.  Are there places where
it's not as simple as doing this?

To be honest, the whole name vs type thing isn't widely used, and it makes
the mtx_init() function kind of fugly.  I think what I would actually prefer
is to just kill it, changing the various places that pass a separate name to
just pass the type instead.  Note that none of the other lock APIs even allow
setting a separate type.  This would let us remove the static pending list
array as well.

(And yes, I added the name vs type thing, but at this point I think it did
not turn out nearly as useful as I had thought it would be.)

The original issue of picking useful-to-witness lock names (i.e. not just
using device_get_nameunit()) still remains of course.

I really want to agree, but anything that reduces the immediate ability 
for people to diagnose problems really makes me worry.


This would mean that you would see "network device lock" or some "type" 
but not know the actual owner.


I would say that maybe given this it's just better to grow 
WITNESS_PENDING based on maxcpu like the PR I pointed out, that way we 
do not introduce churn AND we maintain the debug-ability.


http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/185831

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


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

2014-01-22 Thread Alfred Perlstein


On 1/22/14, 2:52 PM, John-Mark Gurney wrote:

Alfred Perlstein wrote this message on Wed, Jan 22, 2014 at 14:15 -0800:

On 1/22/14, 1:22 PM, John Baldwin wrote:

On Wednesday, January 22, 2014 3:59:37 pm Alfred Perlstein wrote:

On 1/22/14, 12:27 PM, John Baldwin wrote:

On Wednesday, January 22, 2014 2:06:39 pm Alfred Perlstein wrote:

Hmm, what if locks had a pointer to a 2 element char * array, the first
being the name, the second the type.  That would keep the size of the
lock down and most locks could share a common tuple of name/type in each
subsystem.  This would allow us to get rid of the pending static list.

effectively:
struct lock_object {
   char *lo_name;  /* Individual lock name. */
   u_int   lo_flags;
   u_int   lo_data;/* General class specific
   data.

*/

   struct  witness *lo_witness;/* Data for witness. */
};

would change to:
struct lock_object {
   char **lo_name_type;  /* Individual lock
name[0]/type[1]. */
   u_int   lo_flags;
   u_int   lo_data;/* General class specific
   data.

*/

   struct  witness *lo_witness;/* Data for witness. */
};

This may be somewhat disruptive, I haven't played with how it would
actually change driver/etc/code.

Where would the memory for the char* array come from?


That is a good question.  I suspect it would be up to the subsystem to
allocate it.

Wouldn't it be trivial for *most* of the subsystems to simply have this
either as a static global or static function variable:

static char *mutex_typename = { "kqueue", "foo" };

Under kern I see this:
grep mtx_init * | grep -v NULL
...
kern_rmlock.c:mtx_init(&rm->rm_lock_mtx, name, "rmlock_mtx",
MTX_NOWITNESS);
subr_bus.c:mtx_init(&devsoftc.mtx, "dev mtx", "devd", MTX_DEF);

Those are solved with statics.

Another example:

sys/dev/ae/if_ae.c
  mtx_init(&sc->mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);

I think the array could be in the softc here? sc->mutex_name_type[0] =
device_get_nameunit(dev); sc->mutex_name_type[1] = MTX_NETWORK_LOCK;

Do we want to do that?  It moves "wasting space" to another variable.

I'm not sure where there isn't the possibility of using either static
(for a global mutex) or space inside the equiv of the softc (or proc or
whatever) for this?

I'm not sure this is a good idea, just an idea.  Are there places where
it's not as simple as doing this?

To be honest, the whole name vs type thing isn't widely used, and it makes
the mtx_init() function kind of fugly.  I think what I would actually
prefer
is to just kill it, changing the various places that pass a separate name
to
just pass the type instead.  Note that none of the other lock APIs even
allow
setting a separate type.  This would let us remove the static pending list
array as well.

(And yes, I added the name vs type thing, but at this point I think it did
not turn out nearly as useful as I had thought it would be.)

The original issue of picking useful-to-witness lock names (i.e. not just
using device_get_nameunit()) still remains of course.


I really want to agree, but anything that reduces the immediate ability
for people to diagnose problems really makes me worry.

This would mean that you would see "network device lock" or some "type"
but not know the actual owner.

isn't it usually apparent which lock it is from the backtrace?


Isn't the backtrace pretty obvious given IP/PC?

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


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

2014-01-22 Thread Alfred Perlstein


On 1/22/14, 8:34 PM, Rui Paulo wrote:

On 22 Jan 2014, at 20:05, Adrian Chadd  wrote:


.. Make it be an offset into the table rather than a pointer, then we can do 
dirty rcu style hacks to just replace and grow the table as we need more memory.

Don't we have a standard way to pull memory from the top of the physmem area 
early on for allocations like this?

Perhaps a bit overkill for this problem?


Probably.. I keep thinking we should just increase the size by 2x but 
allow platforms to override. for "SMALL".


-Alfred

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


Re: svn commit: r250411 - in head/sys: conf kern sys

2013-05-09 Thread Alfred Perlstein

On 5/9/13 3:13 PM, Attilio Rao wrote:

On Thu, May 9, 2013 at 10:56 PM, Marcel Moolenaar  wrote:

On May 9, 2013, at 9:46 AM, Attilio Rao  wrote:


On Thu, May 9, 2013 at 6:28 PM, Marcel Moolenaar  wrote:

Author: marcel
Date: Thu May  9 16:28:18 2013
New Revision: 250411
URL: http://svnweb.freebsd.org/changeset/base/250411

Log:
  Add option WITNESS_NO_VNODE to suppress printing LORs between VNODE
  locks. To support this, VNODE locks are created with the LK_IS_VNODE
  flag. This flag is propagated down using the LO_IS_VNODE flag.

  Note that WITNESS still records the LOR. Only the printing and the
  optional entering into the kernel debugger is bypassed with the
  WITNESS_NO_VNODE option.

This is the wrong way to deal with such problem and I avoided to do
something like that on purpose.

I disagree. We have known LOR messages between VNODE locks that
pollute the console and so far we haven't fixed the root cause
in some form or shape. Silencing this known case is good to
maximize the attention LORs need to be given while still have
witness involved to catch locking problems with vnodes that are
of a different nature.


The way to fix this is to implement LK_NOWITNESS on a per-lock basis
into lockmgr, propagate the same concept to the vn_lock() (which
should be basically done automatically) and finally identify the
false-positive case and commit for them explicitely LK_NOWITNESS on a
per-call basis, explaining in detail why the single case reported is a
false-positive.

This is worse. You want witness involved.


Please revert this patch asap.

This change does not inhibit people from fixing the problem at the
root cause, and in the mean time maximize witness' effectiveness.
Calling for a backout is unwarranted and unnecessarily aggressive.

I completely disagree with the whole content of your e-mail.
Thanks for disrupting a useful tool along with other commits which
happened in the past by other people about invariants effectiveness.



This should be taken offline.  Marcel has some needs which without such 
a change are hard to manage I encourage you to assist him and meeting 
half-way on this as it will greatly help the project.


Please discuss this offline a bit so you can see where each are coming from.

If you would like to cc me about this I can help mediate and explain 
this pragmatic approach to assertions.


Will you both be at BSDCan?  That would be even better.

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


Re: svn commit: r250411 - in head/sys: conf kern sys

2013-05-10 Thread Alfred Perlstein

On 5/10/13 8:46 AM, Marcel Moolenaar wrote:


And all I did is to allow someone (= Juniper) to not print the LOR
for this well-known and mostly ignored case that is impacting our
ability to keep witness enabled. And the reason I had to do that is
that this is a long-standing LOR that isn't being addressed. The
FreeBSD community apparently has settled on just ignoring it.



This whole issue about not allowing developers to mute warnings stems 
from some FreeBSD developers inability to imagine that they are not 
locus of architecture at an organization.


We really need to gain the ability to put ourselves in the shoes of 
someone that is just one of MANY people working on a product, a product 
that can choose its platform, FreeBSD, or if FreeBSD fails, then Linux 
or whatever works.


Allowing people to customize and/or mute these error messages, when they 
are often superfluous is good.  It allows the team to work on the parts 
that they need to work on and ignore the noise from other broken parts 
of FreeBSD that will eventually be fixed by the community.


If FreeBSD is supposed to be for the community, then why does it have 
portions (WITNESS/INVARIANTS/etc?) that are not for the community?


-Alfred


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


Re: svn commit: r250411 - in head/sys: conf kern sys

2013-05-11 Thread Alfred Perlstein
Can we just admit to ourselves that tweaks to debugging macros/printing 
and WITNESS are our kernel developer's "bikeshed zone" and get over the 
fact that people's needs may diverge and changing non-default behavior 
in non-critical paths is not going to be the death of the kernel as we 
know it?


I could certainly believe that this sort of thing needs long and 
thorough discussion if it wasn't the equivalent of style tweaks to manpages.


Let's leave the long and lengthy discussions to things that matter such 
as standards compliance, ABI, API and really cool performance and 
stability stuff.


-Alfred




On 5/11/13 5:43 PM, Jeff Roberson wrote:

On Thu, 9 May 2013, Marcel Moolenaar wrote:


Author: marcel
Date: Thu May  9 16:28:18 2013
New Revision: 250411
URL: http://svnweb.freebsd.org/changeset/base/250411

Log:
 Add option WITNESS_NO_VNODE to suppress printing LORs between VNODE
 locks. To support this, VNODE locks are created with the LK_IS_VNODE
 flag. This flag is propagated down using the LO_IS_VNODE flag.

 Note that WITNESS still records the LOR. Only the printing and the
 optional entering into the kernel debugger is bypassed with the
 WITNESS_NO_VNODE option.


I'm replying to the original commit because the resulting thread got 
way out of hand.  We need to all take a deep breath and take a 
pragmatic approach to solving the problem at hand.


Let me first say I understand the utility here as this is also coming 
up in my organization.  Test, and users, do not want to see erroneous 
warning messages.  I understand that.  Let's find a solution.


Secondly, I think this project has grown too far for us to commit 
changes like this without some focused discussion.  We need to be more 
mindful of the size of the impact and the number of people who are 
interested in a particular area.  I'm not picking on you Marcel 
because this sort of thing has been coming up lately and we have all 
been guilty of it from time to time.  There are more companies and 
individuals than ever trying to push work into the repository and 
we're having some growing pains.


I am intimately familiar with the problems that lead to these 
erroneous witness messages as I have tracked down many of them and am 
even responsible for the code that generates them in some cases.  Let 
me first outline a handful of generic problems.  The root cause is 
that witness can not determine the real order between two locks due to 
relationships too complex to describe with a pair of strings.


One example, which has been brought up, is the hierarchical nature of 
vnode locks.  This impacts vnodes within one filesystem but it also 
involves vnodes between two different filesystems as you cross mount 
points.  We can construct perfectly valid and deadlock free chains of 
mount points that have two different filesystem types in different 
orders which will LOR at the boundaries.  We already skip duplicates 
to avoid this problem within each filesystem.  We need to skip 
cross-filesystem duplicates, most desirably at the few specific places 
where this happens. This problem comes up especially for devfs because 
we lock devvps while file vnodes are locked but we lock devfs 
directories after the rootfs lock when crossing mountpoints in lookup.


A second example, is locks of a fundamentally different type that have 
a complex ordering relationship.  For example, a vnode lock may be 
acquired after a buf lock belonging to the parent's directory block.  
A cg buf lock may be acquired after any file buf lock.  Here we want 
to ignore interactions between these two specific types at this 
particular location but not others as they may be unsafe.


The third example, is a complex locking pattern with shared locks as 
presented by dirhash.  We are seeing a similar pattern develop in the 
vm where we are going to use an exclusive object lock to protect pages 
or a shared object lock + a page lock.  The semantics only get more 
complex as we push for more scalability. I expect to see more of these 
patterns develop.


None of these problems can be solved with names alone.  So far we've 
just lived with the warnings and we're no longer willing to accept 
that. What we need is a solution that blesses the specific instances 
and the specific lock classes involved without silencing legitimate 
warnings that may only occur after new code is added. For example, it 
may be safe to add a sx lock around some vnode code but you may not 
notice that you LOR if you silence all witness warnings related to the 
vnode lock site.


I believe that the perfect solution would be a mechanism that could 
teach witness about and enforce these specific relationships.  
However, that may be computationally prohibitive and too complex to 
code.  A more reasonable option would be to bless the specific 
relationships at the specific call sites. Turning all witness off at 
particular sites or with particular types renders important 
infrastructure useless for very large fun

Re: svn commit: r250411 - in head/sys: conf kern sys

2013-05-14 Thread Alfred Perlstein

On 5/13/13 12:58 PM, Will Andrews wrote:

On Sun, May 12, 2013 at 12:09 AM, Alfred Perlstein  wrote:


Can we just admit to ourselves that tweaks to debugging macros/printing
and WITNESS are our kernel developer's "bikeshed zone" and get over the
fact that people's needs may diverge and changing non-default behavior in
non-critical paths is not going to be the death of the kernel as we know it?

I could certainly believe that this sort of thing needs long and thorough
discussion if it wasn't the equivalent of style tweaks to manpages.

Let's leave the long and lengthy discussions to things that matter such as
standards compliance, ABI, API and really cool performance and stability
stuff.


Except that this is *not* the equivalent of style tweaks.  I'm not sure how
you got that from Jeff's email.  False positive LORs results in people
ignoring all LORs, including real ones.  And that impacts stability.
  Especially if you are trying to implement performance improvements or fix
bugs; in that case, the LORs act as a safeguard against violating existing
object relationship assumptions.

Having worked on ZFS for a while, I can say that many (if not most) of the
LORs reported there that are false positives are because the locks
represent objects that are frequently and legitimately related to each
other in reverse orders, due to reuse of object types at different points
in the overall hierarchy.  So, I agree that the biggest issue is that
witness's model of comparing strings is insufficient for representing more
complex lock relationships.

In ZFS, in most cases, the locks are acquired after having already (in
debug builds) checked these relationships.  It seems appropriate,
therefore, that witness should be improved by adding the ability to bless
specific object relationships on a per-lock entry basis, so that we
continue to be notified about *legitimate* LORs, at every call site and
between every pair of object types.

It also seems best to add a new API for this purpose, so that it can be
used regardless of which lock type is being used, without having to modify
all existing lock calls.  This does mean that code in FreeBSD would need to
independently verify the object relationships, but doing so is, IMHO, a lot
easier to improve upon than folding this functionality into existing APIs
by adding more arguments.

--Will.



Sure WITNESS should be made to a lot of things.

One volunteer made it work for a subset of developers without breaking 
it for the people outside of that subset.


Time for the pitchforks and demands that IF YOU TOUCH IT, YOU BETTER FIX 
IT TO MY LIKING!!!


Give me a break already.

I highly doubt that Marcel or anyone would object to someone coming 
forward with this "better way", the problem is that no one will, however 
they will harp on bikeshedding about it to no end without a problem.


Stop blocking, start coding.

Start taking a step forward as the gift it is and take time to improve 
upon it instead of bashing it to pieces.


-Alfred





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


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

2013-06-02 Thread Alfred Perlstein
Hey Konstaintin, shouldn't this be scaled against the actual amount of 
KVA we have instead of an arbitrary limit?


-Alfred

On 6/2/13 9:16 PM, Konstantin Belousov wrote:

Author: kib
Date: Mon Jun  3 04:16:48 2013
New Revision: 251282
URL: http://svnweb.freebsd.org/changeset/base/251282

Log:
   When auto-sizing the buffer cache, limit the amount of physical memory
   used as the estimation of size, to 32GB.  This provides around 100K of
   buffer headers and corresponding KVA for buffer map at the peak.
   Sizing the cache larger is not useful, also resulting in the wasting
   and exhausting of KVA for large machines.
   
   Reported and tested by:	bdrewery

   Sponsored by:The FreeBSD Foundation

Modified:
   head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Mon Jun  3 04:11:42 2013(r251281)
+++ head/sys/kern/vfs_bio.c Mon Jun  3 04:16:48 2013(r251282)
@@ -560,7 +560,8 @@ kern_vfs_bio_buffer_alloc(caddr_t v, lon
nbuf += min((physmem_est - 4096) / factor,
65536 / factor);
if (physmem_est > 65536)
-   nbuf += (physmem_est - 65536) * 2 / (factor * 5);
+   nbuf += min((physmem_est - 65536) * 2 / (factor * 5),
+   32 * 1024 * 1024 / (factor * 5));
  
  		if (maxbcache && nbuf > maxbcache / BKVASIZE)

nbuf = maxbcache / BKVASIZE;



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


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

2013-06-03 Thread Alfred Perlstein

On 6/3/13 12:55 AM, Konstantin Belousov wrote:

On Sun, Jun 02, 2013 at 09:27:53PM -0700, Alfred Perlstein wrote:

Hey Konstaintin, shouldn't this be scaled against the actual amount of
KVA we have instead of an arbitrary limit?

The commit changes the buffer cache to scale according to the available
KVA, making the scaling less dumb.

I do not understand what exactly do you want to do, please describe the
algorithm you propose to implement instead of my change.


Sure, how about deriving the hardcoded "32" from the maxkva a machine 
can have?


Is that possible?

-Alfred




-Alfred

On 6/2/13 9:16 PM, Konstantin Belousov wrote:

Author: kib
Date: Mon Jun  3 04:16:48 2013
New Revision: 251282
URL: http://svnweb.freebsd.org/changeset/base/251282

Log:
When auto-sizing the buffer cache, limit the amount of physical memory
used as the estimation of size, to 32GB.  This provides around 100K of
buffer headers and corresponding KVA for buffer map at the peak.
Sizing the cache larger is not useful, also resulting in the wasting
and exhausting of KVA for large machines.

Reported and tested by:	bdrewery

Sponsored by:   The FreeBSD Foundation

Modified:
head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Mon Jun  3 04:11:42 2013(r251281)
+++ head/sys/kern/vfs_bio.c Mon Jun  3 04:16:48 2013(r251282)
@@ -560,7 +560,8 @@ kern_vfs_bio_buffer_alloc(caddr_t v, lon
nbuf += min((physmem_est - 4096) / factor,
65536 / factor);
if (physmem_est > 65536)
-   nbuf += (physmem_est - 65536) * 2 / (factor * 5);
+   nbuf += min((physmem_est - 65536) * 2 / (factor * 5),
+   32 * 1024 * 1024 / (factor * 5));
   
   		if (maxbcache && nbuf > maxbcache / BKVASIZE)

nbuf = maxbcache / BKVASIZE;



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


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

2013-06-05 Thread Alfred Perlstein


Konstantin, is there any way to take some of Bruce's feedback into 
account to get rid of the hard coded max?


-Alfred

On 6/4/13 1:14 AM, Bruce Evans wrote:

On Tue, 4 Jun 2013, Konstantin Belousov wrote:


On Mon, Jun 03, 2013 at 02:24:26AM -0700, Alfred Perlstein wrote:

On 6/3/13 12:55 AM, Konstantin Belousov wrote:

On Sun, Jun 02, 2013 at 09:27:53PM -0700, Alfred Perlstein wrote:
Hey Konstaintin, shouldn't this be scaled against the actual 
amount of

KVA we have instead of an arbitrary limit?
The commit changes the buffer cache to scale according to the 
available

KVA, making the scaling less dumb.

I do not understand what exactly do you want to do, please describe 
the

algorithm you propose to implement instead of my change.


Sure, how about deriving the hardcoded "32" from the maxkva a machine
can have?

Is that possible?

I do not see why this would be useful. Initially I thought about simply
capping nbuf at 10 without referencing any "memory". Then I realized
that this would somewhat conflict with (unlikely) changes to the value
of BKVASIZE due to "factor".


The presence of BKVASIZE in 'factor' is a bug.  My version never had this
bug (see below for a patch).  The scaling should be to maximize nbuf,
subject to non-arbitrary limits on physical memory and kva, and now an
arbirary limit of about 10 / (BKVASIZE / 16384) on nbuf.  Your new
limit is arbitrary so it shouldn't affect nbuf depending on BKVASIZE.

Expanding BKVASIZE should expand kva use, but on i386 this will soon
hit a non-arbitary kva limit so nbuf will not be as high as preferred.
nbuf needs to be very large mainly to support file systems with small
buffers.  Even 10 only gives 50MB of buffering if the fs block
size is 512.  This would shrink to only 12.5MB if BKVASIZE is expanded
by a factor of 4 and the bug is not fixed.  If 25000 buffers after
expanding BKVASIZE is enough, then that should be the arbitary limit
(independent of BKVASIZE) so as to save physical memory.

On i386 systems with 1GB RAM, nbuf defaults to about 7000.  With an
fs block size of 512, that can buffer 3.5MB.  Expanding BKVASIZE by a
factor of 4 shrinks this to 0.875MB in -current.  That is ridiculously
small.  VMIO limits the lossage from this.

BKVASIZE was originally 8KB.  I forget if nbuf was halved by not 
modifying

the scale factor when it was expanded to 16KB.  Probably not.  I used to
modify the scale factor to get twice as many as the default nbuf, but
once the default nbuf expanded to a few thousand it became large enough
for most purposes so I no longer do this.

Except on arches with extremely limit kva like i386, KVASIZE should be
MAXBSIZE, and all of the complications for expanding a buffer's kva
beyond BKVASIZE and handling the fragmentation problems caused by this
shouldn't exist.  Limits like vfs.maxbufspace should be scaled by
NOMBSIZE = current BKVASIZE instead of BKVASIZE.  Oops, my NOMBSIZE
has similar logical problems to BKVASIZE.  It needs to be precisely
16KB to preserve the defaults for nbuf and maxbufspace, but the nominal
(ffs) buffer size is now 32KB.  So the heuristic scale factors should
use the historical magic number 16K.  I changed sequential_heuristic()
to use a hard-coded 16K instead of BKVASIZE.  The correct number here
depends on disk technology.

The patch has many style fixes:

@ Index: vfs_bio.c
@ ===
@ RCS file: /home/ncvs/src/sys/kern/vfs_bio.c,v
@ retrieving revision 1.436
@ diff -u -2 -r1.436 vfs_bio.c
@ --- vfs_bio.c17 Jun 2004 17:16:49 -1.436
@ +++ vfs_bio.c3 Jun 2013 16:04:34 -
@ @@ -419,64 +493,54 @@
@ @  /*
@ - * Calculating buffer cache scaling values and reserve space for 
buffer

@ + * Calculate buffer cache scaling values and reserve space for buffer
@   * headers.  This is called during low level kernel initialization and
@   * may be called more then once.  We CANNOT write to the memory area
@   * being reserved at this time.
@   */
@ -caddr_t
@ -kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
@ +void *
@ +vfs_bio_alloc(void *va)

The API name was verbose and bogus.  The prefix for this subsystem is
vfs_bio_, not kern_vfs_bio_.  This is a generic allocation routine.
It always allocated swbufs and has expanded to do more allocations.

@  {
@ -/*
@ - * physmem_est is in pages.  Convert it to kilobytes (assumes
@ - * PAGE_SIZE is >= 1K)
@ - */
@ -physmem_est = physmem_est * (PAGE_SIZE / 1024);

I use the global physmem.  This change may be too i386-specific. In
with 8-16 RAM, a significant amount of RAM may be eaten by the kernel
image or perhaps just unavailable to the kernel.  Now memories are
larger and the amount eaten is relatively insignificant (since we are
only using a small fraction of physmem, only the relative error matters).

@ +int factor, memsize;
@ @  /*
@ - * The nominal buffer size (an

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

2013-06-07 Thread Alfred Perlstein

On 6/5/13 10:55 AM, Adrian Chadd wrote:

... can people please boot an i386 kernel w/ this stuff in it, with
the RAM constrained to something small (say, 128mb), and verify that
you can at least start a buildworld (minus clang, of course) without
panicing?

There's a recent PR
(http://www.freebsd.org/cgi/query-pr.cgi?pr=179112) which shows
regressions on i386 + small RAM platforms.

I know it's a different area, but I'd really appreciate it if people
better tested this stuff out before they make i386 (and by extension,
any platform with limited KVA and small amounts of RAM) unusable
through carelessness.


Adrian, I'm pretty sure that kib's patch actually limits memory.

The concern I have is that it's a hard limit that appears not based on 
KVA, but rather 32GB.


I can be wrong, but Bruce's feedback looks like it backs up my concern.

-Alfred



Thanks,



Adrian

On 5 June 2013 05:11, Alfred Perlstein  wrote:

Konstantin, is there any way to take some of Bruce's feedback into account
to get rid of the hard coded max?

-Alfred


On 6/4/13 1:14 AM, Bruce Evans wrote:

On Tue, 4 Jun 2013, Konstantin Belousov wrote:


On Mon, Jun 03, 2013 at 02:24:26AM -0700, Alfred Perlstein wrote:

On 6/3/13 12:55 AM, Konstantin Belousov wrote:

On Sun, Jun 02, 2013 at 09:27:53PM -0700, Alfred Perlstein wrote:

Hey Konstaintin, shouldn't this be scaled against the actual amount of
KVA we have instead of an arbitrary limit?

The commit changes the buffer cache to scale according to the available
KVA, making the scaling less dumb.

I do not understand what exactly do you want to do, please describe the
algorithm you propose to implement instead of my change.


Sure, how about deriving the hardcoded "32" from the maxkva a machine
can have?

Is that possible?

I do not see why this would be useful. Initially I thought about simply
capping nbuf at 10 without referencing any "memory". Then I realized
that this would somewhat conflict with (unlikely) changes to the value
of BKVASIZE due to "factor".


The presence of BKVASIZE in 'factor' is a bug.  My version never had this
bug (see below for a patch).  The scaling should be to maximize nbuf,
subject to non-arbitrary limits on physical memory and kva, and now an
arbirary limit of about 10 / (BKVASIZE / 16384) on nbuf.  Your new
limit is arbitrary so it shouldn't affect nbuf depending on BKVASIZE.

Expanding BKVASIZE should expand kva use, but on i386 this will soon
hit a non-arbitary kva limit so nbuf will not be as high as preferred.
nbuf needs to be very large mainly to support file systems with small
buffers.  Even 10 only gives 50MB of buffering if the fs block
size is 512.  This would shrink to only 12.5MB if BKVASIZE is expanded
by a factor of 4 and the bug is not fixed.  If 25000 buffers after
expanding BKVASIZE is enough, then that should be the arbitary limit
(independent of BKVASIZE) so as to save physical memory.

On i386 systems with 1GB RAM, nbuf defaults to about 7000.  With an
fs block size of 512, that can buffer 3.5MB.  Expanding BKVASIZE by a
factor of 4 shrinks this to 0.875MB in -current.  That is ridiculously
small.  VMIO limits the lossage from this.

BKVASIZE was originally 8KB.  I forget if nbuf was halved by not modifying
the scale factor when it was expanded to 16KB.  Probably not.  I used to
modify the scale factor to get twice as many as the default nbuf, but
once the default nbuf expanded to a few thousand it became large enough
for most purposes so I no longer do this.

Except on arches with extremely limit kva like i386, KVASIZE should be
MAXBSIZE, and all of the complications for expanding a buffer's kva
beyond BKVASIZE and handling the fragmentation problems caused by this
shouldn't exist.  Limits like vfs.maxbufspace should be scaled by
NOMBSIZE = current BKVASIZE instead of BKVASIZE.  Oops, my NOMBSIZE
has similar logical problems to BKVASIZE.  It needs to be precisely
16KB to preserve the defaults for nbuf and maxbufspace, but the nominal
(ffs) buffer size is now 32KB.  So the heuristic scale factors should
use the historical magic number 16K.  I changed sequential_heuristic()
to use a hard-coded 16K instead of BKVASIZE.  The correct number here
depends on disk technology.

The patch has many style fixes:

@ Index: vfs_bio.c
@ ===
@ RCS file: /home/ncvs/src/sys/kern/vfs_bio.c,v
@ retrieving revision 1.436
@ diff -u -2 -r1.436 vfs_bio.c
@ --- vfs_bio.c17 Jun 2004 17:16:49 -1.436
@ +++ vfs_bio.c3 Jun 2013 16:04:34 -
@ @@ -419,64 +493,54 @@
@ @  /*
@ - * Calculating buffer cache scaling values and reserve space for buffer
@ + * Calculate buffer cache scaling values and reserve space for buffer
@   * headers.  This is called during low level kernel initialization and
@   * may be called more then once.  We CANNOT write to the memory area
@   * bei

Re: svn commit: r251507 - head/usr.sbin/portsnap/portsnap

2013-06-07 Thread Alfred Perlstein

Oh no, you made me destructive!! :)

-Alfred

On 6/7/13 1:21 PM, Xin LI wrote:

Author: delphij
Date: Fri Jun  7 20:21:30 2013
New Revision: 251507
URL: http://svnweb.freebsd.org/changeset/base/251507

Log:
   Make 'portsnap alfred' overwrite ports tree if it's not created by a
   portsnap.
   
   Discussed with:	alfred

   Reviewed by: cperciva

Modified:
   head/usr.sbin/portsnap/portsnap/portsnap.sh

Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh
==
--- head/usr.sbin/portsnap/portsnap/portsnap.sh Fri Jun  7 19:45:04 2013
(r251506)
+++ head/usr.sbin/portsnap/portsnap/portsnap.sh Fri Jun  7 20:21:30 2013
(r251507)
@@ -1113,7 +1113,7 @@ cmd_alfred() {
else
cmd_cron
fi
-   if [ -d ${PORTSDIR} ]; then
+   if [ -r ${PORTSDIR}/.portsnap.INDEX ]; then
cmd_update
else
cmd_extract



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


svn commit: r257862 - head/sys/ofed/include/linux

2013-11-08 Thread Alfred Perlstein
Author: alfred
Date: Fri Nov  8 18:20:19 2013
New Revision: 257862
URL: http://svnweb.freebsd.org/changeset/base/257862

Log:
  Use explicit long cast to avoid overflow in bitopts.
  
  This was causing problems with the buddy allocator inside of
  ofed.
  
  Submitted by: odeds

Modified:
  head/sys/ofed/include/linux/bitops.h

Modified: head/sys/ofed/include/linux/bitops.h
==
--- head/sys/ofed/include/linux/bitops.hFri Nov  8 17:27:38 2013
(r257861)
+++ head/sys/ofed/include/linux/bitops.hFri Nov  8 18:20:19 2013
(r257862)
@@ -286,14 +286,14 @@ bitmap_empty(unsigned long *addr, int si
 #defineNBLONG  (NBBY * sizeof(long))
 
 #defineset_bit(i, a)   
\
-atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1 << (i) % NBLONG)
+atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << (i) % NBLONG)
 
 #defineclear_bit(i, a) 
\
-atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1 << (i) % NBLONG)
+atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << (i) % NBLONG)
 
 #definetest_bit(i, a)  
\
 !!(atomic_load_acq_long(&((volatile long *)(a))[(i)/NBLONG]) & \
-1 << ((i) % NBLONG))
+1UL << ((i) % NBLONG))
 
 static inline long
 test_and_clear_bit(long bit, long *var)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r257863 - head/sys/ofed/drivers/net/mlx4

2013-11-08 Thread Alfred Perlstein
Author: alfred
Date: Fri Nov  8 18:26:28 2013
New Revision: 257863
URL: http://svnweb.freebsd.org/changeset/base/257863

Log:
  Fix for bad performance when mtu is increased.
  
  Update the auto moderation behavior in the mlxen driver to match
  the new LINUX OFED code.
  
  Submitted by: odeds

Modified:
  head/sys/ofed/drivers/net/mlx4/en_ethtool.c
  head/sys/ofed/drivers/net/mlx4/en_netdev.c
  head/sys/ofed/drivers/net/mlx4/mlx4_en.h

Modified: head/sys/ofed/drivers/net/mlx4/en_ethtool.c
==
--- head/sys/ofed/drivers/net/mlx4/en_ethtool.c Fri Nov  8 18:20:19 2013
(r257862)
+++ head/sys/ofed/drivers/net/mlx4/en_ethtool.c Fri Nov  8 18:26:28 2013
(r257863)
@@ -366,13 +366,13 @@ static int mlx4_en_set_coalesce(struct n
priv->rx_usecs_high = coal->rx_coalesce_usecs_high;
priv->sample_interval = coal->rate_sample_interval;
priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce;
-   priv->last_moder_time = MLX4_EN_AUTO_CONF;
if (priv->adaptive_rx_coal)
return 0;
 
for (i = 0; i < priv->rx_ring_num; i++) {
priv->rx_cq[i].moder_cnt = priv->rx_frames;
priv->rx_cq[i].moder_time = priv->rx_usecs;
+   priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]);
if (err)
return err;
@@ -418,6 +418,7 @@ static int mlx4_en_set_ringparam(struct 
u32 rx_size, tx_size;
int port_up = 0;
int err = 0;
+   int i;
 
if (param->rx_jumbo_pending || param->rx_mini_pending)
return -EINVAL;
@@ -456,6 +457,15 @@ static int mlx4_en_set_ringparam(struct 
en_err(priv, "Failed starting port\n");
}
 
+   for (i = 0; i < priv->rx_ring_num; i++) {
+   priv->rx_cq[i].moder_cnt = priv->rx_frames;
+   priv->rx_cq[i].moder_time = priv->rx_usecs;
+   priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
+   err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]);
+   if (err)
+   goto out;
+   }
+
 out:
mutex_unlock(&mdev->state_lock);
return err;

Modified: head/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- head/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri Nov  8 18:20:19 2013
(r257862)
+++ head/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri Nov  8 18:26:28 2013
(r257863)
@@ -318,6 +318,9 @@ static void mlx4_en_set_default_moderati
cq = &priv->rx_cq[i];
cq->moder_cnt = priv->rx_frames;
cq->moder_time = priv->rx_usecs;
+   priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
+   priv->last_moder_packets[i] = 0;
+   priv->last_moder_bytes[i] = 0;
}
 
for (i = 0; i < priv->tx_ring_num; i++) {
@@ -333,11 +336,8 @@ static void mlx4_en_set_default_moderati
priv->rx_usecs_high = MLX4_EN_RX_COAL_TIME_HIGH;
priv->sample_interval = MLX4_EN_SAMPLE_INTERVAL;
priv->adaptive_rx_coal = 1;
-   priv->last_moder_time = MLX4_EN_AUTO_CONF;
priv->last_moder_jiffies = 0;
-   priv->last_moder_packets = 0;
priv->last_moder_tx_packets = 0;
-   priv->last_moder_bytes = 0;
 }
 
 static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
@@ -349,43 +349,29 @@ static void mlx4_en_auto_moderation(stru
unsigned long avg_pkt_size;
unsigned long rx_packets;
unsigned long rx_bytes;
-   unsigned long tx_packets;
-   unsigned long tx_pkt_diff;
unsigned long rx_pkt_diff;
int moder_time;
-   int i, err;
+   int ring, err;
 
if (!priv->adaptive_rx_coal || period < priv->sample_interval * HZ)
return;
-
-   spin_lock(&priv->stats_lock);
-   rx_packets = priv->dev->if_ipackets;
-   rx_bytes = priv->dev->if_ibytes;
-   tx_packets = priv->dev->if_opackets;
-   spin_unlock(&priv->stats_lock);
-
-   if (!priv->last_moder_jiffies || !period)
-   goto out;
-
-   tx_pkt_diff = ((unsigned long) (tx_packets -
-   priv->last_moder_tx_packets));
-   rx_pkt_diff = ((unsigned long) (rx_packets -
-   priv->last_moder_packets));
-   packets = max(tx_pkt_diff, rx_pkt_diff);
-   rate = packets * HZ / period;
-   avg_pkt_size = packets ? ((unsigned long) (rx_bytes -
-priv->last_moder_bytes)) / packets : 0;
-
-   /* Apply auto-moderation only when packet rate exceeds a rate that
-* it matters */
-   if (rate > MLX4_EN_RX_RATE_THRESH) {
-   /* If tx and rx packet rates are not balanced, assume that
-* traffic is mainly BW bound and apply max

svn commit: r257864 - head/sys/ofed/drivers/net/mlx4

2013-11-08 Thread Alfred Perlstein
Author: alfred
Date: Fri Nov  8 18:28:48 2013
New Revision: 257864
URL: http://svnweb.freebsd.org/changeset/base/257864

Log:
  Do not use a sleep lock when protecting the driver flags.
  
  This was causing a locking issue with lagg
  
  Submitted by: odeds

Modified:
  head/sys/ofed/drivers/net/mlx4/en_netdev.c
  head/sys/ofed/drivers/net/mlx4/mlx4_en.h

Modified: head/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- head/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri Nov  8 18:26:28 2013
(r257863)
+++ head/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri Nov  8 18:28:48 2013
(r257864)
@@ -919,6 +919,7 @@ void mlx4_en_destroy_netdev(struct net_d
 
mtx_destroy(&priv->stats_lock.m);
mtx_destroy(&priv->vlan_lock.m);
+   mtx_destroy(&priv->ioctl_lock.m);
kfree(priv);
if_free(dev);
 }
@@ -1087,9 +1088,9 @@ static int mlx4_en_ioctl(struct ifnet *d
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
-   mutex_lock(&mdev->state_lock);
+spin_lock(&priv->ioctl_lock);
mlx4_en_set_multicast(dev);
-   mutex_unlock(&mdev->state_lock);
+spin_unlock(&priv->ioctl_lock);
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
@@ -1510,6 +1511,7 @@ int mlx4_en_init_netdev(struct mlx4_en_d
priv->msg_enable = MLX4_EN_MSG_LEVEL;
priv->ip_reasm = priv->mdev->profile.ip_reasm;
mtx_init(&priv->stats_lock.m, "mlx4 stats", NULL, MTX_DEF);
+   mtx_init(&priv->ioctl_lock.m, "mlx4 ioctl", NULL, MTX_DEF);
mtx_init(&priv->vlan_lock.m, "mlx4 vlan", NULL, MTX_DEF);
INIT_WORK(&priv->mcast_task, mlx4_en_do_set_multicast);
INIT_WORK(&priv->watchdog_task, mlx4_en_restart);

Modified: head/sys/ofed/drivers/net/mlx4/mlx4_en.h
==
--- head/sys/ofed/drivers/net/mlx4/mlx4_en.hFri Nov  8 18:26:28 2013
(r257863)
+++ head/sys/ofed/drivers/net/mlx4/mlx4_en.hFri Nov  8 18:28:48 2013
(r257864)
@@ -493,6 +493,7 @@ struct mlx4_en_priv {
spinlock_t vlan_lock;
struct mlx4_en_port_state port_state;
spinlock_t stats_lock;
+   spinlock_t ioctl_lock;
 
unsigned long last_moder_packets[MAX_RX_RINGS];
unsigned long last_moder_tx_packets;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r257867 - in stable/10/sys/ofed: drivers/net/mlx4 include/linux

2013-11-08 Thread Alfred Perlstein
Author: alfred
Date: Fri Nov  8 22:29:07 2013
New Revision: 257867
URL: http://svnweb.freebsd.org/changeset/base/257867

Log:
  MFC: r257862, r257863, r257864
  
  r257862:
  
  Use explicit long cast to avoid overflow in bitopts.
  
  This was causing problems with the buddy allocator inside of
  ofed.
  
  r257863:
  
  Fix for bad performance when mtu is increased.
  
  Update the auto moderation behavior in the mlxen driver to match
  the new LINUX OFED code.
  
  r257864:
  
  Do not use a sleep lock when protecting the driver flags.
  
  This was causing a locking issue with lagg.
  
  Approved by:  re

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/en_ethtool.c
  stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
  stable/10/sys/ofed/drivers/net/mlx4/mlx4_en.h
  stable/10/sys/ofed/include/linux/bitops.h
Directory Properties:
  stable/10/sys/   (props changed)

Modified: stable/10/sys/ofed/drivers/net/mlx4/en_ethtool.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/en_ethtool.cFri Nov  8 21:03:47 
2013(r257866)
+++ stable/10/sys/ofed/drivers/net/mlx4/en_ethtool.cFri Nov  8 22:29:07 
2013(r257867)
@@ -366,13 +366,13 @@ static int mlx4_en_set_coalesce(struct n
priv->rx_usecs_high = coal->rx_coalesce_usecs_high;
priv->sample_interval = coal->rate_sample_interval;
priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce;
-   priv->last_moder_time = MLX4_EN_AUTO_CONF;
if (priv->adaptive_rx_coal)
return 0;
 
for (i = 0; i < priv->rx_ring_num; i++) {
priv->rx_cq[i].moder_cnt = priv->rx_frames;
priv->rx_cq[i].moder_time = priv->rx_usecs;
+   priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]);
if (err)
return err;
@@ -418,6 +418,7 @@ static int mlx4_en_set_ringparam(struct 
u32 rx_size, tx_size;
int port_up = 0;
int err = 0;
+   int i;
 
if (param->rx_jumbo_pending || param->rx_mini_pending)
return -EINVAL;
@@ -456,6 +457,15 @@ static int mlx4_en_set_ringparam(struct 
en_err(priv, "Failed starting port\n");
}
 
+   for (i = 0; i < priv->rx_ring_num; i++) {
+   priv->rx_cq[i].moder_cnt = priv->rx_frames;
+   priv->rx_cq[i].moder_time = priv->rx_usecs;
+   priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
+   err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]);
+   if (err)
+   goto out;
+   }
+
 out:
mutex_unlock(&mdev->state_lock);
return err;

Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Fri Nov  8 21:03:47 
2013(r257866)
+++ stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Fri Nov  8 22:29:07 
2013(r257867)
@@ -318,6 +318,9 @@ static void mlx4_en_set_default_moderati
cq = &priv->rx_cq[i];
cq->moder_cnt = priv->rx_frames;
cq->moder_time = priv->rx_usecs;
+   priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
+   priv->last_moder_packets[i] = 0;
+   priv->last_moder_bytes[i] = 0;
}
 
for (i = 0; i < priv->tx_ring_num; i++) {
@@ -333,11 +336,8 @@ static void mlx4_en_set_default_moderati
priv->rx_usecs_high = MLX4_EN_RX_COAL_TIME_HIGH;
priv->sample_interval = MLX4_EN_SAMPLE_INTERVAL;
priv->adaptive_rx_coal = 1;
-   priv->last_moder_time = MLX4_EN_AUTO_CONF;
priv->last_moder_jiffies = 0;
-   priv->last_moder_packets = 0;
priv->last_moder_tx_packets = 0;
-   priv->last_moder_bytes = 0;
 }
 
 static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
@@ -349,43 +349,29 @@ static void mlx4_en_auto_moderation(stru
unsigned long avg_pkt_size;
unsigned long rx_packets;
unsigned long rx_bytes;
-   unsigned long tx_packets;
-   unsigned long tx_pkt_diff;
unsigned long rx_pkt_diff;
int moder_time;
-   int i, err;
+   int ring, err;
 
if (!priv->adaptive_rx_coal || period < priv->sample_interval * HZ)
return;
-
-   spin_lock(&priv->stats_lock);
-   rx_packets = priv->dev->if_ipackets;
-   rx_bytes = priv->dev->if_ibytes;
-   tx_packets = priv->dev->if_opackets;
-   spin_unlock(&priv->stats_lock);
-
-   if (!priv->last_moder_jiffies || !period)
-   goto out;
-
-   tx_pkt_diff = ((unsigned long) (tx_packets -
-   priv->last_moder_tx_packets));
-   rx_pkt_diff = ((unsigned long) (rx_packets -
-   priv->last_moder_packets));
-   packets = max(tx_p

svn commit: r258242 - stable/10/sys/ofed/drivers/net/mlx4

2013-11-16 Thread Alfred Perlstein
Author: alfred
Date: Sun Nov 17 01:07:46 2013
New Revision: 258242
URL: http://svnweb.freebsd.org/changeset/base/258242

Log:
  MFC: 257542
  
  Fix API mismatch exposed by lagg.
  
  When destroying a lagg the driver tries to restore the old mac and
  fails due to API mismatch.
  
  Submitted by:   Shahar Klein (shahark at mellanox.com)
  Approved by: re

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
Directory Properties:
  stable/10/sys/   (props changed)

Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Sun Nov 17 00:49:55 
2013(r258241)
+++ stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Sun Nov 17 01:07:46 
2013(r258242)
@@ -604,8 +604,8 @@ int mlx4_en_start_port(struct net_device
en_dbg(DRV, priv, "Setting mac for port %d\n", priv->port);
err = mlx4_register_mac(mdev->dev, priv->port,
mlx4_en_mac_to_u64(IF_LLADDR(dev)));
-   if (err) {
-   en_err(priv, "Failed setting port mac\n");
+   if (err < 0) {
+   en_err(priv, "Failed setting port mac err=%d\n", err);
goto tx_err;
}
mdev->mac_removed[priv->port] = 0;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r258276 - head/sys/ofed/drivers/net/mlx4

2013-11-17 Thread Alfred Perlstein
Author: alfred
Date: Sun Nov 17 20:58:31 2013
New Revision: 258276
URL: http://svnweb.freebsd.org/changeset/base/258276

Log:
  Fix creating a vlan over lagg over mlxen crash.
  
  PR:   181931
  Submitted by: Shahar Klein (shahark mellanox.com)

Modified:
  head/sys/ofed/drivers/net/mlx4/en_netdev.c

Modified: head/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- head/sys/ofed/drivers/net/mlx4/en_netdev.c  Sun Nov 17 20:29:33 2013
(r258275)
+++ head/sys/ofed/drivers/net/mlx4/en_netdev.c  Sun Nov 17 20:58:31 2013
(r258276)
@@ -52,6 +52,9 @@ static void mlx4_en_vlan_rx_add_vid(void
int idx;
u8 field;
 
+   if (arg != priv)
+   return;
+
if ((vid == 0) || (vid > 4095))/* Invalid */
return;
en_dbg(HW, priv, "adding VLAN:%d\n", vid);
@@ -73,6 +76,9 @@ static void mlx4_en_vlan_rx_kill_vid(voi
int idx;
u8 field;
 
+   if (arg != priv)
+   return;
+
if ((vid == 0) || (vid > 4095))/* Invalid */
return;
en_dbg(HW, priv, "Killing VID:%d\n", vid);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r258280 - stable/10/sys/ofed/drivers/net/mlx4

2013-11-17 Thread Alfred Perlstein
Author: alfred
Date: Sun Nov 17 22:24:34 2013
New Revision: 258280
URL: http://svnweb.freebsd.org/changeset/base/258280

Log:
  MFC:  258276
  
  Fix creating a vlan over lagg over mlxen crash.
  
  PR: 181931
  Submitted by:   Shahar Klein (shahark mellanox.com)
  
  Approved by:  re

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
Directory Properties:
  stable/10/sys/   (props changed)

Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Sun Nov 17 21:36:19 
2013(r258279)
+++ stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Sun Nov 17 22:24:34 
2013(r258280)
@@ -52,6 +52,9 @@ static void mlx4_en_vlan_rx_add_vid(void
int idx;
u8 field;
 
+   if (arg != priv)
+   return;
+
if ((vid == 0) || (vid > 4095))/* Invalid */
return;
en_dbg(HW, priv, "adding VLAN:%d\n", vid);
@@ -73,6 +76,9 @@ static void mlx4_en_vlan_rx_kill_vid(voi
int idx;
u8 field;
 
+   if (arg != priv)
+   return;
+
if ((vid == 0) || (vid > 4095))/* Invalid */
return;
en_dbg(HW, priv, "Killing VID:%d\n", vid);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r259114 - head/sys/modules/crypto

2013-12-08 Thread Alfred Perlstein
Author: alfred
Date: Mon Dec  9 02:06:52 2013
New Revision: 259114
URL: http://svnweb.freebsd.org/changeset/base/259114

Log:
  Chase down cryptodeflate.c change from r259109.

Modified:
  head/sys/modules/crypto/Makefile

Modified: head/sys/modules/crypto/Makefile
==
--- head/sys/modules/crypto/MakefileMon Dec  9 01:30:20 2013
(r259113)
+++ head/sys/modules/crypto/MakefileMon Dec  9 02:06:52 2013
(r259114)
@@ -11,7 +11,7 @@
 KMOD   = crypto
 SRCS   = crypto.c cryptodev_if.c
 SRCS   += criov.c cryptosoft.c xform.c
-SRCS   += cast.c deflate.c rmd160.c rijndael-alg-fst.c rijndael-api.c
+SRCS   += cast.c cryptodeflate.c rmd160.c rijndael-alg-fst.c rijndael-api.c
 SRCS   += skipjack.c bf_enc.c bf_ecb.c bf_skey.c
 SRCS   += des_ecb.c des_enc.c des_setkey.c
 SRCS   += sha1.c sha2.c
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r259411 - head/sys/ofed/drivers/net/mlx4

2013-12-14 Thread Alfred Perlstein
Author: alfred
Date: Sun Dec 15 07:07:13 2013
New Revision: 259411
URL: http://svnweb.freebsd.org/changeset/base/259411

Log:
  Defer start/stop port to workqueues.
  
  We need to do this because the Linux compat layer uses sx(9) for
  mutex, however the lagg code uses rmlocks and calls into the mellanox
  driver.  This causes deadlock due to sleeping while holding a rmlock.
  
  Submitted by: Shahar Klein (shahark mellanox.com)
  MFC After: 3 days.

Modified:
  head/sys/ofed/drivers/net/mlx4/en_netdev.c
  head/sys/ofed/drivers/net/mlx4/mlx4_en.h

Modified: head/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- head/sys/ofed/drivers/net/mlx4/en_netdev.c  Sun Dec 15 07:04:59 2013
(r259410)
+++ head/sys/ofed/drivers/net/mlx4/en_netdev.c  Sun Dec 15 07:07:13 2013
(r259411)
@@ -153,6 +153,19 @@ restart:
return (i);
 }
 
+static void mlx4_en_stop_port(struct net_device *dev)
+{
+   struct mlx4_en_priv *priv = netdev_priv(dev);
+ 
+   queue_work(priv->mdev->workqueue, &priv->stop_port_task);
+}
+
+static void mlx4_en_start_port(struct net_device *dev)
+{
+   struct mlx4_en_priv *priv = netdev_priv(dev);
+
+   queue_work(priv->mdev->workqueue, &priv->start_port_task);
+}
 
 static void mlx4_en_set_multicast(struct net_device *dev)
 {
@@ -473,6 +486,7 @@ static void mlx4_en_do_get_stats(struct 
 
queue_delayed_work(mdev->workqueue, &priv->stats_task, 
STATS_DELAY);
}
+   mlx4_en_QUERY_PORT(priv->mdev, priv->port);
mutex_unlock(&mdev->state_lock);
 }
 
@@ -498,8 +512,31 @@ static void mlx4_en_linkstate(struct wor
mutex_unlock(&mdev->state_lock);
 }
 
+static void mlx4_en_lock_and_stop_port(struct work_struct *work)
+{
+   struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
+stop_port_task);
+   struct net_device *dev = priv->dev;
+   struct mlx4_en_dev *mdev = priv->mdev;
+ 
+   mutex_lock(&mdev->state_lock);
+   mlx4_en_do_stop_port(dev);
+   mutex_unlock(&mdev->state_lock);
+}
+
+static void mlx4_en_lock_and_start_port(struct work_struct *work)
+{
+   struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
+start_port_task);
+   struct net_device *dev = priv->dev;
+   struct mlx4_en_dev *mdev = priv->mdev;
+
+   mutex_lock(&mdev->state_lock);
+   mlx4_en_do_start_port(dev);
+   mutex_unlock(&mdev->state_lock);
+}
 
-int mlx4_en_start_port(struct net_device *dev)
+int mlx4_en_do_start_port(struct net_device *dev)
 {
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -691,7 +728,7 @@ cq_err:
 }
 
 
-void mlx4_en_stop_port(struct net_device *dev)
+void mlx4_en_do_stop_port(struct net_device *dev)
 {
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -761,8 +798,8 @@ reset:
 
mutex_lock(&mdev->state_lock);
if (priv->port_up) {
-   mlx4_en_stop_port(dev);
-   if (mlx4_en_start_port(dev))
+   mlx4_en_do_stop_port(dev);
+   if (mlx4_en_do_start_port(dev))
en_err(priv, "Failed restarting port %d\n", priv->port);
}
mutex_unlock(&mdev->state_lock);
@@ -793,7 +830,7 @@ mlx4_en_init_locked(struct mlx4_en_priv 
dev = priv->dev;
mdev = priv->mdev;
if (dev->if_drv_flags & IFF_DRV_RUNNING)
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
 
if (!mdev->device_up) {
en_err(priv, "Cannot open - device down/disabled\n");
@@ -816,7 +853,7 @@ mlx4_en_init_locked(struct mlx4_en_priv 
}
 
mlx4_en_set_default_moderation(priv);
-   if (mlx4_en_start_port(dev))
+   if (mlx4_en_do_start_port(dev))
en_err(priv, "Failed starting port:%d\n", priv->port);
 }
 
@@ -905,7 +942,7 @@ void mlx4_en_destroy_netdev(struct net_d
mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
 
mutex_lock(&mdev->state_lock);
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
mutex_unlock(&mdev->state_lock);
 
cancel_delayed_work(&priv->stats_task);
@@ -925,7 +962,6 @@ void mlx4_en_destroy_netdev(struct net_d
 
mtx_destroy(&priv->stats_lock.m);
mtx_destroy(&priv->vlan_lock.m);
-   mtx_destroy(&priv->ioctl_lock.m);
kfree(priv);
if_free(dev);
 }
@@ -951,9 +987,9 @@ static int mlx4_en_change_mtu(struct net
 * the port */
en_dbg(DRV, priv, "Change MTU called with card 
down!?\n");
} else {
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
mlx4_en_set_default_moderation(priv);
-  

svn commit: r259608 - stable/10/sys/ofed/drivers/net/mlx4

2013-12-18 Thread Alfred Perlstein
Author: alfred
Date: Thu Dec 19 07:33:07 2013
New Revision: 259608
URL: http://svnweb.freebsd.org/changeset/base/259608

Log:
  Defer start/stop port to workqueues.
  
  MFC: 259411

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
  stable/10/sys/ofed/drivers/net/mlx4/mlx4_en.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Thu Dec 19 07:20:37 
2013(r259607)
+++ stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Thu Dec 19 07:33:07 
2013(r259608)
@@ -153,6 +153,19 @@ restart:
return (i);
 }
 
+static void mlx4_en_stop_port(struct net_device *dev)
+{
+   struct mlx4_en_priv *priv = netdev_priv(dev);
+ 
+   queue_work(priv->mdev->workqueue, &priv->stop_port_task);
+}
+
+static void mlx4_en_start_port(struct net_device *dev)
+{
+   struct mlx4_en_priv *priv = netdev_priv(dev);
+
+   queue_work(priv->mdev->workqueue, &priv->start_port_task);
+}
 
 static void mlx4_en_set_multicast(struct net_device *dev)
 {
@@ -473,6 +486,7 @@ static void mlx4_en_do_get_stats(struct 
 
queue_delayed_work(mdev->workqueue, &priv->stats_task, 
STATS_DELAY);
}
+   mlx4_en_QUERY_PORT(priv->mdev, priv->port);
mutex_unlock(&mdev->state_lock);
 }
 
@@ -498,8 +512,31 @@ static void mlx4_en_linkstate(struct wor
mutex_unlock(&mdev->state_lock);
 }
 
+static void mlx4_en_lock_and_stop_port(struct work_struct *work)
+{
+   struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
+stop_port_task);
+   struct net_device *dev = priv->dev;
+   struct mlx4_en_dev *mdev = priv->mdev;
+ 
+   mutex_lock(&mdev->state_lock);
+   mlx4_en_do_stop_port(dev);
+   mutex_unlock(&mdev->state_lock);
+}
+
+static void mlx4_en_lock_and_start_port(struct work_struct *work)
+{
+   struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
+start_port_task);
+   struct net_device *dev = priv->dev;
+   struct mlx4_en_dev *mdev = priv->mdev;
+
+   mutex_lock(&mdev->state_lock);
+   mlx4_en_do_start_port(dev);
+   mutex_unlock(&mdev->state_lock);
+}
 
-int mlx4_en_start_port(struct net_device *dev)
+int mlx4_en_do_start_port(struct net_device *dev)
 {
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -691,7 +728,7 @@ cq_err:
 }
 
 
-void mlx4_en_stop_port(struct net_device *dev)
+void mlx4_en_do_stop_port(struct net_device *dev)
 {
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -761,8 +798,8 @@ reset:
 
mutex_lock(&mdev->state_lock);
if (priv->port_up) {
-   mlx4_en_stop_port(dev);
-   if (mlx4_en_start_port(dev))
+   mlx4_en_do_stop_port(dev);
+   if (mlx4_en_do_start_port(dev))
en_err(priv, "Failed restarting port %d\n", priv->port);
}
mutex_unlock(&mdev->state_lock);
@@ -793,7 +830,7 @@ mlx4_en_init_locked(struct mlx4_en_priv 
dev = priv->dev;
mdev = priv->mdev;
if (dev->if_drv_flags & IFF_DRV_RUNNING)
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
 
if (!mdev->device_up) {
en_err(priv, "Cannot open - device down/disabled\n");
@@ -816,7 +853,7 @@ mlx4_en_init_locked(struct mlx4_en_priv 
}
 
mlx4_en_set_default_moderation(priv);
-   if (mlx4_en_start_port(dev))
+   if (mlx4_en_do_start_port(dev))
en_err(priv, "Failed starting port:%d\n", priv->port);
 }
 
@@ -905,7 +942,7 @@ void mlx4_en_destroy_netdev(struct net_d
mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
 
mutex_lock(&mdev->state_lock);
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
mutex_unlock(&mdev->state_lock);
 
cancel_delayed_work(&priv->stats_task);
@@ -925,7 +962,6 @@ void mlx4_en_destroy_netdev(struct net_d
 
mtx_destroy(&priv->stats_lock.m);
mtx_destroy(&priv->vlan_lock.m);
-   mtx_destroy(&priv->ioctl_lock.m);
kfree(priv);
if_free(dev);
 }
@@ -951,9 +987,9 @@ static int mlx4_en_change_mtu(struct net
 * the port */
en_dbg(DRV, priv, "Change MTU called with card 
down!?\n");
} else {
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
mlx4_en_set_default_moderation(priv);
-   err = mlx4_en_start_port(dev);
+   err = mlx4_en_do_start_port(dev);
if (err) {
en_err(priv, "Failed res

svn commit: r259616 - releng/10.0/sys/ofed/drivers/net/mlx4

2013-12-19 Thread Alfred Perlstein
Author: alfred
Date: Thu Dec 19 15:45:03 2013
New Revision: 259616
URL: http://svnweb.freebsd.org/changeset/base/259616

Log:
  Defer start/stop port to workqueues.
  MF10: r259608
  
  Approved by:  re

Modified:
  releng/10.0/sys/ofed/drivers/net/mlx4/en_netdev.c
  releng/10.0/sys/ofed/drivers/net/mlx4/mlx4_en.h
Directory Properties:
  releng/10.0/   (props changed)

Modified: releng/10.0/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- releng/10.0/sys/ofed/drivers/net/mlx4/en_netdev.c   Thu Dec 19 15:31:20 
2013(r259615)
+++ releng/10.0/sys/ofed/drivers/net/mlx4/en_netdev.c   Thu Dec 19 15:45:03 
2013(r259616)
@@ -153,6 +153,19 @@ restart:
return (i);
 }
 
+static void mlx4_en_stop_port(struct net_device *dev)
+{
+   struct mlx4_en_priv *priv = netdev_priv(dev);
+ 
+   queue_work(priv->mdev->workqueue, &priv->stop_port_task);
+}
+
+static void mlx4_en_start_port(struct net_device *dev)
+{
+   struct mlx4_en_priv *priv = netdev_priv(dev);
+
+   queue_work(priv->mdev->workqueue, &priv->start_port_task);
+}
 
 static void mlx4_en_set_multicast(struct net_device *dev)
 {
@@ -473,6 +486,7 @@ static void mlx4_en_do_get_stats(struct 
 
queue_delayed_work(mdev->workqueue, &priv->stats_task, 
STATS_DELAY);
}
+   mlx4_en_QUERY_PORT(priv->mdev, priv->port);
mutex_unlock(&mdev->state_lock);
 }
 
@@ -498,8 +512,31 @@ static void mlx4_en_linkstate(struct wor
mutex_unlock(&mdev->state_lock);
 }
 
+static void mlx4_en_lock_and_stop_port(struct work_struct *work)
+{
+   struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
+stop_port_task);
+   struct net_device *dev = priv->dev;
+   struct mlx4_en_dev *mdev = priv->mdev;
+ 
+   mutex_lock(&mdev->state_lock);
+   mlx4_en_do_stop_port(dev);
+   mutex_unlock(&mdev->state_lock);
+}
+
+static void mlx4_en_lock_and_start_port(struct work_struct *work)
+{
+   struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
+start_port_task);
+   struct net_device *dev = priv->dev;
+   struct mlx4_en_dev *mdev = priv->mdev;
+
+   mutex_lock(&mdev->state_lock);
+   mlx4_en_do_start_port(dev);
+   mutex_unlock(&mdev->state_lock);
+}
 
-int mlx4_en_start_port(struct net_device *dev)
+int mlx4_en_do_start_port(struct net_device *dev)
 {
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -691,7 +728,7 @@ cq_err:
 }
 
 
-void mlx4_en_stop_port(struct net_device *dev)
+void mlx4_en_do_stop_port(struct net_device *dev)
 {
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -761,8 +798,8 @@ reset:
 
mutex_lock(&mdev->state_lock);
if (priv->port_up) {
-   mlx4_en_stop_port(dev);
-   if (mlx4_en_start_port(dev))
+   mlx4_en_do_stop_port(dev);
+   if (mlx4_en_do_start_port(dev))
en_err(priv, "Failed restarting port %d\n", priv->port);
}
mutex_unlock(&mdev->state_lock);
@@ -793,7 +830,7 @@ mlx4_en_init_locked(struct mlx4_en_priv 
dev = priv->dev;
mdev = priv->mdev;
if (dev->if_drv_flags & IFF_DRV_RUNNING)
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
 
if (!mdev->device_up) {
en_err(priv, "Cannot open - device down/disabled\n");
@@ -816,7 +853,7 @@ mlx4_en_init_locked(struct mlx4_en_priv 
}
 
mlx4_en_set_default_moderation(priv);
-   if (mlx4_en_start_port(dev))
+   if (mlx4_en_do_start_port(dev))
en_err(priv, "Failed starting port:%d\n", priv->port);
 }
 
@@ -905,7 +942,7 @@ void mlx4_en_destroy_netdev(struct net_d
mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
 
mutex_lock(&mdev->state_lock);
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
mutex_unlock(&mdev->state_lock);
 
cancel_delayed_work(&priv->stats_task);
@@ -925,7 +962,6 @@ void mlx4_en_destroy_netdev(struct net_d
 
mtx_destroy(&priv->stats_lock.m);
mtx_destroy(&priv->vlan_lock.m);
-   mtx_destroy(&priv->ioctl_lock.m);
kfree(priv);
if_free(dev);
 }
@@ -951,9 +987,9 @@ static int mlx4_en_change_mtu(struct net
 * the port */
en_dbg(DRV, priv, "Change MTU called with card 
down!?\n");
} else {
-   mlx4_en_stop_port(dev);
+   mlx4_en_do_stop_port(dev);
mlx4_en_set_default_moderation(priv);
-   err = mlx4_en_start_port(dev);
+   err = mlx4_en_do_start_port(dev);
if (err) {
   

svn commit: r255932 - in head/sys: conf contrib/rdma dev/cxgb/ulp/iw_cxgb modules modules/ibcore modules/ipoib modules/mlx4 modules/mlx4ib ofed/drivers/infiniband/core ofed/drivers/infiniband/hw/ml...

2013-09-28 Thread Alfred Perlstein
Author: alfred
Date: Sun Sep 29 00:35:03 2013
New Revision: 255932
URL: http://svnweb.freebsd.org/changeset/base/255932

Log:
  Update OFED to Linux 3.7 and update Mellanox drivers.
  
  Update the OFED Infiniband core to the version supplied in Linux
  version 3.7.
  
  The update to OFED is nearly all additional defines and functions
  with the exception of the addition of additional parameters to
  ib_register_device() and the reg_user_mr callback.
  
  In addition the ibcore (Infiniband core) and ipoib (IP over Infiniband)
  have both been made into completely loadable modules to facilitate
  testing of the OFED stack in FreeBSD.
  
  Finally the Mellanox Infiniband drivers are now updated to the
  latest version shipping with Linux 3.7.
  
  Submitted by: Mellanox FreeBSD driver team:
  Oded Shanoon (odeds mellanox.com),
  Meny Yossefi (menyy mellanox.com),
  Orit Moskovich (oritm mellanox.com)
  
  Approved by: re

Added:
  head/sys/modules/ibcore/
  head/sys/modules/ibcore/Makefile   (contents, props changed)
  head/sys/modules/ipoib/
  head/sys/modules/ipoib/Makefile   (contents, props changed)
  head/sys/ofed/drivers/infiniband/hw/mlx4/alias_GUID.c   (contents, props 
changed)
  head/sys/ofed/drivers/infiniband/hw/mlx4/cm.c   (contents, props changed)
  head/sys/ofed/drivers/infiniband/hw/mlx4/mcg.c   (contents, props changed)
  head/sys/ofed/drivers/infiniband/hw/mlx4/sysfs.c   (contents, props changed)
  head/sys/ofed/drivers/net/mlx4/resource_tracker.c   (contents, props changed)
  head/sys/ofed/drivers/net/mlx4/sys_tune.c   (contents, props changed)
  head/sys/ofed/include/linux/atomic.h   (contents, props changed)
  head/sys/ofed/include/linux/clocksource.h   (contents, props changed)
  head/sys/ofed/include/rdma/ib_pma.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/contrib/rdma/ib_umem.h
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  head/sys/modules/Makefile
  head/sys/modules/mlx4/Makefile
  head/sys/modules/mlx4ib/Makefile
  head/sys/ofed/drivers/infiniband/core/addr.c
  head/sys/ofed/drivers/infiniband/core/cma.c
  head/sys/ofed/drivers/infiniband/core/core_priv.h
  head/sys/ofed/drivers/infiniband/core/device.c
  head/sys/ofed/drivers/infiniband/core/sa_query.c
  head/sys/ofed/drivers/infiniband/core/sysfs.c
  head/sys/ofed/drivers/infiniband/core/uverbs_cmd.c
  head/sys/ofed/drivers/infiniband/core/uverbs_main.c
  head/sys/ofed/drivers/infiniband/core/verbs.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/Kconfig
  head/sys/ofed/drivers/infiniband/hw/mlx4/Makefile
  head/sys/ofed/drivers/infiniband/hw/mlx4/ah.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/cq.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/mad.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_ib.h
  head/sys/ofed/drivers/infiniband/hw/mlx4/mr.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/qp.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/srq.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/user.h
  head/sys/ofed/drivers/infiniband/hw/mlx4/wc.c
  head/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c
  head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c
  head/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
  head/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c
  head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
  head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
  head/sys/ofed/drivers/net/mlx4/Makefile
  head/sys/ofed/drivers/net/mlx4/alloc.c
  head/sys/ofed/drivers/net/mlx4/catas.c
  head/sys/ofed/drivers/net/mlx4/cmd.c
  head/sys/ofed/drivers/net/mlx4/cq.c
  head/sys/ofed/drivers/net/mlx4/en_cq.c
  head/sys/ofed/drivers/net/mlx4/en_main.c
  head/sys/ofed/drivers/net/mlx4/en_netdev.c
  head/sys/ofed/drivers/net/mlx4/en_port.c
  head/sys/ofed/drivers/net/mlx4/en_port.h
  head/sys/ofed/drivers/net/mlx4/en_rx.c
  head/sys/ofed/drivers/net/mlx4/en_tx.c
  head/sys/ofed/drivers/net/mlx4/eq.c
  head/sys/ofed/drivers/net/mlx4/fw.c
  head/sys/ofed/drivers/net/mlx4/fw.h
  head/sys/ofed/drivers/net/mlx4/icm.c
  head/sys/ofed/drivers/net/mlx4/icm.h
  head/sys/ofed/drivers/net/mlx4/intf.c
  head/sys/ofed/drivers/net/mlx4/main.c
  head/sys/ofed/drivers/net/mlx4/mcg.c
  head/sys/ofed/drivers/net/mlx4/mlx4.h
  head/sys/ofed/drivers/net/mlx4/mlx4_en.h
  head/sys/ofed/drivers/net/mlx4/mr.c
  head/sys/ofed/drivers/net/mlx4/pd.c
  head/sys/ofed/drivers/net/mlx4/port.c
  head/sys/ofed/drivers/net/mlx4/profile.c
  head/sys/ofed/drivers/net/mlx4/qp.c
  head/sys/ofed/drivers/net/mlx4/reset.c
  head/sys/ofed/drivers/net/mlx4/sense.c
  head/sys/ofed/drivers/net/mlx4/srq.c
  head/sys/ofed/include/asm/atomic.h
  head/sys/ofed/include/asm/byteorder.h
  head/sys/ofed/include/linux/bitops.h
  head/sys/ofed/include/linux/compat.h
  head/sys/ofed/include/linux/device.h
  head/sys/ofed/include/linux/dma-mapping.h
  head/sys/ofed/include/linux/gfp.h
  head/sys/ofed/include/linux/idr.h
  head/sys/ofed/include/linux/if_ethe

svn commit: r255969 - in head/sys/ofed/drivers: infiniband/hw/mlx4 net/mlx4

2013-10-01 Thread Alfred Perlstein
Author: alfred
Date: Tue Oct  1 15:36:51 2013
New Revision: 255969
URL: http://svnweb.freebsd.org/changeset/base/255969

Log:
  Fixed kernel crash when removing IPOIB_CM option from configuration file
  
  Changed module init from module_init() to module_init_order() with
  SI_ORDER_MIDDLE flag
  Submitted by: Orit Moskovich (oritm mellanox.com)
  Approved by:  re

Modified:
  head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
  head/sys/ofed/drivers/net/mlx4/main.c

Modified: head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
==
--- head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Tue Oct  1 15:33:00 
2013(r255968)
+++ head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Tue Oct  1 15:36:51 
2013(r255969)
@@ -2431,7 +2431,7 @@ static void __exit mlx4_ib_cleanup(void)
 
 }
 
-module_init(mlx4_ib_init);
+module_init_order(mlx4_ib_init, SI_ORDER_MIDDLE);
 module_exit(mlx4_ib_cleanup);
 
 #undef MODULE_VERSION

Modified: head/sys/ofed/drivers/net/mlx4/main.c
==
--- head/sys/ofed/drivers/net/mlx4/main.c   Tue Oct  1 15:33:00 2013
(r255968)
+++ head/sys/ofed/drivers/net/mlx4/main.c   Tue Oct  1 15:36:51 2013
(r255969)
@@ -2859,7 +2859,7 @@ static void __exit mlx4_cleanup(void)
destroy_workqueue(mlx4_wq);
 }
 
-module_init(mlx4_init);
+module_init_order(mlx4_init, SI_ORDER_MIDDLE);
 module_exit(mlx4_cleanup);
 
 #undef MODULE_VERSION
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r255970 - head/sys/ofed/drivers/infiniband/hw/mlx4

2013-10-01 Thread Alfred Perlstein
Author: alfred
Date: Tue Oct  1 15:38:29 2013
New Revision: 255970
URL: http://svnweb.freebsd.org/changeset/base/255970

Log:
  Fixed 'Couldn't Create QP' issue when running rc_pingpong, uc_pingpong,
  srq_pingpong IBverbs
  
  Removed refrences using 'ifdef __linux__' to qpg functions and
  related fields in struct
  ib_qp_init_attr.
  
  Submitted by: Orit Moskovich (oritm mellanox.com)
  
  Approved by:  re

Modified:
  head/sys/ofed/drivers/infiniband/hw/mlx4/qp.c

Modified: head/sys/ofed/drivers/infiniband/hw/mlx4/qp.c
==
--- head/sys/ofed/drivers/infiniband/hw/mlx4/qp.c   Tue Oct  1 15:36:51 
2013(r255969)
+++ head/sys/ofed/drivers/infiniband/hw/mlx4/qp.c   Tue Oct  1 15:38:29 
2013(r255970)
@@ -611,6 +611,7 @@ static int qp_has_rq(struct ib_qp_init_a
return !attr->srq;
 }
 
+#ifdef __linux__
 static int init_qpg_parent(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *pqp,
   struct ib_qp_init_attr *attr, int *qpn)
 {
@@ -791,6 +792,7 @@ static void free_qpg_qpn(struct mlx4_ib_
break;
}
 }
+#endif
 
 static int alloc_qpn_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
struct ib_qp_init_attr *attr, int *qpn)
@@ -811,11 +813,15 @@ static int alloc_qpn_common(struct mlx4_
}
break;
case IB_QPG_PARENT:
+#ifdef __linux__
err = init_qpg_parent(dev, qp, attr, qpn);
+#endif
break;
case IB_QPG_CHILD_TX:
case IB_QPG_CHILD_RX:
+#ifdef __linux__
err = alloc_qpg_qpn(attr, qp, qpn);
+#endif
break;
default:
qp->qpg_type = IB_QPG_NONE;
@@ -839,11 +845,15 @@ static void free_qpn_common(struct mlx4_
mlx4_qp_release_range(dev->dev, qpn, 1);
break;
case IB_QPG_PARENT:
+#ifdef __linux__
free_qpg_parent(dev, qp);
+#endif
break;
case IB_QPG_CHILD_TX:
case IB_QPG_CHILD_RX:
+#ifdef __linux__
free_qpg_qpn(qp, qpn);
+#endif
break;
default:
break;
@@ -872,6 +882,10 @@ static int create_qp_common(struct mlx4_
struct mlx4_ib_qp *qp;
enum mlx4_ib_qp_type qp_type = (enum mlx4_ib_qp_type) 
init_attr->qp_type;
 
+#ifndef __linux__
+init_attr->qpg_type = IB_QPG_NONE;
+#endif
+
/* When tunneling special qps, we use a plain UD qp */
if (sqpn) {
if (mlx4_is_mfunc(dev->dev) &&
@@ -1287,6 +1301,7 @@ static u32 get_sqp_num(struct mlx4_ib_de
return dev->dev->caps.qp1_proxy[attr->port_num - 1];
 }
 
+#ifdef __linux__
 static int check_qpg_attr(struct mlx4_ib_dev *dev,
  struct ib_qp_init_attr *attr)
 {
@@ -1332,6 +1347,7 @@ static int check_qpg_attr(struct mlx4_ib
}
return 0;
 }
+#endif
 
 #define RESERVED_FLAGS_MASK unsigned int)IB_QP_CREATE_RESERVED_END - 1) | 
IB_QP_CREATE_RESERVED_END)   \
& 
~(IB_QP_CREATE_RESERVED_START - 1))
@@ -1390,9 +1406,11 @@ struct ib_qp *mlx4_ib_create_qp(struct i
  init_attr->qp_type > IB_QPT_GSI)))
return ERR_PTR(-EINVAL);
 
+#ifdef __linux__
err = check_qpg_attr(to_mdev(device), init_attr);
if (err)
return ERR_PTR(err);
+#endif
 
switch (init_attr->qp_type) {
case IB_QPT_XRC_TGT:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r255972 - in head/sys/ofed: drivers/infiniband/core drivers/infiniband/hw/mlx4 include/rdma

2013-10-01 Thread Alfred Perlstein
Author: alfred
Date: Tue Oct  1 15:42:38 2013
New Revision: 255972
URL: http://svnweb.freebsd.org/changeset/base/255972

Log:
  Enable ib_dev.mmap function
  
  Removed the ifdef linux from this function.
  Added stub function for contiguous pages to avoid compilation
  errors.
  
  Submitted by: Orit Moskovich (oritm mellanox.com)
  Approved by:  re

Modified:
  head/sys/ofed/drivers/infiniband/core/umem.c
  head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
  head/sys/ofed/include/rdma/ib_umem.h

Modified: head/sys/ofed/drivers/infiniband/core/umem.c
==
--- head/sys/ofed/drivers/infiniband/core/umem.cTue Oct  1 15:40:27 
2013(r255971)
+++ head/sys/ofed/drivers/infiniband/core/umem.cTue Oct  1 15:42:38 
2013(r255972)
@@ -530,3 +530,46 @@ int ib_umem_page_count(struct ib_umem *u
return n;
 }
 EXPORT_SYMBOL(ib_umem_page_count);
+
+/**/
+/* 
+ * Stub functions for contiguous pages - 
+ * We currently do not support this feature
+ */
+/**/
+
+/**
+ * ib_cmem_release_contiguous_pages - release memory allocated by
+ *  ib_cmem_alloc_contiguous_pages.
+ * @cmem: cmem struct to release
+ */
+void ib_cmem_release_contiguous_pages(struct ib_cmem *cmem)
+{
+}
+EXPORT_SYMBOL(ib_cmem_release_contiguous_pages);
+
+/**
+ *  * ib_cmem_alloc_contiguous_pages - allocate contiguous pages
+ *  *  @context: userspace context to allocate memory for
+ *   * @total_size: total required size for that allocation.
+ ** @page_size_order: order of one contiguous page.
+ * */
+struct ib_cmem *ib_cmem_alloc_contiguous_pages(struct ib_ucontext *context,
+unsigned long total_size,
+   unsigned long 
page_size_order)
+{
+   return NULL;
+}
+EXPORT_SYMBOL(ib_cmem_alloc_contiguous_pages);
+
+/**
+ *  * ib_cmem_map_contiguous_pages_to_vma - map contiguous pages into VMA
+ *   * @ib_cmem: cmem structure returned by ib_cmem_alloc_contiguous_pages
+ ** @vma: VMA to inject pages into.
+ * */
+int ib_cmem_map_contiguous_pages_to_vma(struct ib_cmem *ib_cmem,
+struct vm_area_struct *vma)
+{
+   return 0;
+}
+EXPORT_SYMBOL(ib_cmem_map_contiguous_pages_to_vma);

Modified: head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
==
--- head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Tue Oct  1 15:40:27 
2013(r255971)
+++ head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Tue Oct  1 15:42:38 
2013(r255972)
@@ -726,6 +726,7 @@ full_search:
addr = ALIGN(vma->vm_end, 1 << page_size_order);
}
 }
+#endif
 
 static int mlx4_ib_mmap(struct ib_ucontext *context, struct vm_area_struct 
*vma)
 {
@@ -780,7 +781,6 @@ static int mlx4_ib_mmap(struct ib_uconte
 
return 0;
 }
-#endif
 
 static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
  struct ib_ucontext *context,
@@ -1984,8 +1984,8 @@ static void *mlx4_ib_add(struct mlx4_dev
ibdev->ib_dev.modify_port   = mlx4_ib_modify_port;
ibdev->ib_dev.alloc_ucontext= mlx4_ib_alloc_ucontext;
ibdev->ib_dev.dealloc_ucontext  = mlx4_ib_dealloc_ucontext;
-#ifdef __linux__
ibdev->ib_dev.mmap  = mlx4_ib_mmap;
+#ifdef __linux__
ibdev->ib_dev.get_unmapped_area = mlx4_ib_get_unmapped_area;
 #endif
ibdev->ib_dev.alloc_pd  = mlx4_ib_alloc_pd;

Modified: head/sys/ofed/include/rdma/ib_umem.h
==
--- head/sys/ofed/include/rdma/ib_umem.hTue Oct  1 15:40:27 2013
(r255971)
+++ head/sys/ofed/include/rdma/ib_umem.hTue Oct  1 15:42:38 2013
(r255972)
@@ -57,6 +57,24 @@ struct ib_umem {
unsigned long   diff;
 };
 
+struct ib_cmem {
+
+struct ib_ucontext *context;
+size_t  length;
+/* Link list of contiguous blocks being part of that cmem  */
+struct list_head ib_cmem_block;
+
+/* Order of cmem block,  2^ block_order will equal number
+ of physical pages per block
+*/
+unsigned longblock_order;
+/* Refernce counter for that memory area
+  - When value became 0 pages will be returned to the kernel.
+*/
+struct kref refcount;
+};
+
+
 struct ib_umem_chunk {
struct list_headlist;
int nents;
@@ -70,4 +88,14 @@ struct ib_umem *ib_umem_get(struct ib_uc
 void ib_umem_release(struct ib_umem *umem);
 int ib_umem_page_count(struct ib_umem *umem);
 
+int ib_cmem_map_contiguous_pages_to_vma(struct ib_cmem *ib_cmem,
+struct vm_ar

svn commit: r255973 - head/sys/ofed/drivers/infiniband/core

2013-10-01 Thread Alfred Perlstein
Author: alfred
Date: Tue Oct  1 15:43:23 2013
New Revision: 255973
URL: http://svnweb.freebsd.org/changeset/base/255973

Log:
  Fixed kernel crash when running devinfo
  
  When calling to ib_uverbs_cleanup_ucontext, there is a call to
  mutex_lock of xrcd_table_mutex, which was not initialized.
  Added missing initialization for xrcd_table_mutex.
  
  Submitted by: Orit Moskovich (oritm mellanox.com)
  
  Approved by:  re

Modified:
  head/sys/ofed/drivers/infiniband/core/device.c

Modified: head/sys/ofed/drivers/infiniband/core/device.c
==
--- head/sys/ofed/drivers/infiniband/core/device.c  Tue Oct  1 15:42:38 
2013(r255972)
+++ head/sys/ofed/drivers/infiniband/core/device.c  Tue Oct  1 15:43:23 
2013(r255973)
@@ -296,6 +296,8 @@ int ib_register_device(struct ib_device 
INIT_LIST_HEAD(&device->client_data_list);
spin_lock_init(&device->event_handler_lock);
spin_lock_init(&device->client_data_lock);
+   device->ib_uverbs_xrcd_table = RB_ROOT;
+   mutex_init(&device->xrcd_table_mutex);
 
ret = read_port_table_lengths(device);
if (ret) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r255968 - head/sys/ofed/include/linux

2013-10-01 Thread Alfred Perlstein
Author: alfred
Date: Tue Oct  1 15:33:00 2013
New Revision: 255968
URL: http://svnweb.freebsd.org/changeset/base/255968

Log:
  Fix mis-merge of upstream fix.
  
  We would accidentally make the string one byte too short.
  
  Submitted by: Orit Moskovich (oritm mellanox.com)
  
  Approved by:  re

Modified:
  head/sys/ofed/include/linux/sysfs.h

Modified: head/sys/ofed/include/linux/sysfs.h
==
--- head/sys/ofed/include/linux/sysfs.h Tue Oct  1 12:01:20 2013
(r255967)
+++ head/sys/ofed/include/linux/sysfs.h Tue Oct  1 15:33:00 2013
(r255968)
@@ -105,10 +105,6 @@ sysctl_handle_attr(SYSCTL_HANDLER_ARGS)
/* Trim trailing newline. */
buf[len] = '\0';
}
-
-   /* Trim trailing newline. */
-   len--;
-   ((char*)buf)[len] = '\0';
}
 
/* Leave one trailing byte to append a newline. */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r256269 - head/sys/ofed/drivers/infiniband/hw/mlx4

2013-10-10 Thread Alfred Perlstein
Author: alfred
Date: Thu Oct 10 14:03:03 2013
New Revision: 256269
URL: http://svnweb.freebsd.org/changeset/base/256269

Log:
  Fix for When more than one NIC is present.
  
  The device name was incorrect due to a specific function we ported
  from the Linux driver that is not FBSD compatible.  This resulted
  with a false sysctl registration and some more problematic issues.
  
  The patch basically revokes it all together.
  
  Submitted by: Meny Yossefi (menyy mellanox.com)
  
  Approved by:  re

Modified:
  head/sys/ofed/drivers/infiniband/hw/mlx4/main.c

Modified: head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
==
--- head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Thu Oct 10 12:47:34 
2013(r256268)
+++ head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Thu Oct 10 14:03:03 
2013(r256269)
@@ -1859,33 +1859,6 @@ err:
"is incorrect. The parameter value is discarded!");
 }
 
-static int mlx4_ib_dev_idx(struct mlx4_dev *dev)
-{
-   int /*bus,*/ slot, fn;
-   int i;
-
-   if (!dev)
-   return -1;
-   else if (!dev->pdev)
-   return -1;
-   //else if (!dev->pdev->bus)
-   //  return -1;
-
-   //bus   = dev->pdev->bus->conf.pc_sel.pc_bus;
-   slot= PCI_SLOT(dev->pdev->devfn);
-   fn  = PCI_FUNC(dev->pdev->devfn);
-
-   for (i = 0; i < MAX_DR; ++i) {
-   if (/*dr[i].bus == bus &&*/
-   dr[i].dev == slot &&
-   dr[i].func == fn) {
-   return dr[i].nr;
-   }
-   }
-
-   return -1;
-}
-
 static void *mlx4_ib_add(struct mlx4_dev *dev)
 {
struct mlx4_ib_dev *ibdev;
@@ -1893,7 +1866,6 @@ static void *mlx4_ib_add(struct mlx4_dev
int i, j;
int err;
struct mlx4_ib_iboe *iboe;
-   int dev_idx;
 
printk(KERN_INFO "%s", mlx4_ib_version);
 
@@ -1928,12 +1900,7 @@ static void *mlx4_ib_add(struct mlx4_dev
 
ibdev->dev = dev;
 
-   dev_idx = mlx4_ib_dev_idx(dev);
-   if (dev_idx >= 0)
-   sprintf(ibdev->ib_dev.name, "mlx4_%d", dev_idx);
-   else
-   strlcpy(ibdev->ib_dev.name, "mlx4_%d", IB_DEVICE_NAME_MAX);
-
+   strlcpy(ibdev->ib_dev.name, "mlx4_%d", IB_DEVICE_NAME_MAX);
ibdev->ib_dev.owner = THIS_MODULE;
ibdev->ib_dev.node_type = RDMA_NODE_IB_CA;
ibdev->ib_dev.local_dma_lkey= dev->caps.reserved_lkey;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r256546 - head/sys/ofed/include/linux

2013-10-15 Thread Alfred Perlstein
Author: alfred
Date: Tue Oct 15 15:50:43 2013
New Revision: 256546
URL: http://svnweb.freebsd.org/changeset/base/256546

Log:
  Fix __free_pages() in the linux shim.
  
  __free_pages() is actaully supposed to take a "struct page *" not
  an address.

Modified:
  head/sys/ofed/include/linux/gfp.h

Modified: head/sys/ofed/include/linux/gfp.h
==
--- head/sys/ofed/include/linux/gfp.h   Tue Oct 15 15:43:29 2013
(r256545)
+++ head/sys/ofed/include/linux/gfp.h   Tue Oct 15 15:50:43 2013
(r256546)
@@ -92,14 +92,14 @@ __free_page(struct page *m)
 }
 
 static inline void
-__free_pages(void *p, unsigned int order)
+__free_pages(struct page *m, unsigned int order)
 {
size_t size;
 
-   if (p == 0)
+   if (m == NULL)
return;
size = PAGE_SIZE << order;
-   kmem_free(kmem_arena, (vm_offset_t)p, size);
+   kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r256682 - head/sys/ofed/drivers/net/mlx4

2013-10-17 Thread Alfred Perlstein
Author: alfred
Date: Thu Oct 17 12:19:36 2013
New Revision: 256682
URL: http://svnweb.freebsd.org/changeset/base/256682

Log:
  Fix resource free.
  
  The order of releasing resources in mlxen was wrong, which caused
  panic on reload of the module.
  
  conf_ctx list should be released before stat_ctx list, otherwise
  the leafs in conf_ctx list won't be released because of the dependancy.
  
  The fix is to change the order of the releases.
  
  Submitted by: Shahar Klein (shahark at mellanox.com)

Modified:
  head/sys/ofed/drivers/net/mlx4/en_netdev.c

Modified: head/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- head/sys/ofed/drivers/net/mlx4/en_netdev.c  Thu Oct 17 12:15:21 2013
(r256681)
+++ head/sys/ofed/drivers/net/mlx4/en_netdev.c  Thu Oct 17 12:19:36 2013
(r256682)
@@ -927,9 +927,6 @@ void mlx4_en_destroy_netdev(struct net_d
if (priv->allocated)
mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
 
-   if (priv->sysctl)
-   sysctl_ctx_free(&priv->conf_ctx);
-
mutex_lock(&mdev->state_lock);
mlx4_en_stop_port(dev);
mutex_unlock(&mdev->state_lock);
@@ -946,6 +943,9 @@ void mlx4_en_destroy_netdev(struct net_d
 
mlx4_en_free_resources(priv);
 
+   if (priv->sysctl)
+   sysctl_ctx_free(&priv->conf_ctx);
+
mtx_destroy(&priv->stats_lock.m);
mtx_destroy(&priv->vlan_lock.m);
kfree(priv);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r256686 - stable/10/sys/ofed/include/linux

2013-10-17 Thread Alfred Perlstein
Author: alfred
Date: Thu Oct 17 14:08:46 2013
New Revision: 256686
URL: http://svnweb.freebsd.org/changeset/base/256686

Log:
  Fix __free_pages() in the linux shim.
  
  __free_pages() is actaully supposed to take a "struct page *" not
  an address.
  
  MFC: 256546
  
  Approved by:  re

Modified:
  stable/10/sys/ofed/include/linux/gfp.h
Directory Properties:
  stable/10/sys/   (props changed)

Modified: stable/10/sys/ofed/include/linux/gfp.h
==
--- stable/10/sys/ofed/include/linux/gfp.h  Thu Oct 17 13:28:57 2013
(r256685)
+++ stable/10/sys/ofed/include/linux/gfp.h  Thu Oct 17 14:08:46 2013
(r256686)
@@ -92,14 +92,14 @@ __free_page(struct page *m)
 }
 
 static inline void
-__free_pages(void *p, unsigned int order)
+__free_pages(struct page *m, unsigned int order)
 {
size_t size;
 
-   if (p == 0)
+   if (m == NULL)
return;
size = PAGE_SIZE << order;
-   kmem_free(kmem_arena, (vm_offset_t)p, size);
+   kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r256810 - stable/10/sys/ofed/drivers/net/mlx4

2013-10-20 Thread Alfred Perlstein
Author: alfred
Date: Sun Oct 20 21:21:50 2013
New Revision: 256810
URL: http://svnweb.freebsd.org/changeset/base/256810

Log:
  Fix resource free.
  
  The order of releasing resources in mlxen was wrong, which caused
  panic on reload of the module.
  
  MFC: 256682
  
  Submitted by: Shahar Klein (shahark at mellanox.com)
  Approved by:   re

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
Directory Properties:
  stable/10/sys/   (props changed)

Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Sun Oct 20 21:21:07 
2013(r256809)
+++ stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Sun Oct 20 21:21:50 
2013(r256810)
@@ -927,9 +927,6 @@ void mlx4_en_destroy_netdev(struct net_d
if (priv->allocated)
mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
 
-   if (priv->sysctl)
-   sysctl_ctx_free(&priv->conf_ctx);
-
mutex_lock(&mdev->state_lock);
mlx4_en_stop_port(dev);
mutex_unlock(&mdev->state_lock);
@@ -946,6 +943,9 @@ void mlx4_en_destroy_netdev(struct net_d
 
mlx4_en_free_resources(priv);
 
+   if (priv->sysctl)
+   sysctl_ctx_free(&priv->conf_ctx);
+
mtx_destroy(&priv->stats_lock.m);
mtx_destroy(&priv->vlan_lock.m);
kfree(priv);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r257542 - head/sys/ofed/drivers/net/mlx4

2013-11-02 Thread Alfred Perlstein
Author: alfred
Date: Sat Nov  2 10:49:47 2013
New Revision: 257542
URL: http://svnweb.freebsd.org/changeset/base/257542

Log:
  Fix API mismatch exposed by lagg.
  
  When destroying a lagg the driver tries to restore the old mac and
  fails due to API mismatch

Modified:
  head/sys/ofed/drivers/net/mlx4/en_netdev.c

Modified: head/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- head/sys/ofed/drivers/net/mlx4/en_netdev.c  Sat Nov  2 09:16:11 2013
(r257541)
+++ head/sys/ofed/drivers/net/mlx4/en_netdev.c  Sat Nov  2 10:49:47 2013
(r257542)
@@ -633,8 +633,8 @@ int mlx4_en_start_port(struct net_device
en_dbg(DRV, priv, "Setting mac for port %d\n", priv->port);
err = mlx4_register_mac(mdev->dev, priv->port,
mlx4_en_mac_to_u64(IF_LLADDR(dev)));
-   if (err) {
-   en_err(priv, "Failed setting port mac\n");
+   if (err < 0) {
+   en_err(priv, "Failed setting port mac err=%d\n", err);
goto tx_err;
}
mdev->mac_removed[priv->port] = 0;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r257543 - head/sys/dev/usb/wlan

2013-11-02 Thread Alfred Perlstein
Author: alfred
Date: Sat Nov  2 11:37:16 2013
New Revision: 257543
URL: http://svnweb.freebsd.org/changeset/base/257543

Log:
  Add device ID for 'Sanoxy 802.11N' usb

Modified:
  head/sys/dev/usb/wlan/if_urtwn.c

Modified: head/sys/dev/usb/wlan/if_urtwn.c
==
--- head/sys/dev/usb/wlan/if_urtwn.cSat Nov  2 10:49:47 2013
(r257542)
+++ head/sys/dev/usb/wlan/if_urtwn.cSat Nov  2 11:37:16 2013
(r257543)
@@ -139,6 +139,7 @@ static const STRUCT_USB_HOST_ID urtwn_de
URTWN_DEV(REALTEK,  RTL8191CU),
URTWN_DEV(REALTEK,  RTL8192CE),
URTWN_DEV(REALTEK,  RTL8192CU),
+   URTWN_DEV(REALTEK,  RTL8188CU_0),
URTWN_DEV(SITECOMEU,RTL8188CU_1),
URTWN_DEV(SITECOMEU,RTL8188CU_2),
URTWN_DEV(SITECOMEU,RTL8192CU),
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r243594 - head/sys/netinet

2012-11-26 Thread Alfred Perlstein
Author: alfred
Date: Tue Nov 27 03:04:24 2012
New Revision: 243594
URL: http://svnweb.freebsd.org/changeset/base/243594

Log:
  Auto size the tcbhashsize structure based on max sockets.
  
  While here, also make the code that enforces power-of-two more
  forgiving, instead of just resetting to 512, graciously round-down
  to the next lower power of two.

Modified:
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Tue Nov 27 02:28:42 2012(r243593)
+++ head/sys/netinet/tcp_subr.c Tue Nov 27 03:04:24 2012(r243594)
@@ -235,7 +235,7 @@ static char *   tcp_log_addr(struct in_con
  * variable net.inet.tcp.tcbhashsize
  */
 #ifndef TCBHASHSIZE
-#define TCBHASHSIZE512
+#define TCBHASHSIZE0
 #endif
 
 /*
@@ -282,11 +282,35 @@ tcp_inpcb_init(void *mem, int size, int 
return (0);
 }
 
+/*
+ * Take a value and get the next power of 2 that doesn't overflow.
+ * Used to size the tcp_inpcb hash buckets.
+ */
+static int
+maketcp_hashsize(int size)
+{
+   int hashsize;
+
+   /*
+* auto tune.
+* get the next power of 2 higher than maxsockets.
+*/
+   hashsize = 1 << fls(size);
+   /* catch overflow, and just go one power of 2 smaller */
+   if (hashsize < size) {
+   hashsize = 1 << (fls(size) - 1);
+   }
+   return (hashsize);
+}
+
 void
 tcp_init(void)
 {
+   const char *tcbhash_tuneable;
int hashsize;
 
+   tcbhash_tuneable = "net.inet.tcp.tcbhashsize";
+
if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN,
&V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0)
printf("%s: WARNING: unable to register helper hook\n", 
__func__);
@@ -295,10 +319,43 @@ tcp_init(void)
printf("%s: WARNING: unable to register helper hook\n", 
__func__);
 
hashsize = TCBHASHSIZE;
-   TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", &hashsize);
+   TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize);
+   if (hashsize == 0) {
+   /*
+* Auto tune the hash size based on maxsockets.
+* A perfect hash would have a 1:1 mapping
+* (hashsize = maxsockets) however it's been
+* suggested that O(2) average is better.
+*/
+   hashsize = maketcp_hashsize(maxsockets / 4);
+   /*
+* Our historical default is 512,
+* do not autotune lower than this.
+*/
+   if (hashsize < 512)
+   hashsize = 512;
+   if (bootverbose)
+   printf("%s: %s auto tuned to %d\n", __func__,
+   tcbhash_tuneable, hashsize);
+   }
+   /*
+* We require a hashsize to be a power of two.
+* Previously if it was not a power of two we would just reset it
+* back to 512, which could be a nasty surprise if you did not notice
+* the error message.
+* Instead what we do is clip it to the closest power of two lower
+* than the specified hash value.
+*/
if (!powerof2(hashsize)) {
-   printf("WARNING: TCB hash size not a power of 2\n");
-   hashsize = 512; /* safe default */
+   int oldhashsize = hashsize;
+
+   hashsize = maketcp_hashsize(hashsize);
+   /* prevent absurdly low value */
+   if (hashsize < 16)
+   hashsize = 16;
+   printf("%s: WARNING: TCB hash size not a power of 2, "
+   "clipped from %d to %d.\n", __func__, oldhashsize,
+   hashsize);
}
in_pcbinfo_init(&V_tcbinfo, "tcp", &V_tcb, hashsize, hashsize,
"tcp_inpcb", tcp_inpcb_init, NULL, UMA_ZONE_NOFREE,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r243637 - head/usr.sbin/nfsd

2012-11-27 Thread Alfred Perlstein
Author: alfred
Date: Tue Nov 27 22:34:46 2012
New Revision: 243637
URL: http://svnweb.freebsd.org/changeset/base/243637

Log:
  Autoconfigure nfsd threads based on ncpu.
  
  Rick Macklem and I discussed the default number of nfsd threads and
  concluded that it is too low to perform adiquitely on today's hardware.
  
  We decided to auto tune the number of nfsds based on the number of cpus
  in the system.
  
  While I'm here I've also added:
  
  1) ability to set the minthreads/maxthreads from userland.
  2) ability to run nfsd in debug mode via the cli.
  
  Reviewed by: rmacklem
  MFC after: 2 weeks

Modified:
  head/usr.sbin/nfsd/nfsd.c

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Tue Nov 27 22:14:22 2012(r243636)
+++ head/usr.sbin/nfsd/nfsd.c   Tue Nov 27 22:34:46 2012(r243637)
@@ -53,6 +53,7 @@ static const char rcsid[] =
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -71,14 +72,11 @@ static const char rcsid[] =
 #include 
 #include 
 #include 
+#include 
+
+#include 
 
-/* Global defs */
-#ifdef DEBUG
-#definesyslog(e, s...) fprintf(stderr,s)
-static int debug = 1;
-#else
 static int debug = 0;
-#endif
 
 #defineNFSD_STABLERESTART  "/var/db/nfs-stablerestart"
 #defineNFSD_STABLEBACKUP   "/var/db/nfs-stablerestart.bak"
@@ -86,11 +84,26 @@ static int  debug = 0;
 #defineDEFNFSDCNT   4
 static pid_t children[MAXNFSDCNT]; /* PIDs of children */
 static int nfsdcnt;/* number of children */
+static int nfsdcnt_set;
+static int minthreads;
+static int maxthreads;
 static int new_syscall;
 static int run_v4server = 1;   /* Force running of nfsv4 server */
 static int nfssvc_nfsd;/* Set to correct NFSSVC_xxx flag */
 static int stablefd = -1;  /* Fd for the stable restart file */
 static int backupfd;   /* Fd for the backup stable restart file */
+static const char *getopt_shortopts;
+static const char *getopt_usage;
+
+static int minthreads_set;
+static int maxthreads_set;
+
+static struct option longopts[] = {
+   { "debug", no_argument, &debug, 1 },
+   { "minthreads", required_argument, &minthreads_set, 1 },
+   { "maxthreads", required_argument, &maxthreads_set, 1 },
+   { NULL, 0, NULL, 0}
+};
 
 void   cleanup(int);
 void   child_cleanup(int);
@@ -145,26 +158,28 @@ main(int argc, char **argv)
int udpflag, ecode, error, s, srvcnt;
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
int nfssvc_addsock;
+   int longindex = 0;
+   const char *lopt;
char **bindhost = NULL;
pid_t pid;
 
nfsdcnt = DEFNFSDCNT;
unregister = reregister = tcpflag = maxsock = 0;
bindanyflag = udpflag = connect_type_cnt = bindhostc = 0;
-#defineGETOPT  "ah:n:rdtueo"
-#defineUSAGE   "[-ardtueo] [-n num_servers] [-h bindip]"
-   while ((ch = getopt(argc, argv, GETOPT)) != -1)
+   getopt_shortopts = "ah:n:rdtueo";
+   getopt_usage =
+   "usage:\n"
+   "  nfsd [-ardtueo] [-h bindip]\n"
+   "   [-n numservers] [--minthreads #] [--maxthreads #]\n";
+   while ((ch = getopt_long(argc, argv, getopt_shortopts, longopts,
+   &longindex)) != -1)
switch (ch) {
case 'a':
bindanyflag = 1;
break;
case 'n':
+   nfsdcnt_set = 1;
nfsdcnt = atoi(optarg);
-   if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
-   warnx("nfsd count %d; reset to %d", nfsdcnt,
-   DEFNFSDCNT);
-   nfsdcnt = DEFNFSDCNT;
-   }
break;
case 'h':
bindhostc++;
@@ -193,6 +208,14 @@ main(int argc, char **argv)
case 'o':
run_v4server = 0;
break;
+   case 0:
+   lopt = longopts[longindex].name;
+   if (!strcmp(lopt, "minthreads")) {
+   minthreads = atoi(optarg);
+   } else if (!strcmp(lopt, "maxthreads")) {
+   maxthreads = atoi(optarg);
+   }
+   break;
default:
case '?':
usage();
@@ -209,6 +232,7 @@ main(int argc, char **argv)
if (argc > 1)
usage();
if (argc == 1) {
+   nfsdcnt_set = 1;
nfsdcnt = atoi(argv[0]);
if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
warnx("nfsd count %d; reset to %d", nfsdcnt,
@@ -356,7 +380,7 @@ main(int argc, char **argv)
(void)signal(SIGCHLD, reapchild);
   

svn commit: r243644 - head/usr.sbin/nfsd

2012-11-27 Thread Alfred Perlstein
Author: alfred
Date: Wed Nov 28 02:23:59 2012
New Revision: 243644
URL: http://svnweb.freebsd.org/changeset/base/243644

Log:
  Fix typo.
  
  Pointed out by: marck

Modified:
  head/usr.sbin/nfsd/nfsd.c

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:03:53 2012(r243643)
+++ head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:23:59 2012(r243644)
@@ -431,7 +431,7 @@ main(int argc, char **argv)
nfsdcnt = DEFNFSDCNT;
}
if (nfsdcnt > MAXNFSDCNT) {
-   warnx("nfsd counta too high %d; reset to %d", nfsdcnt,
+   warnx("nfsd count too high %d; reset to %d", nfsdcnt,
DEFNFSDCNT);
nfsdcnt = MAXNFSDCNT;
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r243645 - head/usr.sbin/nfsd

2012-11-27 Thread Alfred Perlstein
Author: alfred
Date: Wed Nov 28 02:47:31 2012
New Revision: 243645
URL: http://svnweb.freebsd.org/changeset/base/243645

Log:
  Don't allow minthreads > maxthreads.
  
  Suggested by: rmacklem

Modified:
  head/usr.sbin/nfsd/nfsd.c

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:23:59 2012(r243644)
+++ head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:47:31 2012(r243645)
@@ -224,6 +224,10 @@ main(int argc, char **argv)
udpflag = 1;
argv += optind;
argc -= optind;
+   if (minthreads_set && maxthreads_set && minthreads > maxthreads)
+   errx(EX_USAGE,
+   "error: minthreads(%d) can't be greater than "
+   "maxthreads(%d)", minthreads, maxthreads);
 
/*
 * XXX
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r243594 - head/sys/netinet

2012-11-27 Thread Alfred Perlstein

On 11/27/12 2:12 PM, Andre Oppermann wrote:

On 27.11.2012 04:04, Alfred Perlstein wrote:

Author: alfred
Date: Tue Nov 27 03:04:24 2012
New Revision: 243594
URL: http://svnweb.freebsd.org/changeset/base/243594

Log:
   Auto size the tcbhashsize structure based on max sockets.

   While here, also make the code that enforces power-of-two more
   forgiving, instead of just resetting to 512, graciously round-down
   to the next lower power of two.


The porthash (also a parameter to in_pcbinfo_init()) should not be
scaled the same as tcbhashsize.  It's unlikely that anyone is going
to have more than a thousand listen ports.

The default tcbhashsize scaling factor of maxsockets / 4 is IMHO
excessive.  If someone is running at the limit he's going to up
maxsockets to double the target load.  Dividing by 8 is a better
balance for normal and well used large memory machines.
The hashsize calculation logic is done a bit in a roundabout way.

What do think of the attached patch to fix the porthash and to simplify
the hashsize logic?


I like the porthash fix.

However your change:
1) removes explanation of what the code is doing. (comments/clarity)
2) removes the more forgiving code that rounds-down the tcp_tcbhashsize.

Can you please maintain the comments (probably keeping the logic of 
maketcp_hashsize() in a separate function).


Can you please maintain the more forgiving code for dealing with 
non-power of 2 tunable?  I like this, it makes it easier for admins and 
less error prone.


-   if (!powerof2(hashsize)) {
-   int oldhashsize = hashsize;

-   hashsize = maketcp_hashsize(hashsize);
-   /* prevent absurdly low value */
-   if (hashsize < 16)
-   hashsize = 16;
-   printf("%s: WARNING: TCB hash size not a power of 2, "
-   "clipped from %d to %d.\n", __func__, oldhashsize,
-   hashsize);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2012-11-28 Thread Alfred Perlstein

On 11/28/12 12:01 AM, Andre Oppermann wrote:

On 28.11.2012 00:59, Robert N. M. Watson wrote:


On 27 Nov 2012, at 23:29, Andre Oppermann wrote:

Andre.. this breaks incoming connections.  TCP is immediately 
reset and never even gets to the
listener process.  You need to back out of fix this urgently 
please.


I just found out and fixed it.  Sorry for the breakage.


I'd like to see a much more thorough use of "Reviewed by:" in 
socket and TCP-related commits -- this
is very sensitive code, and a second pair of eyes is always 
valuable.  Post-commit review is not a
substitute.  Looking back over similar changes in the socket code 
over the last two years, I see
that almost all have reviewers, so I think it would be reasonable 
to consider it mandatory for these
subsystems at this point.  The good news is that we have lots of 
people with expertise in it.


Good to see you becoming more active again. :-)  And yes,
you have a point there.


Yes -- this is only about three weeks old, however; for the prior 
six-twelve months, I've been fairly non-existent in FreeBSD-land 
due to outside obligations :-).


Just saw that I did indeed send you a review request three weeks 
ago. ;-)

At the end of a rather long email though.


Yes, indeed -- no patch was attached, and it followed quite a long 
e-mail on your plans to rewrite the TCP stack. I'm afraid that went 
onto the "read this later as time permits" pile as I was at a 
conference, rather than the fast-path "oh, quickly review this patch" 
pile. However, simply committing the patch rather than trying a bit 
harder to find a reviewer isn't the right answer either. To maximise 
the likelihood of a review, construct an e-mail with a subject line 
like "Review request: (patch description)", attach the patch, and 
include a proposed commit message.


Yes, and I didn't really expect you to answer (at least quickly) during
your FreeBSD hiatus.  So it was seeking review by chance.

Alas I found and fixed the bug myself within 2.5hrs.  While not optimal,
a sign of poor prior testing and too much trust into the submitter of
the patch it wasn't an earth shattering event.  Doesn't distract from
the fact that it was mea culpa in any case though.

For prior review of kern_socket* and netinet/tcp_* related changes it has
been on and off by various committers over the past year.  If we do have
a policy of prior review required then it should be made official and
codified in MAINTAINERS and universally applied to all.

Personally I don't think we need any more anchors attached to people's 
feet when developing FreeBSD.


Mistakes will happen, they will happen in head.  Slowing down the 
process to eliminate mistakes only works to slow down change and give a 
false sense of "fixing stability" when in fact the only thing "stable" 
is the slowness of submitting code.


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


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

2012-11-28 Thread Alfred Perlstein
Do you think we need another TRB?

It could be used to oust undesirable committers if needed. 

Sent from my iPhone

On Nov 28, 2012, at 10:25 AM, "Robert N. M. Watson"  wrote:

> 
> On 28 Nov 2012, at 17:51, Gleb Smirnoff wrote:
> 
>> On Wed, Nov 28, 2012 at 09:39:15AM -0800, Alfred Perlstein wrote:
>> A> Personally I don't think we need any more anchors attached to people's 
>> A> feet when developing FreeBSD.
>> A> 
>> A> Mistakes will happen, they will happen in head.  Slowing down the 
>> A> process to eliminate mistakes only works to slow down change and give a 
>> A> false sense of "fixing stability" when in fact the only thing "stable" 
>> A> is the slowness of submitting code.
>> 
>> This will eventually lead back to the situation when no one runs head,
>> because it is unusable.
> 
> Also, based on past experience: I'm much happier reviewing shaky code before 
> it goes into the tree than trying to debug it in situ and having to back it 
> out. If our advice to many companies is that they should start developing 
> products against head, we can't let the quality of the head get back to the 
> way it was in the 5.x timeframe. Several factors have led to our having a 
> nearly-production quality development head over the last few years -- one is 
> much heavier use of branched development for features (first Perforce, and 
> more recently, Subversion, git, etc branches); the other is much heavier use 
> of code review, especially for critical parts of the system. Device driver 
> authors have a lot more leeway, but for core parts of the design, seeking 
> review during development of a feature, and then before merging it upstream, 
> should be an expectation for all but the most trivial of changes. It's a 
> two-way street, of course: if you review other people's code, they will 
> review your
 s, so as more people use review, the pool of potential reviewers goes up as 
well.
> 
> Robert
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: Reviewing before commit and stability minibikeshed (Re: svn commit: r243627 - head/sys/kern)

2012-11-28 Thread Alfred Perlstein

On 11/28/12 7:49 PM, Garrett Cooper wrote:

On Nov 28, 2012, at 9:39 AM, Alfred Perlstein  wrote:


On 11/28/12 12:01 AM, Andre Oppermann wrote:

On 28.11.2012 00:59, Robert N. M. Watson wrote:

On 27 Nov 2012, at 23:29, Andre Oppermann wrote:


Andre.. this breaks incoming connections.  TCP is immediately reset and never 
even gets to the
listener process.  You need to back out of fix this urgently please.

I just found out and fixed it.  Sorry for the breakage.

I'd like to see a much more thorough use of "Reviewed by:" in socket and 
TCP-related commits -- this
is very sensitive code, and a second pair of eyes is always valuable.  
Post-commit review is not a
substitute.  Looking back over similar changes in the socket code over the last 
two years, I see
that almost all have reviewers, so I think it would be reasonable to consider 
it mandatory for these
subsystems at this point.  The good news is that we have lots of people with 
expertise in it.

Good to see you becoming more active again. :-)  And yes,
you have a point there.

Yes -- this is only about three weeks old, however; for the prior six-twelve 
months, I've been fairly non-existent in FreeBSD-land due to outside 
obligations :-).

Just saw that I did indeed send you a review request three weeks ago. ;-)
At the end of a rather long email though.

Yes, indeed -- no patch was attached, and it followed quite a long e-mail on your plans to rewrite the TCP 
stack. I'm afraid that went onto the "read this later as time permits" pile as I was at a 
conference, rather than the fast-path "oh, quickly review this patch" pile. However, simply 
committing the patch rather than trying a bit harder to find a reviewer isn't the right answer either. To 
maximise the likelihood of a review, construct an e-mail with a subject line like "Review request: 
(patch description)", attach the patch, and include a proposed commit message.

Yes, and I didn't really expect you to answer (at least quickly) during
your FreeBSD hiatus.  So it was seeking review by chance.

Alas I found and fixed the bug myself within 2.5hrs.  While not optimal,
a sign of poor prior testing and too much trust into the submitter of
the patch it wasn't an earth shattering event.  Doesn't distract from
the fact that it was mea culpa in any case though.

For prior review of kern_socket* and netinet/tcp_* related changes it has
been on and off by various committers over the past year.  If we do have
a policy of prior review required then it should be made official and
codified in MAINTAINERS and universally applied to all.

Personally I don't think we need any more anchors attached to people's feet 
when developing FreeBSD.

Mistakes will happen, they will happen in head.  Slowing down the process to eliminate mistakes 
only works to slow down change and give a false sense of "fixing stability" when in fact 
the only thing "stable" is the slowness of submitting code.

Organizing cabals of people to review code is the best way to go. It's an 
extension of the maintainers concept applied in a better fashion because it 
encourages several developers to provide input on a series of commits instead 
of one.

I know it's sort of done in some groups [based on commit messages], but it 
would be nice to have it better formalized and socialized as well. Things like 
this are helpful for other potential freebsd contributors/developers (like some 
folks I work with for instance!).

An extension of this code review idea would probably be reviewboard. Email 
based review is doable and a lot of OSS groups use it, but there are some nice 
points to using a more advanced tool, in particular:
1. Colorized diffs.
2. Various diff niceties (hide white space changes, etc).
3. It does a reasonable job at establishing code context (code block A has 
moved to B).

There are 2 FreeBSD corporate consumers that use it, with at least one other 
group considering it, and there are probably more groups that using it as well. 
Plus it integrates well with p4, and does pretty well with git and svn.


I've seen what happens with large groups, it doesn't scale and basically 
you wind up with the following type of reviewers:


1) whitespace nazis
2) rubber stampers
3) forever absentee reviewers
4) name nazis

The whitespace nazis will never give review approval until you've gone 
through 600 iterations of the code.  Imagine Bruce... but if he wasn't 
pragmatic and awesome and didn't have other amazing skills.


The rubber stampers are friends or people that feel bad about what's 
happening to you by the whitespace nazis and name nazis so they just 
glance and approve based on the fact that you're a good guy who has 
committed to the same place before and usually doesn't break stuff.


The forever absentee reviewers are the ones that sign up to review, but 
never are around

svn commit: r243785 - head/usr.sbin/nfsd

2012-12-01 Thread Alfred Perlstein
Author: alfred
Date: Sun Dec  2 05:57:53 2012
New Revision: 243785
URL: http://svnweb.freebsd.org/changeset/base/243785

Log:
  Document maxthreads and minthreads arguments

Modified:
  head/usr.sbin/nfsd/nfsd.8

Modified: head/usr.sbin/nfsd/nfsd.8
==
--- head/usr.sbin/nfsd/nfsd.8   Sun Dec  2 01:25:19 2012(r243784)
+++ head/usr.sbin/nfsd/nfsd.8   Sun Dec  2 05:57:53 2012(r243785)
@@ -41,6 +41,8 @@ server
 .Op Fl arduteo
 .Op Fl n Ar num_servers
 .Op Fl h Ar bindip
+.Op Fl maxthreads Ar max_threads
+.Op Fl minthreads Ar min_threads
 .Sh DESCRIPTION
 The
 .Nm
@@ -74,8 +76,17 @@ Unregister the
 service with
 .Xr rpcbind 8
 without creating any servers.
-.It Fl n
-Specifies how many servers to create.
+.It Fl n Ar threads
+Specifies how many servers to create.  This option is equivalent to specifying
+.Fl maxthreads
+and
+.Fl minthreads
+with their respective arguments to
+.Ar threads .
+.It Fl maxthreads Ar threads
+Specifies the maximum servers that will be kept around to service requests.
+.It Fl minthreads Ar threads
+Specifies the minimum servers that will be kept around to service requests.
 .It Fl h Ar bindip
 Specifies which IP address or hostname to bind to on the local host.
 This option is recommended when a host has multiple interfaces.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   >