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 C8F8EC4167B for ; Wed, 8 Nov 2023 07:38:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A9998D00A0; Wed, 8 Nov 2023 02:38:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 45A778D000F; Wed, 8 Nov 2023 02:38:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3218E8D00A0; Wed, 8 Nov 2023 02:38:02 -0500 (EST) 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 20A388D000F for ; Wed, 8 Nov 2023 02:38:02 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E395D80C14 for ; Wed, 8 Nov 2023 07:38:01 +0000 (UTC) X-FDA: 81433983162.24.04D0880 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by imf03.hostedemail.com (Postfix) with ESMTP id EFA3920003 for ; Wed, 8 Nov 2023 07:37:58 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=hdxTYGew; spf=pass (imf03.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699429080; 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=+hHLCsPZz+aL/n5SAMv10mGzJvX5LGFVzVHzeja+PR4=; b=QWNIPICmW3sNSJE1hURV8Ywe8KkISW8BPIB75zUHKeMZU53Uz8+H6HI2gjjCVjpjz9ar0P FfYWr3XIT4VVaMZIw7hqDPzbbD/ExA8szIEi5OzLvhO5e5uIxs2AMKABWrOgWwjvAv/NOI zT7k0sKhFbs7Hf6WP5V8AVbZirUUqtM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699429080; a=rsa-sha256; cv=none; b=7qwqv4GXuGY4nQGxR9WRqFnJNkcz8yrYfUDMY2HmLk3/a1nNRnufG1v9PR/1tTC6sjovso QhU8c1ijutgH8zwF3KCO9RFXBnN7J60QXIAMT9BAyjDlK1NG3B2GUX+dHjWtLRB8iQ/1z7 ZRVsLTO7zyOzTg7oQqLK52U7rRqFXSI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=hdxTYGew; spf=pass (imf03.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699429079; x=1730965079; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=TpGd3HGFIDIBnfCapFtkocNEgRH8g9vMjuBQGrRQR0M=; b=hdxTYGewPPq8nKfRQHb7Q1Kpk/wXXfQnruH4MEEfdiGtQYp7xFSHfzju /gC6t4LBi3Ifqls0+V7EyB93OcAlm/UPyMZhnAk15uR/58PeyeX3Dvk1J yLwPHdeLGenjWvlzr0oEf5womYLWM0Og5JuqUgb5uMviCcnsFMS2+uUgR ppVBjRXOIs+Y+CuRbtBZ1zWoUKsOHws/zPnBEPVcyIsMmGEwsy7B+BuCk 0Gv14oGVQownNV88PKrzHOKtMooCD1kZjH35RA63lUB6c5ScrAdW4awMM EcrjHQGcf2cgmCGpG+1plcoBhZ2Wgdt/8mH4TUHTtNYeDKJI8Ol8g4Cl3 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="454012834" X-IronPort-AV: E=Sophos;i="6.03,285,1694761200"; d="scan'208";a="454012834" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2023 23:37:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="853651335" X-IronPort-AV: E=Sophos;i="6.03,285,1694761200"; d="scan'208";a="853651335" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2023 23:37:50 -0800 From: "Huang, Ying" To: Huan Yang Cc: Tejun Heo , Zefan Li , "Johannes Weiner" , Jonathan Corbet , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , David Hildenbrand , "Matthew Wilcox" , Kefeng Wang , Peter Xu , "Vishal Moola (Oracle)" , Yosry Ahmed , "Liu Shixin" , Hugh Dickins , , , , , Subject: Re: [RFC 0/4] Introduce unbalance proactive reclaim In-Reply-To: <20231108065818.19932-1-link@vivo.com> (Huan Yang's message of "Wed, 8 Nov 2023 14:58:11 +0800") References: <20231108065818.19932-1-link@vivo.com> Date: Wed, 08 Nov 2023 15:35:50 +0800 Message-ID: <87v8ack889.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: EFA3920003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: bng7krqq87airq3e4p56g9to91c7dx37 X-HE-Tag: 1699429078-334532 X-HE-Meta: U2FsdGVkX18Rkdv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05NLGPKOKpaN4eS5+BHct7Y8sH+E5/soncTZUblsECUmrxbOuXPNXf+hkDpgp9WMc8zCiYTuZy8pk3EpqmMwHMq1ZFB8PToLszXI74E+nmqRMcIPVQJaJfR3q/eV1AzxCyKdAl+4gz0hK2FTFXglnVw9uNArUw7moIXJAUGw== 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: Huan Yang writes: > In some cases, we need to selectively reclaim file pages or anonymous > pages in an unbalanced manner. > > For example, when an application is pushed to the background and frozen, > it may not be opened for a long time, and we can safely reclaim the > application's anonymous pages, but we do not want to touch the file pages. > > This patchset extends the proactive reclaim interface to achieve > unbalanced reclamation. Users can control the reclamation tendency by > inputting swappiness under the original interface. Specifically, users > can input special values to extremely reclaim specific pages. >From mem_cgroup_swappiness(), cgroupv2 doesn't have per-cgroup swappiness. So you need to add that firstly? > Example: > echo "1G" 200 > memory.reclaim (only reclaim anon) > echo "1G" 0 > memory.reclaim (only reclaim file) > echo "1G" 1 > memory.reclaim (only reclaim file) > > Note that when performing unbalanced reclamation, the cgroup swappiness > will be temporarily adjusted dynamically to the input value. Therefore, > if the cgroup swappiness is further modified during runtime, there may > be some errors. If cgroup swappiness will be adjusted temporarily, why not just change it via a script before/after proactive reclaiming? > However, this is acceptable because the interface is dynamically called > by the user and the timing should be controlled by the user. > > This patchset did not implement the type-based reclamation as expected > in the documentation.(anon or file) Because in addition to extreme unbalanced > reclamation, this patchset can also adapt to the reclamation tendency > allocated according to swappiness, which is more flexible. > > Self test > ======== > After applying the following patches and myself debug patch, my self-test > results are as follows: > > 1. LRU test > =========== > a. Anon unbalance reclaim > ``` > cat memory.stat | grep anon > inactive_anon 7634944 > active_anon 7741440 > > echo "200M" 200 > memory.reclaim > > cat memory.stat | grep anon > inactive_anon 0 > active_anon 0 > > cat memory.reclaim_stat_summary(self debug interface) > [22368]sh total reclaimed 0 file, 3754 anon, covered item=0 > ``` > > b. File unbalance reclaim > ``` > cat memory.stat | grep file > inactive_file 82862080 > active_file 48664576 > > echo "100M" 0 > memory.reclaim > cat memory.stat | grep file > inactive_file 34164736 > active_file 18370560 > > cat memory.reclaim_stat_summary(self debug interface) > [22368]sh total reclaimed 13732 file, 0 anon, covered item=0 > ``` > > 2. MGLRU test > ============ > a. Anon unbalance reclaim > ``` > echo y > /sys/kernel/mm/lru_gen/enabled > cat /sys/kernel/mm/lru_gen/enabled > 0x0003 > > cat memory.stat | grep anon > inactive_anon 17653760 > active_anon 1740800 > > echo "100M" 200 > memory.reclaim > > cat memory.reclaim_stat_summary > [8251]sh total reclaimed 0 file, 5393 anon, covered item=0 > ``` > > b. File unbalance reclaim > ``` > cat memory.stat | grep file > inactive_file 17858560 > active_file 5943296 > > echo "100M" 0 > memory.reclaim > > cat memory.stat | grep file > inactive_file 491520 > active_file 2764800 > cat memory.reclaim_stat_summary > [8251]sh total reclaimed 5230 file, 0 anon, covered item=0 > ``` > > Patch 1-3 implement the functionality described above. > Patch 4 aims to implement proactive reclamation to the cgroupv1 interface > for use on Android. > > Huan Yang (4): > mm: vmscan: LRU unbalance cgroup reclaim > mm: multi-gen LRU: MGLRU unbalance reclaim > mm: memcg: implement unbalance proactive reclaim > mm: memcg: apply proactive reclaim into cgroupv1 We will not add new features to cgroupv1 in upstream. > .../admin-guide/cgroup-v1/memory.rst | 38 +++++- > Documentation/admin-guide/cgroup-v2.rst | 16 ++- > include/linux/swap.h | 1 + > mm/memcontrol.c | 126 ++++++++++++------ > mm/vmscan.c | 38 +++++- > 5 files changed, 169 insertions(+), 50 deletions(-) -- Best Regards, Huang, Ying