From: Eric Dumazet <eric.dumazet@gmail.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: netdev@vger.kernel.org, Ivan Vecera <ivecera@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Ben Hutchings <bhutchings@solarflare.com>
Subject: Re: [PATCH v2] netpoll: protect napi_poll and poll_controller during dev_[open|close]
Date: Fri, 01 Feb 2013 09:14:07 -0800 [thread overview]
Message-ID: <1359738847.30177.48.camel@edumazet-glaptop> (raw)
In-Reply-To: <1359738159-22597-1-git-send-email-nhorman@tuxdriver.com>
On Fri, 2013-02-01 at 12:02 -0500, Neil Horman wrote:
> Ivan Vercera was recently backporting commit
> 9c13cb8bb477a83b9a3c9e5a5478a4e21294a760 to a RHEL kernel, and I noticed that,
> while this patch protects the tg3 driver from having its ndo_poll_controller
> routine called during device initalization, it does nothing for the driver
> during shutdown. I.e. it would be entirely possible to have the
> ndo_poll_controller method (or subsequently the ndo_poll) routine called for a
> driver in the netpoll path on CPU A while in parallel on CPU B, the ndo_close or
> ndo_open routine could be called. Given that the two latter routines tend to
> initizlize and free many data structures that the former two rely on, the result
> can easily be data corruption or various other crashes. Furthermore, it seems
> that this is potentially a problem with all net drivers that support netpoll,
> and so this should ideally be fixed in a common path.
>
> As Ben H Pointed out to me, we can't preform dev_open/dev_close in atomic
> context, so I've come up with this solution. I've modified the npinfo->rx_flags
> to make use of bitops, so that we can atomically set/clear individual bits.
> We use one of these bits to provide mutual exclusion between the netpoll polling
> path and the dev_open/close paths. I can't say Im a huge fan of returning
> -EBUSY in open/close, but I like it better than busy waiting while the poll path
> completes.
>
> I've tested this here by flooding netconsole with messages on a system whos nic
> driver I modfied to periodically return NETDEV_TX_BUSY, so that the netpoll tx
> workqueue would be forced to send frames and poll the device. While this was
> going on I rapidly ifdown/up'ed the interface and watched for any problems.
> I've not found any.
>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: Ivan Vecera <ivecera@redhat.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Ben Hutchings <bhutchings@solarflare.com>
> ---
> include/linux/netpoll.h | 14 +++++++++----
> net/core/dev.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
> net/core/netpoll.c | 23 ++++++++++++++-------
> 3 files changed, 79 insertions(+), 11 deletions(-)
>
> diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
> index f54c3bb..09ef2e5 100644
> --- a/include/linux/netpoll.h
> +++ b/include/linux/netpoll.h
> @@ -35,10 +35,14 @@ struct netpoll {
> struct rcu_head rcu;
> };
>
> +#define NETPOLL_RX_ENABLED 1
> +#define NETPOLL_RX_DROP 2
> +#define NETPOLL_RX_ACTIVE 3
> +
> struct netpoll_info {
> atomic_t refcnt;
>
> - int rx_flags;
> + unsigned long flags;
> spinlock_t rx_lock;
> struct list_head rx_np; /* netpolls that registered an rx_hook */
You could avoid holes on 64bit arches using following order :
atomic_t refcnt;
spinlock_t rx_lock;
unsigned long flags;
next prev parent reply other threads:[~2013-02-01 17:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-30 20:44 [PATCH] netpoll: protect napi_poll and poll_controller during dev_[open|close] Neil Horman
2013-01-30 21:07 ` Ben Hutchings
2013-01-30 21:25 ` Neil Horman
2013-02-01 17:02 ` [PATCH v2] " Neil Horman
2013-02-01 17:14 ` Eric Dumazet [this message]
2013-02-01 17:49 ` [PATCH v3] " Neil Horman
2013-02-01 21:21 ` Francois Romieu
2013-02-02 18:51 ` [PATCH v4] " Neil Horman
2013-02-03 21:05 ` David Miller
2013-02-04 0:32 ` Neil Horman
2013-02-04 17:40 ` [PATCH v5] " Neil Horman
2013-02-05 2:06 ` David Miller
2013-02-05 15:07 ` Neil Horman
2013-02-05 18:05 ` [PATCH v6] " Neil Horman
2013-02-06 20:45 ` David Miller
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=1359738847.30177.48.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=ivecera@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.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