From patchwork Thu Aug 29 10:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhongkun He X-Patchwork-Id: 13782954 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 2D4A3C8302B for ; Thu, 29 Aug 2024 10:19:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4DD56B00A7; Thu, 29 Aug 2024 06:19:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FDF76B00A8; Thu, 29 Aug 2024 06:19:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89F116B00A9; Thu, 29 Aug 2024 06:19:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6A4966B00A7 for ; Thu, 29 Aug 2024 06:19:34 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E82B7140422 for ; Thu, 29 Aug 2024 10:19:33 +0000 (UTC) X-FDA: 82504886226.06.E189545 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf09.hostedemail.com (Postfix) with ESMTP id 55C2B140017 for ; Thu, 29 Aug 2024 10:19:31 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=GCQIhXZF; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf09.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724926706; a=rsa-sha256; cv=none; b=2WtRzs+Xi1heCUM5w6UbqmSXvgzHUUsZULEGRrFK4tYqIzr6npwMrAKBQ1/9J0HcklRzsd EMNqUFEg145gBnbPymnesO51rvytjDzuXlzXIH/Bye0wl16zkvJMFSnvu7RMD3xibX3ExM vfuRLk/vq4a3OUxghK1R4JIyUMPTxg0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=GCQIhXZF; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf09.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724926706; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=FLZw23XkOzc6bRGw9yd5cNf3epruUgLmmmKcBkgtqCw=; b=ETGCFHoExyf6OeZe2T0PYreBK9dRoJIPv+mx+i5+zwdUuYnfLGzKzVT1S5GCOuO6pm2RY6 m78QM5BRt0dYSJPxgFnuHReSqNx8BkQ8IpOfKkmrxKe3hshKFIJWnXhJ19AtJbgK5i6PW3 VcAN4ROeX0wfE3G/QvPSs6vfbqCdxH8= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-70cec4aa1e4so330140b3a.1 for ; Thu, 29 Aug 2024 03:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1724926770; x=1725531570; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FLZw23XkOzc6bRGw9yd5cNf3epruUgLmmmKcBkgtqCw=; b=GCQIhXZFCuCev8mX9sEHzh5/stFGFbLtPeNBFNCQcoeqWDalwut9pfPrMYryshmDMT 4NTUwFuLWI9SFo/oaoXlzGGQOgNxn4+usybSbmY4RaRNPjW15vRyzegDZEeea8NJPoWA I9q+fJzAmeaNl00Z7gvXNfwIFQM5M0sLS+29Xxz4b3zoDt2TCL5sd6lQPhp67U0J46l+ wV+qKeiD7MaAzx6tw8QKIsYB91dKWpPpiFZjdTLp5wrDEbtiT1+uuJ8PvokmuxJHdr1k s9JCXW9m9H328cU57AT4Gym4IdfmESYAOGMg9uq3mbn1sQEhBy8+OSLyusQlTEKpyjB5 7vdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724926770; x=1725531570; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FLZw23XkOzc6bRGw9yd5cNf3epruUgLmmmKcBkgtqCw=; b=OZS9IEXJ30bqwElkvVZQuDEnR3vNcEppgqubW9o+kHYqtAQPN6v4667MZGoqix+i+M FKz7CQI5uWoxX0nr4YcYSmFFSY95KXTRh4/qY/aagOaX91sLBj0dJkYhS5TxAqxfaEX4 KT7qvhlKqBPFmARW4HiJSj6Ig1CxNPEv+WnnCgB8Ds/MUD21UswCWAHRTz4xprNE1yz9 MOkfVvAyGjmarW/g2gIc1qZ3inHYJGxmbeby50tnTfR5TO4eFIv+fKMvDUTr0Zo9Qy/1 Y7vm3huryfxSDwevXfPziSXQwcCOLQC8EOiFFc1MdmySLTjE9D439fuzzmnrxAP5/xhB 6BfA== X-Forwarded-Encrypted: i=1; AJvYcCUSVJrth4rpvXZkcxNpN43bgoRaxl3QETkfiLKnaaZYAVXqACj6HCS//8YsAzbYEjVlgYuXfLLsQw==@kvack.org X-Gm-Message-State: AOJu0YzwtDCwj3n3UGziJs0KiMtBDlZoUV6NbQb3g+JjWOHQORR3BaZ2 AYgAsrLqKnGxz/EOdHW8tM9rs/LEqplTNifvSsTpIBGbe5RW9YMgzfsl7OBfDbI= X-Google-Smtp-Source: AGHT+IFIKkW/GME2WB37S6Icf1LvrURHazG/BMTTIoPk3O0B5HuY8rq4leOo17BgMXHb3gk5eadxCg== X-Received: by 2002:a05:6a20:e687:b0:1c0:e925:f3e1 with SMTP id adf61e73a8af0-1cce10f41f6mr2121458637.50.1724926769821; Thu, 29 Aug 2024 03:19:29 -0700 (PDT) Received: from n37-034-248.byted.org ([180.184.51.40]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d22e9d4ee3sm785119a12.83.2024.08.29.03.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 03:19:28 -0700 (PDT) From: Zhongkun He To: akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org Cc: roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, lizefan.x@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Zhongkun He Subject: [RFC PATCH 0/2] Add disable_unmap_file arg to memory.reclaim Date: Thu, 29 Aug 2024 18:19:16 +0800 Message-Id: <20240829101918.3454840-1-hezhongkun.hzk@bytedance.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 55C2B140017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: sknpbwzomog3bnxw61bs17rzhb8c53sa X-HE-Tag: 1724926771-710450 X-HE-Meta: U2FsdGVkX1/56sgiP7vQLEnXNtXIUskRHDkzdPvCybabKMQ4ZNdaCzIucu46jCx+o2Anc/DRhU8o57kXIYL4ZB4OvpihNxP3ezyWFnCuMnsUYHUHiTUufAtSr1D3onl8hQDxzrnMVKSy74f3Cqzrqdx4+FD5dm1muzEOuziv6MTFFGmkUMZQ2wtg/owBbX0kEMMyhbcALBn9utmy/tDaQ1IK9sWchdXpPMKG9a4PjdAbTNvioOg5Enh0xB9wDiZ2dtnofdpUdlWMttJ1XoDQ4h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=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This patch proposes augmenting the memory.reclaim interface with a disable_unmap_file argument that will skip the mapped pages in that reclaim attempt. For example: echo "2M disable_unmap_file" > /sys/fs/cgroup/test/memory.reclaim will perform reclaim on the test cgroup with no mapped file page. The memory.reclaim is a useful interface. We can carry out proactive memory reclaim in the user space, which can increase the utilization rate of memory. In the actual usage scenarios, we found that when there are sufficient anonymous pages, mapped file pages with a relatively small proportion would still be reclaimed. This is likely to cause an increase in refaults and an increase in task delay, because mapped file pages usually include important executable codes, data, and shared libraries, etc. According to the verified situation, if we can skip this part of the memory, the task delay will be reduced. IMO,it is difficult to balance the priorities of various pages in the kernel, there are too many scenarios to consider. However, for the scenario of proactive memory reclaim in user space, we can make a simple judgment in this case. Zhongkun He (2): mm: vmscan: modify the semantics of scan_control.may_unmap to UNMAP_ANON and UNMAP_FILE mm: memcg: add disbale_unmap_file arg to memory.reclaim include/linux/swap.h | 1 + mm/memcontrol.c | 9 ++++-- mm/vmscan.c | 65 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 59 insertions(+), 16 deletions(-)