netdev
[Top] [All Lists]

Re: [RFC] add rtnl semaphore to linux-atm

To: "David S. Miller" <davem@xxxxxxxxxx>
Subject: Re: [RFC] add rtnl semaphore to linux-atm
From: Mitchell Blank Jr <mitch@xxxxxxxxxx>
Date: Fri, 3 Oct 2003 23:56:29 -0700
Cc: chas3@xxxxxxxxxxxxxxxxxxxxx, chas@xxxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx
In-reply-to: <20031004055526.GG73152@xxxxxxxxxxxxxx>
References: <200310011134.h91BYPkT003172@xxxxxxxxxxxxxxxxxxxxxxx> <20031001054226.126cea7b.davem@xxxxxxxxxx> <20031003022615.GA42593@xxxxxxxxxxxxxx> <20031003065824.713627c6.davem@xxxxxxxxxx> <20031003214541.GA73152@xxxxxxxxxxxxxx> <20031003221640.19aa485f.davem@xxxxxxxxxx> <20031004055526.GG73152@xxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.1i
Mitchell Blank Jr wrote:
> I'm just trying to make the point that the spinlock (or rwlock, whatever)
> can't be held when we call atm_dev->{open,close}() since they can sleep.
> Which is why we need to do the three-step process I described in the
> earlier email.

Actually I guess there's two ways of doing it... so instead of

Method 1:
  1. Take rwlock for writing
  2. Search for {dev,vpi,vci} tuple.  If found, fail - otherwise add it
     as "inactive"
  3. Drop rwlock
  4. Take semaphore
  5. Call atm_dev->open()
  6. Drop semaphore
  7. Take rwlock for writing
  8. If open succeeded clear "inactive" flag.  If failed remove entry
  9. Drop rwlock

Method 2:
  1. Take semaphore
  2. Take rwlock for reading
  3. Search for tuple, if found fail
  4. Drop rwlock
  5. Call atm_dev->open
  6. Take rwlock for writing
  7. Add tuple to list
  8. Drop rwlock
  9. Drop semaphore

The second method has the advantage that you don't need the "inactive"
flag.  On the other hand, you have to wait for the semaphore before
you can return EADDRINUSE.

-Mitch

<Prev in Thread] Current Thread [Next in Thread>