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 C5566C433EF for ; Tue, 8 Mar 2022 12:52:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 384F88D0002; Tue, 8 Mar 2022 07:52:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 334118D0001; Tue, 8 Mar 2022 07:52:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2247F8D0002; Tue, 8 Mar 2022 07:52:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 111478D0001 for ; Tue, 8 Mar 2022 07:52:39 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id C90FD615C1 for ; Tue, 8 Mar 2022 12:52:38 +0000 (UTC) X-FDA: 79221207996.03.C824507 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf16.hostedemail.com (Postfix) with ESMTP id 2533B180011 for ; Tue, 8 Mar 2022 12:52:37 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B4B431F37B; Tue, 8 Mar 2022 12:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1646743956; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lRaLiSx/+7wYcapcOjboAfSDrQGY3y4Vmq02XjhF0Ww=; b=beLTnCIRd93oFtoGf3mf8R6Px97SGQlKGVXCkNf6REbuOL500UeeBZu0hDRGBYF7SlOONr Xzt9+4p/1x+juvjC8bdNqTEar8wtLhz1tiXG+0K2tZFRHKYXtScaQPnDmW8P9lDIDaYcos /dQ5T2lAozVYgudHFE4z9MYjkk6cf1Q= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 8672BA3B81; Tue, 8 Mar 2022 12:52:36 +0000 (UTC) Date: Tue, 8 Mar 2022 13:52:33 +0100 From: Michal Hocko To: Shakeel Butt Cc: David Rientjes , Andrew Morton , Johannes Weiner , Yu Zhao , Dave Hansen , linux-mm@kvack.org, Yosry Ahmed , Wei Xu , Greg Thelen Subject: Re: [RFC] Mechanism to induce memory reclaim Message-ID: References: <5df21376-7dd1-bf81-8414-32a73cea45dd@google.com> <20220307183141.npa4627fpbsbgwvv@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220307183141.npa4627fpbsbgwvv@google.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2533B180011 X-Stat-Signature: n4d1znwjcn8sidqtm44ugmjn3d6xss71 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=beLTnCIR; spf=pass (imf16.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspam-User: X-HE-Tag: 1646743957-555235 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: On Mon 07-03-22 18:31:41, Shakeel Butt wrote: > On Mon, Mar 07, 2022 at 03:41:45PM +0100, Michal Hocko wrote: > > On Sun 06-03-22 15:11:23, David Rientjes wrote: > > [...] > > > Some questions to get discussion going: > > > > > > - Overall feedback or suggestions for the proposal in general? > > > Do we really need this interface? What would be usecases which cannot > > use an existing interfaces we have for that? Most notably memcg and > > their high limit? > > > Let me take a stab at this. The specific reasons why high limit is not a > good interface to implement proactive reclaim: > > 1) It can cause allocations from the target application to get > throttled. > > 2) It leaves a state (high limit) in the kernel which needs to be reset > by the userspace part of proactive reclaimer. > > If I remember correctly, Facebook actually tried to use high limit to > implement the proactive reclaim but due to exactly these limitations [1] > they went the route [2] aligned with this proposal. I do remember we have discussed this in the past. There were proposals for an additional limit to trigger a background reclaim [3] or to add a pressure based memcg knob [4]. For the nr_to_reclaim based interface there were some challenges outlined in that email thread. I do understand that practical experience could have confirmed or diminished those concerns. I am definitely happy to restart those discussion but it would be really great to summarize existing options and why they do not work in practice. It would be also great to mention why concerns about nr_to_reclaim based interface expressed in the past are not standing out anymore wrt. other proposals. > To further explain why the above limitations are pretty bad: The > proactive reclaimers usually use feedback loop to decide how much to > squeeze from the target applications without impacting their performance > or impacting within a tolerable range. The metrics used for the feedback > loop are either refaults or PSI and these metrics becomes messy due to > application getting throttled due to high limit. One thing is not really clear to me here. You are saying that the PSI/refaults are influenced by the throttling IIUC. Does that mean that your reclaimer is living outside of the controlled memcg? Or why does it make any difference who is reclaiming the memory from the the metrics POV? I do understand that you want to avoid throttling on the regular workload in that memcg and this is where the high limit comes short but the work has to be done by somebody, right? > For (2), the high limit interface is a very awkward interface to use to > do proactive reclaim. If the userspace proactive reclaimer fails/crashed > due to whatever reason during triggering the reclaim in an application, > it can leave the application in a bad state (memory pressure state and > throttled) for a long time. Fair enough. > [1] https://lore.kernel.org/all/20200928210216.GA378894@cmpxchg.org/ > [2] https://dl.acm.org/doi/10.1145/3503222.3507731 (Section 3.3) [3] http://lkml.kernel.org/r/20200922190859.GH12990@dhcp22.suse.cz resp. http://lkml.kernel.org/r/20200219181219.54356-1-hannes@cmpxchg.org/ [4] http://lkml.kernel.org/r/20200928210216.GA378894@cmpxchg.org -- Michal Hocko SUSE Labs