Skip to contentSkip to conversation

Add MM_DEAD flag to struct mm_struct

PATCH/RFC Benjamin Herrenschmidt 1 participant 4 messages Jul 27, 2007

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Some architectures like sparc can do useful optimizations when knowing that an entire MM is being destroyed. At the moment, they rely on fullmm in the mmu_gather structure. However, that doesn't always work out very well with some of the changes we are doing. Among other things, the TLB flushing on sparc64 is done using per-CPU tracking data, making the batch not per-CPU will break that link.

So instead, we add a new flag to struct mm_struct that indicates that the mm is going away, for those archs to use. It also allows to use it in situations (such as PTE ops) where the batch isn't accessible (or there is no batch)

---

include/linux/sched.h +1 -0
Index: linux-work/include/linux/sched.h
===================================================================
@@ -353,6 +353,7 @@ extern int get_dumpable(struct mm_struct
 #define MMF_DUMPABLE      0  /* core dump is permitted */
 #define MMF_DUMP_SECURELY 1  /* core file is readable only by root */
 #define MMF_DUMPABLE_BITS 2
+#define MMF_DEAD          3  /* mm is being destroyed */
 
 /* coredump filter bits */
 #define MMF_DUMP_ANON_PRIVATE	2
mm/mmap.c +3 -0
Index: linux-work/mm/mmap.c
===================================================================
@@ -1991,6 +1991,9 @@ void exit_mmap(struct mm_struct *mm)
 	unsigned long nr_accounted = 0;
 	unsigned long end;
 
+	/* Mark the MM as dead */
+	__set_bit(MMF_DEAD, &mm->flags);
+
 	/* mm's last user has gone, and its about to be pulled down */
 	arch_exit_mmap(mm);
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 11 lines · Benjamin Herrenschmidt

Some architectures like sparc can do useful optimizations when knowing that an entire MM is being destroyed. At the moment, they rely on fullmm in the mmu_gather structure. However, that doesn't always work out very well with some of the changes we are doing. Among other things, the TLB flushing on sparc64 is done using per-CPU tracking data, making the batch not per-CPU will break that link.

So instead, we add a new flag to struct mm_struct that indicates that the mm is going away, for those archs to use. It also allows to use it in situations (such as PTE ops) where the batch isn't accessible (or there is no batch)

And the patch forgets to clear it in mm_init ... will send a new one later.

Cheers,
Ben.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

[PATCH/RFC] Add MM_DEAD flag to struct mm_struct #2

In reply to Benjamin Herrenschmidt

Some architectures like sparc can do useful optimizations when knowing that an entire MM is being destroyed. At the moment, they rely on fullmm in the mmu_gather structure. However, that doesn't always work out very well with some of the changes we are doing. Among other things, the TLB flushing on sparc64 is done using per-CPU tracking data, making the batch not per-CPU will break that link.

So instead, we add a new flag to struct mm_struct that indicates that the mm is going away, for those archs to use. It also allows to use it in situations (such as PTE ops) where the batch isn't accessible (or there is no batch)

---

And here's a version that clears it too...

include/linux/sched.h +1 -0
Index: linux-work/include/linux/sched.h
===================================================================
@@ -353,6 +353,7 @@ extern int get_dumpable(struct mm_struct
 #define MMF_DUMPABLE      0  /* core dump is permitted */
 #define MMF_DUMP_SECURELY 1  /* core file is readable only by root */
 #define MMF_DUMPABLE_BITS 2
+#define MMF_DEAD          3  /* mm is being destroyed */
 
 /* coredump filter bits */
 #define MMF_DUMP_ANON_PRIVATE	2
mm/mmap.c +3 -0
Index: linux-work/mm/mmap.c
===================================================================
@@ -1991,6 +1991,9 @@ void exit_mmap(struct mm_struct *mm)
 	unsigned long nr_accounted = 0;
 	unsigned long end;
 
+	/* Mark the MM as dead */
+	__set_bit(MMF_DEAD, &mm->flags);
+
 	/* mm's last user has gone, and its about to be pulled down */
 	arch_exit_mmap(mm);
 
kernel/fork.c +1 -0
Index: linux-work/kernel/fork.c
===================================================================
@@ -336,6 +336,7 @@ static struct mm_struct * mm_init(struct
 	INIT_LIST_HEAD(&mm->mmlist);
 	mm->flags = (current->mm) ? current->mm->flags
 				  : MMF_DUMP_FILTER_DEFAULT;
+	__clear_bit(MMF_DEAD, &mm->flags);
 	mm->core_waiters = 0;
 	mm->nr_ptes = 0;
 	set_mm_counter(mm, file_rss, 0);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw

[PATCH/RFC] Add MM_DEAD flag to struct mm_struct #3

Some architectures like sparc can do useful optimizations when knowing that an entire MM is being destroyed. At the moment, they rely on fullmm in the mmu_gather structure. However, that doesn't always work out very well with some of the changes we are doing. Among other things, the TLB flushing on sparc64 is done using per-CPU tracking data, making the batch not per-CPU will break that link.

So instead, we add a new flag to struct mm_struct that indicates that the mm is going away, for those archs to use. It also allows to use it in situations (such as PTE ops) where the batch isn't accessible (or there is no batch)

---

And because I really have shit in my eyes today, here's a version that doesn't use a bit already used for something else... yuck.

Thanks David !

include/linux/sched.h +2 -0
Index: linux-work/include/linux/sched.h
===================================================================
@@ -366,6 +366,8 @@ extern int get_dumpable(struct mm_struct
 #define MMF_DUMP_FILTER_DEFAULT \
 	((1 << MMF_DUMP_ANON_PRIVATE) |	(1 << MMF_DUMP_ANON_SHARED))
 
+#define MMF_DEAD          	6  /* mm is being destroyed */
+
 struct mm_struct {
 	struct vm_area_struct * mmap;		/* list of VMAs */
 	struct rb_root mm_rb;
mm/mmap.c +3 -0
Index: linux-work/mm/mmap.c
===================================================================
@@ -1991,6 +1991,9 @@ void exit_mmap(struct mm_struct *mm)
 	unsigned long nr_accounted = 0;
 	unsigned long end;
 
+	/* Mark the MM as dead */
+	__set_bit(MMF_DEAD, &mm->flags);
+
 	/* mm's last user has gone, and its about to be pulled down */
 	arch_exit_mmap(mm);
 
kernel/fork.c +1 -0
Index: linux-work/kernel/fork.c
===================================================================
@@ -336,6 +336,7 @@ static struct mm_struct * mm_init(struct
 	INIT_LIST_HEAD(&mm->mmlist);
 	mm->flags = (current->mm) ? current->mm->flags
 				  : MMF_DUMP_FILTER_DEFAULT;
+	__clear_bit(MMF_DEAD, &mm->flags);
 	mm->core_waiters = 0;
 	mm->nr_ptes = 0;
 	set_mm_counter(mm, file_rss, 0);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>