Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752217AbdLFTiD (ORCPT ); Wed, 6 Dec 2017 14:38:03 -0500 Received: from mail-he1eur01on0124.outbound.protection.outlook.com ([104.47.0.124]:32704 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751544AbdLFTiA (ORCPT ); Wed, 6 Dec 2017 14:38:00 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Subject: Re: [PATCH 0/5] blkcg: Limit maximum number of aio requests available for cgroup To: Benjamin LaHaise Cc: Oleg Nesterov , Tejun Heo , axboe@kernel.dk, viro@zeniv.linux.org.uk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org References: <151240305010.10164.15584502480037205018.stgit@localhost.localdomain> <20171204200756.GC2421075@devbig577.frc2.facebook.com> <17b22d53-ad3d-1ba8-854f-fc2a43d86c44@virtuozzo.com> <20171205151956.GA22836@redhat.com> <20171205153503.GE15720@kvack.org> <20171206173256.GA24254@redhat.com> <20171206174445.GM1493@kvack.org> <103a542b-58c0-5d31-7b51-2a957a5bbd66@virtuozzo.com> <20171206183036.GO1493@kvack.org> From: Kirill Tkhai Message-ID: <06f180e3-73b5-96e5-d281-8bb2a0958f8f@virtuozzo.com> Date: Wed, 6 Dec 2017 22:37:44 +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: <20171206183036.GO1493@kvack.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [89.178.229.144] X-ClientProxiedBy: DB6P193CA0018.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::28) To HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f84a42a1-d139-439b-feed-08d53ce0d977 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603286);SRVR:HE1PR0801MB1338; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;3:RT/WAh1Ebpt52+vY/vP2n6QTkrs5G7DyF/L/iHJLf/DVJi/9kCo2IfHibsWEpLFz33HnuXYSrdDJX4g/IXZ8+nxHk7cOqftqyXx6QuC8KZMMFI4vUJ7dEiIvF+3YcxO8p20Mkkd8pXE2GvhJ9XnvvofwR96h5MEvPr/ZtyyG437aZJqXB+9tClmvmYzrQc+uj1Bgn7iUQSxjlGyBNjSSZqdtcquMCdSZZ/2XgZUn1HuExl3eIHjlm+1K5bP6fQt6;25:DKmyVqRd/Y6ysTT/pdMQqmv/6UYMe2MMGHGmGN4lqaH+CJdEwe6qrZvWipIMjqkXnh30q4DvRT5Dlc9JvxJcC2LinOVYWBweZyVDgGKs0mIGnSfE+1k+LEJWtToP0WHdy1onEBtuq3VRWa4agUpFXd4MrAXntukdhly3rro0cHh+Q356nMxP/zJpg7KqoUm4IAdhzT7DV1oeesbbkn32YBk58ZGJhcE6DGnsPLxo5cIm6bxTGtwGk+fO6EOt5mQbTIqYJn6MGGkkJrtZ09UU8F+LETpOCziJQ8/b5y5IurL4ha8zMp2ZN4pzLO5ECckvizzaAsn6zBSH52JY8kC51A==;31:j3qW4X0dRIdOBI+1sPdTWlSavo5GFe4Wvenv5LV5V0InMaAX0pICtZ87YrEo/A17A0HHqw2jN8wfyKQcbaU8jq/svEpUsX5vIVoJJ1lNGan9w+EBunAFx1Gp95l7qQBVzEGkR7BKtQJQLVKmKLyTZqY9l8JWEPjS7ucHNyfnZKCG6ads8Z36D5o+7D81omhBWqp1RFtEgXTkORDPP2nFfAnEq5gMRbHZ72JBWXBB+l8= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1338: X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;20:KXCr8JG1GxQP0FsbjFr6U1aJZi+tOHhzsmjxWG2tNnPwwXr0fnEgXRb3v3HAE1KRnocfNFvUU/ENjtNk4bvqjSg19Xr1RGm+FftYm/wSqf40Mc011EaIXprrOE+oYSea+CE2XnnmknUVZDw1+1UMNKf3mNp35rka3r6mi493GlKLkCJnAGMFsNxygHeBoYIuV+madrkLDoVUNQE5Vc3Epc8GnOw4mfRd9vNIk0HOb/k0zEZxbygMNSMCe9f/5Lufj0NQgb59l5u48fhiGtEU7MQyyHEUUujPuCZU8ZSw8+AMdQlj8/y0wq4Ar4Gm4WJvUZ2WLBwYZfXJB14LrK1Wn47JS2nqo/vK68MxYjyRSAMpAry+9e1HJmopZfIyg5weGgXSHsJCfx/DalzJ9hZa/BZ8S4XiDBurL8PevIVLZSQ=;4:1VnsKbbxyKF5bpvrvYLuQpP/5Bq7LpfT1okazw40/CDQ9mE9dDaE6fi1o0sD8q+BiLzXgDZbKny3JrVnMj5CteOhPP3HIFH9OsnwH+/IE2Y1wF20e5/ZWx8EINlG264nQufixwnA8KVHtdPz3vq8csdWttVCFbace5vX9EBZ/2MKQupIU+mMy+a0v291z55+zIDr+pFPgI0+/LRvaJHOe9KQ7I19HIOM+u1UVMOGaNV8WCAeOCJdinYOhjyapJSmUnhEqMCFu6eCKsZfDGJ7Uw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231022)(93006095)(93001095)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123555025)(20161123560025)(6072148)(201708071742011);SRVR:HE1PR0801MB1338;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:HE1PR0801MB1338; X-Forefront-PRVS: 05134F8B4F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(376002)(346002)(366004)(24454002)(199004)(189003)(58126008)(54906003)(65826007)(64126003)(16526018)(93886005)(23676004)(52116002)(5660300001)(50466002)(2486003)(68736007)(36756003)(2950100002)(230700001)(83506002)(6666003)(316002)(81156014)(6916009)(2906002)(3846002)(6116002)(52146003)(7736002)(81166006)(76176011)(97736004)(25786009)(53936002)(66066001)(65956001)(65806001)(33646002)(106356001)(47776003)(8676002)(6506006)(305945005)(105586002)(53546010)(86362001)(8936002)(31696002)(229853002)(6246003)(6512007)(31686004)(478600001)(6486002)(101416001)(4326008)(58950200002);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1338;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzg7MjM6OW15TVBmZnhabm10SmJEcDZmcUh6STFS?= =?utf-8?B?akVGZTdUcmdUbHhudm56TzRCSjZXaDBCUGhOZmVvaDNJcnBvTldMYjZhSUxE?= =?utf-8?B?ZXBNZCtCSHlta1BNLzlHSEJna2xMNmtCQ0VCU2ZUSkttNXRGazNwWDRZbWJ4?= =?utf-8?B?MklVaTZsVW9BdExkOXdscFhkWmxBeGVuWjRKMzdzMXlFYmNkNnFUNml2ckhI?= =?utf-8?B?Q3hiOEZKWDhtSUxxdm0zZkJvYWRreERFMS84RlhKS0VkL0d1OXBIUXlydWUw?= =?utf-8?B?RWNDckVhVktxZHprenlmT2VjR01LKzUrWi8wVmlFM0wrdVJ5SjVNcGJzNFNq?= =?utf-8?B?Z2t2M00wMkVSdW5ya1l0cG5TN08yQURqd3ltRTRVa0NSV3hJeExzTWo1Y2hM?= =?utf-8?B?V0ZZcklHZ2V4ZTJDbnBHajZPcmlreEhBQ0dQR2wzMWNXbUp6bGh3Y3o1Umlu?= =?utf-8?B?d0Y3aU9ORnVrQ09HSUcvSmkrQThqYUZOYng0d3YrVnRRUERIK0dqN2VoUjd3?= =?utf-8?B?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b/nqns9ujjM6D2buqy70oRseYm7kiz2JHfkOI+XTDjsgfj7iY=;24:bMRa0DplG7G7hllEX7HWx4L4QH/sl0jx/FZSYISf/nIzMfQF0w+Tz/kIW76aAC9Cw7G1EqHO5rDAmh3vgoqSLVw8FdV+YnR0rpi10uFmsCY=;7:dYlZzCtK618bgkrGBDQEOFjho7ky1a/6UX0HqM4HD3lTYDNbpXghu992qmkQcLXUVwf5aAQTxW5wowWAEJNojZXxJbWZn5PWQEzMxKWXH4KfZST0ljx8ETcw7b0Gl0ObXtQLhlK4/TscgU5QWDmVAcIVmRxE70fHoXlPQdIphKOliY5MoKlfBL0JsVAhYSbkRPYDsU1NoWikFpLUdbUjXjc3b1+HgiPAmXCOjYo/lf0yXfX7rS9iXO2vquEVIVd6 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;20:tAWVL8nyur9Dp1pXKrUhhrY0WE8bbmNPTSXoQTK2BlMJVZCjTvveyGL4Pbbe3jVICHFIeFRIKDfVyY8yDWNdJ/oxhEy2Jae67VWOSvR05VouflrtG9+H+APpz8oVBrMz1/cMnbPPctI+vZO/sHEhqOqgwH9HoQdLtZj8Zu1AZz0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2017 19:37:54.8684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f84a42a1-d139-439b-feed-08d53ce0d977 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1338 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3192 Lines: 64 On 06.12.2017 21:30, Benjamin LaHaise wrote: > On Wed, Dec 06, 2017 at 09:19:09PM +0300, Kirill Tkhai wrote: >> On 06.12.2017 20:44, Benjamin LaHaise wrote: >>> On Wed, Dec 06, 2017 at 06:32:56PM +0100, Oleg Nesterov wrote: >>>>>> This memory lives in page-cache/lru, it is visible for shrinker which >>>>>> will unmap these pages for no reason on memory shortage. IOW, aio fools >>>>>> the kernel, this memory looks reclaimable but it is not. And we only do >>>>>> this for migration. >>>>> >>>>> It's the same as any other memory that's mlock()ed into RAM. >>>> >>>> No. Again, this memory is not properly accounted, and unlike mlock()ed >>>> memory it is visible to shrinker which will do the unnecessary work on >>>> memory shortage which in turn will lead to unnecessary page faults. >>>> >>>> So let me repeat, shouldn't we at least do mapping_set_unevictable() in >>>> aio_private_file() ? >>> >>> Send a patch then! I don't know why you're asking rather than sending a >>> patch to do this if you think it is needed. >>> >>>>>> triggers OOM-killer which kills sshd and other daemons on my machine. >>>>>> These pages were not even faulted in (or the shrinker can unmap them), >>>>>> the kernel can not know who should be blamed. >>>>> >>>>> The OOM-killer killed the wrong process: News at 11. >>>> >>>> Well. I do not think we should blame OOM-killer in this case. But as I >>>> said this is not a bug-report or something like this, I agree this is >>>> a minor issue. >>> >>> I do think the OOM-killer is doing the wrong thing here. If process X is >>> the only one that is allocating gobs of memory, why kill process Y that >>> hasn't allocated memory in minutes or hours just because it is bigger? >> >> I assume, if a process hasn't allocated memory in minutes or hours, >> then the most probably all of its evictable memory has already been >> moved to swap as its pages were last in lru list. > > That assumption would be incorrect. Just because memory isn't being > allocated doesn't mean that it isn't being used - the two are very > different things. You are sure, allocation and using are different things. But if memory is being used does not mean that it can't be swapped on disk. And as the memory is still being used, the swapped pages are read to the RAM again, when pagefaults happen. And as pagefaults happen, the task allocates new pages to place the swapped pages in RAM. So, allocations of memory happen, and honestly this seems to be not the case we started to speak. Of course, maybe, there were implemented a tracker of used memory, which prevents used pages to be swapped on the disk. But when I dived there last time, there was only PROT_NONE based tracker used for NUMA balancing. Maybe you or someone else have new information about this. > Most of the embedded systems I work on allocate memory > at startup and then use it until the system gets restarted or rebooted. > By only doing memory allocations at startup, code is simplified, > performance is more predictable and failure modes are constrained. Yeah, and many realtime systems have the same model. But it may look strange, aio is also popular on many other configurations too :) Kirill