From patchwork Mon Aug 27 16:26: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: 10577417 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 81B2B13B8 for ; Mon, 27 Aug 2018 16:27:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B6FB29A62 for ; Mon, 27 Aug 2018 16:27:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DD4629DCC; Mon, 27 Aug 2018 16:27:20 +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 207C329DB9 for ; Mon, 27 Aug 2018 16:27:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D72F46B4166; Mon, 27 Aug 2018 12:27:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D239D6B4168; Mon, 27 Aug 2018 12:27:17 -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 BEA4A6B4169; Mon, 27 Aug 2018 12:27:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 59B386B4166 for ; Mon, 27 Aug 2018 12:27:17 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id m9-v6so1456725eds.17 for ; Mon, 27 Aug 2018 09:27:17 -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=J1cj7ZXg2ZGUw9fXBt8+jsCqFzx1mcYvf7SzwHTz9nk=; b=PWlTVUhG32DFwA75RGRoNwsFHTrh5R5KLncKOeiULvoBQsN7ytaS7323Ie7hW5ZA8K s9KzEMBdAJfPIP8QZrjvGfl+Ii3/zQho7zcQ1pHGNukPverQ/JCXvm/WbPElKcnPsm8I qRNwok8hsXc+5rK5GT1YQ+p74ev2epXHFi3bGcCELC+30Yf3Mlv9tGHZfuQGDh2ddGy0 TA8WVpogLvAlKghBK+CeX5h3YTNU6dFoTEoLa+vtj++4hTXhpy9YrUTjXA18m44lEoMp BcLcPumFggdi2wyT565tgg5IThhDounTEtQQ6Gnh8jSC+z7fZS96GVb18dSQgDNWLHaM qdbA== X-Gm-Message-State: APzg51Dza6QbPVi5a1wJjki9ECecpr22qewiru+xdESdJOzzVMuOMVSH KcCukhL92umC44VQYoiNkNOEBbIIm5nIs67gp68bELuKyuZdvFSeOlygqiTWKfaV8zeZ3H8bOsv B/kLUbHtUTL/JZk+GffrjKmaXljR4h5uEBE6RAtV05qNRSrRw5F6vTiDtJ8ynRh7drw== X-Received: by 2002:aa7:ca15:: with SMTP id y21-v6mr16736696eds.285.1535387236831; Mon, 27 Aug 2018 09:27:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYxVG5MVXAE2ON5EWLM0ohCmYp0OoVu50VyKoZcJ2PvN+UPyEOFOwSMDsWCPuNYpHtI3stu X-Received: by 2002:aa7:ca15:: with SMTP id y21-v6mr16736618eds.285.1535387235666; Mon, 27 Aug 2018 09:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535387235; cv=none; d=google.com; s=arc-20160816; b=us0PGJCRJMC4W3dq0tZwhiMDVtB07aZ7sm/Zy+HTONUlOtxctXiCtDWLpYiK6nZnFK FHUSAsYQZP04hd5CMkFhJ1psDNUAnq17wxHBvxJWJNN4TKXbyhDXxCP3cd3WHWPaElrr lBfShsbOJFH+cDt18Mv1+KDK3jNtVILJmq0NvB/pE3z7zm7GhDMxrwhOEltKbzrKjFbi qjLPT8I6m5RbjXIbXaSwjRQHqQ7vbcg3UJX0vye6YLuFFXFyML+yFiXR1OosRyVUEMdq xLBzmVMN7bPKwi/CKlLl98bfhRFG/NgGYLAn+zDdeW5KVGcjRtv3l1Ju8vHIfz2E1Y5z 8msg== 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=J1cj7ZXg2ZGUw9fXBt8+jsCqFzx1mcYvf7SzwHTz9nk=; b=JO8wLz5H/7RLlebKjVSjreiV6FB4RGuwqtfZoBfctizmyY0cNu4UOWxwCv1xMU3zqb b/w68YjrR4qWyzA7hBgau29cF074Klynai1r3zggD/nP8Fq0EGuCHlgOMQyhjQZUJc1J LxJeEGIwwXRRos7wEeoLneVaK1AZxJyJOlp4P/uQUra+stFHgoLpset5EKO6x33tTF5e cRl0OnWnG8S+4Ey+W39+CAjiX9CfaOuOs5xkY7ryQ+8UyRNjrfBIf190FQ+Q98hGVBqu CVHYSizes4+dLoixvM2+mIEFJVR/SEx9OJPYmQupvtWvtJf3I5ZAOrHJmrC2+dO7fYxo K0tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=OrQ7K5Uq; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=QtV9vROn; spf=pass (google.com: domain of prvs=177771a572=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=177771a572=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id k19-v6si3130155edq.27.2018.08.27.09.27.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 09:27:15 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=177771a572=guro@fb.com designates 67.231.153.30 as permitted sender) client-ip=67.231.153.30; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=OrQ7K5Uq; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=QtV9vROn; spf=pass (google.com: domain of prvs=177771a572=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=177771a572=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w7RGM8Fo012182; Mon, 27 Aug 2018 09:27:06 -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=J1cj7ZXg2ZGUw9fXBt8+jsCqFzx1mcYvf7SzwHTz9nk=; b=OrQ7K5Uqoe3TBdl0Mky/jCYBxei+maPny1Rke0Tr1azCaTTThPCThTrm3zprhg+A5q2j vuP9N/7BtIjg8+wU1cZC8IpUf4Q6DZGIBlgoD6junED8qtx3K1SDmdTjljVti1nLcVRj dHTOu0FW7NN0n1gcYblAmHoeUZc1Kur62OM= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0b-00082601.pphosted.com with ESMTP id 2m4h470sg4-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 27 Aug 2018 09:27:06 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.29) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 27 Aug 2018 12:27:04 -0400 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=J1cj7ZXg2ZGUw9fXBt8+jsCqFzx1mcYvf7SzwHTz9nk=; b=QtV9vROnwBbyPeRNB4A7ALdA69DGl1Nmr/6oFWYN8wTzO8Bfq3IJNCCF5DLaQX9WhftA9zKJdJm6i9fL90HRBRR592KpRPFV9nhjCGCheGQjZM56R1V4dyHCM3lm4d3cxUG4fngxybWLiEIqjVvK7Ti2ghB/FyKe3tMKBt4Z2Ls= Received: from tower.thefacebook.com (2620:10d:c090:200::4:4b2f) by CY1PR15MB0170.namprd15.prod.outlook.com (2a01:111:e400:58bb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.15; Mon, 27 Aug 2018 16:26:59 +0000 From: Roman Gushchin To: CC: , , Shakeel Butt , Michal Hocko , Andrew Morton , Roman Gushchin , Johannes Weiner , Andy Lutomirski , Konstantin Khlebnikov , Tejun Heo Subject: [PATCH v3 1/3] mm: rework memcg kernel stack accounting Date: Mon, 27 Aug 2018 09:26:19 -0700 Message-ID: <20180827162621.30187-1-guro@fb.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::4:4b2f] X-ClientProxiedBy: MWHPR04CA0045.namprd04.prod.outlook.com (2603:10b6:300:ee::31) To CY1PR15MB0170.namprd15.prod.outlook.com (2a01:111:e400:58bb::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d698cbf-f456-46b6-95f4-08d60c39ea11 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:CY1PR15MB0170; X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0170;3:V7guu/R7DFX/el7iYo1/Qf4pf0Cu7eKR4vmKg1JvGPQx6oxTN+Jh6uXdF85qeVhlkef0ANyMdn4zPYqic8bTqxxvI3tOv7BOPo998GkmKG7K+IZCYy1/0OjMDNi8wJj7WEod9FK1v7rJ+QjYpTCqZrT+Lc0kqEOqZubmo/uEa05Q/cQSEkcPpC+m4gPT+4qf1mw41xISXwCwjhdoxw3+HflM2MC+LVcSq0RgqjUGCPw/7xZz0IKu16zpEq/EW/Nd;25:D/n8VUYdHiWmQmmLDsk1vRkbD5Ug8bvlDuurD6EqydivXPgmZrrrtoDDTUuowD13arSzfgGHEyzJKN4cyz1S/pyNOy60J2va+cS53jGpmfPPYukAnBciMbEzvJPmD6EMOKndCCe2MOJeAjnOgIYOMaCvCFevoHC/rEYSwqFo0A4AgWqvnY9TrJ+dG8exoN0XERvljqYQkXqlXQE3ZOHQWsl338jv7NmYvjl8HXXIpA4pMSo+LxMWpxU807slmeLhrm2SthwnGvnc4fUlAha2UnSw+tNd6V7d2xLyASOMcCNKMTQtmkfkdMkRlcYbJPzoaCT5BJjxD6+i2+bHmeZzCw==;31:JuviIVRhsgJ0/mtxcPxjTVMKgy/FnF7DVJXZrMWa510i7Fri3bUigzFJVC7TRv4KAIDZ6yJgYVEj5zELpJLtZyyxntbZIqHZzaahG0pm9+fK4TjzdhuY9jtpyLnvoZefq3re/y8q4rigNP2zcGFwGotulPmjT6ocgH9otdd3FJxKNYJ69FA8DRfksPz2J5lI2y76e/Caooj8lRVYY7Jumv+0SlXQV3XO3AbmKxOruHs= X-MS-TrafficTypeDiagnostic: CY1PR15MB0170: X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0170;20:cI4V/AgaiT4y06E1C54k5vJXuJWDmXNdDHodtUYVxhw3voa7oSxuJRIYw2hC4Ak7mYrJ7D4Y4Du84ZAU/tiug5y+NVQr9kIHPlWh+01wdCY7C95kA1FPgfI/b1dIIi3/YdCitWKK6Oby5jhj3MItE9br9UqacpYYRhJg4jahuEaSmUNMhfD6Xxj+IK885us5l4gLnNr5bqRZ2k2pI00nVxNz0CkB/kheMVy+9kOdgjpQ6T0VC6/q+BnGX8IfQp/MjaL1UtrAw+48dk8XExh2Z6sJc+UxpbjFd8BsBDHaMxJ2+ec6YXc9KqhZQ+AAmKgSAJw0BK313TzyWCtHbL5TJeS67PZR4LQWH5GeC3LVwTOxn2M3PaGFIeMTyQF0RHVBZrmkrmlXebz0e8UAscm8387Idb8oe7En6Hq4CBbsFFlFP5GL3hQD8iOswkhnve/lo8ZNyJ77AepOaGdzEFBQtXxo8rUsKAudxAn+2JU/C0pDz1K63b1oQH75j3FGsO2R;4:aao+Q3FYqBj9A6zQaDBrMMsmdkVkrwNeUyyb5w911WBAG0UrPMEWnlD0PpZRHWX83tZRMfx2n4GrKAOzEG1suZmVXR/cg6XxG5zqFniutxaAFViyQnp/5m34oYwPOBBh712GHODnAstYQhxcfOmCYf3lpboywxOV7ktwMaPnBdPm5qtdQZ/NfIv/KY8XRa9GBU8AVaXdEO3Zlt2S/sEoKJKiRsowXyOpx98PeRDZn7aB3ZpiEgqdfIczAbT4FZ9rEsB6W5ABWp5OoaYJfVCTw+AllVY8Q3jGp5X5QI1klRd+ITppGYAg1Vttqun4p7eBKQzlWkL8pDO6kc3MjqAdj7g0fCWVrNGVUa3dbFQp5kIYe6Gs+nWKbWINuTiHS+phN4HUqt1ObtiSerX1kid9ME3NTptdAyDY5U9+OB rWy64= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(67672495146484)(211936372134217)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(93006095)(93001095)(3002001)(10201501046)(3231311)(11241501184)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699016);SRVR:CY1PR15MB0170;BCL:0;PCL:0;RULEID:;SRVR:CY1PR15MB0170; X-Forefront-PRVS: 07778E4001 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(376002)(366004)(39860400002)(346002)(136003)(199004)(189003)(8936002)(16586007)(97736004)(5660300001)(81166006)(316002)(81156014)(6916009)(6666003)(54906003)(6506007)(386003)(186003)(16526019)(52396003)(52116002)(53416004)(51416003)(15650500001)(47776003)(2351001)(69596002)(1076002)(105586002)(6116002)(106356001)(478600001)(46003)(8676002)(2616005)(476003)(48376002)(50466002)(7736002)(2906002)(486006)(305945005)(14444005)(36756003)(68736007)(6512007)(25786009)(86362001)(575784001)(6486002)(53936002)(50226002)(4326008)(39060400002)(2361001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR15MB0170;H:tower.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;CY1PR15MB0170;23:2M07mbOYny2ynFkW1aHmcms2fjIO1WNiDN2PnrRl0Bzok7jDMQ03ZpZ8MwRHJpiGVmxD9qQ6xzpB+lPnyavyySLPlzQcHAPtY8v0Nq6gKMT1OYB4YWJc+HAtPu+APzwccpqreC64gy6hUV8dGybVhBM70pMwrjGpp/zhXy7BWYWaULix2+yysSE3dRdZ1B3gY+67MwhXK3r7cGkpy+N7aD/nAfJefalnehoMfaMhEZtB/UUKYZCI11lRWrUtPsLnEohMBA8uAdiDTkU9nhrcU8Dpi9+J4kBgcDKPnHntATZhTaSh7HTNXWH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48T8Eqj1s1MLZ2/PJE0ywcdnFLmWEirLAT/f148t/qxCuC5p5KNRF1/NGu3Zx7bv12KEPVIhB+0qc3rmUMEtrbtiIhjeY31vQ7NlSYrqe4aVRL+LS2iisSA9rLrjzsxUFiUJmwR7KTnZKP44eNBQe5u6fVDdwiNJVj/uR9u0RGlolaEs+uY0THv SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0170;20:kumW2C1CX2K4cRwHwgExDSADjFPdhj3C+KmSqXhqqt9peV5TQDlwFXcdScQEZkyhMUekxGM9ZFGF5UO0ei/yF/xXgmuBMECxTtHUn4FhjGTgTwl8bZH6L4zqS/3yLK73iV4aB02rraIKORYdAK3sqw8pCuDHFbPWOmXjPVz3z5c= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2018 16:26:59.1850 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d698cbf-f456-46b6-95f4-08d60c39ea11 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR15MB0170 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-27_06:,, 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. Fixes: ac496bf48d97 ("fork: Optimize task creation by caching two thread stacks per CPU if CONFIG_VMAP_STACK=y") Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt Acked-by: Michal Hocko Cc: Johannes Weiner Cc: Andy Lutomirski Cc: Konstantin Khlebnikov Cc: Tejun Heo Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt Acked-by: Michal Hocko --- include/linux/memcontrol.h | 13 ++++++++- kernel/fork.c | 55 +++++++++++++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 652f602167df..4399cc3f00e4 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1268,10 +1268,11 @@ struct kmem_cache *memcg_kmem_get_cache(struct kmem_cache *cachep); void memcg_kmem_put_cache(struct kmem_cache *cachep); int memcg_kmem_charge_memcg(struct page *page, gfp_t gfp, int order, struct mem_cgroup *memcg); + +#ifdef CONFIG_MEMCG_KMEM int memcg_kmem_charge(struct page *page, gfp_t gfp, int order); void memcg_kmem_uncharge(struct page *page, int order); -#ifdef CONFIG_MEMCG_KMEM extern struct static_key_false memcg_kmem_enabled_key; extern struct workqueue_struct *memcg_kmem_cache_wq; @@ -1307,6 +1308,16 @@ extern int memcg_expand_shrinker_maps(int new_id); extern void memcg_set_shrinker_bit(struct mem_cgroup *memcg, int nid, int shrinker_id); #else + +static inline int memcg_kmem_charge(struct page *page, gfp_t gfp, int order) +{ + return 0; +} + +static inline void memcg_kmem_uncharge(struct page *page, int order) +{ +} + #define for_each_memcg_cache_index(_idx) \ for (; NULL; ) diff --git a/kernel/fork.c b/kernel/fork.c index 6ad26f6ef456..c0fb8d00f3cb 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)); @@ -249,9 +254,19 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node) 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; + for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) { + mod_memcg_page_state(vm->pages[i], + MEMCG_KERNEL_STACK_KB, + -(int)(PAGE_SIZE / 1024)); + + memcg_kmem_uncharge(vm->pages[i], 0); + } + for (i = 0; i < NR_CACHED_STACKS; i++) { if (this_cpu_cmpxchg(cached_stacks[i], NULL, tsk->stack_vm_area) != NULL) @@ -352,10 +367,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 @@ -371,6 +382,35 @@ static void account_kernel_stack(struct task_struct *tsk, int account) } } +static int memcg_charge_kernel_stack(struct task_struct *tsk) +{ +#ifdef CONFIG_VMAP_STACK + struct vm_struct *vm = task_stack_vm_area(tsk); + int ret; + + if (vm) { + int i; + + for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) { + /* + * If memcg_kmem_charge() fails, page->mem_cgroup + * pointer is NULL, and both memcg_kmem_uncharge() + * and mod_memcg_page_state() in free_thread_stack() + * will ignore this page. So it's safe. + */ + ret = memcg_kmem_charge(vm->pages[i], GFP_KERNEL, 0); + if (ret) + return ret; + + mod_memcg_page_state(vm->pages[i], + MEMCG_KERNEL_STACK_KB, + PAGE_SIZE / 1024); + } + } +#endif + return 0; +} + static void release_task_stack(struct task_struct *tsk) { if (WARN_ON(tsk->state != TASK_DEAD)) @@ -808,6 +848,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node) if (!stack) goto free_tsk; + if (memcg_charge_kernel_stack(tsk)) + goto free_stack; + stack_vm_area = task_stack_vm_area(tsk); err = arch_dup_task_struct(tsk, orig);