From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li RongQing Subject: [PATCH] netfilter: avoid stalls in nf_ct_alloc_hashtable Date: Tue, 24 Jul 2018 15:19:05 +0800 Message-ID: <1532416745-9926-1-git-send-email-lirongqing@baidu.com> To: netdev@vger.kernel.org, pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de Return-path: Received: from mx56.baidu.com ([61.135.168.56]:28150 "EHLO tc-sys-mailedm02.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388366AbeGXIkm (ORCPT ); Tue, 24 Jul 2018 04:40:42 -0400 Sender: netdev-owner@vger.kernel.org List-ID: when system forks a process with CLONE_NEWNET flag under the high memory pressure, it will trigger memory reclaim and stall for a long time because nf_ct_alloc_hashtable need to allocate high-order memory at that time. The calltrace as below: delay_tsc __delay _raw_spin_lock _spin_lock mmu_shrink shrink_slab zone_reclaim get_page_from_freelist __alloc_pages_nodemask alloc_pages_current __get_free_pages nf_ct_alloc_hashtable nf_conntrack_init_net setup_net copy_net_ns create_new_namespaces copy_namespaces copy_process do_fork sys_clone stub_clone __clone not use the directly memory reclaim flag to avoid stall Signed-off-by: Ni Xun Signed-off-by: Zhang Yu Signed-off-by: Wang Li Signed-off-by: Li RongQing --- net/netfilter/nf_conntrack_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 8a113ca1eea2..672c5960530d 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -2120,8 +2120,8 @@ void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls) return NULL; sz = nr_slots * sizeof(struct hlist_nulls_head); - hash = (void *)__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, - get_order(sz)); + hash = (void *)__get_free_pages((GFP_KERNEL & ~__GFP_DIRECT_RECLAIM) | + __GFP_NOWARN | __GFP_ZERO, get_order(sz)); if (!hash) hash = vzalloc(sz); -- 2.16.2