[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200929235920.537849-1-guro@fb.com>
Date: Tue, 29 Sep 2020 16:59:16 -0700
From: Roman Gushchin <guro@...com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: Shakeel Butt <shakeelb@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
<kernel-team@...com>, Roman Gushchin <guro@...com>
Subject: [PATCH v3 0/4] mm: allow mapping accounted kernel pages to userspace
Currently a non-slab kernel page which has been charged to a memory
cgroup can't be mapped to userspace. The underlying reason is simple:
PageKmemcg flag is defined as a page type (like buddy, offline, etc),
so it takes a bit from a page->mapped counter. Pages with a type set
can't be mapped to userspace.
But in general the kmemcg flag has nothing to do with mapping to
userspace. It only means that the page has been accounted by the page
allocator, so it has to be properly uncharged on release.
Some bpf maps are mapping the vmalloc-based memory to userspace, and
their memory can't be accounted because of this implementation detail.
This patchset removes this limitation by moving the PageKmemcg flag
into one of the free bits of the page->mem_cgroup pointer. Also it
formalizes all accesses to the page->mem_cgroup and page->obj_cgroups
using new helpers, adds several checks and removes a couple of obsolete
functions. As the result the code became more robust with fewer
open-coded bits tricks.
v3:
- READ_ONCE() in page_memcg_rcu() and page_objcgs*(), by Johannes
- many cosmetic changes and renamings, by Johannes
v2:
- fixed a bug in page_obj_cgroups_check()
- moved some definitions between patches, by Shakeel
- dropped the memcg flags mutual exclusion requirement, by Shakeel
v1:
- added and fixed comments, by Shakeel
- added some VM_BUG_ON() checks
- fixed the debug output format of page->memcg_data
Roman Gushchin (4):
mm: memcontrol: use helpers to access page's memcg data
mm: memcontrol/slab: use helpers to access slab page's memcg_data
mm: introduce page memcg flags
mm: convert page kmemcg type to a page memcg flag
fs/buffer.c | 2 +-
fs/iomap/buffered-io.c | 2 +-
include/linux/memcontrol.h | 294 ++++++++++++++++++++++++++++++-
include/linux/mm.h | 22 ---
include/linux/mm_types.h | 5 +-
include/linux/page-flags.h | 11 +-
include/trace/events/writeback.h | 2 +-
kernel/fork.c | 7 +-
mm/debug.c | 4 +-
mm/huge_memory.c | 4 +-
mm/memcontrol.c | 139 +++++++--------
mm/page_alloc.c | 6 +-
mm/page_io.c | 6 +-
mm/slab.h | 38 +---
mm/workingset.c | 2 +-
15 files changed, 378 insertions(+), 166 deletions(-)
--
2.26.2
Powered by blists - more mailing lists