linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Shakeel Butt <shakeelb@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Jan Kara <jack@suse.com>, Greg Thelen <gthelen@google.com>,
	Amir Goldstein <amir73il@gmail.com>, Roman Gushchin <guro@fb.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	Jan Kara <jack@suse.cz>
Subject: Re: [PATCH 1/2] fs: fsnotify: account fsnotify metadata to kmemcg
Date: Thu, 28 Jun 2018 12:02:53 +0200	[thread overview]
Message-ID: <20180628100253.jscxkw2d6vfhnbo5@quack2.suse.cz> (raw)
In-Reply-To: <20180627191250.209150-2-shakeelb@google.com>

On Wed 27-06-18 12:12:49, Shakeel Butt wrote:
> A lot of memory can be consumed by the events generated for the huge or
> unlimited queues if there is either no or slow listener.  This can cause
> system level memory pressure or OOMs.  So, it's better to account the
> fsnotify kmem caches to the memcg of the listener.
> 
> However the listener can be in a different memcg than the memcg of the
> producer and these allocations happen in the context of the event
> producer. This patch introduces remote memcg charging API which the
> producer can use to charge the allocations to the memcg of the listener.
> 
> There are seven fsnotify kmem caches and among them allocations from
> dnotify_struct_cache, dnotify_mark_cache, fanotify_mark_cache and
> inotify_inode_mark_cachep happens in the context of syscall from the
> listener.  So, SLAB_ACCOUNT is enough for these caches.
> 
> The objects from fsnotify_mark_connector_cachep are not accounted as they
> are small compared to the notification mark or events and it is unclear
> whom to account connector to since it is shared by all events attached to
> the inode.
> 
> The allocations from the event caches happen in the context of the event
> producer.  For such caches we will need to remote charge the allocations
> to the listener's memcg.  Thus we save the memcg reference in the
> fsnotify_group structure of the listener.
> 
> This patch has also moved the members of fsnotify_group to keep the size
> same, at least for 64 bit build, even with additional member by filling
> the holes.

...

>  static int __init fanotify_user_setup(void)
>  {
> -	fanotify_mark_cache = KMEM_CACHE(fsnotify_mark, SLAB_PANIC);
> +	fanotify_mark_cache = KMEM_CACHE(fsnotify_mark,
> +					 SLAB_PANIC|SLAB_ACCOUNT);
>  	fanotify_event_cachep = KMEM_CACHE(fanotify_event_info, SLAB_PANIC);
>  	if (IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS)) {
>  		fanotify_perm_event_cachep =

Why don't you setup also fanotify_event_cachep and
fanotify_perm_event_cachep caches with SLAB_ACCOUNT and instead specify
__GFP_ACCOUNT manually? Otherwise the patch looks good to me.

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2018-06-28 19:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180628100253.jscxkw2d6vfhnbo5@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=amir73il@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=gthelen@google.com \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=shakeelb@google.com \
    --cc=vdavydov.dev@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).