From: Dan Carpenter <dan.carpenter@oracle.com>
To: maorg@mellanox.com
Cc: linux-rdma@vger.kernel.org
Subject: [bug report] net/mlx5: Replace fs_node mutex with reader/writer semaphore
Date: Wed, 25 Aug 2021 12:58:11 +0300 [thread overview]
Message-ID: <20210825095811.GA32291@kili> (raw)
[ This is not really the correct commit, but you seem like a person who
understands this locking. - dan ]
Hello Maor Gottlieb,
The patch c7784b1c8ab3: "net/mlx5: Replace fs_node mutex with
reader/writer semaphore" from Aug 27, 2017, leads to the following
Smatch static checker warning:
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c:336 down_write_ref_node()
warn: sleeping in atomic context
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
332 static void down_write_ref_node(struct fs_node *node, bool locked)
333 {
334 if (node) {
335 if (!locked)
--> 336 down_write(&node->lock);
337 refcount_inc(&node->refcount);
338 }
339 }
The call tree is this:
build_match_list() <- disables preempt
-> free_match_list()
-> tree_put_node()
-> down_write_ref_node()
The build_match_list() function takes rcu_read_lock(). What would make
the checker happy is if we did this. But it's not the correct fix
because locked is talking about &node->lock... Could you look at it and
give me a Reported-by cookie if you find a fix?
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 9fe8e3c204d6..41ee18be1a3b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1682,7 +1682,7 @@ static int build_match_list(struct match_list *match_head,
curr_match = kmalloc(sizeof(*curr_match), GFP_ATOMIC);
if (!curr_match) {
- free_match_list(match_head, ft_locked);
+ free_match_list(match_head, true);
err = -ENOMEM;
goto out;
}
regards,
dan carpenter
reply other threads:[~2021-08-25 9:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210825095811.GA32291@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@mellanox.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).