From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: Robin Jarry <rjarry@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH dpdk v3 0/2] hash: safe data replacement on overwrite
Date: Mon, 9 Mar 2026 07:50:15 +0000 [thread overview]
Message-ID: <540b570f12bb458997f4b8a1a4322dff@huawei.com> (raw)
In-Reply-To: <20260306084710.492520-4-rjarry@redhat.com>
> When rte_hash_add_key_data() is called with an existing key, the old
> data pointer is silently overwritten. With RCU-protected readers still
> potentially accessing the old data, the application cannot safely free
> it since the old pointer is never returned.
>
> This series fixes the issue in two places:
>
> * When RCU is configured with a free_key_data_func callback,
> rte_hash_add_key_data() now automatically defers freeing the old data
> on overwrite. No caller changes are needed.
>
> * If rte_hash_del_key() fails to enqueue the deleted entry in
> RTE_HASH_QSBR_MODE_DQ, it falls back on RTE_HASH_QSBR_MODE_SYNC to
> avoid leaking slots and data pointers.
>
> v3:
>
> * Use rte_atomic_exchange_explicit() to swap the new data pointer with
> the old one in search_and_update().
>
> * Removed the rte_hash_replace_key_data() API
That's a pity - I think it is a useful one.
> which required to bubble
> a potential old_data pointer from search_and_update() to all
> intermediate callers down to __rte_hash_add_key_with_hash(). It made
> an already complex code even more obscure.
>
> v2:
>
> * New patch to fallback to SYNC mode when DQ fails on delete.
> * Check key_idx == EMPTY_SLOT in DQ mode to differentiate when old_data
> is NULL.
> * Also fallback to SYNC mode when DQ fails on replace.
>
> Robin Jarry (2):
> hash: avoid leaking entries on RCU defer queue failure
> hash: free replaced data on overwrite when RCU is configured
>
> app/test/test_hash.c | 134 +++++++++++++++++++++++++
> doc/guides/rel_notes/release_26_03.rst | 7 ++
> lib/hash/rte_cuckoo_hash.c | 47 +++++++--
> lib/hash/rte_hash.h | 8 +-
> 4 files changed, 187 insertions(+), 9 deletions(-)
>
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-03-09 7:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 21:33 [PATCH dpdk 0/2] hash: safe data replacement on overwrite Robin Jarry
2026-02-12 21:33 ` [PATCH dpdk 1/2] hash: free replaced data on overwrite when RCU is configured Robin Jarry
2026-02-12 21:33 ` [PATCH dpdk 2/2] hash: add replace API returning old data on overwrite Robin Jarry
2026-02-12 22:55 ` [PATCH dpdk 0/2] hash: safe data replacement " Stephen Hemminger
2026-02-13 10:34 ` [PATCH dpdk v2 0/3] " Robin Jarry
2026-02-13 10:34 ` [PATCH dpdk v2 1/3] hash: avoid leaking entries on RCU defer queue failure Robin Jarry
2026-03-04 10:28 ` Konstantin Ananyev
2026-02-13 10:34 ` [PATCH dpdk v2 2/3] hash: free replaced data on overwrite when RCU is configured Robin Jarry
2026-03-04 11:40 ` Konstantin Ananyev
2026-03-04 11:45 ` Robin Jarry
2026-03-04 12:50 ` Robin Jarry
2026-02-13 10:34 ` [PATCH dpdk v2 3/3] hash: add replace API returning old data on overwrite Robin Jarry
2026-03-04 11:44 ` Konstantin Ananyev
2026-03-06 8:47 ` [PATCH dpdk v3 0/2] hash: safe data replacement " Robin Jarry
2026-03-06 8:47 ` [PATCH dpdk v3 1/2] hash: avoid leaking entries on RCU defer queue failure Robin Jarry
2026-03-06 8:47 ` [PATCH dpdk v3 2/2] hash: free replaced data on overwrite when RCU is configured Robin Jarry
2026-03-09 7:48 ` Konstantin Ananyev
2026-03-09 7:50 ` Konstantin Ananyev [this message]
2026-03-09 7:52 ` [PATCH dpdk v3 0/2] hash: safe data replacement on overwrite Robin Jarry
2026-03-09 8:32 ` Konstantin Ananyev
2026-03-17 9:40 ` Thomas Monjalon
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=540b570f12bb458997f4b8a1a4322dff@huawei.com \
--to=konstantin.ananyev@huawei.com \
--cc=dev@dpdk.org \
--cc=rjarry@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox