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); From patchwork Wed Aug 15 00:36:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10566205 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 2943C157B for ; Wed, 15 Aug 2018 00:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A00328C1F for ; Wed, 15 Aug 2018 00:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DD8C2A1DC; Wed, 15 Aug 2018 00:36:53 +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 09E1328C1F for ; Wed, 15 Aug 2018 00:36:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB36A6B0005; 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 A630D6B0003; 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 905676B0008; 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-f72.google.com (mail-oi0-f72.google.com [209.85.218.72]) by kanga.kvack.org (Postfix) with ESMTP id 634B36B0003 for ; Tue, 14 Aug 2018 20:36:50 -0400 (EDT) Received: by mail-oi0-f72.google.com with SMTP id b8-v6so21845667oib.4 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:in-reply-to:references:mime-version :spamdiagnosticoutput:spamdiagnosticmetadata; bh=eesPrDvOqeXhMz2Kka4CiC+3KQRHS0oUCbgFaiOyA2I=; b=ThqXDWY6Hhat5OjH+X+ZdezLM+NiiZPlBM8FUBN5EfYhm0HtGReYrJsJAT8PVmSUnx R8fwKWupTXPQObrnn7sVbuGw0RpiepB2cUIEHzam6c53KFS7z+kC8+u+UjrmlV+oqNqU zEp9ZiuNDPwAhPNi2DNBHR8JXk1dhsiJuz3xajZHaFcLgoWnkGdSJIoUbmc3owD0nJOt buc1ErSaN6ofQEy8EXwPTukSShCuXslMD2zoF/3j4KeRHBSIEbWWCxeUtdlE165ZQHll OMm4cNs/WPkOwkiEc1tfsQOjG1iQ1z2dViUteeyZP61tHhPcv7MiGwY5TO54RDIV1gTL Xbeg== X-Gm-Message-State: AOUpUlGfq00J6Rgrut1KmZSnUD/bDggnnIUOJIE27p9CCcnDPrGupuIu Ff1jacS6bLHYvMqmHp2NO88kPqT4Jmv1FzdbAd0n5rJIhKT6KQNm+fFMlb9kOrHdKfnzXM7crPi slvvbXSUzdFOTJsI4jDOPV8HKEaAVq9ZdIQTmGG5+Py+hc9PCeR1uZumYa/xy257Rug== X-Received: by 2002:aca:acb:: with SMTP id k72-v6mr26305371oiy.78.1534293410102; Tue, 14 Aug 2018 17:36:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzZ9jGH7iFSH2l5SRr2IUdSB6uBZFQIEBBh2h2jLxAXG2hkyGqYk8IaZND2ppuplGoa+T59 X-Received: by 2002:aca:acb:: with SMTP id k72-v6mr26305343oiy.78.1534293409455; 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=UV9eVdYRG2sNTyyy9ZgWJGElApaFoMDF90gmAWZM994B65fYE9cTevalJFwswrYekt L4bRN57a3TNbgo8caS2QjWtk2Q9wbDGKRlpV4Mu4CJTBogd0bOu7YYjPpFVZRfloMsad AdqA6NkM2Udac4YSdCXo9lCIt8Y7HqkuR9xr/jTGOlQXC2YruKs3e+rB5yfT5kqiikMf yVJRIT6Tucd5y6lu+95/Cd3lmuYueUP7Oplm1qRf7guYRE4t84T64jRt3ywu+g5bjqwe am0ZSadG1y2pgNApwHRcTRtCQzku8482ixQDCkegkAyymkF3wMaWfy2R5bWI0SzysB6e f77A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=spamdiagnosticmetadata:spamdiagnosticoutput:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=eesPrDvOqeXhMz2Kka4CiC+3KQRHS0oUCbgFaiOyA2I=; b=bkToh54VgqIShKD08XzEJtovK62H0GbNY43KgpjE7IIYlwi3XhEdDIQ1VlWU1IGEVl yYjAxJMiQlt7WthzxfgnyyXXoWv/mM1lsDpUj+httqwc6mhxFY9ZkAr34eXnHaWtgCaL Zd4JW6xm0uLUp7K9K9mLDb0L4SbH0jV/9RVhRRAvFKtvW9yj7JLBBoNJPkU8GBVR760o RMO28NUDrD97Ann6tuKsRMBPAA0pTtrPW8Ry3k9vrsnoM5N0lv7fa5KHVQLz7gI0bcGt XPM5ANIWGBoimXf/NZP5iiUT/YurkvgQnhEnVrItpTJ2VAWdjMYiTtRkCu1BL7dgs54q m8ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=lg9y5jYy; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XwTPYzfV; 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 l77-v6si14731910oig.48.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=lg9y5jYy; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XwTPYzfV; 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 w7F0UOna028091; 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 : in-reply-to : references : mime-version : content-type; s=facebook; bh=eesPrDvOqeXhMz2Kka4CiC+3KQRHS0oUCbgFaiOyA2I=; b=lg9y5jYyHQURsMpjlHM/eNSGuBXqflp3SMMpZ/hF6NXnwwQjzDvpAICHml4w1O09mNn+ 9DR1ntzKkNteyStGrGbu+tA4P2Am1k+7EMpu0o6kFvchWx6yXaEN4p6/fZfyg/4rAGKh 0HGSpHrXniZhygfKa3HRjmaZkgxPE9vs6PQ= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kv6hqgg7w-2 (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=eesPrDvOqeXhMz2Kka4CiC+3KQRHS0oUCbgFaiOyA2I=; b=XwTPYzfVJkqTd9zEHQE8MPRh6PwxAVe9/nQSMv6OF+y7kNvujKmFmCrRjVREy4h7ztByEgPWcl9DFReazpQ3CLEaxvwihOXF+/7ItGeEP8Zr3ygNOLy2CRQzkw7tzaCwimI2nX4pXDnKEu0qR0fEf+eRlsLkYS8e2+sbdI0iag4= 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:41 +0000 From: Roman Gushchin To: CC: , , Roman Gushchin , Johannes Weiner , Michal Hocko , Konstantin Khlebnikov , Tejun Heo Subject: [RFC PATCH 2/2] mm: drain memcg stocks on css offlining Date: Tue, 14 Aug 2018 17:36:20 -0700 Message-ID: <20180815003620.15678-2-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180815003620.15678-1-guro@fb.com> References: <20180815003620.15678-1-guro@fb.com> 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: d6f46611-207b-4f65-0590-08d602472b88 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:UI46yOKmfkpe/1meHUV6jztQpakFTB7S868xTeM/dM2ON1Ozzdn48vQCtNV1qO0KEoBHCf8GLbn52n7QoZ4md8Hhf+p0EVRhAQMf4Jjf3DFRHoQAIloxikda12pubGoqmcVQwIoFVVOlh4znWs8OYIW90E2b9tKi67MJQgx5roeOlSCCzzMLl0gZYKaj4EaK7qRP009vXBJ3yQnFXTKZ27KQGe4YcgcpBBSCSEVx+VBJMJLU1NuWc1CGsZkphpI5;25:etb9QUBEsFrmnsF5eFjbLKdrDslScAbPgtc+e8V6HcWiNk5VTbbhR1zwEJ+Dj/HRvZ7VpnWj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wmf22zTcywQW3aoCYqtQnXFyCUj+4h1eS;4:P32FkiNsLl8wDY6/4n68RPX0XV3jku8zQPWgCjSWTiJRK00HjF7FPTO6QgHUKuh5IYRetYm7MO3KlwAsNvDqJkyct0FhoTt7ZnfIdiz7KA8Sna1Q7Er6nz8D1777+ZKgYQWxgL1AIPLrSdM9ohDZdEpmQ05lFqPLxvEZnH+xIBgOqqEhpZSGAwqbTPyyFDDRGxPY+s0OMAL+oU27sm1KSyrjXr0iH76M7H1gRaRigAItBz0W0zjIbdoVNT68rpCoW3QvylQwE2kwvLp1FZpfKSrG1HeKZ1sUhnM90HDhcSTtjZh2lcIGTvePO6ChhTqHXQ6LPXVm2LYWhcdTpbJhcHAP9lAjeIcOl3YgVNfSGEE= 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)(76176011)(52116002)(36756003)(305945005)(50466002)(7736002)(106356001)(48376002)(2361001)(97736004)(68736007)(8676002)(81166006)(81156014)(6512007)(6486002)(53936002)(46003)(8936002)(2616005)(486006)(476003)(386003)(446003)(11346002)(6506007)(186003)(1076002)(86362001)(6116002)(2351001)(6916009)(6666003)(47776003)(5660300001)(217873002)(478600001)(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:UY4HuPUJKdKcLYQjpc56eGtqA9hoQFrwYHtlFvWa/UF0Ycraq6GR+pIRpHRwVMXzZIVJPRgYQlGS+dgdzVX4GYZkae2qH8WUPX19m6V8Zzl4skoGV+3IXjYRkmpvsLxP1AjNbOb1XNgQb5xXzk3kTy9D2UK9YI2V/hLf6m/mZn2SMPUMC+IM2z1RcXeTmDI4n0k6SBUmlL6UM6JiWx88PcS+fnm8rBkleknfBwYSO8tBDXaGFB9DdIwCtxNw72I28cPSAAjdugzkYGGa/wx3FCXE/rSTjUEjyifrjkLqbyo+tvgIOo+BVlx365PHVgOEezyAGWXWurVZ1etEgKRV5dJuiTDHoGOV6tE4e2oVKYybP9baH+CtJDvvLVDt7E1Ai0vRcoGa7WvYfeAVMQcOQo+3Qj/ubwLWUcgy+PvZfvi2iwWb/ed8C2qefOI4KT+SeDwdGq1G3rHGx3R/geMBJYEBgAatWr+wriwCEBygBJXXxxO91xW9UnE5XabTrU2CR5Oo6oZp7MDQvWaOuyImccJG7ZwsJThehCvendKy8h4EFcTXPF69PFcHCKB4rndFTEuATFFYJYYax+AgLOx0UqILE0IH9nLVrbaoQCQfsQpxH6fQvN3WVkVMuhR/gW7ZmmXm4zhGunVUExQHWymz/XInsePf7+jGZTxumkka8hpmlUk6/zhKuMwbQoNT8nZgdeF3C/CgYE8fh9L4vv0gSdTqe9lTrO14wayaasC2CS637i4cCi7l7iz/xMAHzGTplag3NofR3bXD0nB+pRuff4dM9plZnA9kdb7BEoqjTlYNmlCyGlNhBJ5k7HVSeMsa4Mbo8OlL+0Ai4b9tBNiq2u8vMI4N8KYUxyGZmYQTpc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c8Hn64MdcF/Da8m8XwjcZE5xGqXusODeCMOK/GFkF0oVyhMiUA0JBzrXwCWJ2LdMi6ro2uldp+E8BE26d5m7jrCAzKeAXjNYZWpWJL7HLdBLQvNCdqI7NhYhIgH4fxH5PCLJYDHtQhnBBzI2IB9wMrjJ9luRQsBFyNAC/uYSjZQXD/0PM12aoaRhxM6A/Eiin8nqLuqIKxsMwHRFbHkumuVnKe2+491Qv+ci4cq0kiEiCP0UFiaVUsGqd+juDxKVA==;5:F3Tm6MGeRibFLgZMAXUB+DxM+LPvG3llDVaxTccrQFYgrxzTjZ9bKNQFOVlD3oCIuPsjjSQL5kwJ9IgwIyoGNk+boh5LUFJI+hIolbeOQIOX6kPZhPWu1H6IQYfKoLfx8KBG3RFk3vSxPpi8vYW16cPwH9qGpufK/t7H/yqhmYk=;7:hr0iK5zABr70wuxRxy/xl/MqbEZZK3+/Cq+w+EX2TUWnRS76NOW95pDk1wtkGZl02KxV8J1uItfIW2mrtPsg3+CkZw3552tDmmAbLJV1c6DO8OwNaWWdtr2yg6GDgm//uagO1lKuoJQYfGtB7/CnuAVSPVcEQ4MSn6IoQJipXunA2PVQudq1wDeR9oIIR9ys46V9wPptRsnq7gBY0aV8LxCByzVEtXKU+ldyp6DoAcONTOprDV9nMKcQiDQx1kNb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0169;20:dRmZNGU4EStOcIfQTVsgNK4E6+Uj7zLvYCUnpBydMr6yh9y2hLv75QC/g2wO9BA6vFKPmLfBqeTPBa5AYk9olcRPjeNq/24VOurejgndA9qVm7tC+QJl9dL+CfXVOg5g56zq3OXAmjxlsEYcSQkaDb+yIQ7nR7HC95aoIpo4jgo= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2018 00:36:41.0302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d6f46611-207b-4f65-0590-08d602472b88 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 Memcg charge is batched using per-cpu stocks, so an offline memcg can be pinned by a cached charge up to a moment, when a process belonging to some other cgroup will charge some memory on the same cpu. In other words, cached charges can prevent a memory cgroup from being reclaimed for some time, without any clear need. Let's optimize it by explicit draining of all stocks on css offlining. As draining is performed asynchronously, and is skipped if any parallel draining is happening, it's cheap. Signed-off-by: Roman Gushchin Cc: Johannes Weiner Cc: Michal Hocko Cc: Konstantin Khlebnikov Cc: Tejun Heo Reviewed-by: Shakeel Butt Acked-by: Michal Hocko --- mm/memcontrol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4e3c1315b1de..cfb64b5b9957 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4575,6 +4575,8 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) memcg_offline_kmem(memcg); wb_memcg_offline(memcg); + drain_all_stock(memcg); + mem_cgroup_id_put(memcg); }