Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20241029191425.2519085-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
a911bad0 4138e9ec

+2 -2
+1 -1
include/linux/dynamic_queue_limits.h
··· 127 127 if (WARN_ON_ONCE(count > DQL_MAX_OBJECT)) 128 128 return; 129 129 130 - dql->last_obj_cnt = count; 130 + WRITE_ONCE(dql->last_obj_cnt, count); 131 131 132 132 /* We want to force a write first, so that cpu do not attempt 133 133 * to get cache line containing last_obj_cnt, num_queued, adj_limit
+1 -1
lib/dynamic_queue_limits.c
··· 179 179 180 180 dql->adj_limit = limit + completed; 181 181 dql->prev_ovlimit = ovlimit; 182 - dql->prev_last_obj_cnt = dql->last_obj_cnt; 182 + dql->prev_last_obj_cnt = READ_ONCE(dql->last_obj_cnt); 183 183 dql->num_completed = completed; 184 184 dql->prev_num_queued = num_queued; 185 185