From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Felix Maurer <fmaurer@redhat.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
jkarrenpalo@gmail.com, tglx@linutronix.de, mingo@kernel.org,
allison.henderson@oracle.com, petrm@nvidia.com,
antonio@openvpn.net, Steffen Lindner <steffen.lindner@de.abb.com>
Subject: Re: [PATCH net-next v2 4/9] hsr: Implement more robust duplicate discard for PRP
Date: Thu, 29 Jan 2026 14:29:40 +0100 [thread overview]
Message-ID: <20260129132940.XvIWrwoG@linutronix.de> (raw)
In-Reply-To: <fe1dbc483482e98fbc286290a2a3e88f555894d4.1769093335.git.fmaurer@redhat.com>
On 2026-01-22 15:56:59 [+0100], Felix Maurer wrote:
> The PRP duplicate discard algorithm does not work reliably with certain
…
> The idea of the new algorithm is to store the seen sequence numbers in a
> bitmap. To keep the size of the bitmap in control, we store it as a "sparse
> bitmap" where the bitmap is split into blocks and not all blocks exist at
> the same time. The sparse bitmap is implemented using an xarray that keeps
> the references to the individual blocks and a backing ring buffer that
…
My idea was to keep track of say the last 64 sequence numbers but I had
no idea how to efficiently implement it with all the "forget" parts and
so on. What you did here is quite nice.
> @@ -280,6 +301,59 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
…
> +/* Get the currently active sequence number block. If there is no block yet, or
> + * the existing one is expired, a new block is created. The idea is to maintain
> + * a "sparse bitmap" where a bitmap for the whole sequence number space is
> + * split into blocks and not all blocks exist all the time. The blocks can
> + * expire after time (in low traffic situations) or when they are replaced in
> + * the backing fixed size buffer (in high traffic situations).
HSR_MAX_SEQ_BLOCKS,
> + */
> +static struct hsr_seq_block *hsr_get_seq_block(struct hsr_node *node,
> + u16 block_idx)
> +{
> + struct hsr_seq_block *block, *res;
> +
> + block = xa_load(&node->seq_blocks, block_idx);
> +
> + if (block && hsr_seq_block_is_old(block)) {
> + hsr_forget_seq_block(node, block);
> + block = NULL;
> + }
> +
> + if (!block) {
> + block = &node->block_buf[node->next_block];
> + hsr_forget_seq_block(node, block);
> +
> + memset(block, 0, sizeof(*block));
> + block->time = jiffies;
So we assign ->time here while the block is created and it expires after
HSR_ENTRY_FORGET_TIME (400ms). *Maybe* it should be updated in
hsr_check_duplicate() if we set a bit. The difference would be that the
last sequence in the block would get it whole life time while now the
lifetime starts with the first entry in the block. The downside
of course would be that the first entry gets more than the initialy
expected lifetime.
Not sure if this matters in reality, just wanted to mention.
> + block->block_idx = block_idx;
> +
> + res = xa_store(&node->seq_blocks, block_idx, block, GFP_ATOMIC);
> + if (xa_is_err(res))
> + return NULL;
> +
> + node->next_block =
> + (node->next_block + 1) & (HSR_MAX_SEQ_BLOCKS - 1);
> + }
> +
> + return block;
> +}
> +
> /* Use the Supervision frame's info about an eventual macaddress_B for merging
> * nodes that has previously had their macaddress_B registered as a separate
> * node.
> @@ -545,47 +631,26 @@ int prp_register_frame_out(struct hsr_port *port, struct hsr_frame_info *frame)
…
> +
> + seq_bit = hsr_seq_block_bit(sequence_nr);
> + if (test_and_set_bit(seq_bit, block->seq_nrs))
the access happens under ::seq_out_lock so you don't need to be atomic
here. You could safe a cycle and use __test_and_set_bit() instead.
> + goto out_seen;
>
> node->time_out[port->type] = jiffies;
> node->seq_out[port->type] = sequence_nr;
> +out_new:
> spin_unlock_bh(&node->seq_out_lock);
> return 0;
> +
> +out_seen:
> + spin_unlock_bh(&node->seq_out_lock);
> + return 1;
> }
>
> #if IS_MODULE(CONFIG_PRP_DUP_DISCARD_KUNIT_TEST)
Sebastian
next prev parent reply other threads:[~2026-01-29 13:29 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 14:56 [PATCH net-next v2 0/9] hsr: Implement more robust duplicate discard algorithm Felix Maurer
2026-01-22 14:56 ` [PATCH net-next v2 1/9] selftests: hsr: Add ping test for PRP Felix Maurer
2026-01-29 11:05 ` Sebastian Andrzej Siewior
2026-01-29 13:31 ` Felix Maurer
2026-01-29 15:21 ` Sebastian Andrzej Siewior
2026-01-29 17:44 ` Felix Maurer
2026-02-02 11:51 ` Felix Maurer
2026-02-02 15:55 ` Sebastian Andrzej Siewior
2026-02-03 10:12 ` Felix Maurer
2026-02-03 11:55 ` Sebastian Andrzej Siewior
2026-02-03 12:23 ` Felix Maurer
2026-02-03 13:47 ` Sebastian Andrzej Siewior
2026-02-03 15:07 ` Felix Maurer
2026-01-22 14:56 ` [PATCH net-next v2 2/9] selftests: hsr: Check duplicates on HSR with VLAN Felix Maurer
2026-01-22 14:56 ` [PATCH net-next v2 3/9] selftests: hsr: Add tests for faulty links Felix Maurer
2026-01-22 14:56 ` [PATCH net-next v2 4/9] hsr: Implement more robust duplicate discard for PRP Felix Maurer
2026-01-28 16:38 ` Simon Horman
2026-01-28 18:37 ` Felix Maurer
2026-02-02 16:57 ` Sebastian Andrzej Siewior
2026-02-03 10:23 ` Felix Maurer
2026-02-03 11:57 ` Sebastian Andrzej Siewior
2026-02-03 12:42 ` Felix Maurer
2026-02-03 13:49 ` Sebastian Andrzej Siewior
2026-02-03 15:11 ` Felix Maurer
2026-01-29 13:29 ` Sebastian Andrzej Siewior [this message]
2026-01-29 15:30 ` Felix Maurer
2026-02-02 8:47 ` Steffen Lindner
2026-01-22 14:57 ` [PATCH net-next v2 5/9] selftests: hsr: Add tests for more link faults with PRP Felix Maurer
2026-01-29 13:32 ` Sebastian Andrzej Siewior
2026-02-02 11:30 ` Felix Maurer
2026-02-02 16:45 ` Sebastian Andrzej Siewior
2026-02-03 12:09 ` Felix Maurer
2026-02-03 14:49 ` Sebastian Andrzej Siewior
2026-02-03 15:32 ` Felix Maurer
2026-01-22 14:57 ` [PATCH net-next v2 6/9] hsr: Implement more robust duplicate discard for HSR Felix Maurer
2026-01-29 14:43 ` Sebastian Andrzej Siewior
2026-01-29 16:17 ` Felix Maurer
2026-01-29 18:01 ` Felix Maurer
2026-01-30 10:34 ` Felix Maurer
2026-02-02 17:53 ` Sebastian Andrzej Siewior
2026-02-03 11:49 ` Felix Maurer
2026-02-03 12:08 ` Sebastian Andrzej Siewior
2026-02-02 17:11 ` Sebastian Andrzej Siewior
2026-02-03 11:08 ` Felix Maurer
2026-02-03 12:09 ` Sebastian Andrzej Siewior
2026-01-22 14:57 ` [PATCH net-next v2 7/9] selftests: hsr: Add more link fault tests " Felix Maurer
2026-01-22 14:57 ` [PATCH net-next v2 8/9] hsr: Update PRP duplicate discard KUnit test for new algorithm Felix Maurer
2026-01-29 15:12 ` Sebastian Andrzej Siewior
2026-01-29 16:19 ` Felix Maurer
2026-01-22 14:57 ` [PATCH net-next v2 9/9] MAINTAINERS: Assign hsr selftests to HSR Felix Maurer
2026-01-22 17:24 ` [PATCH net-next v2 0/9] hsr: Implement more robust duplicate discard algorithm Sebastian Andrzej Siewior
2026-01-23 1:35 ` Jakub Kicinski
2026-01-26 9:28 ` Felix Maurer
2026-01-29 15:29 ` Sebastian Andrzej Siewior
2026-01-29 16:29 ` Felix Maurer
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=20260129132940.XvIWrwoG@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=allison.henderson@oracle.com \
--cc=antonio@openvpn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fmaurer@redhat.com \
--cc=horms@kernel.org \
--cc=jkarrenpalo@gmail.com \
--cc=kuba@kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=steffen.lindner@de.abb.com \
--cc=tglx@linutronix.de \
/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