Two alternatives for mm async teardown
Subsystems (20)
cover Two alternatives for mm async teardown
This RFC series proposes two possible ways for enabling asynchronous mm teardown.
The first approach, in patch 1, is simply to provide an arch hook in exit_mm. This has no functional change for archs that don't explicitly use the hook, and leaves the hard part to arch code (including accounting, if any).
The second approach, in patches 2 to 4, adds a new syscall to allow an mm to be asynchronously torn down in the context of another process (similarly to how process_mrelease works). It also adds an OOM notifier to prevent the OOM killer from killing processes while the teardown is in progress.
Claudio Imbrenda (4):
exit: add arch mmput hook in exit_mm
kernel/fork.c: implement new process_mmput_async syscall
mm: wire up the process_mmput_async syscall kernel/fork.c: process_mmput_async: stop OOM while freeing memory
arch/alpha/kernel/syscalls/syscall.tbl | 2 + arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 2 + arch/ia64/kernel/syscalls/syscall.tbl | 2 + arch/m68k/kernel/syscalls/syscall.tbl | 2 + arch/microblaze/kernel/syscalls/syscall.tbl | 2 + arch/mips/kernel/syscalls/syscall_n32.tbl | 2 + arch/mips/kernel/syscalls/syscall_n64.tbl | 2 + arch/mips/kernel/syscalls/syscall_o32.tbl | 2 + arch/parisc/kernel/syscalls/syscall.tbl | 2 + arch/powerpc/kernel/syscalls/syscall.tbl | 2 + arch/s390/kernel/syscalls/syscall.tbl | 2 + arch/sh/kernel/syscalls/syscall.tbl | 2 + arch/sparc/kernel/syscalls/syscall.tbl | 2 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 2 + include/asm-generic/mmu_context.h | 4 + include/linux/mm_types.h | 1 + include/linux/syscalls.h | 1 + include/uapi/asm-generic/unistd.h | 5 +- kernel/exit.c | 2 +- kernel/fork.c | 131 +++++++++++++++++++- kernel/sys_ni.c | 1 + 25 files changed, 173 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
RFC 1/4 exit: add arch mmput hook in exit_mm
This simple patch adds a hook for the mmput in exit_mm. This allows archs to perform the mmput in custom ways if desired (e.g. asynchronously)
No functional change intended.
--- include/asm-generic/mmu_context.h | 4 ++++ kernel/exit.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
include/asm-generic/mmu_context.h +4 -0
@@ -73,4 +73,8 @@ static inline void deactivate_mm(struct task_struct *tsk, }#endif +#ifndef arch_exit_mm_mmput +#define arch_exit_mm_mmput mmput +#endif +#endif /* __ASM_GENERIC_MMU_CONTEXT_H */
kernel/exit.c +1 -1
@@ -504,7 +504,7 @@ static void exit_mm(void)task_unlock (current);mmap_read_unlock (mm);mm_update_next_owner (mm); -mmput (mm); +arch_exit_mm_mmput (mm);if (test_thread_flag (TIF_MEMDIE ))exit_oom_victim (); }
Signature · 1 line
2.31.1
Re: [RFC v1 1/4] exit: add arch mmput hook in exit_mm
Quoted 5 lines · Claudio Imbrenda
This simple patch adds a hook for the mmput in
exit_mm. This allows archs to perform the mmput in custom ways if desired (e.g. asynchronously)No functional change intended.
Ouch! No.
You changes don't include an architecture taking advantage of this so there is not way to see how this is used in practice and maintain the code.
Further you are making the generic code much harder to read and follow replacing generic code with something random that some buggy architecture implements that no one understands.
Saying "some buggy architecture implements and no one understands" is a bit hyperbole but that is how these hooks feel when digging in to changing the code. It takes weeks to months to read through ask questions etc to clean hooks like this up and change the code in an appropriate way.
As things are ill specified like this really do need change eventually.
So please use much more targeted routines for architecture code to call. Especially when dealing with something as fundamental as the lifetime of a core kernel object.
If you want an example of how silly some of these kinds of things can get just look at arch_ptrace_stop and sigkill_pending. Linus has just merged my fixes for these things. There are worse examples, I just remember them off the top of my head.
If this is merged as is, this feels like code that will be subtly wrong for a decade before someone figures it out and fixes it.
Eric
Quoted 32 lines
Signed-off-by Claudio Imbrenda <[email protected]>--- include/asm-generic/mmu_context.h | 4 ++++ kernel/exit.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)include/asm-generic/mmu_context.h +4
-0@@ -73,4 +73,8 @@ static inline void deactivate_mm(struct task_struct *tsk, }#endif +#ifndef arch_exit_mm_mmput +#define arch_exit_mm_mmput mmput +#endif +#endif /* __ASM_GENERIC_MMU_CONTEXT_H */ kernel/exit.c +1
-1@@ -504,7 +504,7 @@ static void exit_mm(void)task_unlock (current);mmap_read_unlock (mm);mm_update_next_owner (mm); -mmput (mm); +arch_exit_mm_mmput (mm);if (test_thread_flag (TIF_MEMDIE ))exit_oom_victim (); }
RFC 1/4 add arch mmput hook in exit.c
In reply to Claudio ImbrendaThis simple patch adds a hook for the mmput in exit_mm. This allows archs to perform the mmput in custom ways if desired (e.g. asynchronously)
No functional change intended.
--- include/asm-generic/mmu_context.h | 4 ++++ kernel/exit.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
include/asm-generic/mmu_context.h +4 -0
@@ -73,4 +73,8 @@ static inline void deactivate_mm(struct task_struct *tsk, }#endif +#ifndef arch_exit_mm_mmput +#define arch_exit_mm_mmput mmput +#endif +#endif /* __ASM_GENERIC_MMU_CONTEXT_H */
kernel/exit.c +1 -1
@@ -504,7 +504,7 @@ static void exit_mm(void)task_unlock (current);mmap_read_unlock (mm);mm_update_next_owner (mm); -mmput (mm); +arch_exit_mm_mmput (mm);if (test_thread_flag (TIF_MEMDIE ))exit_oom_victim (); }
Signature · 1 line
2.31.1
RFC 2/4 kernel/fork.c: implement new process_mmput_async syscall
In reply to Claudio ImbrendaThe goal of this new syscall is to be able to asynchronously free the mm of a dying process. This is especially useful for processes that use huge amounts of memory (e.g. databases or KVM guests). The process is allowed to terminate immediately, while its mm is cleaned/reclaimed asynchronously.
A separate process needs use the process_mmput_async syscall to attach itself to the mm of a running target process. The process will then sleep until the last user of the target mm has gone.
When the last user of the mm has gone, instead of synchronously free the mm, the attached process is awoken. The syscall will then continue and clean up the target mm.
This solution has the advantage that the cleanup of the target mm can happen both be asynchronous and properly accounted for (e.g. cgroups).
Tested on s390x.
A separate patch will actually wire up the syscall.
--- include/linux/mm_types.h | 1 + kernel/fork.c | 103 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 2 deletions(-)
include/linux/mm_types.h +1 -0
@@ -631,6 +631,7 @@ struct mm_struct {atomic_long_t hugetlb_usage;#endif struct work_struct async_put_work; +struct task_struct *mmput_async_task;#ifdef CONFIG_IOMMU_SUPPORT u32 pasid;
kernel/fork.c +101 -2
124 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [RFC v1 2/4] kernel/fork.c: implement new process_mmput_async syscall
Quoted 14 lines · Claudio Imbrenda
The goal of this new syscall is to be able to asynchronously free the mm of a dying process. This is especially useful for processes that use huge amounts of memory (e.g. databases or KVM guests). The process is allowed to terminate immediately, while its mm is cleaned/reclaimed asynchronously.
A separate process needs use the
process_mmput_asyncsyscall to attach itself to the mm of a running target process. The process will then sleep until the last user of the target mm has gone.When the last user of the mm has gone, instead of synchronously free the mm, the attached process is awoken. The syscall will then continue and clean up the target mm.
Quoted 6 lines
This solution has the advantage that the cleanup of the target mm can happen both be asynchronous and properly accounted for (e.g. cgroups).
Tested on s390x.
A separate patch will actually wire up the syscall.
I am a bit confused.
You want the process report that it has finished immediately, and you want the cleanup work to continue on in the background.
Why do you need a separate process?
Why not just modify the process cleanup code to keep the task_struct running while allowing waitpid to reap the process (aka allowing release_task to run)? All tasks can be already be reaped after exit_notify in do_exit.
I can see some reasons for wanting an opt-in. It is nice to know all of a processes resources have been freed when waitpid succeeds.
Still I don't see why this whole thing isn't exit_mm returning the mm_sturct when a flag is set, and then having an exit_mm_late being called and passed the returned mm after exit_notify.
Or maybe something with schedule_work or task_work, instead of an exit_mm_late. I don't see any practical difference.
I really don't see why this needs a whole other process to connect to the process you care about asynchronously.
This whole thing seems an exercise in spending lots of resources to free resources much later.
Eric
Re: [RFC v1 2/4] kernel/fork.c: implement new process_mmput_async syscall
Quoted 19 lines · On Thu, 11 Nov 2021 13:20:11 -0600 [email protected] (Eric W. Biederman)…
Quoted 17 lines · Claudio Imbrenda
The goal of this new syscall is to be able to asynchronously free the mm of a dying process. This is especially useful for processes that use huge amounts of memory (e.g. databases or KVM guests). The process is allowed to terminate immediately, while its mm is cleaned/reclaimed asynchronously.
A separate process needs use the
process_mmput_asyncsyscall to attach itself to the mm of a running target process. The process will then sleep until the last user of the target mm has gone.When the last user of the mm has gone, instead of synchronously free the mm, the attached process is awoken. The syscall will then continue and clean up the target mm.
This solution has the advantage that the cleanup of the target mm can happen both be asynchronous and properly accounted for (e.g. cgroups).
Quoted 8 lines
Quoted 3 lines
Tested on s390x.
A separate patch will actually wire up the syscall.
I am a bit confused.
You want the process report that it has finished immediately, and you want the cleanup work to continue on in the background.
yes
Quoted 7 lines
Why do you need a separate process?
Why not just modify the process cleanup code to keep the
task_structrunning while allowing waitpid to reap the process (aka allowingrelease_taskto run)? All tasks can be already be reaped afterexit_notifyindo_exit.
Quoted 6 lines
I can see some reasons for wanting an opt-in. It is nice to know all of a processes resources have been freed when waitpid succeeds.
Still I don't see why this whole thing isn't
exit_mmreturning themm_sturctwhen a flag is set, and then having anexit_mm_latebeing called and passed the returned mm afterexit_notify.
so if I understand correctly you are saying exit_mm would skip the mmput, set a flag, then I should introduce a new function "exit_mm_late" after exit_notify, to check the flag and do the mmput if needed
and that would mean that the cleanup would still be done in the context of the exiting process, but without holding back anyone waiting for the process to terminate (so the process appears to exit immediately)
sounds clean, I will do it
Quoted 5 lines
Or maybe something with
schedule_workortask_work, instead of anexit_mm_late. I don't see any practical difference.I really don't see why this needs a whole other process to connect to the process you care about asynchronously.
accounting. workqueues or kernel threads are not properly accounted to the right cgroups; by using a userspace process, things get accounted properly.
this was a major point that was made last month when a similar discussion came up
Quoted 2 lines
This whole thing seems an exercise in spending lots of resources to free resources much later.
there are some usecases for this (huge processes like databases, or huge secure VMs where the teardown is significantly slower than normal processes)
Quoted 2 lines
Eric
Re: [RFC v1 2/4] kernel/fork.c: implement new process_mmput_async syscall
In reply to Eric W. BiedermanQuoted 35 lines · On Thu, 11 Nov 2021 13:20:11 -0600 [email protected] (Eric W. Biederman)…
Quoted 14 lines · Claudio Imbrenda
The goal of this new syscall is to be able to asynchronously free the mm of a dying process. This is especially useful for processes that use huge amounts of memory (e.g. databases or KVM guests). The process is allowed to terminate immediately, while its mm is cleaned/reclaimed asynchronously.
A separate process needs use the
process_mmput_asyncsyscall to attach itself to the mm of a running target process. The process will then sleep until the last user of the target mm has gone.When the last user of the mm has gone, instead of synchronously free the mm, the attached process is awoken. The syscall will then continue and clean up the target mm.
Quoted 6 lines
This solution has the advantage that the cleanup of the target mm can happen both be asynchronous and properly accounted for (e.g. cgroups).
Tested on s390x.
A separate patch will actually wire up the syscall.
I am a bit confused.
You want the process report that it has finished immediately, and you want the cleanup work to continue on in the background.
Why do you need a separate process?
Why not just modify the process cleanup code to keep the
task_structrunning while allowing waitpid to reap the process (aka allowingrelease_taskto run)? All tasks can be already be reaped afterexit_notifyindo_exit.
Quoted 6 lines
I can see some reasons for wanting an opt-in. It is nice to know all of a processes resources have been freed when waitpid succeeds.
Still I don't see why this whole thing isn't
exit_mmreturning themm_sturctwhen a flag is set, and then having anexit_mm_latebeing called and passed the returned mm afterexit_notify.
nevermind, exit_notify is done after cgroup_exit, the teardown would then not be accounted properly
Quoted 11 lines
Or maybe something with
schedule_workortask_work, instead of anexit_mm_late. I don't see any practical difference.I really don't see why this needs a whole other process to connect to the process you care about asynchronously.
This whole thing seems an exercise in spending lots of resources to free resources much later.
Eric
Re: [RFC v1 2/4] kernel/fork.c: implement new process_mmput_async syscall
Quoted 41 lines · Claudio Imbrenda
Quoted 38 lines · On Thu, 11 Nov 2021 13:20:11 -0600 [email protected] (Eric W. Biederman)…
Quoted 14 lines · Claudio Imbrenda
The goal of this new syscall is to be able to asynchronously free the mm of a dying process. This is especially useful for processes that use huge amounts of memory (e.g. databases or KVM guests). The process is allowed to terminate immediately, while its mm is cleaned/reclaimed asynchronously.
A separate process needs use the
process_mmput_asyncsyscall to attach itself to the mm of a running target process. The process will then sleep until the last user of the target mm has gone.When the last user of the mm has gone, instead of synchronously free the mm, the attached process is awoken. The syscall will then continue and clean up the target mm.
Quoted 6 lines
This solution has the advantage that the cleanup of the target mm can happen both be asynchronous and properly accounted for (e.g. cgroups).
Tested on s390x.
A separate patch will actually wire up the syscall.
I am a bit confused.
You want the process report that it has finished immediately, and you want the cleanup work to continue on in the background.
Why do you need a separate process?
Why not just modify the process cleanup code to keep the
task_structrunning while allowing waitpid to reap the process (aka allowingrelease_taskto run)? All tasks can be already be reaped afterexit_notifyindo_exit.I can see some reasons for wanting an opt-in. It is nice to know all of a processes resources have been freed when waitpid succeeds.
Quoted 6 lines
Quoted 3 lines
Still I don't see why this whole thing isn't
exit_mmreturning themm_sturctwhen a flag is set, and then having anexit_mm_latebeing called and passed the returned mm afterexit_notify.nevermind,
exit_notifyis done aftercgroup_exit, the teardown would then not be accounted properly
So you want this new mechanism so you can separate the cleanup from the exit notification, and so that things are accounted properly.
It would have helped if you had included a link to the previous conversation.
I think Michal Hoko has a point. This looks like a job for "clone(CLONE_VM)" and "prctl(PR_SET_PDEATH_SIG)". Maybe using a pidfd instead of the prctl.
AKA just create a child that shares the parents memory, and waits for the parent to exit and then cleans things up.
That should not need any new kernel mechanisms.
There is the other question: why this is disastrously slow on s390? Is this a s390 specific issue? Can the issue be fixed by optimizing what is happening on s390?
Eric
Re: [RFC v1 2/4] kernel/fork.c: implement new process_mmput_async syscall
Quoted 56 lines · On Fri, 12 Nov 2021 08:57:13 -0600 [email protected] (Eric W. Biederman)…
Quoted 41 lines · Claudio Imbrenda
Quoted 38 lines · On Thu, 11 Nov 2021 13:20:11 -0600 [email protected] (Eric W. Biederman)…
Quoted 14 lines · Claudio Imbrenda
The goal of this new syscall is to be able to asynchronously free the mm of a dying process. This is especially useful for processes that use huge amounts of memory (e.g. databases or KVM guests). The process is allowed to terminate immediately, while its mm is cleaned/reclaimed asynchronously.
A separate process needs use the
process_mmput_asyncsyscall to attach itself to the mm of a running target process. The process will then sleep until the last user of the target mm has gone.When the last user of the mm has gone, instead of synchronously free the mm, the attached process is awoken. The syscall will then continue and clean up the target mm.
Quoted 6 lines
This solution has the advantage that the cleanup of the target mm can happen both be asynchronous and properly accounted for (e.g. cgroups).
Tested on s390x.
A separate patch will actually wire up the syscall.
I am a bit confused.
You want the process report that it has finished immediately, and you want the cleanup work to continue on in the background.
Why do you need a separate process?
Why not just modify the process cleanup code to keep the
task_structrunning while allowing waitpid to reap the process (aka allowingrelease_taskto run)? All tasks can be already be reaped afterexit_notifyindo_exit.I can see some reasons for wanting an opt-in. It is nice to know all of a processes resources have been freed when waitpid succeeds.
Quoted 6 lines
Quoted 3 lines
Still I don't see why this whole thing isn't
exit_mmreturning themm_sturctwhen a flag is set, and then having anexit_mm_latebeing called and passed the returned mm afterexit_notify.nevermind,
exit_notifyis done aftercgroup_exit, the teardown would then not be accounted properlySo you want this new mechanism so you can separate the cleanup from the exit notification, and so that things are accounted properly.
It would have helped if you had included a link to the previous conversation.
Quoted 8 lines
I think Michal Hoko has a point. This looks like a job for "
clone(CLONE_VM)" and "prctl(PR_SET_PDEATH_SIG)". Maybe using a pidfd instead of the prctl.AKA just create a child that shares the parents memory, and waits for the parent to exit and then cleans things up.
That should not need any new kernel mechanisms.
Of course, but this also means that it's not possible to stop the OOM killer while the teardown is in progress, and will require userspace changes on a case-by-case basis.
Anyway, I will try to kludge something together with clone
Quoted 5 lines
There is the other question: why this is disastrously slow on s390? Is this a s390 specific issue? Can the issue be fixed by optimizing
It's a hardware issue with protected VMs, which are achieved on s390x without memory encryption. When a protected VM terminates, the secure/trusted firmware needs to clear all protected memory, and change the security properties to make it accessible. This last step in particular takes more time than just clearing memory.
Quoted 3 lines
what is happening on s390?
Eric
Michal Hocko
reviewerRe: [RFC v1 2/4] kernel/fork.c: implement new process_mmput_async syscall
On Fri 12-11-21 17:53:09, Claudio Imbrenda wrote:
[...]
Quoted 2 lines
Of course, but this also means that it's not possible to stop the OOM killer while the teardown is in progress,
Blocking the OOM killer and depend on the userspace to make a forward progress is not acceptable solution.
Signature · 2 lines
Michal Hocko SUSE Labs
RFC 3/4 mm: wire up the process_mmput_async syscall
In reply to Claudio ImbrendaWire up the process_mmput_async syscall.
--- arch/alpha/kernel/syscalls/syscall.tbl | 2 ++ arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 2 ++ arch/ia64/kernel/syscalls/syscall.tbl | 2 ++ arch/m68k/kernel/syscalls/syscall.tbl | 2 ++ arch/microblaze/kernel/syscalls/syscall.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_n32.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_n64.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_o32.tbl | 2 ++ arch/parisc/kernel/syscalls/syscall.tbl | 2 ++ arch/powerpc/kernel/syscalls/syscall.tbl | 2 ++ arch/s390/kernel/syscalls/syscall.tbl | 2 ++ arch/sh/kernel/syscalls/syscall.tbl | 2 ++ arch/sparc/kernel/syscalls/syscall.tbl | 2 ++ arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 2 ++ include/linux/syscalls.h | 1 + include/uapi/asm-generic/unistd.h | 5 ++++- kernel/sys_ni.c | 1 + 21 files changed, 38 insertions(+), 2 deletions(-)
arch/alpha/kernel/syscalls/syscall.tbl +2 -0
@@ -488,3 +488,5 @@ 556 common landlock_restrict_self sys_landlock_restrict_self # 557 reserved for memfd_secret 558 common process_mrelease sys_process_mrelease +# 559 reserved for futex_waitv +560 common process_mmput_async sys_process_mmput_async
arch/arm/tools/syscall.tbl +1 -0
@@ -463,3 +463,4 @@ # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/arm64/include/asm/unistd.h +1 -1
@@ -38,7 +38,7 @@#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800) -#define __NR_compat_syscalls 450 +#define __NR_compat_syscalls 451#endif #define __ARCH_WANT_SYS_CLONE
arch/arm64/include/asm/unistd32.h +2 -0
@@ -905,6 +905,8 @@ __SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self) __SYSCALL(__NR_process_mrelease, sys_process_mrelease)#define __NR_futex_waitv 449 __SYSCALL(__NR_futex_waitv, sys_futex_waitv) +#define __NR_process_mmput_async 450 +__SYSCALL (__NR_process_mmput_async, sys_process_mmput_async)/* * Please add new compat syscalls above this comment and update
arch/ia64/kernel/syscalls/syscall.tbl +2 -0
@@ -369,3 +369,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/m68k/kernel/syscalls/syscall.tbl +2 -0
@@ -448,3 +448,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/microblaze/kernel/syscalls/syscall.tbl +2 -0
@@ -454,3 +454,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/mips/kernel/syscalls/syscall_n32.tbl +2 -0
@@ -387,3 +387,5 @@ 446 n32 landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 n32 process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/mips/kernel/syscalls/syscall_n64.tbl +2 -0
@@ -363,3 +363,5 @@ 446 n64 landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 n64 process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/mips/kernel/syscalls/syscall_o32.tbl +2 -0
@@ -436,3 +436,5 @@ 446 o32 landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 o32 process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/parisc/kernel/syscalls/syscall.tbl +2 -0
@@ -446,3 +446,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/powerpc/kernel/syscalls/syscall.tbl +2 -0
@@ -528,3 +528,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/s390/kernel/syscalls/syscall.tbl +2 -0
@@ -451,3 +451,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async sys_process_mmput_async
arch/sh/kernel/syscalls/syscall.tbl +2 -0
@@ -451,3 +451,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/sparc/kernel/syscalls/syscall.tbl +2 -0
@@ -494,3 +494,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
arch/x86/entry/syscalls/syscall_32.tbl +1 -0
@@ -454,3 +454,4 @@ 447 i386 memfd_secret sys_memfd_secret 448 i386 process_mrelease sys_process_mrelease 449 i386 futex_waitv sys_futex_waitv +450 i386 process_mmput_async sys_process_mmput_async
arch/x86/entry/syscalls/syscall_64.tbl +1 -0
@@ -371,6 +371,7 @@ 447 common memfd_secret sys_memfd_secret 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv +450 common process_mmput_async sys_process_mmput_async # # Due to a historical design error, certain syscalls are numbered differently
arch/xtensa/kernel/syscalls/syscall.tbl +2 -0
@@ -419,3 +419,5 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +# 449 reserved for futex_waitv +450 common process_mmput_async sys_process_mmput_async
include/linux/syscalls.h +1 -0
@@ -920,6 +920,7 @@ asmlinkage long sys_mincore(unsigned long start, size_t len,asmlinkage long sys_madvise (unsigned long start,size_t len,int behavior);asmlinkage long sys_process_madvise (int pidfd,const struct iovec __user *vec,size_t vlen,int behavior,unsigned int flags); +asmlinkage long sys_process_mmput_async (int pidfd,unsigned int flags);asmlinkage long sys_process_mrelease (int pidfd,unsigned int flags); asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff,
include/uapi/asm-generic/unistd.h +4 -1
@@ -883,8 +883,11 @@ __SYSCALL(__NR_process_mrelease, sys_process_mrelease)#define __NR_futex_waitv 449 __SYSCALL(__NR_futex_waitv, sys_futex_waitv) +#define __NR_process_mmput_async 450 +__SYSCALL(__NR_process_mmput_async, sys_process_mmput_async) +#undef __NR_syscalls -#define __NR_syscalls 450 +#define __NR_syscalls 451/* * 32 bit systems traditionally used different
kernel/sys_ni.c +1 -0
@@ -290,6 +290,7 @@ COND_SYSCALL(munlockall);COND_SYSCALL (mincore);COND_SYSCALL (madvise);COND_SYSCALL (process_madvise); +COND_SYSCALL (process_mmput_async);COND_SYSCALL (process_mrelease);COND_SYSCALL (remap_file_pages);COND_SYSCALL (mbind);
Signature · 1 line
2.31.1
kernel test robot
build botRe: [RFC v1 3/4] mm: wire up the process_mmput_async syscall
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Claudio,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on linus/master]
[also build test WARNING on v5.16-rc1]
[cannot apply to arnd-asm-generic/master arm64/for-next/core tip/x86/asm next-20211118] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Claudio-Imbrenda/Two-alternatives-for-mm-async-teardown/20211111-175434 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git debe436e77c72fcee804fb867f275e6d31aa999c config: arm64-defconfig (attached as .config) compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f5f328513634dfb3d6c4a57e604445e9619d041f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Claudio-Imbrenda/Two-alternatives-for-mm-async-teardown/20211111-175434 git checkout f5f328513634dfb3d6c4a57e604445e9619d041f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
| ^~~~~~~~~~~~
kernel/sys_ni.c:268:1: note: in expansion of macro 'COND_SYSCALL'
268 | COND_SYSCALL(keyctl);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:41:32: warning: no previous prototype for '__arm64_compat_sys_keyctl' [-Wmissing-prototypes]
41 | asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~~~~~~~~
kernel/sys_ni.c:269:1: note: in expansion of macro 'COND_SYSCALL_COMPAT'
269 | COND_SYSCALL_COMPAT(keyctl);
| ^~~~~~~~~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_landlock_create_ruleset' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:272:1: note: in expansion of macro 'COND_SYSCALL'
272 | COND_SYSCALL(landlock_create_ruleset);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_landlock_add_rule' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:273:1: note: in expansion of macro 'COND_SYSCALL'
273 | COND_SYSCALL(landlock_add_rule);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_landlock_restrict_self' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:274:1: note: in expansion of macro 'COND_SYSCALL'
274 | COND_SYSCALL(landlock_restrict_self);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_fadvise64_64' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:279:1: note: in expansion of macro 'COND_SYSCALL'
279 | COND_SYSCALL(fadvise64_64);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_swapon' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:282:1: note: in expansion of macro 'COND_SYSCALL'
282 | COND_SYSCALL(swapon);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_swapoff' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:283:1: note: in expansion of macro 'COND_SYSCALL'
283 | COND_SYSCALL(swapoff);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_mprotect' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:284:1: note: in expansion of macro 'COND_SYSCALL'
284 | COND_SYSCALL(mprotect);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_msync' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:285:1: note: in expansion of macro 'COND_SYSCALL'
285 | COND_SYSCALL(msync);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_mlock' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:286:1: note: in expansion of macro 'COND_SYSCALL'
286 | COND_SYSCALL(mlock);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_munlock' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:287:1: note: in expansion of macro 'COND_SYSCALL'
287 | COND_SYSCALL(munlock);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_mlockall' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:288:1: note: in expansion of macro 'COND_SYSCALL'
288 | COND_SYSCALL(mlockall);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_munlockall' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:289:1: note: in expansion of macro 'COND_SYSCALL'
289 | COND_SYSCALL(munlockall);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_mincore' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:290:1: note: in expansion of macro 'COND_SYSCALL'
290 | COND_SYSCALL(mincore);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_madvise' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:291:1: note: in expansion of macro 'COND_SYSCALL'
291 | COND_SYSCALL(madvise);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_process_madvise' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:292:1: note: in expansion of macro 'COND_SYSCALL'
292 | COND_SYSCALL(process_madvise);
| ^~~~~~~~~~~~
>> arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_process_mmput_async' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:293:1: note: in expansion of macro 'COND_SYSCALL'
293 | COND_SYSCALL(process_mmput_async);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_process_mrelease' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:294:1: note: in expansion of macro 'COND_SYSCALL'
294 | COND_SYSCALL(process_mrelease);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_remap_file_pages' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:295:1: note: in expansion of macro 'COND_SYSCALL'
295 | COND_SYSCALL(remap_file_pages);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_mbind' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:296:1: note: in expansion of macro 'COND_SYSCALL'
296 | COND_SYSCALL(mbind);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_get_mempolicy' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:297:1: note: in expansion of macro 'COND_SYSCALL'
297 | COND_SYSCALL(get_mempolicy);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_set_mempolicy' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:298:1: note: in expansion of macro 'COND_SYSCALL'
298 | COND_SYSCALL(set_mempolicy);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_migrate_pages' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:299:1: note: in expansion of macro 'COND_SYSCALL'
299 | COND_SYSCALL(migrate_pages);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_move_pages' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:300:1: note: in expansion of macro 'COND_SYSCALL'
300 | COND_SYSCALL(move_pages);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_perf_event_open' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:302:1: note: in expansion of macro 'COND_SYSCALL'
302 | COND_SYSCALL(perf_event_open);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_accept4' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:303:1: note: in expansion of macro 'COND_SYSCALL'
303 | COND_SYSCALL(accept4);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_recvmmsg' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:304:1: note: in expansion of macro 'COND_SYSCALL'
304 | COND_SYSCALL(recvmmsg);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_recvmmsg_time32' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:305:1: note: in expansion of macro 'COND_SYSCALL'
305 | COND_SYSCALL(recvmmsg_time32);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:41:32: warning: no previous prototype for '__arm64_compat_sys_recvmmsg_time32' [-Wmissing-prototypes]
41 | asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~~~~~~~~
kernel/sys_ni.c:306:1: note: in expansion of macro 'COND_SYSCALL_COMPAT'
306 | COND_SYSCALL_COMPAT(recvmmsg_time32);
| ^~~~~~~~~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:41:32: warning: no previous prototype for '__arm64_compat_sys_recvmmsg_time64' [-Wmissing-prototypes]
41 | asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~~~~~~~~
kernel/sys_ni.c:307:1: note: in expansion of macro 'COND_SYSCALL_COMPAT'
307 | COND_SYSCALL_COMPAT(recvmmsg_time64);
| ^~~~~~~~~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_fanotify_init' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:314:1: note: in expansion of macro 'COND_SYSCALL'
314 | COND_SYSCALL(fanotify_init);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_fanotify_mark' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:315:1: note: in expansion of macro 'COND_SYSCALL'
315 | COND_SYSCALL(fanotify_mark);
| ^~~~~~~~~~~~
arch/arm64/include/asm/syscall_wrapper.h:76:32: warning: no previous prototype for '__arm64_sys_name_to_handle_at' [-Wmissing-prototypes]
76 | asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
| ^~~~~~~~~~~~
kernel/sys_ni.c:318:1: note: in expansion of macro 'COND_SYSCALL'
318 | COND_SYSCALL(name_to_handle_at);vim +/__arm64_sys_process_mmput_async +76 arch/arm64/include/asm/syscall_wrapper.h
4378a7d4be30ec Mark Rutland 2018-07-11 50
4378a7d4be30ec Mark Rutland 2018-07-11 51 #define __SYSCALL_DEFINEx(x, name, ...) \
4378a7d4be30ec Mark Rutland 2018-07-11 52 asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \
4378a7d4be30ec Mark Rutland 2018-07-11 53 ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \
4378a7d4be30ec Mark Rutland 2018-07-11 54 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
4378a7d4be30ec Mark Rutland 2018-07-11 55 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
4378a7d4be30ec Mark Rutland 2018-07-11 56 asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \
4378a7d4be30ec Mark Rutland 2018-07-11 57 { \
4378a7d4be30ec Mark Rutland 2018-07-11 58 return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \
4378a7d4be30ec Mark Rutland 2018-07-11 59 } \
4378a7d4be30ec Mark Rutland 2018-07-11 60 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
4378a7d4be30ec Mark Rutland 2018-07-11 61 { \
4378a7d4be30ec Mark Rutland 2018-07-11 62 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
4378a7d4be30ec Mark Rutland 2018-07-11 63 __MAP(x,__SC_TEST,__VA_ARGS__); \
4378a7d4be30ec Mark Rutland 2018-07-11 64 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
4378a7d4be30ec Mark Rutland 2018-07-11 65 return ret; \
4378a7d4be30ec Mark Rutland 2018-07-11 66 } \
4378a7d4be30ec Mark Rutland 2018-07-11 67 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
4378a7d4be30ec Mark Rutland 2018-07-11 68
4378a7d4be30ec Mark Rutland 2018-07-11 69 #define SYSCALL_DEFINE0(sname) \
4378a7d4be30ec Mark Rutland 2018-07-11 70 SYSCALL_METADATA(_##sname, 0); \
0e358bd7b7ebd2 Sami Tolvanen 2019-05-24 71 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \
4378a7d4be30ec Mark Rutland 2018-07-11 72 ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \
0e358bd7b7ebd2 Sami Tolvanen 2019-05-24 73 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused)
4378a7d4be30ec Mark Rutland 2018-07-11 74
c27eccfe4d6c74 Sami Tolvanen 2019-09-10 75 #define COND_SYSCALL(name) \
c27eccfe4d6c74 Sami Tolvanen 2019-09-10 @76 asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
c27eccfe4d6c74 Sami Tolvanen 2019-09-10 77 { \
c27eccfe4d6c74 Sami Tolvanen 2019-09-10 78 return sys_ni_syscall(); \
c27eccfe4d6c74 Sami Tolvanen 2019-09-10 79 }4378a7d4be30ec Mark Rutland 2018-07-11 80
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
RFC 4/4 kernel/fork.c: process_mmput_async: stop OOM while freeing memory
In reply to Claudio ImbrendaThis patch implements a simple OOM notifier to stop the OOM killer while a mm is being reclaimed asynchronously using the process_mmput_async syscall.
Tested on s390x.
--- kernel/fork.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
kernel/fork.c +28 -0
@@ -118,6 +118,11 @@*/ #define MAX_THREADS FUTEX_TID_MASK +/* +* Priority for the OOM notifier used in process_mmput_async +*/ +#define PROCESS_MMPUT_ASYNC_OOM_NOTIFY_PRIORITY 70 +/* * Protected counters by write_lock_irq(&tasklist_lock) */
@@ -3203,13 +3208,27 @@ int sysctl_max_threads(struct ctl_table *table, int write,return 0 ; } +/* Prevent the OOM from being triggered while we are cleaning up asynchronously */ +static int mmput_async_oom_notifier (struct notifier_block *nb,unsigned long dummy,void *parm) +{ +/* +* We cannot know the speed at which pages are being freed, so we +* fake it and say it's at least one. This is already enough to +* stop the OOM killer. +*/ + *(unsigned long *)parm +=PAGE_SIZE ; +return NOTIFY_OK ; +} + SYSCALL_DEFINE2(process_mmput_async, int, pidfd, unsigned int, flags) {#ifdef CONFIG_MMU +struct notifier_block oom_nb;struct mm_struct *mm =NULL ;struct task_struct *task;unsigned int tmp;struct pid *pid; +int r;if (flags)return -EINVAL ;
@@ -3280,8 +3299,17 @@ SYSCALL_DEFINE2(process_mmput_async, int, pidfd, unsigned int, flags)if (atomic_read (&mm->mm_users))panic ("mm_users not 0 but trying to __mmput anyway!" ); +/* +* Register an OOM notifier, to stop the OOM while we are +* asynchronously freeing the mm. +*/ + oom_nb.priority =PROCESS_MMPUT_ASYNC_OOM_NOTIFY_PRIORITY ; + oom_nb.notifier_call = mmput_async_oom_notifier; + r =register_oom_notifier (&oom_nb);/* Do the actual work */ __mmput (mm); +if (!r) +unregister_oom_notifier (&oom_nb);/* And put the extra reference taken above */ mmdrop (mm);
Signature · 1 line
2.31.1
Michal Hocko
reviewerQuoted 2 lines · Claudio Imbrenda
This RFC series proposes two possible ways for enabling asynchronous mm teardown.
It would be great to describe an intended usecase here and also explain why the existing features do not allow the required functionality.
Please also make sure to cc linux-api when adding a new user visible interface or changing a visible behavior of existing one.
E.g. why cannot you simply create a process outside of the thread group yet share the mm with your task. Once the other process exits which you can detect then you just exit that process and do the finall clean up from that context?
Quoted 4 lines
The first approach, in patch 1, is simply to provide an arch hook in
exit_mm. This has no functional change for archs that don't explicitly use the hook, and leaves the hard part to arch code (including accounting, if any).
This is just too vague but I have to say I am not really a fan of hooks that considerably change the existing behavior.
Quoted 5 lines
The second approach, in patches 2 to 4, adds a new syscall to allow an mm to be asynchronously torn down in the context of another process (similarly to how
process_mreleaseworks). It also adds an OOM notifier to prevent the OOM killer from killing processes while the teardown is in progress.
I have to say I do not like oom notifier part at all. You can have different sources of the OOM (memcg, cpusets or global oom). It is impossible to tell those appart in the notifier. Not to mention that memcg oom is explicitly avoiding notifiers altogether.
Signature · 2 lines
Michal Hocko SUSE Labs