From patchwork Wed Aug 15 00:36:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10566207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A131417E1 for ; Wed, 15 Aug 2018 00:36:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9322228C1F for ; Wed, 15 Aug 2018 00:36:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 872072A1FB; Wed, 15 Aug 2018 00:36:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C21F928C1F for ; Wed, 15 Aug 2018 00:36:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C44E26B0003; Tue, 14 Aug 2018 20:36:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B74BA6B000A; Tue, 14 Aug 2018 20:36:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EED26B0007; Tue, 14 Aug 2018 20:36:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by kanga.kvack.org (Postfix) with ESMTP id 6F1C46B0005 for ; Tue, 14 Aug 2018 20:36:50 -0400 (EDT) Received: by mail-oi0-f71.google.com with SMTP id p14-v6so21869698oip.0 for ; Tue, 14 Aug 2018 17:36:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:from:to:cc:subject :date:message-id:mime-version:spamdiagnosticoutput :spamdiagnosticmetadata; bh=msuVjdyVfTRbspscaCDwIy7tMM2QtYrgmrKRNFFQspQ=; b=aaOoz8WN4D01qkAxQ6rG47B3AVbc1zbYRpdaBXTHB31/mXWxUKQ4wPnH7VQkyAxhSB zrUb04gZQ+89G510KmHAm1gvbvFwWrDPjtVnL6RwtenFaZ6o4L0QM52dfWDoJeSiE3OW LX/lusLJKggGWOf6G6Odmj/0nleJt8PgOO5NPpYenqv4b7x1QLGLVhdqfFWJZnWhKBBT lWoEIVbwep5+s/1uQcrgIO6ywcI7UMALemC6qk+OG7uBSWGuP30gGTLRtYh3ceZVLBhd AxfMaY9BExXuCuBrbcixB1qnLOD3U03cX2QpJGldLlkuvW5bUn2vo0CaW1sCoYhGzH10 +Rlw== X-Gm-Message-State: AOUpUlHWZR34tkcCFsB0CYdRGY5YhjrnRPIswgUARcuzmyZIuE4p4KWU oJfNqMsuUwpXuJ96iW9v1ttVdebbUKrE1wOyEzsbzDoA42LPiRBo89FJ9FCheWIz3P4k/cjBRe7 XQM1Wh8WjUpeugKHV/6OTp0hqCRXaIs6ACZtTNqpBX0gaW+gerJ6GhNabnfoHa1a6rQ== X-Received: by 2002:aca:4fcf:: with SMTP id d198-v6mr22408969oib.51.1534293410204; Tue, 14 Aug 2018 17:36:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxwLUbOK91zeyP4581YkKMkaCrLqAIOKmIN1chCdhzJLCRB3mAojQD2Mqcjbt+bmt/tWN2F X-Received: by 2002:aca:4fcf:: with SMTP id d198-v6mr22408946oib.51.1534293409456; Tue, 14 Aug 2018 17:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534293409; cv=none; d=google.com; s=arc-20160816; b=LWACIXJZLO1xyYjQAANZDZOL1t+16Ednkjk7b8GlWN3UA+rtHyDQ8wY10JYR3Dxhwy bA1cozG0xS8AAbrPtzc5Br5CN48X+eRRK8VnG+95RyReZbrxYLLyZuXjBRhtufJIPxHK PAx4ToBYnTvAqanj6Hw5DjQri/rxFNtgHJpslqRCq0TTxjHj4Pu1L+suWNHBP7HpIbVC hNDpH1PCzjYfr+Hh+BOZgW4H02SyBgJUoIyaZxqdIkNUh5VlPnsA/JnkvXT4rzOD5rLA w5J2DIxJp0xnIwA/bqC0w1JyP4clEKdF+8VhOXcppgM6pWGTMtnzpm5SscorL4Eq6mI7 YJVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=spamdiagnosticmetadata:spamdiagnosticoutput:mime-version:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :arc-authentication-results; bh=msuVjdyVfTRbspscaCDwIy7tMM2QtYrgmrKRNFFQspQ=; b=FOx+3vMzrV3VIIqmRiuINQUKxo1tNDK7Z28vrpEvMeaWNSWiS+qWscv51oA/6PNZ4g v5WVGIBG9InaECK1tKhW4ji/9sG7Y7WQqKnFjGFTiq0PV3qTuKMsWCLlBtqeSU6PMqw8 tl3WK1LveheyMeFHErDGcMmLPbYIlyJsa1nsEt9UIzmD8GgtLsw9k9Wr5qCwMqpCyf+i qYTpY6s36zYSAQaWlLN7TZ/Imd2P871Z3/DDacBHbRZYPI0wxNjWMSHtUGxYqOT21+i5 ZSJDEFkSkN5FVxAjd6udSRf0JBeYCCxzdjH2Ykpl0e9eCASZ1Pno21IdDUhgQ6hk8ulR 5IaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=GIt6juWo; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XPi77NN+; spf=pass (google.com: domain of prvs=1765e4075f=guro@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=1765e4075f=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com. [67.231.145.42]) by mx.google.com with ESMTPS id j129-v6si15172840oia.26.2018.08.14.17.36.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 17:36:49 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=1765e4075f=guro@fb.com designates 67.231.145.42 as permitted sender) client-ip=67.231.145.42; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=GIt6juWo; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XPi77NN+; spf=pass (google.com: domain of prvs=1765e4075f=guro@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=1765e4075f=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w7F0UOnZ028091; Tue, 14 Aug 2018 17:36:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=msuVjdyVfTRbspscaCDwIy7tMM2QtYrgmrKRNFFQspQ=; b=GIt6juWoRAuoQ/eHrtOBOWswvnmHcp2oluRtAtqJEoVtzj9tjwsoA0Z53J+9O9nV6JAY CxxdzI/Dq08sZ1RMAu4eMjXle3+wjMHyzY8rKrPoqd/uXK4uwZc8JJjP9SqQt7303os6 YTAEz24Abvt05gaZVWyexfBp+WejkTEtWaU= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kv6hqgg7w-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 14 Aug 2018 17:36:45 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.20) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 14 Aug 2018 17:36:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=msuVjdyVfTRbspscaCDwIy7tMM2QtYrgmrKRNFFQspQ=; b=XPi77NN+JiTx1ADpNQleVwh/AY/CKp7MPzKQhyYQ9PHD6kCPh2V2FxiijPqEhqF31DnZqTK/3fDUXZ7SQLD2pOTE2Vss97KTtNlqd/6paEeOZ0d0E1jFIxApAds2wOMwJmQmkSnVfhVz2lHmJ8RKx2djexWEe0s3alp5NRg/Ozs= Received: from castle.thefacebook.com (2620:10d:c090:200::7:b884) by CY1PR15MB0169.namprd15.prod.outlook.com (2a01:111:e400:58bb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.19; Wed, 15 Aug 2018 00:36:40 +0000 From: Roman Gushchin To: CC: , , Roman Gushchin , Johannes Weiner , Michal Hocko , Andy Lutomirski , Konstantin Khlebnikov , Tejun Heo Subject: [RFC PATCH 1/2] mm: rework memcg kernel stack accounting Date: Tue, 14 Aug 2018 17:36:19 -0700 Message-ID: <20180815003620.15678-1-guro@fb.com> X-Mailer: git-send-email 2.14.4 MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::7:b884] X-ClientProxiedBy: MWHPR19CA0006.namprd19.prod.outlook.com (2603:10b6:300:d4::16) To CY1PR15MB0169.namprd15.prod.outlook.com (2a01:111:e400:58bb::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a5cdb32-0da4-4c4d-f667-08d602472af8 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:CY1PR15MB0169; X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0169;3:LRPc4/4L52F3p92MLwHhcDS1GgNCWW+aDFitu4cOjVbvhMKnamUv9GJab1wWcjzsCqj03dlDRg68gVv9JyvDJ/1yXVtgwLDCKOOS7AS6LOnlVvHW33wzYzQ7Rc/exldgfArZJFtSTriKzInl7FMiv0teCM2/i41/8Ws3utRGDVQ7WxhpxM2YbNnPoL7b1nLyrPJpqgUwRbruKAKJYF0HrpUYHWb+1UaqQTjF3sQa5x4rCDnMAtlcbrgq9egnvGTk;25:o6pCE9DuT7YO2itXB/7za9CkxvdbemYmvFSLo6KhggXzUWum13ceyNPdMJDv/42pCW2mZYxsMB4JAT0tjXzGgM9b51vkuU1uq8YbKAgMqrM4SEoQEmthkD8CM312SpvV4Vy5F2lgxJdBg2uo/p8V7I59KyO+YXXYvx3Oc6YkYUnS8lR/eK+VUIV+Yq2atKSjXnPe97TLP0FEeV6t2RGfWncFnw00ikeblESrqAfbnHkZjCTTZFJdMwJacIuUUw9BKzHXJyHHjK2CQJIQTbShPqxh7aGsBom7XnLZk8rabmJq4nu24fhZpDldYPI/jrXRxvTnexmeD5sRsDl0gt+qYTo/yr1ii/DvM9uJRL9ShRc=;31:m+Z7eYGzZhhQ+/NphMfs+kKsEs6kieQKrnEbykxjDEzHuxmf5GgP2cJdt5Blv7bzzXA2kVyra6X65PlamIefPqc5TycnqwxfuG8VoEZKQOHlZris/BP1AO06/hOepdAtYeFqXb+pm+uY4Bt/+eEKptpN3EnsD1QWSzOrIUx2HvkIm6ZC8xbtHmt55G5BE05M/9OauNtwbvWdH/VtHxdg+leg0WsDWEM4qI0WCCj1vE8= X-MS-TrafficTypeDiagnostic: CY1PR15MB0169: X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0169;20:mSQhI7zsP3mdLBOemKIuqKayUtIgKEhsSM0q0Uwfdf0Pdd88mW5NX0S8+JylweOwb2bf3aNJt16GMxZHLNsJAzSmfCMQIawZv8Se/XVGWNT61wiDIXBVECAEacTyADwPpMDrPT3leHqZejd4It5MzYRaZ78Ex3J9j9AH33GmInOL/Oil2+0lHZvNoFJE7SM6w5sIu+7iMUfL9Yz1MAbgPvGG0lQmA2M73bq366YznMUqyciBL0mC1SxuNeeGrZrl5/GEhvg7TvC4Eu3xZ+Aw9shGZwceEAycOntz1SPR11t1/f95jXwrIA4k3KN/kjOiJCIzjOb9dC5rUcUq4mSd7y8dwwuLUsqXoAup2q/ZvpD5c85+XueCxl5Awc1r4Y6EIHwEjVzIkEpQyLfmKsbz4tAz+hUWSEu8i/q4ako5wqy9lqHl6fwkifnLz3Hbd6j7YUbZRHJaTWtqmcV2jZcDgKLED2zD5P6fSt12e4e+1s89+k05you/2GX8nG35xIQS;4:SDCWh3T5go6v3z/O9XgDKjc9sXEf6Ubzc7jDscFuoQEB2yVhcNYNNG1urUFYxchTfhXQQtPTDk1n4oVxcY41IoZJ/mjRl7ZGG7H80ivSbE/FGYIRvFaGxHE8rtdXAWMEUD+vvXwKStmZWvuGjh3QlROxslxdUscoEeTkVqLbQB7z37LCqaqIPnrTKXuAh6ZzkAjcQjgqKvAUne5tEFvMkg0it4oXTOdgArQR75Cn9jSIvXzgyQCFmV383gb7VLuvOvKM569ohUm7ZGOHoNrrykjaQYYiL3j0kdGMYR9wslpaoEWkr+Ysh64PRyf2B3ucBNN2hYykEXn5r8Hx4yARjE7ido+i0TBNhX9P1oocHP8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(67672495146484); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(11241501184)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:CY1PR15MB0169;BCL:0;PCL:0;RULEID:;SRVR:CY1PR15MB0169; X-Forefront-PRVS: 07658B8EA3 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(346002)(376002)(366004)(39860400002)(136003)(199004)(189003)(316002)(2906002)(52396003)(54906003)(105586002)(4326008)(39060400002)(69596002)(51416003)(25786009)(16586007)(53416004)(52116002)(36756003)(305945005)(50466002)(7736002)(106356001)(48376002)(2361001)(97736004)(68736007)(8676002)(81166006)(81156014)(6512007)(6486002)(53936002)(46003)(8936002)(2616005)(486006)(476003)(386003)(6506007)(186003)(1076002)(86362001)(6116002)(2351001)(6916009)(14444005)(6666003)(47776003)(5660300001)(217873002)(478600001)(15650500001)(16526019)(50226002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR15MB0169;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0169;23:9gjqIN+urvTUoRT2aLAesPJDWHiQEbdxz+geewpDiDPwxGkqOnPa1hF3rZWf1HoQkVgoEw3lNhGxJuouV872ZHII8NtH+kurZ1v+Ehl/Ky472N4SYGyPEKbIvoQOFAkojbAEUWuwjqUFxD+BKG5EOgjdDLGbOQ1N27XIZSrPI2a/b+cWXr3LaZha/IbKEy0JvnJNMLVUIBGT+k8mm8rQNaD5/lgXGQ/woNmfQxx7O2Y9TuhLDmlh1BhG+7xoWPThRQ6Z/Oj+0fdg5nFbQY6DRrexSnP5qNNzwPXm1v5CUsoIfeZj8Z6sYRyFY1bTp6mCaZXVFE9wTxxxd+k8neCQILe0cEgpcpf64iYryrUMR7XPmmExWrINxt87vX7YCChrK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0gewklHwv7LFlYJu6Mtd/cAQrQj2PyKFEPIfV+Hq9/HIQSXcrgVKjU9uQWd3+aVS2IrJo0lCxcMlY/LBzLlSom9rlEN3hMA4W+XSnvZwOiITEB/Y3AhZxX1X SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0169;20:/QgKraNlG6dhTjbyQ0kzePKJDnL7dV/wei6PpnrH3d6IchiEwhcnKyKAS/Nvol3Ulaage2AymD4HKmM7VRP8F8wIpfjOVmcGnzZOCqOkaRgRNAXXYsdMwPjS12Ww8aVXTnuMmGAUYch4Vd5Q7Bwj6gd2OOJoi75RWNbI+2Z1bZE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2018 00:36:40.0458 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a5cdb32-0da4-4c4d-f667-08d602472af8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR15MB0169 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-14_12:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP If CONFIG_VMAP_STACK is set, kernel stacks are allocated using __vmalloc_node_range() with __GFP_ACCOUNT. So kernel stack pages are charged against corresponding memory cgroups on allocation and uncharged on releasing them. The problem is that we do cache kernel stacks in small per-cpu caches and do reuse them for new tasks, which can belong to different memory cgroups. Each stack page still holds a reference to the original cgroup, so the cgroup can't be released until the vmap area is released. To make this happen we need more than two subsequent exits without forks in between on the current cpu, which makes it very unlikely to happen. As a result, I saw a significant number of dying cgroups (in theory, up to 2 * number_of_cpu + number_of_tasks), which can't be released even by significant memory pressure. As a cgroup structure can take a significant amount of memory (first of all, per-cpu data like memcg statistics), it leads to a noticeable waste of memory. Signed-off-by: Roman Gushchin Cc: Johannes Weiner Cc: Michal Hocko Cc: Andy Lutomirski Cc: Konstantin Khlebnikov Cc: Tejun Heo Reviewed-by: Shakeel Butt Acked-by: Michal Hocko --- kernel/fork.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 69b6fea5a181..91872b2b37bd 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -224,9 +224,14 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node) return s->addr; } + /* + * Allocated stacks are cached and later reused by new threads, + * so memcg accounting is performed manually on assigning/releasing + * stacks to tasks. Drop __GFP_ACCOUNT. + */ stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN, VMALLOC_START, VMALLOC_END, - THREADINFO_GFP, + THREADINFO_GFP & ~__GFP_ACCOUNT, PAGE_KERNEL, 0, node, __builtin_return_address(0)); @@ -246,12 +251,41 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node) #endif } +static void memcg_charge_kernel_stack(struct task_struct *tsk) +{ +#ifdef CONFIG_VMAP_STACK + struct vm_struct *vm = task_stack_vm_area(tsk); + + if (vm) { + int i; + + for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) + memcg_kmem_charge(vm->pages[i], __GFP_NOFAIL, + compound_order(vm->pages[i])); + + /* All stack pages belong to the same memcg. */ + mod_memcg_page_state(vm->pages[0], MEMCG_KERNEL_STACK_KB, + THREAD_SIZE / 1024); + } +#endif +} + static inline void free_thread_stack(struct task_struct *tsk) { #ifdef CONFIG_VMAP_STACK - if (task_stack_vm_area(tsk)) { + struct vm_struct *vm = task_stack_vm_area(tsk); + + if (vm) { int i; + /* All stack pages belong to the same memcg. */ + mod_memcg_page_state(vm->pages[0], MEMCG_KERNEL_STACK_KB, + -(int)(THREAD_SIZE / 1024)); + + for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) + memcg_kmem_uncharge(vm->pages[i], + compound_order(vm->pages[i])); + for (i = 0; i < NR_CACHED_STACKS; i++) { if (this_cpu_cmpxchg(cached_stacks[i], NULL, tsk->stack_vm_area) != NULL) @@ -352,10 +386,6 @@ static void account_kernel_stack(struct task_struct *tsk, int account) NR_KERNEL_STACK_KB, PAGE_SIZE / 1024 * account); } - - /* All stack pages belong to the same memcg. */ - mod_memcg_page_state(vm->pages[0], MEMCG_KERNEL_STACK_KB, - account * (THREAD_SIZE / 1024)); } else { /* * All stack pages are in the same zone and belong to the @@ -809,6 +839,8 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node) if (!stack) goto free_tsk; + memcg_charge_kernel_stack(tsk); + stack_vm_area = task_stack_vm_area(tsk); err = arch_dup_task_struct(tsk, orig);