acx: Transform semaphore to mutex
Subsystems (2)
PATCH 1/1 acx: Transform semaphore to mutex
Hi,
The attached patch transform the semaphore to a mutex. That's how we use it,
it's faster and makes the binary smaller. It also deletes the semaphore debug functions because I the kernel takes care of that now. Just yell if I've misunderstood.
text data bss dec hex filename 113475 1520 20 115015 1c147 acx.ko-sem 111033 1520 20 112573 1b7bd acx.ko
This only works for newer kernels, so I suppose it could be kept as an into-mainline patch. People with newer kernels probably want this patch.
cmn
Signature · 3 lines
Carlos Martín http://www.cmartin.tk "Erdbeben? Sicherlich etwas, das mit Erdberen zu tun hat." -- me, paraphrased
acx_func.h +5 -14
@@ -307,27 +307,18 @@ acx_unlock_helper(acx_device_t *adev, unacx_unlock_debug (adev, where); spin_unlock_irqrestore(&adev->lock, *fp); } -static inline void -acx_down_helper (acx_device_t *adev,const char * where) -{ -acx_down_debug (adev, where); -} -static inline void -acx_up_helper (acx_device_t *adev,const char * where) -{ -acx_up_debug (adev, where); -} +#define acx_lock (adev, flags) acx_lock_helper(adev, &(flags), __FILE__ ":" STRING(__LINE__))#define acx_unlock (adev, flags) acx_unlock_helper(adev, &(flags), __FILE__ ":" STRING(__LINE__)) -#define acx_sem_lock (adev) acx_down_helper(adev, __FILE__ ":" STRING(__LINE__)) -#define acx_sem_unlock (adev) acx_up_helper(adev, __FILE__ ":" STRING(__LINE__)) +#define acx_sem_lock (adev) mutex_lock(&(adev)->mutex) +#define acx_sem_unlock (adev) mutex_unlock(&(adev)->mutex)#elif defined(DO_LOCKING)#define acx_lock (adev, flags) spin_lock_irqsave(&adev->lock, flags)#define acx_unlock (adev, flags) spin_unlock_irqrestore(&adev->lock, flags) -#define acx_sem_lock (adev) down(&adev->sem) -#define acx_sem_unlock (adev) up(&adev->sem) +#define acx_sem_lock (adev) mutex_lock(&(adev)->mutex) +#define acx_sem_unlock (adev) mutex_unlock(&(adev)->mutex)#define acx_lock_unhold () ((void)0)#define acx_sem_unhold () ((void)0)
acx_struct.h +1 -1
@@ -1142,7 +1142,7 @@ struct acx_device {/* FIXME: try to convert semaphore to more efficient mutex according to Ingo Molnar's docs (but not before driver is in mainline or pre-mutex Linux 2.6.10 is very outdated). */ -struct semaphore sem; +struct mutex mutex;spinlock_t lock;#if defined(PARANOID_LOCKING )/* Lock debugging */ const char *last_sem;
common.c +0 -52
59 lines not on this page · raw message
pci.c +1 -1
@@ -1617,7 +1617,7 @@ acxpci_e_probe(struct pci_dev *pdev, con adev =ndev2adev (ndev);spin_lock_init (&adev->lock);/* initial state: unlocked */ /* We do not start with downed sem: we want PARANOID_LOCKING to work */ -sema_init (&adev->sem,1 );/* initial state: 1 (upped) */ +mutex_init (&adev->mutex);/* initial state: 1 (upped) */ /* since nobody can see new netdev yet, we can as well ** just _presume_ that we're under sem (instead of actually taking it): */ /* acx_sem_lock(adev); */
usb.c +1 -1
@@ -869,7 +869,7 @@ acxusb_e_probe(struct usb_interface *int adev->usbdev = usbdev;spin_lock_init (&adev->lock);/* initial state: unlocked */ -sema_init (&adev->sem,1 );/* initial state: 1 (upped) */ +mutex_init (&adev->mutex);/* initial state: 1 (upped) */ /* Check that this is really the hardware we know about. ** If not sure, at least notify the user that he
Quoted 7 lines · Carlos Martín
Hi,
The attached patch transform the semaphore to a mutex. That's how we use it,
it's faster and makes the binary smaller. It also deletes the semaphore debug functions because I the kernel takes care of that now. Just yell if I've misunderstood.
Quoted 6 lines
text data bss dec hex filename 113475 1520 20 115015 1c147 acx.ko-sem 111033 1520 20 112573 1b7bd acx.koThis only works for newer kernels, so I suppose it could be kept as an into-mainline patch. People with newer kernels probably want this patch.
http://195.66.192.167/linux/acx_patches/acx-sem-to-mutex.patch
Thanks!
--
vda
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642