From: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Dany Madden <drt@linux.ibm.com>,
Lijun Pan <ljp@linux.ibm.com>
Subject: Re: [PATCH 5/7] ibmvnic: use a lock to serialize remove/reset
Date: Sun, 10 Jan 2021 19:52:25 -0800 [thread overview]
Message-ID: <20210111035225.GB165065@us.ibm.com> (raw)
In-Reply-To: <20210109194146.7c8ac5ce@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Jakub Kicinski [kuba@kernel.org] wrote:
> On Thu, 7 Jan 2021 23:12:34 -0800 Sukadev Bhattiprolu wrote:
> > Use a separate lock to serialze ibmvnic_reset() and ibmvnic_remove()
> > functions. ibmvnic_reset() schedules work for the worker thread and
> > ibmvnic_remove() flushes the work before removing the adapter. We
> > don't want any work to be scheduled once we start removing the
> > adapter (i.e after we have already flushed the work).
>
> Locking based on functions, not on data being accessed is questionable
> IMO. If you don't want work to be scheduled isn't it enough to have a
> bit / flag that you set to let other flows know not to schedule reset?
Maybe I could improve the description, but the "data" being protected
is the work queue. Basically don't add to the work queue while/after
it is (being) flushed.
Existing code is checking for the VNIC_REMOVING state before scheduling
the work but without a lock. If state goes to REMOVING after we check,
we could schedule work after the flush?
>
> > @@ -5459,6 +5464,7 @@ static int ibmvnic_remove(struct vio_dev *dev)
> > {
> > struct net_device *netdev = dev_get_drvdata(&dev->dev);
> > struct ibmvnic_adapter *adapter = netdev_priv(netdev);
> > + unsigned long rmflags;
> > unsigned long flags;
> >
> > spin_lock_irqsave(&adapter->state_lock, flags);
> > @@ -5467,7 +5473,15 @@ static int ibmvnic_remove(struct vio_dev *dev)
> > return -EBUSY;
> > }
>
> > + spin_lock_irqsave(&adapter->remove_lock, rmflags);
>
> You can just use flags again, no need for separate variables.
Ok.
>
> > adapter->state = VNIC_REMOVING;
> > + spin_unlock_irqrestore(&adapter->remove_lock, rmflags);
next prev parent reply other threads:[~2021-01-11 3:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 7:12 [PATCH 0/7] ibmvnic: Use more consistent locking Sukadev Bhattiprolu
2021-01-08 7:12 ` [PATCH 1/7] ibmvnic: restore state in change-param reset Sukadev Bhattiprolu
2021-01-08 7:12 ` [PATCH 2/7] ibmvnic: update reset function prototypes Sukadev Bhattiprolu
2021-01-10 3:37 ` Jakub Kicinski
2021-01-11 3:12 ` Sukadev Bhattiprolu
2021-01-11 19:32 ` Jakub Kicinski
2021-01-11 19:57 ` Sukadev Bhattiprolu
2021-01-08 7:12 ` [PATCH 3/7] ibmvnic: avoid allocating rwi entries Sukadev Bhattiprolu
2021-01-08 7:12 ` [PATCH 4/7] ibmvnic: switch order of checks in ibmvnic_reset Sukadev Bhattiprolu
2021-01-08 7:12 ` [PATCH 5/7] ibmvnic: use a lock to serialize remove/reset Sukadev Bhattiprolu
2021-01-10 3:41 ` Jakub Kicinski
2021-01-11 3:52 ` Sukadev Bhattiprolu [this message]
2021-01-11 19:43 ` Jakub Kicinski
2021-01-11 20:15 ` Sukadev Bhattiprolu
2021-01-08 7:12 ` [PATCH 6/7] ibmvnic: check adapter->state under state_lock Sukadev Bhattiprolu
2021-01-08 7:12 ` [PATCH 7/7] ibmvnic: add comments about adapter->state_lock Sukadev Bhattiprolu
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=20210111035225.GB165065@us.ibm.com \
--to=sukadev@linux.ibm.com \
--cc=drt@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=ljp@linux.ibm.com \
--cc=netdev@vger.kernel.org \
/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).