All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryan O'Sullivan" <bos@pathscale.com>
To: Roland Dreier <rdreier@cisco.com>
Cc: Greg KH <gregkh@suse.de>,
	rolandd@cisco.com, akpm@osdl.org, davem@davemloft.net,
	linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: Re: [PATCH 9 of 20] ipath - char devices for diagnostics and lightweight subnet management
Date: Fri, 10 Mar 2006 09:32:32 -0800	[thread overview]
Message-ID: <1142011952.29925.54.camel@serpentine.pathscale.com> (raw)
In-Reply-To: <ada1wxab533.fsf@cisco.com>

On Fri, 2006-03-10 at 09:08 -0800, Roland Dreier wrote:
>     Bryan> OK.  What's a safe way to iterate over the devices in the
>     Bryan> presence of hotplug, then?  I assume it's
>     Bryan> list_for_each_mumble; I just don't know what mumble is :-)
> 
> You need something that takes a reference to each device while you're
> looking at it, like for_each_pci_dev().

OK, thanks.

It seems like the thing to do to be fully safe might be to have
ipath_get() (just rename ipath_lookup) and ipath_put() functions.  Embed
a kref inside ipath_devdata, and have ipath_dev_get increment the ref
count on both the ipath_devdata and the pci_dev.

Is that sane, or am I way off base?

>   But in general iterating
> through devices is usually the wrong thing to do, because devices can
> come and go in the middle of your loop.

I understand that.  In practice, though, I think this is not a good
approach in many of the cases we're dealing with.  Every use of
ipath_max iterates over all devices for a reason.

For example, the diag open routine wants to find at least one device
that's up.  We could maintain a separate list of devices that are in the
state that it needs, so that it can just get the first entry off that
list or fail if the list is empty, but that's more complex than simply
iterating over every device and checking each one.

> (BTW, what does making ipath_max an atomic_t get
> you?  The updates are protected by a lock anyway).

Probably not much.  The motivation was to ensure that if it got
incremented during an iteration, whoever was iterating would see the
update in a timely fashion.

>   But I was talking
> about the code in ipath_verbs_init(), which is the only place you call
> ipath_verbs_register() that I could find.  You make one pass through
> the devices that are present when ipath_verbs_init() is called at
> module load time, and any devices that get added later are missed.

Yes, that code ought to be restructured.

Thanks for the helpful feedback.

	<b


  reply	other threads:[~2006-03-10 17:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <eac2ad3017b5f160d24c.1141922822@localhost.localdomain>
2006-03-09 23:20 ` [PATCH 9 of 20] ipath - char devices for diagnostics and lightweight subnet management Roland Dreier
2006-03-09 23:39   ` Bryan O'Sullivan
2006-03-09 23:47     ` Roland Dreier
2006-03-09 23:50       ` Bryan O'Sullivan
2006-03-09 23:52         ` Roland Dreier
2006-03-10 15:54     ` Michael S. Tsirkin
2006-03-10 16:05       ` Bryan O'Sullivan
2006-03-09 23:24 ` Roland Dreier
2006-03-09 23:49   ` Bryan O'Sullivan
2006-03-09 23:51     ` Roland Dreier
2006-03-09 23:26 ` Roland Dreier
2006-03-09 23:52   ` Bryan O'Sullivan
2006-03-10  0:00     ` Roland Dreier
2006-03-10  0:04       ` Bryan O'Sullivan
2006-03-10  0:45     ` Greg KH
2006-03-10  0:48       ` Bryan O'Sullivan
2006-03-10  1:04         ` Greg KH
2006-03-10  4:41           ` Bryan O'Sullivan
2006-03-10  5:48             ` Greg KH
2006-03-10 13:40               ` Bryan O'Sullivan
2006-03-10  5:55             ` Roland Dreier
2006-03-10 13:43               ` Bryan O'Sullivan
2006-03-10 16:58                 ` Greg KH
2006-03-10 17:05                   ` Bryan O'Sullivan
2006-03-10 17:08                 ` Roland Dreier
2006-03-10 17:32                   ` Bryan O'Sullivan [this message]
2006-03-10 22:20                     ` Roland Dreier
2006-03-10  0:35 [PATCH 0 of 20] [RFC] ipath driver - another round for review Bryan O'Sullivan
2006-03-10  0:35 ` [PATCH 9 of 20] ipath - char devices for diagnostics and lightweight subnet management Bryan O'Sullivan
2006-03-10  0:45   ` Roland Dreier
2006-03-10  0:47     ` Bryan O'Sullivan
2006-03-10  0:52       ` Roland Dreier

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=1142011952.29925.54.camel@serpentine.pathscale.com \
    --to=bos@pathscale.com \
    --cc=akpm@osdl.org \
    --cc=davem@davemloft.net \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openib-general@openib.org \
    --cc=rdreier@cisco.com \
    --cc=rolandd@cisco.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.