* [PATCH 1/2] mm: list_lru: disable memcg_aware when cgroup.memory is set to "nokmem"
@ 2023-12-28 6:27 Haifeng Xu
2024-01-03 1:53 ` Roman Gushchin
0 siblings, 1 reply; 3+ messages in thread
From: Haifeng Xu @ 2023-12-28 6:27 UTC (permalink / raw)
To: roman.gushchin
Cc: akpm, hannes, mhocko, shakeelb, linux-mm, linux-kernel, Haifeng Xu
Actually, when using a boot time kernel option "cgroup.memory=nokmem",
all lru items are inserted to list_lru_node. But for those users who
invoke list_lru_init_memcg() to initialize list_lru, list_lru_memcg_aware()
returns true. And this brings unneeded operations related to memcg.
To make things more convenient, let's disable memcg_aware when
cgroup.memory is set to "nokmem".
Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
---
mm/list_lru.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/list_lru.c b/mm/list_lru.c
index a05e5bef3b40..86f63c92fd88 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -566,6 +566,9 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware,
lru->shrinker_id = shrinker->id;
else
lru->shrinker_id = -1;
+
+ if (mem_cgroup_kmem_disabled())
+ memcg_aware = false;
#endif
lru->node = kcalloc(nr_node_ids, sizeof(*lru->node), GFP_KERNEL);
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] mm: list_lru: disable memcg_aware when cgroup.memory is set to "nokmem"
2023-12-28 6:27 [PATCH 1/2] mm: list_lru: disable memcg_aware when cgroup.memory is set to "nokmem" Haifeng Xu
@ 2024-01-03 1:53 ` Roman Gushchin
2024-01-08 6:49 ` Haifeng Xu
0 siblings, 1 reply; 3+ messages in thread
From: Roman Gushchin @ 2024-01-03 1:53 UTC (permalink / raw)
To: Haifeng Xu; +Cc: akpm, hannes, mhocko, shakeelb, linux-mm, linux-kernel
On Thu, Dec 28, 2023 at 06:27:14AM +0000, Haifeng Xu wrote:
> Actually, when using a boot time kernel option "cgroup.memory=nokmem",
> all lru items are inserted to list_lru_node. But for those users who
> invoke list_lru_init_memcg() to initialize list_lru, list_lru_memcg_aware()
> returns true. And this brings unneeded operations related to memcg.
>
> To make things more convenient, let's disable memcg_aware when
> cgroup.memory is set to "nokmem".
I guess it's not only more convenient, but also should save a bit of memory.
But _probably_ not enough to justify messing up with stable backports.
Do you have any data on memory savings?
>
> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] mm: list_lru: disable memcg_aware when cgroup.memory is set to "nokmem"
2024-01-03 1:53 ` Roman Gushchin
@ 2024-01-08 6:49 ` Haifeng Xu
0 siblings, 0 replies; 3+ messages in thread
From: Haifeng Xu @ 2024-01-08 6:49 UTC (permalink / raw)
To: Roman Gushchin; +Cc: akpm, hannes, mhocko, shakeelb, linux-mm, linux-kernel
On 2024/1/3 09:53, Roman Gushchin wrote:
> On Thu, Dec 28, 2023 at 06:27:14AM +0000, Haifeng Xu wrote:
>> Actually, when using a boot time kernel option "cgroup.memory=nokmem",
>> all lru items are inserted to list_lru_node. But for those users who
>> invoke list_lru_init_memcg() to initialize list_lru, list_lru_memcg_aware()
>> returns true. And this brings unneeded operations related to memcg.
>>
>> To make things more convenient, let's disable memcg_aware when
>> cgroup.memory is set to "nokmem".
>
> I guess it's not only more convenient, but also should save a bit of memory.
> But _probably_ not enough to justify messing up with stable backports.
> Do you have any data on memory savings?
Do you mean that it will remove the allocation of 'list_lru_memcg' in memcg_init_list_lru_one()?
In fact, even without this patch, if we set cgroup.memory set to "nokmem", all memcg's kmemcg_id is -1, so
memcg_list_lru_allocated() always returns true and we won't invoke memcg_init_list_lru_one().
>
>>
>> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
>
> Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
>
> Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-08 6:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-28 6:27 [PATCH 1/2] mm: list_lru: disable memcg_aware when cgroup.memory is set to "nokmem" Haifeng Xu
2024-01-03 1:53 ` Roman Gushchin
2024-01-08 6:49 ` Haifeng Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox