linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 0/2] Directed kmem charging
@ 2018-06-27 19:12 Shakeel Butt
  2018-06-27 19:12 ` [PATCH 1/2] fs: fsnotify: account fsnotify metadata to kmemcg Shakeel Butt
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Shakeel Butt @ 2018-06-27 19:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Johannes Weiner, Vladimir Davydov, Jan Kara,
	Greg Thelen, Amir Goldstein, Roman Gushchin, Alexander Viro,
	linux-kernel, cgroups, linux-fsdevel, linux-mm, Shakeel Butt

The Linux kernel's memory cgroup allows limiting the memory usage of
the jobs running on the system to provide isolation between the jobs.
All the kernel memory allocated in the context of the job and marked
with __GFP_ACCOUNT will also be included in the memory usage and be
limited by the job's limit.

The kernel memory can only be charged to the memcg of the process in
whose context kernel memory was allocated. However there are cases where
the allocated kernel memory should be charged to the memcg different
from the current processes's memcg. This patch series contains two such
concrete use-cases i.e. fsnotify and buffer_head.

The fsnotify event objects can consume a lot of system memory for large
or unlimited queues if there is either no or slow listener. The events
are allocated in the context of the event producer. However they should
be charged to the event consumer. Similarly the buffer_head objects can
be allocated in a memcg different from the memcg of the page for which
buffer_head objects are being allocated.

To solve this issue, this patch series introduces mechanism to charge
kernel memory to a given memcg. In case of fsnotify events, the memcg of
the consumer can be used for charging and for buffer_head, the memcg of
the page can be charged. For directed charging, the caller can use the
scope API memalloc_[un]use_memcg() to specify the memcg to charge for
all the __GFP_ACCOUNT allocations within the scope.

Shakeel Butt (2):
  fs: fsnotify: account fsnotify metadata to kmemcg
  fs, mm: account buffer_head to kmemcg

 fs/buffer.c                          | 15 ++++++-
 fs/notify/dnotify/dnotify.c          |  5 ++-
 fs/notify/fanotify/fanotify.c        | 17 ++++++--
 fs/notify/fanotify/fanotify_user.c   |  5 ++-
 fs/notify/group.c                    |  4 ++
 fs/notify/inotify/inotify_fsnotify.c | 15 ++++++-
 fs/notify/inotify/inotify_user.c     |  5 ++-
 include/linux/fsnotify_backend.h     | 12 ++++--
 include/linux/memcontrol.h           | 14 +++++++
 include/linux/sched.h                |  3 ++
 include/linux/sched/mm.h             | 41 +++++++++++++++++++
 kernel/fork.c                        |  3 ++
 mm/memcontrol.c                      | 60 ++++++++++++++++++++++++++--
 13 files changed, 182 insertions(+), 17 deletions(-)

-- 
2.18.0.rc2.346.g013aa6912e-goog

^ permalink raw reply	[flat|nested] 21+ messages in thread
* [PATCH v7 0/2] Directed kmem charging
@ 2018-06-25 23:06 Shakeel Butt
  2018-06-25 23:06 ` [PATCH 1/2] fs: fsnotify: account fsnotify metadata to kmemcg Shakeel Butt
  0 siblings, 1 reply; 21+ messages in thread
From: Shakeel Butt @ 2018-06-25 23:06 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Johannes Weiner, Vladimir Davydov, Jan Kara,
	Greg Thelen, Amir Goldstein, Roman Gushchin, Alexander Viro,
	linux-kernel, cgroups, linux-fsdevel, linux-mm, Shakeel Butt

The Linux kernel's memory cgroup allows limiting the memory usage of
the jobs running on the system to provide isolation between the jobs.
All the kernel memory allocated in the context of the job and marked
with __GFP_ACCOUNT will also be included in the memory usage and be
limited by the job's limit.

The kernel memory can only be charged to the memcg of the process in
whose context kernel memory was allocated. However there are cases where
the allocated kernel memory should be charged to the memcg different
from the current processes's memcg. This patch series contains two such
concrete use-cases i.e. fsnotify and buffer_head.

The fsnotify event objects can consume a lot of system memory for large
or unlimited queues if there is either no or slow listener. The events
are allocated in the context of the event producer. However they should
be charged to the event consumer. Similarly the buffer_head objects can
be allocated in a memcg different from the memcg of the page for which
buffer_head objects are being allocated.

To solve this issue, this patch series introduces mechanism to charge
kernel memory to a given memcg. In case of fsnotify events, the memcg of
the consumer can be used for charging and for buffer_head, the memcg of
the page can be charged. For directed charging, the caller can use the
scope API memalloc_[un]use_memcg() to specify the memcg to charge for
all the __GFP_ACCOUNT allocations within the scope.

Shakeel Butt (2):
  fs: fsnotify: account fsnotify metadata to kmemcg
  fs, mm: account buffer_head to kmemcg

 fs/buffer.c                          | 15 ++++++-
 fs/notify/dnotify/dnotify.c          |  5 ++-
 fs/notify/fanotify/fanotify.c        | 17 ++++++--
 fs/notify/fanotify/fanotify_user.c   |  5 ++-
 fs/notify/group.c                    |  4 ++
 fs/notify/inotify/inotify_fsnotify.c | 15 ++++++-
 fs/notify/inotify/inotify_user.c     |  5 ++-
 include/linux/fsnotify_backend.h     | 12 ++++--
 include/linux/memcontrol.h           | 14 +++++++
 include/linux/sched.h                |  3 ++
 include/linux/sched/mm.h             | 41 +++++++++++++++++++
 kernel/fork.c                        |  3 ++
 mm/memcontrol.c                      | 60 ++++++++++++++++++++++++++--
 13 files changed, 182 insertions(+), 17 deletions(-)

-- 
2.18.0.rc2.346.g013aa6912e-goog

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

end of thread, other threads:[~2018-08-17 13:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-27 19:12 [PATCH v8 0/2] Directed kmem charging Shakeel Butt
2018-06-27 19:12 ` [PATCH 1/2] fs: fsnotify: account fsnotify metadata to kmemcg Shakeel Butt
2018-06-28 10:02   ` Jan Kara
2018-06-28 19:21     ` Shakeel Butt
2018-06-29  9:52       ` Michal Hocko
2018-06-29 17:44       ` Jan Kara
2018-07-02 21:54   ` [PATCH] fs-fsnotify-account-fsnotify-metadata-to-kmemcg.patch.cleanup Shakeel Butt
2018-07-02 21:56     ` Shakeel Butt
2018-06-27 19:12 ` [PATCH 2/2] fs, mm: account buffer_head to kmemcg Shakeel Butt
2018-07-02 22:02   ` [PATCH] fs-mm-account-buffer_head-to-kmemcg.patch.fix Shakeel Butt
2018-08-15 22:25 ` [PATCH v8 0/2] Directed kmem charging Andrew Morton
2018-08-17 13:04   ` Johannes Weiner
  -- strict thread matches above, loose matches on Subject: below --
2018-06-25 23:06 [PATCH v7 " Shakeel Butt
2018-06-25 23:06 ` [PATCH 1/2] fs: fsnotify: account fsnotify metadata to kmemcg Shakeel Butt
2018-06-26  5:49   ` Amir Goldstein
2018-06-26 18:00     ` Shakeel Butt
2018-06-26 18:57       ` Johannes Weiner
2018-06-26 19:07         ` Shakeel Butt
2018-06-27  7:31           ` Jan Kara
2018-06-26 19:06   ` Johannes Weiner
2018-06-26 20:05     ` Shakeel Butt
2018-06-27  5:50       ` Amir Goldstein

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).