dql: annotate data-races around dql->last_obj_cnt
Subsystems (3)
PATCH 1/1 dql: annotate data-races around dql->last_obj_cnt
dql->last_obj_cnt is read/written from different contexts, without any lock synchronization.
Use READ_ONCE()/WRITE_ONCE() to avoid load/store tearing.
--- include/linux/dynamic_queue_limits.h | 2 +- lib/dynamic_queue_limits.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/dynamic_queue_limits.h +1 -1
@@ -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
lib/dynamic_queue_limits.c +1 -1
@@ -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;
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
Quoted 29 lines · Eric Dumazet
dql->last_obj_cntis 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]>--- include/linux/dynamic_queue_limits.h | 2 +- lib/dynamic_queue_limits.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)include/linux/dynamic_queue_limits.h +1
-1@@ -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 lib/dynamic_queue_limits.c +0
-0
lib/dynamic_queue_limits.c void dql_completed(struct dql *dql, unsigned int count) · line 185
Quoted 8 lines
lib/dynamic_queue_limits.c +1
-1@@ -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;
This looks fine to me. I noted that dql_reset writes last_obj_cnt, but AFAIU that write is not a problem (from the 1 driver I looked at).
Quoted 32 lines · Joe Damato
Quoted 30 lines · Eric Dumazet
dql->last_obj_cntis 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]>--- include/linux/dynamic_queue_limits.h | 2 +- lib/dynamic_queue_limits.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)include/linux/dynamic_queue_limits.h +1
-1@@ -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 lib/dynamic_queue_limits.c +0
-0@@ -179,7 +179,7 @@ void dql_completed(struct dql *dql, unsigned int count)
Quoted 11 lines
lib/dynamic_queue_limits.c void dql_completed(struct dql *dql, unsigned int count) · line 185
Quoted 7 lines
lib/dynamic_queue_limits.c +1
-1dql->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;This looks fine to me. I noted that
dql_resetwriteslast_obj_cnt, but AFAIU that write is not a problem (from the 1 driver I looked at).
Yeah, I think that dql_reset() should not exist in the first place.
When all skbs are properly tx completed, BQL state should be known and clean.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 29 Oct 2024 19:14:25 +0000 you wrote:
dql->last_obj_cntis 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]>[...]
Here is the summary with links:
- [net-next] dql: annotate data-races around dql->last_obj_cnt
https://git.kernel.org/netdev/net-next/c/a911bad094b0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html