|
@@ -2904,6 +2904,28 @@ static inline unsigned long sigsp(unsigned long sp, struct ksignal *ksig)
|
|
|
*/
|
|
|
extern struct mm_struct * mm_alloc(void);
|
|
|
|
|
|
+/**
|
|
|
+ * mmgrab() - Pin a &struct mm_struct.
|
|
|
+ * @mm: The &struct mm_struct to pin.
|
|
|
+ *
|
|
|
+ * Make sure that @mm will not get freed even after the owning task
|
|
|
+ * exits. This doesn't guarantee that the associated address space
|
|
|
+ * will still exist later on and mmget_not_zero() has to be used before
|
|
|
+ * accessing it.
|
|
|
+ *
|
|
|
+ * This is a preferred way to to pin @mm for a longer/unbounded amount
|
|
|
+ * of time.
|
|
|
+ *
|
|
|
+ * Use mmdrop() to release the reference acquired by mmgrab().
|
|
|
+ *
|
|
|
+ * See also <Documentation/vm/active_mm.txt> for an in-depth explanation
|
|
|
+ * of &mm_struct.mm_count vs &mm_struct.mm_users.
|
|
|
+ */
|
|
|
+static inline void mmgrab(struct mm_struct *mm)
|
|
|
+{
|
|
|
+ atomic_inc(&mm->mm_count);
|
|
|
+}
|
|
|
+
|
|
|
/* mmdrop drops the mm and the page tables */
|
|
|
extern void __mmdrop(struct mm_struct *);
|
|
|
static inline void mmdrop(struct mm_struct *mm)
|