[Devel,RHEL7,COMMIT] ipv6/sit: account and don't WARN on ip_tunnel_prl structs allocation

Submitted by Konstantin Khorenko on Jan. 17, 2017, 12:28 p.m.

Details

Message ID 201701171228.v0HCScYl022439@finist_cl7.x64_64.work.ct
State New
Series "ipv6/sit: account and don't WARN on ip_tunnel_prl structs allocation"
Headers show

Commit Message

Konstantin Khorenko Jan. 17, 2017, 12:28 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.vz7.27.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.vz7.27.13
------>
commit 3fa219c5653954e48c68c9510c3c629af9c7a83a
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Tue Jan 17 16:28:38 2017 +0400

    ipv6/sit: account and don't WARN on ip_tunnel_prl structs allocation
    
    The size of the ip_tunnel_prl structs allocation is controllable from user-space,
    thus it's better to avoid spam in dmesg if allocation failed.
    Also add __GFP_ACCOUNT as this is a good candidate for per-memcg accounting.
    
    khorenko@: allocation is temporary and limited to 4MB.
    
    https://jira.sw.ru/browse/PSBM-58330
    
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 net/ipv6/sit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 527f43a..685abf5 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -309,7 +309,7 @@  static int ipip6_tunnel_get_prl(struct ip_tunnel *t,
 	 * we try harder to allocate.
 	 */
 	kp = (cmax <= 1 || ve_capable(CAP_NET_ADMIN)) ?
-		kcalloc(cmax, sizeof(*kp), GFP_KERNEL) :
+		kcalloc(cmax, sizeof(*kp), GFP_KERNEL_ACCOUNT | __GFP_NOWARN) :
 		NULL;
 
 	rcu_read_lock();
@@ -322,7 +322,8 @@  static int ipip6_tunnel_get_prl(struct ip_tunnel *t,
 		 * For root users, retry allocating enough memory for
 		 * the answer.
 		 */
-		kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC);
+		kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC | __GFP_ACCOUNT |
+				__GFP_NOWARN);
 		if (!kp) {
 			ret = -ENOMEM;
 			goto out;