From: David Wei <dw@davidwei.uk>
To: Simon Horman <horms@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@resnulli.us>,
Sabrina Dubroca <sd@queasysnail.net>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net-next v4 1/5] netdevsim: maintain a list of probed netdevsims
Date: Thu, 21 Dec 2023 16:49:35 -0800 [thread overview]
Message-ID: <2fa47ece-a8ee-4b16-93f7-801927b9b199@davidwei.uk> (raw)
In-Reply-To: <20231220164050.GN882741@kernel.org>
On 2023-12-20 08:40, Simon Horman wrote:
> On Tue, Dec 19, 2023 at 05:47:43PM -0800, David Wei wrote:
>> This patch adds a linked list nsim_dev_list of probed netdevsims, added
>> during nsim_drv_probe() and removed during nsim_drv_remove(). A mutex
>> nsim_dev_list_lock protects the list.
>>
>> Signed-off-by: David Wei <dw@davidwei.uk>
>> ---
>> drivers/net/netdevsim/dev.c | 17 +++++++++++++++++
>> drivers/net/netdevsim/netdevsim.h | 1 +
>> 2 files changed, 18 insertions(+)
>>
>> diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
>> index b4d3b9cde8bd..e30a12130e07 100644
>> --- a/drivers/net/netdevsim/dev.c
>> +++ b/drivers/net/netdevsim/dev.c
>> @@ -35,6 +35,9 @@
>>
>> #include "netdevsim.h"
>>
>> +static LIST_HEAD(nsim_dev_list);
>> +static DEFINE_MUTEX(nsim_dev_list_lock);
>> +
>> static unsigned int
>> nsim_dev_port_index(enum nsim_dev_port_type type, unsigned int port_index)
>> {
>> @@ -1531,6 +1534,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>> nsim_bus_dev->initial_net, &nsim_bus_dev->dev);
>> if (!devlink)
>> return -ENOMEM;
>> + mutex_lock(&nsim_dev_list_lock);
>> devl_lock(devlink);
>> nsim_dev = devlink_priv(devlink);
>> nsim_dev->nsim_bus_dev = nsim_bus_dev;
>> @@ -1544,6 +1548,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>> spin_lock_init(&nsim_dev->fa_cookie_lock);
>>
>> dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev);
>> + list_add(&nsim_dev->list, &nsim_dev_list);
>>
>> nsim_dev->vfconfigs = kcalloc(nsim_bus_dev->max_vfs,
>> sizeof(struct nsim_vf_config),
>> @@ -1607,6 +1612,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>>
>> nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_LEGACY;
>> devl_unlock(devlink);
>> + mutex_unlock(&nsim_dev_list_lock);
>> return 0;
>>
>
> Hi David,
>
> I see Jiri has asked about the scope and type of this lock.
> And updates to address those questions may obviate my observation.
> But it is that mutex_unlock(&nsim_dev_list_lock); needs to
> be added to the unwind ladder:
>
> ...
> err_devlink_unlock:
> devl_unlock(devlink);
> mutex_unlock(&nsim_dev_list_lock);
> ...
>
> ...
>
> Flagged by Smatch.
Hi Simon, thanks for flagging this and I will address it in the next
version.
next prev parent reply other threads:[~2023-12-22 0:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 1:47 [PATCH net-next v4 0/5] netdevsim: link and forward skbs between ports David Wei
2023-12-20 1:47 ` [PATCH net-next v4 1/5] netdevsim: maintain a list of probed netdevsims David Wei
2023-12-20 8:57 ` Jiri Pirko
2023-12-22 0:45 ` David Wei
2023-12-22 4:54 ` David Wei
2024-01-02 10:55 ` Jiri Pirko
2024-01-02 11:01 ` Jiri Pirko
2023-12-20 16:40 ` Simon Horman
2023-12-22 0:49 ` David Wei [this message]
2023-12-20 1:47 ` [PATCH net-next v4 2/5] netdevsim: allow two netdevsim ports to be connected David Wei
2023-12-20 9:09 ` Jiri Pirko
2023-12-22 0:47 ` David Wei
2024-01-02 10:56 ` Jiri Pirko
2023-12-20 12:58 ` kernel test robot
2023-12-20 1:47 ` [PATCH net-next v4 3/5] netdevsim: forward skbs from one connected port to another David Wei
2023-12-20 9:04 ` Jiri Pirko
2023-12-22 0:58 ` David Wei
2023-12-20 1:47 ` [PATCH net-next v4 4/5] netdevsim: add selftest for forwarding skb between connected ports David Wei
2023-12-20 1:47 ` [PATCH net-next v4 5/5] netdevsim: add Makefile for selftests David Wei
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=2fa47ece-a8ee-4b16-93f7-801927b9b199@davidwei.uk \
--to=dw@davidwei.uk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
/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).