aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHiroaki SHIMODA <shimoda.hiroaki@gmail.com>2012-05-30 08:25:37 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-31 18:18:17 -0400
commit914bec1011a25f65cdc94988a6f974bfb9a3c10d (patch)
tree2651e473b6f02888b595f215fbfb9710e6e231ff /lib
parent25426b794efdc70dde7fd3134dc56fac3e7d562d (diff)
bql: Avoid possible inconsistent calculation.
dql->num_queued could change while processing dql_completed(). To provide consistent calculation, added an on stack variable. Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com> Cc: Tom Herbert <therbert@google.com> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Denys Fedoryshchenko <denys@visp.net.lb> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/dynamic_queue_limits.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/dynamic_queue_limits.c b/lib/dynamic_queue_limits.c
index 0fafa77f4036..0777c5a45fa0 100644
--- a/lib/dynamic_queue_limits.c
+++ b/lib/dynamic_queue_limits.c
@@ -17,16 +17,18 @@
17void dql_completed(struct dql *dql, unsigned int count) 17void dql_completed(struct dql *dql, unsigned int count)
18{ 18{
19 unsigned int inprogress, prev_inprogress, limit; 19 unsigned int inprogress, prev_inprogress, limit;
20 unsigned int ovlimit, completed; 20 unsigned int ovlimit, completed, num_queued;
21 bool all_prev_completed; 21 bool all_prev_completed;
22 22
23 num_queued = ACCESS_ONCE(dql->num_queued);
24
23 /* Can't complete more than what's in queue */ 25 /* Can't complete more than what's in queue */
24 BUG_ON(count > dql->num_queued - dql->num_completed); 26 BUG_ON(count > num_queued - dql->num_completed);
25 27
26 completed = dql->num_completed + count; 28 completed = dql->num_completed + count;
27 limit = dql->limit; 29 limit = dql->limit;
28 ovlimit = POSDIFF(dql->num_queued - dql->num_completed, limit); 30 ovlimit = POSDIFF(num_queued - dql->num_completed, limit);
29 inprogress = dql->num_queued - completed; 31 inprogress = num_queued - completed;
30 prev_inprogress = dql->prev_num_queued - dql->num_completed; 32 prev_inprogress = dql->prev_num_queued - dql->num_completed;
31 all_prev_completed = AFTER_EQ(completed, dql->prev_num_queued); 33 all_prev_completed = AFTER_EQ(completed, dql->prev_num_queued);
32 34
@@ -106,7 +108,7 @@ void dql_completed(struct dql *dql, unsigned int count)
106 dql->prev_ovlimit = ovlimit; 108 dql->prev_ovlimit = ovlimit;
107 dql->prev_last_obj_cnt = dql->last_obj_cnt; 109 dql->prev_last_obj_cnt = dql->last_obj_cnt;
108 dql->num_completed = completed; 110 dql->num_completed = completed;
109 dql->prev_num_queued = dql->num_queued; 111 dql->prev_num_queued = num_queued;
110} 112}
111EXPORT_SYMBOL(dql_completed); 113EXPORT_SYMBOL(dql_completed);
112 114