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 0F77FC47258 for ; Tue, 23 Jan 2024 16:19:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87F376B0083; Tue, 23 Jan 2024 11:19:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 82E2D6B0088; Tue, 23 Jan 2024 11:19:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F6B66B0089; Tue, 23 Jan 2024 11:19:11 -0500 (EST) 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 5CF496B0083 for ; Tue, 23 Jan 2024 11:19:11 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 093DC160B6E for ; Tue, 23 Jan 2024 16:19:11 +0000 (UTC) X-FDA: 81711085302.25.0BBBFE6 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf21.hostedemail.com (Postfix) with ESMTP id 8B9C31C000F for ; Tue, 23 Jan 2024 16:19:08 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=IHAU3ilv; dkim=pass header.d=suse.com header.s=susede1 header.b=IHAU3ilv; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf21.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706026749; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uAy3ketzvRMwRbLQUV4pgMQkbDKQ5GdBAhMyiIwhx+k=; b=SIipJegUp1FfYWmJvBNaHwNvuconnFk9addB1O7+M+d4Y586uEt4kvIpKh2ODKfFNuTvJC 2FdLv0u8cuTBzdwHuJSD/7pKPfX2E6yYR3efNLScgP8lkc/qbBVzdIY83EnTWhCI7YTokv aDgwlklGx0JICFTdjUOI+CKA5gfo9V4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=IHAU3ilv; dkim=pass header.d=suse.com header.s=susede1 header.b=IHAU3ilv; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf21.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706026749; a=rsa-sha256; cv=none; b=HiHHCjfGAjjgNLBbuPsREtcpr5n08Yq0fhdB3qxJLdEJdfn/K6y+P2L7REfPEA4CizV/ny IWqHbL9USzh5Fk8iy85rlOfMxUGIJMn839Rg33s9Wv1brZIf5ruyPZ5tth5/7AWTJgCLr4 NF5sRdcE0Qz2KPFdBw/uQWIgkrob4Xc= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3D0B92244D; Tue, 23 Jan 2024 16:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1706026745; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uAy3ketzvRMwRbLQUV4pgMQkbDKQ5GdBAhMyiIwhx+k=; b=IHAU3ilv6nTkpi9HeEfp8+omCcPYaW1FIBDOIsxiTVqRUdx/FGWxsCpgppOePQMF2hGuWI ABZjfXd8UO3dpBHWqtRIBvu6aD0sQaB/plj0mhDz42owfX2XGI82iBUbOGy8uvSNPbwbB1 N3FnnAxdZyQOpCTKoXlMVkAgJTTrO78= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1706026745; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uAy3ketzvRMwRbLQUV4pgMQkbDKQ5GdBAhMyiIwhx+k=; b=IHAU3ilv6nTkpi9HeEfp8+omCcPYaW1FIBDOIsxiTVqRUdx/FGWxsCpgppOePQMF2hGuWI ABZjfXd8UO3dpBHWqtRIBvu6aD0sQaB/plj0mhDz42owfX2XGI82iBUbOGy8uvSNPbwbB1 N3FnnAxdZyQOpCTKoXlMVkAgJTTrO78= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 18A7E136A4; Tue, 23 Jan 2024 16:19:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id EpzeAfnmr2UTCQAAD6G6ig (envelope-from ); Tue, 23 Jan 2024 16:19:05 +0000 Date: Tue, 23 Jan 2024 17:19:00 +0100 From: Michal Hocko To: "T.J. Mercier" Cc: Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , android-mm@google.com, yuzhao@google.com, yangyifei03@kuaishou.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Revert "mm:vmscan: fix inaccurate reclaim during proactive reclaim" Message-ID: References: <20240121214413.833776-1-tjmercier@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 8B9C31C000F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: tthi89m4zzsbor7bf54cnzxgj6s749md X-HE-Tag: 1706026748-500899 X-HE-Meta: U2FsdGVkX18I8hHPTu55moaoXeGWxzflheopa1+0OMBSyeqtYGeWDXxREk9UvfvElNG0OmlyXrhY9T34Epa/EyVDvKuvwdQLZZlMowvbA4PkSqfVs1r+Ta8IjArMyrnguzjlJVo73ihdZT2b/7WiVOXhj+jRxZUAGzDLJ9BVGn5KlxArzRRgn+Rz9q66cswBlNtxXNYjjtiNBO8olOLeEh6eXXBt0Nk9uEeV2sfjvhiHfOhHrSrmchRxp+ppG0uyx9umGLDjRmm7e8UYEMvdTOQCMUK0DzKiLpSL0ea6kWnYjiRbj+KUWY7uoX5z9/7J84DZ7LMuvzCMxEaHxOjcarkQctjglAbzNCB0OktcvAw98GX1sPI12o2vHzHKZ7cMpbqEinW5AnshF2XY045i5BBNKWY1yaKCi81GarMH0izUxdxmNsXZnic3ogcOsMPWK2U+1Me8zTTZFVV9rbsuVlnwJzRJTvw0OavuAPCqb1Wffz8DpDJ5BvE1/M224Vh9VtXgrm448zWSloEkOWR+U1rucHTUCpBXfB0BWxNc77qig48JsEJnMOHwu+EwCKHbtsLrOK8EZlcsx+vTcXGv+R3XL4GHsTEmS/Yd8OGLsXTBslOJz1YuB98zwXOT47GQY++Yzv2MRQMdvHuh5wGnQgO4eOmAsOmqrljL5Lftqvf4NlJYWJQo7wC9L04CAhvlAGvQawCGTxs0gC3vbuZ1eZ9NX16AWfYJ73XdbfoqO/TKPI/j2UlHukhou8m/jFUsovX3NVfGMZQnQbpQuLsQUk4vOQTYH+fXG5EJlRMkguARR7qTJNPq49osvH2x66CacjUB+0fnzUiFluMnL33PcbOxfKKlBR810NKgrQ+llnxQXLlVEiiOJ47vJiDKf2SkRklx+3aIzZ2HO2gaKdMZpVvCauZey9a56ZiBvh51k/cYgvpBoIBRN5pFTCc8prat4MQtyWxfMapbwQonoZs yDuRG/hC 79l188HybTq7aSg4zvJfuhVsNyY1kjdB4exJdK9wKmTVyZJYqtzUwmXaDRxEJcdAz/6p/o/i5DEBkaVxWYr7du5QJ8QqFRkDbj6WGdlaccqKl2/rahEWrBqPGjKc81IUhCMZMOMW7r/652yAadX2DGhw2ti6sIo1yNh1CIUAhmOcP77y1cV5Oqgh9Z7v7P3rZf5Am2546miM1xSr39zLQgVkdI5mmmEdFLTGEcGzyVbAaN2CaoHCUeLTFmHUxqS8OQAu5q8/NVQC97XVnrqN5EHwr41K/MOd2RRZAxv0zhC/lp8AyMu7HCtcSF19CY2b/+HzUcLgiF33NO8d7pqc0680Zxs4Y087GD28MHgDPZbyfDCE= 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: List-Subscribe: List-Unsubscribe: On Tue 23-01-24 05:58:05, T.J. Mercier wrote: > On Tue, Jan 23, 2024 at 1:33 AM Michal Hocko wrote: > > > > On Sun 21-01-24 21:44:12, T.J. Mercier wrote: > > > This reverts commit 0388536ac29104a478c79b3869541524caec28eb. > > > > > > Proactive reclaim on the root cgroup is 10x slower after this patch when > > > MGLRU is enabled, and completion times for proactive reclaim on much > > > smaller non-root cgroups take ~30% longer (with or without MGLRU). > > > > What is the reclaim target in these pro-active reclaim requests? > > Two targets: > 1) /sys/fs/cgroup/memory.reclaim > 2) /sys/fs/cgroup/uid_0/memory.reclaim (a bunch of Android system services) OK, I was not really clear. I was curious about nr_to_reclaim. > Note that lru_gen_shrink_node is used for 1, but shrink_node_memcgs is > used for 2. > > The 10x comes from the rate of reclaim (~70k pages/sec vs ~6.6k > pages/sec) for 1. After this revert the root reclaim took only about > 10 seconds. Before the revert it's still running after about 3 minutes > using a core at 100% the whole time, and I'm too impatient to wait > longer to record times for comparison. > > The 30% comes from the average of a few runs for 2: > Before revert: > $ adb wait-for-device && sleep 120 && adb root && adb shell -t 'time > echo "" > /sys/fs/cgroup/uid_0/memory.reclaim' Ohh, so you want to reclaim all of it (resp. as much as possible). [...] > > > After the patch the reclaim rate is > > > consistently ~6.6k pages/sec due to the reduced nr_pages value causing > > > scan aborts as soon as SWAP_CLUSTER_MAX pages are reclaimed. The > > > proactive reclaim doesn't complete after several minutes because > > > try_to_free_mem_cgroup_pages is still capable of reclaiming pages in > > > tiny SWAP_CLUSTER_MAX page chunks and nr_retries is never decremented. > > > > I do not understand this part. How does a smaller reclaim target manages > > to have reclaimed > 0 while larger one doesn't? > > They both are able to make progress. The main difference is that a > single iteration of try_to_free_mem_cgroup_pages with MGLRU ends soon > after it reclaims nr_to_reclaim, and before it touches all memcgs. So > a single iteration really will reclaim only about SWAP_CLUSTER_MAX-ish > pages with MGLRU. WIthout MGLRU the memcg walk is not aborted > immediately after nr_to_reclaim is reached, so a single call to > try_to_free_mem_cgroup_pages can actually reclaim thousands of pages > even when sc->nr_to_reclaim is 32. (I.E. MGLRU overreclaims less.) > https://lore.kernel.org/lkml/20221201223923.873696-1-yuzhao@google.com/ OK, I do see how try_to_free_mem_cgroup_pages might over reclaim but I do not really follow how increasing the batch actually fixes the issue that there is always progress being made and therefore memory_reclaim takes ages to terminates? -- Michal Hocko SUSE Labs