Skip to content

Commit

Permalink
bql: Avoid possible inconsistent calculation.
Browse files Browse the repository at this point in the history
dql->num_queued could change while processing dql_completed().
To provide consistent calculation, added an on stack variable.

Signed-off-by: Hiroaki SHIMODA <[email protected]>
Cc: Tom Herbert <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Denys Fedoryshchenko <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
hiroa-ki authored and davem330 committed May 31, 2012
1 parent 25426b7 commit 914bec1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/dynamic_queue_limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
void dql_completed(struct dql *dql, unsigned int count)
{
unsigned int inprogress, prev_inprogress, limit;
unsigned int ovlimit, completed;
unsigned int ovlimit, completed, num_queued;
bool all_prev_completed;

num_queued = ACCESS_ONCE(dql->num_queued);

/* Can't complete more than what's in queue */
BUG_ON(count > dql->num_queued - dql->num_completed);
BUG_ON(count > num_queued - dql->num_completed);

completed = dql->num_completed + count;
limit = dql->limit;
ovlimit = POSDIFF(dql->num_queued - dql->num_completed, limit);
inprogress = dql->num_queued - completed;
ovlimit = POSDIFF(num_queued - dql->num_completed, limit);
inprogress = num_queued - completed;
prev_inprogress = dql->prev_num_queued - dql->num_completed;
all_prev_completed = AFTER_EQ(completed, dql->prev_num_queued);

Expand Down Expand Up @@ -106,7 +108,7 @@ void dql_completed(struct dql *dql, unsigned int count)
dql->prev_ovlimit = ovlimit;
dql->prev_last_obj_cnt = dql->last_obj_cnt;
dql->num_completed = completed;
dql->prev_num_queued = dql->num_queued;
dql->prev_num_queued = num_queued;
}
EXPORT_SYMBOL(dql_completed);

Expand Down

0 comments on commit 914bec1

Please sign in to comment.