[v2,1/2] event/sw: fix ordering corruption with op release

Message ID 20230914105852.82471-1-harry.van.haaren@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series [v2,1/2] event/sw: fix ordering corruption with op release |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Van Haaren, Harry Sept. 14, 2023, 10:58 a.m. UTC
  This commit changes the logic in the scheduler to always
reset reorder-buffer (and QID/FID) entries when writing
them. This avoids stale ROB/QID/FID data re-use, which
previously caused ordering issues.

Before this commit, release events left the history-list
in an inconsistent state, and future events with op type of
forward could be incorrectly reordered.

Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

v2:
- Rework fix to simpler suggestion (Bruce)
- Respin patchset to "apply order" (Bruce)

---
 drivers/event/sw/sw_evdev_scheduler.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
  

Comments

Bruce Richardson Sept. 14, 2023, 11:12 a.m. UTC | #1
On Thu, Sep 14, 2023 at 11:58:51AM +0100, Harry van Haaren wrote:
> This commit changes the logic in the scheduler to always
> reset reorder-buffer (and QID/FID) entries when writing
> them. This avoids stale ROB/QID/FID data re-use, which
> previously caused ordering issues.
> 
> Before this commit, release events left the history-list
> in an inconsistent state, and future events with op type of
> forward could be incorrectly reordered.
> 
> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> 

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Couple of very minor style comments below.

> ---
> 
> v2:
> - Rework fix to simpler suggestion (Bruce)
> - Respin patchset to "apply order" (Bruce)
> 
> ---
>  drivers/event/sw/sw_evdev_scheduler.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/event/sw/sw_evdev_scheduler.c b/drivers/event/sw/sw_evdev_scheduler.c
> index de6ed21643..21c360770e 100644
> --- a/drivers/event/sw/sw_evdev_scheduler.c
> +++ b/drivers/event/sw/sw_evdev_scheduler.c
> @@ -90,8 +90,10 @@ sw_schedule_atomic_to_cq(struct sw_evdev *sw, struct sw_qid * const qid,
>  		sw->cq_ring_space[cq]--;
>  
>  		int head = (p->hist_head++ & (SW_PORT_HIST_LIST-1));
> -		p->hist_list[head].fid = flow_id;
> -		p->hist_list[head].qid = qid_id;
> +		p->hist_list[head] = (struct sw_hist_list_entry) {
> +			.qid = qid_id,
> +			.fid = flow_id,
> +		};
>  
>  		p->stats.tx_pkts++;
>  		qid->stats.tx_pkts++;
> @@ -162,8 +164,13 @@ sw_schedule_parallel_to_cq(struct sw_evdev *sw, struct sw_qid * const qid,
>  		qid->stats.tx_pkts++;
>  
>  		const int head = (p->hist_head & (SW_PORT_HIST_LIST-1));
> -		p->hist_list[head].fid = SW_HASH_FLOWID(qe->flow_id);
> -		p->hist_list[head].qid = qid_id;
> +		const uint32_t fid = SW_HASH_FLOWID(qe->flow_id);
> +		p->hist_list[head] = (struct sw_hist_list_entry) {
> +			.qid = qid_id,
> +			.fid = fid,
> +		};
> +
> +
You're adding some extra whitespace here. Can probably be fixed on apply.

And one final minor nit: if doing a new version, you can remove the
temporary variable for "fid". In my suggestion I only added it because I
had the assignment done on a single line and didn't want to wrap. Since
you've split the temporary struct across multiple lines, the temporary
variable isn't needed as the SW_HASH_FLOWID will fit on the assignment
line.
  

Patch

diff --git a/drivers/event/sw/sw_evdev_scheduler.c b/drivers/event/sw/sw_evdev_scheduler.c
index de6ed21643..21c360770e 100644
--- a/drivers/event/sw/sw_evdev_scheduler.c
+++ b/drivers/event/sw/sw_evdev_scheduler.c
@@ -90,8 +90,10 @@  sw_schedule_atomic_to_cq(struct sw_evdev *sw, struct sw_qid * const qid,
 		sw->cq_ring_space[cq]--;
 
 		int head = (p->hist_head++ & (SW_PORT_HIST_LIST-1));
-		p->hist_list[head].fid = flow_id;
-		p->hist_list[head].qid = qid_id;
+		p->hist_list[head] = (struct sw_hist_list_entry) {
+			.qid = qid_id,
+			.fid = flow_id,
+		};
 
 		p->stats.tx_pkts++;
 		qid->stats.tx_pkts++;
@@ -162,8 +164,13 @@  sw_schedule_parallel_to_cq(struct sw_evdev *sw, struct sw_qid * const qid,
 		qid->stats.tx_pkts++;
 
 		const int head = (p->hist_head & (SW_PORT_HIST_LIST-1));
-		p->hist_list[head].fid = SW_HASH_FLOWID(qe->flow_id);
-		p->hist_list[head].qid = qid_id;
+		const uint32_t fid = SW_HASH_FLOWID(qe->flow_id);
+		p->hist_list[head] = (struct sw_hist_list_entry) {
+			.qid = qid_id,
+			.fid = fid,
+		};
+
+
 
 		if (keep_order)
 			rob_ring_dequeue(qid->reorder_buffer_freelist,