From: Alexander Potapenko <glider@google.com>
To: Maninder Singh <maninder1.s@samsung.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>,
mbenes@suse.cz, Thomas Gleixner <tglx@linutronix.de>,
pombredanne@nexb.com, Ingo Molnar <mingo@kernel.org>,
gregkh@linuxfoundation.org, Josh Poimboeuf <jpoimboe@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
Stephen Rothwell <sfr@canb.auug.org.au>,
mhocko@suse.com, LKML <linux-kernel@vger.kernel.org>,
kasan-dev <kasan-dev@googlegroups.com>,
Linux Memory Management List <linux-mm@kvack.org>,
a.sahrawat@samsung.com, pankaj.m@samsung.com,
Vaneet Narang <v.narang@samsung.com>,
Dmitriy Vyukov <dvyukov@google.com>
Subject: Re: [PATCH 1/1] mm/page_owner: ignore everything below the IRQ entry point
Date: Tue, 5 Dec 2017 15:40:27 +0100 [thread overview]
Message-ID: <CAG_fn=Vjh_+11vSdjAv=0d6KYv7uc0JNYLSU8iTmTtbkxx5YTA@mail.gmail.com> (raw)
In-Reply-To: <1512362600-40838-1-git-send-email-maninder1.s@samsung.com>
On Mon, Dec 4, 2017 at 5:43 AM, Maninder Singh <maninder1.s@samsung.com> wrote:
> 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 <v.narang@samsung.com>
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
> ---
> 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 <linux/types.h>
> +#include <asm-generic/sections.h>
>
> 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
>
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
prev parent reply other threads:[~2017-12-05 14:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171204044702epcas5p3a8d82d304038fe197ab324a4e0267e55@epcas5p3.samsung.com>
2017-12-04 4:43 ` [PATCH 1/1] mm/page_owner: ignore everything below the IRQ entry point Maninder Singh
2017-12-05 5:39 ` kbuild test robot
2017-12-05 6:05 ` kbuild test robot
2017-12-05 14:40 ` Alexander Potapenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAG_fn=Vjh_+11vSdjAv=0d6KYv7uc0JNYLSU8iTmTtbkxx5YTA@mail.gmail.com' \
--to=glider@google.com \
--cc=a.sahrawat@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jpoimboe@redhat.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maninder1.s@samsung.com \
--cc=mbenes@suse.cz \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=pankaj.m@samsung.com \
--cc=pombredanne@nexb.com \
--cc=sfr@canb.auug.org.au \
--cc=tglx@linutronix.de \
--cc=v.narang@samsung.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).