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 D20E3C4332F for ; Tue, 13 Dec 2022 08:33:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 217C28E0003; Tue, 13 Dec 2022 03:33:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C6208E0002; Tue, 13 Dec 2022 03:33:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08E958E0003; Tue, 13 Dec 2022 03:33:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EF0F68E0002 for ; Tue, 13 Dec 2022 03:33:28 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C5AB780223 for ; Tue, 13 Dec 2022 08:33:28 +0000 (UTC) X-FDA: 80236618896.10.C5731F3 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf25.hostedemail.com (Postfix) with ESMTP id 09491A001F for ; Tue, 13 Dec 2022 08:33:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=uESRpWwH; spf=pass (imf25.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670920407; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fBioyvD4vd7/35z0fjI4+FQj2kTkuRA99KUFhbZ2zqg=; b=hV2LDsgqd10uhHDl8FB25vWGVuborzoh8eTw7hVPNu2jeSw8gd26aQBd8n6TEMPtS2cAx0 75zD5ERds2a6bV159rXZIduv17jCM7lHtTyEEHBYlw391DOyH+SzclvcxLgVe84eQ8YM7I uJgMMl4CAjfDakqel0C6MfIyFEWLAgE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=uESRpWwH; spf=pass (imf25.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670920407; a=rsa-sha256; cv=none; b=d2K4bEe37BwYmRWqVRlCZtvDJtambTarmtbnzqCFCiIA1z/qWzRxUhprfAOEKAxxEN719K gouUqNRMJQXrvoSDdkul2kYfjwMkkWhjNAGRWUsEKadfqwHU4kkXXfD1AFbd0e43fXUEIn 0SQbGb3fQUvG4Pp5FtjLuVjn05x84AQ= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6E4411FDCF; Tue, 13 Dec 2022 08:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1670920405; 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=fBioyvD4vd7/35z0fjI4+FQj2kTkuRA99KUFhbZ2zqg=; b=uESRpWwH5XHQurdOjS16YAX9ouQKJDmxraaJbjVNNzt5yGgzi9VCBjM7Xsz+SJ/16Paho+ NYeNI9T0S+fxT0pBvaSm7hsUKKbSzk2kMIFbTfq4A6SCdiMgIRHU87BX1boslH+MZmZTfP 8pIFhUoiqU85Vjavt2/xU2nbuRHwxP0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4AE16138EE; Tue, 13 Dec 2022 08:33:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id svfoD9U4mGPWIgAAMHmgww (envelope-from ); Tue, 13 Dec 2022 08:33:25 +0000 Date: Tue, 13 Dec 2022 09:33:24 +0100 From: Michal Hocko To: Mina Almasry Cc: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Huang Ying , Yang Shi , Yosry Ahmed , weixugc@google.com, fvdl@google.com, bagasdotme@gmail.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3] mm: Add nodes= arg to memory.reclaim Message-ID: References: <20221202223533.1785418-1-almasrymina@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 09491A001F X-Stat-Signature: fp53fom4617dqe4zcisztf7q9ratxd8e X-Rspam-User: X-HE-Tag: 1670920406-286053 X-HE-Meta: U2FsdGVkX181+dwdfOuEMGq4ZS3k8Kar2uj2nbb0YebRhiHXABKlkcrHFsqio8sR6WeeqA5Rd2fMYhNOQNYrw4EsAIGwlRbv/l28ZPGDXt3zpuxdB4ub+yoV3EUUjRlNGN7gs3DcQqxQI+eBPPZLX2fPx3BI3h1aHBplUD419kIoJU3pC0zG1T5/D531x2HFuBHfC1YywP12OzkdyRS7U3iyT93HO16+pyYP131dichXQ0wIO8Y68FR1p42CgIJlhzG63aOTKYR/B6Z7suYtfK9ZepIvW+HoNFGiFmeXKqWUmUYLFbPlIxLxMOZWHhVChv9V30v7p4+KfI06MJHzf/tTBh5bQzG3jI6d8CrhqqaBCMrlj+lX5Khc5hk+xPyEoHs1+paGWUEU+Tgp9NDcJJ6X+BXaFXYOCDSF61jYNOOjHJd1VTlTvwvz0jIKQFcl/rx+NUiGDt8Un5THjttHTGSIGpvZAKy69J2sDsCeiJFnCYbknYWvYpi+NmM76CWfX8Ja4i59S+ns1bDT0mp3v9QnT3+vqvY1huTC74KdZlreKQAoHDMlenwy+Bo1ikRzwkAo31Ti/qqBalNKndJMIWZbAs/brb2RQMxuUqCHaG5o+Nz6LVZZweG1VdjsbniAwf+QIete+dTPPZmqwpG+/UcCGQNHGVmFhy9dHBMeynGtnBXCRZWMQz4UVWKyXMKbRmHMghJZfuCyjuOmF0uvckaDXCP4x+6fZQrrm1dSXiD7HfHD2EsSIzaeZcmjxsttkjh/StNkPQVurL8vYYcdSN8wQ1uw+Q42/ZwJZ2ZYoG+0FEMAVUAOLZkj82OL75uB7yAi75IgQIfz9N/DDtE73xgl3st1/R3yVxTjFcmpne67ZnypyQVAzw== 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 12-12-22 16:54:27, Mina Almasry wrote: > On Mon, Dec 12, 2022 at 12:55 AM Michal Hocko wrote: [...] > > Let me summarize my main concerns here as well. The proposed > > implementation doesn't apply the provided nodemask to the whole reclaim > > process. This means that demotion can happen outside of the mask so the > > the user request cannot really control demotion targets and that limits > > the interface should there be any need for a finer grained control in > > the future (see an example in [2]). > > Another problem is that this can limit future reclaim extensions because > > of existing assumptions of the interface [3] - specify only top-tier > > node to force the aging without actually reclaiming any charges and > > (ab)use the interface only for aging on multi-tier system. A change to > > the reclaim to not demote in some cases could break this usecase. > > > > I think this is correct. My use case is to request from the kernel to > do demotion without reclaim in the cgroup, and the reason for that is > stated in the commit message: > > "Reclaim and demotion incur different latency costs to the jobs in the > cgroup. Demoted memory would still be addressable by the userspace at > a higher latency, but reclaimed memory would need to incur a > pagefault." > > For jobs of some latency tiers, we would like to trigger proactive > demotion (which incurs relatively low latency on the job), but not > trigger proactive reclaim (which incurs a pagefault). I initially had > proposed a separate interface for this, but Johannes directed me to > this interface instead in [1]. In the same email Johannes also tells > me that meta's reclaim stack relies on memory.reclaim triggering > demotion, so it seems that I'm not the first to take a dependency on > this. Additionally in [2] Johannes also says it would be great if in > the long term reclaim policy and demotion policy do not diverge. I do recognize your need to control the demotion but I argue that it is a bad idea to rely on an implicit behavior of the memory reclaim and an interface which is _documented_ to primarily _reclaim_ memory. Really, consider that the current demotion implementation will change in the future and based on a newly added heuristic memory reclaim or compression would be preferred over migration to a different tier. This might completely break your current assumptions and break your usecase which relies on an implicit demotion behavior. Do you see that as a potential problem at all? What shall we do in that case? Special case memory.reclaim behavior? Now to your specific usecase. If there is a need to do a memory distribution balancing then fine but this should be a well defined interface. E.g. is there a need to not only control demotion but promotions as well? I haven't heard anybody requesting that so far but I can easily imagine that like outsourcing the memory reclaim to the userspace someone might want to do the same thing with the numa balancing because $REASONS. Should that ever happen, I am pretty sure hooking into memory.reclaim is not really a great idea. See where I am coming from? > [1] https://lore.kernel.org/linux-mm/Y35fw2JSAeAddONg@cmpxchg.org/ > [2] https://lore.kernel.org/linux-mm/Y36fIGFCFKiocAd6@cmpxchg.org/ -- Michal Hocko SUSE Labs