• Greg Kroah-Hartman's avatar
    USB: cdc-acm: remove unneeded spin_lock_irqsave/restore on write path · 71c2fb03
    Greg Kroah-Hartman authored
    When writing data we were:
    	lock
    	do some work
    	unlock
    	call function
    		lock
    		do some work
    		unlock
    		return
    	return
    
    It turns out, that "function" was only ever called in the one place, so
    instead of locking/unlocking for no good reason, just inline the
    function and only grab the lock once.
    
    This has sped up the pathological case of sending 1 byte packets to a
    loop-back cdc-acm device from 49600 bytes per second to 50100 bytes a
    second on my workstation.  A tiny increase yes, but noticable, and now
    the spinlock isn't the hottest thing on the perf graph anymore.  Yes, we
    are still waiting for the hardware for the most part, but getting rid of
    a spinlock_irq_save() call for every packet is still a good thing.
    
    And we end up deleting lines of code, always a win overall.
    
    This was found by using a Teensy 3.0 device and the test program and
    firmware located at:
    	http://www.pjrc.com/teensy/benchmark_usb_serial_receive.htmlReported-by: default avatarPaul Stoffregen <paul@pjrc.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    71c2fb03
cdc-acm.c 47.9 KB