From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: angkery <angkery@163.com>,
mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org,
drt@linux.ibm.com, ljp@linux.ibm.com, sukadev@linux.ibm.com,
davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, Junlin Yang <yangjunlin@yulong.com>
Subject: Re: [PATCH] ibmvnic: remove excessive irqsave
Date: Fri, 5 Mar 2021 06:49:14 +0100 [thread overview]
Message-ID: <67215668-0850-a0f3-06e1-49db590b8fcc@csgroup.eu> (raw)
In-Reply-To: <20210305014350.1460-1-angkery@163.com>
Le 05/03/2021 à 02:43, angkery a écrit :
> From: Junlin Yang <yangjunlin@yulong.com>
>
> ibmvnic_remove locks multiple spinlocks while disabling interrupts:
> spin_lock_irqsave(&adapter->state_lock, flags);
> spin_lock_irqsave(&adapter->rwi_lock, flags);
>
> there is no need for the second irqsave,since interrupts are disabled
> at that point, so remove the second irqsave:
The problème is not that there is no need. The problem is a lot more serious:
As reported by coccinella, the second _irqsave() overwrites the value saved in 'flags' by the first
_irqsave, therefore when the second _irqrestore comes, the value in 'flags' is not valid, the value
saved by the first _irqsave has been lost. This likely leads to IRQs remaining disabled, which is
_THE_ problem really.
> spin_lock_irqsave(&adapter->state_lock, flags);
> spin_lock(&adapter->rwi_lock);
>
> Generated by: ./scripts/coccinelle/locks/flags.cocci
> ./drivers/net/ethernet/ibm/ibmvnic.c:5413:1-18:
> ERROR: nested lock+irqsave that reuses flags from line 5404.
>
> Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
> ---
> drivers/net/ethernet/ibm/ibmvnic.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
> index 2464c8a..a52668d 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -5408,9 +5408,9 @@ static void ibmvnic_remove(struct vio_dev *dev)
> * after setting state, so __ibmvnic_reset() which is called
> * from the flush_work() below, can make progress.
> */
> - spin_lock_irqsave(&adapter->rwi_lock, flags);
> + spin_lock(&adapter->rwi_lock);
> adapter->state = VNIC_REMOVING;
> - spin_unlock_irqrestore(&adapter->rwi_lock, flags);
> + spin_unlock(&adapter->rwi_lock);
>
> spin_unlock_irqrestore(&adapter->state_lock, flags);
>
>
next prev parent reply other threads:[~2021-03-05 5:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-05 1:43 angkery
2021-03-05 4:19 ` Sukadev Bhattiprolu
2021-03-05 5:49 ` Christophe Leroy [this message]
2021-03-05 6:04 ` Lijun Pan
2021-03-05 7:03 ` angkery
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=67215668-0850-a0f3-06e1-49db590b8fcc@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=angkery@163.com \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=drt@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ljp@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=paulus@samba.org \
--cc=sukadev@linux.ibm.com \
--cc=yangjunlin@yulong.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
all inboxes | Powered by JetHome®