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 61614C369A2 for ; Thu, 10 Apr 2025 02:09:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4D142800C1; Wed, 9 Apr 2025 22:09:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFB3E2800C0; Wed, 9 Apr 2025 22:09:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC1FB2800C1; Wed, 9 Apr 2025 22:09:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AEBB52800C0 for ; Wed, 9 Apr 2025 22:09:36 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 086D81CDE19 for ; Thu, 10 Apr 2025 02:09:38 +0000 (UTC) X-FDA: 83316502836.04.3926015 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 3154D80009 for ; Thu, 10 Apr 2025 02:09:36 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=FThdxGyj; dmarc=none; spf=pass (imf30.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744250976; 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=uTQ5G+p2eXkfeQo4P8/+1nSipIxiOu5wCV+7GkyB8Vw=; b=GcFSHjk8LtXsJEeMsKIA3+wQ9MF94gwtmBwoenzXNPWMYaEKyMV6eB8QwXoTpbe+VV6fhC f1giCkf294Zez2vWp1o6znbnE43VQEvKpUNiiViudbIXLddPjiFt/fm7LIBbe8cPqF1TUk 1T1rJcafteKdFs0A04bMCendZrQW0v4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744250976; a=rsa-sha256; cv=none; b=Pxc5jKw9+ZgJ7PfZwnB+1W4SdPydJsFcEQ0Pc7neAK4rTjQkDEH9SGPEgvKL+frypTTDxM 3AV9VGJjr7pp9GBcnqtqVYl8RpRt6v0HKQAR7wklBoUvO3gU2BGKxdwY9l0uRjyR8jbZM7 E/zmZYBnFTI7+4BqrzGx1RfurKpB7w0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=FThdxGyj; dmarc=none; spf=pass (imf30.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E74E45C46C0; Thu, 10 Apr 2025 02:07:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ECC2C4CEE2; Thu, 10 Apr 2025 02:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1744250974; bh=vsazE7r5NTBPE2Muje7CVYR3FyILACBTq3Phk5+GYoc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FThdxGyjH6qfxb1s2aOzCMgKCE7KRlva3utdeLwr2AiVILt16rrA5/qK/Fy38x169 sDhj4fDttsoLJe0vm0vWfRTe1v/sMZAQmgNY6RkYJrv+Hs37Q4/j/4i+h+7tleTkj1 E/zth22DFMQLvxNRaGzuOYzmVR/4taGYyShgM0SE= Date: Wed, 9 Apr 2025 19:09:33 -0700 From: Andrew Morton To: Zhongkun He Cc: hannes@cmpxchg.org, mhocko@suse.com, yosry.ahmed@linux.dev, muchun.song@linux.dev, yuzhao@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 1/3] mm: add swappiness=max arg to memory.reclaim for only anon reclaim Message-Id: <20250409190933.3f08db6d6c1f13bc14a170f9@linux-foundation.org> In-Reply-To: <720e8e2c5b84efed5cf9980567794e7c799d179a.1744169302.git.hezhongkun.hzk@bytedance.com> References: <720e8e2c5b84efed5cf9980567794e7c799d179a.1744169302.git.hezhongkun.hzk@bytedance.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3154D80009 X-Stat-Signature: 58x4hgp5ph97hgaiuy9cqjapea7ydafe X-Rspam-User: X-HE-Tag: 1744250976-803097 X-HE-Meta: U2FsdGVkX1+i+trpyd0AiXNpoCQEpnWqjefpOUxnYehKTzsDiG4WZrAfk5iT6LHjEAGqvo+d/XCx8a2k7z3ZQNm3+7w5nXE0VbMU1/WV+JhOWTRHoffUv9pL0Uv2/nzr8Ptd2F0cd9k39FoFoqYTOHsS1OJB5PVn+9sPEI653+TcNbPkLH4fSnV6/H4wBpDHne9f/QKi3EnY6HzRqYX24rBo4yWWGIDFJMfkUyhA+i5Ay80+vNKx9Pc6eyppkYTrGo1T66/w4VRAQSZ86K8aN4fmui0JwB8rVYznnqPQZHmqJ0FF1aGqn9elQXqCn1W4fUVKglUhPIYUUMw/WuZq1I8gZLrUzrqNieolpQpT6uTWZaYUnlJK98Kctyg/T/87W4wc3wgmCiIYK5P7rkKQvg/ZS4QBQd8m+NxfeUH7DTI3myKZ3YcwvRbPDOxG+SZEPxlW3pFey5gcJ/G0/65ypr65VDgLl596HIapkrANJqQo/x1FeAp+fEO9UT1o69owIg/HyUNr1d7E3yggQz/CFccGY5608PqcYE2/xVnvKVArW1hzYicSB4pM4LOuWvkQmuwF2Nf5GRY0rWiw2IYpojinNX7onjdIRGHGoIprEGtrEHG10fnnyEZQTewKl5LWEpUJZuApThV+qf3u5iuTdqjyrV5fmkY2mximr/ZO+CLegHteTS/s1wDYmDkAU3QSBU3LtRpM6JHwnT9ExVGLIHWbDYsWSe66Gh6tluVWqL1aPlNR1Egk/mmmAUSvBL87+r29b51a/QhYzxDLnXL7tNKzfhRzCbPmbSQyElNgHaAubDpZEYdkUW94y1vK8f/aY1o9+fsBzz0ISSadVCFIYYKNqXKTu1NSzHUHKOVUsFDuRNn5gKphM8ElavHtpBIzSVeNrdLIhRsDOCfInVsSUdksgcG/3FkwOubEGqR9af5hf+RVOHNyg6fGhAq8E1LLhNACMlzo6yy2cVL8t0r vByWICeY wj/jiyChUEd28NxjUIdwyB0S4j4pWzRE7qSywNvjX3Z/pS6+AIgjDRzH8QXzoPAaFzII2GCqwZEMqJuJi1VsnU2t5RE2293n9Cg2iFAGYfyJRR56P5PtT5OsFfzQyLbKiPF6dpVdbA6Htr3vps44s6Y2aIbQMwpcub8o6Q1IPn5D7nrMRi1ZA09l+l8POezUE+TlcRD+654ueJSHL7dftBeMwyxFZq93Hpzx4q4QpG3pJQUZ/fbgG/c6UWHydZi9ttPZr+FmZN63yDMS4Tbls1oSl+w== 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 Wed, 9 Apr 2025 15:06:18 +0800 Zhongkun He wrote: > With this patch 'commit <68cd9050d871> ("mm: add swappiness= arg to > memory.reclaim")', we can submit an additional swappiness= argument > to memory.reclaim. It is very useful because we can dynamically adjust > the reclamation ratio based on the anonymous folios and file folios of > each cgroup. For example,when swappiness is set to 0, we only reclaim > from file folios. > > However,we have also encountered a new issue: when swappiness is set to > the MAX_SWAPPINESS, it may still only reclaim file folios. > > So, we hope to add a new arg 'swappiness=max' in memory.reclaim where > proactive memory reclaim only reclaims from anonymous folios when > swappiness is set to max. The swappiness semantics from a user > perspective remain unchanged. > > For example, something like this: > > echo "2M swappiness=max" > /sys/fs/cgroup/memory.reclaim > > will perform reclaim on the rootcg with a swappiness setting of 'max' (a > new mode) regardless of the file folios. Users have a more comprehensive > view of the application's memory distribution because there are many > metrics available. For example, if we find that a certain cgroup has a > large number of inactive anon folios, we can reclaim only those and skip > file folios, because with the zram/zswap, the IO tradeoff that > cache_trim_mode or other file first logic is making doesn't hold - > file refaults will cause IO, whereas anon decompression will not. > > With this patch, the swappiness argument of memory.reclaim has a new > mode 'max', means reclaiming just from anonymous folios both in traditional > LRU and MGLRU. > > ... > > --- a/Documentation/admin-guide/cgroup-v2.rst > +++ b/Documentation/admin-guide/cgroup-v2.rst > @@ -1348,6 +1348,9 @@ The following nested keys are defined. > same semantics as vm.swappiness applied to memcg reclaim with > all the existing limitations and potential future extensions. > > + The valid range for swappiness is [0-200, max], setting > + swappiness=max exclusively reclaims anonymous memory. Being able to assign either a number or a string feels a bit weird. Usually we use something like "-1" for a hack like this. eg, NUMA_NO_NODE. Perhaps we just shouldn't overload swappiness like this. Add a new tunable (swappiness_mode?) which can override the swappiness setting. I guess it doesn't matter much. We're used to adding messy interfaces ;)