X Tutup
Skip to content

Commit fe896d1

Browse files
JoonsooKimtorvalds
authored andcommitted
mm: introduce page reference manipulation functions
The success of CMA allocation largely depends on the success of migration and key factor of it is page reference count. Until now, page reference is manipulated by direct calling atomic functions so we cannot follow up who and where manipulate it. Then, it is hard to find actual reason of CMA allocation failure. CMA allocation should be guaranteed to succeed so finding offending place is really important. In this patch, call sites where page reference is manipulated are converted to introduced wrapper function. This is preparation step to add tracepoint to each page reference manipulation function. With this facility, we can easily find reason of CMA allocation failure. There is no functional change in this patch. In addition, this patch also converts reference read sites. It will help a second step that renames page._count to something else and prevents later attempt to direct access to it (Suggested by Andrew). Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Minchan Kim <minchan@kernel.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 444eb2a commit fe896d1

File tree

25 files changed

+134
-82
lines changed

25 files changed

+134
-82
lines changed

arch/mips/mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static inline void get_head_page_multiple(struct page *page, int nr)
6464
{
6565
VM_BUG_ON(page != compound_head(page));
6666
VM_BUG_ON(page_count(page) == 0);
67-
atomic_add(nr, &page->_count);
67+
page_ref_add(page, nr);
6868
SetPageReferenced(page);
6969
}
7070

arch/powerpc/mm/mmu_context_hash64.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ static void destroy_pagetable_page(struct mm_struct *mm)
118118
/* drop all the pending references */
119119
count = ((unsigned long)pte_frag & ~PAGE_MASK) >> PTE_FRAG_SIZE_SHIFT;
120120
/* We allow PTE_FRAG_NR fragments from a PTE page */
121-
count = atomic_sub_return(PTE_FRAG_NR - count, &page->_count);
122-
if (!count) {
121+
if (page_ref_sub_and_test(page, PTE_FRAG_NR - count)) {
123122
pgtable_page_dtor(page);
124123
free_hot_cold_page(page, 0);
125124
}

arch/powerpc/mm/pgtable_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static pte_t *__alloc_for_cache(struct mm_struct *mm, int kernel)
403403
* count.
404404
*/
405405
if (likely(!mm->context.pte_frag)) {
406-
atomic_set(&page->_count, PTE_FRAG_NR);
406+
set_page_count(page, PTE_FRAG_NR);
407407
mm->context.pte_frag = ret + PTE_FRAG_SIZE;
408408
}
409409
spin_unlock(&mm->page_table_lock);

arch/powerpc/platforms/512x/mpc512x_shared.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static struct fsl_diu_shared_fb __attribute__ ((__aligned__(8))) diu_shared_fb;
188188
static inline void mpc512x_free_bootmem(struct page *page)
189189
{
190190
BUG_ON(PageTail(page));
191-
BUG_ON(atomic_read(&page->_count) > 1);
191+
BUG_ON(page_ref_count(page) > 1);
192192
free_reserved_page(page);
193193
}
194194

arch/x86/mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static inline void get_head_page_multiple(struct page *page, int nr)
131131
{
132132
VM_BUG_ON_PAGE(page != compound_head(page), page);
133133
VM_BUG_ON_PAGE(page_count(page) == 0, page);
134-
atomic_add(nr, &page->_count);
134+
page_ref_add(page, nr);
135135
SetPageReferenced(page);
136136
}
137137

drivers/block/aoe/aoecmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ bio_pageinc(struct bio *bio)
875875
* compound pages is no longer allowed by the kernel.
876876
*/
877877
page = compound_head(bv.bv_page);
878-
atomic_inc(&page->_count);
878+
page_ref_inc(page);
879879
}
880880
}
881881

@@ -888,7 +888,7 @@ bio_pagedec(struct bio *bio)
888888

889889
bio_for_each_segment(bv, bio, iter) {
890890
page = compound_head(bv.bv_page);
891-
atomic_dec(&page->_count);
891+
page_ref_dec(page);
892892
}
893893
}
894894

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2944,7 +2944,7 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus,
29442944
/* change offset to the other half */
29452945
rxb->page_offset ^= GFAR_RXB_TRUESIZE;
29462946

2947-
atomic_inc(&page->_count);
2947+
page_ref_inc(page);
29482948

29492949
return true;
29502950
}

drivers/net/ethernet/intel/fm10k/fm10k_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static bool fm10k_can_reuse_rx_page(struct fm10k_rx_buffer *rx_buffer,
243243
/* Even if we own the page, we are not allowed to use atomic_set()
244244
* This would break get_page_unless_zero() users.
245245
*/
246-
atomic_inc(&page->_count);
246+
page_ref_inc(page);
247247

248248
return true;
249249
}

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6630,7 +6630,7 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer *rx_buffer,
66306630
/* Even if we own the page, we are not allowed to use atomic_set()
66316631
* This would break get_page_unless_zero() users.
66326632
*/
6633-
atomic_inc(&page->_count);
6633+
page_ref_inc(page);
66346634

66356635
return true;
66366636
}

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ static bool ixgbe_add_rx_frag(struct ixgbe_ring *rx_ring,
19421942
/* Even if we own the page, we are not allowed to use atomic_set()
19431943
* This would break get_page_unless_zero() users.
19441944
*/
1945-
atomic_inc(&page->_count);
1945+
page_ref_inc(page);
19461946

19471947
return true;
19481948
}

0 commit comments

Comments
 (0)
X Tutup