Thread (29 messages) 29 messages, 10 authors, 2021-07-18

Re: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall

From: Andrei Vagin <hidden>
Date: 2021-04-23 07:02:02
Also in: linux-um, lkml

On Wed, Apr 14, 2021 at 07:09:15PM +0200, Oleg Nesterov wrote:
On 04/13, Andrei Vagin wrote:
quoted
+static void swap_mm(struct mm_struct *prev_mm, struct mm_struct *target_mm)
+{
+	struct task_struct *tsk = current;
+	struct mm_struct *active_mm;
+
+	task_lock(tsk);
+	/* Hold off tlb flush IPIs while switching mm's */
+	local_irq_disable();
+
+	sync_mm_rss(prev_mm);
+
+	vmacache_flush(tsk);
+
+	active_mm = tsk->active_mm;
+	if (active_mm != target_mm) {
+		mmgrab(target_mm);
+		tsk->active_mm = target_mm;
+	}
+	tsk->mm = target_mm;
+	switch_mm_irqs_off(active_mm, target_mm, tsk);
+	local_irq_enable();
+	task_unlock(tsk);
+#ifdef finish_arch_post_lock_switch
+	finish_arch_post_lock_switch();
+#endif
+
+	if (active_mm != target_mm)
+		mmdrop(active_mm);
+}
I think this should be unified with kthread_use_mm() somehow...
I agree.
And does it really need the "prev_mm" argument? It must be tsk->mm, no?
No, it doesn't. It is leftover of unuse_mm. BTW why do we pass mm to kthread_unuse_mm?

Thanks,
Andrei.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help