This update contains one bug fix: some lines can come out truncated, because of the safety cutoff. This happened because I forgot to update the size when status packets began to be printed.
The rest is: - Comments updates - Allow snooping with pkmap on x86_64, which is cache-coherent - Enlarge event buffers (certainly we can have a couple of pages) - Add event counter First touch upon usbmon for 2.6.18. Signed-off-by: Pete Zaitcev <[EMAIL PROTECTED]> --- I am far from done with performance issues, especially on loaded systems where cat may be not scheduled for a few jiffies and thus event buffers rapidly expand. If anyone sees any droppage, let me know how it happened, please. diff -urp -X dontdiff linux-2.6.17-rc5/drivers/usb/mon/mon_dma.c linux-2.6.17-rc5-lem/drivers/usb/mon/mon_dma.c --- linux-2.6.17-rc5/drivers/usb/mon/mon_dma.c 2005-10-28 19:12:02.000000000 -0700 +++ linux-2.6.17-rc5-lem/drivers/usb/mon/mon_dma.c 2006-06-09 19:15:43.000000000 -0700 @@ -13,7 +13,10 @@ #include <linux/usb.h> /* Only needed for declarations in usb_mon.h */ #include "usb_mon.h" -#ifdef __i386__ /* CONFIG_ARCH_I386 does not exit */ +/* + * PC-compatibles, are, fortunately, sufficiently cache-coherent for this. + */ +#if defined(__i386__) || defined(__x86_64__) /* CONFIG_ARCH_I386 doesn't exit */ #define MON_HAS_UNMAP 1 #define phys_to_page(phys) pfn_to_page((phys) >> PAGE_SHIFT) diff -urp -X dontdiff linux-2.6.17-rc5/drivers/usb/mon/mon_main.c linux-2.6.17-rc5-lem/drivers/usb/mon/mon_main.c --- linux-2.6.17-rc5/drivers/usb/mon/mon_main.c 2006-05-25 14:03:51.000000000 -0700 +++ linux-2.6.17-rc5-lem/drivers/usb/mon/mon_main.c 2006-06-09 19:09:07.000000000 -0700 @@ -97,6 +97,7 @@ static void mon_submit(struct usb_bus *u if (mbus->nreaders == 0) goto out_locked; + mbus->cnt_events++; list_for_each (pos, &mbus->r_list) { r = list_entry(pos, struct mon_reader, r_link); r->rnf_submit(r->r_data, urb); @@ -152,6 +153,7 @@ static void mon_complete(struct usb_bus } spin_lock_irqsave(&mbus->lock, flags); + mbus->cnt_events++; list_for_each (pos, &mbus->r_list) { r = list_entry(pos, struct mon_reader, r_link); r->rnf_complete(r->r_data, urb); @@ -163,7 +165,6 @@ static void mon_complete(struct usb_bus /* * Stop monitoring. - * Obviously this must be well locked, so no need to play with mb's. */ static void mon_stop(struct mon_bus *mbus) { diff -urp -X dontdiff linux-2.6.17-rc5/drivers/usb/mon/mon_stat.c linux-2.6.17-rc5-lem/drivers/usb/mon/mon_stat.c --- linux-2.6.17-rc5/drivers/usb/mon/mon_stat.c 2005-06-17 12:48:29.000000000 -0700 +++ linux-2.6.17-rc5-lem/drivers/usb/mon/mon_stat.c 2006-06-09 19:10:58.000000000 -0700 @@ -31,8 +31,8 @@ static int mon_stat_open(struct inode *i mbus = inode->u.generic_ip; sp->slen = snprintf(sp->str, STAT_BUF_SIZE, - "nreaders %d text_lost %u\n", - mbus->nreaders, mbus->cnt_text_lost); + "nreaders %d events %u text_lost %u\n", + mbus->nreaders, mbus->cnt_events, mbus->cnt_text_lost); file->private_data = sp; return 0; diff -urp -X dontdiff linux-2.6.17-rc5/drivers/usb/mon/mon_text.c linux-2.6.17-rc5-lem/drivers/usb/mon/mon_text.c --- linux-2.6.17-rc5/drivers/usb/mon/mon_text.c 2006-05-25 14:03:51.000000000 -0700 +++ linux-2.6.17-rc5-lem/drivers/usb/mon/mon_text.c 2006-06-09 18:51:07.000000000 -0700 @@ -26,10 +26,13 @@ /* * This limit exists to prevent OOMs when the user process stops reading. + * If usbmon were available to unprivileged processes, it might be open + * to a local DoS. But we have to keep to root in order to prevent + * password sniffing from HID devices. */ -#define EVENT_MAX 25 +#define EVENT_MAX (2*PAGE_SIZE / sizeof(struct mon_event_text)) -#define PRINTF_DFL 130 +#define PRINTF_DFL 160 struct mon_event_text { struct list_head e_link; @@ -111,7 +114,7 @@ static inline char mon_text_get_data(str * number of corner cases, but it seems that the following is * more or less safe. * - * We do not even try to look transfer_buffer, because it can + * We do not even try to look at transfer_buffer, because it can * contain non-NULL garbage in case the upper level promised to * set DMA for the HCD. */ diff -urp -X dontdiff linux-2.6.17-rc5/drivers/usb/mon/usb_mon.h linux-2.6.17-rc5-lem/drivers/usb/mon/usb_mon.h --- linux-2.6.17-rc5/drivers/usb/mon/usb_mon.h 2006-05-25 14:03:51.000000000 -0700 +++ linux-2.6.17-rc5-lem/drivers/usb/mon/usb_mon.h 2006-06-09 18:56:34.000000000 -0700 @@ -27,6 +27,7 @@ struct mon_bus { struct kref ref; /* Under mon_lock */ /* Stats */ + unsigned int cnt_events; unsigned int cnt_text_lost; }; _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel