Thread (16 messages) 16 messages, 4 authors, 2021-12-01

Re: [PATCH v5 2/3] mm/mempolicy: add set_mempolicy_home_node syscall

From: Aneesh Kumar K.V <hidden>
Date: 2021-12-01 06:16:05
Also in: linux-mm

Daniel Jordan [off-list ref] writes:
On Tue, Nov 16, 2021 at 12:12:37PM +0530, Aneesh Kumar K.V wrote:
quoted
sys_set_mempolicy_home_node((unsigned long)p, nr_pages * page_size,
				  home_node, 0);
What about sys_mbind_home_node so the name is better aligned with mbind,
since both operate on vma policy?  The syscall might or might not be
extended to task memory policy, but vma policy is what we're using this
for today.
I used the name set_mempolicy_home_node, because we are setting the home
for a memory policy. I find the term mbind confusing. 
quoted
+SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, len,
+		unsigned long, home_node, unsigned long, flags)
mbind does untagged_addr(addr), why doesn't this need to do the same?
Seems like tagged addresses could be passed here too.
updated
modified   mm/mempolicy.c
@@ -1489,6 +1489,7 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le
 	unsigned long end;
 	int err = -ENOENT;
 
+	start = untagged_addr(start);
 	if (start & ~PAGE_MASK)
 		return -EINVAL;
 	/*


quoted
+		/*
+		 * Only update home node if there is an existing vma policy
+		 */
+		if (!new)
+			continue;
+		new->home_node = home_node;
+		err = mbind_range(mm, vmstart, vmend, new);
I think you need an mpol_put(new) here since @new is dup'ed again during
mbind_range > vma_replace_policy.
updated
@@ -1536,6 +1540,7 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le
 
 		new->home_node = home_node;
 		err = mbind_range(mm, vmstart, vmend, new);
+		mpol_put(new);
 		if (err)
 			break;
 	}

Thanks for your review
-aneesh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help