From: Andrew Morton <akpm@linux-foundation.org>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: David Decotigny <decot@googlers.com>,
<linux-kernel@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Or Gerlitz <ogerlitz@mellanox.com>,
Amir Vadai <amirv@mellanox.com>,
"Paul E. McKenney" <paul.mckenney@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Josh Triplett <josh@joshtriplett.org>,
David Howells <dhowells@redhat.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: Re: [PATCH v4] lib: cpu_rmap: avoid flushing all workqueues
Date: Thu, 3 Jan 2013 13:58:51 -0800 [thread overview]
Message-ID: <20130103135851.8cc58899.akpm@linux-foundation.org> (raw)
In-Reply-To: <1357170406.3652.66.camel@bwh-desktop.uk.solarflarecom.com>
On Wed, 2 Jan 2013 23:46:46 +0000
Ben Hutchings <bhutchings@solarflare.com> wrote:
> On Wed, 2013-01-02 at 15:12 -0800, Andrew Morton wrote:
> > On Wed, 2 Jan 2013 13:52:25 -0800
> > David Decotigny <decot@googlers.com> wrote:
> >
> > > In some cases, free_irq_cpu_rmap() is called while holding a lock
> > > (eg. rtnl). This can lead to deadlocks, because it invokes
> > > flush_scheduled_work() which ends up waiting for whole system
> > > workqueue to flush, but some pending works might try to acquire the
> > > lock we are already holding.
> > >
> > > This commit uses reference-counting to replace
> > > irq_run_affinity_notifiers(). It also removes
> > > irq_run_affinity_notifiers() altogether.
> >
> > I can't say that I've ever noticed cpu_rmap.c before :( Is is too late
> > to review it?
> >
> > - The naming is chaotic. At least these:
> >
> > EXPORT_SYMBOL(alloc_cpu_rmap);
> > EXPORT_SYMBOL(free_cpu_rmap);
> > EXPORT_SYMBOL(cpu_rmap_add);
> > EXPORT_SYMBOL(cpu_rmap_update);
> > EXPORT_SYMBOL(free_irq_cpu_rmap);
> > EXPORT_SYMBOL(irq_cpu_rmap_add);
> >
> > should be consistently named cpu_rmap_foo()
>
> There is a common practice of defining alloc_foo() and free_foo()
> alongside foo_do_this() and foo_do_that(). I deliberately chose to
> follow that. If this is deprecated then it should be documented
> somewhere.
I don't think anyone has thought about it to that extent. I always
recommend that the exported identifiers be named as
subsysid_functionname() and cannot think of any reason for
special-casing alloc and free.
> > - What's the locking model? It appears to be caller-provided, but
> > it is undocumented.
>
> I think caller-provided can be assumed as the default for library code.
Nope, a lot of library code does internal locking. And boy, does that
cause problems! Experience tells us that caller-provided locking is
better. But to avoid nasty problems, the library should clearly
document its locking requirements!
Bear in mind that spinlocks and mutexes aren't the only form of locks.
A caller may wish to use an rwsem or rwlock, either to get parallelism
in cpu_rmap_lookup_index() and cpu_rmap_lookup_obj(), or because they
were already using such a lock. The cpu_rmap() locking documentation
should describe which interface calls are OK with read-side locking.
Not only to instruct users, but also to act as a constraint upon future
developers of the cpu_rmap code. It becomes a contract saying "if you
use read_lock() for this, we won't later break your stuff".
> And IRQ setup and teardown need to be properly serialised in the driver
> already.
>
> > drivers/net/ethernet/mellanox/mlx4/ appears to be using
> > msix_ctl.pool_lock for exclusion, but I didn't check for coverage.
> >
> > drivers/net/ethernet/sfc/efx.c seems to not need locking because
> > all its cpu_rmap operations are at module_init() time.
> >
> > The cpu_rmap code would be less of a hand grenade if each of its
> > interface functions documented the caller's locking requirements.
>
> This particular 'hand grenade' *was* documented. So I don't think
> documentation is the problem.
Dunno what you're referring to here. There is no cpu_rmap() locking
documentation.
> > As for this patch: there's no cc:stable here but it does appear that
> > the problem is sufficiently serious to justify a backport, agree?
> [...]
>
> Not sure. So far as I can see, nothing called free_irq_cpu_rmap() while
> holding the RTNL lock before v3.8-rc1. If there can be work items on a
> global workqueue that lock a PCI device (perhaps EEH?) then stable
> versions may also be affected.
OK. The patch is rather non-trivial so I guess we aim for 3.8-only
for now.
next prev parent reply other threads:[~2013-01-03 21:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1357163124.git.decot@googlers.com>
2013-01-02 21:52 ` [PATCH v4] lib: cpu_rmap: avoid flushing all workqueues David Decotigny
2013-01-02 21:54 ` Ben Hutchings
2013-01-02 22:05 ` Eric Dumazet
2013-01-02 22:20 ` Josh Triplett
2013-01-02 23:12 ` Andrew Morton
2013-01-02 23:46 ` Ben Hutchings
2013-01-03 21:58 ` Andrew Morton [this message]
2013-01-08 16:05 ` Ben Hutchings
2013-01-03 2:35 ` David Decotigny
2013-01-03 21:47 ` Andrew Morton
2013-01-03 22:26 ` Ben Hutchings
2013-01-07 13:00 ` Amir Vadai
2013-01-07 13:01 ` Amir Vadai
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=20130103135851.8cc58899.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=amirv@mellanox.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=decot@googlers.com \
--cc=dhowells@redhat.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=paul.gortmaker@windriver.com \
--cc=paul.mckenney@linaro.org \
--cc=tglx@linutronix.de \
/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