From: Jason Gunthorpe <jgg@nvidia.com>
To: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, RCU <rcu@vger.kernel.org>,
"Paul E . McKenney" <paulmck@kernel.org>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Daniel Axtens <dja@axtens.net>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraju@codeaurora.org>,
Joel Fernandes <joel@joelfernandes.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Theodore Y . Ts'o" <tytso@mit.edu>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>,
Philipp Reisner <philipp.reisner@linbit.com>,
"Md. Haris Iqbal" <haris.iqbal@ionos.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>,
Samuel Iglesias Gonsalvez <siglesias@igalia.com>,
Lee Jones <lee.jones@linaro.org>,
Jorgen Hansen <jhansen@vmware.com>,
Raju Rangoju <rajur@chelsio.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Boris Pismenny <borisp@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 4/9] drivers: Switch to kvfree_rcu() API
Date: Wed, 8 Dec 2021 11:24:35 -0400 [thread overview]
Message-ID: <20211208152435.GA193770@nvidia.com> (raw)
In-Reply-To: <20211124110308.2053-5-urezki@gmail.com>
On Wed, Nov 24, 2021 at 12:03:03PM +0100, Uladzislau Rezki (Sony) wrote:
> Instead of invoking a synchronize_rcu() to free a pointer
> after a grace period we can directly make use of new API
> that does the same but in more efficient way.
It isn't entirely new, kfree_rcu() has been around for ages and any of
these call sites could have made use of it if they wanted. The
kvfree_rcu() just adds the twist of transparently allocating memory.
We really must ask in each case why the original author didn't use
kfree_rcu()..
> drivers/block/drbd/drbd_nl.c | 9 +++------
> drivers/block/drbd/drbd_receiver.c | 6 ++----
> drivers/block/drbd/drbd_state.c | 3 +--
> drivers/block/rnbd/rnbd-srv.c | 3 +--
> drivers/crypto/nx/nx-common-pseries.c | 3 +--
> drivers/infiniband/hw/hfi1/sdma.c | 3 +--
> drivers/ipack/carriers/tpci200.c | 3 +--
> drivers/mfd/dln2.c | 6 ++----
> drivers/misc/vmw_vmci/vmci_context.c | 6 ++----
> drivers/misc/vmw_vmci/vmci_event.c | 3 +--
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 3 +--
> drivers/net/ethernet/mellanox/mlx5/core/en/qos.c | 3 +--
> drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c | 3 +--
> drivers/net/ethernet/mellanox/mlxsw/core.c | 3 +--
> drivers/scsi/device_handler/scsi_dh_alua.c | 3 +--
> drivers/scsi/device_handler/scsi_dh_rdac.c | 3 +--
> drivers/staging/fwserial/fwserial.c | 3 +--
These all need to be split to single patches and ack'ed by experts.
> diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
> index 44ccf8b4f4b2..28f4d84945fd 100644
> +++ b/drivers/block/drbd/drbd_nl.c
> @@ -1679,8 +1679,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
> drbd_send_sync_param(peer_device);
> }
>
> - synchronize_rcu();
> - kfree(old_disk_conf);
> + kvfree_rcu(old_disk_conf);
> kfree(old_plan);
For instance, this, how do you know that old_plan isn't also RCU
protected?
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> index dde1cf51d0ab..0619cb94f0e0 100644
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> @@ -7190,8 +7190,7 @@ static void remove_one(struct pci_dev *pdev)
> }
> pci_release_regions(pdev);
> kfree(adapter->mbox_log);
> - synchronize_rcu();
> - kfree(adapter);
> + kvfree_rcu(adapter);
> }
And this, for instance, just looks crazy! There is only one RCU region
in this file and it is not protecting an adaptor pointer, it is
protecting a netdev. No idea what this is trying to do today even.
Each case needs to be audited to make sure the synchronize_rcu() is
only protecting the kfree and not other things as well. It is tricky
stuff.
I see you got an Ack for the infiniband peice, so feel free to send
that file to the linux-rdma list.
Jason
next prev parent reply other threads:[~2021-12-08 15:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 11:02 [PATCH 0/9] Switch to single argument kvfree_rcu() API Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 1/9] ext4: Switch to " Uladzislau Rezki (Sony)
2021-12-08 14:36 ` Uladzislau Rezki
2021-11-24 11:03 ` [PATCH 2/9] ext4: Replace ext4_kvfree_array_rcu() by " Uladzislau Rezki (Sony)
2021-12-08 14:37 ` Uladzislau Rezki
2021-11-24 11:03 ` [PATCH 3/9] fs: nfs: sysfs: Switch to " Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 4/9] drivers: " Uladzislau Rezki (Sony)
2021-11-29 12:58 ` Lee Jones
2021-11-29 15:18 ` Uladzislau Rezki
2021-11-29 17:19 ` Marciniszyn, Mike
2021-12-08 15:24 ` Jason Gunthorpe [this message]
2021-11-24 11:03 ` [PATCH 5/9] x86/mm: " Uladzislau Rezki (Sony)
2021-11-24 14:58 ` Steven Rostedt
2021-11-24 14:59 ` Steven Rostedt
2021-11-24 18:01 ` Uladzislau Rezki
2021-11-24 11:03 ` [PATCH 6/9] net/tipc: " Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 7/9] net/core: " Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 8/9] module: " Uladzislau Rezki (Sony)
2021-11-30 10:39 ` Miroslav Benes
2021-11-30 11:04 ` Sebastian Andrzej Siewior
2021-12-01 9:24 ` Uladzislau Rezki
2021-12-01 20:34 ` Uladzislau Rezki
2021-11-24 11:03 ` [PATCH 9/9] tracing: " Uladzislau Rezki (Sony)
2021-11-24 15:00 ` Steven Rostedt
2021-11-24 18:03 ` Uladzislau Rezki
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=20211208152435.GA193770@nvidia.com \
--to=jgg@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=borisp@nvidia.com \
--cc=dja@axtens.net \
--cc=frederic@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=haris.iqbal@ionos.com \
--cc=herbert@gondor.apana.org.au \
--cc=jejb@linux.ibm.com \
--cc=jhansen@vmware.com \
--cc=jiri@nvidia.com \
--cc=joel@joelfernandes.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=mike.marciniszyn@cornelisnetworks.com \
--cc=neeraju@codeaurora.org \
--cc=oleksiy.avramchenko@sonymobile.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=philipp.reisner@linbit.com \
--cc=rajur@chelsio.com \
--cc=rcu@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=siglesias@igalia.com \
--cc=tglx@linutronix.de \
--cc=tytso@mit.edu \
--cc=urezki@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.