All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: tgraf <tgraf@suug.ch>
Cc: netdev <netdev@vger.kernel.org>
Subject: nft_hash rhashtable question
Date: Mon, 12 Jan 2015 14:30:40 -0800	[thread overview]
Message-ID: <54B44B10.7000009@gmail.com> (raw)

Hi Thomas,

I'm looking at the rhashtable usage.

But as I read the nft_hash_destroy() its not clear to me how
rht_for_each_entry_safe() and  nft_hash_elem_destroy() keep everything
in sync.

Here is the code in question,

> static void nft_hash_destroy(const struct nft_set *set)
> {
>         struct rhashtable *priv = nft_set_priv(set);
>         const struct bucket_table *tbl;
>         struct nft_hash_elem *he;
>         struct rhash_head *pos, *next;
>         unsigned int i;
>
>         /* Stop an eventual async resizing */
>         priv->being_destroyed = true;
>         mutex_lock(&priv->mutex); <-- get the lock so we have single updater
>
>         tbl = rht_dereference(priv->tbl, priv);
>         for (i = 0; i < tbl->size; i++) {
>                 rht_for_each_entry_safe(he, pos, next, tbl, i, node)
>                         nft_hash_elem_destroy(set, he);              <-- does a kfree on he?
>         }
>         mutex_unlock(&priv->mutex); <-- release the lock
>
>         rhashtable_destroy(priv);
> }


Is it really safe to kfree 'he' without waiting a grace
period for any rcu readers to drop the reference?

I'm considering what happens if nft_hash_destroy runs in
parallel with nft_hash_lookup?

Thanks,
John


-- 
John Fastabend         Intel Corporation

             reply	other threads:[~2015-01-12 22:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12 22:30 John Fastabend [this message]
2015-01-12 22:42 ` nft_hash rhashtable question tgraf
2015-01-12 22:53   ` John Fastabend

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=54B44B10.7000009@gmail.com \
    --to=john.fastabend@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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.