From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH for-next V6 05/10] IB/core: Add RoCE GID table management
Date: Fri, 17 Jul 2015 13:02:45 -0600 [thread overview]
Message-ID: <20150717190245.GA20632@obsidianresearch.com> (raw)
In-Reply-To: <1435150766-6803-6-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
On Wed, Jun 24, 2015 at 03:59:21PM +0300, Matan Barak wrote:
> +
> + /* in rdma_cap_roce_gid_table, this funciton should be protected by a
> + * sleep-able lock.
> + */
> + write_lock(&table->data_vec[ix].lock);
I'm having a hard time understanding this comment
> +int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
> + union ib_gid *gid, struct ib_gid_attr *attr)
> +{
> + struct ib_gid_table **ports_table =
> + READ_ONCE(ib_dev->cache.gid_cache);
> + /* all table reads depend on ports_table, no need for smp_rmb() */
> + if (!ports_table)
> + return -EOPNOTSUPP;
This common pattern does look genuinely odd...
The gid_cache is part of the common API, it really shouldn't be kfree'd
while held struct ib_devices are around. The kfree for all the cache.c
stuff should probably be called from ib_device_release, not from the
client release.
That is actually something the current code does that is possibly
wrong. It is trivially fixed by moving all the kfrees to
ib_device_release.
Next is the READ_ONCE fencing. I think it is totally unnecessary.
Patch #4 does this:
down_write(&lists_rwsem);
list_del(&device->core_list);
up_write(&lists_rwsem);
list_for_each_entry_reverse(client, &client_list, list)
if (client->remove)
client->remove(device);
So, by the time we get to gid_table_client_cleanup_one, it is no
longer possible for ib_enum_all_roce_netdevs to use the ib_device we
are removing (it is taken off the core_list).
Since all the queued work calls ib_enum_all_roce_netdevs, it is
impossibile for something like ib_cache_gid_add to be called from the
work queue with the ib_dev under removal.
In fact, even the flush_work is not needed because of how lists_rwsem
is being used: we can not remove something from the core list until
there are no ib_enum_all_roce_netdevs callbacks running.
Also, did you notice the double flush of the work queue? One is
enough:
static void ib_cache_cleanup_one(struct ib_device *device)
{
ib_unregister_event_handler(&device->cache.event_handler);
flush_workqueue(ib_wq);
gid_table_client_cleanup_one(device);
static void gid_table_client_cleanup_one(struct ib_device *ib_dev)
{
flush_workqueue(ib_wq);
No other locking problems screamed out at me, but it is a big patch,
and I have't looked closely at all of it.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-07-17 19:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 12:59 [PATCH for-next V6 00/10] Move RoCE GID management to IB/Core Matan Barak
2015-06-24 12:59 ` [PATCH for-next V6 01/10] net/ipv6: Export addrconf_ifid_eui48 Matan Barak
[not found] ` <1435150766-6803-1-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-06-24 12:59 ` [PATCH for-next V6 02/10] net: Add info for NETDEV_CHANGEUPPER event Matan Barak
2015-06-24 12:59 ` [PATCH for-next V6 04/10] IB/core: Add rwsem to allow reading device list or client list Matan Barak
[not found] ` <1435150766-6803-5-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-13 17:29 ` Jason Gunthorpe
2015-06-24 12:59 ` [PATCH for-next V6 05/10] IB/core: Add RoCE GID table management Matan Barak
[not found] ` <1435150766-6803-6-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-07-17 19:02 ` Jason Gunthorpe [this message]
[not found] ` <20150717190245.GA20632-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-07-21 8:42 ` Matan Barak
[not found] ` <CAAKD3BA2Qgw87uXiS-M9gO1-jXPfQncyWzscMuusMABPRRzA8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-23 19:05 ` Jason Gunthorpe
2015-06-24 12:59 ` [PATCH for-next V6 06/10] IB/core: Add RoCE table bonding support Matan Barak
2015-06-24 12:59 ` [PATCH for-next V6 07/10] net/mlx4: Postpone the registration of net_device Matan Barak
2015-06-24 12:59 ` [PATCH for-next V6 08/10] IB/mlx4: Implement ib_device callbacks Matan Barak
2015-06-24 12:59 ` [PATCH for-next V6 09/10] IB/mlx4: Replace mechanism for RoCE GID management Matan Barak
2015-06-24 12:59 ` [PATCH for-next V6 10/10] RDMA/ocrdma: Incorporate the moving of GID Table mgmt to IB/Core Matan Barak
2015-06-25 8:34 ` [PATCH for-next V6 00/10] Move RoCE GID management " Or Gerlitz
[not found] ` <CAJ3xEMjZgMPWA0jm3ReM4Cb1Q-Gz-vXh=XguSYUMAVD+qPA6Zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-25 18:13 ` Jason Gunthorpe
[not found] ` <20150625181357.GG21033-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-06-29 14:07 ` Or Gerlitz
2015-06-24 12:59 ` [PATCH for-next V6 03/10] net/bonding: Export bond_option_active_slave_get_rcu Matan Barak
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=20150717190245.GA20632@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.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