From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0FDEC77B60 for ; Sat, 29 Apr 2023 10:14:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62F6F6B0071; Sat, 29 Apr 2023 06:14:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DD5C6B0074; Sat, 29 Apr 2023 06:14:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A6346B0075; Sat, 29 Apr 2023 06:14:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 381DD6B0071 for ; Sat, 29 Apr 2023 06:14:05 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E4B661A042E for ; Sat, 29 Apr 2023 10:14:04 +0000 (UTC) X-FDA: 80734018008.30.B735EAC Received: from r3-23.sinamail.sina.com.cn (r3-23.sinamail.sina.com.cn [202.108.3.23]) by imf28.hostedemail.com (Postfix) with ESMTP id 93E52C000C for ; Sat, 29 Apr 2023 10:14:01 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf28.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.23 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682763243; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+n1rSmyE8qiJDIx1zPRAFIHmf05Qw4WDGbjMr7R6bc0=; b=5ih2MsOGmkrSvjxVObPBdO0huoSm8Upu479vZCZXX8N7NV5VyeN9b0henamFC/kzfW/B/J UM+hy+3AOhvGJVewZAK6jY3MYbIIxpYaR5PtK5SYtCHyqjYmcuuHmh9OF4GTEnYXQeTwCV cconaLrSoBSBgm8BXTW/tG65T30zAPg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf28.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.23 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682763243; a=rsa-sha256; cv=none; b=IMwcrTL/Q/3ham5yMBJtCrLuZghbQMkXuUpaPY0lC2XPLefKm2zRVitvPnAmb7dPIf7I+7 cDzGgrAsZiXYWOfsqPYfNvufoeDM24Ao/1a4YawXd1IrZcOFjx08llvRzFTSt82ALf5Y0k RWgAoJZOPRF/sV2mRtYLnY+FJXhXQEA= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.59.75]) by sina.com (172.16.97.23) with ESMTP id 644CEDE20001F8A1; Sat, 29 Apr 2023 18:13:55 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 85708731457876 From: Hillf Danton To: Douglas Anderson Cc: Andrew Morton , Mel Gorman , Alexander Viro , Christian Brauner , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , Yu Zhao Subject: Re: [PATCH v3] migrate_pages: Avoid blocking for IO in MIGRATE_SYNC_LIGHT Date: Sat, 29 Apr 2023 18:13:45 +0800 Message-Id: <20230429101345.2769-1-hdanton@sina.com> In-Reply-To: <20230428135414.v3.1.Ia86ccac02a303154a0b8bc60567e7a95d34c96d3@changeid> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam02 X-Rsp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xis4 n3YJg7LzgKl8zFbY1P5ZhxQ9ppm+yQtoNePOw/83fM/gRwVxyA+MYIg10ZiHxHoaGNgxr6sjBHlfHNdMIxwqojn9SbQoA3EyBGx5an3jsYxQIerdHxt2WchBFNhunUc4oFgzlvTBVmFRuLKdTmX4jMlOiWQrY7b8DmfjHNm7KRQAULSZPRdXcC7GHQzsQtQ12mnT35RTUym50o+Y+VLha71j63zXjwfS1WHo8lFUD9wWy6F+Cu45F4aTQyxSndl83YraQDtQTNUU+F+U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000082, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 28 Apr 2023 13:54:38 -0700 Douglas Anderson > The MIGRATE_SYNC_LIGHT mode is intended to block for things that will > finish quickly but not for things that will take a long time. Exactly > how long is too long is not well defined, but waits of tens of > milliseconds is likely non-ideal. > > When putting a Chromebook under memory pressure (opening over 90 tabs > on a 4GB machine) it was fairly easy to see delays waiting for some > locks in the kcompactd code path of > 100 ms. While the laptop wasn't > amazingly usable in this state, it was still limping along and this > state isn't something artificial. Sometimes we simply end up with a > lot of memory pressure. Was kcompactd waken up for PAGE_ALLOC_COSTLY_ORDER? > > Putting the same Chromebook under memory pressure while it was running > Android apps (though not stressing them) showed a much worse result > (NOTE: this was on a older kernel but the codepaths here are similar). > Android apps on ChromeOS currently run from a 128K-block, > zlib-compressed, loopback-mounted squashfs disk. If we get a page > fault from something backed by the squashfs filesystem we could end up > holding a folio lock while reading enough from disk to decompress 128K > (and then decompressing it using the somewhat slow zlib algorithms). > That reading goes through the ext4 subsystem (because it's a loopback > mount) before eventually ending up in the block subsystem. This extra > jaunt adds extra overhead. Without much work I could see cases where > we ended up blocked on a folio lock for over a second. With more > extreme memory pressure I could see up to 25 seconds. In the same kcompactd code path above? > > We considered adding a timeout in the case of MIGRATE_SYNC_LIGHT for > the two locks that were seen to be slow [1] and that generated much > discussion. After discussion, it was decided that we should avoid > waiting for the two locks during MIGRATE_SYNC_LIGHT if they were being > held for IO. We'll continue with the unbounded wait for the more full > SYNC modes. > > With this change, I couldn't see any slow waits on these locks with my > previous testcases. Well this is the upside after this change, but given the win, what is the lose/cost paid? For example the changes in compact fail and success [1]. [1] https://lore.kernel.org/lkml/20230418191313.268131-1-hannes@cmpxchg.org/