Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753210AbdLDErJ (ORCPT ); Sun, 3 Dec 2017 23:47:09 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:41521 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752903AbdLDErF (ORCPT ); Sun, 3 Dec 2017 23:47:05 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20171204044703epoutp04b46f1ff1220f0a129765fe3b78e2049c~8-fmniJtr0114301143epoutp04X X-AuditID: b6c32a4b-cf7ff700000011c1-98-5a24d346580b From: Maninder Singh To: aryabinin@virtuozzo.com, glider@google.com, vyukov@google.com, mbenes@suse.cz, tglx@linutronix.de, pombredanne@nexb.com, mingo@kernel.org, gregkh@linuxfoundation.org, jpoimboe@redhat.com, akpm@linux-foundation.org, vbabka@suse.cz, sfr@canb.auug.org.au, mhocko@suse.com Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, a.sahrawat@samsung.com, pankaj.m@samsung.com, Maninder Singh , Vaneet Narang Subject: [PATCH 1/1] mm/page_owner: ignore everything below the IRQ entry point Date: Mon, 4 Dec 2017 10:13:20 +0530 Message-Id: <1512362600-40838-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA0WTfUxbVRjGd3rbe++IZTcd6rE60tywTDZb2trSg4Iwt2zXsESMxmS4Be7g hKL9wN52uvmHbDJwdTCpsYGNRTKXjZRitVIyPreVgYMRyNY0ViNgzDJEt0q36VTIsO3d4j8n z/O+v/c8OSfn0ITie1JJ19qc2GHjLSyZIe0bzX1WvSOSU66dDReia4MYdQT8JLrniVOoKTFM oI++DJDo4j9XAOq6OS9BkYEOEs35V2Vo9ItGKZrtiknQfEsJ6n4wCdDcrZAErS5Py1BoOEqh b4OfEyg8cQqgk4daAJq8eYwsyeIOxWIk1xl0cUOtEy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9zrBZb915lt9i8aSqzxaGTcxktZjf2MVqcetbD5iDi0XjjBpvHgk2lHnsm nmTz2LSqE0h8msTu8e7cOXaPEzN+s3jsn7uG3WP5ThOP9/uusnn0bVnF6LF+y1UWjzMLjrB7 fN4k5/F6/yHGAP4oLpuU1JzMstQifbsErow/Vy0LLspWHJy2mr2BcatEFyMnh4SAicTulhes XYxcHEICuxklru55wgSRkJb4+e89C4QtLLHy33N2iKJPjBJ7f3eygyTYBPQkVu3awwKSEBFY wSSxYdESsG5mgVuMEu3bK0BsYQF/ia7zk8HiLAKqEh9XzWQGsXkF3CXuz1zLCLFBTuLkscms Exh5FjAyrGKUTC0ozk3PLTYsMMxLLdcrTswtLs1L10vOz93ECI4SLc0djJeXxB9iFOBgVOLh VUhUiRJiTSwrrsw9xCjBwawkwrvgDFCINyWxsiq1KD++qDQntfgQozQHi5I479O8Y5FCAumJ JanZqakFqUUwWSYOTqkGxoisl2s9Iyd6Bu9kTN5bvFts/y5WkVN9MdtcZR/M3pz7gF/Lhj3b 5tC5MNu+Sb6bGLdkn2c5bH3lxpuotZMeXa7S//hy4bIZDTe+1BhEBUT2L9YLfXDlzUXld73F 2dFGKrs8s0w//3fh8vp4NidCkOuaSEeMQ8n2bb7fWTVXTjhd219urMU5V4mlOCPRUIu5qDgR AG17/3OOAgAA X-CMS-MailID: 20171204044702epcas5p3a8d82d304038fe197ab324a4e0267e55 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20171204044702epcas5p3a8d82d304038fe197ab324a4e0267e55 CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20171204044702epcas5p3a8d82d304038fe197ab324a4e0267e55 X-RootMTR: 20171204044702epcas5p3a8d82d304038fe197ab324a4e0267e55 References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3676 Lines: 115 Check whether the allocation happens in an IRQ handler. This lets us strip everything below the IRQ entry point to reduce the number of unique stack traces needed to be stored. so moved code of KASAN in generic file so that page_owner can also do same filteration. Initial KASAN commit id=be7635e7287e0e8013af3c89a6354a9e0182594c Signed-off-by: Vaneet Narang Signed-off-by: Maninder Singh --- include/linux/stacktrace.h | 25 +++++++++++++++++++++++++ mm/kasan/kasan.c | 22 ---------------------- mm/page_owner.c | 1 + 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h index ba29a06..2c1a562 100644 --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -3,6 +3,7 @@ #define __LINUX_STACKTRACE_H #include +#include struct task_struct; struct pt_regs; @@ -26,6 +27,28 @@ extern int save_stack_trace_tsk_reliable(struct task_struct *tsk, extern int snprint_stack_trace(char *buf, size_t size, struct stack_trace *trace, int spaces); +static inline int in_irqentry_text(unsigned long ptr) +{ + return (ptr >= (unsigned long)&__irqentry_text_start && + ptr < (unsigned long)&__irqentry_text_end) || + (ptr >= (unsigned long)&__softirqentry_text_start && + ptr < (unsigned long)&__softirqentry_text_end); +} + +static inline void filter_irq_stacks(struct stack_trace *trace) +{ + int i; + + if (!trace->nr_entries) + return; + for (i = 0; i < trace->nr_entries; i++) + if (in_irqentry_text(trace->entries[i])) { + /* Include the irqentry function into the stack. */ + trace->nr_entries = i + 1; + break; + } +} + #ifdef CONFIG_USER_STACKTRACE_SUPPORT extern void save_stack_trace_user(struct stack_trace *trace); #else @@ -38,6 +61,8 @@ extern int snprint_stack_trace(char *buf, size_t size, # define save_stack_trace_user(trace) do { } while (0) # define print_stack_trace(trace, spaces) do { } while (0) # define snprint_stack_trace(buf, size, trace, spaces) do { } while (0) +# define filter_irq_stacks(trace) do { } while (0) +# define in_irqentry_text(ptr) do { } while (0) # define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; }) #endif /* CONFIG_STACKTRACE */ diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index 405bba4..129e7b8 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -412,28 +412,6 @@ void kasan_poison_object_data(struct kmem_cache *cache, void *object) KASAN_KMALLOC_REDZONE); } -static inline int in_irqentry_text(unsigned long ptr) -{ - return (ptr >= (unsigned long)&__irqentry_text_start && - ptr < (unsigned long)&__irqentry_text_end) || - (ptr >= (unsigned long)&__softirqentry_text_start && - ptr < (unsigned long)&__softirqentry_text_end); -} - -static inline void filter_irq_stacks(struct stack_trace *trace) -{ - int i; - - if (!trace->nr_entries) - return; - for (i = 0; i < trace->nr_entries; i++) - if (in_irqentry_text(trace->entries[i])) { - /* Include the irqentry function into the stack. */ - trace->nr_entries = i + 1; - break; - } -} - static inline depot_stack_handle_t save_stack(gfp_t flags) { unsigned long entries[KASAN_STACK_DEPTH]; diff --git a/mm/page_owner.c b/mm/page_owner.c index 8602fb4..30e9cb2 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -148,6 +148,7 @@ static noinline depot_stack_handle_t save_stack(gfp_t flags) depot_stack_handle_t handle; save_stack_trace(&trace); + filter_irq_stacks(&trace); if (trace.nr_entries != 0 && trace.entries[trace.nr_entries-1] == ULONG_MAX) trace.nr_entries--; -- 1.9.1