The patch titled Subject: mm: oom_kill: add trace logs in process_mrelease() system call has been added to the -mm mm-unstable branch. Its filename is mm-oom_kill-add-trace-logs-in-process_mrelease-system-call.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-oom_kill-add-trace-logs-in-process_mrelease-system-call.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Charan Teja Kalla <quic_charante@xxxxxxxxxxx> Subject: mm: oom_kill: add trace logs in process_mrelease() system call Date: Tue, 16 Aug 2022 11:30:17 +0530 The process_mrelease() system call is used to release the memory of a dying process from the context of the caller, which is similar to and uses the functions of the oom reaper logic. There exist trace logs for a process when reaped by the oom reaper. Just extend the same to when done by the process_mrelease() system call. This patch provides information on how much memory is freed from a process which is being reaped. Adding trace events in the process_mrelease() path when process is being reaped would enable more holistic debug as it happens in oom_reap_task_mm() currently. This extends the debug functionality for the events as described in [1] to the process_mrelease() system call. Now the coverage of trace events is complete. [1] https://lore.kernel.org/all/20170530185231.GA13412@castle/T/#u Link: https://lkml.kernel.org/r/20220816060017.17996-1-pbrahma@xxxxxxxxxxxxxxxx Signed-off-by: Charan Teja Kalla <quic_charante@xxxxxxxxxxx> Signed-off-by: Pratyush Brahma <quic_pbrahma@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/oom_kill.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) --- a/mm/oom_kill.c~mm-oom_kill-add-trace-logs-in-process_mrelease-system-call +++ a/mm/oom_kill.c @@ -995,7 +995,6 @@ static void __oom_kill_process(struct ta mmdrop(mm); put_task_struct(victim); } -#undef K /* * Kill provided task unless it's secured by setting @@ -1241,17 +1240,33 @@ SYSCALL_DEFINE2(process_mrelease, int, p goto drop_mm; if (mmap_read_lock_killable(mm)) { + trace_skip_task_reaping(task->pid); ret = -EINTR; - goto drop_mm; + goto read_unlock; } /* * Check MMF_OOM_SKIP again under mmap_read_lock protection to ensure * possible change in exit_mmap is seen */ - if (!test_bit(MMF_OOM_SKIP, &mm->flags) && !__oom_reap_task_mm(mm)) + if (test_bit(MMF_OOM_SKIP, &mm->flags)) { + trace_skip_task_reaping(task->pid); + goto read_unlock; + } + + trace_start_task_reaping(task->pid); + + if (!__oom_reap_task_mm(mm)) ret = -EAGAIN; - mmap_read_unlock(mm); + pr_debug("process_mrelease: reaped process %d (%s), now anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n", + task_pid_nr(task), task->comm, + K(get_mm_counter(mm, MM_ANONPAGES)), + K(get_mm_counter(mm, MM_FILEPAGES)), + K(get_mm_counter(mm, MM_SHMEMPAGES))); + trace_finish_task_reaping(task->pid); + +read_unlock: + mmap_read_unlock(mm); drop_mm: mmdrop(mm); put_task: @@ -1261,3 +1276,4 @@ put_task: return -ENOSYS; #endif /* CONFIG_MMU */ } +#undef K _ Patches currently in -mm which might be from quic_charante@xxxxxxxxxxx are mm-page_ext-remove-unused-variable-in-offline_page_ext.patch mm-fix-use-after-free-of-page_ext-after-race-with-memory-offline.patch mm-cma_debug-show-complete-cma-name-in-debugfs-directories.patch mm-oom_kill-add-trace-logs-in-process_mrelease-system-call.patch