diff options
| author | Dave Airlie <airlied@redhat.com> | 2024-12-19 11:59:43 +1000 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2024-12-19 12:00:02 +1000 |
| commit | 38e961097e04e7adfe1d3335e3371e97c1723064 (patch) | |
| tree | 40ffe2d6d45d668ed42fa28c270760f8967fcfba /net/core/net_namespace.c | |
| parent | 301e2772295e8de0cf8acdd9ddb1824b546375a5 (diff) | |
| parent | 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8 (diff) | |
Merge tag 'v6.13-rc3' into drm-next
Backmerge linux 6.13-rc3 as amd next has some dependencies on fixes in it.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'net/core/net_namespace.c')
| -rw-r--r-- | net/core/net_namespace.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index ae34ac818cda..b5cd3ae4f04c 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -449,6 +449,21 @@ out_free: goto out; } +static LLIST_HEAD(defer_free_list); + +static void net_complete_free(void) +{ + struct llist_node *kill_list; + struct net *net, *next; + + /* Get the list of namespaces to free from last round. */ + kill_list = llist_del_all(&defer_free_list); + + llist_for_each_entry_safe(net, next, kill_list, defer_free_list) + kmem_cache_free(net_cachep, net); + +} + static void net_free(struct net *net) { if (refcount_dec_and_test(&net->passive)) { @@ -457,7 +472,8 @@ static void net_free(struct net *net) /* There should not be any trackers left there. */ ref_tracker_dir_exit(&net->notrefcnt_tracker); - kmem_cache_free(net_cachep, net); + /* Wait for an extra rcu_barrier() before final free. */ + llist_add(&net->defer_free_list, &defer_free_list); } } @@ -642,6 +658,8 @@ static void cleanup_net(struct work_struct *work) */ rcu_barrier(); + net_complete_free(); + /* Finally it is safe to free my network namespace structure */ list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) { list_del_init(&net->exit_list); |
