aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/mm.h14
-rw-r--r--mm/memcontrol.c12
-rw-r--r--mm/memory-failure.c12
3 files changed, 26 insertions, 12 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9c2695beab86..ce97a2bb0b19 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -450,6 +450,20 @@ static inline int compound_order(struct page *page)
450 return (unsigned long)page[1].lru.prev; 450 return (unsigned long)page[1].lru.prev;
451} 451}
452 452
453static inline int compound_trans_order(struct page *page)
454{
455 int order;
456 unsigned long flags;
457
458 if (!PageHead(page))
459 return 0;
460
461 flags = compound_lock_irqsave(page);
462 order = compound_order(page);
463 compound_unlock_irqrestore(page, flags);
464 return order;
465}
466
453static inline void set_compound_order(struct page *page, unsigned long order) 467static inline void set_compound_order(struct page *page, unsigned long order)
454{ 468{
455 page[1].lru.prev = (void *)order; 469 page[1].lru.prev = (void *)order;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f4ea3410fb4d..741206ffdace 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1027,10 +1027,6 @@ mem_cgroup_get_reclaim_stat_from_page(struct page *page)
1027{ 1027{
1028 struct page_cgroup *pc; 1028 struct page_cgroup *pc;
1029 struct mem_cgroup_per_zone *mz; 1029 struct mem_cgroup_per_zone *mz;
1030 int page_size = PAGE_SIZE;
1031
1032 if (PageTransHuge(page))
1033 page_size <<= compound_order(page);
1034 1030
1035 if (mem_cgroup_disabled()) 1031 if (mem_cgroup_disabled())
1036 return NULL; 1032 return NULL;
@@ -2286,8 +2282,10 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
2286 int ret; 2282 int ret;
2287 int page_size = PAGE_SIZE; 2283 int page_size = PAGE_SIZE;
2288 2284
2289 if (PageTransHuge(page)) 2285 if (PageTransHuge(page)) {
2290 page_size <<= compound_order(page); 2286 page_size <<= compound_order(page);
2287 VM_BUG_ON(!PageTransHuge(page));
2288 }
2291 2289
2292 pc = lookup_page_cgroup(page); 2290 pc = lookup_page_cgroup(page);
2293 /* can happen at boot */ 2291 /* can happen at boot */
@@ -2558,8 +2556,10 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
2558 if (PageSwapCache(page)) 2556 if (PageSwapCache(page))
2559 return NULL; 2557 return NULL;
2560 2558
2561 if (PageTransHuge(page)) 2559 if (PageTransHuge(page)) {
2562 page_size <<= compound_order(page); 2560 page_size <<= compound_order(page);
2561 VM_BUG_ON(!PageTransHuge(page));
2562 }
2563 2563
2564 count = page_size >> PAGE_SHIFT; 2564 count = page_size >> PAGE_SHIFT;
2565 /* 2565 /*
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 1b43d0ffff65..548fbd70f026 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -203,7 +203,7 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
203#ifdef __ARCH_SI_TRAPNO 203#ifdef __ARCH_SI_TRAPNO
204 si.si_trapno = trapno; 204 si.si_trapno = trapno;
205#endif 205#endif
206 si.si_addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT; 206 si.si_addr_lsb = compound_trans_order(compound_head(page)) + PAGE_SHIFT;
207 /* 207 /*
208 * Don't use force here, it's convenient if the signal 208 * Don't use force here, it's convenient if the signal
209 * can be temporarily blocked. 209 * can be temporarily blocked.
@@ -930,7 +930,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
930static void set_page_hwpoison_huge_page(struct page *hpage) 930static void set_page_hwpoison_huge_page(struct page *hpage)
931{ 931{
932 int i; 932 int i;
933 int nr_pages = 1 << compound_order(hpage); 933 int nr_pages = 1 << compound_trans_order(hpage);
934 for (i = 0; i < nr_pages; i++) 934 for (i = 0; i < nr_pages; i++)
935 SetPageHWPoison(hpage + i); 935 SetPageHWPoison(hpage + i);
936} 936}
@@ -938,7 +938,7 @@ static void set_page_hwpoison_huge_page(struct page *hpage)
938static void clear_page_hwpoison_huge_page(struct page *hpage) 938static void clear_page_hwpoison_huge_page(struct page *hpage)
939{ 939{
940 int i; 940 int i;
941 int nr_pages = 1 << compound_order(hpage); 941 int nr_pages = 1 << compound_trans_order(hpage);
942 for (i = 0; i < nr_pages; i++) 942 for (i = 0; i < nr_pages; i++)
943 ClearPageHWPoison(hpage + i); 943 ClearPageHWPoison(hpage + i);
944} 944}
@@ -968,7 +968,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
968 return 0; 968 return 0;
969 } 969 }
970 970
971 nr_pages = 1 << compound_order(hpage); 971 nr_pages = 1 << compound_trans_order(hpage);
972 atomic_long_add(nr_pages, &mce_bad_pages); 972 atomic_long_add(nr_pages, &mce_bad_pages);
973 973
974 /* 974 /*
@@ -1166,7 +1166,7 @@ int unpoison_memory(unsigned long pfn)
1166 return 0; 1166 return 0;
1167 } 1167 }
1168 1168
1169 nr_pages = 1 << compound_order(page); 1169 nr_pages = 1 << compound_trans_order(page);
1170 1170
1171 if (!get_page_unless_zero(page)) { 1171 if (!get_page_unless_zero(page)) {
1172 /* 1172 /*
@@ -1304,7 +1304,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
1304 } 1304 }
1305done: 1305done:
1306 if (!PageHWPoison(hpage)) 1306 if (!PageHWPoison(hpage))
1307 atomic_long_add(1 << compound_order(hpage), &mce_bad_pages); 1307 atomic_long_add(1 << compound_trans_order(hpage), &mce_bad_pages);
1308 set_page_hwpoison_huge_page(hpage); 1308 set_page_hwpoison_huge_page(hpage);
1309 dequeue_hwpoisoned_huge_page(hpage); 1309 dequeue_hwpoisoned_huge_page(hpage);
1310 /* keep elevated page count for bad page */ 1310 /* keep elevated page count for bad page */