Skip to contentSkip to conversation

flowcache: Tune per cpu flow cache shrink size

PATCH In review Fan Du 3 participants 3 messages Mar 14, 2014

Subsystems (2)
lore
Share & tools
lore

Fan Du

author
#0 lore raw

PATCH 1/1 flowcache: Tune per cpu flow cache shrink size

When per cpu flow cache entries count reaches over high_watermark, flow cache will be shrinked gently to around low_watermark, not brutally killing most of cached entries by left only two.

---
 net/core/flow.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/flow.c +1 -1
index 31cfb365e0c6..e379cdcd699b 100644
@@ -142,7 +142,7 @@ static void __flow_cache_shrink(struct flow_cache *fc,
 static void flow_cache_shrink(struct flow_cache *fc,
 			      struct flow_cache_percpu *fcp)
 {
-	int shrink_to = fc->low_watermark / flow_cache_hash_size(fc);
+	int shrink_to = fc->low_watermark;
 
 	__flow_cache_shrink(fc, fcp, shrink_to);
 }
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 4 lines · Fan Du

When per cpu flow cache entries count reaches over high_watermark, flow cache will be shrinked gently to around low_watermark, not brutally killing most of cached entries by left only two.

We currently keep two entries per hash bucket, this means that we keep low_watermark entries at most in the flow cache.

With your change, we would keep low_watermark entries per hash bucket. The flow cache would grow to low_watermark * flow_cache_hash_size then. This would make DoS attacks against the flow cache quite easy.

maintainer
#2 lore raw
In reply to Fan Du

From: Fan Du <[email protected]>
Date: Fri, 14 Mar 2014 15:42:46 +0800

Quoted 5 lines

When per cpu flow cache entries count reaches over high_watermark, flow cache will be shrinked gently to around low_watermark, not brutally killing most of cached entries by left only two.

We are limiting hash chain lengths, not total hash table size.

Your change is therefore not appropriate.