summaryrefslogtreecommitdiff
path: root/c_src/include/linux/sched/mm.h
diff options
context:
space:
mode:
Diffstat (limited to 'c_src/include/linux/sched/mm.h')
-rw-r--r--c_src/include/linux/sched/mm.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/c_src/include/linux/sched/mm.h b/c_src/include/linux/sched/mm.h
new file mode 100644
index 00000000..03feda7a
--- /dev/null
+++ b/c_src/include/linux/sched/mm.h
@@ -0,0 +1,31 @@
+#ifndef _LINUX_SCHED_MM_H
+#define _LINUX_SCHED_MM_H
+
+#define PF_MEMALLOC 0x00000800 /* Allocating memory */
+#define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */
+
+static inline unsigned int memalloc_nofs_save(void)
+{
+ unsigned int flags = current->flags & PF_MEMALLOC_NOFS;
+ current->flags |= PF_MEMALLOC_NOFS;
+ return flags;
+}
+
+static inline void memalloc_nofs_restore(unsigned int flags)
+{
+ current->flags = (current->flags & ~PF_MEMALLOC_NOFS) | flags;
+}
+
+static inline unsigned int memalloc_noreclaim_save(void)
+{
+ unsigned int flags = current->flags & PF_MEMALLOC;
+ current->flags |= PF_MEMALLOC;
+ return flags;
+}
+
+static inline void memalloc_noreclaim_restore(unsigned int flags)
+{
+ current->flags = (current->flags & ~PF_MEMALLOC) | flags;
+}
+
+#endif /* _LINUX_SCHED_MM_H */