mm, oom_reaper: do not mmput synchronously from the oom reaper context
Forking new thread because my comment is not related to this patch's purpose but found a thing during reading this patch.
Quoted 8 lines · Michal Hocko
From: Michal Hocko <[email protected]>
Tetsuo has properly noted that mmput slow path might get blocked waiting for another party (e.g.
exit_aiowaits for an IO). If that happens theoom_reaperwould be put out of the way and will not be able to process next oom victim. We should strive for making this context as reliable and independent on other subsystems as much as possible.
Quoted 8 lines
Introduce
mmput_asyncwhich will perform the slow path from an async (WQ) context. This will delay the operation but that shouldn't be a problem because theoom_reaperhas reclaimed the victim's address space for most cases as much as possible and the remaining context shouldn't bind too much memory anymore. The only exception is whenmmap_semtrylock has failed which shouldn't happen too often.The issue is only theoretical but not impossible.
The mmput_async is used for only OOM reaper which is enabled on CONFIG_MMU. So until someone who want to use mmput_async in !CONFIG_MMU come out, we could save sizeof(struct work_struct) per mm in !CONFIG_MMU.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 19 lines · Minchan Kim
Forking new thread because my comment is not related to this patch's purpose but found a thing during reading this patch.
Quoted 15 lines · Michal Hocko
From: Michal Hocko <[email protected]>
Tetsuo has properly noted that mmput slow path might get blocked waiting for another party (e.g.
exit_aiowaits for an IO). If that happens theoom_reaperwould be put out of the way and will not be able to process next oom victim. We should strive for making this context as reliable and independent on other subsystems as much as possible.Introduce
mmput_asyncwhich will perform the slow path from an async (WQ) context. This will delay the operation but that shouldn't be a problem because theoom_reaperhas reclaimed the victim's address space for most cases as much as possible and the remaining context shouldn't bind too much memory anymore. The only exception is whenmmap_semtrylock has failed which shouldn't happen too often.
Quoted 5 lines
Quoted 1 line
The issue is only theoretical but not impossible.
The
mmput_asyncis used for only OOM reaper which is enabled onCONFIG_MMU. So until someone who want to usemmput_asyncin !CONFIG_MMU come out, we could savesizeof(struct work_struct)per mm in !CONFIG_MMU.
You are right. What about the following?
---
Minchan Kim
Acked-byQuoted 34 lines · Michal Hocko
Quoted 19 lines · Minchan Kim
Forking new thread because my comment is not related to this patch's purpose but found a thing during reading this patch.
Quoted 15 lines · Michal Hocko
From: Michal Hocko <[email protected]>
Tetsuo has properly noted that mmput slow path might get blocked waiting for another party (e.g.
exit_aiowaits for an IO). If that happens theoom_reaperwould be put out of the way and will not be able to process next oom victim. We should strive for making this context as reliable and independent on other subsystems as much as possible.Introduce
mmput_asyncwhich will perform the slow path from an async (WQ) context. This will delay the operation but that shouldn't be a problem because theoom_reaperhas reclaimed the victim's address space for most cases as much as possible and the remaining context shouldn't bind too much memory anymore. The only exception is whenmmap_semtrylock has failed which shouldn't happen too often.Quoted 5 lines
Quoted 1 line
The issue is only theoretical but not impossible.
The
mmput_asyncis used for only OOM reaper which is enabled onCONFIG_MMU. So until someone who want to usemmput_asyncin !CONFIG_MMU come out, we could savesizeof(struct work_struct)per mm in !CONFIG_MMU.You are right. What about the following?
---
From8f8a34bf00882bfc0b557ed79e0e9e956ac9d217Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Fri, 20 May 2016 08:14:39 +0200
Subject: [PATCH] mmotm:
mm-oom_reaper-do-not-mmput-synchronously-from-the-oom-reaper-context-fix
Quoted 6 lines
mmput_asyncis currently used only from theoom_reaperwhich is defined only forCONFIG_MMU. We can savework_structinmm_structfor !CONFIG_MMU.Reported-by Minchan Kim <[email protected]>Signed-off-by Michal Hocko <[email protected]>
Found a typo below although it was not caused by this patch. My brand new glasses are really good for me.
Quoted 25 lines
--- include/linux/mm_types.h | 2 ++ include/linux/sched.h | 2 ++ kernel/fork.c | 2 ++ 3 files changed, 6 insertions(+)include/linux/mm_types.h +2
-0@@ -514,7 +514,9 @@ struct mm_struct {#ifdef CONFIG_HUGETLB_PAGE atomic_long_t hugetlb_usage;#endif +#ifdef CONFIG_MMU struct work_struct async_put_work; +#endif };static inline void mm_init_cpumask (struct mm_struct *mm)include/linux/sched.h +0
-0
include/linux/sched.h static inline void mmdrop(struct mm_struct * mm) · line 2608
Quoted 5 lines
include/linux/sched.h +1
-0@@ -2604,10 +2604,12 @@ static inline void mmdrop(struct mm_struct * mm)/* mmput gets rid of the mappings and all user-space */ extern void mmput (struct mm_struct *); +#ifdef CONFIG_MMU /* same as above but performs the slow path from the async kontext. Can
c
Quoted 34 lines
include/linux/sched.h +1
-0* be called from the atomic context as well */ extern void mmput_async (struct mm_struct *); +#endif /* Grab a reference to a task's mm, if it is not already going away */ extern struct mm_struct *get_task_mm (struct task_struct *task);kernel/fork.c +2
-0@@ -732,6 +732,7 @@ void mmput(struct mm_struct *mm) }EXPORT_SYMBOL_GPL (mmput); +#ifdef CONFIG_MMU static void mmput_async_fn (struct work_struct *work) { struct mm_struct *mm = container_of(work, struct mm_struct, async_put_work);@@ -745,6 +746,7 @@ void mmput_async(struct mm_struct *mm) schedule_work(&mm->async_put_work); } } +#endif /** * set_mm_exe_file - change a reference to the mm's executable file Signature · 6 lines
2.8.1 -- Michal Hocko SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>