lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2AD939572F25A448A3AE3CAEA61328C2378CDFAA@BC-MAIL-M28.internal.baidu.com>
Date:   Wed, 25 Jul 2018 05:49:05 +0000
From:   "Li,Rongqing" <lirongqing@...du.com>
To:     Eric Dumazet <eric.dumazet@...il.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "pablo@...filter.org" <pablo@...filter.org>,
        "kadlec@...ckhole.kfki.hu" <kadlec@...ckhole.kfki.hu>,
        "fw@...len.de" <fw@...len.de>,
        "netfilter-devel@...r.kernel.org" <netfilter-devel@...r.kernel.org>,
        "coreteam@...filter.org" <coreteam@...filter.org>,
        "edumazet@...gle.com" <edumazet@...gle.com>
Subject: 答复: [PATCH][v2] netfilter: use kvzalloc to allocate memory for hashtable



> -----邮件原件-----
> 发件人: Eric Dumazet [mailto:eric.dumazet@...il.com]
> 发送时间: 2018年7月25日 13:45
> 收件人: Li,Rongqing <lirongqing@...du.com>; netdev@...r.kernel.org;
> pablo@...filter.org; kadlec@...ckhole.kfki.hu; fw@...len.de; netfilter-
> devel@...r.kernel.org; coreteam@...filter.org; edumazet@...gle.com
> 主题: Re: [PATCH][v2] netfilter: use kvzalloc to allocate memory for
> hashtable
> 
> 
> 
> On 07/24/2018 10:34 PM, Li RongQing wrote:
> > nf_ct_alloc_hashtable is used to allocate memory for conntrack, NAT
> > bysrc and expectation hashtable. Assuming 64k bucket size, which means
> > 7th order page allocation, __get_free_pages, called by
> > nf_ct_alloc_hashtable, will trigger the direct memory reclaim and
> > stall for a long time, when system has lots of memory stress
> 
> ...
> 
> >  	sz = nr_slots * sizeof(struct hlist_nulls_head);
> > -	hash = (void *)__get_free_pages(GFP_KERNEL | __GFP_NOWARN |
> __GFP_ZERO,
> > -					get_order(sz));
> > -	if (!hash)
> > -		hash = vzalloc(sz);
> > +	hash = kvzalloc(sz, GFP_KERNEL);
> 
> 
> You could remove the @sz computation and call
> 
> hash = kvcalloc(nr_slots, sizeof(struct hlist_nulls_head), GFP_KERNEL);
> 
> Thanks to kvmalloc_array() check, you also could remove the :
> 
> if (nr_slots > (UINT_MAX / sizeof(struct hlist_nulls_head)))
>     return NULL;
> 
> That would remove a lot of stuff now we have proper helpers.


Ok, I will send v3

Thanks

-RongQing

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ