linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/4] mm: allow mapping accounted kernel pages to userspace
@ 2020-09-22 20:36 Roman Gushchin
  2020-09-22 20:36 ` [PATCH v1 1/4] mm: memcontrol: use helpers to access page's memcg data Roman Gushchin
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Roman Gushchin @ 2020-09-22 20:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Shakeel Butt, Johannes Weiner, Michal Hocko, linux-kernel,
	linux-mm, kernel-team, Roman Gushchin

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.

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       | 244 +++++++++++++++++++++++++++++--
 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                  | 135 ++++++++---------
 mm/migrate.c                     |   2 +-
 mm/page_alloc.c                  |   6 +-
 mm/page_io.c                     |   4 +-
 mm/slab.h                        |  28 +---
 mm/workingset.c                  |   6 +-
 16 files changed, 318 insertions(+), 166 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-09-25 18:09 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-22 20:36 [PATCH v1 0/4] mm: allow mapping accounted kernel pages to userspace Roman Gushchin
2020-09-22 20:36 ` [PATCH v1 1/4] mm: memcontrol: use helpers to access page's memcg data Roman Gushchin
2020-09-24 19:45   ` Johannes Weiner
2020-09-24 20:27     ` Roman Gushchin
2020-09-25 17:39       ` Johannes Weiner
2020-09-22 20:36 ` [PATCH v1 2/4] mm: memcontrol/slab: use helpers to access slab page's memcg_data Roman Gushchin
2020-09-24 19:53   ` Johannes Weiner
2020-09-24 20:29     ` Roman Gushchin
2020-09-22 20:36 ` [PATCH v1 3/4] mm: introduce page memcg flags Roman Gushchin
2020-09-24  7:03   ` Shakeel Butt
2020-09-24 17:05     ` Roman Gushchin
2020-09-24 20:01   ` Johannes Weiner
2020-09-24 20:39     ` Roman Gushchin
2020-09-25 18:07       ` Johannes Weiner
2020-09-24 20:05   ` Johannes Weiner
2020-09-22 20:37 ` [PATCH v1 4/4] mm: convert page kmemcg type to a page memcg flag Roman Gushchin
2020-09-24  7:06   ` Shakeel Butt
2020-09-24 20:14   ` Johannes Weiner
2020-09-24 20:42     ` Roman Gushchin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).