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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF923C433C1 for ; Tue, 30 Mar 2021 10:20:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2F26E619AA for ; Tue, 30 Mar 2021 10:20:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F26E619AA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ADF736B0071; Tue, 30 Mar 2021 06:20:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB5F86B007D; Tue, 30 Mar 2021 06:20:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 908DA6B0081; Tue, 30 Mar 2021 06:20:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 735416B0071 for ; Tue, 30 Mar 2021 06:20:36 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3578E8249980 for ; Tue, 30 Mar 2021 10:20:36 +0000 (UTC) X-FDA: 77976146472.09.2988E16 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf24.hostedemail.com (Postfix) with ESMTP id 94681A0000FC for ; Tue, 30 Mar 2021 10:20:30 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id v10so6483545pfn.5 for ; Tue, 30 Mar 2021 03:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TU4CV4YLVkFbwG4kyfiazu8+2NmeG1063RTT/LGVd6w=; b=0pg6UFsP/hE+myqG0q7Cv0BwoV83P31hKY44lzq2US9m0TbommXHTAt7kYU3yx+U5q 3TuSpxvEakTlPhIg+rmECo2YBk72hz8mDex4yNJNgZOMrWq6+Kui9Llw9SgEvaHlvXpy sXgJfeRGV4Wp+gbeagkvkvYUECqRn+eVv6LTDcBK8Foh8TgwPenVSb15OLdpkUZrWuHN tDyAiSX8TjCzKmkt+clyuNxagJ8Dg3fMGx90TVnwDmuB8Z/cwXqEv6wFMOfo4ENq/Hp+ QMS8pCd5Wi1WO9BqyYD/MZKIzhOSflUpKlVF0vSPMfP6N3QanFgIHTPnY5dt1Q+JAOrZ DFlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TU4CV4YLVkFbwG4kyfiazu8+2NmeG1063RTT/LGVd6w=; b=Wh6Wf4AWWhtY+DHrqcl3v3jHpRPFHLyMU3STA+K6+4WWhqlZ40VA/L8JAGt2hhv57H njDV2iy5ZqYzxyL0lWLJrDUOWOXZNAueZn5/HyuFuWbmC/0n/4DvEa1muzk1TJqJ9giI pmC6VaQNZ9YzRyR2/Ft7DrdjQXXGEf4Su8EgL13HX62lU3kytw7s+FVz5UqoThRulHOU /iygBFPZ4FgX6/e4GNevltxkZJuqCV2Ajggs7zNjgxSeHYIfkPb6+Z1Zs20suZARuIcJ TbAlsZGmFH566Mh0usSCqGpIiqhWX5pU7+tz+llLJ2njFXjiPvUxHzg67YSlPV7BosUq EhcQ== X-Gm-Message-State: AOAM532R7NTLpIGoXDXxZmd/HXrnOuej7jwUT3vNUlghXaPfYx2fIG94 xcu5wolI9f33TdUsFDJpO3WZBA== X-Google-Smtp-Source: ABdhPJyER9cwj4Z/xC/2DKZfUBiRyk4g6KI/BsbAEu6XMj4TJnpWHTAL83PIbQsIvialX253VaTlng== X-Received: by 2002:a65:40c7:: with SMTP id u7mr11924136pgp.29.1617099632791; Tue, 30 Mar 2021 03:20:32 -0700 (PDT) Received: from localhost.localdomain ([2408:8445:ad30:68d8:c87f:ca1b:dc00:4730]) by smtp.gmail.com with ESMTPSA id k10sm202259pfk.205.2021.03.30.03.20.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Mar 2021 03:20:32 -0700 (PDT) From: Muchun Song To: guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, shakeelb@google.com, vdavydov.dev@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, Muchun Song Subject: [RFC PATCH 00/15] Use obj_cgroup APIs to charge the LRU pages Date: Tue, 30 Mar 2021 18:15:16 +0800 Message-Id: <20210330101531.82752-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 X-Rspamd-Queue-Id: 94681A0000FC X-Stat-Signature: cdig4o69knjez35sjr84huqaomtxqzwb X-Rspamd-Server: rspam02 Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-pf1-f177.google.com; client-ip=209.85.210.177 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617099630-147718 Content-Transfer-Encoding: quoted-printable 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: Since the following patchsets applied. All the kernel memory are charged with the new APIs of obj_cgroup. [v17,00/19] The new cgroup slab memory controller [v5,0/7] Use obj_cgroup APIs to charge kmem pages But user memory allocations (LRU pages) pinning memcgs for a long time - it exists at a larger scale and is causing recurring problems in the real world: page cache doesn't get reclaimed for a long time, or is used by th= e second, third, fourth, ... instance of the same job that was restarted in= to a new cgroup every time. Unreclaimable dying cgroups pile up, waste memor= y, and make page reclaim very inefficient. We can convert LRU pages and most other raw memcg pins to the objcg direc= tion to fix this problem, and then the LRU pages will not pin the memcgs. This patchset aims to make the LRU pages to drop the reference to memory cgroup by using the APIs of obj_cgroup. Finally, we can see that the numb= er of the dying cgroups will not increase if we run the following test scrip= t. ```bash #!/bin/bash cat /proc/cgroups | grep memory cd /sys/fs/cgroup/memory for i in range{1..500} do mkdir test echo $$ > test/cgroup.procs sleep 60 & echo $$ > cgroup.procs echo `cat test/cgroup.procs` > cgroup.procs rmdir test done cat /proc/cgroups | grep memory ``` Patch 1 aims to fix page charging in page replacement. Patch 2-5 are code cleanup and simplification. Patch 6-15 convert LRU pages pin to the objcg direction. Muchun Song (15): mm: memcontrol: fix page charging in page replacement mm: memcontrol: bail out early when !mm in get_mem_cgroup_from_mm mm: memcontrol: remove the pgdata parameter of mem_cgroup_page_lruvec mm: memcontrol: use lruvec_memcg in lruvec_holds_page_lru_lock mm: memcontrol: simplify the logic of objcg pinning memcg mm: memcontrol: move the objcg infrastructure out of CONFIG_MEMCG_KMEM mm: memcontrol: introduce compact_lock_page_lruvec_irqsave mm: memcontrol: make lruvec lock safe when the LRU pages reparented mm: thp: introduce lock/unlock_split_queue{_irqsave}() mm: thp: make deferred split queue lock safe when the LRU pages reparented mm: memcontrol: make all the callers of page_memcg() safe mm: memcontrol: introduce memcg_reparent_ops mm: memcontrol: use obj_cgroup APIs to charge the LRU pages mm: memcontrol: rename {un}lock_page_memcg() to {un}lock_page_objcg() mm: lru: add VM_BUG_ON_PAGE to lru maintenance function Documentation/admin-guide/cgroup-v1/memory.rst | 2 +- fs/buffer.c | 13 +- fs/fs-writeback.c | 23 +- fs/iomap/buffered-io.c | 4 +- include/linux/memcontrol.h | 197 +++++---- include/linux/mm_inline.h | 6 + mm/compaction.c | 42 +- mm/filemap.c | 2 +- mm/huge_memory.c | 175 +++++++- mm/memcontrol.c | 578 +++++++++++++++++--= ------ mm/migrate.c | 4 + mm/page-writeback.c | 28 +- mm/page_io.c | 5 +- mm/rmap.c | 14 +- mm/swap.c | 7 +- mm/vmscan.c | 3 +- mm/workingset.c | 2 +- 17 files changed, 762 insertions(+), 343 deletions(-) --=20 2.11.0