From: Roman Gushchin <guro@fb.com>
To: Dennis Zhou <dennis@kernel.org>
Cc: Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, Roman Gushchin <guro@fb.com>
Subject: [PATCH v2 2/3] mm, memcg: introduce mem_cgroup_kmem_disabled()
Date: Wed, 2 Jun 2021 18:09:30 -0700 [thread overview]
Message-ID: <20210603010931.1472512-3-guro@fb.com> (raw)
In-Reply-To: <20210603010931.1472512-1-guro@fb.com>
Introduce a new mem_cgroup_kmem_disabled() helper, similar to
mem_cgroup_disabled(), to check whether the kernel memory accounting
is off. A user could disable it using a boot option to eliminate
some associated costs.
The helper can be used outside of memcontrol.c to dynamically disable
the kmem-related code. The returned value is stable after the kernel
initialization is finished.
Signed-off-by: Roman Gushchin <guro@fb.com>
---
include/linux/memcontrol.h | 5 +++++
mm/memcontrol.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 0c04d39a7967..8ef51c58f470 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1583,6 +1583,7 @@ static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
#endif
#ifdef CONFIG_MEMCG_KMEM
+bool mem_cgroup_kmem_disabled(void);
int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order);
void __memcg_kmem_uncharge_page(struct page *page, int order);
@@ -1636,6 +1637,10 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg)
struct mem_cgroup *mem_cgroup_from_obj(void *p);
#else
+static inline bool mem_cgroup_kmem_disabled(void)
+{
+ return true;
+}
static inline int memcg_kmem_charge_page(struct page *page, gfp_t gfp,
int order)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e6203ee24a11..1fa9b00ec71d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -255,6 +255,11 @@ struct cgroup_subsys_state *vmpressure_to_css(struct vmpressure *vmpr)
#ifdef CONFIG_MEMCG_KMEM
extern spinlock_t css_set_lock;
+bool mem_cgroup_kmem_disabled(void)
+{
+ return cgroup_memory_nokmem;
+}
+
static int __memcg_kmem_charge(struct mem_cgroup *memcg, gfp_t gfp,
unsigned int nr_pages);
static void __memcg_kmem_uncharge(struct mem_cgroup *memcg,
--
2.31.1
next prev parent reply other threads:[~2021-06-03 1:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 1:09 [PATCH v2 0/3] percpu: memcg memory accounting rework Roman Gushchin
2021-06-03 1:09 ` [PATCH v2 1/3] mm, memcg: mark cgroup_memory_nosocket, nokmem and noswap as __ro_after_init Roman Gushchin
2021-06-03 1:09 ` Roman Gushchin [this message]
2021-06-03 1:09 ` [PATCH v2 3/3] percpu: rework memcg accounting Roman Gushchin
2021-06-04 16:10 ` [PATCH v2 0/3] percpu: memcg memory accounting rework Dennis Zhou
2021-06-04 20:31 ` Andrew Morton
2021-06-05 21:02 ` Dennis Zhou
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=20210603010931.1472512-3-guro@fb.com \
--to=guro@fb.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tj@kernel.org \
--cc=vbabka@suse.cz \
/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