[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200323113621.12048-1-urezki@gmail.com>
Date: Mon, 23 Mar 2020 12:36:14 +0100
From: "Uladzislau Rezki (Sony)" <urezki@...il.com>
To: LKML <linux-kernel@...r.kernel.org>,
"Paul E . McKenney" <paulmck@...nel.org>,
Joel Fernandes <joel@...lfernandes.org>
Cc: RCU <rcu@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Uladzislau Rezki <urezki@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Oleksiy Avramchenko <oleksiy.avramchenko@...ymobile.com>
Subject: [PATCH 0/7] Headless support in the kvfree_rcu()
Motivation.
We had some discussions about having possibility to kvfree() an
object that does not contain any rcu_head inside its allocated
memory. Basically to have a simple interface like:
<snip>
void *ptr = kvmalloc(some_bytes, GFP_KERNEL);
if (ptr)
kvfree_rcu(ptr);
<snip>
For example, please have a look at recent ext4 topic
https://lkml.org/lkml/2020/2/19/1372
due to lack of the interface that is in question, the
ext4 specific workaround has been introduced to kvfree()
after a grace period:
<snip>
void ext4_kvfree_array_rcu(void *to_free)
{
struct ext4_rcu_ptr *ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
if (ptr) {
ptr->ptr = to_free;
call_rcu(&ptr->rcu, ext4_rcu_ptr_callback);
return;
}
synchronize_rcu();
kvfree(ptr);
}
<snip>
Also, as Joel Fernandes mentioned and proposed we also
can have kfree_rcu() headless variant. Actually with this
series it is capable of doing that, but there is missing
one thing. The kfree_rcu() macro is eligible to be called
with two arguments only. So it should be updated similar
way as it has been done for kvfree_rcu().
In that case we can update many places in the kernel where
people do not embed the rcu_head into their stuctures for
some reason and do like:
<snip>
synchronize_rcu();
kfree(p);
<snip>
<snip>
urezki@...36:~/data/ssd/coding/linux-rcu$ find ./ -name "*.c" | xargs grep -C 1 -rn "synchronize_rcu" | grep kfree
./arch/x86/mm/mmio-mod.c-314- kfree(found_trace);
./kernel/module.c-3910- kfree(mod->args);
./kernel/trace/ftrace.c-5078- kfree(direct);
./kernel/trace/ftrace.c-5155- kfree(direct);
./kernel/trace/trace_probe.c-1087- kfree(link);
./fs/nfs/sysfs.c-113- kfree(old);
./fs/ext4/super.c-1701- kfree(old_qname);
./net/ipv4/gre.mod.c-36- { 0xfc3fcca2, "kfree_skb" },
./net/core/sysctl_net_core.c-143- kfree(cur);
./drivers/crypto/nx/nx-842-pseries.c-1010- kfree(old_devdata);
./drivers/misc/vmw_vmci/vmci_context.c-692- kfree(notifier);
./drivers/misc/vmw_vmci/vmci_event.c-213- kfree(s);
./drivers/infiniband/core/device.c:2162: * synchronize_rcu before the netdev is kfreed, so we
./drivers/infiniband/hw/hfi1/sdma.c-1337- kfree(dd->per_sdma);
./drivers/net/ethernet/myricom/myri10ge/myri10ge.c-3582- kfree(mgp->ss);
./drivers/net/ethernet/myricom/myri10ge/myri10ge.mod.c-156- { 0x37a0cba, "kfree" },
./drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c:286: synchronize_rcu(); /* before kfree(flow) */
./drivers/net/ethernet/mellanox/mlxsw/core.c-1504- kfree(rxl_item);
./drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c-6648- kfree(adapter->mbox_log);
./drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c-6650- kfree(adapter);
./drivers/block/drbd/drbd_receiver.c-3804- kfree(old_net_conf);
./drivers/block/drbd/drbd_receiver.c-4176- kfree(old_disk_conf);
./drivers/block/drbd/drbd_state.c-2074- kfree(old_conf);
./drivers/block/drbd/drbd_nl.c-1689- kfree(old_disk_conf);
./drivers/block/drbd/drbd_nl.c-2522- kfree(old_net_conf);
./drivers/block/drbd/drbd_nl.c-2935- kfree(old_disk_conf);
./drivers/mfd/dln2.c-178- kfree(i);
./drivers/staging/fwserial/fwserial.c-2122- kfree(peer);
<snip>
Uladzislau Rezki (Sony) (7):
rcu/tree: simplify KFREE_BULK_MAX_ENTR macro
rcu/tree: maintain separate array for vmalloc ptrs
rcu/tree: introduce expedited_drain flag
rcu/tree: support reclaim for head-less object
rcu/tiny: move kvfree_call_rcu() out of header
rcu/tiny: support reclaim for head-less object
rcu: support headless variant in the kvfree_rcu()
include/linux/rcupdate.h | 38 ++++-
include/linux/rcutiny.h | 6 +-
kernel/rcu/tiny.c | 161 +++++++++++++++++++++
kernel/rcu/tree.c | 294 ++++++++++++++++++++++++++++-----------
4 files changed, 407 insertions(+), 92 deletions(-)
--
2.20.1
Powered by blists - more mailing lists