Thread (1 message) 1 message, 1 author, 2023-11-28

Re: [RFC PATCH 04/11] mm/mempolicy: modify get_mempolicy call stack to take a task argument

From: Michal Hocko <mhocko@suse.com>
Date: 2023-11-28 14:49:11
Also in: linux-arch, linux-doc, linux-fsdevel, linux-mm, lkml

[restoring the CC list as I believe this was not meant to be a private
response]

On Tue 28-11-23 09:12:35, Gregory Price wrote:
On Tue, Nov 28, 2023 at 03:07:28PM +0100, Michal Hocko wrote:
quoted
On Wed 22-11-23 16:11:53, Gregory Price wrote:
[...]
quoted
@@ -928,7 +929,16 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
 		 * vma/shared policy at addr is NULL.  We
 		 * want to return MPOL_DEFAULT in this case.
 		 */
-		mm = current->mm;
+		if (task == current) {
+			/*
+			 * original behavior allows a kernel task changing its
+			 * own policy to avoid the condition in get_task_mm,
+			 * so we'll directly access
+			 */
+			mm = task->mm;
+			mmget(mm);
Do we actually have any kernel thread that would call this? Does it
actually make sense to support?
This was changed in the upcoming v2 by using the pidfd interface for
referencing both the task and the mm, so this code is a bit dead.
OK, that is the right thing to do IMHO. Allowing modifications on memory
policies on borrowed mms sounds rather weird and if we do not have any
actual usecases that would require that support then I would rather not
open that possibility at all.

-- 
Michal Hocko
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help