Skip to content

Commit

Permalink
dql: annotate data-races around dql->last_obj_cnt
Browse files Browse the repository at this point in the history
dql->last_obj_cnt is read/written from different contexts,
without any lock synchronization.

Use READ_ONCE()/WRITE_ONCE() to avoid load/store tearing.

Signed-off-by: Eric Dumazet <[email protected]>
Reviewed-by: Joe Damato <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Eric Dumazet authored and kuba-moo committed Nov 1, 2024
1 parent 4138e9e commit a911bad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/linux/dynamic_queue_limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static inline void dql_queued(struct dql *dql, unsigned int count)
if (WARN_ON_ONCE(count > DQL_MAX_OBJECT))
return;

dql->last_obj_cnt = count;
WRITE_ONCE(dql->last_obj_cnt, count);

/* We want to force a write first, so that cpu do not attempt
* to get cache line containing last_obj_cnt, num_queued, adj_limit
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamic_queue_limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void dql_completed(struct dql *dql, unsigned int count)

dql->adj_limit = limit + completed;
dql->prev_ovlimit = ovlimit;
dql->prev_last_obj_cnt = dql->last_obj_cnt;
dql->prev_last_obj_cnt = READ_ONCE(dql->last_obj_cnt);
dql->num_completed = completed;
dql->prev_num_queued = num_queued;

Expand Down

0 comments on commit a911bad

Please sign in to comment.