netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH net-next 3/6] xfrm: state: delay freeing until rcu grace period has elapsed
Date: Tue,  9 Aug 2016 12:16:06 +0200	[thread overview]
Message-ID: <1470737769-30438-4-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1470737769-30438-1-git-send-email-fw@strlen.de>

The hash table backend memory and the state structs are free'd via
kfree/vfree.

Once we only rely on rcu during lookups we have to make sure no other cpu
is currently accessing this before doing the free.

Free operations already happen from worker so we can use synchronize_rcu
to wait until concurrent readers are done.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/xfrm/xfrm_state.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 84c1db6..8e37387 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -146,6 +146,9 @@ static void xfrm_hash_resize(struct work_struct *work)
 	spin_unlock_bh(&net->xfrm.xfrm_state_lock);
 
 	osize = (ohashmask + 1) * sizeof(struct hlist_head);
+
+	synchronize_rcu();
+
 	xfrm_hash_free(odst, osize);
 	xfrm_hash_free(osrc, osize);
 	xfrm_hash_free(ospi, osize);
@@ -369,6 +372,8 @@ static void xfrm_state_gc_task(struct work_struct *work)
 	hlist_move_list(&net->xfrm.state_gc_list, &gc_list);
 	spin_unlock_bh(&xfrm_state_gc_lock);
 
+	synchronize_rcu();
+
 	hlist_for_each_entry_safe(x, tmp, &gc_list, gclist)
 		xfrm_state_gc_destroy(x);
 }
-- 
2.7.3

  parent reply	other threads:[~2016-08-09 10:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09 10:16 [PATCH net-next 0/6] xfrm: convert xfrm_state_find to rcu Florian Westphal
2016-08-09 10:16 ` [PATCH net-next 1/6] xfrm: state: use hlist_for_each_entry_rcu helper Florian Westphal
2016-08-09 10:16 ` [PATCH net-next 2/6] xfrm: state: use atomic_inc_not_zero to increment refcount Florian Westphal
2016-08-09 10:16 ` Florian Westphal [this message]
2016-08-09 10:16 ` [PATCH net-next 4/6] xfrm: state: add sequence count to detect hash resizes Florian Westphal
2016-08-09 10:16 ` [PATCH net-next 5/6] xfrm: state: use rcu_deref and assign_pointer helpers Florian Westphal
2016-08-09 10:16 ` [PATCH net-next 6/6] xfrm: state: don't use lock anymore unless acquire operation is needed Florian Westphal
2016-08-11 11:13 ` [PATCH net-next 0/6] xfrm: convert xfrm_state_find to rcu Steffen Klassert

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=1470737769-30438-4-git-send-email-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).