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 8958DC4332F for ; Wed, 14 Dec 2022 10:23:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF0848E0005; Wed, 14 Dec 2022 05:23:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA1088E0002; Wed, 14 Dec 2022 05:23:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6A1E8E0005; Wed, 14 Dec 2022 05:23:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C3C658E0002 for ; Wed, 14 Dec 2022 05:23:36 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 798681C66BB for ; Wed, 14 Dec 2022 10:23:36 +0000 (UTC) X-FDA: 80240525232.10.D50E100 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf23.hostedemail.com (Postfix) with ESMTP id BE1EF140004 for ; Wed, 14 Dec 2022 10:23:34 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=IojBzwyz; spf=pass (imf23.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 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=1671013415; a=rsa-sha256; cv=none; b=DxZshepTRdSXKhiMU5cEFWqb/UPnPbzRt8smnI1CqdcoXC4JpnpXTKany3938TvE7dybAd YAoRkAd0f2kC+JmxOqqvw0BlpDzOSX6jklCq43F2YzDmROmGbjNn3EgNaCBp0FZFRWwNO4 8i68+kKw+Aqgs54padw724NuHtReF1Q= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=IojBzwyz; spf=pass (imf23.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 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=1671013415; 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=fxBVCTztKvCx7NZz2W8gthEPH9JUIWAZ4+V+PfsVmzY=; b=nLzDxEgSsjYI1hNWVqv1P7STKFIRVCDgswjnndq99kZQNPLcBINx+BHrHguT+B84p3VTI3 IbzIuB9Z0ZjzUnKU6gZrrBh83INr3tQFYGiOyRFLjone2zmUOQ+Ldx3kvVPaZUHQMr2ofY AEzY4f3uxGmg8LTeheNcukOptouXwuE= 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-out1.suse.de (Postfix) with ESMTPS id 73346220F3; Wed, 14 Dec 2022 10:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1671013413; 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=fxBVCTztKvCx7NZz2W8gthEPH9JUIWAZ4+V+PfsVmzY=; b=IojBzwyziVtYiucjSQDvGHnCXVjXg2p/sHVYk80E3xfs7e5jBbeS9JU65R1LNQ8A+RlA3V nVZqvAW9UjKHw/QmPgCvEjbeBUhDxCLc2YH+bnaeQwiWi1j0MPSlkXpy3rHQMIUkQMDreQ Z/LmeErn8iJyWo5NQRig0Hzxee4+ACc= 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 517C61333E; Wed, 14 Dec 2022 10:23:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XCt/ESWkmWMbHwAAMHmgww (envelope-from ); Wed, 14 Dec 2022 10:23:33 +0000 Date: Wed, 14 Dec 2022 11:23:32 +0100 From: Michal Hocko To: Mina Almasry Cc: Johannes Weiner , "Huang, Ying" , Tejun Heo , Zefan Li , Jonathan Corbet , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , 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> <87k02volwe.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BE1EF140004 X-Stat-Signature: ugangasotiofboq3uo86o3nrty9piayt X-HE-Tag: 1671013414-504761 X-HE-Meta: U2FsdGVkX18l/5rV40sAjJ9HtG0cu1AJQKSmXkqc5jH4QhsYpWud5XjvIMiGIjJWsYuZ0b2fceMUSwI5s1nu1zU2pOqwEwBEfCjtDag+dnQy80YZ4DrXxYcoh6GVG0ebkzaMdxpV4SRrjRLWWPn0jC8ztJ1+DwJppj1m/j8U+c3UGjK3suhnG8YUxwnpO20lRH7i2kV6lRBHoQV+5hdrD6OaRN4SVJ8QduqQUn75BKxzXcoklN3Cs2r35car09SvgZx4rePOSdMIURVfHUmgOKDLzWabPeoT/30LtAIPMpRXctOPWRa8zIYfqCRz5jsdLfPSltpDmHAAo6hSwlmjE/dS3Z7JzEy0d3GbU+V/vCE1IlFp8cBuiG4OjVGN7hx7PL7Dmcp6BjD4QB+p5sHPJTH712y8t8JgmEp9dZoxHF7hPm3D64JCRk0mqDOARPY61VyPY3IuYK/2wwwEbuMoyAv7rTH3/XdNUXcQHV9oUv03/FA0pk5cAFW/VY2jjYENztAzoTXGinFF3xLycfA22IyUTKPk0MOPFLSu8GclVVwz49w5hXXDoAwZHOBsqdewnZ0HnqMvyv379OwgBRBC9y0DYtICBmV8cy+cWIQGCF2FLt/jL31s6rYtowA8GS2uhYopjNvcHI/pIYe7BWTXcTumv+Z8GRkHwUrxlPmUtosh6esqmClxxfuFFoYYWH9pPRc5DqNuPR9DkfqyQAMvBTWsmeM508AozzqiH7/CcO3wHbJmxRLheBT4hjzgoYW1sC/Klf5uktxKkZNKU18LoH1WK2buVuXaJPi0CbiLwobUbj6NnHVOpykGYPyAF2A1a9NGkMYMrGtWg9GrN2TzKXy8oc+VZ625F5pEWaC9p48TfMWs3/zKcw== 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 Tue 13-12-22 11:29:45, Mina Almasry wrote: > On Tue, Dec 13, 2022 at 6:03 AM Michal Hocko wrote: > > > > On Tue 13-12-22 14:30:40, Johannes Weiner wrote: > > > On Tue, Dec 13, 2022 at 02:30:57PM +0800, Huang, Ying wrote: > > [...] > > > > After these discussion, I think the solution maybe use different > > > > interfaces for "proactive demote" and "proactive reclaim". That is, > > > > reconsider "memory.demote". In this way, we will always uncharge the > > > > cgroup for "memory.reclaim". This avoid the possible confusion there. > > > > And, because demotion is considered aging, we don't need to disable > > > > demotion for "memory.reclaim", just don't count it. > > > > > > Hm, so in summary: > > > > > > 1) memory.reclaim would demote and reclaim like today, but it would > > > change to only count reclaimed pages against the goal. > > > > > > 2) memory.demote would only demote. > > > > > If the above 2 points are agreeable then yes, this sounds good to me > and does address our use case. > > > > a) What if the demotion targets are full? Would it reclaim or fail? > > > > > Wei will chime in if he disagrees, but I think we _require_ that it > fails, not falls back to reclaim. The interface is asking for > demotion, and is called memory.demote. For such an interface to fall > back to reclaim would be very confusing to userspace and may trigger > reclaim on a high priority job that we want to shield from proactive > reclaim. But what should happen if the immediate demotion target is full but lower tiers are still usable. Should the first one demote before allowing to demote from the top tier? > > > 3) Would memory.reclaim and memory.demote still need nodemasks? > > memory.demote will need a nodemask, for sure. Today the nodemask would > be useful if there is a specific node in the top tier that is > overloaded and we want to reduce the pressure by demoting. In the > future there will be N tiers and the nodemask says which tier to > demote from. OK, so what is the exact semantic of the node mask. Does it control where to demote from or to or both? > I don't think memory.reclaim would need a nodemask anymore? At least I > no longer see the use for it for us. > > > > Would > > > they return -EINVAL if a) memory.reclaim gets passed only toptier > > > nodes or b) memory.demote gets passed any lasttier nodes? > > > > Honestly it would be great if memory.reclaim can force reclaim from a > top tier nodes. It breaks the aginig pipeline, yes, but if the user is > specifically asking for that because they decided in their usecase > it's a good idea then the kernel should comply IMO. Not a strict > requirement for us. Wei will chime in if he disagrees. That would require a nodemask to say which nodes to reclaim, no? The default behavior should be in line with what standard memory reclaim does. If the demotion is a part of that process so should be memory.reclaim part of it. If we want to have a finer control then a nodemask is really a must and then the nodemaks should constrain both agining and reclaim. > memory.demote returning -EINVAL for lasttier nodes makes sense to me. > > > I would also add > > 4) Do we want to allow to control the demotion path (e.g. which node to > > demote from and to) and how to achieve that? > > We care deeply about specifying which node to demote _from_. That > would be some node that is approaching pressure and we're looking for > proactive saving from. So far I haven't seen any reason to control > which nodes to demote _to_. The kernel deciding that based on the > aging pipeline and the node distances sounds good to me. Obviously > someone else may find that useful. Please keep in mind that the interface should be really prepared for future extensions so try to abstract from your immediate usecases. > > 5) Is the demotion api restricted to multi-tier systems or any numa > > configuration allowed as well? > > > > demotion will of course not work on single tiered systems. The > interface may return some failure on such systems or not be available > at all. Is there any strong reason for that? We do not have any interface to control NUMA balancing from userspace. Why cannot we use the interface for that purpose? -- Michal Hocko SUSE Labs