[2.5] convert atm_dev_lock from spinlock to semaphore
you seem to be under the impression that <linux/sem.h> has something to do with linux semaphores. this is not the case; they're sysv semaphores.
apart from this, i think it's a pretty bad idea to just replace the spinlocks with semaphores. atm really needs fixing properly.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 2 lines · Matthew Wilcox
you seem to be under the impression that <
linux/sem.h> has something to do with linux semaphores. this is not the case; they're sysv semaphores.
I agree, this bit has to be fixed.
Quoted 1 line
atm really needs fixing properly.
True, but his change by itself is OK. All of the places where atm_dev_lock is acquired it is safe to do things like sleep.
While checking this I notice that atm_alloc_dev uses GFP_ATOMIC thus unnecessarily.
Anyways, Matt, without a full time ATM maintainer and having basically nobody who wants to take that on, we should take the small fixes when they do occur and are correct as Chas's patch is.
Quoted 3 lines · In message <[email protected]>,"David S. Miller" writes:
Anyways, Matt, without a full time ATM maintainer and having basically nobody who wants to take that on, we should take the small fixes when they do occur and are correct as Chas's patch is.
we (meaning some folks here at nrl) already maintain a seperate kernel with atm 'enhancements' locally. we are very interested in keeping linux-atm alive (particularly in the linux kernel) and extending it as well. i would take the role of maintainer for atm if no one truly wants it.
From: chas williams <[email protected]>
Date: Wed, 19 Feb 2003 00:01:01 -0500
we (meaning some folks here at nrl) already maintain a seperate kernel with atm 'enhancements' locally. we are very interested in keeping linux-atm alive (particularly in the linux kernel) and extending it as well. i would take the role of maintainer for atm if no one truly wants it.
This is the situation.
Therefore, please send me a patch to add an appropriate entry to linux/MAINTAINERS.
Thank you.
Quoted 9 lines · David S. Miller
From: chas williams <[email protected]>
Date: Wed, 19 Feb 2003 00:01:01 -0500we (meaning some folks here at nrl) already maintain a seperate kernel with atm 'enhancements' locally. we are very interested in keeping linux-atm alive (particularly in the linux kernel) and extending it as well. i would take the role of maintainer for atm if no one truly wants it.
Quoted 4 lines
This is the situation.
Therefore, please send me a patch to add an appropriate entry to linux/MAINTAINERS.
Yes, Chas and I have already been discussing moving the maintainership. Previously his work has been concentrated on 2.4 but now he's porting his updates to 2.5 and will be taking over maintenence of the kernel stuff.
As for the locking issues a semaphore is probably the best thing to use at the moment. The *correct* fix would be to have atm_dev's and atm_vcc's be reference counted instead so the card's interrupt handlers can safely work with them. This has been well understood for awhile and I was planning on implementing it about a year ago for 2.5 but I've had basically zero time to devote to linux-atm these days (sorry) Maybe Chas or I or someone will do it for 2.7. The bad part isn't the atm core code (I could probably do that myself in a day) but it would require overhaul of a lot of the ATM drivers. Some of the drivers are pretty scary.
(Side note: basically linux-atm was originally written before SMP support existed and made heavy use of cti/sti to make sure the dev's and vcc's didn't change underneath the drivers. Later these became largely spinlocks but they never really became SMP safe - even though the core code would have proper SMP-exclusion we could have the card doing rx an atm_vcc on one CPU while another was closing it.
There's some stream-of-consiousness comments about this that I wrote a long time ago in drivers/atm/lanai.c around line 616. They're not 100% correct - I was planning on researching the issue more before submitting that driver for inclusion into the tree but it lanai.c eventually got submitted by someone else without asking me first)
-Mitch
Hello Mitchell & Chas , Please do not forget about 2.4 tho as you move forward . Tia , JimL
Signature · 5 lines
+------------------------------------------------------------------+
| James W. Laferriere | System Techniques | Give me VMS |
| Network Engineer | P.O. Box 854 | Give me Linux |
| [email protected] | Coudersport PA 16915 | only on AXP |
+------------------------------------------------------------------+Quoted 2 lines · In message <[email protected]>,Matthew…
you seem to be under the impression that <
linux/sem.h> has something to do with linux semaphores. this is not the case; they're sysv semaphores.
sorry about that. i just picked what seemed like likely culprits for header files.
Quoted 2 lines
apart from this, i think it's a pretty bad idea to just replace the spinlocks with semaphores. atm really needs fixing properly.
yes, atm_dev_lock is wrapped around large chunks of the code. however, it should probably never have been a spinlock--it certainly doesnt need to be one. as a mutex its far less offensive. i am willing to take suggestions as to what would need to be done to fix atm properly?
Quoted 4 lines · chas williams
yes,
atm_dev_lockis wrapped around large chunks of the code. however, it should probably never have been a spinlock--it certainly doesnt need to be one. as a mutex its far less offensive. i am willing to take suggestions as to what would need to be done to fix atm properly?
well, I'm no networking guru, but here are some of the things that seem useful to me:
Try to use `struct sock' where you can. For example, using sk->stamp would allow the SIOCGSTAMP ioctl to be dealt with at a higher level. Right now, atm uses a timestamp embedded in vcc. (Actually, I think I see how to do this one. I'll send you a patch for your review and testing, OK?)
Figure out what actually needs to be locked and lock only that. spinlocks are, by and large, the right solution -- having a Big ATM Lock isn't a good thing (though I do recognise that you may want to do this temporarily while you work on fixing it properly).
You should probably do away with SOCKOPS_WRAP / SOCKOPS_WRAPPED. The BKL doesn't really protect you from much any more.
Might want to consider converting the proc files to the seqfile interface.
There seems to be some custom doubly-linked-list handling going on in atm/resources.c. Should probably be switched to use <linux/list.h>.
I don't like the look of the locking in ipcommon.c:skb_migrate(). If there's really no better way of doing it, I'd recommend something like:
spinlock_t *first, *second;
if ((unsigned long)from < (unsigned long) to)) {
first = &from->lock;
second = &to->lock;
} else {
first = &to->lock;
second = &from->lock;
}
local_irq_save(flags);
spin_lock(&first);
spin_lock(&second);(note that you can leave the spin_unlock and spin_unlock_irqrestore calls as they are).
That's just a quick survey... I'm sure someone who actually uses ATM could find more things to look at ;-)
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk