Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbdLDWtw (ORCPT ); Mon, 4 Dec 2017 17:49:52 -0500 Received: from mail-eopbgr10115.outbound.protection.outlook.com ([40.107.1.115]:30937 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751522AbdLDWtt (ORCPT ); Mon, 4 Dec 2017 17:49:49 -0500 Subject: Re: [PATCH 0/5] blkcg: Limit maximum number of aio requests available for cgroup To: Tejun Heo , axboe@kernel.dk, bcrl@kvack.org Cc: viro@zeniv.linux.org.uk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, oleg@redhat.com References: <151240305010.10164.15584502480037205018.stgit@localhost.localdomain> <20171204200756.GC2421075@devbig577.frc2.facebook.com> <17b22d53-ad3d-1ba8-854f-fc2a43d86c44@virtuozzo.com> <20171204215234.GN2421075@devbig577.frc2.facebook.com> From: Kirill Tkhai Message-ID: <6eaa11a6-a087-42ab-df65-9142b59bf726@virtuozzo.com> Date: Tue, 5 Dec 2017 01:49:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171204215234.GN2421075@devbig577.frc2.facebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [89.178.229.144] X-ClientProxiedBy: HE1PR09CA0080.eurprd09.prod.outlook.com (2603:10a6:7:3d::24) To HE1PR0801MB1339.eurprd08.prod.outlook.com (2603:10a6:3:3a::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d700534-4235-43b6-2c25-08d53b6950e8 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603286);SRVR:HE1PR0801MB1339; X-Microsoft-Exchange-Di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O9DSke5yToK4FDY/zein25syoNZLcygyI88QCNdxHBByiBd5hrs3y/9eTxxz8VR93YW4gC7aEEO4KZUpBe7mU3XHXseixCaad+BupY0Ae6N1qw9P2S8pSidFYmSmSf1WpjFTi8Jgdnp885eyTfW1pABaFtmLoFkXGbX1MsnQQcboY3IS5Pj+wJyv/JbXs8WTPoJ4CcNQAEC5t2tVPUw567XpDPkCIAzdC/RWM8B0qicPM1H2VItrBqXJG6sJ4FAJF9HF08USg5zh0DGRQ5KBiVM5NrzlnmJA=;4:woOGqOWVwb3s4Amh+Z0Yt1DyCJn6NtbL3XJZSUJafoMJcMnIvbK3B6uXJ06CHWXh7M8BnWI+FWqARsVa8SDKk0eUZ0k1joHkQaXbFSV+nG1E1obSEkyAIiU3rzXA1abFeDD6djA49XMX4eWaI6+r4tUHlSm65cGV2QBhOfd25WhrF97008JhPskxrWPwEopnwnKLUigAs5ULQ4HSM8AfPfBpaQ8F7fVLbj3YT3bWMGyuAvaQdlvUsrPRajBPJBjLO2L6UXehJl+G6k3qCGJa06sTbi3LkozjakB3PW1krdo3N7jR5mqiFaqfPJOWnUH/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(3231022)(93006095)(93001095)(3002001)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123555025)(20161123560025)(20161123562025)(6072148)(201708071742011);SRVR:HE1PR0801MB1339;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:HE1PR0801MB1339; X-Forefront-PRVS: 051158ECBB X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(6069001)(346002)(366004)(376002)(189002)(199003)(24454002)(81166006)(64126003)(53936002)(50466002)(6512007)(81156014)(53546010)(2950100002)(6666003)(83506002)(8676002)(6506006)(229853002)(33646002)(31686004)(316002)(58126008)(6116002)(6486002)(93886005)(3846002)(16526018)(6246003)(65956001)(105586002)(47776003)(65806001)(66066001)(230700001)(36756003)(106356001)(7736002)(305945005)(101416001)(31696002)(2906002)(65826007)(8936002)(478600001)(97736004)(5660300001)(52116002)(86362001)(52146003)(54356011)(76176011)(189998001)(23676004)(2486003)(4326008)(68736007)(25786009);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1339;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzk7MjM6QzJxRm1jNE0yd1Rlb0hsdUVaTUp1MHd1?= =?utf-8?B?SmRkekVBL3g3ZjQ1cEdUWHpYem9KK25ZaXgxODVQM29VVE1relVqK2xYMTdW?= =?utf-8?B?UFpqMkQxb21JTnZVQXNFZk9jVmVrRWI3Mk5NUU1kOVdHcTdwREhOV3owRGdO?= =?utf-8?B?QUlDTjlWZ3ZvWU03aDkvM0pYNk56UzVIM1UyR3Q3UEtrSXBjRkgzRDBWemxN?= =?utf-8?B?aVJmdnRlM0xoWkpyblNoK1AzMU1vMTZMcmVkMURNZzJYNUpmckhuTDZlN1h4?= =?utf-8?B?Q2dzSElYQ2R6eTBaaERiaFp4cFJKV01RK200UWlrWXJTcmhCNk90MlhwMW5R?= =?utf-8?B?d3A4MktBclJOd1oySXkwcm1pNHBhWWJGaU1DK0dWVXpyczh1WU9rSWRSTnh1?= =?utf-8?B?bzllenB4WGxLRnA2WDdaTG1CazdWOEp1cExOKzkyeWlpaFNXUmlPSHp3aDNF?= =?utf-8?B?Qmx2UDJ2UjlmZEJCbHZyQ3RXYjdCOE5xRW5RbTI0bXNyVWNvTjgwYlRBejFG?= =?utf-8?B?UG5VeFY5T3U0ekJrNmFaSjBBQndGblJtZnNPdTBrT2hQeVZYMXNqd3dva1ZZ?= =?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KC5lgQHxE8cEEMA2JgoXdBIPhX1dzLVNFpMz5oMjB9qlnqGP247pdoUSvh23q9hpwug85vTQC3aqpP27LXyGFG4CtI=;7:DpYXa1VnaXO4WHia/7S/9XydCEc5iyO7UK2XSBMy/YfNgiASeI9CuJKfXSxhdnwZFIhj5fXv+/hCjCQhvoS+cALQdD5O7LyuuBzcJr+RXNdDRIeoQTvC3ZUWRkWg0bhTLl37J6VRz4lN4wPuSBM2IBDjfVAUiwrRbe2UNr+RCwNtf5tL3NLa98Ck1ffyV0Nn7vrWufw0EELMEzkYOIMgnv9Un2TxXcbWPzxxetwwBDaxxPlLyh1AwMip/Lhg4VQR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1339;20:fq9Pr5N2IgSsihZM3HhYQ8R11qV5lF+f99Tj4dkFOuVSV/YeZ/J8XLR6BfD6JBcy3Q9afUYmteautXzwcM/1k2KsUr9QZD7HW8oRysmasQ3JNUjZGOhc4w7ePRVdxA9oBhifud1LyUrgP2CPiMxU6JpNUUnvnBLPp4i3ez2BEUQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2017 22:49:45.4353 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d700534-4235-43b6-2c25-08d53b6950e8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1339 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1988 Lines: 41 On 05.12.2017 00:52, Tejun Heo wrote: > Hello, Kirill. > > On Tue, Dec 05, 2017 at 12:44:00AM +0300, Kirill Tkhai wrote: >>> Can you please explain how this is a fundamental resource which can't >>> be controlled otherwise? >> >> Currently, aio_nr and aio_max_nr are global. In case of containers this >> means that a single container may occupy all aio requests, which are >> available in the system, and to deprive others possibility to use aio >> at all. This may happen because of evil intentions of the container's >> user or because of the program error, when the user makes this occasionally. > > Hmm... I see. It feels really wrong to me to make this a first class > resource because there is a system wide limit. The only reason I can > think of for the system wide limit is to prevent too much kernel > memory consumed by creating a lot of aios but that squarely falls > inside cgroup memory controller protection. If there are other > reasons why the number of aios should be limited system-wide, please > bring them up. > > If the only reason is kernel memory consumption protection, the only > thing we need to do is making sure that memory used for aio commands > are accounted against cgroup kernel memory consumption and > relaxing/removing system wide limit. So, we just use GFP_KERNEL_ACCOUNT flag for allocation of internal aio structures and pages, and all the memory will be accounted in kmem and limited by memcg. Looks very good. One detail about memory consumption. io_submit() calls primitives file_operations::write_iter and read_iter. It's not clear for me whether they consume the same memory as if writev() or readv() system calls would be used instead. writev() may delay the actual write till dirty pages limit will be reached, so it seems logic of the accounting should be the same. So aio mustn't use more not accounted system memory in file system internals, then simple writev(). Could you please to say if you have thoughts about this? Kirill