netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Veaceslav Falico <darkmag@gmail.com>
To: Veaceslav Falico <vfalico@redhat.com>
Cc: David Miller <davem@davemloft.net>,
	nhorman@tuxdriver.com, netdev@vger.kernel.org, amwang@redhat.com
Subject: Re: [PATCH] netconsole: release the spinlock before __netpoll_cleanup()
Date: Mon, 11 Mar 2013 11:08:02 +0100	[thread overview]
Message-ID: <CAE3RKN=ix96skUHw3j5snbue-r8SOnSovw4_zh4RX4t-uDW2Cw@mail.gmail.com> (raw)
In-Reply-To: <20130310152546.GA4897@redhat.com>

On Sun, Mar 10, 2013 at 4:25 PM, Veaceslav Falico <vfalico@redhat.com> wrote:
> On Thu, Mar 07, 2013 at 04:14:38PM -0500, David Miller wrote:
>>
...snip...
>> Quite a bit of email corruption of this patch.
>
>
> Sorry, somehow messed it.
>
>
>>
>> Also, this code block is probably too deeply indented to be sane,
>> consider creating a small helper function to call instead.
>
>
> It gets quite ugly if I try to move it to another function. However, maybe
> something like that will work - it's effectively the same code, just that
> I've moved the long part out of the if () { } block. Looks a lot more
> readable, though one line still breaks 80chars limit. I've reworked the
> subject/commit message too.
>
> Subject: [PATCH] netconsole: don't call __netpoll_cleanup() while atomic
>
> __netpoll_cleanup() is called in netconsole_netdev_event() while holding a
> spinlock. Release/acquire the spinlock before/after it and restart the
>
> loop.
>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
> ---
>    drivers/net/netconsole.c |   22 +++++++++++++++-------
>    1 files changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> index 37add21..38eaa8c 100644
>
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -666,6 +666,7 @@ static int netconsole_netdev_event(struct notifier_block
> *this,
>                 goto done;
>         spin_lock_irqsave(&target_list_lock, flags);
> +restart:
>         list_for_each_entry(nt, &target_list, list) {
>                 netconsole_target_get(nt);
>                 if (nt->np.dev == dev) {
> @@ -679,14 +680,21 @@ static int netconsole_netdev_event(struct
> notifier_block *this,
>                                 /*
>
>                                  * rtnl_lock already held
>                                  */
> -                               if (nt->np.dev) {
> -                                       __netpoll_cleanup(&nt->np);
> -                                       dev_put(nt->np.dev);
> -                                       nt->np.dev = NULL;
> +                               if (!nt->np.dev) {
> +                                       nt->enabled = 0;
> +                                       stopped = true;
> +                                       break;
>                                 }
> -                               nt->enabled = 0;
> -                               stopped = true;
> -                               break;
> +                               /*
> +                                * we might sleep in __netpoll_cleanup()
> +                                */
> +                               spin_unlock_irqrestore(&target_list_lock,
> flags);
> +                               __netpoll_cleanup(&nt->np);
> +                               spin_lock_irqsave(&target_list_lock, flags);
> +                               dev_put(nt->np.dev);
> +                               nt->np.dev = NULL;
>
> +                               netconsole_target_put(nt);
> +                               goto restart;
>                         }
>                 }
>                 netconsole_target_put(nt);
> --
> 1.7.1

Self-NAK this patch, I've triggered another kernel panic with it. Will
send another one shortly. Basicly, the whole if (!nt->np.dev) is not
needed and nt->enabled=0 should always be set, otherwise we
end up with nt->np.dev == NULL and nt->enabled == 1, thus
triggering panics in places like write_msg(), where it verifies only
if the nt->enabled is true.

-- 
Best regards,
Veaceslav Falico

  reply	other threads:[~2013-03-11 10:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 14:46 [PATCH] netconsole: release the spinlock before __netpoll_cleanup() Veaceslav Falico
2013-03-06 14:51 ` Cong Wang
2013-03-07  0:08 ` Neil Horman
2013-03-07 10:03   ` Veaceslav Falico
2013-03-07 14:43     ` Neil Horman
2013-03-07 21:14     ` David Miller
2013-03-10 15:25       ` Veaceslav Falico
2013-03-11 10:08         ` Veaceslav Falico [this message]
2013-03-11 11:30           ` Neil Horman
2013-03-11 11:39             ` Veaceslav Falico
2013-03-11 17:58               ` Neil Horman

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='CAE3RKN=ix96skUHw3j5snbue-r8SOnSovw4_zh4RX4t-uDW2Cw@mail.gmail.com' \
    --to=darkmag@gmail.com \
    --cc=amwang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=vfalico@redhat.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).