Re: [RFC 03/11] mm: debug: dump VMA into a string rather than directly on screen
From: Kirill A. Shutemov
Date: Thu Apr 30 2015 - 12:18:34 EST
On Tue, Apr 14, 2015 at 04:56:25PM -0400, Sasha Levin wrote:
> This lets us use regular string formatting code to dump VMAs, use it
> in VM_BUG_ON_VMA instead of just printing it to screen as well.
>
> Signed-off-by: Sasha Levin <sasha.levin@xxxxxxxxxx>
> ---
> include/linux/mmdebug.h | 8 ++++++--
> lib/vsprintf.c | 7 +++++--
> mm/debug.c | 26 ++++++++++++++------------
> 3 files changed, 25 insertions(+), 16 deletions(-)
>
> diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
> index 877ef22..506e405 100644
> --- a/include/linux/mmdebug.h
> +++ b/include/linux/mmdebug.h
> @@ -10,10 +10,10 @@ struct mm_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);
> void dump_mm(const struct mm_struct *mm);
>
> #ifdef CONFIG_DEBUG_VM
> +char *format_vma(const struct vm_area_struct *vma, char *buf, char *end);
> #define VM_BUG_ON(cond) BUG_ON(cond)
> #define VM_BUG_ON_PAGE(cond, page) \
> do { \
> @@ -25,7 +25,7 @@ void dump_mm(const struct mm_struct *mm);
> #define VM_BUG_ON_VMA(cond, vma) \
> do { \
> if (unlikely(cond)) { \
> - dump_vma(vma); \
> + pr_emerg("%pZv", vma); \
> BUG(); \
> } \
> } while (0)
> @@ -40,6 +40,10 @@ void dump_mm(const struct mm_struct *mm);
> #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond)
> #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format)
> #else
> +static char *format_vma(const struct vm_area_struct *vma, char *buf, char *end)
> +{
Again: print address ?
> + return buf;
> +}
> #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)
--
Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/