diff options
author | Song Liu <songliubraving@fb.com> | 2019-09-23 18:38:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-24 18:54:11 -0400 |
commit | 010c164a5fa7e169deab0a4d8211611f1930c1cd (patch) | |
tree | fb07bdd2cf844ccf1e1aaf6fc40e42399fb0dc19 | |
parent | 87eaceb3faa59b9b4d940ec9554ce251325d83fe (diff) |
mm: move memcmp_pages() and pages_identical()
Patch series "THP aware uprobe", v13.
This patchset makes uprobe aware of THPs.
Currently, when uprobe is attached to text on THP, the page is split by
FOLL_SPLIT. As a result, uprobe eliminates the performance benefit of
THP.
This set makes uprobe THP-aware. Instead of FOLL_SPLIT, we introduces
FOLL_SPLIT_PMD, which only split PMD for uprobe.
After all uprobes within the THP are removed, the PTE-mapped pages are
regrouped as huge PMD.
This set (plus a few THP patches) is also available at
https://github.com/liu-song-6/linux/tree/uprobe-thp
This patch (of 6):
Move memcmp_pages() to mm/util.c and pages_identical() to mm.h, so that we
can use them in other files.
Link: http://lkml.kernel.org/r/20190815164525.1848545-2-songliubraving@fb.com
Signed-off-by: Song Liu <songliubraving@fb.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox <matthew.wilcox@oracle.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/mm.h | 7 | ||||
-rw-r--r-- | mm/ksm.c | 18 | ||||
-rw-r--r-- | mm/util.c | 13 |
3 files changed, 20 insertions, 18 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 57a9fa34f159..0ac87d9ee9d8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -2868,5 +2868,12 @@ void __init setup_nr_node_ids(void); | |||
2868 | static inline void setup_nr_node_ids(void) {} | 2868 | static inline void setup_nr_node_ids(void) {} |
2869 | #endif | 2869 | #endif |
2870 | 2870 | ||
2871 | extern int memcmp_pages(struct page *page1, struct page *page2); | ||
2872 | |||
2873 | static inline int pages_identical(struct page *page1, struct page *page2) | ||
2874 | { | ||
2875 | return !memcmp_pages(page1, page2); | ||
2876 | } | ||
2877 | |||
2871 | #endif /* __KERNEL__ */ | 2878 | #endif /* __KERNEL__ */ |
2872 | #endif /* _LINUX_MM_H */ | 2879 | #endif /* _LINUX_MM_H */ |
@@ -1029,24 +1029,6 @@ static u32 calc_checksum(struct page *page) | |||
1029 | return checksum; | 1029 | return checksum; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | static int memcmp_pages(struct page *page1, struct page *page2) | ||
1033 | { | ||
1034 | char *addr1, *addr2; | ||
1035 | int ret; | ||
1036 | |||
1037 | addr1 = kmap_atomic(page1); | ||
1038 | addr2 = kmap_atomic(page2); | ||
1039 | ret = memcmp(addr1, addr2, PAGE_SIZE); | ||
1040 | kunmap_atomic(addr2); | ||
1041 | kunmap_atomic(addr1); | ||
1042 | return ret; | ||
1043 | } | ||
1044 | |||
1045 | static inline int pages_identical(struct page *page1, struct page *page2) | ||
1046 | { | ||
1047 | return !memcmp_pages(page1, page2); | ||
1048 | } | ||
1049 | |||
1050 | static int write_protect_page(struct vm_area_struct *vma, struct page *page, | 1032 | static int write_protect_page(struct vm_area_struct *vma, struct page *page, |
1051 | pte_t *orig_pte) | 1033 | pte_t *orig_pte) |
1052 | { | 1034 | { |
@@ -783,3 +783,16 @@ out_mm: | |||
783 | out: | 783 | out: |
784 | return res; | 784 | return res; |
785 | } | 785 | } |
786 | |||
787 | int memcmp_pages(struct page *page1, struct page *page2) | ||
788 | { | ||
789 | char *addr1, *addr2; | ||
790 | int ret; | ||
791 | |||
792 | addr1 = kmap_atomic(page1); | ||
793 | addr2 = kmap_atomic(page2); | ||
794 | ret = memcmp(addr1, addr2, PAGE_SIZE); | ||
795 | kunmap_atomic(addr2); | ||
796 | kunmap_atomic(addr1); | ||
797 | return ret; | ||
798 | } | ||