Skip to content

Commit

Permalink
fq_impl: Properly enforce memory limit
Browse files Browse the repository at this point in the history
The fq structure would fail to properly enforce the memory limit in the case
where the packet being enqueued was bigger than the packet being removed to
bring the memory usage down. So keep dropping packets until the memory usage is
back below the limit. Also, fix the statistics for memory limit violations.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Toke Høiland-Jørgensen authored and Johannes Berg committed Oct 18, 2017
1 parent e5f5ce3 commit 0bfe649
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions include/net/fq_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static void fq_tin_enqueue(struct fq *fq,
fq_flow_get_default_t get_default_func)
{
struct fq_flow *flow;
bool oom;

lockdep_assert_held(&fq->lock);

Expand All @@ -167,8 +168,8 @@ static void fq_tin_enqueue(struct fq *fq,
}

__skb_queue_tail(&flow->queue, skb);

if (fq->backlog > fq->limit || fq->memory_usage > fq->memory_limit) {
oom = (fq->memory_usage > fq->memory_limit);
while (fq->backlog > fq->limit || oom) {
flow = list_first_entry_or_null(&fq->backlogs,
struct fq_flow,
backlogchain);
Expand All @@ -183,8 +184,10 @@ static void fq_tin_enqueue(struct fq *fq,

flow->tin->overlimit++;
fq->overlimit++;
if (fq->memory_usage > fq->memory_limit)
if (oom) {
fq->overmemory++;
oom = (fq->memory_usage > fq->memory_limit);
}
}
}

Expand Down

0 comments on commit 0bfe649

Please sign in to comment.