@@ -3130,5 +3130,10 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping,
extern int sysctl_nr_trim_pages;
+
+/* Page exclusive access do depend on some helpers define in here. */
+#include <linux/page-xa.h>
+
+
#endif /* __KERNEL__ */
#endif /* _LINUX_MM_H */
new file mode 100644
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Page eXclusive Acess (PXA) is a generic mechanism to allow exclusive access
+ * to a file back or an anonymous page. Exclusive access means that no one can
+ * write to page except the owner of the protection (but the page can still be
+ * read). The exclusive access can be _broken_ at anytime and this can not be
+ * block (so anyone using that feature must be ready to give away the exclusive
+ * access at _any_ time and must do so in a timely fashion).
+ *
+ * Using PXA allows to implement few different features:
+ * - KSM (Kernel Shared Memory) where page with same content are deduplicated
+ * using a unique page and all mapping are updated to read only. This allow
+ * to save memory for workload with a lot of pages in different process that
+ * end up with same content (multiple VM for instance).
+ *
+ * - NUMA duplication (sort of the opposite of KSM) here a page is duplicated
+ * into multiple read only copy with each copy using physical memory local a
+ * NUMA node (or a device). This allow to improve performance by minimizing
+ * cross node memory transaction and also help minimizing bus traffic. It
+ * does however use more memory, so what you gain in performance you loose
+ * in available resources.
+ *
+ * - Exclusive write access to a page, for instance you can use regular write
+ * instruction and still get atomic behavior (as you are the only being able
+ * to write you the garantee that no one can race with you).
+ *
+ * And any other use cases you can think of ...
+ *
+ * See Documentation/vm/page-xa.rst for further informations.
+ *
+ * Authors:
+ * Jérôme Glisse
+ */
+#ifndef LINUX_PAGE_XA_H
+#define LINUX_PAGE_XA_H
+
+#include <linux/page-flags.h>
+#include <linux/mm_types.h>
+
+
+/*
+ * MAPPING_NULL this is temporary define use to simplify the mass modificaitons
+ * to stop relying on struct page.mapping and instead pass down mapping pointer
+ * from the context (either from inode when in syscall operating on a file or
+ * from vma->vm_file when operating on some virtual address range).
+ *
+ * DO NOT USE ! THIS IS ONLY FOR SEMANTIC PATCHES SIMPLIFICATION !
+ */
+#define MAPPING_NULL NULL
+
+
+/**
+ * PageXA() - is page under exclusive acces ?
+ *
+ * This function checks if a page is under exclusive access.
+ *
+ * @page: Pointer to page to be queried.
+ * @Return: True, if it is under exclusive access, false otherwise.
+ */
+static inline bool PageXA(struct page *page)
+{
+ return false;
+}
+
+
+#endif /* LINUX_PAGE_XA_H */