From patchwork Tue Mar 9 08:04:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12124323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 378F6C433DB for ; Tue, 9 Mar 2021 08:05:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C732A652AB for ; Tue, 9 Mar 2021 08:05:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C732A652AB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 67E9E8D00C4; Tue, 9 Mar 2021 03:05:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6555D8D007F; Tue, 9 Mar 2021 03:05:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D0328D00C4; Tue, 9 Mar 2021 03:05:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 3345B8D007F for ; Tue, 9 Mar 2021 03:05:01 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E63474DB8 for ; Tue, 9 Mar 2021 08:05:00 +0000 (UTC) X-FDA: 77899599960.12.E475273 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10114.outbound.protection.outlook.com [40.107.1.114]) by imf14.hostedemail.com (Postfix) with ESMTP id EE5EAC0007CA for ; Tue, 9 Mar 2021 08:04:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kfn9HUyO0797SZOLr9eZPUj8VIJuy3dHFysJo8GIg2jAaWYpDP+sqjJp/c18slEuYQyuzX11DNKwdHUFpg9fdE+ReumNWX2BTqMnUQFPuxTlIhN7BF/CDeoKQTRHFqj9JXjCRDD16jRKVACQjrQo0kuERNi4cXfXSmAxs+iFCaBJKYpMdMHUvdSfDgapz8MQIqL95MWGsj7afslcGWTSqpsu3g1FoUn6nZnSZMfcTJtcbsDPvNeS9QTJh3fDYxChSla8NnRtl4M0gVVYynlHRHe/8n0eyvR7Ahl1yfJc1hLFCw2VwGf/iD2vXcpQRBt2s4j/F8htIu2Oi86p1r1XzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DETAgUIoY/Yh+88xtrJ0p4ub3J39q3mROrB0pV7+7iY=; b=XtEYBmV3dSl7P42kwK/ipnoyUZDc5M5mZcWy1CEPKBOJzZZXTk3XqeyL7jcCBhJsmpxOkaknscF8UzHc3NLXx8LuhRsIOIgkicvvVruOjpsNAqRNaeS8c+PF6Hp2Ub8QpcaAMgaj4v37esuXaLK/WJChIeHkwrBE6fqJhXTkUnr/mCQ/vTY9aMZcbmPyX/sU5dq3SfZDJ4jzR0i6ekBR0q9QQMd5ngXUUc2W3+qkUCgSHf7J7lv+2R/+egez0+Ri0zJhb9Af8/IVdAhIWWH+VYCUWnZc2+xEa3nLnTRdcBBQt8nvk4LIk1ewgUdRj95ASiyYGMkoJfdV/BgA/+aArw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DETAgUIoY/Yh+88xtrJ0p4ub3J39q3mROrB0pV7+7iY=; b=s1VeK+kL/60lgVPBobVfRF82ESE/ZrQt6G7tL6f0LBe3D+HFVMTQU6ILix5Gf/uZWUi+lQDaluVNyWxT2qFCLctf8EqjgL47nG/6eBAOi58InqTwljsuG4JiZBg4eLf5OvcLW7HzQ6NtliUXsI1QlCTcq/Yf50HgWzw+AdY/cNY= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=virtuozzo.com; Received: from VI1PR0802MB2254.eurprd08.prod.outlook.com (2603:10a6:800:9c::22) by VE1PR08MB5789.eurprd08.prod.outlook.com (2603:10a6:800:1b3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Tue, 9 Mar 2021 08:04:58 +0000 Received: from VI1PR0802MB2254.eurprd08.prod.outlook.com ([fe80::e4c3:b366:458c:c613]) by VI1PR0802MB2254.eurprd08.prod.outlook.com ([fe80::e4c3:b366:458c:c613%11]) with mapi id 15.20.3912.028; Tue, 9 Mar 2021 08:04:58 +0000 From: Vasily Averin Subject: [PATCH 9/9] memcg: accounting for ldt_struct objects To: cgroups@vger.kernel.org, linux-mm@kvack.org Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov Message-ID: <05c448c7-d992-8d80-b423-b80bf5446d7c@virtuozzo.com> Date: Tue, 9 Mar 2021 11:04:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 Content-Language: en-US X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: AM0P190CA0019.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::29) To VI1PR0802MB2254.eurprd08.prod.outlook.com (2603:10a6:800:9c::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [172.16.24.21] (185.231.240.5) by AM0P190CA0019.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Tue, 9 Mar 2021 08:04:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd3af80f-71a7-40ce-eac1-08d8e2d20815 X-MS-TrafficTypeDiagnostic: VE1PR08MB5789: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6wz4CtwHx1MUT8YX9OB2Xwo7jEpC7AZMVaf4LSNVU2LrEFMEzmFFqcbmh/AcaqDfhoaYIYQtGfXKM1n7PE/sS+SV4misZG8NmPn1AGbU3R/qzuJRYbHBZ6BJsEsusdw5QnMaXWT+c0Af/H9yldaxEpAKMY52U436G/1m30bFcPLXXLptUYU5qZihELSS6pCEmZuL2w0askVOGCAQOvaPhDQkaQ7ZZZARmR6BR9IyD32N+Uh6DG99aho/0EzlexZRfGPUNZtNug4AENpOwIfaePsAGxsR+RjiL5g/PTOFNTs/dUL+t2ZODnFi4ZeYqL+J8YxUsFVHFjLzUtYJdi+45A0PweMl1vjOcnunsQYUJph1zEbwNxe9KVt0ofcfxzllv0m47GzuGU9NyRh4u/lImZ1e2u/XUUfuzgPrBchs/0hz15xMfMrVJwfZUDufXk+AP9qbXX/fuyGSgyCJnXLPmIHqZ2vi0oqiWUN+VEHqgKC0lC+IWTppfqI6khtTTechfVjg5CfmQ2OiWTDBCkmY6+U99pnYZT3ND2rTT3XuZib/wMkqBlDIp77gX9AnzhEJE9ivMqSrpO2kVqNknQdc+sNvHDrTWipt6ESbqw01+cY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR0802MB2254.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(366004)(396003)(136003)(39840400004)(376002)(26005)(54906003)(31696002)(66556008)(66476007)(66946007)(36756003)(186003)(4326008)(83380400001)(86362001)(478600001)(8676002)(2616005)(5660300002)(6486002)(16526019)(2906002)(8936002)(31686004)(16576012)(316002)(52116002)(956004)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?98QtP1NGjEK3l9pG1kMkcmG3/ottRF?= =?utf-8?q?lOvFdhrRyEXhL0eil5HwVsRoHCxRJbsnIQjaZxFu0DFonx9dTTBeJK5MB0c2xYMjj?= =?utf-8?q?NlXWBBZIaocq1KF9ApsEN9uUj/lNemM4jPWQKGiwuaS4zmY8VYOqwOxw6YveIdyj8?= =?utf-8?q?/Ho5toeZKD3ELr28HPdPP/Pu5GgEzhUoyyF6nJb8v9TzAWPi31rcwaY5x8gw+XcXv?= =?utf-8?q?YYiLYEvzIyzZ8b3VBG99ZvEZcg2yY7CsY/i7SImAXFKl1Cr6CFJNA9cnUbNbjWUlG?= =?utf-8?q?x75Ekvg9JJeTdNt1qB/iUnsnWFKigahF4lZfjZakazfn0jxjYr8m9oj7uL+pvwz6W?= =?utf-8?q?XKbpdHPFHdRieWyB4m+KyeqGcOqgqVkzO8D/wueEu7lxViIoPvERuNWko04CUaogd?= =?utf-8?q?kz8ApfCmfq/qAQvQWrN3XrRyB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: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd3af80f-71a7-40ce-eac1-08d8e2d20815 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0802MB2254.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2021 08:04:58.1128 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KlmVPULP6W+42BzgND7cArqD4SaS2ZDhjHBj8SaSum4XBlbPHf3DXdMKyrAFvBUtIEam/4FFMEdsX+514xXARQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5789 X-Stat-Signature: oc4ot7sx8uijsxe69g4zyy3xhk8ndpcc X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EE5EAC0007CA Received-SPF: none (virtuozzo.com>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=EUR02-HE1-obe.outbound.protection.outlook.com; client-ip=40.107.1.114 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615277095-803755 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: Objects can be created from memcg-limited tasks but its misuse may lead to host OOM. Signed-off-by: Vasily Averin --- arch/x86/kernel/ldt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index aa15132..a1889a0 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -154,7 +154,7 @@ static struct ldt_struct *alloc_ldt_struct(unsigned int num_entries) if (num_entries > LDT_ENTRIES) return NULL; - new_ldt = kmalloc(sizeof(struct ldt_struct), GFP_KERNEL); + new_ldt = kmalloc(sizeof(struct ldt_struct), GFP_KERNEL_ACCOUNT); if (!new_ldt) return NULL; @@ -168,9 +168,10 @@ static struct ldt_struct *alloc_ldt_struct(unsigned int num_entries) * than PAGE_SIZE. */ if (alloc_size > PAGE_SIZE) - new_ldt->entries = vzalloc(alloc_size); + new_ldt->entries = __vmalloc(alloc_size, + GFP_KERNEL_ACCOUNT | __GFP_ZERO); else - new_ldt->entries = (void *)get_zeroed_page(GFP_KERNEL); + new_ldt->entries = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT); if (!new_ldt->entries) { kfree(new_ldt);