aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/flow.c
diff options
context:
space:
mode:
authorMiroslav Urbanek <mu@miroslavurbanek.com>2016-11-21 09:48:21 -0500
committerSteffen Klassert <steffen.klassert@secunet.com>2016-11-23 00:37:09 -0500
commit6b226487815574193c1da864f2eac274781a2b0c (patch)
treeab9132564a33ee87fb6fc5f810b70531e9445ab5 /net/core/flow.c
parent330e832abda923df06a4ca6d3faac6e9c1b42548 (diff)
flowcache: Increase threshold for refusing new allocations
The threshold for OOM protection is too small for systems with large number of CPUs. Applications report ENOBUFs on connect() every 10 minutes. The problem is that the variable net->xfrm.flow_cache_gc_count is a global counter while the variable fc->high_watermark is a per-CPU constant. Take the number of CPUs into account as well. Fixes: 6ad3122a08e3 ("flowcache: Avoid OOM condition under preasure") Reported-by: Lukáš Koldrt <lk@excello.cz> Tested-by: Jan Hejl <jh@excello.cz> Signed-off-by: Miroslav Urbanek <mu@miroslavurbanek.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/core/flow.c')
-rw-r--r--net/core/flow.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/core/flow.c b/net/core/flow.c
index 3937b1b68d5b..18e8893d4be5 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -95,7 +95,6 @@ static void flow_cache_gc_task(struct work_struct *work)
95 list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) { 95 list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) {
96 flow_entry_kill(fce, xfrm); 96 flow_entry_kill(fce, xfrm);
97 atomic_dec(&xfrm->flow_cache_gc_count); 97 atomic_dec(&xfrm->flow_cache_gc_count);
98 WARN_ON(atomic_read(&xfrm->flow_cache_gc_count) < 0);
99 } 98 }
100} 99}
101 100
@@ -236,9 +235,8 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
236 if (fcp->hash_count > fc->high_watermark) 235 if (fcp->hash_count > fc->high_watermark)
237 flow_cache_shrink(fc, fcp); 236 flow_cache_shrink(fc, fcp);
238 237
239 if (fcp->hash_count > 2 * fc->high_watermark || 238 if (atomic_read(&net->xfrm.flow_cache_gc_count) >
240 atomic_read(&net->xfrm.flow_cache_gc_count) > fc->high_watermark) { 239 2 * num_online_cpus() * fc->high_watermark) {
241 atomic_inc(&net->xfrm.flow_cache_genid);
242 flo = ERR_PTR(-ENOBUFS); 240 flo = ERR_PTR(-ENOBUFS);
243 goto ret_object; 241 goto ret_object;
244 } 242 }