* [PATCH 2/3] Introduce VM_BUG_ON_VMA
2014-08-29 14:54 [PATCH 1/3] Introduce dump_vma Sasha Levin
@ 2014-08-29 14:54 ` Sasha Levin
2014-08-29 18:51 ` Naoya Horiguchi
2014-08-29 14:54 ` [PATCH 3/3] Convert a few VM_BUG_ON callers to VM_BUG_ON_VMA Sasha Levin
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Sasha Levin @ 2014-08-29 14:54 UTC (permalink / raw)
To: akpm
Cc: kirill.shutemov, khlebnikov, riel, mgorman, n-horiguchi, mhocko,
hughd, vbabka, walken, minchan, linux-kernel, linux-mm,
Sasha Levin
Very similar to VM_BUG_ON_PAGE but dumps VMA information instead.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
include/linux/mmdebug.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
index dfb9333..569e4c8 100644
--- a/include/linux/mmdebug.h
+++ b/include/linux/mmdebug.h
@@ -20,12 +20,20 @@ void dump_vma(const struct vm_area_struct *vma);
BUG(); \
} \
} while (0)
+#define VM_BUG_ON_VMA(cond, vma) \
+ do { \
+ if (unlikely(cond)) { \
+ dump_vma(vma); \
+ BUG(); \
+ } \
+ } while (0)
#define VM_WARN_ON(cond) WARN_ON(cond)
#define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond)
#define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format)
#else
#define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
#define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
+#define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond)
#define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
#define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
#define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
--
1.7.10.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] Introduce VM_BUG_ON_VMA
2014-08-29 14:54 ` [PATCH 2/3] Introduce VM_BUG_ON_VMA Sasha Levin
@ 2014-08-29 18:51 ` Naoya Horiguchi
0 siblings, 0 replies; 8+ messages in thread
From: Naoya Horiguchi @ 2014-08-29 18:51 UTC (permalink / raw)
To: Sasha Levin
Cc: akpm, kirill.shutemov, khlebnikov, riel, mgorman, mhocko, hughd,
vbabka, walken, minchan, linux-kernel, linux-mm
On Fri, Aug 29, 2014 at 10:54:18AM -0400, Sasha Levin wrote:
> Very similar to VM_BUG_ON_PAGE but dumps VMA information instead.
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> ---
> include/linux/mmdebug.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
> index dfb9333..569e4c8 100644
> --- a/include/linux/mmdebug.h
> +++ b/include/linux/mmdebug.h
> @@ -20,12 +20,20 @@ void dump_vma(const struct vm_area_struct *vma);
> BUG(); \
> } \
> } while (0)
> +#define VM_BUG_ON_VMA(cond, vma) \
> + do { \
> + if (unlikely(cond)) { \
> + dump_vma(vma); \
> + BUG(); \
> + } \
> + } while (0)
> #define VM_WARN_ON(cond) WARN_ON(cond)
> #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond)
> #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format)
> #else
> #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
> #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
> +#define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond)
> #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
> #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
> #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
> --
> 1.7.10.4
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] Convert a few VM_BUG_ON callers to VM_BUG_ON_VMA
2014-08-29 14:54 [PATCH 1/3] Introduce dump_vma Sasha Levin
2014-08-29 14:54 ` [PATCH 2/3] Introduce VM_BUG_ON_VMA Sasha Levin
@ 2014-08-29 14:54 ` Sasha Levin
2014-08-29 19:17 ` Naoya Horiguchi
2014-08-29 18:51 ` [PATCH 1/3] Introduce dump_vma Naoya Horiguchi
2014-08-29 19:37 ` Andrew Morton
3 siblings, 1 reply; 8+ messages in thread
From: Sasha Levin @ 2014-08-29 14:54 UTC (permalink / raw)
To: akpm
Cc: kirill.shutemov, khlebnikov, riel, mgorman, n-horiguchi, mhocko,
hughd, vbabka, walken, minchan, linux-kernel, linux-mm,
Sasha Levin
Trivially convert a few VM_BUG_ON calls to VM_BUG_ON_VMA to extract
more information when they trigger.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
include/linux/huge_mm.h | 2 +-
include/linux/rmap.h | 2 +-
mm/huge_memory.c | 6 +++---
mm/hugetlb.c | 14 +++++++-------
mm/interval_tree.c | 2 +-
mm/mlock.c | 4 ++--
mm/mmap.c | 6 +++---
mm/mremap.c | 2 +-
mm/rmap.c | 8 ++++----
9 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 63579cb..ad9051b 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -132,7 +132,7 @@ extern int __pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma,
static inline int pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma,
spinlock_t **ptl)
{
- VM_BUG_ON(!rwsem_is_locked(&vma->vm_mm->mmap_sem));
+ VM_BUG_ON_VMA(!rwsem_is_locked(&vma->vm_mm->mmap_sem), vma);
if (pmd_trans_huge(*pmd))
return __pmd_trans_huge_lock(pmd, vma, ptl);
else
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index be57450..c0c2bce 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -150,7 +150,7 @@ int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
static inline void anon_vma_merge(struct vm_area_struct *vma,
struct vm_area_struct *next)
{
- VM_BUG_ON(vma->anon_vma != next->anon_vma);
+ VM_BUG_ON_VMA(vma->anon_vma != next->anon_vma, vma);
unlink_anon_vmas(next);
}
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 7cfc325..d81f8ba 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1096,7 +1096,7 @@ int do_huge_pmd_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long mmun_end; /* For mmu_notifiers */
ptl = pmd_lockptr(mm, pmd);
- VM_BUG_ON(!vma->anon_vma);
+ VM_BUG_ON_VMA(!vma->anon_vma, vma);
haddr = address & HPAGE_PMD_MASK;
if (is_huge_zero_pmd(orig_pmd))
goto alloc;
@@ -2080,7 +2080,7 @@ int khugepaged_enter_vma_merge(struct vm_area_struct *vma)
if (vma->vm_ops)
/* khugepaged not yet working on file or special mappings */
return 0;
- VM_BUG_ON(vma->vm_flags & VM_NO_THP);
+ VM_BUG_ON_VMA(vma->vm_flags & VM_NO_THP, vma);
hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
hend = vma->vm_end & HPAGE_PMD_MASK;
if (hstart < hend)
@@ -2403,7 +2403,7 @@ static bool hugepage_vma_check(struct vm_area_struct *vma)
return false;
if (is_vma_temporary_stack(vma))
return false;
- VM_BUG_ON(vma->vm_flags & VM_NO_THP);
+ VM_BUG_ON_VMA(vma->vm_flags & VM_NO_THP, vma);
return true;
}
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index eeceeeb..9fd7227 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -434,7 +434,7 @@ static inline struct resv_map *inode_resv_map(struct inode *inode)
static struct resv_map *vma_resv_map(struct vm_area_struct *vma)
{
- VM_BUG_ON(!is_vm_hugetlb_page(vma));
+ VM_BUG_ON_VMA(!is_vm_hugetlb_page(vma), vma);
if (vma->vm_flags & VM_MAYSHARE) {
struct address_space *mapping = vma->vm_file->f_mapping;
struct inode *inode = mapping->host;
@@ -449,8 +449,8 @@ static struct resv_map *vma_resv_map(struct vm_area_struct *vma)
static void set_vma_resv_map(struct vm_area_struct *vma, struct resv_map *map)
{
- VM_BUG_ON(!is_vm_hugetlb_page(vma));
- VM_BUG_ON(vma->vm_flags & VM_MAYSHARE);
+ VM_BUG_ON_VMA(!is_vm_hugetlb_page(vma), vma);
+ VM_BUG_ON_VMA(vma->vm_flags & VM_MAYSHARE, vma);
set_vma_private_data(vma, (get_vma_private_data(vma) &
HPAGE_RESV_MASK) | (unsigned long)map);
@@ -458,15 +458,15 @@ static void set_vma_resv_map(struct vm_area_struct *vma, struct resv_map *map)
static void set_vma_resv_flags(struct vm_area_struct *vma, unsigned long flags)
{
- VM_BUG_ON(!is_vm_hugetlb_page(vma));
- VM_BUG_ON(vma->vm_flags & VM_MAYSHARE);
+ VM_BUG_ON_VMA(!is_vm_hugetlb_page(vma), vma);
+ VM_BUG_ON_VMA(vma->vm_flags & VM_MAYSHARE, vma);
set_vma_private_data(vma, get_vma_private_data(vma) | flags);
}
static int is_vma_resv_set(struct vm_area_struct *vma, unsigned long flag)
{
- VM_BUG_ON(!is_vm_hugetlb_page(vma));
+ VM_BUG_ON_VMA(!is_vm_hugetlb_page(vma), vma);
return (get_vma_private_data(vma) & flag) != 0;
}
@@ -474,7 +474,7 @@ static int is_vma_resv_set(struct vm_area_struct *vma, unsigned long flag)
/* Reset counters to 0 and clear all HPAGE_RESV_* flags */
void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
{
- VM_BUG_ON(!is_vm_hugetlb_page(vma));
+ VM_BUG_ON_VMA(!is_vm_hugetlb_page(vma), vma);
if (!(vma->vm_flags & VM_MAYSHARE))
vma->vm_private_data = (void *)0;
}
diff --git a/mm/interval_tree.c b/mm/interval_tree.c
index 4a5822a..8da581f 100644
--- a/mm/interval_tree.c
+++ b/mm/interval_tree.c
@@ -34,7 +34,7 @@ void vma_interval_tree_insert_after(struct vm_area_struct *node,
struct vm_area_struct *parent;
unsigned long last = vma_last_pgoff(node);
- VM_BUG_ON(vma_start_pgoff(node) != vma_start_pgoff(prev));
+ VM_BUG_ON_VMA(vma_start_pgoff(node) != vma_start_pgoff(prev), node);
if (!prev->shared.linear.rb.rb_right) {
parent = prev;
diff --git a/mm/mlock.c b/mm/mlock.c
index ce84cb0..d5d09d0 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -233,8 +233,8 @@ long __mlock_vma_pages_range(struct vm_area_struct *vma,
VM_BUG_ON(start & ~PAGE_MASK);
VM_BUG_ON(end & ~PAGE_MASK);
- VM_BUG_ON(start < vma->vm_start);
- VM_BUG_ON(end > vma->vm_end);
+ VM_BUG_ON_VMA(start < vma->vm_start, vma);
+ VM_BUG_ON_VMA(end > vma->vm_end, vma);
VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem));
gup_flags = FOLL_TOUCH | FOLL_MLOCK;
diff --git a/mm/mmap.c b/mm/mmap.c
index 45dc9ac..9351482 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -786,8 +786,8 @@ again: remove_next = 1 + (end > next->vm_end);
if (!anon_vma && adjust_next)
anon_vma = next->anon_vma;
if (anon_vma) {
- VM_BUG_ON(adjust_next && next->anon_vma &&
- anon_vma != next->anon_vma);
+ VM_BUG_ON_VMA(adjust_next && next->anon_vma &&
+ anon_vma != next->anon_vma, next);
anon_vma_lock_write(anon_vma);
anon_vma_interval_tree_pre_update_vma(vma);
if (adjust_next)
@@ -2917,7 +2917,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
* safe. It is only safe to keep the vm_pgoff
* linear if there are no pages mapped yet.
*/
- VM_BUG_ON(faulted_in_anon_vma);
+ VM_BUG_ON_VMA(faulted_in_anon_vma, new_vma);
*vmap = vma = new_vma;
}
*need_rmap_locks = (new_vma->vm_pgoff <= vma->vm_pgoff);
diff --git a/mm/mremap.c b/mm/mremap.c
index 05f1180..ba7d241 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -195,7 +195,7 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
if (pmd_trans_huge(*old_pmd)) {
int err = 0;
if (extent == HPAGE_PMD_SIZE) {
- VM_BUG_ON(vma->vm_file || !vma->anon_vma);
+ VM_BUG_ON_VMA(vma->vm_file || !vma->anon_vma, vma);
/* See comment in move_ptes() */
if (need_rmap_locks)
anon_vma_lock_write(vma->anon_vma);
diff --git a/mm/rmap.c b/mm/rmap.c
index 3e8491c..5fbd0fe 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -527,7 +527,7 @@ vma_address(struct page *page, struct vm_area_struct *vma)
unsigned long address = __vma_address(page, vma);
/* page should be within @vma mapping range */
- VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
+ VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma);
return address;
}
@@ -897,7 +897,7 @@ void page_move_anon_rmap(struct page *page,
struct anon_vma *anon_vma = vma->anon_vma;
VM_BUG_ON_PAGE(!PageLocked(page), page);
- VM_BUG_ON(!anon_vma);
+ VM_BUG_ON_VMA(!anon_vma, vma);
VM_BUG_ON_PAGE(page->index != linear_page_index(vma, address), page);
anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
@@ -1024,7 +1024,7 @@ void do_page_add_anon_rmap(struct page *page,
void page_add_new_anon_rmap(struct page *page,
struct vm_area_struct *vma, unsigned long address)
{
- VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
+ VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma);
SetPageSwapBacked(page);
atomic_set(&page->_mapcount, 0); /* increment count (starts at -1) */
if (PageTransHuge(page))
@@ -1666,7 +1666,7 @@ static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
* structure at mapping cannot be freed and reused yet,
* so we can safely take mapping->i_mmap_mutex.
*/
- VM_BUG_ON(!PageLocked(page));
+ VM_BUG_ON_PAGE(!PageLocked(page), page);
if (!mapping)
return ret;
--
1.7.10.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] Convert a few VM_BUG_ON callers to VM_BUG_ON_VMA
2014-08-29 14:54 ` [PATCH 3/3] Convert a few VM_BUG_ON callers to VM_BUG_ON_VMA Sasha Levin
@ 2014-08-29 19:17 ` Naoya Horiguchi
2014-08-29 19:32 ` Sasha Levin
0 siblings, 1 reply; 8+ messages in thread
From: Naoya Horiguchi @ 2014-08-29 19:17 UTC (permalink / raw)
To: Sasha Levin
Cc: akpm, kirill.shutemov, khlebnikov, riel, mgorman, mhocko, hughd,
vbabka, walken, minchan, linux-kernel, linux-mm
On Fri, Aug 29, 2014 at 10:54:19AM -0400, Sasha Levin wrote:
> Trivially convert a few VM_BUG_ON calls to VM_BUG_ON_VMA to extract
> more information when they trigger.
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
...
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 3e8491c..5fbd0fe 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
...
> @@ -897,7 +897,7 @@ void page_move_anon_rmap(struct page *page,
> struct anon_vma *anon_vma = vma->anon_vma;
>
> VM_BUG_ON_PAGE(!PageLocked(page), page);
> - VM_BUG_ON(!anon_vma);
> + VM_BUG_ON_VMA(!anon_vma, vma);
> VM_BUG_ON_PAGE(page->index != linear_page_index(vma, address), page);
This line contains both of vma and page.
But I'm not sure that introducing another macro like VM_BUG_ON_PAGE_AND_VMA()
is worth doing. So it's ok for me to keep it untouched.
>
> anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
> @@ -1024,7 +1024,7 @@ void do_page_add_anon_rmap(struct page *page,
> void page_add_new_anon_rmap(struct page *page,
> struct vm_area_struct *vma, unsigned long address)
> {
> - VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
> + VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma);
> SetPageSwapBacked(page);
> atomic_set(&page->_mapcount, 0); /* increment count (starts at -1) */
> if (PageTransHuge(page))
> @@ -1666,7 +1666,7 @@ static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
> * structure at mapping cannot be freed and reused yet,
> * so we can safely take mapping->i_mmap_mutex.
> */
> - VM_BUG_ON(!PageLocked(page));
> + VM_BUG_ON_PAGE(!PageLocked(page), page);
This is not the replacement with VM_BUG_ON_VMA(), but it's fine :)
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Thanks,
Naoya Horiguchi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] Convert a few VM_BUG_ON callers to VM_BUG_ON_VMA
2014-08-29 19:17 ` Naoya Horiguchi
@ 2014-08-29 19:32 ` Sasha Levin
0 siblings, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2014-08-29 19:32 UTC (permalink / raw)
To: Naoya Horiguchi
Cc: akpm, kirill.shutemov, khlebnikov, riel, mgorman, mhocko, hughd,
vbabka, walken, minchan, linux-kernel, linux-mm
On 08/29/2014 03:17 PM, Naoya Horiguchi wrote:
>> - VM_BUG_ON(!PageLocked(page));
>> > + VM_BUG_ON_PAGE(!PageLocked(page), page);
> This is not the replacement with VM_BUG_ON_VMA(), but it's fine :)
Woops, I was on a spree and got this one as well.
Thanks for the review Naoya!
Thanks,
Sasha
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] Introduce dump_vma
2014-08-29 14:54 [PATCH 1/3] Introduce dump_vma Sasha Levin
2014-08-29 14:54 ` [PATCH 2/3] Introduce VM_BUG_ON_VMA Sasha Levin
2014-08-29 14:54 ` [PATCH 3/3] Convert a few VM_BUG_ON callers to VM_BUG_ON_VMA Sasha Levin
@ 2014-08-29 18:51 ` Naoya Horiguchi
2014-08-29 19:37 ` Andrew Morton
3 siblings, 0 replies; 8+ messages in thread
From: Naoya Horiguchi @ 2014-08-29 18:51 UTC (permalink / raw)
To: Sasha Levin
Cc: akpm, kirill.shutemov, khlebnikov, riel, mgorman, mhocko, hughd,
vbabka, walken, minchan, linux-kernel, linux-mm
On Fri, Aug 29, 2014 at 10:54:17AM -0400, Sasha Levin wrote:
> Introduce a helper to dump information about a VMA, this also
> makes dump_page_flags more generic and re-uses that so the
> output looks very similar to dump_page:
>
> [ 61.903437] vma ffff88070f88be00 start 00007fff25970000 end 00007fff25992000
> [ 61.903437] next ffff88070facd600 prev ffff88070face400 mm ffff88070fade000
> [ 61.903437] prot 8000000000000025 anon_vma ffff88070fa1e200 vm_ops (null)
> [ 61.903437] pgoff 7ffffffdd file (null) private_data (null)
> [ 61.909129] flags: 0x100173(read|write|mayread|maywrite|mayexec|growsdown|account)
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
# checkpatch.pl shows warnings on using printk(KERN_ALERT), but there
# are many other lines using printk in this file, so it should be done
# as a whole in a separate patch.
Thanks,
Naoya Horiguchi
> ---
> include/linux/mmdebug.h | 2 ++
> mm/page_alloc.c | 77 +++++++++++++++++++++++++++++++++++++++++------
> 2 files changed, 70 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
> index 2f348d0..dfb9333 100644
> --- a/include/linux/mmdebug.h
> +++ b/include/linux/mmdebug.h
> @@ -4,10 +4,12 @@
> #include <linux/stringify.h>
>
> struct page;
> +struct vm_area_struct;
>
> extern void dump_page(struct page *page, const char *reason);
> extern void dump_page_badflags(struct page *page, const char *reason,
> unsigned long badflags);
> +void dump_vma(const struct vm_area_struct *vma);
>
> #ifdef CONFIG_DEBUG_VM
> #define VM_BUG_ON(cond) BUG_ON(cond)
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index f86023b..add97b8 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -6628,27 +6628,26 @@ static const struct trace_print_flags pageflag_names[] = {
> #endif
> };
>
> -static void dump_page_flags(unsigned long flags)
> +static void dump_flags(unsigned long flags,
> + const struct trace_print_flags *names, int count)
> {
> const char *delim = "";
> unsigned long mask;
> int i;
>
> - BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS);
> -
> - printk(KERN_ALERT "page flags: %#lx(", flags);
> + printk(KERN_ALERT "flags: %#lx(", flags);
>
> /* remove zone id */
> flags &= (1UL << NR_PAGEFLAGS) - 1;
>
> - for (i = 0; i < ARRAY_SIZE(pageflag_names) && flags; i++) {
> + for (i = 0; i < count && flags; i++) {
>
> - mask = pageflag_names[i].mask;
> + mask = names[i].mask;
> if ((flags & mask) != mask)
> continue;
>
> flags &= ~mask;
> - printk("%s%s", delim, pageflag_names[i].name);
> + printk("%s%s", delim, names[i].name);
> delim = "|";
> }
>
> @@ -6666,12 +6665,14 @@ void dump_page_badflags(struct page *page, const char *reason,
> "page:%p count:%d mapcount:%d mapping:%p index:%#lx\n",
> page, atomic_read(&page->_count), page_mapcount(page),
> page->mapping, page->index);
> - dump_page_flags(page->flags);
> + BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS);
> + dump_flags(page->flags, pageflag_names, ARRAY_SIZE(pageflag_names));
> if (reason)
> pr_alert("page dumped because: %s\n", reason);
> if (page->flags & badflags) {
> pr_alert("bad because of flags:\n");
> - dump_page_flags(page->flags & badflags);
> + dump_flags(page->flags & badflags,
> + pageflag_names, ARRAY_SIZE(pageflag_names));
> }
> mem_cgroup_print_bad_page(page);
> }
> @@ -6681,3 +6682,61 @@ void dump_page(struct page *page, const char *reason)
> dump_page_badflags(page, reason, 0);
> }
> EXPORT_SYMBOL(dump_page);
> +
> +static const struct trace_print_flags vmaflags_names[] = {
> + {VM_READ, "read" },
> + {VM_WRITE, "write" },
> + {VM_EXEC, "exec" },
> + {VM_SHARED, "shared" },
> + {VM_MAYREAD, "mayread" },
> + {VM_MAYWRITE, "maywrite" },
> + {VM_MAYEXEC, "mayexec" },
> + {VM_MAYSHARE, "mayshare" },
> + {VM_GROWSDOWN, "growsdown" },
> + {VM_PFNMAP, "pfnmap" },
> + {VM_DENYWRITE, "denywrite" },
> + {VM_LOCKED, "locked" },
> + {VM_IO, "io" },
> + {VM_SEQ_READ, "seqread" },
> + {VM_RAND_READ, "randread" },
> + {VM_DONTCOPY, "dontcopy" },
> + {VM_DONTEXPAND, "dontexpand" },
> + {VM_ACCOUNT, "account" },
> + {VM_NORESERVE, "noreserve" },
> + {VM_HUGETLB, "hugetlb" },
> + {VM_NONLINEAR, "nonlinear" },
> +#if defined(CONFIG_X86)
> + {VM_PAT, "pat" },
> +#elif defined(CONFIG_PPC)
> + {VM_SAO, "sao" },
> +#elif defined(CONFIG_PARISC) || defined(CONFIG_METAG) || defined(CONFIG_IA64)
> + {VM_GROWSUP, "growsup" },
> +#elif !defined(CONFIG_MMU)
> + {VM_MAPPED_COPY, "mappedcopy" },
> +#else
> + {VM_ARCH_1, "arch_1" },
> +#endif
> + {VM_DONTDUMP, "dontdump" },
> +#ifdef CONFIG_MEM_SOFT_DIRTY
> + {VM_SOFTDIRTY, "softdirty" },
> +#endif
> + {VM_MIXEDMAP, "mixedmap" },
> + {VM_HUGEPAGE, "hugepage" },
> + {VM_NOHUGEPAGE, "nohugepage" },
> + {VM_MERGEABLE, "mergeable" },
> +};
> +
> +void dump_vma(const struct vm_area_struct *vma)
> +{
> + printk(KERN_ALERT
> + "vma %p start %p end %p\n"
> + "next %p prev %p mm %p\n"
> + "prot %lx anon_vma %p vm_ops %p\n"
> + "pgoff %lx file %p private_data %p\n",
> + vma, (void *)vma->vm_start, (void *)vma->vm_end, vma->vm_next,
> + vma->vm_prev, vma->vm_mm, vma->vm_page_prot.pgprot,
> + vma->anon_vma, vma->vm_ops, vma->vm_pgoff,
> + vma->vm_file, vma->vm_private_data);
> + dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names));
> +}
> +EXPORT_SYMBOL(dump_vma);
> --
> 1.7.10.4
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] Introduce dump_vma
2014-08-29 14:54 [PATCH 1/3] Introduce dump_vma Sasha Levin
` (2 preceding siblings ...)
2014-08-29 18:51 ` [PATCH 1/3] Introduce dump_vma Naoya Horiguchi
@ 2014-08-29 19:37 ` Andrew Morton
3 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2014-08-29 19:37 UTC (permalink / raw)
To: Sasha Levin
Cc: kirill.shutemov, khlebnikov, riel, mgorman, n-horiguchi, mhocko,
hughd, vbabka, walken, minchan, linux-kernel, linux-mm
On Fri, 29 Aug 2014 10:54:17 -0400 Sasha Levin <sasha.levin@oracle.com> wrote:
> Introduce a helper to dump information about a VMA, this also
> makes dump_page_flags more generic and re-uses that so the
> output looks very similar to dump_page:
>
That's another kilobyte which we don't actually use unless
CONFIG_DEBUG_VM, so how about we do
--- a/mm/page_alloc.c~introduce-dump_vma-fix
+++ a/mm/page_alloc.c
@@ -6683,6 +6683,8 @@ void dump_page(struct page *page, const
}
EXPORT_SYMBOL(dump_page);
+#ifdef CONFIG_DEBUG_VM
+
static const struct trace_print_flags vmaflags_names[] = {
{VM_READ, "read" },
{VM_WRITE, "write" },
@@ -6740,3 +6742,5 @@ void dump_vma(const struct vm_area_struc
dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names));
}
EXPORT_SYMBOL(dump_vma);
+
+#endif /* CONFIG_DEBUG_VM */
until someone needs it from non-debug code?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread