* [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm @ 2022-12-15 9:19 Haifeng Xu 2022-12-15 18:18 ` Shakeel Butt 0 siblings, 1 reply; 9+ messages in thread From: Haifeng Xu @ 2022-12-15 9:19 UTC (permalink / raw) To: akpm Cc: shakeelb, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel, Haifeng Xu The memory events aren't supported on root cgroup, so there is no need to account MEMCG_OOM_KILL on root memcg. Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com> --- include/linux/memcontrol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 567f12323f55..09f75161a3bc 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1142,7 +1142,7 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm, rcu_read_lock(); memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); - if (likely(memcg)) + if (likely(memcg && !mem_cgroup_is_root(memcg))) memcg_memory_event(memcg, event); rcu_read_unlock(); } -- 2.25.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-15 9:19 [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm Haifeng Xu @ 2022-12-15 18:18 ` Shakeel Butt 2022-12-16 1:43 ` Haifeng Xu 0 siblings, 1 reply; 9+ messages in thread From: Shakeel Butt @ 2022-12-15 18:18 UTC (permalink / raw) To: Haifeng Xu Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: > The memory events aren't supported on root cgroup, so there is no need > to account MEMCG_OOM_KILL on root memcg. > Can you explain the scenario where this is happening and causing issue for you? > Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com> > --- > include/linux/memcontrol.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 567f12323f55..09f75161a3bc 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -1142,7 +1142,7 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm, > > rcu_read_lock(); > memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); > - if (likely(memcg)) > + if (likely(memcg && !mem_cgroup_is_root(memcg))) Even if we need this additional check, this is not the right place. > memcg_memory_event(memcg, event); > rcu_read_unlock(); > } > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-15 18:18 ` Shakeel Butt @ 2022-12-16 1:43 ` Haifeng Xu 2022-12-16 6:42 ` Shakeel Butt 0 siblings, 1 reply; 9+ messages in thread From: Haifeng Xu @ 2022-12-16 1:43 UTC (permalink / raw) To: Shakeel Butt Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On 2022/12/16 02:18, Shakeel Butt wrote: > On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: >> The memory events aren't supported on root cgroup, so there is no need >> to account MEMCG_OOM_KILL on root memcg. >> > > Can you explain the scenario where this is happening and causing issue > for you? > If the victim selected by oom killer belongs to root memcg, memcg_memory_event_mm still counts the MEMCG_OOM_KILL event. This behavior is meaningless because the flag of events/events.local in memory_files is CFTYPE_NOT_ON_ROOT. The root memcg does not count any memory event. >> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com> >> --- >> include/linux/memcontrol.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index 567f12323f55..09f75161a3bc 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -1142,7 +1142,7 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm, >> >> rcu_read_lock(); >> memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); >> - if (likely(memcg)) >> + if (likely(memcg && !mem_cgroup_is_root(memcg))) > > Even if we need this additional check, this is not the right place. > >> memcg_memory_event(memcg, event); >> rcu_read_unlock(); >> } >> -- >> 2.25.1 >> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-16 1:43 ` Haifeng Xu @ 2022-12-16 6:42 ` Shakeel Butt 2022-12-16 7:28 ` Haifeng Xu 0 siblings, 1 reply; 9+ messages in thread From: Shakeel Butt @ 2022-12-16 6:42 UTC (permalink / raw) To: Haifeng Xu Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On Fri, Dec 16, 2022 at 09:43:02AM +0800, Haifeng Xu wrote: > > > On 2022/12/16 02:18, Shakeel Butt wrote: > > On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: > >> The memory events aren't supported on root cgroup, so there is no need > >> to account MEMCG_OOM_KILL on root memcg. > >> > > > > Can you explain the scenario where this is happening and causing issue > > for you? > > > If the victim selected by oom killer belongs to root memcg, memcg_memory_event_mm > still counts the MEMCG_OOM_KILL event. This behavior is meaningless because the > flag of events/events.local in memory_files is CFTYPE_NOT_ON_ROOT. The root memcg > does not count any memory event. > What about v1's memory.oom_control? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-16 6:42 ` Shakeel Butt @ 2022-12-16 7:28 ` Haifeng Xu 2022-12-16 7:36 ` Shakeel Butt 0 siblings, 1 reply; 9+ messages in thread From: Haifeng Xu @ 2022-12-16 7:28 UTC (permalink / raw) To: Shakeel Butt Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On 2022/12/16 14:42, Shakeel Butt wrote: > On Fri, Dec 16, 2022 at 09:43:02AM +0800, Haifeng Xu wrote: >> >> >> On 2022/12/16 02:18, Shakeel Butt wrote: >>> On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: >>>> The memory events aren't supported on root cgroup, so there is no need >>>> to account MEMCG_OOM_KILL on root memcg. >>>> >>> >>> Can you explain the scenario where this is happening and causing issue >>> for you? >>> >> If the victim selected by oom killer belongs to root memcg, memcg_memory_event_mm >> still counts the MEMCG_OOM_KILL event. This behavior is meaningless because the >> flag of events/events.local in memory_files is CFTYPE_NOT_ON_ROOT. The root memcg >> does not count any memory event. >> > > What about v1's memory.oom_control? > The memory.oom_control doesn't set the CFTYPE_NOT_ON_ROOT flag. But oom_kill_disable or under_oom actually only support non-root memcg, so the memory_events should be consistent with them. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-16 7:28 ` Haifeng Xu @ 2022-12-16 7:36 ` Shakeel Butt 2022-12-16 7:50 ` Haifeng Xu 0 siblings, 1 reply; 9+ messages in thread From: Shakeel Butt @ 2022-12-16 7:36 UTC (permalink / raw) To: Haifeng Xu Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On Fri, Dec 16, 2022 at 03:28:53PM +0800, Haifeng Xu wrote: > > > On 2022/12/16 14:42, Shakeel Butt wrote: > > On Fri, Dec 16, 2022 at 09:43:02AM +0800, Haifeng Xu wrote: > >> > >> > >> On 2022/12/16 02:18, Shakeel Butt wrote: > >>> On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: > >>>> The memory events aren't supported on root cgroup, so there is no need > >>>> to account MEMCG_OOM_KILL on root memcg. > >>>> > >>> > >>> Can you explain the scenario where this is happening and causing issue > >>> for you? > >>> > >> If the victim selected by oom killer belongs to root memcg, memcg_memory_event_mm > >> still counts the MEMCG_OOM_KILL event. This behavior is meaningless because the > >> flag of events/events.local in memory_files is CFTYPE_NOT_ON_ROOT. The root memcg > >> does not count any memory event. > >> > > > > What about v1's memory.oom_control? > > > > The memory.oom_control doesn't set the CFTYPE_NOT_ON_ROOT flag. But oom_kill_disable or > under_oom actually only support non-root memcg, so the memory_events should be consistent > with them. Did you take a look at mem_cgroup_oom_control_read()? It is displaying MEMCG_OOM_KILL for root memcg. Irrespective it makes sense or not, you want to change behavior of user visible interface. If you really want to then propose for the deprecation of that interface. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-16 7:36 ` Shakeel Butt @ 2022-12-16 7:50 ` Haifeng Xu 2022-12-16 8:17 ` Shakeel Butt 0 siblings, 1 reply; 9+ messages in thread From: Haifeng Xu @ 2022-12-16 7:50 UTC (permalink / raw) To: Shakeel Butt Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On 2022/12/16 15:36, Shakeel Butt wrote: > On Fri, Dec 16, 2022 at 03:28:53PM +0800, Haifeng Xu wrote: >> >> >> On 2022/12/16 14:42, Shakeel Butt wrote: >>> On Fri, Dec 16, 2022 at 09:43:02AM +0800, Haifeng Xu wrote: >>>> >>>> >>>> On 2022/12/16 02:18, Shakeel Butt wrote: >>>>> On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: >>>>>> The memory events aren't supported on root cgroup, so there is no need >>>>>> to account MEMCG_OOM_KILL on root memcg. >>>>>> >>>>> >>>>> Can you explain the scenario where this is happening and causing issue >>>>> for you? >>>>> >>>> If the victim selected by oom killer belongs to root memcg, memcg_memory_event_mm >>>> still counts the MEMCG_OOM_KILL event. This behavior is meaningless because the >>>> flag of events/events.local in memory_files is CFTYPE_NOT_ON_ROOT. The root memcg >>>> does not count any memory event. >>>> >>> >>> What about v1's memory.oom_control? >>> >> >> The memory.oom_control doesn't set the CFTYPE_NOT_ON_ROOT flag. But oom_kill_disable or >> under_oom actually only support non-root memcg, so the memory_events should be consistent >> with them. > > Did you take a look at mem_cgroup_oom_control_read()? It is displaying > MEMCG_OOM_KILL for root memcg. Irrespective it makes sense or not, you > want to change behavior of user visible interface. If you really want to > then propose for the deprecation of that interface. Yes, I have see it in mem_cgroup_oom_control_read() and I think that showing MEMCG_OOM_KILL for root memcg doesn't make much sense. Shoud I add the CFTYPE_NOT_ON_ROOT flag for cgroup v1? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-16 7:50 ` Haifeng Xu @ 2022-12-16 8:17 ` Shakeel Butt 2022-12-16 8:37 ` Haifeng Xu 0 siblings, 1 reply; 9+ messages in thread From: Shakeel Butt @ 2022-12-16 8:17 UTC (permalink / raw) To: Haifeng Xu Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On Fri, Dec 16, 2022 at 03:50:49PM +0800, Haifeng Xu wrote: > > > On 2022/12/16 15:36, Shakeel Butt wrote: > > On Fri, Dec 16, 2022 at 03:28:53PM +0800, Haifeng Xu wrote: > >> > >> > >> On 2022/12/16 14:42, Shakeel Butt wrote: > >>> On Fri, Dec 16, 2022 at 09:43:02AM +0800, Haifeng Xu wrote: > >>>> > >>>> > >>>> On 2022/12/16 02:18, Shakeel Butt wrote: > >>>>> On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: > >>>>>> The memory events aren't supported on root cgroup, so there is no need > >>>>>> to account MEMCG_OOM_KILL on root memcg. > >>>>>> > >>>>> > >>>>> Can you explain the scenario where this is happening and causing issue > >>>>> for you? > >>>>> > >>>> If the victim selected by oom killer belongs to root memcg, memcg_memory_event_mm > >>>> still counts the MEMCG_OOM_KILL event. This behavior is meaningless because the > >>>> flag of events/events.local in memory_files is CFTYPE_NOT_ON_ROOT. The root memcg > >>>> does not count any memory event. > >>>> > >>> > >>> What about v1's memory.oom_control? > >>> > >> > >> The memory.oom_control doesn't set the CFTYPE_NOT_ON_ROOT flag. But oom_kill_disable or > >> under_oom actually only support non-root memcg, so the memory_events should be consistent > >> with them. > > > > Did you take a look at mem_cgroup_oom_control_read()? It is displaying > > MEMCG_OOM_KILL for root memcg. Irrespective it makes sense or not, you > > want to change behavior of user visible interface. If you really want to > > then propose for the deprecation of that interface. > > Yes, I have see it in mem_cgroup_oom_control_read() and I think that > showing MEMCG_OOM_KILL for root memcg doesn't make much sense. > It doesn't matter as there might already be users using it. > Shoud I add the CFTYPE_NOT_ON_ROOT flag for cgroup v1? > Before doing anything, I am still not seeing why we really need this patch? What exactly is the issue this patch is trying to solve? To me this patch is negatively impacting the readability of the code. Unless you are seeing some real production issues, I don't think we need to add any special casing for MEMCG_OOM_KILL here. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm 2022-12-16 8:17 ` Shakeel Butt @ 2022-12-16 8:37 ` Haifeng Xu 0 siblings, 0 replies; 9+ messages in thread From: Haifeng Xu @ 2022-12-16 8:37 UTC (permalink / raw) To: Shakeel Butt Cc: akpm, roman.gushchin, songmuchun, hannes, vbabka, willy, vasily.averin, linux-kernel On 2022/12/16 16:17, Shakeel Butt wrote: > On Fri, Dec 16, 2022 at 03:50:49PM +0800, Haifeng Xu wrote: >> >> >> On 2022/12/16 15:36, Shakeel Butt wrote: >>> On Fri, Dec 16, 2022 at 03:28:53PM +0800, Haifeng Xu wrote: >>>> >>>> >>>> On 2022/12/16 14:42, Shakeel Butt wrote: >>>>> On Fri, Dec 16, 2022 at 09:43:02AM +0800, Haifeng Xu wrote: >>>>>> >>>>>> >>>>>> On 2022/12/16 02:18, Shakeel Butt wrote: >>>>>>> On Thu, Dec 15, 2022 at 09:19:07AM +0000, Haifeng Xu wrote: >>>>>>>> The memory events aren't supported on root cgroup, so there is no need >>>>>>>> to account MEMCG_OOM_KILL on root memcg. >>>>>>>> >>>>>>> >>>>>>> Can you explain the scenario where this is happening and causing issue >>>>>>> for you? >>>>>>> >>>>>> If the victim selected by oom killer belongs to root memcg, memcg_memory_event_mm >>>>>> still counts the MEMCG_OOM_KILL event. This behavior is meaningless because the >>>>>> flag of events/events.local in memory_files is CFTYPE_NOT_ON_ROOT. The root memcg >>>>>> does not count any memory event. >>>>>> >>>>> >>>>> What about v1's memory.oom_control? >>>>> >>>> >>>> The memory.oom_control doesn't set the CFTYPE_NOT_ON_ROOT flag. But oom_kill_disable or >>>> under_oom actually only support non-root memcg, so the memory_events should be consistent >>>> with them. >>> >>> Did you take a look at mem_cgroup_oom_control_read()? It is displaying >>> MEMCG_OOM_KILL for root memcg. Irrespective it makes sense or not, you >>> want to change behavior of user visible interface. If you really want to >>> then propose for the deprecation of that interface. >> >> Yes, I have see it in mem_cgroup_oom_control_read() and I think that >> showing MEMCG_OOM_KILL for root memcg doesn't make much sense. >> > > It doesn't matter as there might already be users using it. > >> Shoud I add the CFTYPE_NOT_ON_ROOT flag for cgroup v1? >> > > Before doing anything, I am still not seeing why we really need this > patch? What exactly is the issue this patch is trying to solve? To me > this patch is negatively impacting the readability of the code. Unless > you are seeing some real production issues, I don't think we need to add > any special casing for MEMCG_OOM_KILL here. As we can see in memcg_memory_event(), memory event never be count in root memcg. Passing the root memcg to it seems somewhat self-contradictory. Also, cgroup v2 doesn't need this. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-12-16 8:37 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-12-15 9:19 [PATCH] mm/memcontrol: Skip root memcg in memcg_memory_event_mm Haifeng Xu 2022-12-15 18:18 ` Shakeel Butt 2022-12-16 1:43 ` Haifeng Xu 2022-12-16 6:42 ` Shakeel Butt 2022-12-16 7:28 ` Haifeng Xu 2022-12-16 7:36 ` Shakeel Butt 2022-12-16 7:50 ` Haifeng Xu 2022-12-16 8:17 ` Shakeel Butt 2022-12-16 8:37 ` Haifeng Xu
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.