Chintalapati,Sriram wrote:

Hi,
We are planning to port a STREAMS driver which does not support SMP to Linux using latest version of LiS.


Also, can you please let me know/point to any information about making a driver MP-safe, like what are the issues to be considered while using locks in Linux and effort involved in making a driver MP-safe?

It isn't actually that hard. You can learn just about everything you need to know from the Solaris driver writer's guide and the Solaris Streams guide. If you follow the rules there for making a driver MP safe, it should work on Linux. Of course, you'll have to use the LiS calls.


Here are a couple of things to bear in mind. Some of these things you will find in the Solaris document, some are from my personal experience:

1. Do not call putnext when holding a spin lock. This can lead to trying to aquire a lock that you already have. On Solaris/Unixware, you will panic. Although LiS spin locks can be reentered by the same thread of control, trying to get it all working will complicate your life.

A better solution is to putq to your lower write q or upper read q and have the appropriate service routine do a putnext.

2. Do not call untimeout while holding a lock that could be acquired in the routine that would be called from the timeout. Some OS's cause untimeout to wait until that routine returns if it is currently running. This means that you could hold the lock on one processor. On the second processor the timeout occurs and that routine blocks attempting to get the lock you hold. You now call untimeout which blocks waiting for the timed out routine to return.

3. Although there are a number of different locks and routines available, you can probably just stick to spin locks. Your life will also be easier if you use only the routines lis_spin_lock_irqsave, and lis_spin_unlock_irqrestore.

4. You can get as complicated as you want, but the easiest way to do things is to have one lock for the entire driver/module. Aquire it when you enter the driver via a streams routine (open, close, put, uwsrv, lrsrv) or timeout. Let it go when you exit that routine. Follow Rule #1. If this doesn't give the performance you need, you can start looking for ways to optimize.

By the way, in my opinion, it is much easier to do your development on Solaris and port to Linux.

Have fun,
Jared


_______________________________________________ Linux-streams mailing list [EMAIL PROTECTED] http://gsyc.escet.urjc.es/mailman/listinfo/linux-streams

Reply via email to