From: Shakeel Butt <shakeelb@google.com>
To: Michal Hocko <mhocko@kernel.org>, Jan Kara <jack@suse.cz>,
Amir Goldstein <amir73il@gmail.com>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Thelen <gthelen@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
Mel Gorman <mgorman@suse.de>, Vlastimil Babka <vbabka@suse.cz>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux MM <linux-mm@kvack.org>, Cgroups <cgroups@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Shakeel Butt <shakeelb@google.com>
Subject: Re: [PATCH v5 1/2] mm: memcg: remote memcg charging for kmem allocations
Date: Tue, 5 Jun 2018 10:54:18 -0700 [thread overview]
Message-ID: <CALvZod5buYF8O2TWq06f=M1SyJdS0vJrFhkH4FQw2Ga1qv3GsA@mail.gmail.com> (raw)
In-Reply-To: <20180416205150.113915-2-shakeelb@google.com>
On Mon, Apr 16, 2018 at 1:51 PM, Shakeel Butt <shakeelb@google.com> wrote:
> Introduce the memcg variant for kmalloc[_node] and
> kmem_cache_alloc[_node]. For kmem_cache_alloc, the kernel switches the
> root kmem cache with the memcg specific kmem cache for __GFP_ACCOUNT
> allocations to charge those allocations to the memcg. However, the memcg
> to charge is extracted from the current task_struct. This patch
> introduces the variant of kmem cache allocation functions where the memcg
> can be provided explicitly by the caller instead of deducing the memcg
> from the current task.
>
> The kmalloc allocations are underlying served using the kmem caches unless
> the size of the allocation request is larger than KMALLOC_MAX_CACHE_SIZE,
> in which case, the kmem caches are bypassed and the request is routed
> directly to page allocator. So, for __GFP_ACCOUNT kmalloc allocations,
> the memcg of current task is charged. This patch introduces memcg variant
> of kmalloc functions to allow callers to provide memcg for charging.
>
> These functions are useful for use-cases where the allocations should be
> charged to the memcg different from the memcg of the caller. One such
> concrete use-case is the allocations for fsnotify event objects where the
> objects should be charged to the listener instead of the producer.
>
> One requirement to call these functions is that the caller must have the
> reference to the memcg. Using kmalloc_memcg and kmem_cache_alloc_memcg
> implicitly assumes that the caller is requesting a __GFP_ACCOUNT
> allocation.
>
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
I will send the v6 of this patchset after this merge window. In v6, I
will make memalloc_memcg_[save|restore] scope API similar to NOFS,
NOIO and NORECLAIM APIs.
> ---
> Changelog since v4:
> - Removed branch from hot path of memory charging.
>
> Changelog since v3:
> - Added node variant of directed kmem allocation functions.
>
> Changelog since v2:
> - Merge the kmalloc_memcg patch into this patch.
> - Instead of plumbing memcg throughout, use field in task_struct to pass
> the target_memcg.
>
> Changelog since v1:
> - Fixed build for SLOB
>
next prev parent reply other threads:[~2018-06-05 17:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-16 20:51 [PATCH v5 0/2] Directed kmem charging Shakeel Butt
2018-04-16 20:51 ` [PATCH v5 1/2] mm: memcg: remote memcg charging for kmem allocations Shakeel Butt
2018-06-05 17:54 ` Shakeel Butt [this message]
2018-04-16 20:51 ` [PATCH v5 2/2] fs: fsnotify: account fsnotify metadata to kmemcg Shakeel Butt
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='CALvZod5buYF8O2TWq06f=M1SyJdS0vJrFhkH4FQw2Ga1qv3GsA@mail.gmail.com' \
--to=shakeelb@google.com \
--cc=akpm@linux-foundation.org \
--cc=amir73il@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=cl@linux.com \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@kernel.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
--cc=vdavydov.dev@gmail.com \
/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).