netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mitchell Blank Jr <mitch@sfgoth.com>
To: "David S. Miller" <davem@redhat.com>
Cc: chas3@users.sourceforge.net, chas@cmf.nrl.navy.mil, netdev@oss.sgi.com
Subject: Re: [RFC] add rtnl semaphore to linux-atm
Date: Thu, 2 Oct 2003 19:26:15 -0700	[thread overview]
Message-ID: <20031003022615.GA42593@gaz.sfgoth.com> (raw)
In-Reply-To: <20031001054226.126cea7b.davem@redhat.com>

David S. Miller wrote:
> Although, unless VCC connect can potentially sleep, it might
> be better to keep exporting the rwlock and take it as a reader
> instead of grabbing the rtnl semaphore.

VCC connect can definately sleep - a good example is
drirvers/usb/misc/speedtch.c but there are probably other ones.

My personal recommendations:
  * There should be a per-atm-device semaphore held across calls into the
    driver's ->open, ->close, ->change_qos and maybe a couple other things
    to serialize those operations (for the sake of keeping the drivers
    sane - there's no reason there should be multiple operations pending)

  * The ATM layer shouldn't need to keep any other sorts of locks across
    calls into atm_dev->open or such.  To avoid race conditions the ATM
    code needs to:
      1. Take whatever internal spinlock it needs
      2. Add the itf/vpi/vci tuple to whatever datastructure we're holding
         the vcc list in - but mark it as "inactive" so we don't find it
	 while others are searching the list.  Obviously the open will
	 fail if we find a matching tuple (whether or not it was active)
      3. Drop the spinlock
      4. Take the per-device semaphore
      5. Call atmdev->open
      6. Drop the per-device semaphore
      7. Re-take the internal spinlock
      8. If open succeeded now mark the vcc as "active".  If the open failed
         just delete it
      9. Drop the internal spinlock

    To do a close the method is similar:
      1. Take the internal spinlock
      2. Find the tuple, mark it as inactive
      3. Drop the spinlock
      4. Take the per-device semaphore
      5. Call atmdev->close
      6. Drop the per-device semaphore
      7. Re-take the internal spinlock
      8. Delete vcc from the list
      9. Drop the internal spinlock

    Then ->open and ->close can sleep like they need to but won't block
    other accesses to the list in the mean time.

  * If ATM_ITF_ANY is a pain to fix it should just be removed - it's
    basically a misfeature and is probably never used by anybody.  I've
    already posted a patch to linux-atm-general that basically does this
    (it changes "ATM_ITF_ANY" to mean "first interface we find")

-Mitch

  parent reply	other threads:[~2003-10-03  2:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-01 11:34 [RFC] add rtnl semaphore to linux-atm chas williams
2003-10-01 12:42 ` David S. Miller
2003-10-01 13:07   ` chas williams
2003-10-01 13:14     ` David S. Miller
2003-10-03  2:26   ` Mitchell Blank Jr [this message]
2003-10-03 13:58     ` David S. Miller
2003-10-03 21:45       ` Mitchell Blank Jr
2003-10-04  5:16         ` David S. Miller
2003-10-04  5:55           ` Mitchell Blank Jr
2003-10-04  6:56             ` Mitchell Blank Jr
2003-10-04  6:59       ` Mitchell Blank Jr
2003-10-04 12:50         ` chas williams
2003-10-04 19:42           ` Mitchell Blank Jr
2003-10-05 12:52             ` chas williams
2003-10-06  9:03               ` Mitchell Blank Jr
2003-10-06 14:46                 ` chas williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031003022615.GA42593@gaz.sfgoth.com \
    --to=mitch@sfgoth.com \
    --cc=chas3@users.sourceforge.net \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=davem@redhat.com \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).