From: Andrew Morton <akpm@linux-foundation.org>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: oleg@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] get_task_exe_file: check PF_KTHREAD locklessly
Date: Thu, 21 Nov 2024 22:35:09 -0800 [thread overview]
Message-ID: <20241121223509.a77731933dd7fb3e1728eacc@linux-foundation.org> (raw)
In-Reply-To: <20241119143526.704986-1-mjguzik@gmail.com>
On Tue, 19 Nov 2024 15:35:26 +0100 Mateusz Guzik <mjguzik@gmail.com> wrote:
> Same thing as 8ac5dc66599c ("get_task_mm: check PF_KTHREAD lockless")
We prefer that patches have fuller changelogs, please.
I copied the 8ac5dc66599c changelog text into this patch's changelog.
From: Mateusz Guzik <mjguzik@gmail.com>
Subject: get_task_exe_file: check PF_KTHREAD locklessly
Date: Tue, 19 Nov 2024 15:35:26 +0100
Same thing as 8ac5dc66599c ("get_task_mm: check PF_KTHREAD lockless")
Nowadays PF_KTHREAD is sticky and it was never protected by ->alloc_lock.
Move the PF_KTHREAD check outside of task_lock() section to make this code
more understandable.
Link: https://lkml.kernel.org/r/20241119143526.704986-1-mjguzik@gmail.com
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/fork.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--- a/kernel/fork.c~get_task_exe_file-check-pf_kthread-locklessly
+++ a/kernel/fork.c
@@ -1496,12 +1496,13 @@ struct file *get_task_exe_file(struct ta
struct file *exe_file = NULL;
struct mm_struct *mm;
+ if (task->flags & PF_KTHREAD)
+ return NULL;
+
task_lock(task);
mm = task->mm;
- if (mm) {
- if (!(task->flags & PF_KTHREAD))
- exe_file = get_mm_exe_file(mm);
- }
+ if (mm)
+ exe_file = get_mm_exe_file(mm);
task_unlock(task);
return exe_file;
}
_
prev parent reply other threads:[~2024-11-22 6:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 14:35 Mateusz Guzik
2024-11-19 15:05 ` Oleg Nesterov
2024-11-22 6:35 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241121223509.a77731933dd7fb3e1728eacc@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®