mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Salil Mehta <salil.mehta@huawei.com>
To: Marc Zyngier <maz@kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"Zhuangyuzeng (Yisen)" <yisen.zhuang@huawei.com>,
	"lipeng (Y)" <lipeng321@huawei.com>,
	"mehta.salil@opnsrc.net" <mehta.salil@opnsrc.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linuxarm <linuxarm@huawei.com>
Subject: RE: [PATCH net] net: hns: Fix the stray netpoll locks causing deadlock in NAPI path
Date: Thu, 7 Nov 2019 14:20:57 +0000	[thread overview]
Message-ID: <9c15e61f739045ee876ae3fbb1e49446@huawei.com> (raw)
In-Reply-To: <a6f06cfc7ef91685746dfe5ab6c56401@www.loen.fr>

Hi Marc,

> From: Marc Zyngier [mailto:maz@kernel.org]
> Sent: Thursday, November 7, 2019 2:13 PM
> To: Salil Mehta <salil.mehta@huawei.com>
> 
> Hi Salil,
> 
> On 2019-11-06 20:03, Salil Mehta wrote:
> > This patch fixes the problem of the spin locks, originally
> > meant for the netpoll path of hns driver, causing deadlock in
> > the normal NAPI poll path. The issue happened due presence of
> > the stray leftover spin lock code related to the netpoll,
> > whose support was earlier removed from the HNS[1], got activated
> > due to enabling of NET_POLL_CONTROLLER switch.
> >
> > Earlier background:
> > The netpoll handling code originally had this bug(as identified
> > by Marc Zyngier[2]) of wrong spin lock API being used which did
> > not disable the interrupts and hence could cause locking issues.
> > i.e. if the lock were first acquired in context to thread like
> > 'ip' util and this lock if ever got later acquired again in
> > context to the interrupt context like TX/RX (Interrupts could
> > always pre-empt the lock holding task and acquire the lock again)
> > and hence could cause deadlock.
> >
> > Proposed Solution:
> > 1. If the netpoll was enabled in the HNS driver, which is not
> >    right now, we could have simply used spin_[un]lock_irqsave()
> > 2. But as netpoll is disabled, therefore, it is best to get rid
> >    of the existing locks and stray code for now. This should
> >    solve the problem reported by Marc.
> >
> > @Marc,
> > Could you please test this patch and confirm if the problem is
> > fixed at your end?
> 
> Yes, this fixes it, although you may want to fully get rid of
> the now useless lock:


Oops..missed them. I will fix these as well and float V2 version
of this patch.


> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c
> b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index 6d0457eb4faa..08339278c722 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -199,7 +199,6 @@ hnae_init_ring(struct hnae_queue *q, struct
> hnae_ring *ring, int flags)
> 
>   	ring->q = q;
>   	ring->flags = flags;
> -	spin_lock_init(&ring->lock);
>   	ring->coal_param = q->handle->coal_param;
>   	assert(!ring->desc && !ring->desc_cb && !ring->desc_dma_addr);
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h
> b/drivers/net/ethernet/hisilicon/hns/hnae.h
> index e9c67c06bfd2..6ab9458302e1 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
> @@ -274,9 +274,6 @@ struct hnae_ring {
>   	/* statistic */
>   	struct ring_stats stats;
> 
> -	/* ring lock for poll one */
> -	spinlock_t lock;
> -
>   	dma_addr_t desc_dma_addr;
>   	u32 buf_size;       /* size for hnae_desc->addr, preset by AE */
>   	u16 desc_num;       /* total number of desc */
> 
> With that:
> 
> Acked-by: Marc Zyngier <maz@kernel.org>
> Tested-by: Marc Zyngier <maz@kernel.org>


Many thanks for your review and testing.


Best Regards
Salil.

      reply	other threads:[~2019-11-07 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 18:54 Salil Mehta
2019-11-07 14:12 ` Marc Zyngier
2019-11-07 14:20   ` Salil Mehta [this message]

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=9c15e61f739045ee876ae3fbb1e49446@huawei.com \
    --to=salil.mehta@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=lipeng321@huawei.com \
    --cc=maz@kernel.org \
    --cc=mehta.salil@opnsrc.net \
    --cc=netdev@vger.kernel.org \
    --cc=yisen.zhuang@huawei.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®